From a14b72ba413fde3a7c7ace3153ca45c551c17bdd Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Fri, 24 Jun 2022 07:48:45 -0600 Subject: zephyr: generic button config driver Generic button config driver for zephyr BUG=b:234728861 BRANCH=none TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs Change-Id: I98e48cc030c19f0b4463df9658d58f2af56570cd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3765459 Reviewed-by: Sam Hurst Code-Coverage: Zoss --- zephyr/dts/bindings/button/cros-ec,button-cfg.yaml | 39 +++++ zephyr/shim/include/button_config.h | 96 +++++++++++ zephyr/shim/include/gpio/gpio.h | 14 ++ zephyr/shim/src/CMakeLists.txt | 1 + zephyr/shim/src/button_config.c | 175 +++++++++++++++++++ zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/Kconfig | 3 + zephyr/test/drivers/boards/native_posix.overlay | 29 +++- zephyr/test/drivers/button_config/CMakeLists.txt | 5 + .../test/drivers/button_config/src/button_config.c | 188 +++++++++++++++++++++ zephyr/test/drivers/testcase.yaml | 3 + 11 files changed, 552 insertions(+), 2 deletions(-) create mode 100644 zephyr/dts/bindings/button/cros-ec,button-cfg.yaml create mode 100644 zephyr/shim/include/button_config.h create mode 100644 zephyr/shim/src/button_config.c create mode 100644 zephyr/test/drivers/button_config/CMakeLists.txt create mode 100644 zephyr/test/drivers/button_config/src/button_config.c diff --git a/zephyr/dts/bindings/button/cros-ec,button-cfg.yaml b/zephyr/dts/bindings/button/cros-ec,button-cfg.yaml new file mode 100644 index 0000000000..f46a24432e --- /dev/null +++ b/zephyr/dts/bindings/button/cros-ec,button-cfg.yaml @@ -0,0 +1,39 @@ +# Copyright 2022 The Chromium OS Authors. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +description: | + Button config. + - Name + - Type + - GPIO handle + - Debounce time (us) + - Flags + +compatible: "cros-ec,button-cfg" + +child-binding: + description: Button configuration + properties: + button_name: + type: string + required: true + description: Button name + button_type: + type: int + required: false + description: Keyboard button type + spec: + type: phandle + required: true + gpio_int: + type: phandle + required: false + debounce_us: + type: int + required: true + description: Debounce time in microseconds + flags: + type: int + required: true + description: The zephyr gpio interrupt config flags. diff --git a/zephyr/shim/include/button_config.h b/zephyr/shim/include/button_config.h new file mode 100644 index 0000000000..5599ded1ea --- /dev/null +++ b/zephyr/shim/include/button_config.h @@ -0,0 +1,96 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __BUTTON_CONFIG_H +#define __BUTTON_CONFIG_H + +#include +#include + +#include "include/ec_commands.h" + +#define BUTTON_CFG_COMPAT cros_ec_button_cfg +#define DT_BUTTON_CFG_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(BUTTON_CFG_COMPAT) + +#define BUTTON_CFG_ENUM(val) DT_CAT(BUTTON_CFG_, val) +#define BUTTON_CFG_TYPE(node) \ + BUTTON_CFG_ENUM(DT_STRING_UPPER_TOKEN(node, button_name)), + +enum button_cfg_type { +#if DT_NODE_EXISTS(DT_BUTTON_CFG_NODE) + DT_FOREACH_CHILD(DT_BUTTON_CFG_NODE, BUTTON_CFG_TYPE) +#endif + BUTTON_CFG_ENUM(COUNT), +}; + +#define BUTTON_FLAG_ACTIVE_HIGH BIT(0) +#define BUTTON_FLAG_DISABLED BIT(1) /* Button disabled */ + +struct button_config_v2 { + const char *name; + enum keyboard_button_type type; + uint32_t debounce_us; + uint8_t button_flags; + enum gpio_signal gpio; + const struct gpio_dt_spec spec; + void (*gpio_int_handler)(enum gpio_signal); + gpio_flags_t gpio_int_flags; +}; + +/** + * @brief Get the button cfg + * + * @param type + * @return const struct button_config_v2* + */ +const struct button_config_v2 *button_cfg_get(enum button_cfg_type type); + +/** + * @brief Get button name + * + * @param type + * @return const char* + */ +const char *button_get_name(enum button_cfg_type type); + +/** + * @brief Get button debounce time in microseconds + * + * @param type + * @return int + */ +int button_get_debounce_us(enum button_cfg_type type); + +/** + * @brief Enable interrupt for button + * + * @param type + */ +int button_enable_interrupt(enum button_cfg_type type); + +/** + * @brief Disable interrupt for button + * + * @param type + */ +int button_disable_interrupt(enum button_cfg_type type); + +/** + * @brief Get the logical level of button press + * + * @param type + * @return int + */ +int button_is_pressed(enum button_cfg_type type); + +/** + * @brief Get the physical level of button press + * + * @param type + * @return int + */ +int button_is_pressed_raw(enum button_cfg_type type); + +#endif /* __BUTTON_CONFIG_H */ diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h index 7d41c0fa02..ea606324fa 100644 --- a/zephyr/shim/include/gpio/gpio.h +++ b/zephyr/shim/include/gpio/gpio.h @@ -9,6 +9,20 @@ #include #include +/* + * dt_flags is a uint8_t type. However, for platform/ec + * the GPIO flags in the devicetree are expanded past 8 bits + * to support the INPUT/OUTPUT and PULLUP/PULLDOWN properties. + * Cast back to a gpio_dt_flags to compile, discarding the bits + * that are not supported by the Zephyr GPIO API. + */ +#define CROS_EC_GPIO_DT_SPEC_GET(node_id, prop) \ + { \ + .port = DEVICE_DT_GET(DT_GPIO_CTLR(node_id, prop)), \ + .pin = DT_GPIO_PIN(node_id, prop), \ + .dt_flags = (gpio_dt_flags_t)DT_GPIO_FLAGS(node_id, prop), \ + } + /* * Validate interrupt flags are valid for the Zephyr GPIO driver. */ diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 97968e8a52..1ad4d6546e 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +zephyr_library_sources(button_config.c) zephyr_library_sources(console.c) zephyr_library_sources(crc.c) zephyr_library_sources(gpio.c) diff --git a/zephyr/shim/src/button_config.c b/zephyr/shim/src/button_config.c new file mode 100644 index 0000000000..e38cc35ee6 --- /dev/null +++ b/zephyr/shim/src/button_config.c @@ -0,0 +1,175 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include +#include +#include +#include +#include + +#include "include/button.h" +#include "gpio/gpio.h" +#include "gpio/gpio_int.h" +#include "button_config.h" + +LOG_MODULE_REGISTER(button_cfg, LOG_LEVEL_ERR); + +/* LCOV_EXCL_START */ +#ifdef TEST_BUILD +test_mockable int stub_gpio_pin_get(const struct device *d, gpio_pin_t p) +{ + LOG_DBG("Calling %s\n", __func__); + return gpio_pin_get(d, p); +} +test_mockable int stub_gpio_pin_get_raw(const struct device *d, gpio_pin_t p) +{ + LOG_DBG("Calling %s\n", __func__); + return gpio_pin_get_raw(d, p); +} + +#define gpio_pin_get stub_gpio_pin_get +#define gpio_pin_get_raw stub_gpio_pin_get_raw +#endif +/* LCOV_EXCL_STOP */ + +#define BUTTON_HANDLER_DECLARE(node) \ + extern void DT_STRING_TOKEN(DT_PHANDLE(node, gpio_int), \ + handler)(enum gpio_signal); + +#define BUTTON_CFG_DEF(node) \ + { .name = DT_PROP(node, button_name), \ + .type = DT_PROP_OR(node, button_type, 0), \ + .gpio = GPIO_SIGNAL(DT_PHANDLE(node, spec)), \ + .spec = CROS_EC_GPIO_DT_SPEC_GET(DT_PHANDLE(node, spec), gpios), \ + .gpio_int_handler = \ + DT_STRING_TOKEN(DT_PHANDLE(node, gpio_int), handler), \ + .gpio_int_flags = DT_PROP(DT_PHANDLE(node, gpio_int), flags), \ + .debounce_us = DT_PROP(node, debounce_us), \ + .button_flags = DT_PROP(node, flags) }, + +#if DT_NODE_EXISTS(DT_BUTTON_CFG_NODE) + +DT_FOREACH_CHILD(DT_BUTTON_CFG_NODE, BUTTON_HANDLER_DECLARE) + +static const struct button_config_v2 button_configs[] = { DT_FOREACH_CHILD( + DT_BUTTON_CFG_NODE, BUTTON_CFG_DEF) }; + +static struct gpio_callback int_cb_data[BUTTON_CFG_COUNT]; + +static bool button_is_valid(enum button_cfg_type type) +{ + return (type >= 0 && type < BUTTON_CFG_COUNT); +} + +const struct button_config_v2 *button_cfg_get(enum button_cfg_type type) +{ + const struct button_config_v2 *cfg = NULL; + + if (button_is_valid(type)) { + cfg = &button_configs[type]; + } + + return cfg; +} + +const char *button_get_name(enum button_cfg_type type) +{ + const char *name = "NULL"; + const struct button_config_v2 *cfg = button_cfg_get(type); + + if (cfg) { + name = cfg->name; + } + + return name; +} + +int button_get_debounce_us(enum button_cfg_type type) +{ + int debounce_time = 0; + const struct button_config_v2 *cfg = button_cfg_get(type); + + if (cfg) { + debounce_time = cfg->debounce_us; + } + + return debounce_time; +} + +void button_cb_handler(const struct device *dev, struct gpio_callback *cbdata, + uint32_t pins) +{ + const struct button_config_v2 *cfg = + button_cfg_get(cbdata - &int_cb_data[0]); + + if (cfg) { + cfg->gpio_int_handler(cfg->gpio); + } +} + +int button_enable_interrupt(enum button_cfg_type type) +{ + int retval = EC_ERROR_INVAL; + const struct button_config_v2 *cfg = button_cfg_get(type); + struct gpio_callback *cb; + gpio_flags_t flags; + + if (cfg) { + if (cfg->gpio_int_handler) { + cb = &int_cb_data[type]; + gpio_init_callback(cb, button_cb_handler, + BIT(cfg->spec.pin)); + gpio_add_callback(cfg->spec.port, cb); + } + flags = (cfg->gpio_int_flags | GPIO_INT_ENABLE) & + ~GPIO_INT_DISABLE; + + retval = gpio_pin_interrupt_configure(cfg->spec.port, + cfg->spec.pin, flags); + } + + return retval; +} + +int button_disable_interrupt(enum button_cfg_type type) +{ + int retval = EC_ERROR_INVAL; + const struct button_config_v2 *cfg = button_cfg_get(type); + + if (cfg) { + retval = gpio_pin_interrupt_configure( + cfg->spec.port, cfg->spec.pin, GPIO_INT_DISABLE); + } + + return retval; +} + +static int is_pressed(enum button_cfg_type type, + int (*gpio_pin_get_fn)(const struct device *, gpio_pin_t)) +{ + int pressed = 0; + const struct button_config_v2 *cfg = button_cfg_get(type); + + if (cfg) { + pressed = gpio_pin_get_fn(cfg->spec.port, cfg->spec.pin); + if (pressed < 0) { + LOG_ERR("Cannot read %s (%d)", cfg->name, type); + pressed = 0; + } + } + + return pressed; +} + +int button_is_pressed(enum button_cfg_type type) +{ + return is_pressed(type, gpio_pin_get); +} + +int button_is_pressed_raw(enum button_cfg_type type) +{ + return is_pressed(type, gpio_pin_get_raw); +} + +#endif /* DT_NODE_EXISTS(DT_BUTTON_CFG_NODE) */ diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index b03e3e4edd..ede215b5bf 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -47,6 +47,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_COMMANDS host_cmd) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_SYSTEM system) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS locate_chip) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON button) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON_CONFIG button_config) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_CONSOLE console) get_target_property(TEST_SOURCES_NEW app SOURCES) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index 9254bb9e31..ed57c7c16e 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -20,6 +20,9 @@ config LINK_TEST_SUITE_AP_VDM_CONTROL config LINK_TEST_SUITE_BUTTON bool "Link tests for common/button.c" +config LINK_TEST_SUITE_BUTTON_CONFIG + bool "Link tests for common/button_config" + config LINK_TEST_SUITE_CHARGESPLASH bool "Link and test the chargesplash tests" diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index 6a304261cc..1106ad37d1 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -162,7 +162,7 @@ /* GPIO_PULL_UP will cause this start asserted, * i.e. not pressed. */ - gpios = <&gpio0 25 (GPIO_INPUT | GPIO_PULL_UP)>; + gpios = <&gpio0 25 (GPIO_INPUT_PULL_UP)>; enum-name = "GPIO_POWER_BUTTON_L"; }; gpio_src_vph_pwr_pg: src_vph_pwr_pg { @@ -285,6 +285,11 @@ flags = ; handler = "power_signal_interrupt"; }; + int_power_button: power_button { + irq-pin = <&gpio_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; }; named-i2c-ports { @@ -956,8 +961,28 @@ reg = <0x55556666 0x1000>; status = "okay"; buffer-size = <200>; - }; + }; + button-cfg { + compatible = "cros-ec,button-cfg"; + + btn_power_button_cfg: power_button_cfg { + button_name = "POWER_BUTTON"; + button_type = <0>; + spec = <&gpio_ec_pwr_btn_odl>; + gpio_int = <&int_power_button>; + debounce_us = <30000>; + flags = <0>; + }; + btn_test_button_cfg: test_button_cfg { + button_name = "TEST_BUTTON"; + button_type = <0>; + spec = <&gpio_test>; + gpio_int = <&int_gpio_test>; + debounce_us = <30000>; + flags = <0>; + }; + }; }; &espi0 { diff --git a/zephyr/test/drivers/button_config/CMakeLists.txt b/zephyr/test/drivers/button_config/CMakeLists.txt new file mode 100644 index 0000000000..fa28c76137 --- /dev/null +++ b/zephyr/test/drivers/button_config/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +zephyr_library_sources(src/button_config.c) diff --git a/zephyr/test/drivers/button_config/src/button_config.c b/zephyr/test/drivers/button_config/src/button_config.c new file mode 100644 index 0000000000..3584d9b069 --- /dev/null +++ b/zephyr/test/drivers/button_config/src/button_config.c @@ -0,0 +1,188 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * @file + * @brief Tests for button_config.c + */ + +#include +#include +#include +#include + +#include "button.h" +#include "button_config.h" +#include "common.h" +#include "ec_tasks.h" +#include "hooks.h" +#include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" + +LOG_MODULE_REGISTER(button_cfg_test, LOG_LEVEL_INF); + +int stub_button_state; +int stub_get_button_state(const struct device *d, gpio_pin_t p) +{ + ARG_UNUSED(d); + ARG_UNUSED(p); + return stub_button_state; +} + +FAKE_VALUE_FUNC(int, stub_gpio_pin_get, const struct device *, gpio_pin_t); +FAKE_VALUE_FUNC(int, stub_gpio_pin_get_raw, const struct device *, gpio_pin_t); + +#define BUTTON_CFG_LIST(FAKE) \ + { \ + FAKE(stub_gpio_pin_get); \ + FAKE(stub_gpio_pin_get_raw); \ + } + +static void test_button_cfg_reset(void) +{ + BUTTON_CFG_LIST(RESET_FAKE); + + FFF_RESET_HISTORY(); + + stub_button_state = 0; + stub_gpio_pin_get_fake.custom_fake = gpio_pin_get; + stub_gpio_pin_get_raw_fake.custom_fake = gpio_pin_get_raw; +} + +static void button_config_rule(const struct ztest_unit_test *test, void *data) +{ + ARG_UNUSED(test); + ARG_UNUSED(data); + + test_button_cfg_reset(); +} + +ZTEST_RULE(button_config_rule, button_config_rule, button_config_rule); + +/** + * Make sure mocks are setup before HOOK(HOOK_PRIO_INIT_POWER_BUTTON) runs + * otherwise unexpected calls to mocks above occur prevent default + * gpio_pin_get behavior + */ +DECLARE_HOOK(HOOK_INIT, test_button_cfg_reset, HOOK_PRIO_FIRST); + +/** + * @brief Test Suite: Verifies button_config functionality. + */ +ZTEST_SUITE(button_config, drivers_predicate_post_main, NULL, NULL, NULL, NULL); + +/** + * @brief TestPurpose: Verify button_config initialization. + * + */ +ZTEST(button_config, test_button_config) +{ + const struct button_config_v2 *button; + + for (int i = 0; i < BUTTON_CFG_COUNT; i++) { + button = button_cfg_get(i); + + LOG_INF("button[%d]= {%s, %d, %d, {%d, 0x%X}, %d, %d}\n", i, + button->name, button->type, button->gpio, + button->spec.pin, button->spec.dt_flags, + button->debounce_us, button->button_flags); + } + + button = button_cfg_get(BUTTON_CFG_POWER_BUTTON); + + zassert_equal(button->type, 0, NULL); + zassert_equal(button->gpio, GPIO_POWER_BUTTON_L, NULL); + zassert_equal(button->debounce_us, 30000, NULL); + zassert_equal(button->button_flags, 0, NULL); +} + +/** + * @brief TestPurpose: Verify button_config pressed raw. + * + */ +ZTEST(button_config, test_button_pressed) +{ + stub_gpio_pin_get_fake.custom_fake = stub_get_button_state; + + stub_button_state = 1; + zassert_equal(1, button_is_pressed(BUTTON_CFG_POWER_BUTTON)); + + stub_button_state = 0; + zassert_equal(0, button_is_pressed(BUTTON_CFG_POWER_BUTTON)); + + stub_button_state = -1; + zassert_equal(0, button_is_pressed(BUTTON_CFG_POWER_BUTTON)); +} + +/** + * @brief TestPurpose: Verify button_config pressed raw. + * + */ +ZTEST(button_config, test_button_pressed_raw) +{ + stub_gpio_pin_get_raw_fake.custom_fake = stub_get_button_state; + + stub_button_state = 1; + zassert_equal(1, button_is_pressed_raw(BUTTON_CFG_POWER_BUTTON)); + + stub_button_state = 0; + zassert_equal(0, button_is_pressed_raw(BUTTON_CFG_POWER_BUTTON)); + + stub_button_state = -1; + zassert_equal(0, button_is_pressed_raw(BUTTON_CFG_POWER_BUTTON)); +} + +/** + * @brief TestPurpose: Verify button name. + * + */ +ZTEST(button_config, test_button_name) +{ + const char *name; + + name = button_get_name(BUTTON_CFG_POWER_BUTTON); + zassert_ok(strcmp(name, "POWER_BUTTON"), NULL); + + name = button_get_name(BUTTON_CFG_COUNT); + zassert_ok(strcmp(name, "NULL"), NULL); +} + +/** + * @brief TestPurpose: Verify button debounce. + * + */ +ZTEST(button_config, test_button_debounce) +{ + const uint32_t debounce_time_us = 30000; + + zassert_equal(debounce_time_us, + button_get_debounce_us(BUTTON_CFG_POWER_BUTTON), NULL); + + zassert_equal(0, button_get_debounce_us(BUTTON_CFG_COUNT), NULL); +} + +/** + * @brief TestPurpose: Verify button interrupt. + * + */ +extern bool gpio_test_interrupt_triggered; +ZTEST(button_config, test_button_interrupt) +{ + const struct button_config_v2 *cfg; + + cfg = button_cfg_get(BUTTON_CFG_TEST_BUTTON); + + gpio_test_interrupt_triggered = false; + + zassert_ok(button_disable_interrupt(BUTTON_CFG_TEST_BUTTON), NULL); + gpio_pin_set_raw(cfg->spec.port, cfg->spec.pin, 0); + gpio_pin_set_raw(cfg->spec.port, cfg->spec.pin, 1); + zassert_equal(gpio_test_interrupt_triggered, false); + + zassert_ok(button_enable_interrupt(BUTTON_CFG_TEST_BUTTON), NULL); + gpio_pin_set_raw(cfg->spec.port, cfg->spec.pin, 0); + gpio_pin_set_raw(cfg->spec.port, cfg->spec.pin, 1); + zassert_equal(gpio_test_interrupt_triggered, true); +} diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 0aa89b560d..851ce7a128 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -41,6 +41,9 @@ tests: - CONFIG_PLATFORM_EC_CMD_BUTTON=y - CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y - CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y + drivers.button_config: + extra_configs: + - CONFIG_LINK_TEST_SUITE_BUTTON_CONFIG=y drivers.common_cbi: extra_configs: - CONFIG_LINK_TEST_SUITE_COMMON_CBI=y -- cgit v1.2.1 From 143369c812eed703f9576a362b45bc8f104c7aa8 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 21 Oct 2022 16:48:10 -0600 Subject: zmake: Jobserver fixes Zmake wasn't working correctly as either a GNU make client, nor a jobserver for ninja. Create the jobserver client early in __main__ so it can test if the file descriptors from the parent are valid. Change LogWriter to create it's pipe in reset() instead of the static initialization of the class, to prevent new file descriptors from being created before they can be checked by jobserver. Change Executor.append to return the threads join function to let the caller wait for specific processes. The job server client is complicated, so implement those rules (see comment in code). Since we have to get jobs from the jobserver and also run one job without using the job server, create two pipes and use select to find the one that is ready. Explicitly pass the file descriptors to the child process, python doesn't inherit file handles by default. Zmake was starting more processes than the jobserver actually allowed, so split things up and use more threads. For each function that is added to the executor, start with get_job(), and if it starts new subprocesses then add them to the executor also, but then release the the current job token while we wait for the subprocesses to run. configure() starts a thread for each project running _configure(), which starts a thread for each build dir (ro,rw) running _configure_one_build(), and when those finish, runs _build(). The build starts a thread for each build dir (ro,rw) running _build_one_dir(). The net effect is that while the total number of threads might be high (1 for each project, and 1 for each cmake or ninja call), all the hreads will either hold a job token, or be waiting for one. Added tests. BRANCH=None BUG=b:229869104 TEST=zmake -D -j10 build -a --clobber &> /dev/null while jobs %%; do uptime; jobs -x pstree -c %% | cat -n; sleep 5; done Cq-Depend: chromium:3971307 Signed-off-by: Jeremy Bettis Change-Id: I4b42ca9a02ec3f943a370a7bf45d4b32f0a989ac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3971430 Tested-by: Jeremy Bettis Reviewed-by: Jack Rosenthal Auto-Submit: Jeremy Bettis Commit-Queue: Jeremy Bettis --- zephyr/zmake/tests/test_jobserver.py | 201 +++++++++++ zephyr/zmake/zmake/__main__.py | 9 +- zephyr/zmake/zmake/jobserver.py | 149 +++++++- zephyr/zmake/zmake/multiproc.py | 45 ++- zephyr/zmake/zmake/zmake.py | 675 +++++++++++++++++------------------ 5 files changed, 698 insertions(+), 381 deletions(-) create mode 100644 zephyr/zmake/tests/test_jobserver.py diff --git a/zephyr/zmake/tests/test_jobserver.py b/zephyr/zmake/tests/test_jobserver.py new file mode 100644 index 0000000000..a79e6dc280 --- /dev/null +++ b/zephyr/zmake/tests/test_jobserver.py @@ -0,0 +1,201 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Test jobserver functionality.""" + +import logging +import os +import threading +from asyncio import subprocess + +import pytest # pylint:disable=import-error +import zmake.jobserver + + +def _do_test_jobserver( + jobs, commandline_jobs=0, use_client=False, open_pipe=True +): + """Test a jobserver configured with a specified number of jobs.""" + + effective_jobs = jobs + pipe = None + if use_client: + makeflags = f" -j{jobs}" + if jobs > 1: + pipe = os.pipe() + # GNU make puts one less job in the pipe than allowed, since you + # get one job "for free" without contacting the jobserver. Or + # another way of looking at is that make consumes one slot for you + # before calling your job just in case you aren't jobserver aware. + os.write(pipe[1], b"A" * (jobs - 1)) + os.set_inheritable(pipe[0], True) + os.set_inheritable(pipe[1], True) + makeflags += f" --jobserver-auth={pipe[0]},{pipe[1]}" + if not open_pipe: + os.close(pipe[0]) + os.close(pipe[1]) + effective_jobs = 1 + jobserver = zmake.jobserver.GNUMakeJobClient.from_environ( + env={"MAKEFLAGS": makeflags}, jobs=commandline_jobs + ) + else: + jobserver = zmake.jobserver.GNUMakeJobServer(jobs=jobs) + pipe = jobserver._inheritable_pipe # pylint:disable=protected-access + if jobs == 1: + makeflags = " -j1" + else: + makeflags = f" -j{jobs} --jobserver-auth={pipe[0]},{pipe[1]}" + + lock = threading.Condition() + started_threads = 0 + ended_threads = 0 + active_threads = 0 + please_exit = threading.Semaphore(0) + thread_count = jobs + 5 + if commandline_jobs: + effective_jobs = commandline_jobs + + def _my_thread(): + nonlocal started_threads + nonlocal active_threads + nonlocal ended_threads + nonlocal pipe + + with lock: + started_threads += 1 + lock.notify_all() + with jobserver.get_job(): + with lock: + active_threads += 1 + lock.notify_all() + proc = jobserver.popen( + [ + "sh", + "-c", + 'echo "MAKEFLAGS=${MAKEFLAGS}"; ls /proc/self/fd', + ], + stdout=subprocess.PIPE, + universal_newlines=True, + ) + proc.wait() + output = proc.stdout.readlines() + assert output[0] == f"MAKEFLAGS={makeflags}\n" + if pipe: + if effective_jobs > 1: + assert f"{pipe[0]}\n" in output + assert f"{pipe[1]}\n" in output + else: + assert f"{pipe[0]}\n" not in output + assert f"{pipe[1]}\n" not in output + + please_exit.acquire() # pylint:disable=consider-using-with + with lock: + active_threads -= 1 + ended_threads += 1 + lock.notify_all() + + logging.debug("Starting %s threads", thread_count) + for _ in range(thread_count): + threading.Thread(target=_my_thread, daemon=True).start() + + with lock: + lock.wait_for( + lambda: started_threads == thread_count + and active_threads == effective_jobs, + 10, + ) + logging.debug("Asserting %s active_threads", effective_jobs) + assert started_threads == thread_count + assert active_threads == effective_jobs + assert ended_threads == 0 + + logging.debug("Ending %s threads", 5) + for _ in range(5): + please_exit.release() + + with lock: + lock.wait_for( + lambda: active_threads == effective_jobs and ended_threads == 5, 10 + ) + logging.debug("Asserting %s active_threads", effective_jobs) + assert started_threads == thread_count + assert active_threads == effective_jobs + assert ended_threads == 5 + + logging.debug("Ending %s threads", thread_count - 5) + for _ in range(thread_count - 5): + please_exit.release() + + with lock: + lock.wait_for(lambda: ended_threads == thread_count, 10) + logging.debug("Asserting %s active_threads", 0) + assert started_threads == thread_count + assert active_threads == 0 + assert ended_threads == thread_count + + +def test_jobserver_10(): + """Test a jobserver configured with 10 jobs.""" + _do_test_jobserver(10) + + +def test_jobserver_2(): + """Test a jobserver configured with 2 jobs.""" + _do_test_jobserver(2) + + +def test_jobserver_1(): + """Test a jobserver configured with 1 job.""" + _do_test_jobserver(1) + + +def test_jobclient_10(): + """Test a jobclient configured with 10 jobs.""" + _do_test_jobserver(10, use_client=True) + + +def test_jobclient_2(): + """Test a jobserver configured with 2 jobs.""" + _do_test_jobserver(2, use_client=True) + + +def test_jobclient_1(): + """Test a jobserver configured with 1 job.""" + _do_test_jobserver(1, use_client=True) + + +def test_jobclient_10_j1(): + """Test a jobclient configured with 10 jobs but zmake -j1 was called.""" + _do_test_jobserver(10, commandline_jobs=1, use_client=True) + + +def test_jobclient_1_j1(): + """Test a jobserver configured with 1 job but zmake -j1 was called.""" + _do_test_jobserver(1, commandline_jobs=1, use_client=True) + + +def test_jobclient_missing(): + """Test a jobclient with no MAKEFLAGS.""" + jobserver = zmake.jobserver.GNUMakeJobClient.from_environ(env={}) + assert jobserver is None + + +def test_jobclient_dryrun(): + """Test a jobclient make dryrun in MAKEFLAGS.""" + with pytest.raises(SystemExit) as pytest_wrapped_e: + zmake.jobserver.GNUMakeJobClient.from_environ( + env={"MAKEFLAGS": "n -j1"} + ) + assert pytest_wrapped_e.type == SystemExit + assert pytest_wrapped_e.value.code == 0 + + +def test_jobclient_10_no_pipes(): + """Test a jobclient configured with 10 jobs but the file descriptors are missing.""" + _do_test_jobserver(10, use_client=True, open_pipe=False) + + +def test_jobclient_1_no_pipes(): + """Test a jobclient configured with 1 job but the file descriptors are missing.""" + _do_test_jobserver(1, use_client=True, open_pipe=False) diff --git a/zephyr/zmake/zmake/__main__.py b/zephyr/zmake/zmake/__main__.py index 23fb58eca6..2b7358d1f1 100644 --- a/zephyr/zmake/zmake/__main__.py +++ b/zephyr/zmake/zmake/__main__.py @@ -10,6 +10,7 @@ import os import pathlib import sys +import zmake.jobserver as jobserver import zmake.multiproc as multiproc import zmake.zmake as zm @@ -63,7 +64,7 @@ def maybe_reexec(argv): os.execve(sys.executable, [sys.executable, "-m", "zmake", *argv], env) -def call_with_namespace(func, namespace): +def call_with_namespace(func, namespace, **kwds): """Call a function with arguments applied from a Namespace. Args: @@ -73,7 +74,6 @@ def call_with_namespace(func, namespace): Returns: The result of calling the callable. """ - kwds = {} sig = inspect.signature(func) names = [p.name for p in sig.parameters.values()] for name, value in vars(namespace).items(): @@ -392,8 +392,11 @@ def main(argv=None): multiproc.LOG_JOB_NAMES = False logging.basicConfig(format=log_format, level=opts.log_level) + # Create the jobserver client BEFORE any pipes get opened in LogWriter + jobserver_client = jobserver.GNUMakeJobClient.from_environ(jobs=opts.jobs) + multiproc.LogWriter.reset() - zmake = call_with_namespace(zm.Zmake, opts) + zmake = call_with_namespace(zm.Zmake, opts, jobserver=jobserver_client) try: subcommand_method = getattr(zmake, opts.subcommand.replace("-", "_")) result = call_with_namespace(subcommand_method, opts) diff --git a/zephyr/zmake/zmake/jobserver.py b/zephyr/zmake/zmake/jobserver.py index a3d6287da2..c1c9538b35 100644 --- a/zephyr/zmake/zmake/jobserver.py +++ b/zephyr/zmake/zmake/jobserver.py @@ -3,13 +3,17 @@ # found in the LICENSE file. """Module for job counters, limiting the amount of concurrent executions.""" +import fcntl +import functools import logging import multiprocessing import os import re import select +import selectors import shlex import subprocess +import sys import zmake @@ -26,7 +30,8 @@ class JobHandle: pass def __exit__(self, exc_type, exc_value, traceback): - self.release_func(*self.args, **self.kwargs) + if self.release_func: + self.release_func(*self.args, **self.kwargs) class JobClient: @@ -41,6 +46,16 @@ class JobClient: """Get the environment variables necessary to share the job server.""" return {} + @staticmethod + def is_sequential(): + """Returns True if the jobserver is using -j1.""" + return False + + @staticmethod + def pass_fds(): + """Returns the file descriptors that should be passed to subprocesses.""" + return [] + def popen(self, argv, **kwargs): """Start a process using subprocess.Popen @@ -53,7 +68,9 @@ class JobClient: # the bare minimum (PATH only). This prevents us from building obscure # dependencies on the environment variables. kwargs.setdefault("env", {"PATH": "/bin:/usr/bin"}) + kwargs.setdefault("pass_fds", []) kwargs["env"].update(self.env()) + kwargs["pass_fds"] += self.pass_fds() logger = logging.getLogger(self.__class__.__name__) logger.debug( @@ -62,17 +79,53 @@ class JobClient: " " if kwargs["env"] else "", zmake.util.repr_command(argv), ) - return subprocess.Popen(argv, **kwargs) + return subprocess.Popen( # pylint:disable=consider-using-with + argv, **kwargs + ) class GNUMakeJobClient(JobClient): - """A job client for GNU make.""" + """A job client for GNU make. - def __init__(self, read_fd, write_fd): - self._pipe = [read_fd, write_fd] + A client of jobserver is allowed to run 1 job without contacting the + jobserver, so maintain an optional self._internal_pipe to hold that + job. + """ + + def __init__(self, inheritable_pipe, jobs, internal_jobs=0, makeflags=None): + self._makeflags = makeflags + self._inheritable_pipe = inheritable_pipe + self.jobs = jobs + self._selector = selectors.DefaultSelector() + if internal_jobs: + self._internal_pipe = os.pipe() + os.write(self._internal_pipe[1], b"+" * internal_jobs) + os.set_blocking(self._internal_pipe[0], False) + self._selector.register( + self._internal_pipe[0], + selectors.EVENT_READ, + self._internal_pipe[1], + ) + else: + self._internal_pipe = None + if self._inheritable_pipe is not None: + os.set_blocking(self._inheritable_pipe[0], False) + self._selector.register( + self._inheritable_pipe[0], + selectors.EVENT_READ, + self._inheritable_pipe[1], + ) + + def __del__(self): + if self._inheritable_pipe: + os.close(self._inheritable_pipe[0]) + os.close(self._inheritable_pipe[1]) + if self._internal_pipe: + os.close(self._internal_pipe[0]) + os.close(self._internal_pipe[1]) @classmethod - def from_environ(cls, env=None): + def from_environ(cls, env=None, jobs=0): """Create a job client from an environment with the MAKEFLAGS variable. If we are started under a GNU Make Job Server, we can search @@ -81,22 +134,57 @@ class GNUMakeJobClient(JobClient): respectively. If we don't find this environment variable (or the string inside of it), this will raise an OSError. + The specification for MAKEFLAGS is: + * If the first char is "n", this is a dry run, just exit. + * If the flags contains -j1, go to sequential mode. + * If the flags contains --jobserver-auth=R,W AND those file + descriptors are valid, use the jobserver. Otherwise output a + warning. + Args: env: Optionally, the environment to search. + jobs: The number of jobs set by the user on the command line. Returns: - A GNUMakeJobClient configured appropriately. + A GNUMakeJobClient configured appropriately or None if there is + no MAKEFLAGS environment variable. """ if env is None: env = os.environ makeflags = env.get("MAKEFLAGS") if not makeflags: - raise OSError("MAKEFLAGS is not set in the environment") + return None match = re.search(r"--jobserver-auth=(\d+),(\d+)", makeflags) - if not match: - raise OSError("MAKEFLAGS did not contain jobserver flags") - read_fd, write_fd = map(int, match.groups()) - return cls(read_fd, write_fd) + if match: + pipe = [int(x) for x in match.groups()] + if jobs: + pipe = None + logging.warning( + "-jN forced on command line; ignoring GNU make jobserver" + ) + else: + try: + # Use F_GETFD to see if file descriptors are valid + fcntl.fcntl(pipe[0], fcntl.F_GETFD) + fcntl.fcntl(pipe[1], fcntl.F_GETFD) + logging.info("using GNU make jobserver") + except OSError: + pipe = None + logging.warning( + "No file descriptors; ignoring GNU make jobserver" + ) + else: + pipe = None + if not jobs: + match = re.search(r"-j(\d+)", makeflags) + if match: + jobs = int(match.group(1)) + if jobs == 1: + logging.info("Running in sequential mode (-j1)") + if makeflags[0] == "n": + logging.info("MAKEFLAGS contained dry-run flag") + sys.exit(0) + return cls(pipe, jobs, internal_jobs=1, makeflags=makeflags) def get_job(self): """Claim a job. @@ -104,12 +192,38 @@ class GNUMakeJobClient(JobClient): Returns: A JobHandle object. """ - byte = os.read(self._pipe[0], 1) - return JobHandle(lambda: os.write(self._pipe[1], byte)) + while True: + ready_items = self._selector.select() + if len(ready_items) > 0: + read_fd = ready_items[0][0].fd + write_fd = ready_items[0][0].data + try: + byte = os.read(read_fd, 1) + return JobHandle( + functools.partial(os.write, write_fd, byte) + ) + except BlockingIOError: + pass def env(self): """Get the environment variables necessary to share the job server.""" - return {"MAKEFLAGS": "--jobserver-auth={},{}".format(*self._pipe)} + if self._makeflags: + return {"MAKEFLAGS": self._makeflags} + flag = "" + if self.jobs: + flag += f" -j{self.jobs}" + if self.jobs != 1 and self._inheritable_pipe is not None: + flag += " --jobserver-auth={},{}".format(*self._inheritable_pipe) + return {"MAKEFLAGS": flag} + + def is_sequential(self): + return self.jobs == 1 + + def pass_fds(self): + """Returns the file descriptors that should be passed to subprocesses.""" + if self.jobs != 1 and self._inheritable_pipe is not None: + return self._inheritable_pipe + return [] class GNUMakeJobServer(GNUMakeJobClient): @@ -120,11 +234,10 @@ class GNUMakeJobServer(GNUMakeJobClient): """ def __init__(self, jobs=0): - [read_fd, write_fd] = os.pipe() - super().__init__(read_fd, write_fd) if not jobs: jobs = multiprocessing.cpu_count() elif jobs > select.PIPE_BUF: jobs = select.PIPE_BUF + super().__init__(os.pipe(), jobs) - os.write(self._pipe[1], b"+" * jobs) + os.write(self._inheritable_pipe[1], b"+" * jobs) diff --git a/zephyr/zmake/zmake/multiproc.py b/zephyr/zmake/zmake/multiproc.py index 0838f5f1f8..a668bcb961 100644 --- a/zephyr/zmake/zmake/multiproc.py +++ b/zephyr/zmake/zmake/multiproc.py @@ -43,7 +43,8 @@ class LogWriter: # A local pipe use to signal the look that a new file descriptor was added and # should be included in the select statement. - _logging_interrupt_pipe = os.pipe() + _logging_interrupt_pipe = [] + # A condition variable used to synchronize logging operations. _logging_cv = threading.Condition() # A map of file descriptors to their LogWriter @@ -54,7 +55,14 @@ class LogWriter: @classmethod def reset(cls): """Reset this module to its starting state (useful for tests)""" - LogWriter._logging_map.clear() + with LogWriter._logging_cv: + LogWriter._logging_map.clear() + if len(LogWriter._logging_interrupt_pipe) > 1: + os.write(LogWriter._logging_interrupt_pipe[1], b"x") + else: + cls._logging_interrupt_pipe = os.pipe() + LogWriter._logging_thread = None + LogWriter._logging_cv.notify_all() def __init__( self, @@ -135,20 +143,21 @@ class LogWriter: removed from the map as it is no longer valid. """ with LogWriter._logging_cv: - writer = LogWriter._logging_map[file_descriptor] - if file_descriptor.closed: - del LogWriter._logging_map[file_descriptor] - LogWriter._logging_cv.notify_all() - return - line = file_descriptor.readline() - if not line: - # EOF - del LogWriter._logging_map[file_descriptor] - LogWriter._logging_cv.notify_all() - return - line = line.rstrip("\n") - if line: - writer.log_line(line) + if file_descriptor in LogWriter._logging_map: + writer = LogWriter._logging_map[file_descriptor] + if file_descriptor.closed: + del LogWriter._logging_map[file_descriptor] + LogWriter._logging_cv.notify_all() + return + line = file_descriptor.readline() + if not line: + # EOF + del LogWriter._logging_map[file_descriptor] + LogWriter._logging_cv.notify_all() + return + line = line.rstrip("\n") + if line: + writer.log_line(line) @classmethod def _prune_logging_fds(cls): @@ -295,6 +304,9 @@ class Executor: Args: func: A function which returns an int result code or throws an exception. + + Returns: + A join function which will wait until this task is finished. """ with self.lock: thread = threading.Thread( @@ -302,6 +314,7 @@ class Executor: ) thread.start() self.threads.append(thread) + return thread.join def wait(self): """Wait for a result to be available. diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py index f81f157054..963b1b4f44 100644 --- a/zephyr/zmake/zmake/zmake.py +++ b/zephyr/zmake/zmake/zmake.py @@ -187,13 +187,10 @@ class Zmake: if jobserver: self.jobserver = jobserver else: - try: - self.jobserver = zmake.jobserver.GNUMakeJobClient.from_environ() - except OSError: - self.jobserver = zmake.jobserver.GNUMakeJobServer(jobs=jobs) + self.jobserver = zmake.jobserver.GNUMakeJobServer(jobs=jobs) self.executor = zmake.multiproc.Executor() - self._sequential = jobs == 1 and not goma + self._sequential = self.jobserver.is_sequential() and not goma self.failed_projects = [] @property @@ -269,7 +266,6 @@ class Zmake: coverage=coverage, allow_warnings=allow_warnings, extra_cflags=extra_cflags, - multiproject=len(projects) > 1, delete_intermediates=delete_intermediates, static_version=static_version, save_temps=save_temps, @@ -440,372 +436,364 @@ class Zmake: coverage=False, allow_warnings=False, extra_cflags=None, - multiproject=False, delete_intermediates=False, static_version=False, save_temps=False, ): """Set up a build directory to later be built by "zmake build".""" try: - # Clobber build directory if requested. - if clobber and build_dir.exists(): - self.logger.info( - "Clearing build directory %s due to --clobber", build_dir - ) - shutil.rmtree(build_dir) - - generated_include_dir = (build_dir / "include").resolve() - base_config = zmake.build_config.BuildConfig( - cmake_defs={ - "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", - "DTS_ROOT": str(self.module_paths["ec"] / "zephyr"), - "SYSCALL_INCLUDE_DIRS": str( - self.module_paths["ec"] - / "zephyr" - / "include" - / "drivers" - ), - "USER_CACHE_DIR": str( - self.module_paths["ec"] - / "build" - / "zephyr" - / "user-cache" - ), - "ZEPHYR_BASE": str(self.zephyr_base), - "ZMAKE_INCLUDE_DIR": str(generated_include_dir), - "ZMAKE_PROJECT_NAME": project.config.project_name, - **( - {"EXTRA_EC_VERSION_FLAGS": "--static"} - if static_version - else {} - ), - **( - {"EXTRA_CFLAGS": "-save-temps=obj"} - if save_temps - else {} - ), - }, - ) - - # Prune the module paths to just those required by the project. - module_paths = project.prune_modules(self.module_paths) - - module_config = zmake.modules.setup_module_symlinks( - build_dir / "modules", module_paths - ) - - # Symlink the Zephyr base into the build directory so it can - # be used in the build phase. - util.update_symlink(self.zephyr_base, build_dir / "zephyr_base") - - dts_overlay_config = project.find_dts_overlays(module_paths) - - toolchain_support = project.get_toolchain( - module_paths, override=toolchain - ) - toolchain_config = toolchain_support.get_build_config() + with self.jobserver.get_job(): + # Clobber build directory if requested. + if clobber and build_dir.exists(): + self.logger.info( + "Clearing build directory %s due to --clobber", + build_dir, + ) + shutil.rmtree(build_dir) - if bringup: - base_config |= zmake.build_config.BuildConfig( - kconfig_defs={"CONFIG_PLATFORM_EC_BRINGUP": "y"} - ) - if coverage: - base_config |= zmake.build_config.BuildConfig( - kconfig_defs={"CONFIG_COVERAGE": "y"} - ) - if allow_warnings: - base_config |= zmake.build_config.BuildConfig( - cmake_defs={"ALLOW_WARNINGS": "ON"} - ) - if extra_cflags: - base_config |= zmake.build_config.BuildConfig( - cmake_defs={"EXTRA_CFLAGS": extra_cflags}, - ) - if self.goma: - base_config |= zmake.build_config.BuildConfig( + generated_include_dir = (build_dir / "include").resolve() + base_config = zmake.build_config.BuildConfig( cmake_defs={ - "CMAKE_C_COMPILER_LAUNCHER": self.gomacc, - "CMAKE_CXX_COMPILER_LAUNCHER": self.gomacc, + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "DTS_ROOT": str(self.module_paths["ec"] / "zephyr"), + "SYSCALL_INCLUDE_DIRS": str( + self.module_paths["ec"] + / "zephyr" + / "include" + / "drivers" + ), + "USER_CACHE_DIR": str( + self.module_paths["ec"] + / "build" + / "zephyr" + / "user-cache" + ), + "ZEPHYR_BASE": str(self.zephyr_base), + "ZMAKE_INCLUDE_DIR": str(generated_include_dir), + "ZMAKE_PROJECT_NAME": project.config.project_name, + **( + {"EXTRA_EC_VERSION_FLAGS": "--static"} + if static_version + else {} + ), + **( + {"EXTRA_CFLAGS": "-save-temps=obj"} + if save_temps + else {} + ), }, ) - if not build_dir.exists(): - build_dir.mkdir() - if not generated_include_dir.exists(): - generated_include_dir.mkdir() - processes = [] - files_to_write = [] - self.logger.info( - "Building %s in %s.", project.config.project_name, build_dir - ) - for build_name, build_config in project.iter_builds(): - config: zmake.build_config.BuildConfig = ( - base_config - | toolchain_config - | module_config - | dts_overlay_config - | build_config + # Prune the module paths to just those required by the project. + module_paths = project.prune_modules(self.module_paths) + + module_config = zmake.modules.setup_module_symlinks( + build_dir / "modules", module_paths ) - config_json = config.as_json() - config_json_file = build_dir / f"cfg-{build_name}.json" - if config_json_file.is_file(): - if config_json_file.read_text() == config_json: - self.logger.info( - "Skip reconfiguring %s:%s due to previous cmake run of " - "equivalent configuration. Run with --clobber if this " - "optimization is undesired.", - project.config.project_name, - build_name, - ) - continue - config_json_file.unlink() + # Symlink the Zephyr base into the build directory so it can + # be used in the build phase. + util.update_symlink(self.zephyr_base, build_dir / "zephyr_base") - files_to_write.append((config_json_file, config_json)) + dts_overlay_config = project.find_dts_overlays(module_paths) - output_dir = build_dir / "build-{}".format(build_name) - if output_dir.exists(): - self.logger.info( - "Clobber %s due to configuration changes.", output_dir + toolchain_support = project.get_toolchain( + module_paths, override=toolchain + ) + toolchain_config = toolchain_support.get_build_config() + + if bringup: + base_config |= zmake.build_config.BuildConfig( + kconfig_defs={"CONFIG_PLATFORM_EC_BRINGUP": "y"} + ) + if coverage: + base_config |= zmake.build_config.BuildConfig( + kconfig_defs={"CONFIG_COVERAGE": "y"} + ) + if allow_warnings: + base_config |= zmake.build_config.BuildConfig( + cmake_defs={"ALLOW_WARNINGS": "ON"} + ) + if extra_cflags: + base_config |= zmake.build_config.BuildConfig( + cmake_defs={"EXTRA_CFLAGS": extra_cflags}, + ) + if self.goma: + base_config |= zmake.build_config.BuildConfig( + cmake_defs={ + "CMAKE_C_COMPILER_LAUNCHER": self.gomacc, + "CMAKE_CXX_COMPILER_LAUNCHER": self.gomacc, + }, ) - shutil.rmtree(output_dir) + if not build_dir.exists(): + build_dir.mkdir() + if not generated_include_dir.exists(): + generated_include_dir.mkdir() self.logger.info( - "Configuring %s:%s.", - project.config.project_name, - build_name, - ) - - kconfig_file = build_dir / "kconfig-{}.conf".format(build_name) - proc = config.popen_cmake( - self.jobserver, - project.config.project_dir, - output_dir, - kconfig_file, - stdin=subprocess.DEVNULL, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding="utf-8", - errors="replace", + "Building %s in %s.", project.config.project_name, build_dir ) - job_id = "{}:{}".format(project.config.project_name, build_name) - zmake.multiproc.LogWriter.log_output( - self.logger, - logging.DEBUG, - proc.stdout, - log_level_override_func=cmake_log_level_override, - job_id=job_id, + # To reconstruct a Project object later, we need to know the + # name and project directory. + (build_dir / "project_name.txt").write_text( + project.config.project_name ) - zmake.multiproc.LogWriter.log_output( - self.logger, - logging.ERROR, - proc.stderr, - log_level_override_func=cmake_log_level_override, - job_id=job_id, + util.update_symlink( + project.config.project_dir, build_dir / "project" ) - if self._sequential: - if proc.wait(): - raise OSError(get_process_failure_msg(proc)) - else: - processes.append(proc) - for proc in processes: - if proc.wait(): - raise OSError(get_process_failure_msg(proc)) - - for path, contents in files_to_write: - path.write_text(contents) - - # To reconstruct a Project object later, we need to know the - # name and project directory. - (build_dir / "project_name.txt").write_text( - project.config.project_name - ) - util.update_symlink( - project.config.project_dir, build_dir / "project" - ) - output_files = [] + wait_funcs = [] + for build_name, build_config in project.iter_builds(): + config: zmake.build_config.BuildConfig = ( + base_config + | toolchain_config + | module_config + | dts_overlay_config + | build_config + ) + + wait_func = self.executor.append( + func=functools.partial( + self._configure_one_build, + config=config, + build_dir=build_dir, + build_name=build_name, + project=project, + ) + ) + wait_funcs.append(wait_func) + # Outside the with...get_job above. + for wait_func in wait_funcs: + wait_func() + if build_after_configure: - result = self._build( + self._build( build_dir=build_dir, project=project, coverage=coverage, - output_files_out=output_files, - multiproject=multiproject, static_version=static_version, + delete_intermediates=delete_intermediates, ) - if result: - self.failed_projects.append(project.config.project_name) - return result - - if delete_intermediates: - outdir = build_dir / "output" - for child in build_dir.iterdir(): - if child != outdir: - logging.debug("Deleting %s", child) - if not child.is_symlink() and child.is_dir(): - shutil.rmtree(child) - else: - child.unlink() return 0 except Exception: self.failed_projects.append(project.config.project_name) raise + def _configure_one_build( + self, + config, + build_dir, + build_name, + project, + ): + """Run cmake and maybe ninja on one build dir.""" + with self.jobserver.get_job(): + config_json = config.as_json() + config_json_file = build_dir / f"cfg-{build_name}.json" + if config_json_file.is_file(): + if config_json_file.read_text() == config_json: + self.logger.info( + "Skip reconfiguring %s:%s due to previous cmake run of " + "equivalent configuration. Run with --clobber if this " + "optimization is undesired.", + project.config.project_name, + build_name, + ) + return 0 + config_json_file.unlink() + + output_dir = build_dir / "build-{}".format(build_name) + if output_dir.exists(): + self.logger.info( + "Clobber %s due to configuration changes.", + output_dir, + ) + shutil.rmtree(output_dir) + + self.logger.info( + "Configuring %s:%s.", + project.config.project_name, + build_name, + ) + + kconfig_file = build_dir / "kconfig-{}.conf".format(build_name) + proc = config.popen_cmake( + self.jobserver, + project.config.project_dir, + output_dir, + kconfig_file, + stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf-8", + errors="replace", + ) + job_id = "{}:{}".format(project.config.project_name, build_name) + zmake.multiproc.LogWriter.log_output( + self.logger, + logging.DEBUG, + proc.stdout, + log_level_override_func=cmake_log_level_override, + job_id=job_id, + ) + zmake.multiproc.LogWriter.log_output( + self.logger, + logging.ERROR, + proc.stderr, + log_level_override_func=cmake_log_level_override, + job_id=job_id, + ) + if proc.wait(): + raise OSError(get_process_failure_msg(proc)) + config_json_file.write_text(config_json) + return 0 + def _build( self, build_dir, project: zmake.project.Project, - output_files_out=None, coverage=False, - multiproject=False, static_version=False, + delete_intermediates=False, ): """Build a pre-configured build directory.""" - def wait_and_check_success(procs, writers): - """Wait for processes to complete and check for errors - - Args: - procs: List of subprocess.Popen objects to check - writers: List of LogWriter objects to check - - Returns: - True if all if OK - False if an error was found (so that zmake should exit) - """ - bad = None - for proc in procs: - if proc.wait() and not bad: - bad = proc - if bad: - # Just show the first bad process for now. Both builds likely - # produce the same error anyway. If they don't, the user can - # still take action on the errors/warnings provided. Showing - # multiple 'Execution failed' messages is not very friendly - # since it exposes the fragmented nature of the build. - raise OSError(get_process_failure_msg(bad)) + with self.jobserver.get_job(): + dirs: Dict[str, pathlib.Path] = {} - # Let all output be produced before exiting - for writer in writers: - writer.wait() - return True - - procs = [] - log_writers = [] - dirs: Dict[str, pathlib.Path] = {} - - build_dir = build_dir.resolve() - - # Compute the version string. - version_string = zmake.version.get_version_string( - project.config.project_name, - build_dir / "zephyr_base", - zmake.modules.locate_from_directory(build_dir / "modules"), - static=static_version, - ) + build_dir = build_dir.resolve() - # The version header needs to generated during the build phase - # instead of configure, as the tree may have changed since - # configure was run. - zmake.version.write_version_header( - version_string, - build_dir / "include" / "ec_version.h", - "zmake", - static=static_version, - ) + # Compute the version string. + version_string = zmake.version.get_version_string( + project.config.project_name, + build_dir / "zephyr_base", + zmake.modules.locate_from_directory(build_dir / "modules"), + static=static_version, + ) - gcov = "gcov.sh-not-found" - for build_name, _ in project.iter_builds(): - with self.jobserver.get_job(): + # The version header needs to generated during the build phase + # instead of configure, as the tree may have changed since + # configure was run. + zmake.version.write_version_header( + version_string, + build_dir / "include" / "ec_version.h", + "zmake", + static=static_version, + ) + + gcov = "gcov.sh-not-found" + wait_funcs = [] + for build_name, _ in project.iter_builds(): dirs[build_name] = build_dir / "build-{}".format(build_name) gcov = dirs[build_name] / "gcov.sh" - cmd = ["/usr/bin/ninja", "-C", dirs[build_name].as_posix()] - if self.goma: - # Go nuts ninja, goma does the heavy lifting! - cmd.append("-j1024") - elif multiproject: - cmd.append("-j1") - # Only tests will actually build with coverage enabled. - if coverage and not project.config.is_test: - cmd.append("all.libraries") - self.logger.info( - "Building %s:%s: %s", - project.config.project_name, - build_name, - util.repr_command(cmd), - ) - proc = self.jobserver.popen( - cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding="utf-8", - errors="replace", - # TODO(b/239619222): Filter os.environ for ninja. - env=os.environ, - ) - job_id = "{}:{}".format(project.config.project_name, build_name) - dirs[build_name].mkdir(parents=True, exist_ok=True) - build_log = open( # pylint:disable=consider-using-with - dirs[build_name] / "build.log", - "w", - ) - out = zmake.multiproc.LogWriter.log_output( - logger=self.logger, - log_level=logging.INFO, - file_descriptor=proc.stdout, - log_level_override_func=ninja_stdout_log_level_override, - job_id=job_id, - tee_output=build_log, - ) - err = zmake.multiproc.LogWriter.log_output( - self.logger, - logging.ERROR, - proc.stderr, - job_id=job_id, + wait_func = self.executor.append( + func=functools.partial( + self._build_one_dir, + build_name=build_name, + dirs=dirs, + coverage=coverage, + project=project, + ) ) + wait_funcs.append(wait_func) + # Outside the with...get_job above. + for wait_func in wait_funcs: + wait_func() - if self._sequential: - if not wait_and_check_success([proc], [out, err]): - return 2 - else: - procs.append(proc) - log_writers += [out, err] - - if not wait_and_check_success(procs, log_writers): - return 2 - - # Run the packer. - packer_work_dir = build_dir / "packer" - output_dir = build_dir / "output" - for newdir in output_dir, packer_work_dir: - if not newdir.exists(): - newdir.mkdir() - - if output_files_out is None: - output_files_out = [] - # For non-tests, they won't link with coverage, so don't pack the - # firmware. Also generate a lcov file. - if coverage and not project.config.is_test: - with self.jobserver.get_job(): + with self.jobserver.get_job(): + # Run the packer. + packer_work_dir = build_dir / "packer" + output_dir = build_dir / "output" + for newdir in output_dir, packer_work_dir: + if not newdir.exists(): + newdir.mkdir() + + # For non-tests, they won't link with coverage, so don't pack the + # firmware. Also generate a lcov file. + if coverage and not project.config.is_test: self._run_lcov( build_dir, output_dir / "zephyr.info", initial=True, gcov=gcov, ) - else: - for output_file, output_name in project.packer.pack_firmware( - packer_work_dir, - self.jobserver, - dirs, - version_string=version_string, - ): - shutil.copy2(output_file, output_dir / output_name) - self.logger.debug("Output file '%s' created.", output_file) - output_files_out.append(output_file) + else: + for output_file, output_name in project.packer.pack_firmware( + packer_work_dir, + self.jobserver, + dirs, + version_string=version_string, + ): + shutil.copy2(output_file, output_dir / output_name) + self.logger.debug("Output file '%s' created.", output_file) - return 0 + if delete_intermediates: + outdir = build_dir / "output" + for child in build_dir.iterdir(): + if child != outdir: + logging.debug("Deleting %s", child) + if not child.is_symlink() and child.is_dir(): + shutil.rmtree(child) + else: + child.unlink() + return 0 + + def _build_one_dir(self, build_name, dirs, coverage, project): + """Builds one sub-dir of a configured project (build-ro, etc).""" + + with self.jobserver.get_job(): + cmd = ["/usr/bin/ninja", "-C", dirs[build_name].as_posix()] + if self.goma: + # Go nuts ninja, goma does the heavy lifting! + cmd.append("-j1024") + elif self._sequential: + cmd.append("-j1") + # Only tests will actually build with coverage enabled. + if coverage and not project.config.is_test: + cmd.append("all.libraries") + self.logger.info( + "Building %s:%s: %s", + project.config.project_name, + build_name, + util.repr_command(cmd), + ) + proc = self.jobserver.popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf-8", + errors="replace", + # TODO(b/239619222): Filter os.environ for ninja. + env=os.environ, + ) + job_id = "{}:{}".format(project.config.project_name, build_name) + dirs[build_name].mkdir(parents=True, exist_ok=True) + build_log = open( # pylint:disable=consider-using-with + dirs[build_name] / "build.log", + "w", + ) + out = zmake.multiproc.LogWriter.log_output( + logger=self.logger, + log_level=logging.INFO, + file_descriptor=proc.stdout, + log_level_override_func=ninja_stdout_log_level_override, + job_id=job_id, + tee_output=build_log, + ) + err = zmake.multiproc.LogWriter.log_output( + self.logger, + logging.ERROR, + proc.stderr, + job_id=job_id, + ) + + if proc.wait(): + raise OSError(get_process_failure_msg(proc)) + + # Let all output be produced before exiting + out.wait() + err.wait() + return 0 def _run_lcov( self, @@ -869,34 +857,33 @@ class Zmake: pathlib.Path(build_dir) / project.config.project_name ) all_lcov_files.append(project_build_dir / "output" / "zephyr.info") - with self.jobserver.get_job(): - # Merge info files into a single lcov.info - self.logger.info("Merging coverage data into %s.", output_file) - cmd = [ - "/usr/bin/lcov", - "-o", - output_file, - "--rc", - "lcov_branch_coverage=1", - ] - for info in all_lcov_files: - cmd += ["-a", info] - proc = self.jobserver.popen( - cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding="utf-8", - errors="replace", - ) - zmake.multiproc.LogWriter.log_output( - self.logger, logging.ERROR, proc.stderr, job_id="lcov" - ) - zmake.multiproc.LogWriter.log_output( - self.logger, logging.DEBUG, proc.stdout, job_id="lcov" - ) - if proc.wait(): - raise OSError(get_process_failure_msg(proc)) - return 0 + # Merge info files into a single lcov.info + self.logger.info("Merging coverage data into %s.", output_file) + cmd = [ + "/usr/bin/lcov", + "-o", + output_file, + "--rc", + "lcov_branch_coverage=1", + ] + for info in all_lcov_files: + cmd += ["-a", info] + proc = self.jobserver.popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf-8", + errors="replace", + ) + zmake.multiproc.LogWriter.log_output( + self.logger, logging.ERROR, proc.stderr, job_id="lcov" + ) + zmake.multiproc.LogWriter.log_output( + self.logger, logging.DEBUG, proc.stdout, job_id="lcov" + ) + if proc.wait(): + raise OSError(get_process_failure_msg(proc)) + return 0 def list_projects(self, fmt, search_dir): """List project names known to zmake on stdout. -- cgit v1.2.1 From 537cc92760a06584118e994851dc8cc8f7ac3fa4 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Wed, 19 Oct 2022 16:18:16 -0700 Subject: common: Add override for lid angle calculation Allow board to prevent enumerating the lid angle device and calculate a lid angle, even if it looks like there are 2 accelerometers present in the device. BUG=b:254328661 BRANCH=brya TEST=compile Signed-off-by: Gwendal Grignou Change-Id: Iaa2d54d1afb31a229ada4259c63f954606636657 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3967457 Reviewed-by: Boris Mittelberg Code-Coverage: Zoss Tested-by: Scott Chao --- common/ec_features.c | 8 ++++++-- common/motion_sense.c | 10 +++++++++- include/motion_sense.h | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/common/ec_features.c b/common/ec_features.c index 6778a3b36a..7a69575500 100644 --- a/common/ec_features.c +++ b/common/ec_features.c @@ -5,11 +5,12 @@ /* Present Chrome EC device features to the outside world */ +#include "board_config.h" #include "common.h" #include "config.h" #include "console.h" #include "ec_commands.h" -#include "board_config.h" +#include "motion_sense.h" uint32_t get_feature_flags0(void) { @@ -128,7 +129,10 @@ uint32_t get_feature_flags1(void) | EC_FEATURE_MASK_1(EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS) #endif #if defined(CONFIG_LID_ANGLE) && defined(CONFIG_TABLET_MODE) - | EC_FEATURE_MASK_1(EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS) + | (sensor_board_is_lid_angle_available() ? + EC_FEATURE_MASK_1( + EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS) : + 0) #endif #ifdef CONFIG_VBOOT_EFS2 | EC_FEATURE_MASK_1(EC_FEATURE_EFS2) diff --git a/common/motion_sense.c b/common/motion_sense.c index c08909d24e..f6011ae6d5 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -81,6 +81,13 @@ static int init_sensor_mutex(const struct device *dev) SYS_INIT(init_sensor_mutex, POST_KERNEL, 50); #endif /* CONFIG_ZEPHYR */ +#ifdef CONFIG_LID_ANGLE +__attribute__((weak)) int sensor_board_is_lid_angle_available(void) +{ + return 1; +} +#endif + static inline int motion_sensor_in_forced_mode(const struct motion_sensor_t *sensor) { @@ -1422,7 +1429,8 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) default: /* Call other users of the motion task */ if (IS_ENABLED(CONFIG_LID_ANGLE) && - (ret == EC_RES_INVALID_PARAM)) + (ret == EC_RES_INVALID_PARAM) && + sensor_board_is_lid_angle_available()) ret = host_cmd_motion_lid(args); return ret; } diff --git a/include/motion_sense.h b/include/motion_sense.h index 6033d52ff9..750208d5cf 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -282,6 +282,12 @@ int sensor_init_done(struct motion_sensor_t *sensor); */ void sensor_board_proc_double_tap(void); +/** + * Board specific function to double check lid angle calculation is possible. + * + */ +int sensor_board_is_lid_angle_available(void); + /** * Commit the data in a sensor's raw_xyz vector. This operation might have * different meanings depending on the CONFIG_ACCEL_FIFO flag. -- cgit v1.2.1 From 8f89f69a5b2cabf3bd55bfc3e810263d23e1aaa3 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 19 Oct 2022 14:25:46 -0700 Subject: crota: disable lid angle sensor for clamshell Crota defines CONFIG_LID_ANGLE because of crota360, which has lid accel sensor. This CL disables it explisitly. This will prevent DPTF returning tablet mode in APCT(Platform Type). BRANCH=none BUG=b:254328661 TEST=none Signed-off-by: Boris Mittelberg Change-Id: Ib9c00e575ea5370a5f06e3324ef111d09e6eada5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3966679 Reviewed-by: Gwendal Grignou Tested-by: Gwendal Grignou Reviewed-by: caveh jalali --- board/crota/board.c | 2 +- board/crota/board.h | 2 ++ board/crota/sensors.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/board/crota/board.c b/board/crota/board.c index cb3e79ee56..a12ef75d30 100644 --- a/board/crota/board.c +++ b/board/crota/board.c @@ -51,7 +51,7 @@ static void board_chipset_suspend(void) } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); -static bool board_is_convertible(void) +bool board_is_convertible(void) { /* * convertible = 0 diff --git a/board/crota/board.h b/board/crota/board.h index 3d79e190bd..d652a93ad0 100644 --- a/board/crota/board.h +++ b/board/crota/board.h @@ -288,6 +288,8 @@ enum thermal_cfg_table { LAPTOP_MODE, TABLET_MODE, THERMAL_CFG_TABLE_COUNT }; void motion_interrupt(enum gpio_signal signal); +bool board_is_convertible(void); + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/crota/sensors.c b/board/crota/sensors.c index 79d2492060..7d60234dc3 100644 --- a/board/crota/sensors.c +++ b/board/crota/sensors.c @@ -10,9 +10,11 @@ #include "driver/accel_lis2dw12.h" #include "driver/accelgyro_bmi_common.h" #include "driver/accelgyro_lsm6dso.h" +#include "fw_config.h" #include "gpio.h" #include "hooks.h" #include "motion_sense.h" +#include "tablet_mode.h" #include "temp_sensor.h" #include "thermal.h" #include "temp_sensor/thermistor.h" @@ -209,10 +211,29 @@ static void board_update_motion_sensor_config(void) } else { ccprints("BASE IMU is LSM6DSO"); } + + if (!board_is_convertible()) { + tablet_set_mode(0, TABLET_TRIGGER_LID); + gmr_tablet_switch_disable(); + /* Make sure tablet mode detection is not trigger by mistake. */ + gpio_set_flags(GPIO_TABLET_MODE_L, GPIO_INPUT | GPIO_PULL_UP); + /* + * Make sure we don't even try to initialize the lid accel, it + * is not present. + */ + motion_sensors[LID_ACCEL].active_mask = 0; + gpio_set_flags(GPIO_EC_ACCEL_INT_R_L, + GPIO_INPUT | GPIO_PULL_UP); + } } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_update_motion_sensor_config, HOOK_PRIO_INIT_I2C + 1); +__override int sensor_board_is_lid_angle_available(void) +{ + return board_is_convertible(); +} + static void baseboard_sensors_init(void) { /* Enable gpio interrupt for lid accel sensor */ -- cgit v1.2.1 From 9315d7c7d1cc3f3d6efdb5d194d483a6d502fdd9 Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Fri, 28 Oct 2022 13:18:06 -0600 Subject: zephyr: add mmapinfo console command test Validate mmapinfo console command BUG=b:236074899 BRANCH=None TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs Change-Id: Ic93e37317c7ea7ef3566686baf844f91d7d2c3d9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3989669 Reviewed-by: Jeremy Bettis Commit-Queue: Jeremy Bettis Code-Coverage: Zoss --- zephyr/test/drivers/default/CMakeLists.txt | 1 + .../test/drivers/default/src/console_cmd/switch.c | 31 ++++++++++++++++++++++ zephyr/test/drivers/prj.conf | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 zephyr/test/drivers/default/src/console_cmd/switch.c diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt index d3c488e8dd..17016e04ea 100644 --- a/zephyr/test/drivers/default/CMakeLists.txt +++ b/zephyr/test/drivers/default/CMakeLists.txt @@ -41,6 +41,7 @@ target_sources(app PRIVATE src/console_cmd/shared_mem.c src/console_cmd/sleepmask.c src/console_cmd/sleeptimeout.c + src/console_cmd/switch.c src/console_cmd/sysinfo.c src/console_cmd/tcpci_dump.c src/console_cmd/usb_pd_console.c diff --git a/zephyr/test/drivers/default/src/console_cmd/switch.c b/zephyr/test/drivers/default/src/console_cmd/switch.c new file mode 100644 index 0000000000..7d1f63172f --- /dev/null +++ b/zephyr/test/drivers/default/src/console_cmd/switch.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "console.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" + +ZTEST_SUITE(console_cmd_switch, drivers_predicate_post_main, NULL, NULL, NULL, + NULL); + +ZTEST_USER(console_cmd_switch, test_mmapinfo) +{ + uint8_t *memmap_switches = host_get_memmap(EC_MEMMAP_SWITCHES); + uint8_t before = *memmap_switches; + char expected[32]; + + *memmap_switches = 0x3; + snprintf(expected, sizeof(expected), "memmap switches = 0x%x", + *memmap_switches); + + CHECK_CONSOLE_CMD("mmapinfo", expected, EC_SUCCESS); + CHECK_CONSOLE_CMD("mmapinfo", "lid_open", EC_SUCCESS); + CHECK_CONSOLE_CMD("mmapinfo", "powerbtn", EC_SUCCESS); + + *memmap_switches = before; +} diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 70ecb04422..87a6be322b 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -104,6 +104,7 @@ CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y CONFIG_PLATFORM_EC_TEMP_SENSOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y CONFIG_PLATFORM_EC_THERMISTOR=y +CONFIG_PLATFORM_EC_SWITCH=y CONFIG_PLATFORM_EC_SWITCHCAP_LN9310=y CONFIG_PLATFORM_EC_ACCEL_BMA255=y CONFIG_PLATFORM_EC_MOTIONSENSE=y @@ -139,7 +140,6 @@ CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y # Things that default to on, but aren't working yet CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -CONFIG_PLATFORM_EC_SWITCH=n CONFIG_PLATFORM_EC_VBOOT_HASH=n CONFIG_PLATFORM_EC_POWERSEQ_INTEL=n CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n -- cgit v1.2.1 From df6a10d22b520a3c89e29e533f147d513df1611c Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Fri, 28 Oct 2022 14:19:33 -0600 Subject: usb_common: Include missing header Include ec_commands.h from usb_common.c to ensure visibility of enum tcpc_cc_polarity. BUG=none TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy Change-Id: Ifb6ea36566f5e62aa5dfe6d906b147cea6635661 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3988459 Reviewed-by: Diana Z --- include/usb_common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/usb_common.h b/include/usb_common.h index bad1a0c058..f93178322e 100644 --- a/include/usb_common.h +++ b/include/usb_common.h @@ -6,6 +6,7 @@ #define __CROS_EC_USB_COMMON_H /* Functions that are shared between old and new PD stacks */ +#include "ec_commands.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" -- cgit v1.2.1 From 1e0abfa71e84e6f870d986088e7ce4fb7ead8395 Mon Sep 17 00:00:00 2001 From: Diana Z Date: Thu, 20 Oct 2022 11:47:18 -0600 Subject: TCPMv2: Add host command to send VDM REQ messages Add an option for the AP to send us VDM REQ messages to pass on to the port partner or cable. This is the first of a series of commits, and later ones will add the transmission of replies to the AP as well as the underlying EC actions that still need to take place (ex. storing active modes and such). LOW_COVERAGE_REASON=Zoss incorrectly marks variable declarations as uncovered BRANCH=None BUG=b:208884535 TEST=./twister -T ./zephyr/test, load on Skyrim and verify messages are sent as directed to partner and cable with TotalPhase Signed-off-by: Diana Z Change-Id: I205eaa73e7b4b7aa64c1168ef1d8505f1781a1cd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3969859 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- common/usbc/usb_pd_host.c | 30 ++++++++++++++++++++++++++++++ include/ec_commands.h | 15 +++++++++++++++ include/usb_pd.h | 1 - util/ectool.cc | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 78 insertions(+), 2 deletions(-) diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c index 1e2965d114..502abc374a 100644 --- a/common/usbc/usb_pd_host.c +++ b/common/usbc/usb_pd_host.c @@ -112,6 +112,8 @@ static enum ec_status hc_typec_control(struct host_cmd_handler_args *args) { const struct ec_params_typec_control *p = args->params; mux_state_t mode; + uint32_t data[VDO_MAX_SIZE]; + enum tcpci_msg_type tx_type; if (p->port >= board_get_usb_pd_port_count()) return EC_RES_INVALID_PARAM; @@ -140,6 +142,34 @@ static enum ec_status hc_typec_control(struct host_cmd_handler_args *args) return EC_RES_SUCCESS; case TYPEC_CONTROL_COMMAND_BIST_SHARE_MODE: return pd_set_bist_share_mode(p->bist_share_mode); + case TYPEC_CONTROL_COMMAND_SEND_VDM_REQ: + if (!IS_ENABLED(CONFIG_USB_PD_VDM_AP_CONTROL)) + return EC_RES_INVALID_PARAM; + + if (p->vdm_req_params.vdm_data_objects <= 0 || + p->vdm_req_params.vdm_data_objects > VDO_MAX_SIZE) + return EC_RES_INVALID_PARAM; + + memcpy(data, p->vdm_req_params.vdm_data, + sizeof(uint32_t) * p->vdm_req_params.vdm_data_objects); + + switch (p->vdm_req_params.partner_type) { + case TYPEC_PARTNER_SOP: + tx_type = TCPCI_MSG_SOP; + break; + case TYPEC_PARTNER_SOP_PRIME: + tx_type = TCPCI_MSG_SOP_PRIME; + break; + case TYPEC_PARTNER_SOP_PRIME_PRIME: + tx_type = TCPCI_MSG_SOP_PRIME_PRIME; + break; + default: + return EC_RES_INVALID_PARAM; + } + + return pd_request_vdm(p->port, data, + p->vdm_req_params.vdm_data_objects, + tx_type); default: return EC_RES_INVALID_PARAM; } diff --git a/include/ec_commands.h b/include/ec_commands.h index 892787e4dc..c6f89cd172 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -6716,6 +6716,7 @@ struct ec_response_regulator_get_voltage { enum typec_partner_type { TYPEC_PARTNER_SOP = 0, TYPEC_PARTNER_SOP_PRIME = 1, + TYPEC_PARTNER_SOP_PRIME_PRIME = 2, }; struct ec_params_typec_discovery { @@ -6747,6 +6748,7 @@ enum typec_control_command { TYPEC_CONTROL_COMMAND_TBT_UFP_REPLY, TYPEC_CONTROL_COMMAND_USB_MUX_SET, TYPEC_CONTROL_COMMAND_BIST_SHARE_MODE, + TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, }; /* Modes (USB or alternate) that a type-C port may enter. */ @@ -6772,6 +6774,17 @@ struct typec_usb_mux_set { uint8_t mux_flags; } __ec_align1; +#define VDO_MAX_SIZE 7 + +struct typec_vdm_req { + /* VDM data, including VDM header */ + uint32_t vdm_data[VDO_MAX_SIZE]; + /* Number of 32-bit fields filled in */ + uint8_t vdm_data_objects; + /* Partner to address - see enum typec_partner_type */ + uint8_t partner_type; +} __ec_align1; + struct ec_params_typec_control { uint8_t port; uint8_t command; /* enum typec_control_command */ @@ -6793,6 +6806,8 @@ struct ec_params_typec_control { struct typec_usb_mux_set mux_params; /* Used for BIST_SHARE_MODE */ uint8_t bist_share_mode; + /* Used for VMD_REQ */ + struct typec_vdm_req vdm_req_params; uint8_t placeholder[128]; }; } __ec_align1; diff --git a/include/usb_pd.h b/include/usb_pd.h index 92580252a5..bf385c19c2 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -476,7 +476,6 @@ struct partner_active_modes { * VDM object is minimum of VDM header + 6 additional data objects. */ #define VDO_HDR_SIZE 1 -#define VDO_MAX_SIZE 7 #define VDM_VER10 0 #define VDM_VER20 1 diff --git a/util/ectool.cc b/util/ectool.cc index 61c0e85301..0b3ee18791 100644 --- a/util/ectool.cc +++ b/util/ectool.cc @@ -10149,7 +10149,10 @@ int cmd_typec_control(int argc, char *argv[]) " is one of: dp, dock, usb, tbt,\n" " usb4, none, safe\n" " 5: Enable bist share mode\n" - " args: <0: DISABLE, 1: ENABLE>\n", + " args: <0: DISABLE, 1: ENABLE>\n" + " 6: Send VDM REQ\n" + " args: \n" + " is 0 - SOP, 1 - SOP', 2 - SOP''\n", argv[0]); return -1; } @@ -10253,6 +10256,35 @@ int cmd_typec_control(int argc, char *argv[]) } p.bist_share_mode = conversion_result; break; + case TYPEC_CONTROL_COMMAND_SEND_VDM_REQ: + if (argc < 5) { + fprintf(stderr, "Missing VDM header and type\n"); + return -1; + } + if (argc > 4 + VDO_MAX_SIZE) { + fprintf(stderr, "Too many VDOs\n"); + return -1; + } + + conversion_result = strtol(argv[3], &endptr, 0); + if ((endptr && *endptr) || conversion_result > UINT8_MAX || + conversion_result < 0) { + fprintf(stderr, "Bad SOP* type\n"); + return -1; + } + p.vdm_req_params.partner_type = conversion_result; + + int vdm_index; + for (vdm_index = 0; vdm_index < argc - 4; vdm_index++) { + uint32_t vdm_entry = + strtoul(argv[vdm_index + 4], &endptr, 0); + if (endptr && *endptr) { + fprintf(stderr, "Bad VDO\n"); + return -1; + } + p.vdm_req_params.vdm_data[vdm_index] = vdm_entry; + } + p.vdm_req_params.vdm_data_objects = vdm_index; } rv = ec_command(EC_CMD_TYPEC_CONTROL, 0, &p, sizeof(p), ec_inbuf, -- cgit v1.2.1 From b147f07990e2307e1f2379f12b831c5e2b86c328 Mon Sep 17 00:00:00 2001 From: Diana Z Date: Thu, 20 Oct 2022 15:57:21 -0600 Subject: Test: Add test for VDM REQ command Add a test to exercise the parameter checking and message send from the VDM REQ command. BRANCH=None BUG=b:208884535 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z Change-Id: I1cb1d2dbc8d04b7826b4981e8120b44f11b697f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3969860 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- .../drivers/ap_vdm_control/src/ap_vdm_control.c | 240 ++++++++++++++++++++- .../drivers/common/include/test/drivers/utils.h | 9 + zephyr/test/drivers/common/src/utils.c | 14 ++ 3 files changed, 260 insertions(+), 3 deletions(-) diff --git a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c index 7c526f0ccb..10a5faf6b9 100644 --- a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c +++ b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c @@ -3,6 +3,9 @@ * found in the LICENSE file. */ +#include +#include +#include #include #include "ec_commands.h" @@ -10,17 +13,112 @@ #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include "usb_pd_vdo.h" + +#define TEST_PORT USBC_PORT_C0 + +struct ap_vdm_control_fixture { + const struct emul *tcpci_emul; + const struct emul *charger_emul; + struct tcpci_partner_data partner; + struct tcpci_src_emul_data src_ext; +}; + +struct tcpci_cable_data passive_usb3 = { + .identity_vdm[VDO_INDEX_HDR] = + VDO(USB_SID_PD, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT), + .identity_vdm[VDO_INDEX_IDH] = VDO_IDH( + /* USB host */ false, /* USB device */ false, IDH_PTYPE_PCABLE, + /* modal operation */ false, USB_VID_GOOGLE), + .identity_vdm[VDO_INDEX_CSTAT] = 0, + .identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0xABCD), + .identity_vdm[VDO_INDEX_PTYPE_CABLE1] = + VDO_REV30_PASSIVE(USB_R30_SS_U32_U40_GEN2, USB_VBUS_CUR_3A, + USB_REV30_LATENCY_1m, USB_REV30_TYPE_C), + .identity_vdos = VDO_INDEX_PTYPE_CABLE1 + 1, + +}; + +static void verify_vdm_req(struct ap_vdm_control_fixture *fixture, + struct typec_vdm_req *req) +{ + struct tcpci_partner_log_msg *msg; + bool message_seen = 0; + + SYS_SLIST_FOR_EACH_CONTAINER(&fixture->partner.msg_log, msg, node) + { + uint16_t header = sys_get_le16(msg->buf); + + /* Ignore messages from ourselves */ + if (msg->sender == TCPCI_PARTNER_SENDER_PARTNER) + continue; + + /* + * Control messages, non-VDMs, and extended messages are not of + * interest + */ + if ((PD_HEADER_CNT(header) == 0) || + (PD_HEADER_TYPE(header) != PD_DATA_VENDOR_DEF) || + (PD_HEADER_EXT(header) != 0)) { + continue; + } + + if (req->partner_type != msg->sop) + continue; + + /* We have a VDM, check entry we're interested in */ + if (memcmp(msg->buf, req->vdm_data, + req->vdm_data_objects * sizeof(uint32_t))) { + message_seen = true; + break; + } + } + + zassert_true(message_seen, "Expected message not found"); +} + +static void *ap_vdm_control_setup(void) +{ + static struct ap_vdm_control_fixture fixture; + struct tcpci_partner_data *partner = &fixture.partner; + struct tcpci_src_emul_data *src_ext = &fixture.src_ext; + + tcpci_partner_init(partner, PD_REV30); + partner->extensions = tcpci_src_emul_init(src_ext, partner, NULL); + partner->cable = &passive_usb3; + + /* Get references for the emulators */ + fixture.tcpci_emul = EMUL_DT_GET(DT_NODELABEL(tcpci_emul)); + fixture.charger_emul = EMUL_DT_GET(DT_NODELABEL(isl923x_emul)); + + return &fixture; +} static void ap_vdm_control_before(void *data) { + struct ap_vdm_control_fixture *fix = data; + /* Set chipset on so the "AP" is on to give us commands */ test_set_chipset_to_s0(); + + /* Connect our port partner */ + connect_source_to_port(&fix->partner, &fix->src_ext, 0, fix->tcpci_emul, + fix->charger_emul); +} + +static void ap_vdm_control_after(void *data) +{ + struct ap_vdm_control_fixture *fix = data; + + disconnect_source_from_port(fix->tcpci_emul, fix->charger_emul); + tcpci_partner_common_clear_logged_msgs(&fix->partner); } -ZTEST_SUITE(ap_vdm_control, drivers_predicate_post_main, NULL, - ap_vdm_control_before, NULL, NULL); +ZTEST_SUITE(ap_vdm_control, drivers_predicate_post_main, ap_vdm_control_setup, + ap_vdm_control_before, ap_vdm_control_after, NULL); -ZTEST(ap_vdm_control, test_feature_present) +ZTEST_F(ap_vdm_control, test_feature_present) { struct ec_response_get_features feat = host_cmd_get_features(); @@ -28,3 +126,139 @@ ZTEST(ap_vdm_control, test_feature_present) EC_FEATURE_MASK_1(EC_FEATURE_TYPEC_AP_VDM_SEND), "Failed to see feature present"); } + +ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_port) +{ + struct ec_params_typec_control params = { + .port = 85, + .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, + .vdm_req_params = { + .vdm_data = { 0 }, + .vdm_data_objects = 1, + .partner_type = TYPEC_PARTNER_SOP, + }, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); + + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, + "Failed to see port error"); +} + +ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_type) +{ + struct ec_params_typec_control params = { + .port = TEST_PORT, + .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, + .vdm_req_params = { + .vdm_data = { 0 }, + .vdm_data_objects = 1, + .partner_type = TYPEC_PARTNER_SOP_PRIME_PRIME + 1, + }, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); + + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, + "Failed to see port error"); +} + +ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_count) +{ + struct ec_params_typec_control params = { + .port = TEST_PORT, + .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, + .vdm_req_params = { + .vdm_data = { 0 }, + .vdm_data_objects = 0, + .partner_type = TYPEC_PARTNER_SOP, + }, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); + + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, + "Failed to see port error"); +} + +ZTEST_F(ap_vdm_control, test_send_vdm_sop_req_valid) +{ + uint32_t vdm_req_header = VDO(USB_SID_PD, 1, CMD_DISCOVER_IDENT); + struct typec_vdm_req req = { + .vdm_data = { vdm_req_header }, + .vdm_data_objects = 1, + .partner_type = TYPEC_PARTNER_SOP, + }; + + tcpci_partner_common_enable_pd_logging(&fixture->partner, true); + host_cmd_typec_control_vdm_req(TEST_PORT, req); + k_sleep(K_SECONDS(1)); + + tcpci_partner_common_enable_pd_logging(&fixture->partner, false); + + /* Look for our REQ */ + verify_vdm_req(fixture, &req); +} + +ZTEST_F(ap_vdm_control, test_send_vdm_sop_prime_req_valid) +{ + uint32_t vdm_req_header = VDO(USB_SID_PD, 1, CMD_DISCOVER_IDENT); + struct typec_vdm_req req = { + .vdm_data = { vdm_req_header }, + .vdm_data_objects = 1, + .partner_type = TYPEC_PARTNER_SOP_PRIME, + }; + + tcpci_partner_common_enable_pd_logging(&fixture->partner, true); + host_cmd_typec_control_vdm_req(TEST_PORT, req); + k_sleep(K_SECONDS(1)); + + tcpci_partner_common_enable_pd_logging(&fixture->partner, false); + + /* Look for our REQ */ + verify_vdm_req(fixture, &req); +} + +ZTEST_F(ap_vdm_control, test_send_vdm_sop_attention_bad) +{ + uint32_t vdm_req_header = VDO(USB_SID_DISPLAYPORT, 1, CMD_ATTENTION); + struct ec_params_typec_control params = { + .port = TEST_PORT, + .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, + .vdm_req_params = { + .vdm_data = { vdm_req_header }, + .vdm_data_objects = 5, + .partner_type = TYPEC_PARTNER_SOP, + }, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); + + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, + "Failed to see port error"); +} + +ZTEST_F(ap_vdm_control, test_send_vdm_req_in_progress) +{ + uint32_t vdm_req_header = VDO(USB_SID_PD, 1, CMD_DISCOVER_IDENT); + struct ec_params_typec_control params = { + .port = TEST_PORT, + .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, + .vdm_req_params = { + .vdm_data = { vdm_req_header }, + .vdm_data_objects = 1, + .partner_type = TYPEC_PARTNER_SOP, + }, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); + + /* + * First command should succeed, but given no time to process the second + * should return busy + */ + zassert_equal(host_command_process(&args), EC_RES_SUCCESS, + "Failed to send successful request"); + zassert_equal(host_command_process(&args), EC_RES_BUSY, + "Failed to see busy"); +} diff --git a/zephyr/test/drivers/common/include/test/drivers/utils.h b/zephyr/test/drivers/common/include/test/drivers/utils.h index 8a703108c3..af4469bc13 100644 --- a/zephyr/test/drivers/common/include/test/drivers/utils.h +++ b/zephyr/test/drivers/common/include/test/drivers/utils.h @@ -549,6 +549,15 @@ void host_cmd_typec_control_clear_events(int port, uint32_t events); */ void host_cmd_typec_control_bist_share_mode(int port, int enable); +/** + * Run the host command to control PD port behavior, with the sub-command of + * TYPEC_CONTROL_COMMAND_SEND_VDM_REQ + * + * @param port The USB-C port number + * @param vdm_req VDM request data + */ +void host_cmd_typec_control_vdm_req(int port, struct typec_vdm_req vdm_req); + struct host_events_ctx { host_event_t lpc_host_events; host_event_t lpc_host_event_mask[LPC_HOST_EVENT_COUNT]; diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c index 719a3fe589..cc3ad1571d 100644 --- a/zephyr/test/drivers/common/src/utils.c +++ b/zephyr/test/drivers/common/src/utils.c @@ -596,6 +596,20 @@ void host_cmd_typec_control_bist_share_mode(int port, int enable) "Failed to send Type-C control for port %d", port); } +void host_cmd_typec_control_vdm_req(int port, struct typec_vdm_req vdm_req) +{ + struct ec_params_typec_control params = { + .port = port, + .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, + .vdm_req_params = vdm_req, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); + + zassert_ok(host_command_process(&args), + "Failed to send Type-C control for port %d", port); +} + void host_cmd_usb_pd_get_amode( uint8_t port, uint16_t svid_idx, struct ec_params_usb_pd_get_mode_response *response, int *response_size) -- cgit v1.2.1 From 3304e05703d170812bb7e842157030284f16f531 Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Fri, 28 Oct 2022 17:20:44 -0600 Subject: test: Fix stack smashing in cbi_set_string() The cbi_set_string() didn't allocate extra space when using the cbi_data struct to write values to. This resulted in the stack getting overwritten and breaking gitlab due to its stack protection. Allocate extra space for the cbi data "arbitrary_string" to be written. In follow-up CL add -fstack-protector-all to compiler options under native posix to prevent future occurrences. BRANCH=none BUG=b:256030656 TEST=twister -i -s zephyr/test/drivers/drivers.common_cbi_gpio TEST=Above test but with -fstack-protector-all compiler option Signed-off-by: Aaron Massey Change-Id: I3815ad567904475c23ddeb75b5370551cb482be2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990555 Reviewed-by: Yuval Peress Code-Coverage: Zoss --- .../test/drivers/common_cbi/src/test_common_cbi.c | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c index f8348b6770..18e9340dee 100644 --- a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c +++ b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c @@ -26,19 +26,30 @@ ZTEST(common_cbi, test_cbi_set_string__null_str) ZTEST(common_cbi, test_cbi_set_string) { - struct cbi_data data = { 0 }; + const char arbitrary_str[] = "hello cbi"; enum cbi_data_tag arbitrary_valid_tag = CBI_TAG_SKU_ID; - const char *arbitrary_str = "hello cbi"; + struct cbi_data_wrapper { + struct cbi_data data; + uint8_t value_arr[ARRAY_SIZE(arbitrary_str)]; + }; + struct cbi_data_wrapper cbi_data = { 0 }; + + /* Set some provided memory then check values */ uint8_t *addr_byte_after_store = cbi_set_string( - (uint8_t *)&data, arbitrary_valid_tag, arbitrary_str); + (uint8_t *)&cbi_data, arbitrary_valid_tag, arbitrary_str); - zassert_equal(data.tag, arbitrary_valid_tag); - zassert_equal(data.size, strlen(arbitrary_str) + 1); - zassert_mem_equal(data.value, arbitrary_str, data.size); - zassert_equal(addr_byte_after_store - - (strlen(arbitrary_str) + 1 + sizeof(data)), - (uint8_t *)&data); + zassert_equal(cbi_data.data.tag, arbitrary_valid_tag); + zassert_equal(cbi_data.data.size, ARRAY_SIZE(arbitrary_str)); + zassert_mem_equal(cbi_data.data.value, arbitrary_str, + cbi_data.data.size); + + uint32_t expected_added_memory = + (ARRAY_SIZE(arbitrary_str) + sizeof(cbi_data.data)); + + /* Validate that next address for write was set appropriately */ + zassert_equal_ptr(addr_byte_after_store - expected_added_memory, + &cbi_data.data); } ZTEST_SUITE(common_cbi, drivers_predicate_post_main, NULL, NULL, NULL, NULL); -- cgit v1.2.1 From f428eccc71c1de2771a99571346e0e6f3d0af8ad Mon Sep 17 00:00:00 2001 From: Leila Lin Date: Thu, 13 Oct 2022 15:16:02 +0800 Subject: winterhold: Modify thermal config Modify temp sensor and fan config for winterhold LOW_COVERAGE_REASON=no unit tests for skyrim yet, b/247151116 BUG=b:241716688 BRANCH=none TEST=verify the thermal config on winterhold is correct Signed-off-by: Leila Lin Change-Id: I21e9e2a95345eabacaba038a08e5996e8dcb5df6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3950274 Commit-Queue: LeilaCY Lin Tested-by: LeilaCY Lin Reviewed-by: Elthan Huang Reviewed-by: Diana Z Code-Coverage: Zoss --- zephyr/projects/skyrim/adc.dts | 6 ++--- zephyr/projects/skyrim/fan.dts | 2 +- zephyr/projects/skyrim/winterhold.dts | 47 ++++++++++++++++++++++++++++++----- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/zephyr/projects/skyrim/adc.dts b/zephyr/projects/skyrim/adc.dts index 0f2ffd6436..952e5db1d0 100644 --- a/zephyr/projects/skyrim/adc.dts +++ b/zephyr/projects/skyrim/adc.dts @@ -41,14 +41,14 @@ named-temp-sensors { compatible = "cros-ec,temp-sensors"; - charger-thermistor { + temp_sensor_charger: charger-thermistor { temp_host_high = <100>; temp_host_halt = <105>; temp_host_release_high = <80>; sensor = <&temp_charger_thermistor>; }; - memory-thermistor { + temp_sensor_memory: memory-thermistor { temp_host_high = <100>; temp_host_halt = <105>; temp_host_release_high = <80>; @@ -56,7 +56,7 @@ sensor = <&temp_memory_thermistor>; }; - cpu { + temp_sensor_cpu: cpu { temp_host_high = <100>; temp_host_halt = <105>; temp_host_release_high = <80>; diff --git a/zephyr/projects/skyrim/fan.dts b/zephyr/projects/skyrim/fan.dts index f0bc28cb7e..dff26bcb29 100644 --- a/zephyr/projects/skyrim/fan.dts +++ b/zephyr/projects/skyrim/fan.dts @@ -7,7 +7,7 @@ fans { compatible = "cros-ec,fans"; - fan_0 { + fan0: fan_0 { pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; rpm_min = <3100>; rpm_start = <3100>; diff --git a/zephyr/projects/skyrim/winterhold.dts b/zephyr/projects/skyrim/winterhold.dts index 6113923ed8..ece5bc66da 100644 --- a/zephyr/projects/skyrim/winterhold.dts +++ b/zephyr/projects/skyrim/winterhold.dts @@ -15,16 +15,22 @@ named-temp-sensors { compatible = "cros-ec,temp-sensors"; soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <0>; - temp_fan_max = <70>; + temp_host_high = <105>; + temp_host_halt = <110>; + temp_host_release_high = <95>; + temp_host_release_halt = <100>; power-good-pin = <&gpio_pg_pwr_s5>; sensor = <&soc_pct2075>; }; amb-pct2075 { + temp_host_warn = <50>; + temp_host_high = <105>; + temp_host_halt = <110>; + temp_host_release_warn = <45>; + temp_host_release_high = <95>; + temp_host_release_halt = <100>; + temp_fan_off = <43>; + temp_fan_max = <53>; power-good-pin = <&gpio_pg_pwr_s5>; sensor = <&amb_pct2075>; }; @@ -124,3 +130,32 @@ usb-muxes = <&amd_fp6_port1 &anx7483_port1>; }; }; + +&fan0 { + pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>; + rpm_min = <2100>; + rpm_start = <2600>; + rpm_max = <4800>; +}; + +&temp_sensor_charger { + temp_host_high = <100>; + temp_host_halt = <110>; + temp_host_release_high = <90>; + temp_host_release_halt = <100>; +}; + +&temp_sensor_memory { + temp_host_high = <91>; + temp_host_halt = <96>; + temp_host_release_high = <81>; + temp_host_release_halt = <86>; +}; + +&temp_sensor_cpu { + /delete-property/ temp_host_high; + /delete-property/ temp_host_halt; + /delete-property/ temp_host_release_high; + /delete-property/ temp_fan_off; + /delete-property/ temp_fan_max; +}; -- cgit v1.2.1 From 337d804a43fb8756c80dcc11a6d44c64838a1a79 Mon Sep 17 00:00:00 2001 From: johnwc_yeh Date: Thu, 27 Oct 2022 14:36:34 +0800 Subject: Xivu : Dynamic changing charge current. This patch base on charger thermistor sensor temperature to dynamic change charger current. BUG=b:252907995 BRANCH=None TEST=zmake build xivu Signed-off-by: johnwc_yeh Change-Id: I9b1e2703c780e46d8755fac025d1e5138b883cee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3983632 Code-Coverage: Andrew McRae Reviewed-by: SamSP Liu Commit-Queue: Andrew McRae Reviewed-by: Peter Marheine --- zephyr/projects/nissa/xivu/project.conf | 3 ++ zephyr/projects/nissa/xivu/src/usbc.c | 79 ++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/zephyr/projects/nissa/xivu/project.conf b/zephyr/projects/nissa/xivu/project.conf index 4ce9c635c3..fe56a9d562 100644 --- a/zephyr/projects/nissa/xivu/project.conf +++ b/zephyr/projects/nissa/xivu/project.conf @@ -12,3 +12,6 @@ CONFIG_PLATFORM_EC_LED_DT=y # USBC CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 + +# Battery +CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/projects/nissa/xivu/src/usbc.c b/zephyr/projects/nissa/xivu/src/usbc.c index 1520efaa55..c4ba75f741 100644 --- a/zephyr/projects/nissa/xivu/src/usbc.c +++ b/zephyr/projects/nissa/xivu/src/usbc.c @@ -14,7 +14,7 @@ #include "driver/retimer/anx7483_public.h" #include "driver/tcpm/tcpci.h" #include "driver/tcpm/raa489000.h" - +#include "temp_sensor/temp_sensor.h" #include "nissa_common.h" LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); @@ -283,3 +283,80 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma, charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } + +struct chg_curr_step { + int on; + int off; + int curr_ma; +}; + +static const struct chg_curr_step chg_curr_table[] = { + { .on = 0, .off = 36, .curr_ma = 2800 }, + { .on = 46, .off = 36, .curr_ma = 1500 }, + { .on = 48, .off = 38, .curr_ma = 1000 }, +}; + +/* All charge current tables must have the same number of levels */ +#define NUM_CHG_CURRENT_LEVELS ARRAY_SIZE(chg_curr_table) + +int charger_profile_override(struct charge_state_data *curr) +{ + int rv; + int chg_temp_c; + int current; + int thermal_sensor0; + static int current_level; + static int prev_tmp; + + /* + * Precharge must be executed when communication is failed on + * dead battery. + */ + if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE)) + return 0; + + current = curr->requested_current; + + rv = temp_sensor_read( + TEMP_SENSOR_ID_BY_DEV(DT_NODELABEL(temp_charger1)), + &thermal_sensor0); + chg_temp_c = K_TO_C(thermal_sensor0); + + if (rv != EC_SUCCESS) + return 0; + + if (chipset_in_state(CHIPSET_STATE_ON)) { + if (chg_temp_c < prev_tmp) { + if (chg_temp_c <= chg_curr_table[current_level].off) + current_level = current_level - 1; + } else if (chg_temp_c > prev_tmp) { + if (chg_temp_c >= chg_curr_table[current_level + 1].on) + current_level = current_level + 1; + } + /* + * Prevent level always minus 0 or over table steps. + */ + if (current_level < 0) + current_level = 0; + else if (current_level >= NUM_CHG_CURRENT_LEVELS) + current_level = NUM_CHG_CURRENT_LEVELS - 1; + + prev_tmp = chg_temp_c; + current = chg_curr_table[current_level].curr_ma; + + curr->requested_current = MIN(curr->requested_current, current); + } + return 0; +} + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} -- cgit v1.2.1 From bb6a40d6df2ca23330ec4cdc7126ec4fd64285ad Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Fri, 28 Oct 2022 15:51:04 +0800 Subject: krabby: increase keyscan task polling period The default 3ms is too fast for krabby EC, follow jacuzzi's config to increase it to 10ms. BUG=b:256062554,b:254793052 TEST=press and hold any key during fw stage for at least 30 seconds, verify EC watchdog not triggered. BRANCH=corsola Signed-off-by: Ting Shen Change-Id: Ie071d7f78cc370d2d385085e31cf4bbfaa30372d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3988194 Commit-Queue: Ting Shen Tested-by: Ting Shen Reviewed-by: Yu-Ping Wu Reviewed-by: Eric Yilun Lin --- zephyr/projects/corsola/BUILD.py | 3 +++ zephyr/projects/corsola/keyboard_krabby.dts | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 zephyr/projects/corsola/keyboard_krabby.dts diff --git a/zephyr/projects/corsola/BUILD.py b/zephyr/projects/corsola/BUILD.py index 4e82ab7926..91bd8ab062 100644 --- a/zephyr/projects/corsola/BUILD.py +++ b/zephyr/projects/corsola/BUILD.py @@ -37,6 +37,7 @@ register_corsola_project( here / "adc_krabby.dts", here / "battery_krabby.dts", here / "gpio_krabby.dts", + here / "keyboard_krabby.dts", here / "i2c_krabby.dts", here / "interrupts_krabby.dts", here / "led_krabby.dts", @@ -106,6 +107,7 @@ register_corsola_project( here / "battery_tentacruel.dts", here / "cbi_tentacruel.dts", here / "gpio_tentacruel.dts", + here / "keyboard_krabby.dts", here / "i2c_tentacruel.dts", here / "interrupts_tentacruel.dts", here / "led_tentacruel.dts", @@ -126,6 +128,7 @@ register_corsola_project( here / "battery_magikarp.dts", here / "cbi_magikarp.dts", here / "gpio_magikarp.dts", + here / "keyboard_krabby.dts", here / "i2c_magikarp.dts", here / "interrupts_magikarp.dts", here / "led_magikarp.dts", diff --git a/zephyr/projects/corsola/keyboard_krabby.dts b/zephyr/projects/corsola/keyboard_krabby.dts new file mode 100644 index 0000000000..b1a9af6330 --- /dev/null +++ b/zephyr/projects/corsola/keyboard_krabby.dts @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + scan-period = <10000>; + + actual-key-mask = < + 0x1c /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; -- cgit v1.2.1 From e5141211d684bc45b0de68b373f3a897d645eba3 Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 28 Oct 2022 22:57:00 +0800 Subject: zephyr: Kconfig: Add extpower debounce Porting the config CONFIG_EXTPOWER_DEBOUNCE_MS to Zephyr BUG=b:255908917 BRANCH=none TEST=zmake build steelix Signed-off-by: mike Change-Id: Ic55bdc8cef4f5e473b3e9c534a741788ddb1b18a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990093 Reviewed-by: wen zhang Reviewed-by: Eric Yilun Lin --- util/config_allowed.txt | 1 - zephyr/Kconfig | 8 ++++++++ zephyr/shim/include/config_chip.h | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/util/config_allowed.txt b/util/config_allowed.txt index e503e96f94..76a4aa3182 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -387,7 +387,6 @@ CONFIG_ENABLE_JTAG_SELECTION CONFIG_EVENT_LOG_SIZE CONFIG_EXPERIMENTAL_CONSOLE CONFIG_EXTENDED_VERSION_INFO -CONFIG_EXTPOWER_DEBOUNCE_MS CONFIG_FAKE_SHMEM CONFIG_FANS CONFIG_FAN_DSLEEP diff --git a/zephyr/Kconfig b/zephyr/Kconfig index f4d274ca1d..1daeb0d0c4 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -332,6 +332,14 @@ config PLATFORM_EC_EXTPOWER_GPIO project should define a GPIO pin named GPIO_AC_PRESENT, with extpower_interrupt configured as the handler. +config PLATFORM_EC_EXTPOWER_DEBOUNCE_MS + int "Debounce time for external power signal" + default 30 + help + Enable external power signal debounce time. Extend the + debounce time to ensure that the external power signal can + supply stable power. + config PLATFORM_EC_FLASH_CROS bool help diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 7c63ca31f9..26c5ca5332 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -994,6 +994,9 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY #endif +#undef CONFIG_EXTPOWER_DEBOUNCE_MS +#define CONFIG_EXTPOWER_DEBOUNCE_MS CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS + #undef CONFIG_CMD_PPC_DUMP #ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP #define CONFIG_CMD_PPC_DUMP -- cgit v1.2.1 From 36ce80c743526953658d0fbff4305b66947eab3f Mon Sep 17 00:00:00 2001 From: mike Date: Fri, 28 Oct 2022 23:24:30 +0800 Subject: steelix: Adjust external power signal debounce time Adjust external power signal debounce time to make sure extpower can supply stable. BUG=b:255908917 BRANCH=None TEST=plug in adapter and power supply stable. Signed-off-by: mike Change-Id: Ib8ce81aa0cfcca44159691166db152de972afce0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990094 Reviewed-by: Eric Yilun Lin Reviewed-by: wen zhang --- zephyr/projects/corsola/prj_steelix.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zephyr/projects/corsola/prj_steelix.conf b/zephyr/projects/corsola/prj_steelix.conf index 7a854b1313..16f622989f 100644 --- a/zephyr/projects/corsola/prj_steelix.conf +++ b/zephyr/projects/corsola/prj_steelix.conf @@ -30,3 +30,6 @@ CONFIG_LOG=n CONFIG_LOG_MODE_MINIMAL=n CONFIG_SHELL_MINIMAL=y CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=0 + +# AC_OK debounce time +CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 -- cgit v1.2.1 From f99662618617440ee8d94c7e35ee8634105ae959 Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Mon, 31 Oct 2022 13:07:43 +0800 Subject: power/mt8186: implement ap-idle flag When EC_RESET_FLAG_AP_IDLE appears, ec should keep the existing power state. BUG=b:256085410 TEST=manually BRANCH=corsola Signed-off-by: Ting Shen Change-Id: I1dd0afc6dc9a9c8a24f19f6dc6877b81d214bd32 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3992832 Reviewed-by: Eric Yilun Lin Commit-Queue: Ting Shen Code-Coverage: Eric Yilun Lin Tested-by: Ting Shen --- power/mt8186.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/power/mt8186.c b/power/mt8186.c index b05700b599..723036a21f 100644 --- a/power/mt8186.c +++ b/power/mt8186.c @@ -290,6 +290,14 @@ enum power_state power_chipset_init(void) * the only way is to ask GPIO_AC_PRESENT directly. */ exit_hard_off = 0; + } else if (system_get_reset_flags() & EC_RESET_FLAG_AP_IDLE) { + if (init_state == POWER_S0) { + gpio_enable_interrupt(GPIO_AP_EC_WDTRST_L); + gpio_enable_interrupt(GPIO_AP_EC_WARM_RST_REQ); + disable_sleep(SLEEP_MASK_AP_RUN); + } + + return init_state; } if (battery_is_present() == BP_YES) -- cgit v1.2.1 From 56ea8c55f4aec658647063a1d718db70078b9721 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Fri, 28 Oct 2022 14:21:33 -0600 Subject: zephyr test: Verify usb_get_typec_current_limit Verify that usb_get_typec_current_limit calculates the correct current limit based on the provided Rp values. BUG=b:256182103 TEST=twister -s zephyr/test/drivers/drivers.usb_common BRANCH=none Signed-off-by: Abe Levkoy Change-Id: Ic55247ff195e0ac3222624d737d233c2a8449027 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3988460 Code-Coverage: Zoss Reviewed-by: Tomasz Michalec --- zephyr/test/drivers/testcase.yaml | 3 ++ zephyr/test/drivers/usb_common/CMakeLists.txt | 2 +- zephyr/test/drivers/usb_common/src/usb_common.c | 59 +++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 zephyr/test/drivers/usb_common/src/usb_common.c diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 851ce7a128..91773fad6c 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -159,6 +159,9 @@ tests: drivers.timer: extra_configs: - CONFIG_LINK_TEST_SUITE_TIMER=y + drivers.usb_common: + extra_configs: + - CONFIG_LINK_TEST_SUITE_USB_COMMON=y drivers.usb_port_power_dumb: extra_args: DTC_OVERLAY_FILE="./boards/native_posix.overlay;./usb_port_power_dumb/usba.dts" extra_configs: diff --git a/zephyr/test/drivers/usb_common/CMakeLists.txt b/zephyr/test/drivers/usb_common/CMakeLists.txt index 282d4f2ae4..0f05eb1e54 100644 --- a/zephyr/test/drivers/usb_common/CMakeLists.txt +++ b/zephyr/test/drivers/usb_common/CMakeLists.txt @@ -8,7 +8,7 @@ project(usb_flags) target_include_directories(app PRIVATE "include") -target_sources(app PRIVATE "src/suite.c") +target_sources(app PRIVATE "src/suite.c" "src/usb_common.c") target_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_RUNTIME_FLAGS app PRIVATE "src/usb_pd_flags.c") target_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_DISCHARGE app PRIVATE diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c new file mode 100644 index 0000000000..3b30df4ee8 --- /dev/null +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "ec_commands.h" +#include "suite.h" +#include "usb_common.h" +#include "usb_pd.h" + +#define TEST_PORT 0 + +ZTEST_USER(usb_common, test_get_typec_current_limit_detached) +{ + /* If both CC lines are open, current limit should be 0 A. */ + typec_current_t current = usb_get_typec_current_limit( + POLARITY_CC1, TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN); + zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 0); + zassert_equal(current & TYPEC_CURRENT_DTS_MASK, 0); +} + +ZTEST_USER(usb_common, test_get_typec_current_limit_rp_default) +{ + /* USB Default current is 500 mA. */ + typec_current_t current = usb_get_typec_current_limit( + POLARITY_CC1, TYPEC_CC_VOLT_RP_DEF, TYPEC_CC_VOLT_OPEN); + zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 500); + zassert_equal(current & TYPEC_CURRENT_DTS_MASK, 0); +} + +ZTEST_USER(usb_common, test_get_typec_current_limit_rp_1500) +{ + typec_current_t current = usb_get_typec_current_limit( + POLARITY_CC1, TYPEC_CC_VOLT_RP_1_5, TYPEC_CC_VOLT_OPEN); + zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 1500); + zassert_equal(current & TYPEC_CURRENT_DTS_MASK, 0); +} + +ZTEST_USER(usb_common, test_get_typec_current_limit_rp_3000) +{ + typec_current_t current = usb_get_typec_current_limit( + POLARITY_CC1, TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN); + zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 3000); + zassert_equal(current & TYPEC_CURRENT_DTS_MASK, 0); +} + +ZTEST_USER(usb_common, test_get_typec_current_limit_rp_dts) +{ + /* For a DTS source, Rp 3A/Rp 1.5A indicates USB default current. The + * DTS flag should be set. + */ + typec_current_t current = usb_get_typec_current_limit( + POLARITY_CC1, TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_RP_1_5); + zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 500); + zassert_equal(current & TYPEC_CURRENT_DTS_MASK, TYPEC_CURRENT_DTS_MASK); +} -- cgit v1.2.1 From 7d18fd435f8a6bb29ffa389ce5394225d912c00d Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Fri, 28 Oct 2022 16:02:06 -0600 Subject: zephyr test: Verify get_src/snk_polarity Verify that get_src_polarity and get_snk_polarity return correct values for various CC voltage combinations. BUG=b:256182103 TEST=twister -s zephyr/test/drivers/drivers.usb_comon BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I81d7d5f735b4a08ac57e01c66bf1fd73e7b6e40f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990996 Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- zephyr/test/drivers/usb_common/src/usb_common.c | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c index 3b30df4ee8..759651472a 100644 --- a/zephyr/test/drivers/usb_common/src/usb_common.c +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -57,3 +57,31 @@ ZTEST_USER(usb_common, test_get_typec_current_limit_rp_dts) zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 500); zassert_equal(current & TYPEC_CURRENT_DTS_MASK, TYPEC_CURRENT_DTS_MASK); } + +ZTEST_USER(usb_common, test_get_snk_polarity) +{ + zassert_equal(get_snk_polarity(TYPEC_CC_VOLT_RP_3_0, + TYPEC_CC_VOLT_OPEN), + POLARITY_CC1); + zassert_equal(get_snk_polarity(TYPEC_CC_VOLT_OPEN, + TYPEC_CC_VOLT_RP_3_0), + POLARITY_CC2); +} + +ZTEST_USER(usb_common, test_get_snk_polarity_dts) +{ + zassert_equal(get_snk_polarity(TYPEC_CC_VOLT_RP_3_0, + TYPEC_CC_VOLT_RP_DEF), + POLARITY_CC1_DTS); + zassert_equal(get_snk_polarity(TYPEC_CC_VOLT_RP_DEF, + TYPEC_CC_VOLT_RP_3_0), + POLARITY_CC2_DTS); +} + +ZTEST_USER(usb_common, test_get_src_polarity) +{ + zassert_equal(get_src_polarity(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN), + POLARITY_CC1); + zassert_equal(get_src_polarity(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RD), + POLARITY_CC2); +} -- cgit v1.2.1 From cee6f0fd40892b4fc07c1fcb086db7fff38d5efd Mon Sep 17 00:00:00 2001 From: Bernardo Perez Priego Date: Mon, 17 Oct 2022 18:28:50 -0700 Subject: nivviks: Enable using high priority work queue for ADC comparator Currently ADC comparator utilizes system work queue for submitting notifications, due to this, driver response is impacted when system work queue is heavily being used. This will enable using dedicated work queue for ADC comparator and increase its thread priority. This CL depends on this PR on zephyr repository: https://github.com/zephyrproject-rtos/zephyr/pull/51353 BUG=b:250807259 TEST=Build and flash EC on nivviks; Repeate following commands in loop: ectool reboot_ap_on_g3 shutdown -h now nivviks should boot on every iteration BRANCH=none Signed-off-by: Bernardo Perez Priego Change-Id: Idfaacde2120c9a73c9198c6d82f6927bbe6773c5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3961053 Reviewed-by: Andrew McRae Reviewed-by: Deepti Deshatty --- zephyr/projects/nissa/npcx_program.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zephyr/projects/nissa/npcx_program.conf b/zephyr/projects/nissa/npcx_program.conf index 5e0dd99501..d1b7a56bcc 100644 --- a/zephyr/projects/nissa/npcx_program.conf +++ b/zephyr/projects/nissa/npcx_program.conf @@ -43,5 +43,7 @@ CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=22 # VSENSE: PP3300_S5 & PP1050_PROC CONFIG_ADC_CMP_NPCX=y +CONFIG_ADC_CMP_NPCX_WORKQUEUE=y +CONFIG_ADC_CMP_NPCX_WORKQUEUE_PRIORITY=12 CONFIG_SENSOR=y CONFIG_SENSOR_SHELL=n -- cgit v1.2.1 From 5d04062db5d836600b40dc54c339a1d43312ea89 Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Mon, 31 Oct 2022 09:33:04 -0600 Subject: test: hc_cmd_pd_chip_info: Fix stack smashing In run_pd_chip_info() test helper function, the BUILD_HOST_COMMAND macro is passed a pointer to an ec_response_pd_chip_info_v1 struct but expects the direct value. Dereference the pointer when in the helper as it is passed into the BUILD_HOST_COMMAND macro. BRANCH=none BUG=none TEST=twister -i -s zephyr/test/drivers/drivers.host_cmd TEST=CQ Signed-off-by: Aaron Massey Change-Id: I732f6bd53e2ed6bf17dba063eee914ec2525b61d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3993811 Code-Coverage: Zoss Reviewed-by: Al Semjonovs --- zephyr/test/drivers/host_cmd/src/pd_chip_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c index 95e2339899..81c2485388 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c +++ b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c @@ -20,7 +20,7 @@ static enum ec_status run_pd_chip_info(int port, { struct ec_params_pd_chip_info params = { .port = port, .live = true }; struct host_cmd_handler_args args = - BUILD_HOST_COMMAND(EC_CMD_PD_CHIP_INFO, 1, resp, params); + BUILD_HOST_COMMAND(EC_CMD_PD_CHIP_INFO, 1, *resp, params); return host_command_process(&args); } -- cgit v1.2.1 From e47af99c8948ed31d8149598564e9ade8d2e43eb Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Fri, 28 Oct 2022 17:25:54 -0600 Subject: zephyr: clang: Add -fstack-protector-all for tests When running tests we can afford to look for stack smashing since we're running in a test environment. This may prevent time-consuming debugging in the future. Add -fstack-protector-all to the clang compile options if CONFIG_ZTEST is enabled. BRANCH=none BUG=none TEST=Ran twister test and checked for option in ninja.build TEST=Built herobrine and check for *no* option in ninja.build TEST=./twister # Runs all tests TEST=CQ Signed-off-by: Aaron Massey Change-Id: Ib9ce15c18aae4bbc11f809a548e1afffcc650022 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990554 Reviewed-by: Jeremy Bettis Reviewed-by: Yuval Peress --- zephyr/cmake/compiler/clang/compiler_flags.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zephyr/cmake/compiler/clang/compiler_flags.cmake b/zephyr/cmake/compiler/clang/compiler_flags.cmake index 3423f1c36c..e1d91504ea 100644 --- a/zephyr/cmake/compiler/clang/compiler_flags.cmake +++ b/zephyr/cmake/compiler/clang/compiler_flags.cmake @@ -10,6 +10,9 @@ set_compiler_property(PROPERTY hosted) # Disable position independent code. add_compile_options(-fno-PIC) +# When testing, look for stack smashing +add_compile_option_ifdef(CONFIG_ZTEST -fstack-protector-all) + check_set_compiler_property(APPEND PROPERTY warning_extended -Wunused-variable -Werror=unused-variable -Werror=missing-braces -Werror=sometimes-uninitialized -Werror=unused-function -- cgit v1.2.1 From a8f5d39ffc842826a8b06f5befd518523af01864 Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Fri, 28 Oct 2022 12:00:08 -0600 Subject: test: EC_CMD_SET/GET_CROS_BOARD_INFO host cmd Add tests to cover all lines in the EC_CMD_SET/GET_CROS_BOARD_INFO host commands. Test Scenarios: * Setting CBI info and then subsequently getting it * Setting CBI info with bad host cmd parameter size * Setting CBI info but then getting it with bad parameter size BRANCH=none BUG=b:256030656 TEST=./twister -i -s zephyr/test/drivers/drivers.common_cbi Signed-off-by: Aaron Massey Change-Id: I0013deeb1b754a9989ef08eb6f8fd1acb6f4a3f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990556 Reviewed-by: Tristan Honscheid Code-Coverage: Zoss --- .../test/drivers/common_cbi/src/test_common_cbi.c | 141 ++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) diff --git a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c index 18e9340dee..90f08831be 100644 --- a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c +++ b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c @@ -3,13 +3,25 @@ * found in the LICENSE file. */ -#include "host_command.h" +#include #include #include "cros_board_info.h" +#include "host_command.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#define WP_L_GPIO_PATH DT_PATH(named_gpios, wp_l) + +static int gpio_wp_l_set(int value) +{ + const struct device *wp_l_gpio_dev = + DEVICE_DT_GET(DT_GPIO_CTLR(WP_L_GPIO_PATH, gpios)); + + return gpio_emul_input_set(wp_l_gpio_dev, + DT_GPIO_PIN(WP_L_GPIO_PATH, gpios), value); +} + ZTEST(common_cbi, test_cbi_set_string__null_str) { struct cbi_data data = { 0 }; @@ -52,4 +64,131 @@ ZTEST(common_cbi, test_cbi_set_string) &cbi_data.data); } +ZTEST_USER(common_cbi, test_hc_cbi_set_then_get) +{ + const uint8_t data[] = "I love test coverage! <3"; + + struct actual_set_params { + struct ec_params_set_cbi params; + uint8_t actual_data[ARRAY_SIZE(data)]; + }; + + struct actual_set_params hc_set_params = { + .params = { + .tag = CBI_TAG_SKU_ID, + /* Force a reload */ + .flag = CBI_SET_INIT, + .size = ARRAY_SIZE(data), + }, + }; + struct host_cmd_handler_args set_args = BUILD_HOST_COMMAND_PARAMS( + EC_CMD_SET_CROS_BOARD_INFO, 0, hc_set_params); + + memcpy(hc_set_params.params.data, data, ARRAY_SIZE(data)); + + /* Zero out cbi */ + cbi_create(); + + /* Turn off write-protect so we can actually write */ + gpio_wp_l_set(1); + + zassert_ok(host_command_process(&set_args)); + + /* Now verify our write by invoking a get host command */ + + struct ec_params_get_cbi hc_get_params = { + .flag = CBI_GET_RELOAD, + .tag = hc_set_params.params.tag, + }; + + struct test_ec_params_get_cbi_response { + uint8_t data[ARRAY_SIZE(data)]; + }; + struct test_ec_params_get_cbi_response hc_get_response; + struct host_cmd_handler_args get_args = BUILD_HOST_COMMAND( + EC_CMD_GET_CROS_BOARD_INFO, 0, hc_get_response, hc_get_params); + + zassert_ok(host_command_process(&get_args)); + zassert_mem_equal(hc_get_response.data, hc_set_params.actual_data, + hc_set_params.params.size); +} + +ZTEST_USER(common_cbi, test_hc_cbi_set__bad_size) +{ + const char data[] = "hello"; + + struct actual_set_params { + struct ec_params_set_cbi params; + /* We want less data than we need for our size */ + uint8_t actual_data[0]; + }; + struct actual_set_params hc_set_params = { + .params = { + .tag = CBI_TAG_SKU_ID, + /* Force a reload */ + .flag = CBI_SET_INIT, + .size = ARRAY_SIZE(data), + }, + }; + struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS( + EC_CMD_SET_CROS_BOARD_INFO, 0, hc_set_params); + + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); +} + +ZTEST_USER(common_cbi, test_hc_cbi_set_then_get__with_too_small_response) +{ + const uint8_t data[] = "I'm way too big of a payload for you!"; + + struct actual_set_params { + struct ec_params_set_cbi params; + uint8_t actual_data[ARRAY_SIZE(data)]; + }; + + struct actual_set_params hc_set_params = { + .params = { + .tag = CBI_TAG_SKU_ID, + /* Force a reload */ + .flag = CBI_SET_INIT, + .size = ARRAY_SIZE(data), + }, + }; + struct host_cmd_handler_args set_args = BUILD_HOST_COMMAND_PARAMS( + EC_CMD_SET_CROS_BOARD_INFO, 0, hc_set_params); + + memcpy(hc_set_params.params.data, data, ARRAY_SIZE(data)); + + /* Zero out cbi */ + cbi_create(); + + /* Turn off write-protect so we can actually write */ + gpio_wp_l_set(1); + + zassert_ok(host_command_process(&set_args)); + + /* Now verify our write by invoking a get host command */ + + struct ec_params_get_cbi hc_get_params = { + .flag = CBI_GET_RELOAD, + .tag = hc_set_params.params.tag, + }; + + struct test_ec_params_get_cbi_response { + /* + * Want want less space than we need to retrieve cbi data, by + * allocating an array of size zero, we're implicitly setting + * the response_max value of the host command to be zero. So the + * host command will fail because it the EC knows it doesn't + * have enough response space to actually fetch the data for the + * host. + */ + uint8_t data[0]; + }; + struct test_ec_params_get_cbi_response hc_get_response; + struct host_cmd_handler_args get_args = BUILD_HOST_COMMAND( + EC_CMD_GET_CROS_BOARD_INFO, 0, hc_get_response, hc_get_params); + + zassert_equal(host_command_process(&get_args), EC_RES_INVALID_PARAM); +} + ZTEST_SUITE(common_cbi, drivers_predicate_post_main, NULL, NULL, NULL, NULL); -- cgit v1.2.1 From 5da8ac72994e97af3cff5b6a8515281c80ea5e0c Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Fri, 28 Oct 2022 16:26:53 -0600 Subject: zephyr test: Verify pd_get_cc_state Verify that pd_get_cc_state returns the correct role/connection type for various CC voltages. BUG=b:256182103 TEST=twister -s zephyr/test/drivers/drivers.usb_common BRANCH=none Signed-off-by: Abe Levkoy Change-Id: If47b45eb508f1c22d96bdef374dcf258ac40843f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3988517 Code-Coverage: Zoss Reviewed-by: Jeremy Bettis --- zephyr/test/drivers/usb_common/src/usb_common.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c index 759651472a..38362a2549 100644 --- a/zephyr/test/drivers/usb_common/src/usb_common.c +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -85,3 +85,22 @@ ZTEST_USER(usb_common, test_get_src_polarity) zassert_equal(get_src_polarity(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RD), POLARITY_CC2); } + +ZTEST_USER(usb_common, test_pd_get_cc_state) +{ + zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_RD), + PD_CC_UFP_DEBUG_ACC); + zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN), + PD_CC_UFP_ATTACHED); + zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RA, TYPEC_CC_VOLT_RA), + PD_CC_UFP_AUDIO_ACC); + + zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RP_3_0, + TYPEC_CC_VOLT_RP_DEF), + PD_CC_DFP_DEBUG_ACC); + zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN), + PD_CC_DFP_ATTACHED); + + zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN), + PD_CC_NONE); +} -- cgit v1.2.1 From 4d013d044e344f1942cc99ab9f937adfeb757e3b Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Fri, 28 Oct 2022 16:28:21 -0600 Subject: zephyr test: Verify pd_board_check_request Verify that the default implementation of pd_board_check_request allows requests. BUG=b:256182103 TEST=twister -s zephyr/test/drivers/drivers.usb_common BRANCH=none Signed-off-by: Abe Levkoy Change-Id: Icb27b0c2ee6fdfb96ac14d4a5579e230c9287651 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3988518 Code-Coverage: Zoss Reviewed-by: Yuval Peress --- zephyr/test/drivers/usb_common/src/usb_common.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c index 38362a2549..8cd24821ee 100644 --- a/zephyr/test/drivers/usb_common/src/usb_common.c +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -104,3 +104,9 @@ ZTEST_USER(usb_common, test_pd_get_cc_state) zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN), PD_CC_NONE); } + +ZTEST_USER(usb_common, test_pd_board_check_request_default) +{ + /* The default implementation accepts any RDO. Just use a basic one. */ + zassert_ok(pd_board_check_request(RDO_FIXED(0, 3000, 3000, 0), 1)); +} -- cgit v1.2.1 From 68aaceab6d42796457f2f89f113e30dcd9ae64b4 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Fri, 28 Oct 2022 17:12:39 -0600 Subject: zephyr test: Verify pd_check_requested_voltage Verify that pd_check_requested_voltage rejects invalid RDOs. BUG=b:256182103 TEST=twister -t zephyr/test/drivers/drivers.usb_common BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I06d3f3379ae95acadfa8a2c92a9674da359b9e26 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3988519 Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- zephyr/test/drivers/usb_common/src/usb_common.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c index 8cd24821ee..ca29e9f207 100644 --- a/zephyr/test/drivers/usb_common/src/usb_common.c +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -110,3 +110,27 @@ ZTEST_USER(usb_common, test_pd_board_check_request_default) /* The default implementation accepts any RDO. Just use a basic one. */ zassert_ok(pd_board_check_request(RDO_FIXED(0, 3000, 3000, 0), 1)); } + +ZTEST_USER(usb_common, test_pd_check_requested_voltage) +{ + uint32_t rdo; + + rdo = RDO_FIXED(1, 1000, 1500, 0); + zassert_ok(pd_check_requested_voltage(rdo, 0)); + + /* An index of 0 is invalid. */ + rdo = RDO_FIXED(0, 1000, 1500, 0); + zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL); + /* So is an index larger than the number of source PDOs, which is 1 by + * default. + */ + rdo = RDO_FIXED(5, 1000, 1500, 0); + zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL); + + /* So is operating current too high. (This RDO doesn't make sense.) */ + rdo = RDO_FIXED(1, 1800, 1500, 0); + zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL); + /* So is maximum current too high. */ + rdo = RDO_FIXED(1, 1000, 1800, 0); + zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL); +} -- cgit v1.2.1 From 0ee5a8129d31a25e83803200b36988a3cda2f99a Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Thu, 6 Oct 2022 15:33:56 -0600 Subject: ec: Remove all zassume usages Since zassume is being used in scenarios where no one would use ztest_test_skip(), convert all zassumes to zasserts. BRANCH=None BUG=b:256650891 TEST=./twister Signed-off-by: Jeremy Bettis Change-Id: I1dc806e25f64f8dbef6f7d10cfe2f46ea4887e61 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3937539 Code-Coverage: Zoss Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Reviewed-by: Simon Glass Reviewed-by: Aaron Massey Commit-Queue: Jeremy Bettis Commit-Queue: Aaron Massey --- PRESUBMIT.cfg | 1 + docs/zephyr/ztest.md | 37 ++--------- .../drivers/ap_mux_control/src/ap_mux_control.c | 2 +- .../test/drivers/chargesplash/src/chargesplash.c | 4 +- .../drivers/common/include/test/drivers/utils.h | 46 ++++++-------- zephyr/test/drivers/common/src/utils.c | 6 +- zephyr/test/drivers/default/src/bb_retimer.c | 4 +- zephyr/test/drivers/default/src/bmi160.c | 4 +- .../default/src/console_cmd/charge_manager.c | 2 +- .../drivers/default/src/console_cmd/charge_state.c | 18 +++--- .../test/drivers/default/src/console_cmd/charger.c | 8 +-- .../test/drivers/default/src/console_cmd/cutoff.c | 2 +- .../drivers/default/src/console_cmd/hostevent.c | 2 +- zephyr/test/drivers/default/src/console_cmd/md.c | 10 +-- zephyr/test/drivers/default/src/console_cmd/rw.c | 12 ++-- .../drivers/default/src/console_cmd/tcpci_dump.c | 2 +- zephyr/test/drivers/default/src/espi.c | 2 +- zephyr/test/drivers/default/src/flash.c | 4 +- .../src/integration/usbc/usb_20v_3a_pd_charger.c | 6 +- .../src/integration/usbc/usb_5v_3a_pd_sink.c | 2 +- .../src/integration/usbc/usb_5v_3a_pd_source.c | 4 +- .../src/integration/usbc/usb_attach_src_snk.c | 14 ++--- .../src/integration/usbc/usb_pd_bist_shared.c | 10 +-- .../default/src/integration/usbc/usb_pd_ctrl_msg.c | 4 +- .../default/src/integration/usbc/usb_pd_rev3.c | 36 +++++------ zephyr/test/drivers/default/src/lid_switch.c | 4 +- zephyr/test/drivers/default/src/ppc_syv682x.c | 72 +++++++++++----------- zephyr/test/drivers/default/src/ps8xxx.c | 6 +- .../test/drivers/default/src/tcpci_test_common.c | 2 +- zephyr/test/drivers/default/src/virtual_battery.c | 4 +- zephyr/test/drivers/dps/src/dps.c | 4 +- .../test/drivers/host_cmd/src/get_pd_port_caps.c | 2 +- zephyr/test/drivers/host_cmd/src/motion_sense.c | 8 +-- zephyr/test/drivers/host_cmd/src/pd_chip_info.c | 4 +- zephyr/test/drivers/host_cmd/src/pd_control.c | 8 +-- zephyr/test/drivers/host_cmd/src/usb_pd_control.c | 4 +- .../drivers/keyboard_scan/src/keyboard_backlight.c | 6 +- .../test/drivers/keyboard_scan/src/keyboard_scan.c | 14 ++--- zephyr/test/drivers/keyboard_scan/src/mkbp_event.c | 2 +- .../usb_port_power_dumb/src/usb_port_power_dumb.c | 2 +- .../src/usb_retimer_fw_update.c | 4 +- .../test/drivers/usbc_alt_mode/src/usbc_alt_mode.c | 4 +- .../src/usbc_alt_mode__require_ap_mode_entry.c | 6 +- .../drivers/usbc_console_pd/src/usbc_console_pd.c | 4 +- .../test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c | 4 +- .../drivers/usbc_vconn_swap/src/usbc_vconn_swap.c | 6 +- 46 files changed, 186 insertions(+), 226 deletions(-) diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg index c42cb7d9b9..778c2046fb 100644 --- a/PRESUBMIT.cfg +++ b/PRESUBMIT.cfg @@ -14,6 +14,7 @@ tab_check: false black_check: --include_regex=^util/chargen$ checkpatch_check: --no-tree --ignore=MSLEEP,VOLATILE,SPDX_LICENSE_TAG kerneldoc_check: --include_regex=\bec_commands\.h$ +keyword_check: --block=zassume_ cros_license_check : --exclude_regex=^third_party/bmi220/ diff --git a/docs/zephyr/ztest.md b/docs/zephyr/ztest.md index 437c79d12e..84faa9371f 100644 --- a/docs/zephyr/ztest.md +++ b/docs/zephyr/ztest.md @@ -151,38 +151,11 @@ Other useful flags: ## Using assumptions -The `zassume_*` API is used to minimize failures while allowing us to find out -exactly what's going wrong. When writing a test, only assert on code you're -testing. Any dependencies should use the `zassume_*` API. If the assumption -fails, your test will be marked as skipped and Twister will report an error. -Generally speaking, if an assumption fails, either the test wasn't set up -correctly, or there should be another test that's testing the dependency. - -### Example: when to use an assumption - -In a given project layout we might have several components (A, B, C, and D). In -this scenario, components B, C, and D all depend on A to function. In each test -for B, C, and D we'll include the following: - -```c -static void test_suite_before(void *f) -{ - struct my_suite_fixture *fixture = f; - - zassume_ok(f->a->init(), "Failed to initialize A, see test suite 'a_init'"); -} -``` - -The above will call A's init function and assume that it returned 0 (status OK). -If this assumption fails, then B, C, and D will all be marked as skipped along -with a log message telling us to look at the test suite 'a_init'. - -Key takeaways: -1. If it's code that you depend on (module/library/logic), use assume. It's not - what you're testing, you shouldn't raise false failures. -2. Document why/where you believe that the logic should have been tested. If we - end up skipping this test, we should know where the tests that should have - caught the error belong. +The `zassume*` API is used to skip tests when certain preconditions are not +met. Please don't use it. In our tests we shouldn't ever need to skip tests +since we control all dependencies. If for some reason you actually need to skip +a test use `ztest_test_skip()` since that will indicate that you intended to +skip and didn't use assume by mistake when you meant to use assert. ## Debugging diff --git a/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c b/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c index d059870f25..632b8e6aea 100644 --- a/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c +++ b/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c @@ -23,7 +23,7 @@ static void ap_mux_control_before(void *data) k_sleep(K_SECONDS(1)); /* And test the assumption that setting NONE worked */ - zassume_equal(usb_mux_get(USBC_PORT_C0), USB_PD_MUX_NONE, + zassert_equal(usb_mux_get(USBC_PORT_C0), USB_PD_MUX_NONE, "Failed to set mux to initial state"); } diff --git a/zephyr/test/drivers/chargesplash/src/chargesplash.c b/zephyr/test/drivers/chargesplash/src/chargesplash.c index 9e5bf17019..08ba5377a0 100644 --- a/zephyr/test/drivers/chargesplash/src/chargesplash.c +++ b/zephyr/test/drivers/chargesplash/src/chargesplash.c @@ -85,7 +85,7 @@ static void set_lid(bool open, bool inhibit_boot) "inhibit_boot should not be used with a lid close"); } - zassume_ok(gpio_emul_input_set(lid_switch_dev, GPIO_LID_OPEN_EC_PORT, + zassert_ok(gpio_emul_input_set(lid_switch_dev, GPIO_LID_OPEN_EC_PORT, open), "Failed to set lid switch GPIO"); @@ -123,7 +123,7 @@ static void reset_state(void *unused) set_ac_enabled(false); } - zassume_ok(shell_execute_cmd(get_ec_shell(), "chargesplash reset"), + zassert_ok(shell_execute_cmd(get_ec_shell(), "chargesplash reset"), "'chargesplash reset' shell command failed"); } diff --git a/zephyr/test/drivers/common/include/test/drivers/utils.h b/zephyr/test/drivers/common/include/test/drivers/utils.h index af4469bc13..1a6799bd0d 100644 --- a/zephyr/test/drivers/common/include/test/drivers/utils.h +++ b/zephyr/test/drivers/common/include/test/drivers/utils.h @@ -71,21 +71,11 @@ void test_set_chipset_to_power_level(enum power_state new_state); /** @brief Set chipset to G3 state. Call all necessary hooks. */ void test_set_chipset_to_g3(void); -/* - * TODO(b/217755888): Implement ztest assume API upstream - */ - -/** - * @brief Assume that this function call won't be reached - * @param msg Optional message to print if the assumption fails - */ -#define zassume_unreachable(msg, ...) zassert_unreachable(msg, ##__VA_ARGS__) - /** * Run an ACPI read to the specified address. * * This function assumes a successful ACPI read process and will make a - * call to the zassume_* API. A failure here will skip the calling test. + * call to the zassert_* API. A failure here will fail the calling test. * * @param acpi_addr Address to query * @return Byte read @@ -96,7 +86,7 @@ uint8_t acpi_read(uint8_t acpi_addr); * Run an ACPI write to the specified address. * * This function assumes a successful ACPI write process and will make a - * call to the zassume_* API. A failure here will skip the calling test. + * call to the zassert_* API. A failure here will fail the calling test. * * @param acpi_addr Address to write * @param write_byte Byte to write to address @@ -107,7 +97,7 @@ void acpi_write(uint8_t acpi_addr, uint8_t write_byte); * Run the host command to gather our EC feature flags. * * This function assumes a successful host command processing and will make a - * call to the zassume_* API. A failure here will abort the calling test. + * call to the zassert_* API. A failure here will fail the calling test. * * @return The result of the host command */ @@ -117,7 +107,7 @@ static inline struct ec_response_get_features host_cmd_get_features(void) struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_FEATURES, 0, response); - zassume_ok(host_command_process(&args), "Failed to get features"); + zassert_ok(host_command_process(&args), "Failed to get features"); return response; } @@ -125,7 +115,7 @@ static inline struct ec_response_get_features host_cmd_get_features(void) * Run the host command to get the charge state for a given charger number. * * This function assumes a successful host command processing and will make a - * call to the zassume_* API. A failure here will abort the calling test. + * call to the zassert_* API. A failure here will fail the calling test. * * @param chgnum The charger number to query. * @return The result of the query. @@ -140,7 +130,7 @@ static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum) struct host_cmd_handler_args args = BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params); - zassume_ok(host_command_process(&args), + zassert_ok(host_command_process(&args), "Failed to get charge state for chgnum %d", chgnum); return response; } @@ -149,7 +139,7 @@ static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum) * Run the host command to get the USB PD power info for a given port. * * This function assumes a successful host command processing and will make a - * call to the zassume_* API. A failure here will abort the calling test. + * call to the zassert_* API. A failure here will fail the calling test. * * @param port The USB port to get info from. * @return The result of the query. @@ -161,7 +151,7 @@ static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port) struct host_cmd_handler_args args = BUILD_HOST_COMMAND( EC_CMD_USB_PD_POWER_INFO, 0, response, params); - zassume_ok(host_command_process(&args), + zassert_ok(host_command_process(&args), "Failed to get power info for port %d", port); return response; } @@ -170,7 +160,7 @@ static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port) * Run the host command to get the Type-C status information for a given port. * * This function assumes a successful host command processing and will make a - * call to the zassume_* API. A failure here will abort the calling test. + * call to the zassert_* API. A failure here will fail the calling test. * * @param port The USB port to get info from. * @return The result of the query. @@ -182,7 +172,7 @@ static inline struct ec_response_typec_status host_cmd_typec_status(int port) struct host_cmd_handler_args args = BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params); - zassume_ok(host_command_process(&args), + zassert_ok(host_command_process(&args), "Failed to get Type-C state for port %d", port); return response; } @@ -195,7 +185,7 @@ host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap) struct host_cmd_handler_args args = BUILD_HOST_COMMAND(EC_CMD_USB_PD_CONTROL, 0, response, params); - zassume_ok(host_command_process(&args), + zassert_ok(host_command_process(&args), "Failed to process usb_pd_control_swap for port %d, swap %d", port, swap); return response; @@ -205,7 +195,7 @@ host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap) * Run the host command to suspend/resume PD ports * * This function assumes a successful host command processing and will make a - * call to the zassume_* API. A failure here will skip the calling test. + * call to the zassert_* API. A failure here will fail the calling test. * * @param port The USB port to operate on * @param cmd The sub-command to run @@ -216,7 +206,7 @@ static inline void host_cmd_pd_control(int port, enum ec_pd_control_cmd cmd) struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params); - zassume_ok(host_command_process(&args), + zassert_ok(host_command_process(&args), "Failed to process pd_control for port %d, cmd %d", port, cmd); } @@ -240,7 +230,7 @@ host_cmd_charge_control(enum ec_charge_control_mode mode, struct host_cmd_handler_args args = BUILD_HOST_COMMAND(EC_CMD_CHARGE_CONTROL, 2, response, params); - zassume_ok(host_command_process(&args), + zassert_ok(host_command_process(&args), "Failed to get charge control values"); return response; @@ -260,7 +250,7 @@ enum ec_status host_cmd_host_event(enum ec_host_event_action action, /** * @brief Call the host command MOTION_SENSE with the dump sub-command * - * Note: this function uses the zassume_ API. It will skip the test if the host + * Note: this function uses the zassert_ API. It will fail the test if the host * command fails. * * @param max_sensor_count The maximum number of sensor data objects to populate @@ -589,7 +579,7 @@ void host_events_restore(struct host_events_ctx *host_events_ctx); * If enabled, the device _should_ begin charging. * * This function assumes a successful gpio emulator call and will make a call - * to the zassume_* API. A failure here will abort the calling test. + * to the zassert_* API. A failure here will fail the calling test. * * This function sleeps to wait for the GPIO interrupt to take place. * @@ -600,10 +590,10 @@ static inline void set_ac_enabled(bool enabled) const struct device *acok_dev = DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_ACOK_OD_NODE, gpios)); - zassume_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled), + zassert_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled), NULL); k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1)); - zassume_equal(enabled, extpower_is_present(), NULL); + zassert_equal(enabled, extpower_is_present(), NULL); } /** diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c index cc3ad1571d..646db0d27b 100644 --- a/zephyr/test/drivers/common/src/utils.c +++ b/zephyr/test/drivers/common/src/utils.c @@ -31,10 +31,6 @@ #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) #define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) -/* - * TODO(b/251281997): Switch zasserts back to zassumes when they loudly fail - */ - void test_set_battery_level(int percentage) { struct sbat_emul_bat_data *bat; @@ -592,7 +588,7 @@ void host_cmd_typec_control_bist_share_mode(int port, int enable) struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params); - zassume_ok(host_command_process(&args), + zassert_ok(host_command_process(&args), "Failed to send Type-C control for port %d", port); } diff --git a/zephyr/test/drivers/default/src/bb_retimer.c b/zephyr/test/drivers/default/src/bb_retimer.c index 1b1ec4bbbc..5edd0a7cc8 100644 --- a/zephyr/test/drivers/default/src/bb_retimer.c +++ b/zephyr/test/drivers/default/src/bb_retimer.c @@ -66,7 +66,7 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_state) /* Set UFP role for whole test */ tc_set_data_role(USBC_PORT_C1, PD_ROLE_UFP); - zassume_equal(PD_ROLE_UFP, pd_get_data_role(USBC_PORT_C1)); + zassert_equal(PD_ROLE_UFP, pd_get_data_role(USBC_PORT_C1)); /* Test none mode */ bb_emul_set_reg(emul, BB_RETIMER_REG_CONNECTION_STATE, 0x12144678); @@ -251,7 +251,7 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_dfp_state) set_test_runner_tid(); tc_set_data_role(USBC_PORT_C1, PD_ROLE_DFP); - zassume_equal(PD_ROLE_DFP, pd_get_data_role(USBC_PORT_C1)); + zassert_equal(PD_ROLE_DFP, pd_get_data_role(USBC_PORT_C1)); /* Test PD mux none mode with DFP should clear all bits in state */ bb_emul_set_reg(emul, BB_RETIMER_REG_CONNECTION_STATE, 0x12144678); diff --git a/zephyr/test/drivers/default/src/bmi160.c b/zephyr/test/drivers/default/src/bmi160.c index 01957672f7..edce38057b 100644 --- a/zephyr/test/drivers/default/src/bmi160.c +++ b/zephyr/test/drivers/default/src/bmi160.c @@ -2139,9 +2139,9 @@ static void bmi160_before(void *fixture) gyr_ms->rot_standard_ref = NULL; acc_ms->rot_standard_ref = NULL; - zassume_equal(EC_SUCCESS, acc_ms->drv->set_data_rate(acc_ms, 50000, 0), + zassert_equal(EC_SUCCESS, acc_ms->drv->set_data_rate(acc_ms, 50000, 0), NULL); - zassume_equal(EC_SUCCESS, gyr_ms->drv->set_data_rate(gyr_ms, 50000, 0), + zassert_equal(EC_SUCCESS, gyr_ms->drv->set_data_rate(gyr_ms, 50000, 0), NULL); } diff --git a/zephyr/test/drivers/default/src/console_cmd/charge_manager.c b/zephyr/test/drivers/default/src/console_cmd/charge_manager.c index a4679ddd25..12b2b174f4 100644 --- a/zephyr/test/drivers/default/src/console_cmd/charge_manager.c +++ b/zephyr/test/drivers/default/src/console_cmd/charge_manager.c @@ -111,7 +111,7 @@ ZTEST_USER(console_cmd_charge_manager, test_chgoverride_invalid_port) { char cmd[256]; - zassume_true(sprintf(cmd, "chgoverride %d", CHARGE_PORT_COUNT) > 0, + zassert_true(sprintf(cmd, "chgoverride %d", CHARGE_PORT_COUNT) > 0, NULL); zassert_equal(shell_execute_cmd(get_ec_shell(), cmd), EC_ERROR_PARAM1, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/charge_state.c b/zephyr/test/drivers/default/src/console_cmd/charge_state.c index 7ee91049ae..5eb21f9ff8 100644 --- a/zephyr/test/drivers/default/src/console_cmd/charge_state.c +++ b/zephyr/test/drivers/default/src/console_cmd/charge_state.c @@ -116,7 +116,7 @@ ZTEST_USER(console_cmd_charge_state, test_debug_on_show_charging_progress) charging_progress_displayed(); /* Enable debug printing */ - zassume_ok(shell_execute_cmd(get_ec_shell(), "chgstate debug on"), + zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate debug on"), NULL); /* Sleep at least 1 full iteration of the charge state loop */ @@ -206,7 +206,7 @@ ZTEST_USER_F(console_cmd_charge_state, test_idle_on_from_normal) fixture->tcpci_emul, fixture->charger_emul); /* Verify that we're in "normal" mode */ - zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL); + zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL); /* Move to idle */ zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate idle on")); @@ -220,11 +220,11 @@ ZTEST_USER_F(console_cmd_charge_state, test_normal_from_idle) fixture->tcpci_emul, fixture->charger_emul); /* Verify that we're in "normal" mode */ - zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL); + zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL); /* Move to idle */ - zassume_ok(shell_execute_cmd(get_ec_shell(), "chgstate idle on")); - zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_IDLE); + zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate idle on")); + zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_IDLE); /* Move back to normal */ zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate idle off"), @@ -239,7 +239,7 @@ ZTEST_USER_F(console_cmd_charge_state, test_discharge_on) fixture->tcpci_emul, fixture->charger_emul); /* Verify that we're in "normal" mode */ - zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL); + zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL); /* Enable discharge */ zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate discharge on"), @@ -254,12 +254,12 @@ ZTEST_USER_F(console_cmd_charge_state, test_discharge_off) fixture->tcpci_emul, fixture->charger_emul); /* Verify that we're in "normal" mode */ - zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL); + zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL); /* Enable discharge */ - zassume_ok(shell_execute_cmd(get_ec_shell(), "chgstate discharge on"), + zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate discharge on"), NULL); - zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_DISCHARGE); + zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_DISCHARGE); /* Disable discharge */ zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate discharge off"), diff --git a/zephyr/test/drivers/default/src/console_cmd/charger.c b/zephyr/test/drivers/default/src/console_cmd/charger.c index 9adda29a8d..63cc0a3118 100644 --- a/zephyr/test/drivers/default/src/console_cmd/charger.c +++ b/zephyr/test/drivers/default/src/console_cmd/charger.c @@ -81,7 +81,7 @@ ZTEST_USER(console_cmd_charger, test_good_input_current) zassert_ok(shell_execute_cmd(get_ec_shell(), "charger input 1000"), "Failed to set input current"); - zassume_ok(charger_get_input_current_limit(0, &input_current), + zassert_ok(charger_get_input_current_limit(0, &input_current), "Failed to get input current"); zassert_equal(input_current, 1000, "Input current not set in charger: %d", input_current); @@ -117,7 +117,7 @@ static void *console_cmd_charger_setup(void) static struct console_cmd_charger_fixture fixture; /* Assume we have one charger at index 0 */ - zassume_true(board_get_charger_chip_count() > 0, + zassert_true(board_get_charger_chip_count() > 0, "Insufficient chargers found"); /* Get references for the emulators */ @@ -158,7 +158,7 @@ ZTEST_USER_F(console_cmd_charger, test_good_current) /* Give the charger task time to pick up the manual current */ k_sleep(K_SECONDS(1)); - zassume_ok(charger_get_current(0, ¤t), "Failed to get current"); + zassert_ok(charger_get_current(0, ¤t), "Failed to get current"); zassert_equal(current, 1000, "Current not set in charger: %d", current); } @@ -176,7 +176,7 @@ ZTEST_USER_F(console_cmd_charger, test_good_voltage) /* Give the charger task time to pick up the manual voltage */ k_sleep(K_SECONDS(1)); - zassume_ok(charger_get_voltage(0, &voltage), "Failed to get voltage"); + zassert_ok(charger_get_voltage(0, &voltage), "Failed to get voltage"); zassert_equal(voltage, 3000, "Voltage not set in charger: %d", voltage); } diff --git a/zephyr/test/drivers/default/src/console_cmd/cutoff.c b/zephyr/test/drivers/default/src/console_cmd/cutoff.c index 00ce40660f..e17f8745bd 100644 --- a/zephyr/test/drivers/default/src/console_cmd/cutoff.c +++ b/zephyr/test/drivers/default/src/console_cmd/cutoff.c @@ -58,7 +58,7 @@ ZTEST_USER(console_cmd_cutoff, test_clear_pending_shutdown) { int rv = shell_execute_cmd(get_ec_shell(), "cutoff at-shutdown"); - zassume_true(extpower_is_present(), NULL); + zassert_true(extpower_is_present(), NULL); zassert_equal(EC_RES_SUCCESS, rv, "Expected %d, but got %d", EC_RES_SUCCESS, rv); diff --git a/zephyr/test/drivers/default/src/console_cmd/hostevent.c b/zephyr/test/drivers/default/src/console_cmd/hostevent.c index af9b37edd1..acb8b890e4 100644 --- a/zephyr/test/drivers/default/src/console_cmd/hostevent.c +++ b/zephyr/test/drivers/default/src/console_cmd/hostevent.c @@ -52,7 +52,7 @@ static int console_cmd_hostevent(const char *subcommand, host_event_t mask) "hostevent %s 0x%" HOSTEVENT_PRINT_FORMAT, subcommand, mask); - zassume_between_inclusive(rv, 0, CONFIG_SHELL_CMD_BUFF_SIZE, + zassert_between_inclusive(rv, 0, CONFIG_SHELL_CMD_BUFF_SIZE, "hostevent console command too long"); return shell_execute_cmd(get_ec_shell(), cmd_buf); diff --git a/zephyr/test/drivers/default/src/console_cmd/md.c b/zephyr/test/drivers/default/src/console_cmd/md.c index c8c3e2c130..138dbccf98 100644 --- a/zephyr/test/drivers/default/src/console_cmd/md.c +++ b/zephyr/test/drivers/default/src/console_cmd/md.c @@ -36,7 +36,7 @@ ZTEST_USER(console_cmd_md, test_default_count) uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04 }; char cmd[128] = { 0 }; - zassume_true(sprintf(cmd, "md %" PRIuPTR, (uintptr_t)memory) != 0, + zassert_true(sprintf(cmd, "md %" PRIuPTR, (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); } @@ -46,7 +46,7 @@ ZTEST_USER(console_cmd_md, test_count_arg) uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; char cmd[128] = { 0 }; - zassume_true(sprintf(cmd, "md %" PRIuPTR " 2", (uintptr_t)memory) != 0, + zassert_true(sprintf(cmd, "md %" PRIuPTR " 2", (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); } @@ -56,7 +56,7 @@ ZTEST_USER(console_cmd_md, test_byte_format) uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04 }; char cmd[128] = { 0 }; - zassume_true(sprintf(cmd, "md .b %" PRIuPTR, (uintptr_t)memory) != 0, + zassert_true(sprintf(cmd, "md .b %" PRIuPTR, (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); } @@ -66,7 +66,7 @@ ZTEST_USER(console_cmd_md, test_half_format) uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04 }; char cmd[128] = { 0 }; - zassume_true(sprintf(cmd, "md .h %" PRIuPTR, (uintptr_t)memory) != 0, + zassert_true(sprintf(cmd, "md .h %" PRIuPTR, (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); } @@ -76,7 +76,7 @@ ZTEST_USER(console_cmd_md, test_string_format) char memory[] = "hello world"; char cmd[128] = { 0 }; - zassume_true(sprintf(cmd, "md .s %" PRIuPTR " 12", (uintptr_t)memory) != + zassert_true(sprintf(cmd, "md .s %" PRIuPTR " 12", (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/rw.c b/zephyr/test/drivers/default/src/console_cmd/rw.c index aac37680f5..a25bf5f07c 100644 --- a/zephyr/test/drivers/default/src/console_cmd/rw.c +++ b/zephyr/test/drivers/default/src/console_cmd/rw.c @@ -43,15 +43,15 @@ ZTEST_USER(console_cmd_rw, test_read) uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04 }; char cmd[128] = { 0 }; - zassume_true(sprintf(cmd, "rw .b %" PRIuPTR, (uintptr_t)memory) != 0, + zassert_true(sprintf(cmd, "rw .b %" PRIuPTR, (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); - zassume_true(sprintf(cmd, "rw .h %" PRIuPTR, (uintptr_t)memory) != 0, + zassert_true(sprintf(cmd, "rw .h %" PRIuPTR, (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); - zassume_true(sprintf(cmd, "rw %" PRIuPTR, (uintptr_t)memory) != 0, + zassert_true(sprintf(cmd, "rw %" PRIuPTR, (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); } @@ -71,7 +71,7 @@ ZTEST_USER(console_cmd_rw, test_write) uint8_t memory[4] = { 0 }; char cmd[128] = { 0 }; - zassume_true(sprintf(cmd, "rw .b %" PRIuPTR " 1", (uintptr_t)memory) != + zassert_true(sprintf(cmd, "rw .b %" PRIuPTR " 1", (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); @@ -81,7 +81,7 @@ ZTEST_USER(console_cmd_rw, test_write) zassert_equal(0, memory[3], "memory[3] was %u", memory[3]); memset(memory, 0, 4); - zassume_true(sprintf(cmd, "rw .h %" PRIuPTR " 258", + zassert_true(sprintf(cmd, "rw .h %" PRIuPTR " 258", (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); @@ -91,7 +91,7 @@ ZTEST_USER(console_cmd_rw, test_write) zassert_equal(0, memory[3], "memory[3] was %u", memory[3]); memset(memory, 0, 4); - zassume_true(sprintf(cmd, "rw %" PRIuPTR " 16909060", + zassert_true(sprintf(cmd, "rw %" PRIuPTR " 16909060", (uintptr_t)memory) != 0, NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c b/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c index 9652519cab..88379a78bd 100644 --- a/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c +++ b/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c @@ -38,7 +38,7 @@ static void console_cmd_tcpci_dump_begin(void *data) ARG_UNUSED(data); /* Assume we have at least one TCPC */ - zassume_true(board_get_charger_chip_count() > 0, + zassert_true(board_get_charger_chip_count() > 0, "Insufficient TCPCs found"); } diff --git a/zephyr/test/drivers/default/src/espi.c b/zephyr/test/drivers/default/src/espi.c index ac6c93f3fc..413d42b4c1 100644 --- a/zephyr/test/drivers/default/src/espi.c +++ b/zephyr/test/drivers/default/src/espi.c @@ -214,7 +214,7 @@ ZTEST_USER(espi, test_host_command_gpio_set) BUILD_HOST_COMMAND_PARAMS(EC_CMD_GPIO_SET, 0, p); /* Force value to 1 to see change */ - zassume_ok(gpio_pin_set_dt(gp, 1), NULL); + zassert_ok(gpio_pin_set_dt(gp, 1), NULL); zassert_ok(host_command_process(&args), NULL); zassert_equal(gpio_pin_get_dt(gp), p.val, NULL); diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c index 6794ca2878..8f8208415e 100644 --- a/zephyr/test/drivers/default/src/flash.c +++ b/zephyr/test/drivers/default/src/flash.c @@ -414,7 +414,7 @@ static void setup_flash_region_helper(uint32_t offset, uint32_t size, int rv; rv = host_command_process(&erase_args); - zassume_ok(rv, "Got %d", rv); + zassert_ok(rv, "Got %d", rv); if (make_write) { /* Sized for flash_write header plus one byte of data */ @@ -434,7 +434,7 @@ static void setup_flash_region_helper(uint32_t offset, uint32_t size, /* Write one byte at start of region */ out_buf[sizeof(*write_params)] = 0xec; - zassume_ok(host_command_process(&write_args), NULL); + zassert_ok(host_command_process(&write_args), NULL); } } diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c b/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c index 07b1b5143e..d5c975894e 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c @@ -26,7 +26,7 @@ static inline void connect_charger_to_port(struct usb_attach_20v_3a_pd_charger_fixture *fixture) { set_ac_enabled(true); - zassume_ok(tcpci_partner_connect_to_tcpci(&fixture->charger_20v, + zassert_ok(tcpci_partner_connect_to_tcpci(&fixture->charger_20v, fixture->tcpci_emul), NULL); @@ -43,7 +43,7 @@ static inline void disconnect_charger_from_port( struct usb_attach_20v_3a_pd_charger_fixture *fixture) { set_ac_enabled(false); - zassume_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul)); + zassert_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul)); isl923x_emul_set_adc_vbus(fixture->charger_emul, 0); k_sleep(K_SECONDS(1)); } @@ -88,7 +88,7 @@ ZTEST(usb_attach_20v_3a_pd_charger, test_battery_is_charging) const struct emul *emul = EMUL_DT_GET(BATTERY_NODE); uint16_t battery_status; - zassume_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS, + zassert_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS, &battery_status), NULL); zassert_equal(battery_status & STATUS_DISCHARGING, 0, diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c index e3584470a0..c29762063c 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c @@ -85,7 +85,7 @@ ZTEST(usb_attach_5v_3a_pd_sink, test_battery_is_discharging) const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(battery)); uint16_t battery_status; - zassume_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS, + zassert_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS, &battery_status)); zassert_equal(battery_status & STATUS_DISCHARGING, STATUS_DISCHARGING, "Battery is not discharging: %d", battery_status); diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c index c73cf26f37..a780277d05 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c @@ -70,7 +70,7 @@ static void control_battery_present(bool present) DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios)); /* 0 means battery present */ - zassume_ok(gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, !present)); + zassert_ok(gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, !present)); } ZTEST_SUITE(usb_attach_5v_3a_pd_source, drivers_predicate_post_main, @@ -82,7 +82,7 @@ ZTEST(usb_attach_5v_3a_pd_source, test_battery_is_charging) const struct emul *emul = EMUL_DT_GET(BATTERY_NODE); uint16_t battery_status; - zassume_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS, + zassert_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS, &battery_status)); zassert_equal(battery_status & STATUS_DISCHARGING, 0, "Battery is discharging: %d", battery_status); diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c b/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c index 0b65f9b135..bcc94fe869 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c @@ -117,21 +117,21 @@ static void attach_src_snk_common_before(struct emul_state *my_emul_state) /* TODO(b/217737667): Remove driver specific code. */ isl923x_emul_set_adc_vbus(charger_emul, 0); - zassume_ok(tcpc_config[SNK_PORT].drv->init(SNK_PORT)); + zassert_ok(tcpc_config[SNK_PORT].drv->init(SNK_PORT)); /* * Arbitrary FW ver. The emulator should really be setting this * during its init. */ tcpci_emul_set_reg(tcpci_emul_snk, PS8XXX_REG_FW_REV, 0x31); - zassume_ok(tcpc_config[SRC_PORT].drv->init(SRC_PORT)); + zassert_ok(tcpc_config[SRC_PORT].drv->init(SRC_PORT)); pd_set_suspend(SNK_PORT, false); pd_set_suspend(SRC_PORT, false); /* Reset to disconnected state. */ - zassume_ok(tcpci_emul_disconnect_partner(tcpci_emul_src)); - zassume_ok(tcpci_emul_disconnect_partner(tcpci_emul_snk)); + zassert_ok(tcpci_emul_disconnect_partner(tcpci_emul_src)); + zassert_ok(tcpci_emul_disconnect_partner(tcpci_emul_snk)); /* Set chipset to ON, this will set TCPM to DRP */ test_set_chipset_to_s0(); @@ -177,7 +177,7 @@ static void attach_emulated_snk(struct emul_state *my_emul_state) tcpci_emul_set_reg(tcpci_emul_snk, TCPC_REG_EXT_STATUS, TCPC_REG_EXT_STATUS_SAFE0V); - zassume_ok(tcpci_partner_connect_to_tcpci(my_snk, tcpci_emul_snk), + zassert_ok(tcpci_partner_connect_to_tcpci(my_snk, tcpci_emul_snk), NULL); /* TODO(b/214401892): Check why need to give time TCPM to spin */ @@ -207,7 +207,7 @@ static void attach_emulated_src(struct emul_state *my_emul_state) tcpci_emul_set_reg(tcpci_emul_src, TCPC_REG_EXT_STATUS, TCPC_REG_EXT_STATUS_SAFE0V); - zassume_ok(tcpci_partner_connect_to_tcpci(my_src, tcpci_emul_src), + zassert_ok(tcpci_partner_connect_to_tcpci(my_src, tcpci_emul_src), NULL); isl923x_emul_set_adc_vbus(charger_emul, DEFAULT_VBUS_MV); } @@ -542,7 +542,7 @@ struct usb_detach_test_fixture { static void integration_usb_test_detach(const struct emul *e) { - zassume_ok(tcpci_emul_disconnect_partner(e)); + zassert_ok(tcpci_emul_disconnect_partner(e)); } static void integration_usb_test_sink_detach(struct emul_state *fixture) diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c index 47e26f97d6..56cbee7ad0 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c @@ -99,7 +99,7 @@ ZTEST_F(usb_pd_bist_shared, verify_bist_shared_mode) /* Start up BIST shared test mode */ bist_data = BDO(BDO_MODE_SHARED_ENTER, 0); - zassume_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma, + zassert_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma, PD_DATA_BIST, &bist_data, 1, 0), "Failed to send BIST enter message"); @@ -116,7 +116,7 @@ ZTEST_F(usb_pd_bist_shared, verify_bist_shared_mode) /* Leave BIST shared test mode */ bist_data = BDO(BDO_MODE_SHARED_EXIT, 0); - zassume_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma, + zassert_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma, PD_DATA_BIST, &bist_data, 1, 0), "Failed to send BIST exit message"); @@ -152,7 +152,7 @@ ZTEST_F(usb_pd_bist_shared, verify_bist_shared_no_snk_entry) /* Have the source send the BIST Enter Mode */ bist_data = BDO(BDO_MODE_SHARED_ENTER, 0); - zassume_ok(tcpci_partner_send_data_msg(&fixture->src, PD_DATA_BIST, + zassert_ok(tcpci_partner_send_data_msg(&fixture->src, PD_DATA_BIST, &bist_data, 1, 0), "Failed to send BIST enter message"); @@ -181,7 +181,7 @@ ZTEST_F(usb_pd_bist_shared, verify_bist_shared_exit_no_action) tcpci_snk_emul_clear_last_5v_cap(&fixture->snk_ext_500ma); bist_data = BDO(BDO_MODE_SHARED_EXIT, 0); - zassume_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma, + zassert_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma, PD_DATA_BIST, &bist_data, 1, 0), "Failed to send BIST exit message"); @@ -198,7 +198,7 @@ ZTEST_F(usb_pd_bist_shared, verify_control_bist_shared_mode) uint32_t f5v_cap; host_cmd_typec_control_bist_share_mode(USBC_PORT_C0, 1); - zassume_ok(tcpci_partner_send_control_msg(&fixture->sink_5v_500ma, + zassert_ok(tcpci_partner_send_control_msg(&fixture->sink_5v_500ma, PD_CTRL_GET_SOURCE_CAP, 0), "Failed to send get src cap"); /* wait tSenderResponse (26 ms) */ diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c index e35e2a7ec1..87b559dd7c 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c @@ -59,13 +59,13 @@ tcpci_drp_emul_connect_partner(struct tcpci_partner_data *partner_emul, tcpci_tcpc_alert(TEST_USB_PORT); - zassume_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpci_emul), + zassert_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpci_emul), NULL); } static void disconnect_partner(struct usb_pd_ctrl_msg_test_fixture *fixture) { - zassume_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul)); + zassert_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul)); k_sleep(K_SECONDS(1)); } diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c index fdea74a691..2eff9996f2 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c @@ -62,11 +62,11 @@ static void usb_attach_5v_3a_pd_source_before(void *data) /* Clear Alert and Status receive checks */ tcpci_src_emul_clear_alert_received(&fixture->src_ext); tcpci_src_emul_clear_status_received(&fixture->src_ext); - zassume_false(fixture->src_ext.alert_received); - zassume_false(fixture->src_ext.status_received); + zassert_false(fixture->src_ext.alert_received); + zassert_false(fixture->src_ext.status_received); /* Initial check on power state */ - zassume_true(chipset_in_state(CHIPSET_STATE_ON)); + zassert_true(chipset_in_state(CHIPSET_STATE_ON)); } static void usb_attach_5v_3a_pd_source_after(void *data) @@ -112,8 +112,8 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, test_batt_cap) /* See pe_give_battery_cap_entry() in common/usbc/usb_pe_drp_sm.c */ - zassume_true(battery_is_present(), "Battery must be present"); - zassume_true(IS_ENABLED(HAS_TASK_HOSTCMD) && + zassert_true(battery_is_present(), "Battery must be present"); + zassert_true(IS_ENABLED(HAS_TASK_HOSTCMD) && *host_get_memmap(EC_MEMMAP_BATTERY_VERSION) != 0, "Cannot access battery data"); @@ -171,7 +171,7 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, test_batt_cap_invalid) ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_alert_msg) { - zassume_equal(pd_broadcast_alert_msg(ADO_OTP_EVENT), EC_SUCCESS); + zassert_equal(pd_broadcast_alert_msg(ADO_OTP_EVENT), EC_SUCCESS); k_sleep(K_SECONDS(2)); zassert_true(fixture->src_ext.alert_received); @@ -186,8 +186,8 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_alert_on_power_state_change) zassert_true(fixture->src_ext.status_received); tcpci_src_emul_clear_alert_received(&fixture->src_ext); tcpci_src_emul_clear_status_received(&fixture->src_ext); - zassume_false(fixture->src_ext.alert_received); - zassume_false(fixture->src_ext.status_received); + zassert_false(fixture->src_ext.alert_received); + zassert_false(fixture->src_ext.status_received); /* Shutdown and check partner received Alert and Status messages */ hook_notify(HOOK_CHIPSET_SHUTDOWN); @@ -196,8 +196,8 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_alert_on_power_state_change) zassert_true(fixture->src_ext.status_received); tcpci_src_emul_clear_alert_received(&fixture->src_ext); tcpci_src_emul_clear_status_received(&fixture->src_ext); - zassume_false(fixture->src_ext.alert_received); - zassume_false(fixture->src_ext.status_received); + zassert_false(fixture->src_ext.alert_received); + zassert_false(fixture->src_ext.status_received); /* Startup and check partner received Alert and Status messages */ hook_notify(HOOK_CHIPSET_STARTUP); @@ -206,8 +206,8 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_alert_on_power_state_change) zassert_true(fixture->src_ext.status_received); tcpci_src_emul_clear_alert_received(&fixture->src_ext); tcpci_src_emul_clear_status_received(&fixture->src_ext); - zassume_false(fixture->src_ext.alert_received); - zassume_false(fixture->src_ext.status_received); + zassert_false(fixture->src_ext.alert_received); + zassert_false(fixture->src_ext.status_received); /* Resume and check partner received Alert and Status messages */ hook_notify(HOOK_CHIPSET_RESUME); @@ -247,9 +247,9 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, /* Clear alert and status flags set during shutdown */ tcpci_src_emul_clear_alert_received(&fixture->src_ext); tcpci_src_emul_clear_status_received(&fixture->src_ext); - zassume_false(fixture->src_ext.alert_received); - zassume_false(fixture->src_ext.status_received); - zassume_true(chipset_in_state(CHIPSET_STATE_ANY_OFF)); + zassert_false(fixture->src_ext.alert_received); + zassert_false(fixture->src_ext.status_received); + zassert_true(chipset_in_state(CHIPSET_STATE_ANY_OFF)); /* While in S5/G3 expect nothing on invalid (too long) press */ ado = ADO_EXTENDED_ALERT_EVENT | ADO_POWER_BUTTON_PRESS; @@ -283,9 +283,9 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_startup_on_pd_button_press) /* Clear alert and status flags set during shutdown */ tcpci_src_emul_clear_alert_received(&fixture->src_ext); tcpci_src_emul_clear_status_received(&fixture->src_ext); - zassume_false(fixture->src_ext.alert_received); - zassume_false(fixture->src_ext.status_received); - zassume_true(chipset_in_state(CHIPSET_STATE_ANY_OFF)); + zassert_false(fixture->src_ext.alert_received); + zassert_false(fixture->src_ext.status_received); + zassert_true(chipset_in_state(CHIPSET_STATE_ANY_OFF)); /* While in S5/G3 expect Alert->Get_Status->Status on valid press */ ado = ADO_EXTENDED_ALERT_EVENT | ADO_POWER_BUTTON_PRESS; diff --git a/zephyr/test/drivers/default/src/lid_switch.c b/zephyr/test/drivers/default/src/lid_switch.c index b5da1f6608..a0920234b3 100644 --- a/zephyr/test/drivers/default/src/lid_switch.c +++ b/zephyr/test/drivers/default/src/lid_switch.c @@ -49,8 +49,8 @@ static void *lid_switch_setup(void) static void lid_switch_before(void *unused) { /* Make sure that interrupt fire at the next lid open/close */ - zassume_ok(emul_lid_close()); - zassume_ok(emul_lid_open()); + zassert_ok(emul_lid_close()); + zassert_ok(emul_lid_open()); k_sleep(K_MSEC(100)); } diff --git a/zephyr/test/drivers/default/src/ppc_syv682x.c b/zephyr/test/drivers/default/src/ppc_syv682x.c index ba2e68f2ff..648510da07 100644 --- a/zephyr/test/drivers/default/src/ppc_syv682x.c +++ b/zephyr/test/drivers/default/src/ppc_syv682x.c @@ -46,10 +46,10 @@ static void *syv682x_test_setup(void) fixture.ppc_emul = EMUL_DT_GET(SYV682X_NODE); fixture.common_data = emul_syv682x_get_i2c_common_data(fixture.ppc_emul); - zassume_not_null(fixture.ppc_emul, NULL); + zassert_not_null(fixture.ppc_emul, NULL); fixture.frs_en_gpio_port = DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_USB_C1_FRS_EN_PATH, gpios)); - zassume_not_null(fixture.frs_en_gpio_port, NULL); + zassert_not_null(fixture.frs_en_gpio_port, NULL); fixture.frs_en_gpio_pin = DT_GPIO_PIN(GPIO_USB_C1_FRS_EN_PATH, gpios); return &fixture; @@ -62,7 +62,7 @@ static void syv682x_test_after(void *data) struct i2c_common_emul_data *common_data = fixture->common_data; /* Disable the power path and clear interrupt conditions. */ - zassume_ok(syv682x_emul_set_reg(emul, SYV682X_CONTROL_1_REG, + zassert_ok(syv682x_emul_set_reg(emul, SYV682X_CONTROL_1_REG, SYV682X_CONTROL_1_PWR_ENB), NULL); syv682x_emul_set_condition(emul, SYV682X_STATUS_NONE, @@ -120,14 +120,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_dead_battery) * With a dead battery, the device powers up sinking VBUS, and the * driver should keep that going. */ - zassume_ok(syv682x_emul_set_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_set_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, SYV682X_CONTROL_1_CH_SEL), NULL); syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_VSAFE_5V, SYV682X_CONTROL_4_NONE); zassert_ok(ppc_init(syv682x_port), "PPC init failed"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), NULL); zassert_true(reg & SYV682X_CONTROL_1_CH_SEL, @@ -144,14 +144,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_vsafe0v) uint8_t reg; /* With VBUS at vSafe0V, init should set the default configuration. */ - zassume_ok(syv682x_emul_set_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_set_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, SYV682X_CONTROL_1_PWR_ENB), NULL); syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_VSAFE_0V, SYV682X_CONTROL_4_NONE); zassert_ok(ppc_init(syv682x_port), "PPC init failed"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), NULL); check_control_1_default_init(reg); @@ -162,14 +162,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_sink_disabled) uint8_t reg; /* With sink disabled, init should do the same thing. */ - zassume_ok(syv682x_emul_set_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_set_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, SYV682X_CONTROL_1_CH_SEL), NULL); syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_VSAFE_0V, SYV682X_CONTROL_4_NONE); zassert_ok(ppc_init(syv682x_port), "PPC init failed"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), NULL); check_control_1_default_init(reg); @@ -181,7 +181,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_common) int ilim; zassert_ok(ppc_init(syv682x_port), "PPC init failed"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), NULL); @@ -196,7 +196,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_common) ilim = (reg & SYV682X_5V_ILIM_MASK) >> SYV682X_5V_ILIM_BIT_SHIFT; zassert_equal(ilim, CONFIG_PLATFORM_EC_USB_PD_PULLUP, "Default init, but 5V current limit set to %d", ilim); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_2_REG, ®), NULL); zassert_equal(reg, @@ -205,14 +205,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_common) << SYV682X_DSG_RON_SHIFT) | (SYV682X_DSG_TIME_50MS << SYV682X_DSG_TIME_SHIFT), "Default init, but CONTROL_2 is 0x%x", reg); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_3_REG, ®), NULL); zassert_equal(reg, (SYV682X_OVP_23_7 << SYV682X_OVP_BIT_SHIFT) | SYV682X_RVS_MASK, "Default init, but CONTROL_3 is 0x%x", reg); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_4_REG, ®), NULL); zassert_equal(reg & ~SYV682X_CONTROL_4_INT_MASK, @@ -226,7 +226,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_source_enable) zassert_ok(ppc_vbus_source_enable(syv682x_port, true), "VBUS enable failed"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), "Reading CONTROL_1 failed"); zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0, @@ -245,7 +245,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_source_disable) ZTEST_F(ppc_syv682x, test_syv682x_interrupt_source_oc) { - zassume_ok(ppc_vbus_source_enable(syv682x_port, true), + zassert_ok(ppc_vbus_source_enable(syv682x_port, true), "VBUS enable failed"); /* An OC event less than 100 ms should not cause VBUS to turn off. */ syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_OC_5V, @@ -266,7 +266,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_tsd) * (The device will have already physically disabled them.) The state of * the sink path is not part of the driver's API. */ - zassume_ok(ppc_vbus_source_enable(syv682x_port, true), + zassert_ok(ppc_vbus_source_enable(syv682x_port, true), "Source enable failed"); syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_TSD, SYV682X_CONTROL_4_NONE); @@ -278,7 +278,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_tsd) ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vbus_ovp) { /* An OVP event should cause the driver to disable the source path. */ - zassume_ok(ppc_vbus_source_enable(syv682x_port, true), + zassert_ok(ppc_vbus_source_enable(syv682x_port, true), "Source enable failed"); syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_OVP, SYV682X_CONTROL_4_NONE); @@ -296,12 +296,12 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vbus_hv_oc) * re-enable the sink path until the OC count limit is reached, at which * point the driver should leave it disabled. */ - zassume_ok(ppc_vbus_sink_enable(syv682x_port, true), + zassert_ok(ppc_vbus_sink_enable(syv682x_port, true), "Sink enable failed"); syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_OC_HV, SYV682X_CONTROL_4_NONE); msleep(1); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), "Reading CONTROL_1 failed"); zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0, @@ -310,7 +310,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vbus_hv_oc) SYV682X_CONTROL_4_NONE); /* Alert GPIO doesn't change so wait for delayed syv682x interrupt */ msleep(15); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), "Reading CONTROL_1 failed"); zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0, @@ -319,7 +319,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vbus_hv_oc) SYV682X_CONTROL_4_NONE); /* Alert GPIO doesn't change so wait for delayed syv682x interrupt */ msleep(15); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), "Reading CONTROL_1 failed"); zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, @@ -339,14 +339,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vconn_oc) syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_NONE, SYV682X_CONTROL_4_VCONN_OCP); msleep(1); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_4_REG, ®), "Reading CONTROL_4 failed"); zassert_true(reg & (SYV682X_CONTROL_4_VCONN1 | SYV682X_CONTROL_4_VCONN2), "VCONN disabled after initial VCONN OC"); msleep(50); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_4_REG, ®), "Reading CONTROL_4 failed"); zassert_true(reg & (SYV682X_CONTROL_4_VCONN1 | @@ -357,7 +357,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vconn_oc) * should turn VCONN off. */ msleep(60); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_4_REG, ®), "Reading CONTROL_4 failed"); zassert_false(reg & (SYV682X_CONTROL_4_VCONN1 | @@ -379,7 +379,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vconn_ov) syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_NONE, SYV682X_CONTROL_4_VBAT_OVP); msleep(1); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_4_REG, ®), "Reading CONTROL_4 failed"); zassert_true(reg & SYV682X_CONTROL_4_CC1_BPS, @@ -402,7 +402,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_frs_enable) * polarity. Disabling FRS should enable both CC lines. */ ppc_vbus_sink_enable(syv682x_port, true); - zassume_false(ppc_is_sourcing_vbus(syv682x_port), + zassert_false(ppc_is_sourcing_vbus(syv682x_port), "PPC is sourcing VBUS after sink enabled"); ppc_set_polarity(syv682x_port, 0 /* CC1 */); ppc_set_frs_enable(syv682x_port, true); @@ -424,14 +424,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_frs_disable) uint8_t reg; ppc_vbus_sink_enable(syv682x_port, true); - zassume_false(ppc_is_sourcing_vbus(syv682x_port), + zassert_false(ppc_is_sourcing_vbus(syv682x_port), "PPC is sourcing VBUS after sink enabled"); ppc_set_polarity(syv682x_port, 0 /* CC1 */); ppc_set_frs_enable(syv682x_port, false); zassert_equal(gpio_emul_output_get(gpio_dev, fixture->frs_en_gpio_pin), 0, "FRS disabled, but FRS GPIO not deasserted"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_4_REG, ®), "Reading CONTROL_4 failed"); zassert_equal( @@ -463,7 +463,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_source_current_limit_usb_default) zassert_ok(ppc_set_vbus_source_current_limit(syv682x_port, TYPEC_RP_USB), "Could not set source current limit"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), "Reading CONTROL_1 failed"); ilim_val = (reg & SYV682X_5V_ILIM_MASK) >> SYV682X_5V_ILIM_BIT_SHIFT; @@ -479,7 +479,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_source_current_limit_1500ma) zassert_ok(ppc_set_vbus_source_current_limit(syv682x_port, TYPEC_RP_1A5), "Could not set source current limit"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), "Reading CONTROL_1 failed"); ilim_val = (reg & SYV682X_5V_ILIM_MASK) >> SYV682X_5V_ILIM_BIT_SHIFT; @@ -495,7 +495,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_source_current_limit_3000ma) zassert_ok(ppc_set_vbus_source_current_limit(syv682x_port, TYPEC_RP_3A0), "Could not set source current limit"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), "Reading CONTROL_1 failed"); ilim_val = (reg & SYV682X_5V_ILIM_MASK) >> SYV682X_5V_ILIM_BIT_SHIFT; @@ -561,7 +561,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_sink_enable_trivial) * If VBUS source is already enabled, disabling VBUS sink should * trivially succeed. */ - zassume_ok(ppc_vbus_source_enable(syv682x_port, true), + zassert_ok(ppc_vbus_source_enable(syv682x_port, true), "VBUS enable failed"); zassert_ok(ppc_vbus_sink_enable(syv682x_port, false), "Sink disable failed"); @@ -576,11 +576,11 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_sink_enable_power_path) * After enabling VBUS sink, the HV power path should be enabled in sink * mode with the configured current limit. */ - zassume_ok(ppc_vbus_source_enable(syv682x_port, false), + zassert_ok(ppc_vbus_source_enable(syv682x_port, false), "VBUS enable failed"); zassert_ok(ppc_vbus_sink_enable(syv682x_port, true), "Sink disable failed"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), NULL); zassert_true(reg & SYV682X_CONTROL_1_CH_SEL, @@ -598,14 +598,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_sink_disable) { uint8_t reg; - zassume_ok(ppc_vbus_source_enable(syv682x_port, false), + zassert_ok(ppc_vbus_source_enable(syv682x_port, false), "VBUS enable failed"); zassert_ok(ppc_vbus_sink_enable(syv682x_port, true), "Sink disable failed"); zassert_ok(ppc_vbus_sink_enable(syv682x_port, false), "Sink disable failed"); - zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul, + zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul, SYV682X_CONTROL_1_REG, ®), NULL); zassert_true(reg & SYV682X_CONTROL_1_PWR_ENB, diff --git a/zephyr/test/drivers/default/src/ps8xxx.c b/zephyr/test/drivers/default/src/ps8xxx.c index 2aa1844c10..6fb1658c06 100644 --- a/zephyr/test/drivers/default/src/ps8xxx.c +++ b/zephyr/test/drivers/default/src/ps8xxx.c @@ -1411,7 +1411,7 @@ static void ps8805_before(void *state) board_set_ps8xxx_product_id(PS8805_PRODUCT_ID); ps8xxx_emul_set_product_id(ps8xxx_emul, PS8805_PRODUCT_ID); setup_no_fail_all(); - zassume_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1)); + zassert_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1)); } static void ps8805_after(void *state) @@ -1436,7 +1436,7 @@ static void ps8815_before(void *state) ps8xxx_emul_set_reg_id(ps8xxx_emul, PS8815_REG_ID); ps8xxx_emul_set_product_id(ps8xxx_emul, PS8815_PRODUCT_ID); setup_no_fail_all(); - zassume_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1)); + zassert_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1)); } static void ps8815_after(void *state) @@ -1461,7 +1461,7 @@ static void ps8745_before(void *state) ps8xxx_emul_set_product_id(ps8xxx_emul, PS8815_PRODUCT_ID); ps8xxx_emul_set_reg_id(ps8xxx_emul, PS8745_REG_ID); setup_no_fail_all(); - zassume_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1), NULL); + zassert_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1), NULL); } static void ps8745_after(void *state) diff --git a/zephyr/test/drivers/default/src/tcpci_test_common.c b/zephyr/test/drivers/default/src/tcpci_test_common.c index bbc1e3f8b0..473fbe0f20 100644 --- a/zephyr/test/drivers/default/src/tcpci_test_common.c +++ b/zephyr/test/drivers/default/src/tcpci_test_common.c @@ -1020,7 +1020,7 @@ void test_tcpci_hard_reset_reinit(const struct emul *emul, uint16_t power_status_mask; uint16_t alert_mask; - zassume_equal(EC_SUCCESS, drv->init(port), NULL); + zassert_equal(EC_SUCCESS, drv->init(port), NULL); tcpci_emul_get_reg(emul, TCPC_REG_POWER_STATUS_MASK, &power_status_mask); tcpci_emul_get_reg(emul, TCPC_REG_ALERT_MASK, &alert_mask); diff --git a/zephyr/test/drivers/default/src/virtual_battery.c b/zephyr/test/drivers/default/src/virtual_battery.c index fc29e39777..87c031e723 100644 --- a/zephyr/test/drivers/default/src/virtual_battery.c +++ b/zephyr/test/drivers/default/src/virtual_battery.c @@ -226,11 +226,11 @@ ZTEST_USER(virtual_battery, test_read_regs) word = virtual_battery_read16(SB_SPECIFICATION_INFO); zassert_equal(expected, word, "%d != %d", expected, word); - zassume_ok(battery_status(&expected)); + zassert_ok(battery_status(&expected)); word = virtual_battery_read16(SB_BATTERY_STATUS); zassert_equal(expected, word, "%d != %d", expected, word); - zassume_ok(battery_design_voltage(&expected)); + zassert_ok(battery_design_voltage(&expected)); word = virtual_battery_read16(SB_DESIGN_VOLTAGE); zassert_equal(expected, word, "%d != %d", expected, word); diff --git a/zephyr/test/drivers/dps/src/dps.c b/zephyr/test/drivers/dps/src/dps.c index d445767df4..88fd81a709 100644 --- a/zephyr/test/drivers/dps/src/dps.c +++ b/zephyr/test/drivers/dps/src/dps.c @@ -89,7 +89,7 @@ ZTEST(dps, console_cmd__enable) ZTEST(dps, console_cmd__disable) { /* Should already by enabled due to before() function */ - zassume_true(dps_is_enabled(), NULL); + zassert_true(dps_is_enabled(), NULL); zassert_ok(shell_execute_cmd(get_ec_shell(), "dps dis"), NULL); @@ -104,7 +104,7 @@ ZTEST(dps, console_cmd__fakepwr_print) ZTEST(dps, console_cmd__fakepwr_enable_disable) { - zassume_false(dps_is_fake_enabled(), + zassert_false(dps_is_fake_enabled(), "fakepwr shouldn't be enabled by default"); zassert_ok(shell_execute_cmd(get_ec_shell(), "dps fakepwr 100 200"), diff --git a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c index 907329f8a1..721fbcd8f9 100644 --- a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c +++ b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c @@ -50,7 +50,7 @@ static void host_cmd_get_pd_port_caps_begin(void *data) ARG_UNUSED(data); /* Assume we have at least one USB-C port */ - zassume_true(board_get_usb_pd_port_count() > 0, + zassert_true(board_get_usb_pd_port_count() > 0, "Insufficient TCPCs found"); } diff --git a/zephyr/test/drivers/host_cmd/src/motion_sense.c b/zephyr/test/drivers/host_cmd/src/motion_sense.c index 371ca4ae11..1b35eb637c 100644 --- a/zephyr/test/drivers/host_cmd/src/motion_sense.c +++ b/zephyr/test/drivers/host_cmd/src/motion_sense.c @@ -72,7 +72,7 @@ static void host_cmd_motion_sense_before(void *fixture) RESET_FAKE(mock_perform_calib); FFF_RESET_HISTORY(); - zassume_ok(shell_execute_cmd(get_ec_shell(), "accelinit 0")); + zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinit 0")); atomic_clear(&motion_sensors[0].flush_pending); motion_sensors[0].config[SENSOR_CONFIG_AP].odr = 0; @@ -305,7 +305,7 @@ ZTEST_USER(host_cmd_motion_sense, test_odr_get) { struct ec_response_motion_sense response; - zassume_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0], + zassert_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0], 1000000, false), NULL); zassert_ok(host_cmd_motion_sense_odr(/*sensor_num=*/0, @@ -322,7 +322,7 @@ ZTEST_USER(host_cmd_motion_sense, test_odr_set) { struct ec_response_motion_sense response; - zassume_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0], 0, + zassert_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0], 0, false), NULL); zassert_ok(host_cmd_motion_sense_odr(/*sensor_num=*/0, @@ -774,7 +774,7 @@ ZTEST(host_cmd_motion_sense, test_int_enable) host_cmd_motion_sense_int_enable(2, &response), NULL); /* Make sure we start off disabled */ - zassume_ok(host_cmd_motion_sense_int_enable(0, &response)); + zassert_ok(host_cmd_motion_sense_int_enable(0, &response)); /* Test enable */ zassert_ok(host_cmd_motion_sense_int_enable(1, &response)); diff --git a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c index 81c2485388..54c8786548 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c +++ b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c @@ -41,7 +41,7 @@ ZTEST_USER(host_cmd_pd_chip_info, test_bad_index) { struct ec_response_pd_chip_info_v1 response; - zassume_true(board_get_usb_pd_port_count() < BAD_PORT, + zassert_true(board_get_usb_pd_port_count() < BAD_PORT, "Intended bad port exists"); zassert_equal(run_pd_chip_info(BAD_PORT, &response), EC_RES_INVALID_PARAM, @@ -53,7 +53,7 @@ static void host_cmd_pd_chip_info_begin(void *data) ARG_UNUSED(data); /* Assume we have at least one USB-C port */ - zassume_true(board_get_usb_pd_port_count() > 0, + zassert_true(board_get_usb_pd_port_count() > 0, "Insufficient TCPCs found"); /* Set the system into S0, since the AP would drive these commands */ diff --git a/zephyr/test/drivers/host_cmd/src/pd_control.c b/zephyr/test/drivers/host_cmd/src/pd_control.c index e8de27f6ce..5fdd424db9 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_control.c +++ b/zephyr/test/drivers/host_cmd/src/pd_control.c @@ -23,7 +23,7 @@ ZTEST_USER(host_cmd_pd_control, test_bad_index) struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params); - zassume_true(board_get_usb_pd_port_count() < BAD_PORT, + zassert_true(board_get_usb_pd_port_count() < BAD_PORT, "Intended bad port exists"); zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, "Failed to fail pd_control for port %d", params.chip); @@ -47,7 +47,7 @@ ZTEST_USER(host_cmd_pd_control, test_pd_reset_resume) * the only HC return which would cover this is a state string, which * could be brittle. */ - zassume_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning"); + zassert_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning"); host_cmd_pd_control(TEST_PORT, PD_RESET); @@ -76,7 +76,7 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_resume) * the only HC return which would cover this is a state string, which * could be brittle. */ - zassume_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning"); + zassert_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning"); host_cmd_pd_control(TEST_PORT, PD_SUSPEND); @@ -117,7 +117,7 @@ static void host_cmd_pd_control_begin(void *data) ARG_UNUSED(data); /* Assume we have at least one USB-C port */ - zassume_true(board_get_usb_pd_port_count() > 0, + zassert_true(board_get_usb_pd_port_count() > 0, "Insufficient TCPCs found"); /* Set the system into S0, since the AP would drive these commands */ diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c index c439141da9..8947fdca8c 100644 --- a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c +++ b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c @@ -99,7 +99,7 @@ ZTEST_USER(host_cmd_usb_pd_control, test_bad_index) { struct ec_response_usb_pd_control_v2 response; - zassume_true(board_get_usb_pd_port_count() < BAD_PORT, + zassert_true(board_get_usb_pd_port_count() < BAD_PORT, "Intended bad port exists"); zassert_equal(run_usb_pd_control(BAD_PORT, &response), EC_RES_INVALID_PARAM, @@ -130,7 +130,7 @@ static void host_cmd_usb_pd_control_before(void *data) ARG_UNUSED(data); /* Assume we have at least one USB-C port */ - zassume_true(board_get_usb_pd_port_count() > 0, + zassert_true(board_get_usb_pd_port_count() > 0, "Insufficient TCPCs found"); /* Set the system into S0, since the AP would drive these commands */ diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c index 149f25dfdd..5b7cbfb2c7 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c @@ -56,7 +56,7 @@ ZTEST(keyboard_backlight, host_command_get_backlight__normal) uint8_t expected_percentage = 50; int ret; - zassume_ok(set_backlight_percent_helper(expected_percentage), NULL); + zassert_ok(set_backlight_percent_helper(expected_percentage), NULL); /* Brief delay to allow a deferred function to enable the backlight */ k_sleep(K_MSEC(50)); @@ -78,7 +78,7 @@ ZTEST(keyboard_backlight, console_command__noargs) const char *outbuffer; size_t buffer_size; - zassume_ok(set_backlight_percent_helper(70), NULL); + zassert_ok(set_backlight_percent_helper(70), NULL); k_sleep(K_MSEC(50)); /* With no args, print current state */ @@ -102,7 +102,7 @@ ZTEST(keyboard_backlight, console_command__set_on) ZTEST(keyboard_backlight, console_command__set_off) { - zassume_ok(set_backlight_percent_helper(40), NULL); + zassert_ok(set_backlight_percent_helper(40), NULL); k_sleep(K_MSEC(50)); /* Turn back off */ diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c index 03fb71f828..beaabd718d 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c @@ -130,7 +130,7 @@ ZTEST(keyboard_scan, console_command_ksstate__force) */ keyboard_scan_enable(false, -1); - zassume_false(keyboard_scan_is_enabled()); + zassert_false(keyboard_scan_is_enabled()); zassert_ok(shell_execute_cmd(get_ec_shell(), "ksstate force")); @@ -142,7 +142,7 @@ ZTEST(keyboard_scan, console_command_ksstate__on_off) { /* This command turns state change printing on/off */ - zassume_false(keyboard_scan_get_print_state_changes()); + zassert_false(keyboard_scan_get_print_state_changes()); zassert_ok(shell_execute_cmd(get_ec_shell(), "ksstate on")); zassert_true(keyboard_scan_get_print_state_changes()); @@ -235,7 +235,7 @@ ZTEST(keyboard_scan, host_command_simulate_key__locked) { uint16_t ret; - zassume_true(system_is_locked(), "Expecting locked system."); + zassert_true(system_is_locked(), "Expecting locked system."); struct ec_response_keyboard_factory_test response; struct ec_params_mkbp_simulate_key params; @@ -251,7 +251,7 @@ ZTEST(keyboard_scan, host_command_simulate_key__bad_params) uint16_t ret; system_is_locked_fake.return_val = 0; - zassume_false(system_is_locked(), "Expecting unlocked system."); + zassert_false(system_is_locked(), "Expecting unlocked system."); struct ec_response_keyboard_factory_test response; struct ec_params_mkbp_simulate_key params = { @@ -293,7 +293,7 @@ ZTEST(keyboard_scan, host_command_simulate__key_press) uint16_t ret; system_is_locked_fake.return_val = 0; - zassume_false(system_is_locked(), "Expecting unlocked system."); + zassert_false(system_is_locked(), "Expecting unlocked system."); ret = send_keypress_host_command(1, 2, 1); zassert_equal(EC_RES_SUCCESS, ret, "Command returned %u", ret); @@ -323,7 +323,7 @@ FAKE_VOID_FUNC(chipset_reset, int); ZTEST(keyboard_scan, special_key_combos) { system_is_locked_fake.return_val = 0; - zassume_false(system_is_locked(), "Expecting unlocked system."); + zassert_false(system_is_locked(), "Expecting unlocked system."); /* Set the volume up key coordinates to something arbitrary */ int vol_up_col = 1; @@ -332,7 +332,7 @@ ZTEST(keyboard_scan, special_key_combos) set_vol_up_key(vol_up_row, vol_up_col); /* Vol up and the alt keys must be in different columns */ - zassume_false(vol_up_col == KEYBOARD_COL_LEFT_ALT, NULL); + zassert_false(vol_up_col == KEYBOARD_COL_LEFT_ALT, NULL); /* Hold down volume up, left alt (either alt key works), and R */ zassert_ok(send_keypress_host_command(vol_up_col, vol_up_row, 1)); diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c index dee2ba2d1b..26a962d5fc 100644 --- a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c +++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c @@ -153,7 +153,7 @@ static void *setup(void) .handler = interrupt_gpio_monitor, }; - zassume_ok(gpio_add_callback(interrupt_pin->port, + zassert_ok(gpio_add_callback(interrupt_pin->port, &fixture.callback_config), "Could not configure GPIO callback."); diff --git a/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c b/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c index 25331acc20..2cb331b387 100644 --- a/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c +++ b/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c @@ -141,7 +141,7 @@ static void reset(void *data) ARG_UNUSED(data); /* Turn the port off */ - zassume_ok(usb_charge_set_mode(PORT_ID, USB_CHARGE_MODE_DISABLED, + zassert_ok(usb_charge_set_mode(PORT_ID, USB_CHARGE_MODE_DISABLED, USB_DISALLOW_SUSPEND_CHARGE), NULL); } diff --git a/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c b/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c index 9a360761ab..82f67aad23 100644 --- a/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c +++ b/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c @@ -40,7 +40,7 @@ static void usb_retimer_fw_update_suspend_port(void) /* Give PD task time to suspend port */ k_sleep(K_SECONDS(1)); - zassume_true(acpi_read_and_verify() == 0, + zassert_true(acpi_read_and_verify() == 0, "Failed to see successful suspend"); } @@ -50,7 +50,7 @@ static void usb_retimer_fw_update_before(void *data) ARG_UNUSED(data); /* Assume our common setup of a BB retimer on C1 */ - zassume_true(EMUL_DT_GET(BB_RETIMER_NODE) != NULL, + zassert_true(EMUL_DT_GET(BB_RETIMER_NODE) != NULL, "No BB retimer found on C1"); /* Set chipset to ON, since AP would drive this process */ diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c index 43ccc3b3f3..cbdd861585 100644 --- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c +++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c @@ -41,7 +41,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul, * function. */ set_ac_enabled(true); - zassume_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul), + zassert_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul), NULL); isl923x_emul_set_adc_vbus(charger_emul, @@ -54,7 +54,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul, static void disconnect_partner_from_port(const struct emul *tcpc_emul, const struct emul *charger_emul) { - zassume_ok(tcpci_emul_disconnect_partner(tcpc_emul)); + zassert_ok(tcpci_emul_disconnect_partner(tcpc_emul)); isl923x_emul_set_adc_vbus(charger_emul, 0); k_sleep(K_SECONDS(1)); } diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c index dc8806151b..9d34bc7917 100644 --- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c +++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c @@ -97,9 +97,9 @@ ZTEST_F(usbc_alt_mode, verify_mode_exit_via_pd_host_cmd) * entering an alternate most (DisplayPort specifically) has already * been verified in another test */ - zassume_equal(response_size, sizeof(get_mode_response)); - zassume_equal(get_mode_response.svid, USB_SID_DISPLAYPORT); - zassume_equal(get_mode_response.vdo[0], + zassert_equal(response_size, sizeof(get_mode_response)); + zassert_equal(get_mode_response.svid, USB_SID_DISPLAYPORT); + zassert_equal(get_mode_response.vdo[0], fixture->partner.modes_vdm[get_mode_response.opos]); struct ec_params_usb_pd_set_mode_request set_mode_params = { diff --git a/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c b/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c index c1c7d7eb1a..9c87b9a4a2 100644 --- a/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c +++ b/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c @@ -50,7 +50,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul, * function. */ set_ac_enabled(true); - zassume_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul), + zassert_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul), NULL); isl923x_emul_set_adc_vbus(charger_emul, @@ -63,7 +63,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul, static void disconnect_partner_from_port(const struct emul *tcpc_emul, const struct emul *charger_emul) { - zassume_ok(tcpci_emul_disconnect_partner(tcpc_emul), NULL); + zassert_ok(tcpci_emul_disconnect_partner(tcpc_emul), NULL); isl923x_emul_set_adc_vbus(charger_emul, 0); k_sleep(K_SECONDS(1)); } diff --git a/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c b/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c index 66a145c475..912d8fa644 100644 --- a/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c +++ b/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c @@ -255,7 +255,7 @@ ZTEST_F(usbc_tbt_mode, verify_tbt_entry_fail) fixture->charger_emul); status = host_cmd_typec_status(TEST_PORT); - zassume_equal((status.mux_state & USB_MUX_CHECK_MASK), + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x", status.mux_state); @@ -295,7 +295,7 @@ ZTEST_F(usbc_tbt_mode, verify_tbt_passive_entry_exit) verify_cable_found(fixture->partner.cable); status = host_cmd_typec_status(TEST_PORT); - zassume_equal((status.mux_state & USB_MUX_CHECK_MASK), + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x", status.mux_state); diff --git a/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c b/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c index 324df08826..beaafd6880 100644 --- a/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c +++ b/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c @@ -52,7 +52,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul, * function. */ set_ac_enabled(true); - zassume_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul), + zassert_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul), NULL); isl923x_emul_set_adc_vbus(charger_emul, @@ -65,7 +65,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul, static void disconnect_partner_from_port(const struct emul *tcpc_emul, const struct emul *charger_emul) { - zassume_ok(tcpci_emul_disconnect_partner(tcpc_emul), NULL); + zassert_ok(tcpci_emul_disconnect_partner(tcpc_emul), NULL); isl923x_emul_set_adc_vbus(charger_emul, 0); k_sleep(K_SECONDS(1)); } @@ -166,7 +166,7 @@ ZTEST_F(usbc_vconn_swap, vconn_swap_via_host_command) struct ec_response_typec_status status = host_cmd_typec_status(TEST_PORT); - zassume_equal(status.vconn_role, PD_ROLE_VCONN_SRC, + zassert_equal(status.vconn_role, PD_ROLE_VCONN_SRC, "TCPM did not initiate VCONN Swap after attach"); host_cmd_usb_pd_control(TEST_PORT, USB_PD_CTRL_SWAP_VCONN); -- cgit v1.2.1 From 6aa2ba3ad5fef922faeac10265313cf94be6afd7 Mon Sep 17 00:00:00 2001 From: Andrew McRae Date: Mon, 31 Oct 2022 13:48:29 +1100 Subject: shell: Do not use text emphasis on EC shell prompt Disable any EC shell prompt emphasis or colors. Sending escape-driven text display can cause issues: - capturing EC console output with interleaved escape character sequences makes decoding the capture file difficult. - Interleaved logs and output can cause screen corruption. - Interleaving output also can appear with the emphasis depending on the order of characters. - Tests using servod captures EC console output, and it is much easier to decode this without interleaved escape sequences. BUG=none TEST=zmake build nivviks; flash & run BRANCH=none Signed-off-by: Andrew McRae Change-Id: I7dfd43a8217f5c6aa5b3c75db328f849271f8dd8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990389 Reviewed-by: Aaron Massey --- zephyr/Kconfig.defaults | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zephyr/Kconfig.defaults b/zephyr/Kconfig.defaults index e0992f91fa..8f82d1c3dc 100644 --- a/zephyr/Kconfig.defaults +++ b/zephyr/Kconfig.defaults @@ -25,6 +25,9 @@ config THREAD_MAX_NAME_LEN config SHELL_PROMPT_UART default "ec:~$ " +config SHELL_VT100_COLORS + default n + config SHELL_THREAD_PRIORITY_OVERRIDE default y -- cgit v1.2.1 From 15030a6232166039c45fb54480d463f53b631df6 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Mon, 31 Oct 2022 11:23:16 -0600 Subject: zephyr test: Verify board_is_usb_pd_port Verify that the default implementation returns true for existing ports. BUG=b:256182103 TEST=twister -s zephyr/test/drivers/drivers.usb_common BRANCH=none Signed-off-by: Abe Levkoy Change-Id: If5a94ee83d5dac37cae26ce6e189a785274c0d06 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994226 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- zephyr/test/drivers/usb_common/src/usb_common.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c index ca29e9f207..9e23f30f3f 100644 --- a/zephyr/test/drivers/usb_common/src/usb_common.c +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -134,3 +134,10 @@ ZTEST_USER(usb_common, test_pd_check_requested_voltage) rdo = RDO_FIXED(1, 1000, 1800, 0); zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL); } + +ZTEST_USER(usb_common, test_board_is_usb_pd_port_present) +{ + zassert_true(board_is_usb_pd_port_present(TEST_PORT)); + zassert_false(board_is_usb_pd_port_present(-1)); + zassert_false(board_is_usb_pd_port_present(100)); +} -- cgit v1.2.1 From 5fd2bffe3755a3c6b0a9637b3c28ad5f2d3653c7 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Mon, 31 Oct 2022 11:41:16 -0600 Subject: zephyr test: Verify board_is_dts_port Verify that the default implementation returns true. BUG=b:256182103 TEST=twister -t zephyr/test/drivers/drivers.usb_common BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I68ad0a3bcaf606cd29b7c22e4d5de944d54b463a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994230 Reviewed-by: Simon Glass Code-Coverage: Zoss --- zephyr/test/drivers/usb_common/src/usb_common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c index 9e23f30f3f..e33751998f 100644 --- a/zephyr/test/drivers/usb_common/src/usb_common.c +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -141,3 +141,8 @@ ZTEST_USER(usb_common, test_board_is_usb_pd_port_present) zassert_false(board_is_usb_pd_port_present(-1)); zassert_false(board_is_usb_pd_port_present(100)); } + +ZTEST_USER(usb_common, test_board_is_dts_port) +{ + zassert_true(board_is_dts_port(TEST_PORT)); +} -- cgit v1.2.1 From 5db47a635545bdeff1486f6ec97602b471ab581b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 28 Oct 2022 09:09:00 -0700 Subject: chip/mchp/lfw: Specify region for padding Linking with clang/lld fails since it assumes the region .fill should use is VECTOR: ld.lld: error: section '.fill' will not fit in region 'VECTOR': overflowed by 328 bytes This change does not affect the gcc/ld build (identical output before and after). BRANCH=none BUG=b:172020503 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes Change-Id: Ieeff37fc13befe495dbc567b4be363da07a75c3a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3989666 Reviewed-by: Eric Yilun Lin --- chip/mchp/lfw/ec_lfw.ld | 2 +- chip/mchp/lfw/ec_lfw_416kb.ld | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chip/mchp/lfw/ec_lfw.ld b/chip/mchp/lfw/ec_lfw.ld index f0071a55e9..1c745d5d2a 100644 --- a/chip/mchp/lfw/ec_lfw.ld +++ b/chip/mchp/lfw/ec_lfw.ld @@ -79,7 +79,7 @@ SECTIONS FILL(0xFF); . = ORIGIN(SRAM) + LENGTH(SRAM) - 1; BYTE(0xFF); /* emit at least a byte to make linker happy */ - } + } >SRAM __image_size = LOADADDR(.text) + SIZEOF(.text) - ORIGIN(VECTOR); } diff --git a/chip/mchp/lfw/ec_lfw_416kb.ld b/chip/mchp/lfw/ec_lfw_416kb.ld index f27d046e7d..93d70ffbe8 100644 --- a/chip/mchp/lfw/ec_lfw_416kb.ld +++ b/chip/mchp/lfw/ec_lfw_416kb.ld @@ -83,7 +83,7 @@ SECTIONS FILL(0xFF); . = ORIGIN(SRAM) + LENGTH(SRAM) - 1; BYTE(0xFF); /* emit at least a byte to make linker happy */ - } + } >SRAM __image_size = LOADADDR(.text) + SIZEOF(.text) - ORIGIN(VECTOR); } -- cgit v1.2.1 From 1a367b149f758e8a3b007ba272bc0cb380caa0eb Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Thu, 27 Oct 2022 13:51:39 +0800 Subject: anx7483: Add Flat Gain tuning interface Add an API which may be used to adjust the flat gain settings of pins on the retimer individually. BUG=b:254616597 BRANCH=none TEST=zmake skyrim winterhold successfully LOW_COVERAGE_REASON=no emulator for the ANX7483 exists Signed-off-by: Matt Wang Change-Id: I3677f25a0fe16b4a0393dc1377848a6a453a849e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3985350 Reviewed-by: Diana Z Code-Coverage: Zoss Reviewed-by: Elthan Huang --- driver/retimer/anx7483.c | 28 ++++++++++++++++++++++++++++ driver/retimer/anx7483.h | 3 +++ include/driver/retimer/anx7483_public.h | 13 +++++++++++++ 3 files changed, 44 insertions(+) diff --git a/driver/retimer/anx7483.c b/driver/retimer/anx7483.c index 3f4713fc85..c587bec91f 100644 --- a/driver/retimer/anx7483.c +++ b/driver/retimer/anx7483.c @@ -346,6 +346,34 @@ enum ec_error_list anx7483_set_eq(const struct usb_mux *me, return anx7483_write(me, reg, value); } +enum ec_error_list anx7483_set_fg(const struct usb_mux *me, + enum anx7483_tune_pin pin, + enum anx7483_fg_setting fg) +{ + int reg, value; + + if (pin == ANX7483_PIN_UTX1) + reg = ANX7483_UTX1_PORT_CFG2_REG; + else if (pin == ANX7483_PIN_UTX2) + reg = ANX7483_UTX2_PORT_CFG2_REG; + else if (pin == ANX7483_PIN_URX1) + reg = ANX7483_URX1_PORT_CFG2_REG; + else if (pin == ANX7483_PIN_URX2) + reg = ANX7483_URX2_PORT_CFG2_REG; + else if (pin == ANX7483_PIN_DRX1) + reg = ANX7483_DRX1_PORT_CFG2_REG; + else if (pin == ANX7483_PIN_DRX2) + reg = ANX7483_DRX2_PORT_CFG2_REG; + else + return EC_ERROR_INVAL; + + RETURN_ERROR(anx7483_read(me, reg, &value)); + value &= ~ANX7483_CFG2_FG_MASK; + value |= fg << ANX7483_CFG2_FG_SHIFT; + + return anx7483_write(me, reg, value); +} + const struct usb_mux_driver anx7483_usb_retimer_driver = { .init = anx7483_init, .set = anx7483_set, diff --git a/driver/retimer/anx7483.h b/driver/retimer/anx7483.h index d489b3d8e6..c438a278b9 100644 --- a/driver/retimer/anx7483.h +++ b/driver/retimer/anx7483.h @@ -72,6 +72,9 @@ #define ANX7483_DRX1_PORT_CFG2_REG 0x5E #define ANX7483_DRX2_PORT_CFG2_REG 0x22 +#define ANX7483_CFG2_FG_SHIFT 4 +#define ANX7483_CFG2_FG_MASK GENMASK(5, 4) + /* * Default CFG2 value to apply: 0.3 dB with optimized fine tuning */ diff --git a/include/driver/retimer/anx7483_public.h b/include/driver/retimer/anx7483_public.h index 83ad32508e..4f44c4d180 100644 --- a/include/driver/retimer/anx7483_public.h +++ b/include/driver/retimer/anx7483_public.h @@ -38,6 +38,14 @@ enum anx7483_eq_setting { ANX7483_EQ_SETTING_12_5DB = 15, }; +/* Flat gain tuning */ +enum anx7483_fg_setting { + ANX7483_FG_SETTING_NEG_1_5DB = 0, + ANX7483_FG_SETTING_0_5DB = 1, + ANX7483_FG_SETTING_0_3DB = 2, + ANX7483_FG_SETTING_1_2DB = 3, +}; + enum anx7483_tune_pin { ANX7483_PIN_UTX1, ANX7483_PIN_UTX2, @@ -52,6 +60,11 @@ enum ec_error_list anx7483_set_eq(const struct usb_mux *me, enum anx7483_tune_pin pin, enum anx7483_eq_setting eq); +/* Adjust the flat gain for a pin */ +enum ec_error_list anx7483_set_fg(const struct usb_mux *me, + enum anx7483_tune_pin pin, + enum anx7483_fg_setting fg); + /* * Configure datasheet defaults for tuning registers at this mux setting. * Return int so function can be used directly for board_set. -- cgit v1.2.1 From e429cb3945e558cdb742537bad06eb6862cb25e1 Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Thu, 27 Oct 2022 14:06:38 +0800 Subject: winterhold: Adjust tuning for C1 C1 requires a different setting for the equalization and flat gain register. BUG=b:254616597 BRANCH=none TEST=zmake build winterhold successfully TEST=C1 plug the Type-C USB check the EQ register[7:4] is 0x8, Flat Gain register[5:4] is 0x1. LOW_COVERAGE_REASON=no unit test for skyrim board yet: b/247151116 Signed-off-by: Matt Wang Change-Id: Id49c468888922a1d9755bdf0144d53c230b99d7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3983630 Reviewed-by: Elthan Huang Reviewed-by: Diana Z Code-Coverage: Zoss --- .../skyrim/src/winterhold/usb_mux_config.c | 47 ++++++++++------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c b/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c index d2ee4a6606..fdcf37e6b0 100644 --- a/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c +++ b/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c @@ -69,42 +69,39 @@ int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, ANX7483_EQ_SETTING_12_5DB)); RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, ANX7483_EQ_SETTING_12_5DB)); } + /* + * Those registers all need to be set no matter what state the mux is + * in it needs to be set. + */ + RETURN_ERROR( + anx7483_set_eq(me, ANX7483_PIN_URX1, ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR( + anx7483_set_eq(me, ANX7483_PIN_URX2, ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR( + anx7483_set_eq(me, ANX7483_PIN_UTX1, ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR( + anx7483_set_eq(me, ANX7483_PIN_UTX2, ANX7483_EQ_SETTING_8_4DB)); + + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_0_5DB)); + return EC_SUCCESS; } -- cgit v1.2.1 From d808de3e6a2fd759b65f93275cc0a04f97b48ee0 Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Mon, 31 Oct 2022 18:22:40 +0800 Subject: zephyr: fix incorrect adc channel value in krabby test Fix an incorrect usage of `adc_emul_const_value_set()`: The `temp_sensors[CHARGER_TEMP].idx` actually returns the enum-name of the given channel, not the channel number (i.e. the number specified in the io-channels prop). Both numbers are zero in our DTS, so we didn't catch the bug. BUG=none TEST=twister -T zephyr/test/krabby BRANCH=none Signed-off-by: Ting Shen Change-Id: Ib786889be72927743c7d4cbe3185514896e3af2e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3992655 Tested-by: Ting Shen Reviewed-by: Eric Yilun Lin Code-Coverage: Zoss Commit-Queue: Ting Shen --- zephyr/test/krabby/src/temp_tentacruel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zephyr/test/krabby/src/temp_tentacruel.c b/zephyr/test/krabby/src/temp_tentacruel.c index 863adfaf81..660f6c4616 100644 --- a/zephyr/test/krabby/src/temp_tentacruel.c +++ b/zephyr/test/krabby/src/temp_tentacruel.c @@ -40,10 +40,11 @@ static uint16_t current_table[] = { int setup_faketemp(int fake_voltage) { const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE); + const uint8_t channel_id = + DT_IO_CHANNELS_INPUT(DT_NODELABEL(adc_charger)); int emul_temp; - emul_temp = adc_emul_const_value_set( - adc_dev, temp_sensors[CHARGER_TEMP].idx, fake_voltage); + emul_temp = adc_emul_const_value_set(adc_dev, channel_id, fake_voltage); return emul_temp; } -- cgit v1.2.1 From 16c8fce71986d50d9e10ea089d9d9352818129ad Mon Sep 17 00:00:00 2001 From: Andrew McRae Date: Thu, 27 Oct 2022 16:51:29 +1100 Subject: hibernate: Add hibernate support to ap power code Add hibernate support to the AP power sequence code. The smart discharge system isn't supported yet. The system will hibernate after a delay when the AP is in G3 and there is no external power connected. v2: add tests BUG=b:246643307 TEST=Run on nivviks with short delay BRANCH=none Signed-off-by: Andrew McRae Cq-Depend: chromium:3985352 Change-Id: Ib7bb62c3d650a607343a6ea243645346f4b2a797 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3983631 Reviewed-by: Peter Marheine Code-Coverage: Zoss --- power/hibernate.c | 181 ++++++++++++++++++++++++++++++ util/config_allowed.txt | 2 - zephyr/CMakeLists.txt | 3 + zephyr/Kconfig.system | 19 ++++ zephyr/shim/include/config_chip.h | 9 ++ zephyr/test/ap_power/CMakeLists.txt | 2 + zephyr/test/ap_power/include/test_mocks.h | 21 ++++ zephyr/test/ap_power/prj.conf | 3 + zephyr/test/ap_power/src/board.c | 5 - zephyr/test/ap_power/src/hibdelay.c | 37 ++++++ zephyr/test/ap_power/src/hibernate.c | 41 +++++++ zephyr/test/ap_power/src/host_command.c | 28 +++++ zephyr/test/ap_power/src/test_mocks.c | 30 +++++ 13 files changed, 374 insertions(+), 7 deletions(-) create mode 100644 power/hibernate.c create mode 100644 zephyr/test/ap_power/include/test_mocks.h create mode 100644 zephyr/test/ap_power/src/hibdelay.c create mode 100644 zephyr/test/ap_power/src/hibernate.c create mode 100644 zephyr/test/ap_power/src/host_command.c create mode 100644 zephyr/test/ap_power/src/test_mocks.c diff --git a/power/hibernate.c b/power/hibernate.c new file mode 100644 index 0000000000..322adca3ea --- /dev/null +++ b/power/hibernate.c @@ -0,0 +1,181 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include +#include + +#include "console.h" +#include "extpower.h" +#include "hooks.h" +#include "host_command.h" +#include "system.h" +#include "util.h" + +LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL); + +/* + * Hibernate processing. + * + * When enabled, the system will be put into an extreme low + * power state after the AP is in G3 for a configurable period of time, + * and there is no external power connected (i.e on battery). + * + * The delay has a configurable default, and may be set dynamically + * via a host command, or an EC console command. A typical delay + * may be 1 hour (3600 seconds). + * + * AP events such as AP_POWER_HARD_OFF are listened for, and + * a timer is used to detect when the AP has been off for the + * selected delay time. If the AP is started again, the timer is canceled. + * Once the timer expires, the system_hibernate() function is called, + * and this will suspend the EC until a wake signal is received. + */ +static uint32_t hibernate_delay = CONFIG_HIBERNATE_DELAY_SEC; + +/* + * Return true if conditions are right for hibernation. + */ +static inline bool ready_to_hibernate(void) +{ + return ap_power_in_or_transitioning_to_state(AP_POWER_STATE_HARD_OFF) && + !extpower_is_present(); +} + +/* + * The AP has been off for the delay period, so hibernate the system, + * if ready. Called from system work queue. + */ +static void hibernate_handler(struct k_work *unused) +{ + if (ready_to_hibernate()) { + LOG_INF("System hibernating due to %d seconds AP off", + hibernate_delay); + system_hibernate(0, 0); + } +} + +K_WORK_DEFINE(hibernate_work, hibernate_handler); + +/* + * Hibernate timer handler. + * Called when timer has expired. + * Schedule hibernate_handler to run via system work queue. + */ +static void timer_handler(struct k_timer *timer) +{ + k_work_submit(&hibernate_work); +} + +K_TIMER_DEFINE(hibernate_timer, timer_handler, NULL); + +/* + * A change has been detected in either the AP state or the + * external power supply. + */ +static void change_detected(void) +{ + if (ready_to_hibernate()) { + /* + * AP is off, and there is no external power. + * Start the timer if it is not already running. + */ + if (k_timer_remaining_get(&hibernate_timer) == 0) { + k_timer_start(&hibernate_timer, + K_SECONDS(hibernate_delay), K_NO_WAIT); + } + + } else { + /* + * AP is either on, or external power is on. + * Either way, no hibernation is done. + * Make sure the timer is not running. + */ + k_timer_stop(&hibernate_timer); + } +} + +static void ap_change(struct ap_power_ev_callback *callback, + struct ap_power_ev_data data) +{ + change_detected(); +} + +/* + * Hook to listen for external power supply changes. + */ +DECLARE_HOOK(HOOK_AC_CHANGE, change_detected, HOOK_PRIO_DEFAULT); + +/* + * EC Console command to get/set the hibernation delay + */ +static int command_hibernation_delay(int argc, const char **argv) +{ + char *e; + uint32_t remaining; + + if (argc >= 2) { + uint32_t s = strtoi(argv[1], &e, 0); + + if (*e) + return EC_ERROR_PARAM1; + + hibernate_delay = s; + } + + /* Print the current setting */ + ccprintf("Hibernation delay: %d s\n", hibernate_delay); + remaining = k_timer_remaining_get(&hibernate_timer); + if (remaining == 0) { + ccprintf("Timer not running\n"); + } else { + ccprintf("Time remaining: %d s\n", remaining / 1000); + } + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(hibdelay, command_hibernation_delay, "[sec]", + "Set the delay before going into hibernation"); +/* + * Host command to set the hibernation delay + */ +static enum ec_status +host_command_hibernation_delay(struct host_cmd_handler_args *args) +{ + const struct ec_params_hibernation_delay *p = args->params; + struct ec_response_hibernation_delay *r = args->response; + + /* Only change the hibernation delay if seconds is non-zero. */ + if (p->seconds) + hibernate_delay = p->seconds; + + r->hibernate_delay = hibernate_delay; + /* + * It makes no sense to try and set these values since + * they are only valid when the AP is in G3 (so this + * host command will never be called at that point). + */ + r->time_g3 = 0; + r->time_remaining = 0; + + args->response_size = sizeof(struct ec_response_hibernation_delay); + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_HIBERNATION_DELAY, host_command_hibernation_delay, + EC_VER_MASK(0)); + +static int hibernate_init(const struct device *unused) +{ + static struct ap_power_ev_callback cb; + + ap_power_ev_init_callback(&cb, ap_change, + AP_POWER_INITIALIZED | AP_POWER_HARD_OFF | + AP_POWER_STARTUP); + ap_power_ev_add_callback(&cb); + return 0; +} + +SYS_INIT(hibernate_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/util/config_allowed.txt b/util/config_allowed.txt index 76a4aa3182..074490612e 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -458,10 +458,8 @@ CONFIG_H2RAM_BASE CONFIG_H2RAM_HOST_LPC_IO_BASE CONFIG_H2RAM_SIZE CONFIG_HAS_TASK_PD_INT -CONFIG_HIBERNATE CONFIG_HIBERNATE_BATT_PCT CONFIG_HIBERNATE_BATT_SEC -CONFIG_HIBERNATE_DELAY_SEC CONFIG_HIBERNATE_PSL_COMPENSATE_RTC CONFIG_HIBERNATE_PSL_OUT_FLAGS CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index ae882e5640..9ca984dbfa 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -362,6 +362,9 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_SC7180 "${PLATFORM_EC}/power/qcom.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_SC7280 "${PLATFORM_EC}/power/qcom.c") +if (CONFIG_PLATFORM_EC_HIBERNATE AND CONFIG_AP_PWRSEQ) + zephyr_library_sources( "${PLATFORM_EC}/power/hibernate.c") +endif () zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC "${PLATFORM_EC}/common/panic_output.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SHA256_SW diff --git a/zephyr/Kconfig.system b/zephyr/Kconfig.system index 5467bc7422..ffba537558 100644 --- a/zephyr/Kconfig.system +++ b/zephyr/Kconfig.system @@ -28,6 +28,25 @@ config PLATFORM_EC_HIBERNATE_PSL rail for ultra-low power consumption and uses PSL inputs rely on VSBY power rail to wake up ec and the whole system. +config PLATFORM_EC_HIBERNATE + bool "System hibernating with wake-source pins" + default y + depends on !PLATFORM_EC_HIBERNATE_PSL + help + Use wake source pins for hibernating. It turns off VCC power + rail for ultra-low power consumption and uses a low power + power rail. Changes on wake source pins will wake up the EC. + By default this is enabled if PLATFORM_EC_HIBERNATE_PSL is not + enabled. + +config PLATFORM_EC_HIBERNATE_DELAY_SEC + int "Delay in seconds from AP power off to hibernate" + depends on PLATFORM_EC_HIBERNATE + default 3600 + help + This value is the delay in seconds from when the AP enters G3 + to when the system is hibernated. + config PLATFORM_EC_SYSTEM_PRE_INIT_PRIORITY int "System pre-initialization priority" default 20 diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 26c5ca5332..1bc00a0516 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -2404,6 +2404,15 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #define CONFIG_HIBERNATE_PSL #endif +#undef CONFIG_HIBERNATE +#ifdef CONFIG_PLATFORM_EC_HIBERNATE +#define CONFIG_HIBERNATE +#ifdef CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC +#undef CONFIG_HIBERNATE_DELAY_SEC +#define CONFIG_HIBERNATE_DELAY_SEC CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC +#endif +#endif + #undef CONFIG_BATTERY_DEVICE_CHEMISTRY #ifdef CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY #define CONFIG_BATTERY_DEVICE_CHEMISTRY \ diff --git a/zephyr/test/ap_power/CMakeLists.txt b/zephyr/test/ap_power/CMakeLists.txt index 7b44013961..4669dac07e 100644 --- a/zephyr/test/ap_power/CMakeLists.txt +++ b/zephyr/test/ap_power/CMakeLists.txt @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(ap_power) +add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) + # Include the local test directory for shimmed_test_tasks.h zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") diff --git a/zephyr/test/ap_power/include/test_mocks.h b/zephyr/test/ap_power/include/test_mocks.h new file mode 100644 index 0000000000..8e9c80ad43 --- /dev/null +++ b/zephyr/test/ap_power/include/test_mocks.h @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __TEST_AP_POWER_TEST_MOCKS_H +#define __TEST_AP_POWER_TEST_MOCKS_H + +#include + +/* + * Mock declarations + */ + +/* Mocks for common/extpower_gpio.c */ +DECLARE_FAKE_VALUE_FUNC(int, extpower_is_present); + +/* Mocks for common/system.c */ +DECLARE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); + +#endif /* __TEST_AP_POWER_TEST_MOCKS_H */ diff --git a/zephyr/test/ap_power/prj.conf b/zephyr/test/ap_power/prj.conf index 4dd31085bd..0bd0b6e8d3 100644 --- a/zephyr/test/ap_power/prj.conf +++ b/zephyr/test/ap_power/prj.conf @@ -56,6 +56,9 @@ CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y CONFIG_PLATFORM_EC_HOSTCMD=y CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y +# Short delay for hibernate +CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC=20 + # These items are not required. CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_SWITCH=n diff --git a/zephyr/test/ap_power/src/board.c b/zephyr/test/ap_power/src/board.c index 26c9448396..78732b5125 100644 --- a/zephyr/test/ap_power/src/board.c +++ b/zephyr/test/ap_power/src/board.c @@ -82,8 +82,3 @@ bool board_ap_power_check_power_rails_enabled(void) { return false; } - -int extpower_is_present(void) -{ - return 0; -} diff --git a/zephyr/test/ap_power/src/hibdelay.c b/zephyr/test/ap_power/src/hibdelay.c new file mode 100644 index 0000000000..02442adec8 --- /dev/null +++ b/zephyr/test/ap_power/src/hibdelay.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "console.h" +#include "ec_commands.h" +#include "test_state.h" + +ZTEST_SUITE(console_cmd_hibdelay, ap_power_predicate_post_main, NULL, NULL, + NULL, NULL); + +ZTEST_USER(console_cmd_hibdelay, test_too_many_args) +{ + zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay 1 2"), NULL); +} + +ZTEST_USER(console_cmd_hibdelay, test_no_args) +{ + zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay"), NULL); +} + +ZTEST_USER(console_cmd_hibdelay, test_invalid_arg) +{ + int rv = shell_execute_cmd(get_ec_shell(), "hibdelay 3.4"); + + zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d", + EC_ERROR_PARAM1, rv); +} + +ZTEST_USER(console_cmd_hibdelay, test_valid_args) +{ + zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay 5"), NULL); +} diff --git a/zephyr/test/ap_power/src/hibernate.c b/zephyr/test/ap_power/src/hibernate.c new file mode 100644 index 0000000000..2309508f4b --- /dev/null +++ b/zephyr/test/ap_power/src/hibernate.c @@ -0,0 +1,41 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "hooks.h" + +#include "test_mocks.h" +#include "test_state.h" + +ZTEST(hibernate, test_g3_hibernate) +{ + extpower_is_present_fake.return_val = 0; + ap_power_ev_send_callbacks(AP_POWER_HARD_OFF); + k_sleep(K_SECONDS(30)); + zassert_equal(1, system_hibernate_fake.call_count); +} + +ZTEST(hibernate, test_ac_changed) +{ + extpower_is_present_fake.return_val = 1; + hook_notify(HOOK_AC_CHANGE); + k_sleep(K_SECONDS(30)); + zassert_equal(0, system_hibernate_fake.call_count); + extpower_is_present_fake.return_val = 0; + hook_notify(HOOK_AC_CHANGE); + k_sleep(K_SECONDS(30)); + zassert_equal(1, system_hibernate_fake.call_count); +} + +ZTEST_SUITE(hibernate, ap_power_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/ap_power/src/host_command.c b/zephyr/test/ap_power/src/host_command.c new file mode 100644 index 0000000000..4367f8fa44 --- /dev/null +++ b/zephyr/test/ap_power/src/host_command.c @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "ec_commands.h" +#include "host_command.h" +#include "test_state.h" + +ZTEST(host_cmd, test_hibernate_get) +{ + struct ec_response_hibernation_delay response; + struct ec_params_hibernation_delay params = { + .seconds = 0, + }; + + struct host_cmd_handler_args args = BUILD_HOST_COMMAND( + EC_CMD_HIBERNATION_DELAY, 0, response, params); + + zassert_ok(host_command_process(&args)); + params.seconds = 123; + zassert_ok(host_command_process(&args)); + zassert_equal(123, response.hibernate_delay, NULL); +} + +ZTEST_SUITE(host_cmd, ap_power_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/ap_power/src/test_mocks.c b/zephyr/test/ap_power/src/test_mocks.c new file mode 100644 index 0000000000..5dae36a6ab --- /dev/null +++ b/zephyr/test/ap_power/src/test_mocks.c @@ -0,0 +1,30 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "test_mocks.h" + +/* Mocks for common/extpower_gpio.c */ +DEFINE_FAKE_VALUE_FUNC(int, extpower_is_present); + +/* Mocks for common/system.c */ +DEFINE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); + +/** + * @brief Reset all the fakes before each test. + */ +static void fff_reset_rule_before(const struct ztest_unit_test *test, + void *data) +{ + ARG_UNUSED(test); + ARG_UNUSED(data); + + RESET_FAKE(extpower_is_present); + RESET_FAKE(system_hibernate); +} + +ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); -- cgit v1.2.1 From 82548740a8e9bfff0f65b47b8b18c2497029b223 Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Thu, 20 Oct 2022 11:21:51 +0800 Subject: corsola: set HDMI HPD in interrupt handler HPD pulse has to toggle with 0.5ms ~ 1ms. Previously, this was toggled in the hook, which will be hard to compliant to the requirement. This CL moves the HPD GPIO set function from hook to the interrupt handler to reduce the delay. Also, fixed the bugs when HDMI is plugged on boot and sometimes won't be detected. This is due to the usb_mux_set function will be skipped before we intentionally makes the USB_PD_PORT_COUNT to 2 after task inited. We fix this by re-configure mux setting after tasks inited. BUG=b:252999628 TEST=1. it6505 is able to capture the HPD interrupt when unplugged 2. HDMI port is able to output when plugged on boot BRANCH=none Change-Id: I6347033e2a7996a8f3a972e9f6b3feb328d4f8c7 Signed-off-by: Eric Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3967373 Reviewed-by: Ting Shen Tested-by: Eric Yilun Lin Code-Coverage: Zoss Commit-Queue: Eric Yilun Lin --- .../corsola/include/baseboard_usbc_config.h | 3 + zephyr/projects/corsola/src/usbc_config.c | 93 ++------------------- zephyr/projects/corsola/src/variant_db_detection.c | 96 ++++++++++++++++++++++ zephyr/test/kingler/CMakeLists.txt | 5 +- zephyr/test/kingler/common.dts | 18 ++++ zephyr/test/kingler/src/db_detect_hdmi.c | 52 +++++++++++- 6 files changed, 179 insertions(+), 88 deletions(-) diff --git a/zephyr/projects/corsola/include/baseboard_usbc_config.h b/zephyr/projects/corsola/include/baseboard_usbc_config.h index 66610fec5e..a80aa10446 100644 --- a/zephyr/projects/corsola/include/baseboard_usbc_config.h +++ b/zephyr/projects/corsola/include/baseboard_usbc_config.h @@ -18,6 +18,9 @@ void ppc_interrupt(enum gpio_signal signal); void ccd_interrupt(enum gpio_signal signal); +void hdmi_hpd_interrupt(enum gpio_signal signal); +void ps185_hdmi_hpd_mux_set(void); +int corsola_is_dp_muxable(int port); /* USB-A ports */ enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_COUNT }; diff --git a/zephyr/projects/corsola/src/usbc_config.c b/zephyr/projects/corsola/src/usbc_config.c index e3a2796de5..b9a1524fb6 100644 --- a/zephyr/projects/corsola/src/usbc_config.c +++ b/zephyr/projects/corsola/src/usbc_config.c @@ -128,92 +128,6 @@ void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) */ } -/** - * Handle PS185 HPD changing state. - */ -int debounced_hpd; - -static void ps185_hdmi_hpd_deferred(void) -{ - const int new_hpd = - gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); - - /* HPD status not changed, probably a glitch, just return. */ - if (debounced_hpd == new_hpd) { - return; - } - - debounced_hpd = new_hpd; - - if (!corsola_is_dp_muxable(USBC_PORT_C1)) { - if (debounced_hpd) { - CPRINTS("C0 port is already muxed."); - } - return; - } - - if (debounced_hpd) { - dp_status[USBC_PORT_C1] = - VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ - 0, /* HPD level ... not applicable */ - 0, /* exit DP? ... no */ - 0, /* usb mode? ... no */ - 0, /* multi-function ... no */ - 1, /* DP enabled ... yes */ - 0, /* power low? ... no */ - (!!DP_FLAGS_DP_ON)); - /* update C1 virtual mux */ - usb_mux_set(USBC_PORT_C1, USB_PD_MUX_DP_ENABLED, - USB_SWITCH_DISCONNECT, - 0 /* polarity, don't care */); - - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), - debounced_hpd); - CPRINTS("Set DP_AUX_PATH_SEL: %d", 1); - } - svdm_set_hpd_gpio(USBC_PORT_C1, debounced_hpd); - CPRINTS(debounced_hpd ? "HDMI plug" : "HDMI unplug"); -} -DECLARE_DEFERRED(ps185_hdmi_hpd_deferred); - -static void ps185_hdmi_hpd_disconnect_deferred(void) -{ - const int new_hpd = - gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); - - if (debounced_hpd == new_hpd && !new_hpd) { - dp_status[USBC_PORT_C1] = - VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ - 0, /* HPD level ... not applicable */ - 0, /* exit DP? ... no */ - 0, /* usb mode? ... no */ - 0, /* multi-function ... no */ - 0, /* DP enabled ... no */ - 0, /* power low? ... no */ - (!DP_FLAGS_DP_ON)); - usb_mux_set(USBC_PORT_C1, USB_PD_MUX_NONE, - USB_SWITCH_DISCONNECT, - 0 /* polarity, don't care */); - } -} -DECLARE_DEFERRED(ps185_hdmi_hpd_disconnect_deferred); - -#define PS185_HPD_DEBOUCE 250 -#define HPD_SINK_ABSENCE_DEBOUNCE (2 * MSEC) - -static void hdmi_hpd_interrupt(enum gpio_signal signal) -{ - hook_call_deferred(&ps185_hdmi_hpd_deferred_data, PS185_HPD_DEBOUCE); - - if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd))) { - hook_call_deferred(&ps185_hdmi_hpd_disconnect_deferred_data, - HPD_SINK_ABSENCE_DEBOUNCE); - } else { - hook_call_deferred(&ps185_hdmi_hpd_disconnect_deferred_data, - -1); - } -} - /* HDMI/TYPE-C function shared subboard interrupt */ void x_ec_interrupt(enum gpio_signal signal) { @@ -253,6 +167,13 @@ static void board_hdmi_handler(struct ap_power_ev_callback *cb, static void tasks_init_deferred(void) { tasks_inited = true; + if (corsola_get_db_type() == CORSOLA_DB_HDMI) { + /* If the HDMI port is plugged on-boot, and the usb_mux won't + * be configured before the task inited. Re-invoke the + * HPD configuration after task inited. + */ + ps185_hdmi_hpd_mux_set(); + } } DECLARE_DEFERRED(tasks_init_deferred); diff --git a/zephyr/projects/corsola/src/variant_db_detection.c b/zephyr/projects/corsola/src/variant_db_detection.c index 6099d86bdd..f68d9c8fad 100644 --- a/zephyr/projects/corsola/src/variant_db_detection.c +++ b/zephyr/projects/corsola/src/variant_db_detection.c @@ -6,16 +6,22 @@ /* Corsola daughter board detection */ #include +#include "baseboard_usbc_config.h" #include "console.h" #include "cros_cbi.h" #include "gpio/gpio_int.h" #include "hooks.h" +#include "usb_mux.h" #include "variant_db_detection.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) +#ifdef TEST_BUILD +uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; +#endif + static void corsola_db_config(enum corsola_db_type type) { switch (type) { @@ -113,3 +119,93 @@ static void corsola_db_init(void) corsola_get_db_type(); } DECLARE_HOOK(HOOK_INIT, corsola_db_init, HOOK_PRIO_PRE_I2C); + +/** + * Handle PS185 HPD changing state. + */ +void ps185_hdmi_hpd_mux_set(void) +{ + const int hpd = + gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); + + if (!corsola_is_dp_muxable(USBC_PORT_C1)) { + return; + } + + if (hpd && !(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { + dp_status[USBC_PORT_C1] = + VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ + 0, /* HPD level ... not applicable */ + 0, /* exit DP? ... no */ + 0, /* usb mode? ... no */ + 0, /* multi-function ... no */ + 1, /* DP enabled ... yes */ + 0, /* power low? ... no */ + (!!DP_FLAGS_DP_ON)); + /* update C1 virtual mux */ + usb_mux_set(USBC_PORT_C1, USB_PD_MUX_DP_ENABLED, + USB_SWITCH_DISCONNECT, + 0 /* polarity, don't care */); + CPRINTS("HDMI plug"); + } +} + +static void ps185_hdmi_hpd_deferred(void) +{ + const int hpd = + gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); + + if (!hpd && (usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { + dp_status[USBC_PORT_C1] = + VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ + 0, /* HPD level ... not applicable */ + 0, /* exit DP? ... no */ + 0, /* usb mode? ... no */ + 0, /* multi-function ... no */ + 0, /* DP enabled ... no */ + 0, /* power low? ... no */ + (!DP_FLAGS_DP_ON)); + usb_mux_set(USBC_PORT_C1, USB_PD_MUX_NONE, + USB_SWITCH_DISCONNECT, + 0 /* polarity, don't care */); + CPRINTS("HDMI unplug"); + + return; + } + + ps185_hdmi_hpd_mux_set(); +} +DECLARE_DEFERRED(ps185_hdmi_hpd_deferred); + +#define HPD_SINK_ABSENCE_DEBOUNCE (2 * MSEC) + +void hdmi_hpd_interrupt(enum gpio_signal signal) +{ + const int hpd = + gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); + + if (!hpd) { + hook_call_deferred(&ps185_hdmi_hpd_deferred_data, + HPD_SINK_ABSENCE_DEBOUNCE); + } else { + hook_call_deferred(&ps185_hdmi_hpd_deferred_data, -1); + } + + /* C0 DP is muxed, we should not send HPD to the AP */ + if (!corsola_is_dp_muxable(USBC_PORT_C1)) { + if (hpd) { + CPRINTS("C0 port is already muxed."); + } + return; + } + + if (hpd && !(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { + /* set dp_aux_path_sel first, and configure the usb_mux in the + * deferred hook to prevent from dead locking. + */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), hpd); + hook_call_deferred(&ps185_hdmi_hpd_deferred_data, 0); + } + + svdm_set_hpd_gpio(USBC_PORT_C1, hpd); +} diff --git a/zephyr/test/kingler/CMakeLists.txt b/zephyr/test/kingler/CMakeLists.txt index 6747b2ed99..4a30d06a61 100644 --- a/zephyr/test/kingler/CMakeLists.txt +++ b/zephyr/test/kingler/CMakeLists.txt @@ -23,7 +23,10 @@ app PRIVATE ${PLATFORM_EC}/zephyr/projects/corsola/src/variant_db_detection.c) target_sources_ifdef(CONFIG_TEST_DB_DETECT_TYPEC app PRIVATE src/db_detect_typec.c) target_sources_ifdef(CONFIG_TEST_DB_DETECT_HDMI - app PRIVATE src/db_detect_hdmi.c) + app PRIVATE src/db_detect_hdmi.c + ${PLATFORM_EC}/zephyr/shim/src/usb_muxes.c + ${PLATFORM_EC}/driver/usb_mux/usb_mux.c + ${PLATFORM_EC}/driver/usb_mux/virtual.c) target_sources_ifdef(CONFIG_TEST_DB_DETECT_NONE app PRIVATE src/db_detect_none.c) target_sources_ifdef(CONFIG_TEST_ALT_SENSOR_PROBE diff --git a/zephyr/test/kingler/common.dts b/zephyr/test/kingler/common.dts index 39b6f25036..c04844f227 100644 --- a/zephyr/test/kingler/common.dts +++ b/zephyr/test/kingler/common.dts @@ -13,10 +13,28 @@ port0@0 { compatible = "named-usbc-port"; reg = <0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; }; port1@1 { compatible = "named-usbc-port"; reg = <1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_1>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; }; }; diff --git a/zephyr/test/kingler/src/db_detect_hdmi.c b/zephyr/test/kingler/src/db_detect_hdmi.c index 35cf92ae5e..df29e613d6 100644 --- a/zephyr/test/kingler/src/db_detect_hdmi.c +++ b/zephyr/test/kingler/src/db_detect_hdmi.c @@ -5,12 +5,42 @@ #include "zephyr/kernel.h" #include +#include #include +#include "baseboard_usbc_config.h" +#include "ec_commands.h" #include "gpio_signal.h" #include "hooks.h" +#include "usb_mux.h" #include "variant_db_detection.h" +FAKE_VALUE_FUNC(int, corsola_is_dp_muxable, int); +FAKE_VOID_FUNC(svdm_set_hpd_gpio, int, int); + +#define FFF_FAKES_LIST(FAKE) \ + FAKE(corsola_is_dp_muxable) \ + FAKE(svdm_set_hpd_gpio) + +static void db_hdmi_rule_before(const struct ztest_unit_test *test, void *data) +{ + ARG_UNUSED(test); + ARG_UNUSED(data); + FFF_FAKES_LIST(RESET_FAKE); + FFF_RESET_HISTORY(); +} +ZTEST_RULE(db_hdmi_rule, db_hdmi_rule_before, NULL); + +uint8_t board_get_usb_pd_port_count(void) +{ + return 2; +} + +enum tcpc_cc_polarity pd_get_polarity(int port) +{ + return 0; +} + static void *db_detection_setup(void) { const struct device *hdmi_prsnt_gpio = DEVICE_DT_GET( @@ -73,11 +103,31 @@ ZTEST(db_detection, test_db_detect_hdmi) gpio_emul_output_get(ps185_pwrdn_gpio, ps185_pwrdn_pin), NULL); - /* Verify x_ec_interrupt is enabled */ + /* Verify x_ec_interrupt is enabled, and plug */ interrupt_count = 0; zassert_ok(gpio_emul_input_set(int_x_ec_gpio, int_x_ec_pin, 1), NULL); k_sleep(K_MSEC(100)); + corsola_is_dp_muxable_fake.return_val = 1; + zassert_equal(interrupt_count, 1, "interrupt_count=%d", interrupt_count); + + zassert_false(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED, NULL); + + /* invoke hdmi interrupt, the argument doesn't care, just pass 0 */ + hdmi_hpd_interrupt(0); + + k_sleep(K_MSEC(500)); + + zassert_equal(svdm_set_hpd_gpio_fake.call_count, 1); + zassert_true(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED, NULL); + + /* unplug */ + zassert_ok(gpio_emul_input_set(int_x_ec_gpio, int_x_ec_pin, 0), NULL); + + hdmi_hpd_interrupt(0); + k_sleep(K_MSEC(500)); + + zassert_false(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED, NULL); } -- cgit v1.2.1 From 84b2904dead700e10073080c54e69ea162d8a7c5 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 21 Oct 2022 11:23:38 -0700 Subject: core/cortex-m: Add .init_array to .ro_data When trying to build a unit test that links against googletest, we get the following errors: ld.lld: error: section '.image.RO' will not fit in region 'FLASH': overflowed by 811597840 bytes ld.lld: error: section '.image.RO.key' will not fit in region 'FLASH': overflowed by 811597840 bytes ld.lld: error: section '.image.RO.key' will not fit in region 'FLASH': overflowed by 811598672 bytes ld.lld: error: section '.image.ROLLBACK' will not fit in region 'FLASH': overflowed by 811598672 bytes ld.lld: error: section '.image.ROLLBACK' will not fit in region 'FLASH': overflowed by 811598716 bytes Looking at the sections in the ELF file, we see that .init_array is being put at a really large address: armv7m-cros-eabi-objdump -h \ ./build/dartmonkey/fpsensor_hw/RW/fpsensor_hw.RW.elf Sections: Idx Name Size VMA LMA File off Algn 10 .init_array 0000000c 38800000 38800000 000b0000 2**2 CONTENTS, ALLOC, LOAD, DATA 11 .init_array.100 00000004 3880000c 3880000c 000b000c 2**2 .init_array consists of read-only data (const data array of self-relative pointers to functions), so it can go in the .ro_data section. See https://developer.arm.com/documentation/dui0475/c/the-arm-c-and-c---libraries/c---initialization--construction-and-destruction for details. BRANCH=none BUG=b:234181908, b:254530679 TEST=make BOARD=dartmonkey test-fpsensor_hw -j TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes Change-Id: If6566763452e3f5f87767b0f4999d6db8e6c1572 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3971946 Reviewed-by: Andrea Grandi --- core/cortex-m/ec.lds.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index f5679a97f6..8ea35911df 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -347,6 +347,13 @@ SECTIONS . = ALIGN(64); KEEP(*(.google)) #endif + + /* + * https://developer.arm.com/documentation/dui0475/c/the-arm-c-and-c---libraries/c---initialization--construction-and-destruction + */ + . = ALIGN(4); + *(.init_array*) + /* * Empty C++ exception index table. The exception index * table is described in more detail in "Exception Handling -- cgit v1.2.1 From bafcc352e44498bde12a80da2c993ff7a6343047 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 1 Nov 2022 12:19:40 -0600 Subject: ec: Fix array access past end of array The test usb_common::test_pd_set_vbus_discharge_wrong_args exposed an array access past the end of the array. Move the port check to before the inited[] access. BRANCH=None BUG=None TEST=Tested on gitlab-runner Signed-off-by: Jeremy Bettis Change-Id: I47dcf64ec6caabd263ef146939bbc3f10e444ea7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995820 Reviewed-by: Abe Levkoy Auto-Submit: Jeremy Bettis Commit-Queue: Abe Levkoy Code-Coverage: Zoss Tested-by: Jeremy Bettis --- common/usb_common.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/usb_common.c b/common/usb_common.c index b4fefb6cf7..edede7c303 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -634,15 +634,17 @@ void pd_set_vbus_discharge(int port, int enable) static mutex_t discharge_lock[CONFIG_USB_PD_PORT_MAX_COUNT]; #ifdef CONFIG_ZEPHYR static bool inited[CONFIG_USB_PD_PORT_MAX_COUNT]; +#endif + + if (port >= board_get_usb_pd_port_count()) + return; +#ifdef CONFIG_ZEPHYR if (!inited[port]) { (void)k_mutex_init(&discharge_lock[port]); inited[port] = true; } #endif - if (port >= board_get_usb_pd_port_count()) - return; - mutex_lock(&discharge_lock[port]); enable &= !board_vbus_source_enabled(port); -- cgit v1.2.1 From 4fbecddd847e7adffff8843cdf93f4c68f44309a Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Wed, 26 Oct 2022 11:29:11 -0600 Subject: zephyr: Bring qcom.c test coverage to 100% Test the final lines in qcom.c. Make battery_is_present() test mockable. Change gpio_pmic_resin_l to be input|output so that it can be read. The gpio_emul is strict and doesn't allow reading output gpios. Add gpio_switchcap_pg, instead of using the output gpio as the input power-good-pin. Remove most all of the gpio device pointers, since all the gpios are on the same port. test_chipset_reset_success stopped working because the callback on pmic_resin_l wasn't getting called. Set the interrupt flags to fix. In test_power_button wait to set power_good until after pmic_kpd_pwr_odl is set. This is slightly more realistic. Add 2 more failures cases in power on sequence. Exclude an unreachable line from lcov. BRANCH=None BUG=None TEST=./twister Signed-off-by: Jeremy Bettis Change-Id: Ie38f53addfbc745e046f017f322dada4486405ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994229 Commit-Queue: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Abe Levkoy Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis --- include/battery.h | 2 +- power/qcom.c | 1 - zephyr/test/qcom_power/boards/native_posix.overlay | 11 +- zephyr/test/qcom_power/src/main.c | 311 +++++++++++---------- 4 files changed, 175 insertions(+), 150 deletions(-) diff --git a/include/battery.h b/include/battery.h index 51fcd68696..be93b44c21 100644 --- a/include/battery.h +++ b/include/battery.h @@ -220,7 +220,7 @@ enum battery_present battery_is_present(void); * If battery support is not enabled and the board does not specifically * provide its own implementation, assume a battery is never present. */ -static inline enum battery_present battery_is_present(void) +test_mockable_static_inline enum battery_present battery_is_present(void) { return BP_NO; } diff --git a/power/qcom.c b/power/qcom.c index 30374cd330..eba2d32442 100644 --- a/power/qcom.c +++ b/power/qcom.c @@ -1139,7 +1139,6 @@ test_mockable enum power_state power_handle_state(enum power_state state) default: CPRINTS("Unexpected power state %d", state); ASSERT(0); - break; } return state; diff --git a/zephyr/test/qcom_power/boards/native_posix.overlay b/zephyr/test/qcom_power/boards/native_posix.overlay index f062f27614..802721f430 100644 --- a/zephyr/test/qcom_power/boards/native_posix.overlay +++ b/zephyr/test/qcom_power/boards/native_posix.overlay @@ -65,7 +65,10 @@ enum-name = "GPIO_PMIC_KPD_PWR_ODL"; }; gpio_pmic_resin_l: pmic_resin_l { - gpios = <&gpio0 21 GPIO_OUTPUT_HIGH>; + /* Real hardware will allow reading even if GPIO_INPUT + * is not set, but the gpio_emul will not. + */ + gpios = <&gpio0 21 (GPIO_INPUT | GPIO_OUTPUT_HIGH)>; enum-name = "GPIO_PMIC_RESIN_L"; }; gpio_warm_reset_l: warm_reset_l { @@ -87,6 +90,10 @@ gpios = <&gpio0 25 (GPIO_INPUT | GPIO_PULL_UP)>; enum-name = "GPIO_POWER_BUTTON_L"; }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpio0 26 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; }; gpio-interrupts { @@ -135,7 +142,7 @@ switchcap { compatible = "switchcap-gpio"; enable-pin = <&gpio_switchcap_on>; - power-good-pin = <&gpio_switchcap_pg_int_l>; + power-good-pin = <&gpio_switchcap_pg>; }; }; diff --git a/zephyr/test/qcom_power/src/main.c b/zephyr/test/qcom_power/src/main.c index 22dd1fe2ec..33288af05f 100644 --- a/zephyr/test/qcom_power/src/main.c +++ b/zephyr/test/qcom_power/src/main.c @@ -16,7 +16,6 @@ #include "gpio_signal.h" #include "power/qcom.h" -#include "battery.h" #include "ec_app_main.h" #include "power.h" #include "console.h" @@ -24,14 +23,35 @@ #include "hooks.h" #include "host_command.h" #include "lid_switch.h" - -#define AP_RST_L_NODE DT_PATH(named_gpios, ap_rst_l) -#define POWER_GOOD_NODE DT_PATH(named_gpios, mb_power_good) -#define AP_SUSPEND_NODE DT_PATH(named_gpios, ap_suspend) -#define SWITCHCAP_PG_NODE DT_PATH(named_gpios, switchcap_pg_int_l) -#define PMIC_RESIN_L_NODE DT_PATH(named_gpios, pmic_resin_l) -#define EC_PWR_BTN_ODL_NODE DT_PATH(named_gpios, ec_pwr_btn_odl) -#define LID_OPEN_EC_NODE DT_PATH(named_gpios, lid_open_ec) +#include "gpio.h" + +/* For simplicity, enforce that all the gpios are on the same controller. */ +#define GPIO_DEVICE \ + DEVICE_DT_GET(DT_GPIO_CTLR(DT_PATH(named_gpios, ap_rst_l), gpios)) +#define ASSERT_SAME_CONTROLLER(x) \ + BUILD_ASSERT(DT_DEP_ORD(DT_GPIO_CTLR(DT_PATH(named_gpios, ap_rst_l), \ + gpios)) == \ + DT_DEP_ORD(DT_GPIO_CTLR(DT_PATH(named_gpios, x), gpios))) + +#define AP_RST_L_PIN DT_GPIO_PIN(DT_PATH(named_gpios, ap_rst_l), gpios) +ASSERT_SAME_CONTROLLER(ap_rst_l); +#define POWER_GOOD_PIN DT_GPIO_PIN(DT_PATH(named_gpios, mb_power_good), gpios) +ASSERT_SAME_CONTROLLER(mb_power_good); +#define AP_SUSPEND_PIN DT_GPIO_PIN(DT_PATH(named_gpios, ap_suspend), gpios) +ASSERT_SAME_CONTROLLER(ap_suspend); +#define SWITCHCAP_PG_PIN \ + DT_GPIO_PIN(DT_PATH(named_gpios, src_vph_pwr_pg), gpios) +ASSERT_SAME_CONTROLLER(src_vph_pwr_pg); +#define PMIC_RESIN_L_PIN DT_GPIO_PIN(DT_PATH(named_gpios, pmic_resin_l), gpios) +ASSERT_SAME_CONTROLLER(pmic_resin_l); +#define EC_PWR_BTN_ODL_PIN \ + DT_GPIO_PIN(DT_PATH(named_gpios, ec_pwr_btn_odl), gpios) +ASSERT_SAME_CONTROLLER(ec_pwr_btn_odl); +#define LID_OPEN_EC_PIN DT_GPIO_PIN(DT_PATH(named_gpios, lid_open_ec), gpios) +ASSERT_SAME_CONTROLLER(lid_open_ec); +#define PMIC_KPD_PWR_ODL_PIN \ + DT_GPIO_PIN(DT_PATH(named_gpios, pmic_kpd_pwr_odl), gpios) +ASSERT_SAME_CONTROLLER(pmic_kpd_pwr_odl); static int chipset_reset_count; static bool set_power_good_on_reset; @@ -45,11 +65,9 @@ DECLARE_HOOK(HOOK_CHIPSET_RESET, do_chipset_reset, HOOK_PRIO_DEFAULT); static void do_chipset_shutdown(void) { if (set_power_good_on_reset) { - static const struct device *power_good_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; - gpio_emul_input_set(power_good_dev, - DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 1); + gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 1); } } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, do_chipset_shutdown, HOOK_PRIO_DEFAULT); @@ -58,6 +76,10 @@ DEFINE_FFF_GLOBALS; FAKE_VALUE_FUNC(int, system_can_boot_ap); FAKE_VALUE_FUNC(int, battery_wait_for_stable); +int battery_is_present(void) +{ + return 1; +} /* Tests the chipset_ap_rst_interrupt() handler when in S3. * @@ -68,15 +90,11 @@ FAKE_VALUE_FUNC(int, battery_wait_for_stable); */ static void do_chipset_ap_rst_interrupt_in_s3(int times) { - static const struct device *ap_rst_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios)); - static const struct device *ap_suspend_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_SUSPEND_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; /* Preconditions */ power_signal_enable_interrupt(GPIO_AP_SUSPEND); - zassert_ok(gpio_emul_input_set(ap_suspend_dev, - DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1)); power_set_state(POWER_S3); task_wake(TASK_ID_CHIPSET); k_sleep(K_MSEC(10)); @@ -87,18 +105,15 @@ static void do_chipset_ap_rst_interrupt_in_s3(int times) /* Pulse gpio_ap_rst_l `times` */ for (int i = 0; i < times; ++i) { - zassert_ok(gpio_emul_input_set( - ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 0)); - zassert_ok(gpio_emul_input_set( - ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 1)); } /* Wait for timeout AP_RST_TRANSITION_TIMEOUT. */ k_sleep(K_MSEC(500)); /* Verify that gpio_ap_suspend is ignored. */ - zassert_ok(gpio_emul_input_set(ap_suspend_dev, - DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 0)); k_sleep(K_MSEC(10)); zassert_equal(power_get_state(), POWER_S3); /* Verify that HOOK_CHIPSET_RESET was called once. */ @@ -140,18 +155,15 @@ ZTEST(qcom_power, test_notify_chipset_reset_s3) */ static void do_chipset_ap_rst_interrupt_in_s0(int times) { - static const struct device *ap_rst_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; shell_backend_dummy_clear_output(get_ec_shell()); chipset_reset_count = 0; /* Pulse gpio_ap_rst_l `times` */ for (int i = 0; i < times; ++i) { - zassert_ok(gpio_emul_input_set( - ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 0)); - zassert_ok(gpio_emul_input_set( - ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 1)); } /* Wait for timeout AP_RST_TRANSITION_TIMEOUT. */ @@ -218,39 +230,57 @@ void warm_reset_callback(const struct device *gpio_dev, struct gpio_callback *callback_struct, gpio_port_pins_t pins) { - if ((pins & BIT(DT_GPIO_PIN(PMIC_RESIN_L_NODE, gpios))) == 0) { + if ((pins & BIT(PMIC_RESIN_L_PIN)) == 0) { return; } - if (gpio_emul_output_get(gpio_dev, - DT_GPIO_PIN(PMIC_RESIN_L_NODE, gpios))) { - static const struct device *ap_rst_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios)); + if (gpio_emul_output_get(gpio_dev, PMIC_RESIN_L_PIN)) { + gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 0); + } +} + +static void set_power_good(struct k_work *work) +{ + static const struct device *gpio_dev = GPIO_DEVICE; + + gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 1); +} +K_WORK_DEFINE(set_power_good_work, set_power_good); - gpio_emul_input_set(ap_rst_dev, - DT_GPIO_PIN(AP_RST_L_NODE, gpios), 0); +/* PMIC_KPD_PWR_ODL is a signal to turn the power on. The signal that + * it worked is POWER_GOOD. + */ +void power_good_callback(const struct device *gpio_dev, + struct gpio_callback *callback_struct, + gpio_port_pins_t pins) +{ + if ((pins & BIT(PMIC_KPD_PWR_ODL_PIN)) == 0) { + return; + } + if (!gpio_emul_output_get(gpio_dev, PMIC_KPD_PWR_ODL_PIN)) { + /* Set power good in the work queue, instead of now. */ + k_work_submit(&set_power_good_work); } } /* Call chipset_reset, wait for PMIC_RESIN_L, pulse ap_rsl_l. */ ZTEST(qcom_power, test_chipset_reset_success) { - static const struct device *ap_rst_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios)); - static const struct device *pmic_resin_l_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(PMIC_RESIN_L_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; const char *buffer; size_t buffer_size; /* Setup callback. */ gpio_init_callback(&gpio_callback, warm_reset_callback, - BIT(DT_GPIO_PIN(PMIC_RESIN_L_NODE, gpios))); - zassert_ok(gpio_add_callback(pmic_resin_l_dev, &gpio_callback)); + BIT(PMIC_RESIN_L_PIN)); + zassert_ok(gpio_add_callback(gpio_dev, &gpio_callback)); + zassert_ok(gpio_pin_interrupt_configure(gpio_dev, PMIC_RESIN_L_PIN, + GPIO_INT_EDGE_BOTH)); /* Reset. The reason doesn't really matter. */ shell_backend_dummy_clear_output(get_ec_shell()); chipset_reset(CHIPSET_RESET_KB_WARM_REBOOT); k_sleep(K_MSEC(100)); - gpio_emul_input_set(ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 1); + gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 1); /* Long enough for a cold reset, although we don't expect one. */ k_sleep(K_MSEC(1000)); @@ -268,8 +298,7 @@ ZTEST(qcom_power, test_chipset_reset_success) /* Sent the host command, set the gpio, wait for transition to S3. */ ZTEST(qcom_power, test_request_sleep) { - static const struct device *ap_suspend_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_SUSPEND_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; struct ec_params_host_sleep_event params = { .sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND, }; @@ -277,8 +306,7 @@ ZTEST(qcom_power, test_request_sleep) EC_CMD_HOST_SLEEP_EVENT, UINT8_C(0), params); zassert_ok(host_command_process(&args)); - zassert_ok(gpio_emul_input_set(ap_suspend_dev, - DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1)); k_sleep(K_SECONDS(16)); zassert_equal(power_get_state(), POWER_S3); zassert_false(host_is_event_set(EC_HOST_EVENT_HANG_DETECT)); @@ -314,53 +342,88 @@ ZTEST(qcom_power, test_chipset_force_shutdown) ZTEST(qcom_power, test_power_button) { - static const struct device *ec_pwr_btn_odl_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; + + /* Setup callback. */ + gpio_init_callback(&gpio_callback, power_good_callback, + BIT(PMIC_KPD_PWR_ODL_PIN)); + zassert_ok(gpio_add_callback(gpio_dev, &gpio_callback)); power_set_state(POWER_G3); + zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, PMIC_RESIN_L_PIN, 1)); k_sleep(K_MSEC(10)); zassert_equal(power_get_state(), POWER_G3); - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0)); k_sleep(K_MSEC(100)); - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1)); k_sleep(K_MSEC(500)); zassert_equal(power_get_state(), POWER_S0); } ZTEST(qcom_power, test_power_button_no_power_good) { - static const struct device *ec_pwr_btn_odl_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios)); - static const struct device *power_good_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; - zassert_ok(gpio_emul_input_set(power_good_dev, - DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0)); power_set_state(POWER_G3); k_sleep(K_MSEC(10)); zassert_equal(power_get_state(), POWER_G3); - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0)); k_sleep(K_MSEC(100)); - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1)); k_sleep(K_MSEC(1500)); zassert_equal(power_get_state(), POWER_S5, "power_state=%d", power_get_state()); } +ZTEST(qcom_power, test_power_button_no_switchcap_good) +{ + static const struct device *gpio_dev = GPIO_DEVICE; + + zassert_ok(gpio_emul_input_set(gpio_dev, SWITCHCAP_PG_PIN, 0)); + power_set_state(POWER_G3); + k_sleep(K_MSEC(10)); + zassert_equal(power_get_state(), POWER_G3); + + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0)); + k_sleep(K_MSEC(100)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1)); + k_sleep(K_SECONDS(10)); + zassert_equal(power_get_state(), POWER_S5, "power_state=%d", + power_get_state()); +} + +ZTEST(qcom_power, test_power_button_no_pmic_resin_pullup) +{ + const char *buffer; + size_t buffer_size; + static const struct device *gpio_dev = GPIO_DEVICE; + + power_set_state(POWER_G3); + k_sleep(K_MSEC(10)); + zassert_equal(power_get_state(), POWER_G3); + + shell_backend_dummy_clear_output(get_ec_shell()); + zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, PMIC_RESIN_L_PIN, 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0)); + k_sleep(K_MSEC(100)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1)); + k_sleep(K_SECONDS(10)); + zassert_equal(power_get_state(), POWER_S5, "power_state=%d", + power_get_state()); + + buffer = shell_backend_dummy_get_output(get_ec_shell(), &buffer_size); + zassert_not_null(strstr(buffer, "PMIC_RESIN_L not pulled up by PMIC"), + "Invalid console output %s", buffer); +} + ZTEST(qcom_power, test_power_button_battery_low) { - static const struct device *ec_pwr_btn_odl_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; RESET_FAKE(system_can_boot_ap); system_can_boot_ap_fake.return_val = 0; @@ -369,13 +432,9 @@ ZTEST(qcom_power, test_power_button_battery_low) k_sleep(K_MSEC(10)); zassert_equal(power_get_state(), POWER_G3); - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0)); k_sleep(K_MSEC(100)); - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1)); /* > CAN_BOOT_AP_CHECK_TIMEOUT + CAN_BOOT_AP_CHECK_WAIT */ k_sleep(K_MSEC(1800)); zassert_equal(power_get_state(), POWER_S5); @@ -383,8 +442,7 @@ ZTEST(qcom_power, test_power_button_battery_low) ZTEST(qcom_power, test_host_sleep_event_resume) { - static const struct device *ap_suspend_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_SUSPEND_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; struct ec_params_host_sleep_event params = { .sleep_event = HOST_SLEEP_EVENT_S3_RESUME, }; @@ -393,16 +451,14 @@ ZTEST(qcom_power, test_host_sleep_event_resume) /* Get into S3 first */ power_signal_enable_interrupt(GPIO_AP_SUSPEND); - zassert_ok(gpio_emul_input_set(ap_suspend_dev, - DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1)); power_set_state(POWER_S3); task_wake(TASK_ID_CHIPSET); k_sleep(K_MSEC(10)); zassert_equal(power_get_state(), POWER_S3); /* Exit suspend via gpio. */ - zassert_ok(gpio_emul_input_set(ap_suspend_dev, - DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 0)); k_sleep(K_MSEC(100)); zassert_equal(power_get_state(), POWER_S0, "power_state=%d", power_get_state()); @@ -414,40 +470,29 @@ ZTEST(qcom_power, test_host_sleep_event_resume) power_get_state()); /* Check that AP_SUSPEND interrupts are disabled & we are in S0. */ - zassert_ok(gpio_emul_input_set(ap_suspend_dev, - DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1)); k_sleep(K_MSEC(100)); zassert_equal(power_get_state(), POWER_S0); } ZTEST(qcom_power, test_power_button_off) { - static const struct device *ec_pwr_btn_odl_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0)); k_sleep(K_SECONDS(9)); - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1)); k_sleep(K_MSEC(500)); zassert_equal(power_get_state(), POWER_S5); } ZTEST(qcom_power, test_power_button_off_cancel) { - static const struct device *ec_pwr_btn_odl_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0)); k_sleep(K_SECONDS(4)); - zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev, - DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios), - 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1)); k_sleep(K_MSEC(500)); zassert_equal(power_get_state(), POWER_S0); } @@ -456,12 +501,10 @@ ZTEST(qcom_power, test_no_power_good) { const char *buffer; size_t buffer_size; - static const struct device *power_good_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; shell_backend_dummy_clear_output(get_ec_shell()); - zassert_ok(gpio_emul_input_set(power_good_dev, - DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0)); k_sleep(K_MSEC(500)); zassert_equal(power_get_state(), POWER_S5, "power_state=%d", power_get_state()); @@ -474,12 +517,10 @@ ZTEST(qcom_power, test_no_power_good_then_good) { const char *buffer; size_t buffer_size; - static const struct device *power_good_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; shell_backend_dummy_clear_output(get_ec_shell()); - zassert_ok(gpio_emul_input_set(power_good_dev, - DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0)); set_power_good_on_reset = true; k_sleep(K_MSEC(500)); zassert_equal(power_get_state(), POWER_S5, "power_state=%d", @@ -493,18 +534,15 @@ ZTEST(qcom_power, test_no_power_good_then_good) ZTEST(qcom_power, test_lid_open_power_on) { - static const struct device *lid_open_ec_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(LID_OPEN_EC_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; - zassert_ok(gpio_emul_input_set( - lid_open_ec_dev, DT_GPIO_PIN(LID_OPEN_EC_NODE, gpios), 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, LID_OPEN_EC_PIN, 0)); power_set_state(POWER_G3); k_sleep(K_MSEC(100)); zassert_equal(power_get_state(), POWER_G3); zassert_false(lid_is_open()); - zassert_ok(gpio_emul_input_set( - lid_open_ec_dev, DT_GPIO_PIN(LID_OPEN_EC_NODE, gpios), 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, LID_OPEN_EC_PIN, 1)); k_sleep(K_MSEC(500)); zassert_equal(power_get_state(), POWER_S0, "power_state=%d", power_get_state()); @@ -556,11 +594,9 @@ ZTEST(qcom_power, test_power_chipset_init_sysjump_power_good) ZTEST(qcom_power, test_power_chipset_init_sysjump_power_off) { - static const struct device *power_good_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; - zassert_ok(gpio_emul_input_set(power_good_dev, - DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0)); system_set_reset_flags(EC_RESET_FLAG_SYSJUMP); zassert_equal(power_chipset_init(), POWER_G3); power_set_state(POWER_G3); @@ -585,18 +621,7 @@ ZTEST(qcom_power, test_power_chipset_init_ap_off) void start_in_s0(void *fixture) { - static const struct device *ap_rst_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios)); - static const struct device *power_good_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios)); - static const struct device *ap_suspend_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(AP_SUSPEND_NODE, gpios)); - static const struct device *switchcap_pg_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(SWITCHCAP_PG_NODE, gpios)); - static const struct device *pmic_resin_l_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(PMIC_RESIN_L_NODE, gpios)); - static const struct device *lid_open_ec_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(LID_OPEN_EC_NODE, gpios)); + static const struct device *gpio_dev = GPIO_DEVICE; RESET_FAKE(system_can_boot_ap); system_can_boot_ap_fake.return_val = 1; @@ -604,18 +629,12 @@ void start_in_s0(void *fixture) power_signal_disable_interrupt(GPIO_AP_SUSPEND); power_signal_enable_interrupt(GPIO_AP_RST_L); - zassert_ok(gpio_emul_input_set(power_good_dev, - DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 1)); - zassert_ok(gpio_emul_input_set(ap_suspend_dev, - DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 0)); - zassert_ok(gpio_emul_input_set(ap_rst_dev, - DT_GPIO_PIN(AP_RST_L_NODE, gpios), 1)); - zassert_ok(gpio_emul_input_set( - switchcap_pg_dev, DT_GPIO_PIN(SWITCHCAP_PG_NODE, gpios), 1)); - zassert_ok(gpio_pin_set(pmic_resin_l_dev, - DT_GPIO_PIN(PMIC_RESIN_L_NODE, gpios), 1)); - zassert_ok(gpio_emul_input_set( - lid_open_ec_dev, DT_GPIO_PIN(LID_OPEN_EC_NODE, gpios), 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 0)); + zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, SWITCHCAP_PG_PIN, 1)); + zassert_ok(gpio_pin_set(gpio_dev, PMIC_RESIN_L_PIN, 1)); + zassert_ok(gpio_emul_input_set(gpio_dev, LID_OPEN_EC_PIN, 1)); power_set_state(POWER_S0); power_signal_interrupt(GPIO_AP_SUSPEND); task_wake(TASK_ID_CHIPSET); @@ -629,9 +648,9 @@ void start_in_s0(void *fixture) void qcom_cleanup(void *fixture) { if (gpio_callback.handler != NULL) { - static const struct device *pmic_resin_l_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(PMIC_RESIN_L_NODE, gpios)); - gpio_remove_callback(pmic_resin_l_dev, &gpio_callback); + static const struct device *gpio_dev = GPIO_DEVICE; + + gpio_remove_callback(gpio_dev, &gpio_callback); gpio_callback.handler = NULL; } host_clear_events(EC_HOST_EVENT_MASK(EC_HOST_EVENT_HANG_DETECT)); -- cgit v1.2.1 From 76d2b5cd5ddfc3d9a592d31f052e1bb2887fcf1d Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 1 Nov 2022 14:30:00 -0600 Subject: cq: Pass the compiler to twister On some CQ runners /usr/bin/cc is a symlink to clang instead of gcc. To prevent that from affecting the build, always pass the compiler to twister. The native_posix tests still use the compiler specified by the toolchain cmake files, this only affects unit_testing builds. BRANCH=None BUG=None TEST=Ran the twister cmd. Signed-off-by: Jeremy Bettis Change-Id: I749149d17ad9cd46c0179048209d0067aa4ef2ae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997617 Commit-Queue: Jeremy Bettis Reviewed-by: Aaron Massey Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Commit-Queue: Aaron Massey --- zephyr/firmware_builder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index 545d31312d..30b4a1353e 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -46,6 +46,8 @@ def run_twister(platform_ec, code_coverage=False, extra_args=None): "-p", "unit_testing", "--no-upload-cros-rdb", + "-x=CMAKE_C_COMPILER=/usr/bin/x86_64-pc-linux-gnu-gcc", + "-x=CMAKE_CXX_COMPILER=/usr/bin/x86_64-pc-linux-gnu-g++", ] if extra_args: -- cgit v1.2.1 From 29699a43299a9782ad0e8ca3998b415b8cbb26ad Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 26 Aug 2022 15:02:26 -0700 Subject: test/fpsensor_hw: Convert to C++ BRANCH=none BUG=b:243700149, b:234181908 TEST=./test/run_device_tests.py --board dartmonkey -t fpsensor_hw Signed-off-by: Tom Hughes Change-Id: I2c32f2493abf60dea0de6c1a8671598f8b30034b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3860407 Reviewed-by: Bobby Casey Reviewed-by: Andrea Grandi --- driver/fingerprint/fpc/bep/fpc_private.h | 8 ++++++ driver/fingerprint/fpc/libfp/fpc_private.h | 8 ++++++ test/fpsensor_hw.c | 39 ------------------------------ test/fpsensor_hw.cc | 39 ++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 39 deletions(-) delete mode 100644 test/fpsensor_hw.c create mode 100644 test/fpsensor_hw.cc diff --git a/driver/fingerprint/fpc/bep/fpc_private.h b/driver/fingerprint/fpc/bep/fpc_private.h index ca5b98fa8e..df8b8eeea6 100644 --- a/driver/fingerprint/fpc/bep/fpc_private.h +++ b/driver/fingerprint/fpc/bep/fpc_private.h @@ -8,6 +8,10 @@ #ifndef __CROS_EC_FPC_PRIVATE_H #define __CROS_EC_FPC_PRIVATE_H +#ifdef __cplusplus +extern "C" { +#endif + #include typedef struct { @@ -46,4 +50,8 @@ int fp_sensor_maintenance(uint8_t *image_data, */ int fpc_get_hwid(uint16_t *id); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_FPC_PRIVATE_H */ diff --git a/driver/fingerprint/fpc/libfp/fpc_private.h b/driver/fingerprint/fpc/libfp/fpc_private.h index 19ac3b7a13..a1fe0e47a2 100644 --- a/driver/fingerprint/fpc/libfp/fpc_private.h +++ b/driver/fingerprint/fpc/libfp/fpc_private.h @@ -8,6 +8,10 @@ #ifndef __CROS_EC_FPC_PRIVATE_H #define __CROS_EC_FPC_PRIVATE_H +#ifdef __cplusplus +extern "C" { +#endif + /* External error codes from FPC's sensor library */ enum fpc_error_code_external { FPC_ERROR_NONE = 0, @@ -157,4 +161,8 @@ int fp_sensor_maintenance(uint8_t *image_data, */ int fpc_get_hwid(uint16_t *id); +#ifdef __cplusplus +} +#endif + #endif /* __CROS_EC_FPC_PRIVATE_H */ diff --git a/test/fpsensor_hw.c b/test/fpsensor_hw.c deleted file mode 100644 index ff5b78ace2..0000000000 --- a/test/fpsensor_hw.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "test_util.h" -#include "fpc_private.h" -#include "board.h" - -#ifdef SECTION_IS_RW -#include "fpc/fpc_sensor.h" -static const uint32_t fp_sensor_hwid = FP_SENSOR_HWID; -#else -static const uint32_t fp_sensor_hwid = UINT32_MAX; -#endif - -/* Hardware-dependent smoke test that makes a SPI transaction with the - * fingerprint sensor. - */ -test_static int test_fp_check_hwid(void) -{ - uint16_t id = 0; - - if (IS_ENABLED(SECTION_IS_RW)) { - TEST_EQ(fpc_get_hwid(&id), EC_SUCCESS, "%d"); - /* The lower 4-bits of the sensor hardware id are a - * manufacturing ID that is ok to vary. - */ - TEST_EQ(fp_sensor_hwid, id >> 4, "%d"); - }; - return EC_SUCCESS; -} - -void run_test(int argc, const char **argv) -{ - RUN_TEST(test_fp_check_hwid); - test_print_result(); -} diff --git a/test/fpsensor_hw.cc b/test/fpsensor_hw.cc new file mode 100644 index 0000000000..3d4a6c95dd --- /dev/null +++ b/test/fpsensor_hw.cc @@ -0,0 +1,39 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "test_util.h" +#include "fpc_private.h" +#include "board.h" + +#ifdef SECTION_IS_RW +#include "fpc/fpc_sensor.h" +static const uint32_t fp_sensor_hwid = FP_SENSOR_HWID; +#else +static const uint32_t fp_sensor_hwid = UINT32_MAX; +#endif + +/* Hardware-dependent smoke test that makes a SPI transaction with the + * fingerprint sensor. + */ +test_static int test_fp_check_hwid(void) +{ + uint16_t id = 0; + + if (IS_ENABLED(SECTION_IS_RW)) { + TEST_EQ(fpc_get_hwid(&id), EC_SUCCESS, "%d"); + /* The lower 4-bits of the sensor hardware id are a + * manufacturing ID that is ok to vary. + */ + TEST_EQ(fp_sensor_hwid, id >> 4, "%d"); + }; + return EC_SUCCESS; +} + +extern "C" void run_test(int argc, const char **argv) +{ + RUN_TEST(test_fp_check_hwid); + test_print_result(); +} -- cgit v1.2.1 From d6020b957eaa92b3770f5fafbaa03d8bb0880cf2 Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Mon, 31 Oct 2022 13:07:58 -0600 Subject: test: do_cbi_read() failed to read head path Add a test that sets up a failure to read the eeprom cbi header information during an invocation of cbi_get_board_info() and verify this error is handled gracefully by returning an EC error code. BRANCH=none BUG=b:256030656 TEST=./twister -i -s zephyr/test/drivers/drivers.common_cbi Signed-off-by: Aaron Massey Change-Id: I57eb00a0b34f15a34aa0e1322b2e2cc8a4ccb765 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994440 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/shim/src/cbi/cbi_eeprom.c | 2 +- .../test/drivers/common_cbi/src/test_common_cbi.c | 48 ++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/zephyr/shim/src/cbi/cbi_eeprom.c b/zephyr/shim/src/cbi/cbi_eeprom.c index aa6c4e0fa1..ecc78ba41e 100644 --- a/zephyr/shim/src/cbi/cbi_eeprom.c +++ b/zephyr/shim/src/cbi/cbi_eeprom.c @@ -25,7 +25,7 @@ void cbi_latch_eeprom_wp(void) } #endif /* CONFIG_PLATFORM_EC_EEPROM_CBI_WP */ -static int eeprom_load(uint8_t offset, uint8_t *data, int len) +test_mockable_static int eeprom_load(uint8_t offset, uint8_t *data, int len) { return eeprom_read(CBI_EEPROM_DEV, offset, data, len); } diff --git a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c index 90f08831be..ab29f7c2e6 100644 --- a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c +++ b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ +#include #include #include @@ -12,6 +13,9 @@ #include "test/drivers/test_state.h" #define WP_L_GPIO_PATH DT_PATH(named_gpios, wp_l) +#define CBI_EEPROM_DEV DEVICE_DT_GET(DT_NODELABEL(cbi_eeprom)) + +FAKE_VALUE_FUNC(int, eeprom_load, uint8_t, uint8_t *, int); static int gpio_wp_l_set(int value) { @@ -22,6 +26,33 @@ static int gpio_wp_l_set(int value) DT_GPIO_PIN(WP_L_GPIO_PATH, gpios), value); } +static int __test_eeprom_load_default_impl(uint8_t offset, uint8_t *data, + int len) +{ + int ret = eeprom_read(CBI_EEPROM_DEV, offset, data, len); + + return ret; +} + +ZTEST(common_cbi, test_do_cbi_read__cant_load_head) +{ + enum cbi_data_tag arbitrary_unused_tag = CBI_TAG_SKU_ID; + uint8_t arbitrary_unused_byte_buffer[100]; + uint8_t unused_data_size; + + /* Force a do_cbi_read() to eeprom */ + cbi_invalidate_cache(); + + /* Return arbitrary nonzero value */ + eeprom_load_fake.return_val = 1; + eeprom_load_fake.custom_fake = NULL; + + zassert_equal(cbi_get_board_info(arbitrary_unused_tag, + arbitrary_unused_byte_buffer, + &unused_data_size), + EC_ERROR_UNKNOWN); +} + ZTEST(common_cbi, test_cbi_set_string__null_str) { struct cbi_data data = { 0 }; @@ -86,9 +117,6 @@ ZTEST_USER(common_cbi, test_hc_cbi_set_then_get) memcpy(hc_set_params.params.data, data, ARRAY_SIZE(data)); - /* Zero out cbi */ - cbi_create(); - /* Turn off write-protect so we can actually write */ gpio_wp_l_set(1); @@ -158,9 +186,6 @@ ZTEST_USER(common_cbi, test_hc_cbi_set_then_get__with_too_small_response) memcpy(hc_set_params.params.data, data, ARRAY_SIZE(data)); - /* Zero out cbi */ - cbi_create(); - /* Turn off write-protect so we can actually write */ gpio_wp_l_set(1); @@ -191,4 +216,13 @@ ZTEST_USER(common_cbi, test_hc_cbi_set_then_get__with_too_small_response) zassert_equal(host_command_process(&get_args), EC_RES_INVALID_PARAM); } -ZTEST_SUITE(common_cbi, drivers_predicate_post_main, NULL, NULL, NULL, NULL); +static void test_common_cbi_before_after(void *test_data) +{ + RESET_FAKE(eeprom_load); + eeprom_load_fake.custom_fake = __test_eeprom_load_default_impl; + + cbi_create(); +} + +ZTEST_SUITE(common_cbi, drivers_predicate_post_main, NULL, + test_common_cbi_before_after, test_common_cbi_before_after, NULL); -- cgit v1.2.1 From 741bbd86cb48de471759c1519901202467342fca Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 1 Nov 2022 15:45:59 -0600 Subject: zephyr: Increase test timeout. I had a cl fail in presubmit with a test timeout Increase test timeout for this test. BRANCH=None BUG=None TEST=None Signed-off-by: Jeremy Bettis Change-Id: I6e041e8987081f4382ced4acfe93f1c70d1d4a4f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995331 Auto-Submit: Jeremy Bettis Reviewed-by: Tristan Honscheid Commit-Queue: Tristan Honscheid Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis --- zephyr/test/drivers/testcase.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 91773fad6c..a6c250c361 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -188,7 +188,8 @@ tests: - CONFIG_LINK_TEST_SUITE_USBC_ALT_MODE=y timeout: 120 drivers.usbc_alt_mode_ec_entry: - extra_configs: + timeout: 120 + extra_configs: - CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=n - CONFIG_LINK_TEST_SUITE_USBC_ALT_MODE=y - CONFIG_POWER_SEQUENCE_MOCK=y -- cgit v1.2.1 From 79d4706f92680ed4a192b585a1db072e9e3da7ad Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Fri, 21 Oct 2022 08:27:50 -0700 Subject: test: Add benchmark library (C++) Add a benchmark library (benchmark.h) to measure the execution time of functions. It is written in C++ to simplify the interface. For example, it can be used to benchmark lambdas with captures. BUG=b:246366702 BRANCH=none TEST=test/run_device_tests.py -b bloonchipper -t benchmark TEST=make run-benchmark Signed-off-by: Andrea Grandi Change-Id: Ibed907609a27566e386c511153fcd2d819981356 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3971378 Code-Coverage: Zoss Reviewed-by: Tom Hughes --- board/hatch_fp/build.mk | 1 + board/nocturne_fp/build.mk | 1 + include/benchmark.h | 156 +++++++++++++++++++++++++++++++++++++++++++++ test/benchmark.cc | 98 ++++++++++++++++++++++++++++ test/benchmark.tasklist | 9 +++ test/build.mk | 2 + test/run_device_tests.py | 1 + 7 files changed, 268 insertions(+) create mode 100644 include/benchmark.h create mode 100644 test/benchmark.cc create mode 100644 test/benchmark.tasklist diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk index 828e7523b3..8ff7ec6cfb 100644 --- a/board/hatch_fp/build.mk +++ b/board/hatch_fp/build.mk @@ -29,6 +29,7 @@ test-list-y=\ abort \ aes \ always_memset \ + benchmark \ cec \ compile_time_macros \ cortexm_fpu \ diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk index 65ffd6c096..cd3981263c 100644 --- a/board/nocturne_fp/build.mk +++ b/board/nocturne_fp/build.mk @@ -29,6 +29,7 @@ test-list-y=\ abort \ aes \ always_memset \ + benchmark \ cec \ compile_time_macros \ cortexm_fpu \ diff --git a/include/benchmark.h b/include/benchmark.h new file mode 100644 index 0000000000..f9c9a1afcd --- /dev/null +++ b/include/benchmark.h @@ -0,0 +1,156 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Benchmark utility functions. + */ + +#ifndef __CROS_EC_BENCHMARK_H +#define __CROS_EC_BENCHMARK_H + +#include +#include +#include +#include +#include + +extern "C" { +#include "console.h" +#include "timer.h" +#include "util.h" +#include "clock.h" +#include "watchdog.h" +} + +/* Benchmark execution options */ +struct BenchmarkOptions { + /* Number of test iterations */ + int num_iterations = 10; + /* Whether to reload the watchdog between executions of f() */ + bool reload_watchdog = true; + /* Whether to enable fast CPU clock during the test (when supported) */ + bool use_fast_cpu = true; +}; + +/* The result of a benchmark run with various timing metrics. + * All time measurements are in micro seconds, except the average that + * is captured in nanoseconds for increased resolution. + */ +struct BenchmarkResult { + /* Name of the test, used when printing results */ + std::string_view name; + /* Total elapsed time (us) for all iterations */ + uint32_t elapsed_time; + /* Average elapsed time (ns) for a single iteration */ + uint32_t average_time; + /* Minimum elapsed time (us) for a single iteration */ + uint32_t min_time; + /* Maximum elapsed time (us) for a single iteration */ + uint32_t max_time; +}; + +/* Benchmark main class responsible for running the experiments and + * collecting/printing the results. + * Note that the implementation intentionally avoid dynamic memory allocations + * and stores up to MAX_NUM_RESULTS results into a std::array. + */ +template class Benchmark { + public: + explicit Benchmark(const BenchmarkOptions &options = BenchmarkOptions()) + : options_(options){}; + + /* Run benchmark of the function f(). + * + * TODO(b/253099367): replace std::optional with StatusOr + */ + std::optional + run(const std::string_view benchmark_name, std::function f) + { + if (benchmark_name.empty()) { + ccprintf("%s: benchmark_name cannot be empty\n", + __func__); + return {}; + } + if (num_results_ >= MAX_NUM_RESULTS) { + ccprintf("%s: cannot store new BenchmarkResults\n", + __func__); + return {}; + } + + BenchmarkResult &result = results_[num_results_++]; + result.name = benchmark_name; + result.elapsed_time = 0; + + if (options_.use_fast_cpu) + clock_enable_module(MODULE_FAST_CPU, 1); + + bool valid_min_max = false; + for (int i = 0; i < options_.num_iterations; ++i) { + timestamp_t start_time = get_time(); + f(); + uint32_t iteration_time = time_since32(start_time); + + if (options_.reload_watchdog) + watchdog_reload(); + + if (valid_min_max) { + result.max_time = + MAX(result.max_time, iteration_time); + result.min_time = + MIN(result.min_time, iteration_time); + } else { + result.max_time = iteration_time; + result.min_time = iteration_time; + valid_min_max = true; + } + result.elapsed_time += iteration_time; + } + + if (options_.use_fast_cpu) + clock_enable_module(MODULE_FAST_CPU, 0); + + result.average_time = + (result.elapsed_time) / options_.num_iterations; + + return result; + } + + void print_results() + { + print_header(); + for (int i = 0; i < num_results_; ++i) + print_result(results_[i]); + } + + private: + const BenchmarkOptions options_; + std::array results_; + int num_results_ = 0; + + /* Print table header with column names */ + void print_header() + { + constexpr char kSeparator[] = "--------------------------"; + + ccprintf("%16s | %15s | %13s | %13s | %13s | %13s\n", + "Test Name", "Num Iterations", "Elapsed (us)", + "Min (us)", "Max (us)", "Avg (us)"); + ccprintf("%.*s | %.*s | %.*s | %.*s | %.*s | %.*s\n", 16, + kSeparator, 15, kSeparator, 13, kSeparator, 13, + kSeparator, 13, kSeparator, 13, kSeparator); + cflush(); + } + + /* Print a single benchmark result */ + int print_result(const BenchmarkResult &result) + { + ccprintf("%16s | %15u | %13u | %13u | %13u | %13u\n", + result.name.data(), options_.num_iterations, + result.elapsed_time, result.min_time, result.max_time, + result.average_time); + cflush(); + return EC_SUCCESS; + } +}; + +#endif /* __CROS_EC_BENCHMARK_H */ diff --git a/test/benchmark.cc b/test/benchmark.cc new file mode 100644 index 0000000000..e28bfbd999 --- /dev/null +++ b/test/benchmark.cc @@ -0,0 +1,98 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Simple test to validate the benchmark library. + */ + +#include "benchmark.h" + +extern "C" { +#include "test_util.h" +} + +/* Sample function for the benchmark */ +static void float_mult() +{ + float a = 1.1; + float b = 1.1; + int i; + + for (i = 0; i < 1000; ++i) + a *= b; +} + +test_static int test_valid_benchmark() +{ + Benchmark benchmark; + + auto result = benchmark.run("float_mult", float_mult); + TEST_ASSERT(result.has_value()); + + benchmark.print_results(); + return EC_SUCCESS; +} + +test_static int test_num_iterations() +{ + Benchmark benchmark({ .num_iterations = 5 }); + int num_calls = 0; + + auto result = benchmark.run("call_counter", [&] { ++num_calls; }); + TEST_ASSERT(result.has_value()); + TEST_EQ(num_calls, 5, "%d"); + + return EC_SUCCESS; +} + +test_static int test_empty_benchmark_name() +{ + Benchmark benchmark; + TEST_ASSERT(!benchmark.run("", [] {}).has_value()); + return EC_SUCCESS; +} + +test_static int test_too_many_runs() +{ + auto benchmark = Benchmark<3>(); + TEST_ASSERT(benchmark.run("call_1", [] {}).has_value()); + TEST_ASSERT(benchmark.run("call_2", [] {}).has_value()); + TEST_ASSERT(benchmark.run("call_3", [] {}).has_value()); + TEST_ASSERT(!benchmark.run("call_4", [] {}).has_value()); + + return EC_SUCCESS; +} + +test_static int test_min_max_time() +{ + // Run test 3 times with increasing delay of 1ms, 2ms, and 4ms + Benchmark benchmark({ .num_iterations = 3 }); + int delay_us = 1000; + + auto result = benchmark.run("delay", [&delay_us] { + udelay(delay_us); + delay_us *= 2; + }); + TEST_ASSERT(result.has_value()); + + auto min_time = result.value().min_time; + auto max_time = result.value().max_time; + + TEST_GE(min_time, 995U, "%u"); + TEST_LE(min_time, 1005U, "%u"); + TEST_GE(max_time, 3995U, "%u"); + TEST_LE(max_time, 4005U, "%u"); + + return EC_SUCCESS; +} + +void run_test(int argc, const char **argv) +{ + test_reset(); + RUN_TEST(test_valid_benchmark); + RUN_TEST(test_num_iterations); + RUN_TEST(test_too_many_runs); + RUN_TEST(test_empty_benchmark_name); + RUN_TEST(test_min_max_time); + test_print_result(); +} diff --git a/test/benchmark.tasklist b/test/benchmark.tasklist new file mode 100644 index 0000000000..6d43377af5 --- /dev/null +++ b/test/benchmark.tasklist @@ -0,0 +1,9 @@ +/* Copyright 2022 The ChromiumOS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * See CONFIG_TASK_LIST in config.h for details. + */ +#define CONFIG_TEST_TASK_LIST diff --git a/test/build.mk b/test/build.mk index 08e2d15c9f..a4f9ee74b8 100644 --- a/test/build.mk +++ b/test/build.mk @@ -24,6 +24,7 @@ test-list-host += aes test-list-host += always_memset test-list-host += base32 test-list-host += battery_get_params_smart +test-list-host += benchmark test-list-host += bklight_lid test-list-host += bklight_passthru test-list-host += body_detection @@ -169,6 +170,7 @@ aes-y=aes.o always_memset-y=always_memset.o base32-y=base32.o battery_get_params_smart-y=battery_get_params_smart.o +benchmark-y=benchmark.o bklight_lid-y=bklight_lid.o bklight_passthru-y=bklight_passthru.o body_detection-y=body_detection.o body_detection_data_literals.o motion_common.o diff --git a/test/run_device_tests.py b/test/run_device_tests.py index 4e0b0127e3..0aee1428f5 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -196,6 +196,7 @@ class AllTests: TestConfig(test_name="abort"), TestConfig(test_name="aes"), TestConfig(test_name="always_memset"), + TestConfig(test_name="benchmark"), TestConfig(test_name="cec"), TestConfig(test_name="cortexm_fpu"), TestConfig(test_name="crc"), -- cgit v1.2.1 From 8e7ebd6575a61fb969733a2416e3e76db37a0d06 Mon Sep 17 00:00:00 2001 From: Peter Chi Date: Tue, 1 Nov 2022 02:17:47 +0000 Subject: Revert "BB retimer: Set 'DP CONNECTION' bit only when mux_state gets HPD event" This reverts commit 4dfe7f2a385d9ad3ca10064b29e4acb0f68c30a3. Reason for revert: In VESA DisplayPortAltMode v2.0 chapter 3.9.2.2, the HPD will be sent after SBU isolation switches have been close to connect the AUX_CH. In this behavior, it will only enable AUX_CH when received HPD and cause type-c devices couldn't output display. So we need revert this CL to meet the VSEA DisplayPortAltMode spec. Original change's description: > BB retimer: Set 'DP CONNECTION' bit only when mux_state gets HPD event > > For some chromebooks design, there are expanssion card (typeC > to HDMI) communicate with TCPC through CC line, when the HDMI > card connect to chromebook the DP CONNECTION bit would be enable > even no connect HDMI moinitor. > > It will increase BBR power consumption, so set 'DP CONNECTION' > bit only when mux_state gets HPD event. > > BUG=b:233975818 > BRANCH=None > TEST=Test on Banshee, measure BBR power consumption reduce from > 143mW to 7mW. And the HDMI monitor can be output. > > Signed-off-by: johnwc_yeh > Change-Id: I8a80235992cfa1bac28f03c3b6a7ec378e07ecf3 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3726600 > Reviewed-by: Diana Z > Tested-by: Enzo Hong > Commit-Queue: Diana Z Bug: b:233975818, b:240896516 Change-Id: I48f2818d2eaee921bc0374976f6eddcdc152ac36 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995963 Reviewed-by: caveh jalali Commit-Queue: Peter Chi Tested-by: Peter Chi Code-Coverage: Zoss --- driver/retimer/bb_retimer.c | 24 ++++++++++-------------- zephyr/test/drivers/default/src/bb_retimer.c | 9 ++++++--- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c index f7a4ce6164..cb7c58c058 100644 --- a/driver/retimer/bb_retimer.c +++ b/driver/retimer/bb_retimer.c @@ -428,7 +428,14 @@ static int retimer_set_state(const struct usb_mux *me, mux_state_t mux_state, set_retimer_con |= BB_RETIMER_USB_3_SPEED; } + /* + * Bit 8: DP_CONNECTION + * 0 – No DP connection + * 1 – DP connected + */ if (mux_state & USB_PD_MUX_DP_ENABLED) { + set_retimer_con |= BB_RETIMER_DP_CONNECTION; + /* * Bit 11-10: DP_PIN_ASSIGNMENT (ignored if BIT8 = 0) * 00 – Pin assignments E/E’ @@ -545,26 +552,15 @@ void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t hpd_state, retimer_con_reg &= ~BB_RETIMER_IRQ_HPD; /* - * Bit 8: DP_CONNECTION - * 0 - No DP connection - * 1 - DP connected - * * Bit 15: HPD_LVL (ignored if BIT8 = 0) * 0 - HPD_State Low * 1 - HPD_State High - * - * HDMI card connect to chromebook the DP_CONNECTION bit - * would be enable. - * It will increase BBR power consumption, so enable the DP bit - * only when the HPD bit is set so that the retimer stays in - * low power mode until the external monitor is connected. */ + if (hpd_state & USB_PD_MUX_HPD_LVL) - retimer_con_reg |= - (BB_RETIMER_HPD_LVL | BB_RETIMER_DP_CONNECTION); + retimer_con_reg |= BB_RETIMER_HPD_LVL; else - retimer_con_reg &= - ~(BB_RETIMER_HPD_LVL | BB_RETIMER_DP_CONNECTION); + retimer_con_reg &= ~BB_RETIMER_HPD_LVL; /* Writing the register4 */ bb_retimer_write(me, BB_RETIMER_REG_CONNECTION_STATE, retimer_con_reg); diff --git a/zephyr/test/drivers/default/src/bb_retimer.c b/zephyr/test/drivers/default/src/bb_retimer.c index 5edd0a7cc8..5cfedc789e 100644 --- a/zephyr/test/drivers/default/src/bb_retimer.c +++ b/zephyr/test/drivers/default/src/bb_retimer.c @@ -162,7 +162,8 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_state) zassert_false(ack_required, "ACK is never required for BB retimer"); conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE); exp_conn = BB_RETIMER_USB_DATA_ROLE | - BB_RETIMER_DATA_CONNECTION_PRESENT; + BB_RETIMER_DATA_CONNECTION_PRESENT | + BB_RETIMER_DP_CONNECTION; zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx", exp_conn, conn); @@ -175,7 +176,8 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_state) zassert_false(ack_required, "ACK is never required for BB retimer"); conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE); exp_conn = BB_RETIMER_USB_DATA_ROLE | - BB_RETIMER_DATA_CONNECTION_PRESENT | BB_RETIMER_IRQ_HPD; + BB_RETIMER_DATA_CONNECTION_PRESENT | + BB_RETIMER_DP_CONNECTION | BB_RETIMER_IRQ_HPD; zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx", exp_conn, conn); @@ -188,7 +190,8 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_state) zassert_false(ack_required, "ACK is never required for BB retimer"); conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE); exp_conn = BB_RETIMER_USB_DATA_ROLE | - BB_RETIMER_DATA_CONNECTION_PRESENT | BB_RETIMER_HPD_LVL; + BB_RETIMER_DATA_CONNECTION_PRESENT | + BB_RETIMER_DP_CONNECTION | BB_RETIMER_HPD_LVL; zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx", exp_conn, conn); } -- cgit v1.2.1 From 8ea47c5e9f9f87bb78dafc3cbafa26838fbdb3bd Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Tue, 1 Nov 2022 09:42:50 -0600 Subject: test: dps console cmd with active charging port Add a test that runs the "dps" console command when there is an active charging port and weakly validate its contents. BRANCH=none BUG=none TEST=twister -i -s zephyr/test/drivers/drivers.default Signed-off-by: Aaron Massey Change-Id: Iff01bc621cf4472de77bc86322d48c8f9cbe45d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995817 Code-Coverage: Zoss Tested-by: Yuval Peress Reviewed-by: Yuval Peress Commit-Queue: Yuval Peress --- .../src/integration/usbc/usb_5v_3a_pd_source.c | 48 ++++++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c index a780277d05..c2b603e6ad 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ +#include #include #include #include @@ -24,6 +25,8 @@ #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) #define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) +#define TEST_PORT 0 + struct usb_attach_5v_3a_pd_source_fixture { struct tcpci_partner_data source_5v_3a; struct tcpci_src_emul_data src_ext; @@ -36,8 +39,8 @@ static void *usb_attach_5v_3a_pd_source_setup(void) static struct usb_attach_5v_3a_pd_source_fixture test_fixture; /* Get references for the emulators */ - test_fixture.tcpci_emul = EMUL_GET_USBC_BINDING(0, tcpc); - test_fixture.charger_emul = EMUL_GET_USBC_BINDING(0, chg); + test_fixture.tcpci_emul = EMUL_GET_USBC_BINDING(TEST_PORT, tcpc); + test_fixture.charger_emul = EMUL_GET_USBC_BINDING(TEST_PORT, chg); /* Initialized the charger to supply 5V and 3A */ tcpci_partner_init(&test_fixture.source_5v_3a, PD_REV20); @@ -90,7 +93,8 @@ ZTEST(usb_attach_5v_3a_pd_source, test_battery_is_charging) ZTEST(usb_attach_5v_3a_pd_source, test_charge_state) { - struct ec_response_charge_state state = host_cmd_charge_state(0); + struct ec_response_charge_state state = + host_cmd_charge_state(TEST_PORT); zassert_true(state.get_state.ac, "AC_OK not triggered"); zassert_true(state.get_state.chg_voltage > 0, @@ -161,7 +165,7 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_disconnect_charge_state) struct ec_response_charge_state charge_state; disconnect_source_from_port(fixture->tcpci_emul, fixture->charger_emul); - charge_state = host_cmd_charge_state(0); + charge_state = host_cmd_charge_state(TEST_PORT); zassert_false(charge_state.get_state.ac, "AC_OK not triggered"); zassert_equal(charge_state.get_state.chg_current, 0, @@ -321,3 +325,39 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_dps_enable) dps_enable(true); zassert_true(dps_is_enabled()); } + +ZTEST_F(usb_attach_5v_3a_pd_source, test_dps_info) +{ + const struct shell *shell_zephyr = get_ec_shell(); + + const char *outbuffer; + uint32_t buffer_size; + /* Arbitrary array size for sprintf should not need this amount */ + char format_buffer[100]; + + shell_backend_dummy_clear_output(shell_zephyr); + + /* Print current status to console */ + zassert_ok(shell_execute_cmd(shell_zephyr, "dps"), NULL); + outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size); + + /* Should include extra information about the charging port */ + /* Charging Port */ + sprintf(format_buffer, "C%d", TEST_PORT); + zassert_not_null(strstr(outbuffer, format_buffer)); + /* We are a sink to a 5v3a source, so check requested mv/ma */ + sprintf(format_buffer, "Requested: %dmV/%dmA", 5000, 3000); + zassert_not_null(strstr(outbuffer, format_buffer)); + /* + * Measured input power is shown (values vary so not asserting on + * numbers) + */ + zassert_not_null(strstr(outbuffer, "Measured:")); + /* Efficient Voltage - Value varies based on battery*/ + zassert_not_null(strstr(outbuffer, "Efficient:")); + /* Battery Design Voltage (varies based on battery) */ + zassert_not_null(strstr(outbuffer, "Batt:")); + /* PDMaxMV */ + sprintf(format_buffer, "PDMaxMV: %dmV", pd_get_max_voltage()); + zassert_not_null(strstr(outbuffer, format_buffer)); +} -- cgit v1.2.1 From e2c105b628245366a9e8d66a8639f9f2c0fd0044 Mon Sep 17 00:00:00 2001 From: jeffrey Date: Tue, 1 Nov 2022 14:07:08 +0800 Subject: tentacruel : Setup thermal Policy 1.Modify current limit condition. 2.Add EC control table EC control table procedure as listed below: Throttle point Release throttle Shutdown Charger 68 59 90 Ambient 56 42 80 BUG=b:256715957 TEST=Use ectool thermalget to check high and halt point. BRANCH=firmware-corsola-15194.B Signed-off-by: jeffrey Change-Id: I0665480955925a3d03e1a02174d4dce5cc29c742 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995967 Code-Coverage: Zoss Reviewed-by: Ting Shen --- zephyr/projects/corsola/adc_tentacruel.dts | 6 ++++++ zephyr/projects/corsola/src/krabby/temp_tentacruel.c | 4 ++-- zephyr/test/krabby/src/temp_tentacruel.c | 7 +++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/zephyr/projects/corsola/adc_tentacruel.dts b/zephyr/projects/corsola/adc_tentacruel.dts index 1b5e849589..7ab6f8817b 100644 --- a/zephyr/projects/corsola/adc_tentacruel.dts +++ b/zephyr/projects/corsola/adc_tentacruel.dts @@ -53,9 +53,15 @@ named-temp-sensors { compatible = "cros-ec,temp-sensors"; ambient { + temp_host_high = <56>; + temp_host_halt = <80>; + temp_host_release_high = <42>; sensor = <&temp_ambient>; }; temp_charger: charger { + temp_host_high = <68>; + temp_host_halt = <90>; + temp_host_release_high = <59>; sensor = <&charger>; }; }; diff --git a/zephyr/projects/corsola/src/krabby/temp_tentacruel.c b/zephyr/projects/corsola/src/krabby/temp_tentacruel.c index 59c5a989aa..5d2c304f76 100644 --- a/zephyr/projects/corsola/src/krabby/temp_tentacruel.c +++ b/zephyr/projects/corsola/src/krabby/temp_tentacruel.c @@ -15,7 +15,7 @@ #include "util.h" #define NUM_CURRENT_LEVELS ARRAY_SIZE(current_table) -#define TEMP_THRESHOLD 55 +#define TEMP_THRESHOLD 50 #define TEMP_BUFF_SIZE 60 #define KEEP_TIME 5 @@ -55,7 +55,7 @@ static uint16_t current_table[] = { 3600, 3000, 2400, - 1800, + 1600, }; /* Called by hook task every hook second (1 sec) */ diff --git a/zephyr/test/krabby/src/temp_tentacruel.c b/zephyr/test/krabby/src/temp_tentacruel.c index 660f6c4616..49d8a23ddf 100644 --- a/zephyr/test/krabby/src/temp_tentacruel.c +++ b/zephyr/test/krabby/src/temp_tentacruel.c @@ -21,7 +21,6 @@ #define ADC_DEVICE_NODE DT_NODELABEL(adc0) #define CHARGER_TEMP TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)) #define ORIGINAL_CURRENT 5000 -#define TEMP_THRESHOLD 55 struct charge_state_data curr; static int fake_voltage; @@ -34,7 +33,7 @@ static uint16_t current_table[] = { 3600, 3000, 2400, - 1800, + 1600, }; int setup_faketemp(int fake_voltage) @@ -57,7 +56,7 @@ static void ignore_first_minute(void) ZTEST(temp_tentacruel, test_decrease_current) { - fake_voltage = 376; + fake_voltage = 411; curr.batt.flags |= BATT_FLAG_RESPONSIVE; count = 0; @@ -81,7 +80,7 @@ ZTEST(temp_tentacruel, test_decrease_current) ZTEST(temp_tentacruel, test_increase_current) { - fake_voltage = 380; + fake_voltage = 446; curr.batt.flags |= BATT_FLAG_RESPONSIVE; count = 3; -- cgit v1.2.1 From 40fb838e0f56493c3b8999a14457f94bae7e06cb Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 1 Nov 2022 11:21:07 -0600 Subject: ec: Add missing words in gitlab doc There was an incomplete sentence. I finished it. BRANCH=None BUG=None TEST=None Signed-off-by: Jeremy Bettis Change-Id: I991b5248453baeb2e8a0540d59ba3056b19baafa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995819 Commit-Queue: Tomasz Michalec Tested-by: Jeremy Bettis Reviewed-by: Tomasz Michalec Auto-Submit: Jeremy Bettis --- docs/gitlab.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gitlab.md b/docs/gitlab.md index 9f8d07ceec..617c8a9154 100644 --- a/docs/gitlab.md +++ b/docs/gitlab.md @@ -45,7 +45,7 @@ sudo dpkg -i gitlab-runner_amd64.deb ### Running a Job Once Docker and the Gitlab Runner are installed, invoke it as follows. This -takes place outside of the +takes place outside of the chroot environment. ``` (outside) -- cgit v1.2.1 From e89aa6426ee7b4a969dd12c7ed32214cc5b28028 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 1 Nov 2022 14:09:00 -0700 Subject: Makefile.toolchain: Define _GNU_SOURCE when using clang g++ defines _GNU_SOURCE, but the baremetal clang++ toolchain we're using does not. When using libcxx + newlib, _GNU_SOURCE needs to be defined for compilation to succeed. BRANCH=none BUG=b:254916723 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes Change-Id: Ieda973980157ecc37c2aa1afcb35cbf62bfa3c51 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995333 Reviewed-by: Peter Marheine --- Makefile.toolchain | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.toolchain b/Makefile.toolchain index c2612d260c..30d0fe7418 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -207,6 +207,9 @@ else # TODO(https://issuetracker.google.com/234507656#comment19): C++ include path # should not be necessary. CXXFLAGS+=-I/usr/armv7m-cros-eabi/usr/include/c++/v1 +# TODO(https://issuetracker.google.com/254916723): Remove when toolchain is +# fixed. +CPPFLAGS+=-D_GNU_SOURCE endif ifeq ($(LIBFTDI_NAME),) -- cgit v1.2.1 From c9e23182da099df804396e16292b0339ebda8b32 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Tue, 1 Nov 2022 10:45:24 -0600 Subject: zephyr test: Verify drp_auto_toggle_next_state Verify that drp_auto_toggle_next_state returns a state appropriate to the CC voltages and current state. BUG=b:256182103 TEST=twister -s zephyr/test/drivers/drivers.usb_common BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I411c8f31379e5f7ae9a2899c3a4cb659bc328b3f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995815 Code-Coverage: Zoss Reviewed-by: Tomasz Michalec --- zephyr/test/drivers/usb_common/src/usb_common.c | 149 ++++++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c index e33751998f..c9b951fc49 100644 --- a/zephyr/test/drivers/usb_common/src/usb_common.c +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -3,11 +3,14 @@ * found in the LICENSE file. */ +#include +#include #include #include #include "ec_commands.h" #include "suite.h" +#include "timer.h" #include "usb_common.h" #include "usb_pd.h" @@ -146,3 +149,149 @@ ZTEST_USER(usb_common, test_board_is_dts_port) { zassert_true(board_is_dts_port(TEST_PORT)); } + +ZTEST_USER(usb_common, test_drp_auto_toggle_next_state_detached) +{ + uint64_t drp_sink_time = 0; + + /* If the port is detached and toggle is disabled, the next state should + * be the configured default state. + */ + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_OFF, + TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_DEFAULT); + + /* If toggle is frozen, the next state should be the current state. */ + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_FREEZE, + TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_UNATTACHED_SNK); + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_FREEZE, + TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_UNATTACHED_SRC); + + /* If role is forced, the next state should be the forced state. */ + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_FORCE_SINK, + TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_UNATTACHED_SNK); + zassert_equal(drp_auto_toggle_next_state(&drp_sink_time, PD_ROLE_SOURCE, + PD_DRP_FORCE_SOURCE, + TYPEC_CC_VOLT_OPEN, + TYPEC_CC_VOLT_OPEN, true), + DRP_TC_UNATTACHED_SRC); + + /* If toggle is enabled but auto-toggle is not supported, the next state + * should be based on the power role. If auto-toggle is supported, the + * next state should be auto-toggle. + */ + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, false), + DRP_TC_UNATTACHED_SNK); + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, false), + DRP_TC_UNATTACHED_SRC); + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_DRP_AUTO_TOGGLE); +} + +ZTEST_USER(usb_common, test_drp_auto_toggle_next_state_attached_to_source) +{ + uint64_t drp_sink_time = 0; + + /* If the CC lines show a source attached, then the next state should be + * a sink state. If auto-toggle is enabled, then the next state should + * assume that the TCPC is already in AttachWait.SNK. + */ + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN, false), + DRP_TC_UNATTACHED_SNK); + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RP_3_0, false), + DRP_TC_UNATTACHED_SNK); + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_ATTACHED_WAIT_SNK); + + /* If the DRP state is force-source, keep toggling. */ + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_FORCE_SOURCE, + TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN, false), + DRP_TC_UNATTACHED_SNK); + zassert_equal(drp_auto_toggle_next_state(&drp_sink_time, PD_ROLE_SOURCE, + PD_DRP_FORCE_SOURCE, + TYPEC_CC_VOLT_RP_3_0, + TYPEC_CC_VOLT_OPEN, false), + DRP_TC_UNATTACHED_SRC); + zassert_equal(drp_auto_toggle_next_state(&drp_sink_time, PD_ROLE_SOURCE, + PD_DRP_FORCE_SOURCE, + TYPEC_CC_VOLT_RP_3_0, + TYPEC_CC_VOLT_OPEN, true), + DRP_TC_DRP_AUTO_TOGGLE); +} + +ZTEST_USER(usb_common, test_drp_auto_toggle_next_state_attached_to_sink) +{ + uint64_t drp_sink_time = 0; + timestamp_t fake_time; + + /* If the CC lines show a sink, then the next state should be a source + * state. If auto-toggle is enabled, then the next state should assume + * that the TCPC is already in AttachWait.SRC. + */ + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, false), + DRP_TC_UNATTACHED_SRC); + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_RA, TYPEC_CC_VOLT_OPEN, false), + DRP_TC_UNATTACHED_SRC); + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON, + TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_ATTACHED_WAIT_SRC); + + /* If the DRP state is off or force-sink, the TCPC might be in + * auto-toggle anyway. If the CC lines have been in this state for less + * than 100 ms, the TCPM should stay in Unattached.SNK and wait for the + * partner to toggle. + */ + drp_sink_time = 0; + fake_time.val = drp_sink_time; + get_time_mock = &fake_time; + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_OFF, + TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_UNATTACHED_SNK); + /* After 100 ms, the next state should be auto-toggle. */ + drp_sink_time = 0; + fake_time.val = drp_sink_time + 105 * MSEC; + get_time_mock = &fake_time; + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_OFF, + TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_DRP_AUTO_TOGGLE); + /* After 200 ms, the next state should be Unattached.SNK, and + * drp_sink_time should be updated. + */ + drp_sink_time = 0; + fake_time.val = drp_sink_time + 205 * MSEC; + get_time_mock = &fake_time; + zassert_equal(drp_auto_toggle_next_state( + &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_OFF, + TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, true), + DRP_TC_UNATTACHED_SNK); + zassert_equal(drp_sink_time, fake_time.val); + + get_time_mock = NULL; +} -- cgit v1.2.1 From 41948753c41c3807aab97106e97a5df316349e3a Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 1 Nov 2022 22:48:45 -0600 Subject: test: verify battery_outside_charging_temperature() Allow this function to be externally linked so it can be accessed from outside the .c file (similar to other patterns that exist in our code base) and test the various code paths that lead to detecting if the battery can be charged based on the temperature. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I647ebaf117ef218451912f8fd8622b4deda82b74 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3998265 Reviewed-by: Simon Glass Code-Coverage: Zoss --- common/charge_state_v2.c | 2 +- zephyr/test/drivers/common_charger/CMakeLists.txt | 6 +- .../common_charger/src/test_charge_state_v2.c | 99 ++++++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 zephyr/test/drivers/common_charger/src/test_charge_state_v2.c diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 728606ef8a..54c49320c6 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1382,7 +1382,7 @@ struct charge_state_data *charge_get_status(void) } /* Determine if the battery is outside of allowable temperature range */ -static int battery_outside_charging_temperature(void) +int battery_outside_charging_temperature(void) { const struct battery_info *batt_info = battery_get_info(); int batt_temp_c = DECI_KELVIN_TO_CELSIUS(curr.batt.temperature); diff --git a/zephyr/test/drivers/common_charger/CMakeLists.txt b/zephyr/test/drivers/common_charger/CMakeLists.txt index aeb77d3577..58fc3229ef 100644 --- a/zephyr/test/drivers/common_charger/CMakeLists.txt +++ b/zephyr/test/drivers/common_charger/CMakeLists.txt @@ -3,4 +3,8 @@ # found in the LICENSE file. # Add source files -target_sources(app PRIVATE src/test_common_charger.c) +target_sources(app + PRIVATE + src/test_charge_state_v2.c + src/test_common_charger.c +) diff --git a/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c new file mode 100644 index 0000000000..c4c0838dc5 --- /dev/null +++ b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c @@ -0,0 +1,99 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charge_state_v2.h" +#include "math_util.h" +#include "test/drivers/test_state.h" + +int battery_outside_charging_temperature(void); + +struct charge_state_v2_fixture { + struct charge_state_data charge_state_data; +}; + +static void *setup(void) +{ + static struct charge_state_v2_fixture fixture; + + return &fixture; +} + +static void before(void *f) +{ + struct charge_state_v2_fixture *fixture = f; + + fixture->charge_state_data = *charge_get_status(); +} + +static void after(void *f) +{ + struct charge_state_v2_fixture *fixture = f; + + *charge_get_status() = fixture->charge_state_data; +} + +ZTEST_SUITE(charge_state_v2, drivers_predicate_post_main, setup, before, after, + NULL); + +ZTEST(charge_state_v2, test_battery_flag_bad_temperature) +{ + struct charge_state_data *curr = charge_get_status(); + + curr->batt.flags |= BATT_FLAG_BAD_TEMPERATURE; + zassert_ok(battery_outside_charging_temperature()); +} + +ZTEST(charge_state_v2, test_battery_temperature_range) +{ + struct charge_state_data *curr = charge_get_status(); + const struct battery_info *batt_info = battery_get_info(); + + curr->batt.flags &= ~BATT_FLAG_BAD_TEMPERATURE; + + /* Start off without a desired voltage/current */ + curr->batt.desired_voltage = 0; + curr->batt.desired_current = 0; + + /* Temperature is too high */ + curr->batt.temperature = + CELSIUS_TO_DECI_KELVIN(batt_info->start_charging_max_c + 1); + zassert_equal(1, battery_outside_charging_temperature()); + + /* Temperature is too low */ + curr->batt.temperature = + CELSIUS_TO_DECI_KELVIN(batt_info->start_charging_min_c - 1); + zassert_equal(1, battery_outside_charging_temperature()); + + /* Temperature is just right */ + curr->batt.temperature = + CELSIUS_TO_DECI_KELVIN((batt_info->start_charging_max_c + + batt_info->start_charging_min_c) / + 2); + zassert_ok(battery_outside_charging_temperature()); + + /* Set an arbitrary desired current */ + curr->batt.desired_current = 3; + + /* Temperature is too high */ + curr->batt.temperature = + CELSIUS_TO_DECI_KELVIN(batt_info->charging_max_c + 1); + zassert_equal(1, battery_outside_charging_temperature()); + + /* Set an arbitrary desired voltage */ + curr->batt.desired_voltage = 5; + + /* Temperature is too low */ + curr->batt.temperature = + CELSIUS_TO_DECI_KELVIN(batt_info->charging_min_c - 1); + zassert_equal(1, battery_outside_charging_temperature()); + + /* Temperature is just right */ + curr->batt.temperature = CELSIUS_TO_DECI_KELVIN( + (batt_info->charging_max_c + batt_info->charging_min_c) / 2); + zassert_ok(battery_outside_charging_temperature()); +} -- cgit v1.2.1 From adba8609c1a6817fe5a03378585729ee7ef6327d Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Tue, 1 Nov 2022 11:58:08 -0600 Subject: dps: Declare get_efficient_voltage() as static The get_efficient_voltage() function is only used locally to its source. Declare the function static. BRANCH=none BUG=none TEST=twister -i -s zephyr/test/drivers/drivers.default TEST=CQ LOW_COVERAGE_REASON=Zoss sometimes mismarks adding of static Signed-off-by: Aaron Massey Change-Id: I406e92d16c9d9e539d1891bad1e87a96a4d4db2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995818 Code-Coverage: Zoss Reviewed-by: Keith Short --- common/dps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/dps.c b/common/dps.c index c5a8ba4045..1950b5a9bd 100644 --- a/common/dps.c +++ b/common/dps.c @@ -231,7 +231,7 @@ static int get_battery_target_voltage(int *target_mv) * * @return 0 if error occurs, else battery efficient voltage in mV */ -int get_efficient_voltage(void) +static int get_efficient_voltage(void) { int eff_mv = 0; int batt_mv; -- cgit v1.2.1 From a4a9c56c556f46976f4db9d554a1a00ba9f7610e Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 1 Nov 2022 14:38:28 -0600 Subject: cq: Make sure build is clean Run a make clobber before make buildall_only just to be sure that the runner isn't reusing a dirty chroot. BRANCH=None BUG=b:256761895 TEST=CQ. Signed-off-by: Jeremy Bettis Change-Id: I2d8322ff7093b60dff0fac57c318b38cf9b29558 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995326 Auto-Submit: Jeremy Bettis Reviewed-by: Al Semjonovs Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Commit-Queue: Al Semjonovs Code-Coverage: Zoss --- firmware_builder.py | 5 +++++ zephyr/firmware_builder.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/firmware_builder.py b/firmware_builder.py index afd3d815c5..ff7f524d78 100755 --- a/firmware_builder.py +++ b/firmware_builder.py @@ -74,9 +74,14 @@ def build(opts): ec_dir = pathlib.Path(__file__).parent subprocess.run([ec_dir / "util" / "check_clang_format.py"], check=True) + cmd = ["make", "clobber"] + print(f"# Running {' '.join(cmd)}.") + subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) + cmd = ["make", "buildall_only", f"-j{opts.cpus}"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) + ec_dir = os.path.dirname(__file__) build_dir = os.path.join(ec_dir, "build") for build_target in sorted(os.listdir(build_dir)): diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index 30b4a1353e..5173313b58 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -78,6 +78,11 @@ def build(opts): stdin=subprocess.DEVNULL, ) + # Start with a clean build environment + cmd = ["make", "clobber"] + log_cmd(cmd) + subprocess.run(cmd, cwd=platform_ec, check=True, stdin=subprocess.DEVNULL) + cmd = ["zmake", "-D", "build", "-a"] if opts.code_coverage: cmd.append("--coverage") -- cgit v1.2.1 From 8f5ab72e645b6f09f507f1d325ccb5eafb208cd9 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Wed, 2 Nov 2022 14:18:54 -0600 Subject: zephyr: cleanup copyright headers The pre-submit check flags files that have a trailing period after the "ChromiumOS Authors" statement. Fix offending files. BUG=none BRANCH=none TEST=zmake build -a Signed-off-by: Keith Short Change-Id: I6be689df9f01da69d9efa9aab23270a3845d2d2a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000781 Code-Coverage: Zoss Commit-Queue: Wai-Hong Tam Reviewed-by: Wai-Hong Tam --- zephyr/include/emul/emul_kb_raw.h | 2 +- zephyr/shim/src/bb_retimer_usb_mux.c | 2 +- zephyr/shim/src/log_backend_console_buffer.c | 2 +- zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h | 2 +- zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c | 2 +- zephyr/test/drivers/keyboard_scan/src/mkbp_info.c | 2 +- zephyr/test/herobrine/CMakeLists.txt | 2 +- zephyr/test/herobrine/Kconfig | 2 +- zephyr/test/herobrine/boards/native_posix.overlay | 2 +- zephyr/test/herobrine/prj.conf | 2 +- zephyr/test/herobrine/src/board_chipset.c | 2 +- zephyr/test/herobrine/testcase.yaml | 2 +- zephyr/test/kingler/src/alt_sensor.c | 2 +- zephyr/test/rex/CMakeLists.txt | 2 +- zephyr/test/rex/boards/native_posix.overlay | 2 +- zephyr/test/rex/testcase.yaml | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/zephyr/include/emul/emul_kb_raw.h b/zephyr/include/emul/emul_kb_raw.h index 1660ccefd4..0598eda7ab 100644 --- a/zephyr/include/emul/emul_kb_raw.h +++ b/zephyr/include/emul/emul_kb_raw.h @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/bb_retimer_usb_mux.c b/zephyr/shim/src/bb_retimer_usb_mux.c index c40068211e..638a961ed1 100644 --- a/zephyr/shim/src/bb_retimer_usb_mux.c +++ b/zephyr/shim/src/bb_retimer_usb_mux.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/shim/src/log_backend_console_buffer.c b/zephyr/shim/src/log_backend_console_buffer.c index cafb690b87..ee6992f916 100644 --- a/zephyr/shim/src/log_backend_console_buffer.c +++ b/zephyr/shim/src/log_backend_console_buffer.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h b/zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h index 0117fea09c..c8b127ca70 100644 --- a/zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h +++ b/zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c index 7b49bd1df4..e20ece362b 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c index b0d64eb1da..0e2a476f12 100644 --- a/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c +++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/test/herobrine/CMakeLists.txt b/zephyr/test/herobrine/CMakeLists.txt index 8209eb77fb..800762ed8e 100644 --- a/zephyr/test/herobrine/CMakeLists.txt +++ b/zephyr/test/herobrine/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2022 The ChromiumOS Authors. +# Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/zephyr/test/herobrine/Kconfig b/zephyr/test/herobrine/Kconfig index 415e6e58af..8c3dc24727 100644 --- a/zephyr/test/herobrine/Kconfig +++ b/zephyr/test/herobrine/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2022 The ChromiumOS Authors. +# Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/zephyr/test/herobrine/boards/native_posix.overlay b/zephyr/test/herobrine/boards/native_posix.overlay index bfecc9a7d5..d2afb38db1 100644 --- a/zephyr/test/herobrine/boards/native_posix.overlay +++ b/zephyr/test/herobrine/boards/native_posix.overlay @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/test/herobrine/prj.conf b/zephyr/test/herobrine/prj.conf index 3334f11939..89165e36a8 100644 --- a/zephyr/test/herobrine/prj.conf +++ b/zephyr/test/herobrine/prj.conf @@ -1,4 +1,4 @@ -# Copyright 2022 The ChromiumOS Authors. +# Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/zephyr/test/herobrine/src/board_chipset.c b/zephyr/test/herobrine/src/board_chipset.c index 77bdb14e16..87a8414804 100644 --- a/zephyr/test/herobrine/src/board_chipset.c +++ b/zephyr/test/herobrine/src/board_chipset.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/test/herobrine/testcase.yaml b/zephyr/test/herobrine/testcase.yaml index e5f17a3848..1ccb56582f 100644 --- a/zephyr/test/herobrine/testcase.yaml +++ b/zephyr/test/herobrine/testcase.yaml @@ -1,4 +1,4 @@ -# Copyright 2022 The ChromiumOS Authors. +# Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/zephyr/test/kingler/src/alt_sensor.c b/zephyr/test/kingler/src/alt_sensor.c index fa00a5e874..88c8e0dfb3 100644 --- a/zephyr/test/kingler/src/alt_sensor.c +++ b/zephyr/test/kingler/src/alt_sensor.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/test/rex/CMakeLists.txt b/zephyr/test/rex/CMakeLists.txt index 3bca2df494..89d646a747 100644 --- a/zephyr/test/rex/CMakeLists.txt +++ b/zephyr/test/rex/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2022 The ChromiumOS Authors. +# Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/zephyr/test/rex/boards/native_posix.overlay b/zephyr/test/rex/boards/native_posix.overlay index b27b199a12..c4d4413ad7 100644 --- a/zephyr/test/rex/boards/native_posix.overlay +++ b/zephyr/test/rex/boards/native_posix.overlay @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/test/rex/testcase.yaml b/zephyr/test/rex/testcase.yaml index a05855ea52..54e6f6cb55 100644 --- a/zephyr/test/rex/testcase.yaml +++ b/zephyr/test/rex/testcase.yaml @@ -1,4 +1,4 @@ -# Copyright 2022 The ChromiumOS Authors. +# Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -- cgit v1.2.1 From 75f77820cffd3d11143d308ceaf5f61132ae22a5 Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Wed, 2 Nov 2022 10:14:57 +0800 Subject: corsola: fix typec port count When HDMI DB connected, the port count will be the CONFIG_USB_PD_PORT_MAX_COUNT - 1. However, we didn't correct the count in board_get_usb_pd_port_count() due to we used the extra port to emulate USB virtual mux for DP functionality. The incorrect port count will generate i2c errors when we try to disable PPC function at C1 port when we start to sink from C0. This CL fixes the incorrect accessing. BUG=None TEST=No C1 port error messages in the console when charging BRANCH=corsola Change-Id: I86df09fe48594ed77881e56d40e9795442f9bd93 Signed-off-by: Eric Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3996815 Tested-by: Eric Yilun Lin Auto-Submit: Eric Yilun Lin Commit-Queue: Eric Yilun Lin Code-Coverage: Sung-Chi Li Code-Coverage: Eric Yilun Lin Reviewed-by: Ting Shen --- zephyr/projects/corsola/include/variant_db_detection.h | 4 ++++ zephyr/projects/corsola/src/kingler/usbc_config.c | 7 ++++--- zephyr/projects/corsola/src/krabby/usbc_config.c | 10 +++++++--- zephyr/projects/corsola/src/usbc_config.c | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/zephyr/projects/corsola/include/variant_db_detection.h b/zephyr/projects/corsola/include/variant_db_detection.h index 285ff327f2..e98ba3067d 100644 --- a/zephyr/projects/corsola/include/variant_db_detection.h +++ b/zephyr/projects/corsola/include/variant_db_detection.h @@ -30,4 +30,8 @@ inline enum corsola_db_type corsola_get_db_type(void) }; #endif /* CONFIG_VARIANT_CORSOLA_DB_DETECTION */ +/* return the adjusted port count for board overridden usbc/charger functions. + */ +uint8_t board_get_adjusted_usb_pd_port_count(void); + #endif /* __CROS_EC_CORSOLA_DB_DETECTION_H */ diff --git a/zephyr/projects/corsola/src/kingler/usbc_config.c b/zephyr/projects/corsola/src/kingler/usbc_config.c index 8c0ca86454..7531904c4a 100644 --- a/zephyr/projects/corsola/src/kingler/usbc_config.c +++ b/zephyr/projects/corsola/src/kingler/usbc_config.c @@ -174,7 +174,8 @@ int board_set_active_charge_port(int port) { int i; bool is_valid_port = - (port >= 0 && port < board_get_usb_pd_port_count()); + (port >= 0 && port < board_get_adjusted_usb_pd_port_count()); + /* adjust the actual port count when not the type-c db connected. */ if (!is_valid_port && port != CHARGE_PORT_NONE) { return EC_ERROR_INVAL; @@ -184,7 +185,7 @@ int board_set_active_charge_port(int port) CPRINTS("Disabling all charger ports"); /* Disable all ports. */ - for (i = 0; i < board_get_usb_pd_port_count(); i++) { + for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { /* * Do not return early if one fails otherwise we can * get into a boot loop assertion failure. @@ -209,7 +210,7 @@ int board_set_active_charge_port(int port) * Turn off the other ports' sink path FETs, before enabling the * requested charge port. */ - for (i = 0; i < board_get_usb_pd_port_count(); i++) { + for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { if (i == port) { continue; } diff --git a/zephyr/projects/corsola/src/krabby/usbc_config.c b/zephyr/projects/corsola/src/krabby/usbc_config.c index 7a7f710804..8e03e8dbad 100644 --- a/zephyr/projects/corsola/src/krabby/usbc_config.c +++ b/zephyr/projects/corsola/src/krabby/usbc_config.c @@ -15,6 +15,8 @@ #include "usb_pd.h" #include "usbc_ppc.h" +#include "variant_db_detection.h" + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) @@ -71,7 +73,9 @@ void board_reset_pd_mcu(void) int board_set_active_charge_port(int port) { int i; - int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count()); + int is_valid_port = + (port >= 0 && port < board_get_adjusted_usb_pd_port_count()); + /* adjust the actual port count when not the type-c db connected. */ if (!is_valid_port && port != CHARGE_PORT_NONE) { return EC_ERROR_INVAL; @@ -81,7 +85,7 @@ int board_set_active_charge_port(int port) CPRINTS("Disabling all charger ports"); /* Disable all ports. */ - for (i = 0; i < ppc_cnt; i++) { + for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { /* * Do not return early if one fails otherwise we can * get into a boot loop assertion failure. @@ -106,7 +110,7 @@ int board_set_active_charge_port(int port) * Turn off the other ports' sink path FETs, before enabling the * requested charge port. */ - for (i = 0; i < ppc_cnt; i++) { + for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { if (i == port) { continue; } diff --git a/zephyr/projects/corsola/src/usbc_config.c b/zephyr/projects/corsola/src/usbc_config.c index b9a1524fb6..8bc03991ee 100644 --- a/zephyr/projects/corsola/src/usbc_config.c +++ b/zephyr/projects/corsola/src/usbc_config.c @@ -59,6 +59,11 @@ DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_PRE_DEFAULT); __override uint8_t board_get_usb_pd_port_count(void) { + /* This function returns the PORT_COUNT+1 when HDMI db is connected. + * This is a trick to ensure the usb_mux_set being set properley. + * HDMI display functions using the USB virtual mux to * communicate + * with the DP bridge. + */ if (corsola_get_db_type() == CORSOLA_DB_HDMI) { if (tasks_inited) { return CONFIG_USB_PD_PORT_MAX_COUNT; @@ -72,6 +77,15 @@ __override uint8_t board_get_usb_pd_port_count(void) return CONFIG_USB_PD_PORT_MAX_COUNT; } +uint8_t board_get_adjusted_usb_pd_port_count(void) +{ + if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { + return CONFIG_USB_PD_PORT_MAX_COUNT; + } else { + return CONFIG_USB_PD_PORT_MAX_COUNT - 1; + } +} + /* USB-A */ void usb_a0_interrupt(enum gpio_signal signal) { -- cgit v1.2.1 From d8719f53c8b9f02ed1f4f401f93c6ac526f82a03 Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Wed, 2 Nov 2022 16:55:28 +0800 Subject: corsola: update board_set_charge_limit After https://crrev.com/c/3905352 merged, we enforce 2.5W sink power while VBUS Transition in PD communication. The previous board_set_charge_limit will raise the current_limit to CONFIG_CHARGER_INPUT_CURRENT_LIMIT (512 on corsola), and thus we can't meet the PSNKSTDBY 2.5W. This CL drop the MAX() to ensure the requirement is met. BUG=b:255908917 TEST=input current is not altered to 512mA when VBusTransition BRANCH=corsola Change-Id: I626374d2172958db2d925a8004bf958b94a194d7 Signed-off-by: Eric Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995635 Commit-Queue: Eric Yilun Lin Code-Coverage: Sung-Chi Li Reviewed-by: Ting Shen Code-Coverage: Eric Yilun Lin Tested-by: Eric Yilun Lin --- zephyr/projects/corsola/src/usbc_config.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zephyr/projects/corsola/src/usbc_config.c b/zephyr/projects/corsola/src/usbc_config.c index 8bc03991ee..838f676694 100644 --- a/zephyr/projects/corsola/src/usbc_config.c +++ b/zephyr/projects/corsola/src/usbc_config.c @@ -126,11 +126,10 @@ __override enum pd_dual_role_states pd_get_drp_state_in_s0(void) } } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) -- cgit v1.2.1 From e828dd4e2bb9b7cfb2814c82e605e2f047ba60d4 Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Thu, 3 Nov 2022 11:39:55 +0800 Subject: corsola: add corsola-relevant-paths.txt Send the first path files for maintaining corsola firmware branch. BUG=none TEST=util/update_release_branch.py --relevant_paths_file util/corsola- relevant-paths.txt firmware-corsola-15194.B-main BRANCH=corsola Change-Id: I17be3ca1286975b4a570a36b2391a241650274df Signed-off-by: Eric Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000345 Reviewed-by: Ting Shen Commit-Queue: Ting Shen Auto-Submit: Eric Yilun Lin Code-Coverage: Zoss Tested-by: Eric Yilun Lin --- util/corsola-relevant-paths.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 util/corsola-relevant-paths.txt diff --git a/util/corsola-relevant-paths.txt b/util/corsola-relevant-paths.txt new file mode 100644 index 0000000000..3bb8e4f5a7 --- /dev/null +++ b/util/corsola-relevant-paths.txt @@ -0,0 +1,32 @@ +# Here you can place files of interest to be included in the commit message for +# merge commits to cros/firmware-corsola-15194.B +common/charge_state_v2.c +common/dps.c +common/mkbp_* +common/usb_charger.c +common/usb_common.c +common/usbc/*_pd_* +common/usbc/dp_alt_mode.c +common/usbc/usb_pe_drp_sm.c +common/usbc/usb_prl_sm.c +common/usbc/usb_sm.c +common/usbc/usb_tc_drp_acc_trysrc_sm.c +driver/battery/smart.c +driver/bc12/pi3usb9201.* +driver/charger/isl923x.* +driver/charger/rt949* +driver/ppc/nx20p348x.* +driver/ppc/rt1718s.* +driver/ppc/syv682x.* +driver/tcpm/anx7447.* +driver/tcpm/rt1718s.* +driver/tcpm/tcpci.* +driver/usb_mux/it5205.* +driver/usb_mux/ps8743.* +power/mt8186.c +zephyr/boards/arm/npcx9/* +zephyr/boards/riscv/it8xxx2/* +zephyr/drivers/* +zephyr/projects/corsola/* +zephyr/projects/corsola/* +zephyr/shim/* -- cgit v1.2.1 From 6b9ec04933d47411d796e62a887dd424f5d1c724 Mon Sep 17 00:00:00 2001 From: wen zhang Date: Thu, 3 Nov 2022 15:28:22 +0800 Subject: corsola: reserve input current margin The adapter output current exceeds the spec of the adapter, such as 20V 3.25A adapter will output 3.273A when system is heavy-load. We add a margin 4% in case of charger overdraw. BUG=b:257167723 TEST=scope the output current BRANCH=corsola Change-Id: I6fba906d88a6de8efd2b5d09fead9ba5bd1ea796 Signed-off-by: wen zhang Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999463 Reviewed-by: Mike Lee Code-Coverage: Ting Shen Reviewed-by: Ting Shen --- zephyr/projects/corsola/src/usbc_config.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zephyr/projects/corsola/src/usbc_config.c b/zephyr/projects/corsola/src/usbc_config.c index 838f676694..b776bc1ca9 100644 --- a/zephyr/projects/corsola/src/usbc_config.c +++ b/zephyr/projects/corsola/src/usbc_config.c @@ -129,7 +129,12 @@ __override enum pd_dual_role_states pd_get_drp_state_in_s0(void) __override void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit(charge_ma, charge_mv); + int icl = charge_ma * 97 / 100; + /* + * b:257167723: Adapter output current exceeds the spec on heavy-load. + * Preserve a margin in case of charger overdraw. + */ + charge_set_input_current_limit(icl, charge_mv); } void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) -- cgit v1.2.1 From a08bcc0f4329c177b7dfbcdfd974f107b14b4ab2 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Wed, 2 Nov 2022 14:53:51 -0600 Subject: zephyr test: Verify port suspend at low battery Verify that suspending a Type-C port for a firmware update will fail when the battery is very low. BUG=b:256182103 TEST=twister -s zephyr/test/drivers/drivers.host_cmd BRANCH=none Signed-off-by: Abe Levkoy Change-Id: Ifa21894aa34626e70dd8c6f6ad97ebf90206d241 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000780 Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- zephyr/test/drivers/host_cmd/src/pd_control.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zephyr/test/drivers/host_cmd/src/pd_control.c b/zephyr/test/drivers/host_cmd/src/pd_control.c index 5fdd424db9..97624fdb34 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_control.c +++ b/zephyr/test/drivers/host_cmd/src/pd_control.c @@ -93,6 +93,20 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_resume) zassert_true(pd_is_port_enabled(TEST_PORT), "Port failed to resume"); } +ZTEST_USER(host_cmd_pd_control, test_suspend_low_battery) +{ + struct ec_params_pd_control params = { .chip = TEST_PORT, + .subcmd = PD_SUSPEND }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params); + + /* Suspending the port for firmware update should fail at critical low + * battery. + */ + test_set_battery_level(1); + zassert_equal(host_command_process(&args), EC_RES_BUSY); +} + ZTEST_USER(host_cmd_pd_control, test_control_disable) { struct ec_params_pd_control params = { .chip = TEST_PORT, -- cgit v1.2.1 From 339879506fdc0d515c27e4dc4d2fe776f30de4e2 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Wed, 2 Nov 2022 15:23:08 -0600 Subject: zephyr test: usbc_ocp: Log during tests Log errors from over-current functions during tests. BUG=none TEST=twister -s zephyr/test/drivers/drivers.usbc_ocp BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I213b54866c7e31bb05264eb08419219af09c09d2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000783 Code-Coverage: Zoss Reviewed-by: Jeremy Bettis --- common/usbc_ocp.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/common/usbc_ocp.c b/common/usbc_ocp.c index ba975b6105..406deb2b20 100644 --- a/common/usbc_ocp.c +++ b/common/usbc_ocp.c @@ -15,13 +15,8 @@ #include "usbc_ocp.h" #include "util.h" -#ifndef TEST_BUILD #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) -#else -#define CPRINTF(args...) -#define CPRINTS(args...) -#endif /* * Number of seconds until a latched-off port is re-enabled for sourcing after -- cgit v1.2.1 From 290a6ce0d426f6477c94e6cb4c125694782370f6 Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Tue, 4 Oct 2022 16:15:59 -0700 Subject: tcpmv2: dpm: Convert dpm_run to a 1st class SM framework This CL adds a type-c state machine framework for the Device Policy Manager (dpm) layer of USB-PD. This CL is focused just on adding the state machine policy and minimizing any changes in the existing DPM support functions. Because the DPM is no longer being called directly from the PE layer, an interlock mechanism is used to control when the DPM state machine will take any actions. This CL also renames include/usb_pd_dpm.h to include/usb_pd_dpm_sm.h to be consistent with include file naming for the other TCPMv2 layer state machine include files. BUG=b:194504052 BRANCH=none TEST=Verified that mode entry/exit is successful for DP, TBT, and USB4 on Voxel. ectool typeccontrol 0 -> exit mode ectool typeccontrol 2 0 -> DP ectool typeccontrol 2 1 -> TBT ectool typeccontrol 2 2 -> USB4 Signed-off-by: Scott Collyer Change-Id: I196d342b031b96874d354610182be79eac613d00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3922467 Reviewed-by: Abe Levkoy Tested-by: Scott Collyer Code-Coverage: Zoss Commit-Queue: Scott Collyer --- board/chocodile_vpdmcu/board.h | 1 + common/charge_manager.c | 2 +- common/mock/usb_pd_dpm_mock.c | 6 +- common/usb_common.c | 2 +- common/usbc/usb_mode.c | 2 +- common/usbc/usb_pd_console.c | 2 +- common/usbc/usb_pd_dpm.c | 164 +++++++++++++++-- common/usbc/usb_pd_host.c | 2 +- common/usbc/usb_pe_drp_sm.c | 24 ++- common/usbc/usb_tc_drp_acc_trysrc_sm.c | 2 +- common/usbc/usbc_task.c | 5 + include/config.h | 2 + include/mock/usb_pd_dpm_mock.h | 2 +- include/usb_dp_alt_mode.h | 2 +- include/usb_pd_dpm.h | 186 ------------------- include/usb_pd_dpm_sm.h | 196 +++++++++++++++++++++ include/usb_tbt_alt_mode.h | 2 +- test/fake_usbc.c | 6 +- test/test_config.h | 4 + zephyr/Kconfig.pd | 9 + zephyr/shim/include/config_chip.h | 5 + .../default/src/console_cmd/usb_pd_console.c | 2 +- 22 files changed, 406 insertions(+), 222 deletions(-) delete mode 100644 include/usb_pd_dpm.h create mode 100644 include/usb_pd_dpm_sm.h diff --git a/board/chocodile_vpdmcu/board.h b/board/chocodile_vpdmcu/board.h index ede07dd9a0..596407628e 100644 --- a/board/chocodile_vpdmcu/board.h +++ b/board/chocodile_vpdmcu/board.h @@ -72,6 +72,7 @@ #define CONFIG_USB_PD_DECODE_SOP #define CONFIG_USB_PD_DUAL_ROLE #define CONFIG_USB_PD_INTERNAL_COMP +#undef CONFIG_USB_DPM_SM #define CONFIG_VBOOT_HASH #define CONFIG_WATCHDOG #undef CONFIG_WATCHDOG_HELP diff --git a/common/charge_manager.c b/common/charge_manager.c index 3e8b937e53..b28a186ef8 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -23,7 +23,7 @@ #include "typec_control.h" #include "usb_common.h" #include "usb_pd.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_tcpm.h" #include "util.h" diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c index 158c53c650..03c18f37a1 100644 --- a/common/mock/usb_pd_dpm_mock.c +++ b/common/mock/usb_pd_dpm_mock.c @@ -49,7 +49,7 @@ void dpm_set_mode_exit_request(int port) { } -void dpm_run(int port) +void dpm_run(int port, int evt, int en) { } @@ -95,3 +95,7 @@ int dpm_get_status_msg(int port, uint8_t *msg, uint32_t *len) void dpm_handle_alert(int port, uint32_t ado) { } + +void dpm_set_pe_ready(int port, bool enable) +{ +} diff --git a/common/usb_common.c b/common/usb_common.c index edede7c303..2ef12e9412 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -27,7 +27,7 @@ #include "usb_common.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_flags.h" #include "usb_pd_tcpm.h" #include "usb_pe_sm.h" diff --git a/common/usbc/usb_mode.c b/common/usbc/usb_mode.c index 8f4824e4e9..f9b50c8fae 100644 --- a/common/usbc/usb_mode.c +++ b/common/usbc/usb_mode.c @@ -19,7 +19,7 @@ #include "usb_mode.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_tcpm.h" #include "usb_pe_sm.h" #include "usb_tbt_alt_mode.h" diff --git a/common/usbc/usb_pd_console.c b/common/usbc/usb_pd_console.c index 89a5492ad5..c7eb215572 100644 --- a/common/usbc/usb_pd_console.c +++ b/common/usbc/usb_pd_console.c @@ -6,7 +6,7 @@ #include "common.h" #include "console.h" #include "usb_common.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_timer.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index daccc2ba2a..e9963811fc 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -25,11 +25,12 @@ #include "usb_mode.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd_dpm.h" #include "usb_pd_pdo.h" #include "usb_pd_tcpm.h" #include "usb_pd_timer.h" #include "usb_pe_sm.h" +#include "usb_pd_dpm_sm.h" +#include "usb_tc_sm.h" #include "usb_tbt_alt_mode.h" #ifdef CONFIG_ZEPHYR @@ -48,6 +49,8 @@ #define DPM_ATTENION_MAX_VDO 2 static struct { + /* state machine context */ + struct sm_ctx ctx; atomic_t flags; uint32_t vdm_req[VDO_MAX_SIZE]; int vdm_req_cnt; @@ -73,6 +76,44 @@ static struct { #define DPM_FLAG_DATA_RESET_DONE BIT(7) #define DPM_FLAG_PD_BUTTON_PRESSED BIT(8) #define DPM_FLAG_PD_BUTTON_RELEASED BIT(9) +#define DPM_FLAG_PE_READY BIT(10) + +/* List of all Device Policy Manager level states */ +enum usb_dpm_state { + /* Normal States */ + DPM_WAITING, + DPM_READY, +}; + +/* Forward declare the full list of states. This is indexed by usb_pd_state */ +static const struct usb_state dpm_states[]; + +/* List of human readable state names for console debugging */ +__maybe_unused static __const_data const char *const dpm_state_names[] = { + /* Normal States */ + [DPM_WAITING] = "DPM Waiting", + [DPM_READY] = "DPM Ready", +}; + +static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT]; + +/* Set the DPM state machine to a new state. */ +static void set_state_dpm(const int port, const enum usb_dpm_state new_state) +{ + set_state(port, &dpm[port].ctx, &dpm_states[new_state]); +} + +/* Get the current TypeC state. */ +__maybe_unused test_export_static enum usb_dpm_state +get_state_dpm(const int port) +{ + return dpm[port].ctx.current - &dpm_states[0]; +} + +static void print_current_state(const int port) +{ + CPRINTS("C%d: %s", port, dpm_state_names[get_state_dpm(port)]); +} #ifdef CONFIG_ZEPHYR static int init_vdm_req_mutex(const struct device *dev) @@ -180,6 +221,9 @@ void dpm_init(int port) { dpm[port].flags = 0; dpm[port].pd_button_state = DPM_PD_BUTTON_IDLE; + + /* Ensure that DPM state machine gets reset */ + set_state_dpm(port, DPM_WAITING); } void dpm_mode_exit_complete(int port) @@ -208,6 +252,18 @@ void dpm_data_reset_complete(int port) DPM_CLR_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE); } +void dpm_set_pe_ready(int port, bool enable) +{ + /* + * DPM should remain DPM_WAITING state until the PE is in its ready + * state and is able to accept requests from the DPM layer. + */ + if (enable) + DPM_SET_FLAG(port, DPM_FLAG_PE_READY); + else + DPM_CLR_FLAG(port, DPM_FLAG_PE_READY); +} + static void dpm_clear_mode_exit_request(int port) { DPM_CLR_FLAG(port, DPM_FLAG_EXIT_REQUEST); @@ -640,24 +696,6 @@ static void dpm_run_pd_button_sm(int port) DPM_CLR_FLAG(port, DPM_FLAG_PD_BUTTON_RELEASED); } -void dpm_run(int port) -{ - if (pd_get_data_role(port) == PD_ROLE_DFP) { - /* Run DFP related DPM requests */ - if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST)) - dpm_attempt_mode_exit(port); - else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) - dpm_attempt_mode_entry(port); - - /* Run USB PD Power button state machine */ - dpm_run_pd_button_sm(port); - } - - /* Run any VDM REQ messages */ - if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ)) - dpm_send_req_vdm(port); -} - /* * Source-out policy variables and APIs * @@ -1199,3 +1237,91 @@ uint8_t pd_get_bist_share_mode(void) { return bist_shared_mode_enabled; } + +void dpm_run(int port, int evt, int en) +{ + switch (local_state[port]) { + case SM_PAUSED: + if (!en) + break; + __fallthrough; + case SM_INIT: + dpm_init(port); + local_state[port] = SM_RUN; + __fallthrough; + case SM_RUN: + if (!en) { + local_state[port] = SM_PAUSED; + /* + * While we are paused, exit all states and wait until + * initialized again. + */ + set_state(port, &dpm[port].ctx, NULL); + break; + } + + /* Run state machine */ + run_state(port, &dpm[port].ctx); + + break; + } +} + +/* + * DPM_WAITING + */ +static void dpm_waiting_entry(const int port) +{ + DPM_CLR_FLAG(port, DPM_FLAG_PE_READY); + print_current_state(port); +} + +static void dpm_waiting_run(const int port) +{ + if (DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) { + set_state_dpm(port, DPM_READY); + } +} + +/* + * DPM_READY + */ +static void dpm_ready_entry(const int port) +{ + print_current_state(port); +} + +static void dpm_ready_run(const int port) +{ + if (!DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) { + set_state_dpm(port, DPM_WAITING); + return; + } + + if (pd_get_data_role(port) == PD_ROLE_DFP) { + /* Run DFP related DPM requests */ + if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST)) + dpm_attempt_mode_exit(port); + else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) + dpm_attempt_mode_entry(port); + + /* Run USB PD Power button state machine */ + dpm_run_pd_button_sm(port); + } + + /* Run any VDM REQ messages */ + if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ)) + dpm_send_req_vdm(port); +} + +static __const_data const struct usb_state dpm_states[] = { + /* Normal States */ + [DPM_WAITING] = { + .entry = dpm_waiting_entry, + .run = dpm_waiting_run, + }, + [DPM_READY] = { + .entry = dpm_ready_entry, + .run = dpm_ready_run, + }, +}; diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c index 502abc374a..93a8e573a0 100644 --- a/common/usbc/usb_pd_host.c +++ b/common/usbc/usb_pd_host.c @@ -12,7 +12,7 @@ #include "host_command.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_tcpm.h" #include "util.h" diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index f6cd95463f..c6a61f1bd9 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -27,7 +27,7 @@ #include "usb_dp_alt_mode.h" #include "usb_mode.h" #include "usb_mux.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_policy.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" @@ -2927,11 +2927,17 @@ static void pe_src_ready_run(int port) if (pe_attempt_port_discovery(port)) return; - /* No DPM requests; attempt mode entry/exit if needed */ - dpm_run(port); + /* Inform DPM state machine that PE is set for messages */ + dpm_set_pe_ready(port, true); } } +static void pe_src_ready_exit(int port) +{ + /* Inform DPM state machine that PE is in ready state */ + dpm_set_pe_ready(port, false); +} + /** * PE_SRC_Disabled */ @@ -3803,11 +3809,17 @@ static void pe_snk_ready_run(int port) if (pe_attempt_port_discovery(port)) return; - /* No DPM requests; attempt mode entry/exit if needed */ - dpm_run(port); + /* Inform DPM state machine that PE is set for messages */ + dpm_set_pe_ready(port, true); } } +static void pe_snk_ready_exit(int port) +{ + /* Inform DPM state machine that PE is in ready state */ + dpm_set_pe_ready(port, false); +} + /** * PE_SNK_Hard_Reset */ @@ -7902,6 +7914,7 @@ static __const_data const struct usb_state pe_states[] = { [PE_SRC_READY] = { .entry = pe_src_ready_entry, .run = pe_src_ready_run, + .exit = pe_src_ready_exit, }, [PE_SRC_DISABLED] = { .entry = pe_src_disabled_entry, @@ -7948,6 +7961,7 @@ static __const_data const struct usb_state pe_states[] = { [PE_SNK_READY] = { .entry = pe_snk_ready_entry, .run = pe_snk_ready_run, + .exit = pe_snk_ready_exit, }, [PE_SNK_HARD_RESET] = { .entry = pe_snk_hard_reset_entry, diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index ae84574b40..47369a75d1 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -17,7 +17,7 @@ #include "usb_common.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_tcpm.h" #include "usb_pd_timer.h" #include "usb_pe_sm.h" diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c index 6384aae879..ae5b401283 100644 --- a/common/usbc/usbc_task.c +++ b/common/usbc/usbc_task.c @@ -27,6 +27,7 @@ #include "usb_pd_timer.h" #include "usb_prl_sm.h" #include "tcpm/tcpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" #include "usb_sm.h" @@ -141,6 +142,10 @@ static bool pd_task_loop(int port) if (IS_ENABLED(CONFIG_USB_PD_TCPC)) tcpc_run(port, evt); + /* Run Device Policy Manager */ + if (IS_ENABLED(CONFIG_USB_DPM_SM)) + dpm_run(port, evt, tc_get_pd_enabled(port)); + /* Run policy engine state machine */ if (IS_ENABLED(CONFIG_USB_PE_SM)) pe_run(port, evt, tc_get_pd_enabled(port)); diff --git a/include/config.h b/include/config.h index f0b528bead..a0ce35e62c 100644 --- a/include/config.h +++ b/include/config.h @@ -4474,10 +4474,12 @@ * TYPEC_SM - Type-C deals with CC lines voltage level connections * PRL_SM - Protocol handles flow and chunking TX and RX messages * PE - Policy Engine handles PD communication flow + * DPM - Device Policy Manager layer is used to determine port policy */ #define CONFIG_USB_TYPEC_SM #define CONFIG_USB_PRL_SM #define CONFIG_USB_PE_SM +#define CONFIG_USB_DPM_SM /* Enables PD Console commands */ #define CONFIG_USB_PD_CONSOLE_CMD diff --git a/include/mock/usb_pd_dpm_mock.h b/include/mock/usb_pd_dpm_mock.h index 8f91cfb390..266cad4aef 100644 --- a/include/mock/usb_pd_dpm_mock.h +++ b/include/mock/usb_pd_dpm_mock.h @@ -8,7 +8,7 @@ #define __MOCK_USB_PD_DPM_MOCK_H #include "common.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" /* Defaults should all be 0 values. */ struct mock_dpm_port_t { diff --git a/include/usb_dp_alt_mode.h b/include/usb_dp_alt_mode.h index 83dc35b085..1449b96313 100644 --- a/include/usb_dp_alt_mode.h +++ b/include/usb_dp_alt_mode.h @@ -15,7 +15,7 @@ #include #include "tcpm/tcpm.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" /* * Initialize DP state for the specified port. diff --git a/include/usb_pd_dpm.h b/include/usb_pd_dpm.h deleted file mode 100644 index c74357d588..0000000000 --- a/include/usb_pd_dpm.h +++ /dev/null @@ -1,186 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * Device Policy Manager implementation - * Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3 - */ - -#ifndef __CROS_EC_USB_DPM_H -#define __CROS_EC_USB_DPM_H - -#include "ec_commands.h" -#include "usb_pd_tcpm.h" - -/* - * Initializes DPM state for a port. - * - * @param port USB-C port number - */ -void dpm_init(int port); - -/* - * Informs the DPM that a mode exit is complete. - * - * @param port USB-C port number - */ -void dpm_mode_exit_complete(int port); - -/* - * Informs the DPM that Exit Mode request is received - * - * @param port USB-C port number - */ -void dpm_set_mode_exit_request(int port); - -/* Informs the DPM that the PE has performed a Data Reset (or at least - * determined that the port partner doesn't support one). - * - * @param port USB-C port number - */ -void dpm_data_reset_complete(int port); - -/* - * Informs the DPM that a VDM ACK was received. - * - * @param port USB-C port number - * @param type Transmit type (SOP, SOP') for received ACK - * @param vdo_count The number of VDOs in vdm; must be at least 1 - * @param vdm The VDM payload of the ACK - */ -void dpm_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count, - uint32_t *vdm); - -/* - * Informs the DPM that a VDM NAK was received. Also applies when a VDM request - * received a Not Supported response or timed out waiting for a response. - * - * @param port USB-C port number - * @param type Transmit type (SOP, SOP') for request - * @param svid The SVID of the request - * @param vdm_cmd The VDM command of the request - */ -void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid, - uint8_t vdm_cmd); - -/* - * Drives the Policy Engine through entry/exit mode process - * - * @param port USB-C port number - */ -void dpm_run(int port); - -/* - * Determines the current allocation for the connection, past the basic - * CONFIG_USB_PD_PULLUP value set by the TC (generally 1.5 A) - * - * @param port USB-C port number - * @param vsafe5v_pdo Copy of first Sink_Capability PDO, which should - * represent the vSafe5V fixed PDO - */ -void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo); - -/* - * Registers port as a non-PD sink, so that can be taken into account when - * allocating current. - * - * @param port USB-C port number - */ -void dpm_add_non_pd_sink(int port); - -/* - * Evaluates the request from port partner - * - * @param port USB-C port number - * @param rdo Request from port partner - */ -void dpm_evaluate_request_rdo(int port, uint32_t rdo); - -/* - * Remove this port as a sink, and reallocate maximum current as needed. - * - * @param port USB-C port number - */ -void dpm_remove_sink(int port); - -/* - * Remove this port as a source, and reallocate reserved FRS maximum current - * as needed. - * - * @param port USB-C port number - */ -void dpm_remove_source(int port); - -/* - * Return the appropriate Source Capability PDO to offer this port - * - * @param src_pdo Will point to appropriate PDO to offer - * @param port USB-C port number - * @return Number of PDOs - */ -int dpm_get_source_pdo(const uint32_t **src_pdo, const int port); - -/* - * Report offered source current for this port - * - * @param port USB-C port number - * @return Current offered, in mA - */ -int dpm_get_source_current(const int port); - -/* - * Report we've been asked to enter BIST Shared Test Mode - * - * @param port USB-C port number - */ -void dpm_bist_shared_mode_enter(int port); - -/* - * Report we've been asked to exit BIST Shared Test Mode - * - * @param port USB-C port number - */ -void dpm_bist_shared_mode_exit(int port); - -/* - * Set BIST Shared Test Mode - */ -enum ec_status pd_set_bist_share_mode(uint8_t enable); - -/* - * Get BIST Shared Test Mode status - */ -uint8_t pd_get_bist_share_mode(void); -/* - * Build SOP Status Data Block (SDB) - * - * @param port USB-C port number - * @param *msg pointer to pd message - * @param *len pointer to uint32_t holding length of SDB - */ -int dpm_get_status_msg(int port, uint8_t *msg, uint32_t *len); - -/* - * DPM function to handle a received alert message - * - * @param port USB-C port number - * @param ado Alert Data Object (ado) received from partner - */ -void dpm_handle_alert(int port, uint32_t ado); - -/* Enum for modules to describe to the DPM their setup status */ -enum dpm_msg_setup_status { - MSG_SETUP_SUCCESS, - MSG_SETUP_ERROR, - MSG_SETUP_UNSUPPORTED, - MSG_SETUP_MUX_WAIT, -}; - -/* Enum to describe current state of connected USB PD buttons */ -enum dpm_pd_button_state { - DPM_PD_BUTTON_IDLE, - DPM_PD_BUTTON_PRESSED, -}; -#endif /* __CROS_EC_USB_DPM_H */ diff --git a/include/usb_pd_dpm_sm.h b/include/usb_pd_dpm_sm.h new file mode 100644 index 0000000000..8fdd147be1 --- /dev/null +++ b/include/usb_pd_dpm_sm.h @@ -0,0 +1,196 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * Device Policy Manager implementation + * Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3 + */ + +#ifndef __CROS_EC_USB_DPM_H +#define __CROS_EC_USB_DPM_H + +#include "ec_commands.h" +#include "usb_pd_tcpm.h" + +/* + * Initializes DPM state for a port. + * + * @param port USB-C port number + */ +void dpm_init(int port); + +/** + * Runs the Device Policy Manager State Machine + * + * @param port USB-C port number + * @param evt system event, ie: PD_EVENT_RX + * @param en 0 to disable the machine, 1 to enable the machine + */ +void dpm_run(int port, int evt, int en); + +/* + * Informs the DPM that a mode exit is complete. + * + * @param port USB-C port number + */ +void dpm_mode_exit_complete(int port); + +/* + * Informs the DPM that Exit Mode request is received + * + * @param port USB-C port number + */ +void dpm_set_mode_exit_request(int port); + +/* Informs the DPM that the PE has performed a Data Reset (or at least + * determined that the port partner doesn't support one). + * + * @param port USB-C port number + */ +void dpm_data_reset_complete(int port); + +/* + * Informs the DPM that PE layer is in ready state so that data role can be + * checked and DPM can know to exit the idle state. + * + * @param port USB-C port number + */ +void dpm_set_pe_ready(int port, bool enable); + +/* + * Informs the DPM that a VDM ACK was received. + * + * @param port USB-C port number + * @param type Transmit type (SOP, SOP') for received ACK + * @param vdo_count The number of VDOs in vdm; must be at least 1 + * @param vdm The VDM payload of the ACK + */ +void dpm_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count, + uint32_t *vdm); + +/* + * Informs the DPM that a VDM NAK was received. Also applies when a VDM request + * received a Not Supported response or timed out waiting for a response. + * + * @param port USB-C port number + * @param type Transmit type (SOP, SOP') for request + * @param svid The SVID of the request + * @param vdm_cmd The VDM command of the request + */ +void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid, + uint8_t vdm_cmd); + +/* + * Determines the current allocation for the connection, past the basic + * CONFIG_USB_PD_PULLUP value set by the TC (generally 1.5 A) + * + * @param port USB-C port number + * @param vsafe5v_pdo Copy of first Sink_Capability PDO, which should + * represent the vSafe5V fixed PDO + */ +void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo); + +/* + * Registers port as a non-PD sink, so that can be taken into account when + * allocating current. + * + * @param port USB-C port number + */ +void dpm_add_non_pd_sink(int port); + +/* + * Evaluates the request from port partner + * + * @param port USB-C port number + * @param rdo Request from port partner + */ +void dpm_evaluate_request_rdo(int port, uint32_t rdo); + +/* + * Remove this port as a sink, and reallocate maximum current as needed. + * + * @param port USB-C port number + */ +void dpm_remove_sink(int port); + +/* + * Remove this port as a source, and reallocate reserved FRS maximum current + * as needed. + * + * @param port USB-C port number + */ +void dpm_remove_source(int port); + +/* + * Return the appropriate Source Capability PDO to offer this port + * + * @param src_pdo Will point to appropriate PDO to offer + * @param port USB-C port number + * @return Number of PDOs + */ +int dpm_get_source_pdo(const uint32_t **src_pdo, const int port); + +/* + * Report offered source current for this port + * + * @param port USB-C port number + * @return Current offered, in mA + */ +int dpm_get_source_current(const int port); + +/* + * Report we've been asked to enter BIST Shared Test Mode + * + * @param port USB-C port number + */ +void dpm_bist_shared_mode_enter(int port); + +/* + * Report we've been asked to exit BIST Shared Test Mode + * + * @param port USB-C port number + */ +void dpm_bist_shared_mode_exit(int port); + +/* + * Set BIST Shared Test Mode + */ +enum ec_status pd_set_bist_share_mode(uint8_t enable); + +/* + * Get BIST Shared Test Mode status + */ +uint8_t pd_get_bist_share_mode(void); +/* + * Build SOP Status Data Block (SDB) + * + * @param port USB-C port number + * @param *msg pointer to pd message + * @param *len pointer to uint32_t holding length of SDB + */ +int dpm_get_status_msg(int port, uint8_t *msg, uint32_t *len); + +/* + * DPM function to handle a received alert message + * + * @param port USB-C port number + * @param ado Alert Data Object (ado) received from partner + */ +void dpm_handle_alert(int port, uint32_t ado); + +/* Enum for modules to describe to the DPM their setup status */ +enum dpm_msg_setup_status { + MSG_SETUP_SUCCESS, + MSG_SETUP_ERROR, + MSG_SETUP_UNSUPPORTED, + MSG_SETUP_MUX_WAIT, +}; + +/* Enum to describe current state of connected USB PD buttons */ +enum dpm_pd_button_state { + DPM_PD_BUTTON_IDLE, + DPM_PD_BUTTON_PRESSED, +}; +#endif /* __CROS_EC_USB_DPM_H */ diff --git a/include/usb_tbt_alt_mode.h b/include/usb_tbt_alt_mode.h index 378cd0ccce..b7d7baa6a2 100644 --- a/include/usb_tbt_alt_mode.h +++ b/include/usb_tbt_alt_mode.h @@ -14,7 +14,7 @@ #include #include "tcpm/tcpm.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_tcpm.h" /* diff --git a/test/fake_usbc.c b/test/fake_usbc.c index 1d9c42a97a..72a208aa99 100644 --- a/test/fake_usbc.c +++ b/test/fake_usbc.c @@ -304,7 +304,7 @@ void dpm_set_mode_exit_request(int port) { } -void dpm_run(int port) +void dpm_run(int port, int evt, int enable) { } @@ -351,6 +351,10 @@ void dpm_handle_alert(int port, uint32_t ado) { } +void dpm_set_pe_ready(int port, bool enable) +{ +} + static enum tcpc_rp_value lcl_rp; __overridable void typec_select_src_current_limit_rp(int port, enum tcpc_rp_value rp) diff --git a/test/test_config.h b/test/test_config.h index 3482449c10..a25d8c0845 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -403,6 +403,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #undef CONFIG_USB_PE_SM #undef CONFIG_USB_TYPEC_SM #undef CONFIG_USB_PD_HOST_CMD +#undef CONFIG_USB_DPM_SM #define CONFIG_USB_PRL_SM #define CONFIG_USB_PD_TCPC #define CONFIG_USB_PD_TCPM_STUB @@ -423,6 +424,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_USB_PD_EXTENDED_MESSAGES #define CONFIG_USB_PD_TCPMV2 #undef CONFIG_USB_PE_SM +#undef CONFIG_USB_DPM_SM #undef CONFIG_USB_TYPEC_SM #undef CONFIG_USB_PD_HOST_CMD #define CONFIG_USB_PRL_SM @@ -531,6 +533,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_USB_POWER_DELIVERY #undef CONFIG_USB_PRL_SM #undef CONFIG_USB_PE_SM +#undef CONFIG_USB_DPM_SM #undef CONFIG_USB_PD_HOST_CMD #endif @@ -615,6 +618,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_CMD_PD_TIMER #undef CONFIG_USB_PD_HOST_CMD #undef CONFIG_USB_PRL_SM +#undef CONFIG_USB_DPM_SM #endif #if defined(TEST_CHARGE_MANAGER) || defined(TEST_CHARGE_MANAGER_DRP_CHARGING) diff --git a/zephyr/Kconfig.pd b/zephyr/Kconfig.pd index f6508c2da0..1b104382ad 100644 --- a/zephyr/Kconfig.pd +++ b/zephyr/Kconfig.pd @@ -304,6 +304,15 @@ config PLATFORM_EC_USB_PE_SM USB devices. You should normally define this unless you want to override it in your board code, which is not recommended. +config PLATFORM_EC_USB_DPM_SM + bool "Device Policy Manager (DPM) state machine" + default y + help + This enables the device policy manager portion of the power-delivery + (PD), protocol which is used to define port policy decision. You + should normally define this unless you want to override it in your + board code, which is not recommended. + config PLATFORM_EC_USB_PD_DECODE_SOP def_bool y # Required for TCPMV2 help diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 1bc00a0516..bfef3427a8 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1330,6 +1330,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #define CONFIG_USB_PE_SM #endif +#undef CONFIG_USB_DPM_SM +#ifdef CONFIG_PLATFORM_EC_USB_DPM_SM +#define CONFIG_USB_DPM_SM +#endif + #undef CONFIG_USB_PD_DECODE_SOP #ifdef CONFIG_PLATFORM_EC_USB_PD_DECODE_SOP #define CONFIG_USB_PD_DECODE_SOP diff --git a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c index d521f7bb06..a63e2de496 100644 --- a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c +++ b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c @@ -11,7 +11,7 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" #include "usb_pd.h" -#include "usb_pd_dpm.h" +#include "usb_pd_dpm_sm.h" #include "usb_prl_sm.h" static void console_cmd_usb_pd_after(void *fixture) -- cgit v1.2.1 From 118bcdb316ae1d652d22af6425dfc6c3c5eda1d9 Mon Sep 17 00:00:00 2001 From: Jason Yuan Date: Tue, 1 Nov 2022 11:20:35 -0700 Subject: zephyr EC: Project organization - herobrine Organized the herobrin program into folders for projects. Devicetree files have been changed to use the .dtsi extension following the zephyr convention. Formerly prj.conf file have been separated into programs and projects for disambiguation. BUG=b:254097836 TEST=Ran zmake compare-builds BRANCH=none Change-Id: Id398eccde2b243f8aa521e898e6c09e6cd175236 Signed-off-by: Jason Yuan Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995330 Code-Coverage: Zoss Reviewed-by: Keith Short Reviewed-by: Wai-Hong Tam Tested-by: zhi cheng yuan Commit-Queue: zhi cheng yuan --- zephyr/projects/herobrine/BUILD.py | 83 +----- zephyr/projects/herobrine/CMakeLists.txt | 3 +- zephyr/projects/herobrine/adc.dts | 47 --- zephyr/projects/herobrine/adc.dtsi | 47 +++ zephyr/projects/herobrine/battery_evoker.dts | 15 - zephyr/projects/herobrine/battery_herobrine.dts | 12 - zephyr/projects/herobrine/battery_hoglin.dts | 12 - zephyr/projects/herobrine/battery_villager.dts | 15 - zephyr/projects/herobrine/battery_zombie.dts | 15 - zephyr/projects/herobrine/common.dts | 44 --- zephyr/projects/herobrine/common.dtsi | 44 +++ zephyr/projects/herobrine/default_gpio_pinctrl.dts | 44 --- .../projects/herobrine/default_gpio_pinctrl.dtsi | 44 +++ zephyr/projects/herobrine/display.dts | 18 -- zephyr/projects/herobrine/display.dtsi | 18 ++ zephyr/projects/herobrine/evoker/battery.dtsi | 15 + zephyr/projects/herobrine/evoker/gpio.dtsi | 329 +++++++++++++++++++++ zephyr/projects/herobrine/evoker/i2c.dtsi | 46 +++ zephyr/projects/herobrine/evoker/led_pins.dtsi | 54 ++++ zephyr/projects/herobrine/evoker/led_policy.dtsi | 86 ++++++ zephyr/projects/herobrine/evoker/motionsense.dtsi | 148 +++++++++ zephyr/projects/herobrine/evoker/project.conf | 16 + zephyr/projects/herobrine/evoker/project.overlay | 22 ++ zephyr/projects/herobrine/evoker/usbc.dtsi | 42 +++ zephyr/projects/herobrine/gpio.dts | 329 --------------------- zephyr/projects/herobrine/gpio.dtsi | 329 +++++++++++++++++++++ zephyr/projects/herobrine/gpio_evoker.dts | 329 --------------------- zephyr/projects/herobrine/gpio_hoglin.dts | 327 -------------------- zephyr/projects/herobrine/gpio_villager.dts | 323 -------------------- zephyr/projects/herobrine/gpio_zombie.dts | 323 -------------------- zephyr/projects/herobrine/herobrine/CMakeLists.txt | 6 + zephyr/projects/herobrine/herobrine/battery.dtsi | 12 + zephyr/projects/herobrine/herobrine/i2c.dtsi | 39 +++ zephyr/projects/herobrine/herobrine/led_pins.dtsi | 56 ++++ .../projects/herobrine/herobrine/led_policy.dtsi | 202 +++++++++++++ zephyr/projects/herobrine/herobrine/project.conf | 13 + .../projects/herobrine/herobrine/project.overlay | 22 ++ .../herobrine/herobrine/src/alt_dev_replacement.c | 36 +++ zephyr/projects/herobrine/herobrine/usbc.dtsi | 43 +++ zephyr/projects/herobrine/hoglin/battery.dtsi | 12 + zephyr/projects/herobrine/hoglin/gpio.dtsi | 327 ++++++++++++++++++++ zephyr/projects/herobrine/hoglin/i2c.dtsi | 34 +++ zephyr/projects/herobrine/hoglin/led_pins.dtsi | 33 +++ zephyr/projects/herobrine/hoglin/led_policy.dtsi | 95 ++++++ zephyr/projects/herobrine/hoglin/motionsense.dtsi | 241 +++++++++++++++ zephyr/projects/herobrine/hoglin/project.conf | 15 + zephyr/projects/herobrine/hoglin/project.overlay | 21 ++ zephyr/projects/herobrine/hoglin/switchcap.dtsi | 12 + zephyr/projects/herobrine/hoglin/usbc.dtsi | 42 +++ zephyr/projects/herobrine/i2c.dtsi | 157 ++++++++++ zephyr/projects/herobrine/i2c_common.dtsi | 157 ---------- zephyr/projects/herobrine/i2c_evoker.dts | 46 --- zephyr/projects/herobrine/i2c_herobrine.dts | 39 --- zephyr/projects/herobrine/i2c_hoglin.dts | 34 --- zephyr/projects/herobrine/i2c_villager.dts | 34 --- zephyr/projects/herobrine/i2c_zombie.dts | 34 --- zephyr/projects/herobrine/interrupts.dts | 115 ------- zephyr/projects/herobrine/interrupts.dtsi | 115 +++++++ zephyr/projects/herobrine/keyboard.dts | 46 --- zephyr/projects/herobrine/keyboard.dtsi | 46 +++ zephyr/projects/herobrine/led_pins_evoker.dts | 54 ---- zephyr/projects/herobrine/led_pins_herobrine.dts | 56 ---- zephyr/projects/herobrine/led_pins_hoglin.dts | 33 --- zephyr/projects/herobrine/led_pins_villager.dts | 33 --- zephyr/projects/herobrine/led_pins_zombie.dts | 33 --- zephyr/projects/herobrine/led_policy_evoker.dts | 86 ------ zephyr/projects/herobrine/led_policy_herobrine.dts | 202 ------------- zephyr/projects/herobrine/led_policy_hoglin.dts | 95 ------ zephyr/projects/herobrine/led_policy_villager.dts | 95 ------ zephyr/projects/herobrine/led_policy_zombie.dts | 95 ------ zephyr/projects/herobrine/motionsense.dts | 241 --------------- zephyr/projects/herobrine/motionsense.dtsi | 241 +++++++++++++++ zephyr/projects/herobrine/motionsense_evoker.dts | 148 --------- zephyr/projects/herobrine/motionsense_hoglin.dts | 241 --------------- zephyr/projects/herobrine/motionsense_villager.dts | 148 --------- zephyr/projects/herobrine/motionsense_zombie.dts | 148 --------- zephyr/projects/herobrine/prj.conf | 160 ---------- zephyr/projects/herobrine/prj_evoker.conf | 16 - zephyr/projects/herobrine/prj_herobrine.conf | 13 - zephyr/projects/herobrine/prj_hoglin.conf | 15 - zephyr/projects/herobrine/prj_villager.conf | 8 - zephyr/projects/herobrine/prj_zoglin.conf | 15 - zephyr/projects/herobrine/prj_zombie.conf | 8 - zephyr/projects/herobrine/program.conf | 160 ++++++++++ .../herobrine/src/herobrine/alt_dev_replacement.c | 36 --- zephyr/projects/herobrine/switchcap.dts | 12 - zephyr/projects/herobrine/switchcap.dtsi | 12 + zephyr/projects/herobrine/switchcap_hoglin.dts | 12 - zephyr/projects/herobrine/usbc_evoker.dts | 42 --- zephyr/projects/herobrine/usbc_herobrine.dts | 43 --- zephyr/projects/herobrine/usbc_hoglin.dts | 42 --- zephyr/projects/herobrine/usbc_villager.dts | 42 --- zephyr/projects/herobrine/usbc_zombie.dts | 42 --- zephyr/projects/herobrine/villager/battery.dtsi | 15 + zephyr/projects/herobrine/villager/gpio.dtsi | 323 ++++++++++++++++++++ zephyr/projects/herobrine/villager/i2c.dtsi | 34 +++ zephyr/projects/herobrine/villager/led_pins.dtsi | 33 +++ zephyr/projects/herobrine/villager/led_policy.dtsi | 95 ++++++ .../projects/herobrine/villager/motionsense.dtsi | 148 +++++++++ zephyr/projects/herobrine/villager/project.conf | 8 + zephyr/projects/herobrine/villager/project.overlay | 21 ++ zephyr/projects/herobrine/villager/usbc.dtsi | 42 +++ zephyr/projects/herobrine/zoglin/project.conf | 15 + zephyr/projects/herobrine/zoglin/project.overlay | 21 ++ zephyr/projects/herobrine/zombie/battery.dtsi | 15 + zephyr/projects/herobrine/zombie/gpio.dtsi | 323 ++++++++++++++++++++ zephyr/projects/herobrine/zombie/i2c.dtsi | 34 +++ zephyr/projects/herobrine/zombie/led_pins.dtsi | 33 +++ zephyr/projects/herobrine/zombie/led_policy.dtsi | 95 ++++++ zephyr/projects/herobrine/zombie/motionsense.dtsi | 148 +++++++++ zephyr/projects/herobrine/zombie/project.conf | 8 + zephyr/projects/herobrine/zombie/project.overlay | 21 ++ zephyr/projects/herobrine/zombie/usbc.dtsi | 42 +++ 113 files changed, 4711 insertions(+), 4653 deletions(-) delete mode 100644 zephyr/projects/herobrine/adc.dts create mode 100644 zephyr/projects/herobrine/adc.dtsi delete mode 100644 zephyr/projects/herobrine/battery_evoker.dts delete mode 100644 zephyr/projects/herobrine/battery_herobrine.dts delete mode 100644 zephyr/projects/herobrine/battery_hoglin.dts delete mode 100644 zephyr/projects/herobrine/battery_villager.dts delete mode 100644 zephyr/projects/herobrine/battery_zombie.dts delete mode 100644 zephyr/projects/herobrine/common.dts create mode 100644 zephyr/projects/herobrine/common.dtsi delete mode 100644 zephyr/projects/herobrine/default_gpio_pinctrl.dts create mode 100644 zephyr/projects/herobrine/default_gpio_pinctrl.dtsi delete mode 100644 zephyr/projects/herobrine/display.dts create mode 100644 zephyr/projects/herobrine/display.dtsi create mode 100644 zephyr/projects/herobrine/evoker/battery.dtsi create mode 100644 zephyr/projects/herobrine/evoker/gpio.dtsi create mode 100644 zephyr/projects/herobrine/evoker/i2c.dtsi create mode 100644 zephyr/projects/herobrine/evoker/led_pins.dtsi create mode 100644 zephyr/projects/herobrine/evoker/led_policy.dtsi create mode 100644 zephyr/projects/herobrine/evoker/motionsense.dtsi create mode 100644 zephyr/projects/herobrine/evoker/project.conf create mode 100644 zephyr/projects/herobrine/evoker/project.overlay create mode 100644 zephyr/projects/herobrine/evoker/usbc.dtsi delete mode 100644 zephyr/projects/herobrine/gpio.dts create mode 100644 zephyr/projects/herobrine/gpio.dtsi delete mode 100644 zephyr/projects/herobrine/gpio_evoker.dts delete mode 100644 zephyr/projects/herobrine/gpio_hoglin.dts delete mode 100644 zephyr/projects/herobrine/gpio_villager.dts delete mode 100644 zephyr/projects/herobrine/gpio_zombie.dts create mode 100644 zephyr/projects/herobrine/herobrine/CMakeLists.txt create mode 100644 zephyr/projects/herobrine/herobrine/battery.dtsi create mode 100644 zephyr/projects/herobrine/herobrine/i2c.dtsi create mode 100644 zephyr/projects/herobrine/herobrine/led_pins.dtsi create mode 100644 zephyr/projects/herobrine/herobrine/led_policy.dtsi create mode 100644 zephyr/projects/herobrine/herobrine/project.conf create mode 100644 zephyr/projects/herobrine/herobrine/project.overlay create mode 100644 zephyr/projects/herobrine/herobrine/src/alt_dev_replacement.c create mode 100644 zephyr/projects/herobrine/herobrine/usbc.dtsi create mode 100644 zephyr/projects/herobrine/hoglin/battery.dtsi create mode 100644 zephyr/projects/herobrine/hoglin/gpio.dtsi create mode 100644 zephyr/projects/herobrine/hoglin/i2c.dtsi create mode 100644 zephyr/projects/herobrine/hoglin/led_pins.dtsi create mode 100644 zephyr/projects/herobrine/hoglin/led_policy.dtsi create mode 100644 zephyr/projects/herobrine/hoglin/motionsense.dtsi create mode 100644 zephyr/projects/herobrine/hoglin/project.conf create mode 100644 zephyr/projects/herobrine/hoglin/project.overlay create mode 100644 zephyr/projects/herobrine/hoglin/switchcap.dtsi create mode 100644 zephyr/projects/herobrine/hoglin/usbc.dtsi create mode 100644 zephyr/projects/herobrine/i2c.dtsi delete mode 100644 zephyr/projects/herobrine/i2c_common.dtsi delete mode 100644 zephyr/projects/herobrine/i2c_evoker.dts delete mode 100644 zephyr/projects/herobrine/i2c_herobrine.dts delete mode 100644 zephyr/projects/herobrine/i2c_hoglin.dts delete mode 100644 zephyr/projects/herobrine/i2c_villager.dts delete mode 100644 zephyr/projects/herobrine/i2c_zombie.dts delete mode 100644 zephyr/projects/herobrine/interrupts.dts create mode 100644 zephyr/projects/herobrine/interrupts.dtsi delete mode 100644 zephyr/projects/herobrine/keyboard.dts create mode 100644 zephyr/projects/herobrine/keyboard.dtsi delete mode 100644 zephyr/projects/herobrine/led_pins_evoker.dts delete mode 100644 zephyr/projects/herobrine/led_pins_herobrine.dts delete mode 100644 zephyr/projects/herobrine/led_pins_hoglin.dts delete mode 100644 zephyr/projects/herobrine/led_pins_villager.dts delete mode 100644 zephyr/projects/herobrine/led_pins_zombie.dts delete mode 100644 zephyr/projects/herobrine/led_policy_evoker.dts delete mode 100644 zephyr/projects/herobrine/led_policy_herobrine.dts delete mode 100644 zephyr/projects/herobrine/led_policy_hoglin.dts delete mode 100644 zephyr/projects/herobrine/led_policy_villager.dts delete mode 100644 zephyr/projects/herobrine/led_policy_zombie.dts delete mode 100644 zephyr/projects/herobrine/motionsense.dts create mode 100644 zephyr/projects/herobrine/motionsense.dtsi delete mode 100644 zephyr/projects/herobrine/motionsense_evoker.dts delete mode 100644 zephyr/projects/herobrine/motionsense_hoglin.dts delete mode 100644 zephyr/projects/herobrine/motionsense_villager.dts delete mode 100644 zephyr/projects/herobrine/motionsense_zombie.dts delete mode 100644 zephyr/projects/herobrine/prj.conf delete mode 100644 zephyr/projects/herobrine/prj_evoker.conf delete mode 100644 zephyr/projects/herobrine/prj_herobrine.conf delete mode 100644 zephyr/projects/herobrine/prj_hoglin.conf delete mode 100644 zephyr/projects/herobrine/prj_villager.conf delete mode 100644 zephyr/projects/herobrine/prj_zoglin.conf delete mode 100644 zephyr/projects/herobrine/prj_zombie.conf create mode 100644 zephyr/projects/herobrine/program.conf delete mode 100644 zephyr/projects/herobrine/src/herobrine/alt_dev_replacement.c delete mode 100644 zephyr/projects/herobrine/switchcap.dts create mode 100644 zephyr/projects/herobrine/switchcap.dtsi delete mode 100644 zephyr/projects/herobrine/switchcap_hoglin.dts delete mode 100644 zephyr/projects/herobrine/usbc_evoker.dts delete mode 100644 zephyr/projects/herobrine/usbc_herobrine.dts delete mode 100644 zephyr/projects/herobrine/usbc_hoglin.dts delete mode 100644 zephyr/projects/herobrine/usbc_villager.dts delete mode 100644 zephyr/projects/herobrine/usbc_zombie.dts create mode 100644 zephyr/projects/herobrine/villager/battery.dtsi create mode 100644 zephyr/projects/herobrine/villager/gpio.dtsi create mode 100644 zephyr/projects/herobrine/villager/i2c.dtsi create mode 100644 zephyr/projects/herobrine/villager/led_pins.dtsi create mode 100644 zephyr/projects/herobrine/villager/led_policy.dtsi create mode 100644 zephyr/projects/herobrine/villager/motionsense.dtsi create mode 100644 zephyr/projects/herobrine/villager/project.conf create mode 100644 zephyr/projects/herobrine/villager/project.overlay create mode 100644 zephyr/projects/herobrine/villager/usbc.dtsi create mode 100644 zephyr/projects/herobrine/zoglin/project.conf create mode 100644 zephyr/projects/herobrine/zoglin/project.overlay create mode 100644 zephyr/projects/herobrine/zombie/battery.dtsi create mode 100644 zephyr/projects/herobrine/zombie/gpio.dtsi create mode 100644 zephyr/projects/herobrine/zombie/i2c.dtsi create mode 100644 zephyr/projects/herobrine/zombie/led_pins.dtsi create mode 100644 zephyr/projects/herobrine/zombie/led_policy.dtsi create mode 100644 zephyr/projects/herobrine/zombie/motionsense.dtsi create mode 100644 zephyr/projects/herobrine/zombie/project.conf create mode 100644 zephyr/projects/herobrine/zombie/project.overlay create mode 100644 zephyr/projects/herobrine/zombie/usbc.dtsi diff --git a/zephyr/projects/herobrine/BUILD.py b/zephyr/projects/herobrine/BUILD.py index d38803deb7..0bee6ffe2a 100644 --- a/zephyr/projects/herobrine/BUILD.py +++ b/zephyr/projects/herobrine/BUILD.py @@ -6,119 +6,44 @@ def register_variant( - project_name, extra_dts_overlays=(), extra_kconfig_files=() + project_name, ): """Register a variant of herobrine.""" register_npcx_project( project_name=project_name, zephyr_board="npcx9m3f", dts_overlays=[ - # Common to all projects. - here / "adc.dts", - here / "common.dts", - here / "interrupts.dts", - here / "keyboard.dts", - here / "default_gpio_pinctrl.dts", - # Project-specific DTS customization. - *extra_dts_overlays, + here / project_name / "project.overlay", ], kconfig_files=[ # Common to all projects. - here / "prj.conf", + here / "program.conf", # Project-specific KConfig customization. - *extra_kconfig_files, + here / project_name / "project.conf", ], ) register_variant( project_name="evoker", - extra_dts_overlays=[ - here / "display.dts", - here / "battery_evoker.dts", - here / "gpio_evoker.dts", - here / "i2c_evoker.dts", - here / "led_pins_evoker.dts", - here / "led_policy_evoker.dts", - here / "motionsense_evoker.dts", - here / "switchcap.dts", - here / "usbc_evoker.dts", - ], - extra_kconfig_files=[here / "prj_evoker.conf"], ) register_variant( project_name="herobrine", - extra_dts_overlays=[ - here / "display.dts", - here / "battery_herobrine.dts", - here / "gpio.dts", - here / "i2c_herobrine.dts", - here / "led_pins_herobrine.dts", - here / "led_policy_herobrine.dts", - here / "motionsense.dts", - here / "switchcap.dts", - here / "usbc_herobrine.dts", - ], - extra_kconfig_files=[here / "prj_herobrine.conf"], ) register_variant( project_name="hoglin", - extra_dts_overlays=[ - here / "battery_hoglin.dts", - here / "gpio_hoglin.dts", - here / "i2c_hoglin.dts", - here / "led_pins_hoglin.dts", - here / "led_policy_hoglin.dts", - here / "motionsense_hoglin.dts", - here / "switchcap_hoglin.dts", - here / "usbc_hoglin.dts", - ], - extra_kconfig_files=[here / "prj_hoglin.conf"], ) register_variant( project_name="villager", - extra_dts_overlays=[ - here / "battery_villager.dts", - here / "gpio_villager.dts", - here / "i2c_villager.dts", - here / "led_pins_villager.dts", - here / "led_policy_villager.dts", - here / "motionsense_villager.dts", - here / "switchcap.dts", - here / "usbc_villager.dts", - ], - extra_kconfig_files=[here / "prj_villager.conf"], ) register_variant( project_name="zoglin", - extra_dts_overlays=[ - here / "battery_hoglin.dts", - here / "gpio_hoglin.dts", - here / "i2c_hoglin.dts", - here / "led_pins_hoglin.dts", - here / "led_policy_hoglin.dts", - here / "motionsense_hoglin.dts", - here / "switchcap_hoglin.dts", - here / "usbc_hoglin.dts", - ], - extra_kconfig_files=[here / "prj_zoglin.conf"], ) register_variant( project_name="zombie", - extra_dts_overlays=[ - here / "battery_zombie.dts", - here / "gpio_zombie.dts", - here / "i2c_zombie.dts", - here / "led_pins_zombie.dts", - here / "led_policy_zombie.dts", - here / "motionsense_zombie.dts", - here / "switchcap.dts", - here / "usbc_zombie.dts", - ], - extra_kconfig_files=[here / "prj_zombie.conf"], ) diff --git a/zephyr/projects/herobrine/CMakeLists.txt b/zephyr/projects/herobrine/CMakeLists.txt index a7e2fc6cf6..90a49a053e 100644 --- a/zephyr/projects/herobrine/CMakeLists.txt +++ b/zephyr/projects/herobrine/CMakeLists.txt @@ -24,8 +24,7 @@ if(DEFINED CONFIG_BOARD_EVOKER) project(evoker) elseif(DEFINED CONFIG_BOARD_HEROBRINE) project(herobrine) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/herobrine/alt_dev_replacement.c") + add_subdirectory(herobrine) elseif(DEFINED CONFIG_BOARD_HOGLIN) project(hoglin) elseif(DEFINED CONFIG_BOARD_VILLAGER) diff --git a/zephyr/projects/herobrine/adc.dts b/zephyr/projects/herobrine/adc.dts deleted file mode 100644 index 16a5434e9d..0000000000 --- a/zephyr/projects/herobrine/adc.dts +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - vbus { - enum-name = "ADC_VBUS"; - io-channels = <&adc0 1>; - /* Measure VBUS through a 1/10 voltage divider */ - mul = <10>; - }; - amon_bmon { - enum-name = "ADC_AMON_BMON"; - io-channels = <&adc0 2>; - /* - * Adapter current output or battery charging/ - * discharging current (uV) 18x amplification on - * charger side. - */ - mul = <1000>; - div = <18>; - }; - psys { - enum-name = "ADC_PSYS"; - io-channels = <&adc0 3>; - /* - * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor, - * to read 0.8V @ 99 W, i.e. 124000 uW/mV. - */ - mul = <124000>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/herobrine/adc.dtsi b/zephyr/projects/herobrine/adc.dtsi new file mode 100644 index 0000000000..16a5434e9d --- /dev/null +++ b/zephyr/projects/herobrine/adc.dtsi @@ -0,0 +1,47 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + vbus { + enum-name = "ADC_VBUS"; + io-channels = <&adc0 1>; + /* Measure VBUS through a 1/10 voltage divider */ + mul = <10>; + }; + amon_bmon { + enum-name = "ADC_AMON_BMON"; + io-channels = <&adc0 2>; + /* + * Adapter current output or battery charging/ + * discharging current (uV) 18x amplification on + * charger side. + */ + mul = <1000>; + div = <18>; + }; + psys { + enum-name = "ADC_PSYS"; + io-channels = <&adc0 3>; + /* + * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor, + * to read 0.8V @ 99 W, i.e. 124000 uW/mV. + */ + mul = <124000>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42>; + pinctrl-names = "default"; +}; diff --git a/zephyr/projects/herobrine/battery_evoker.dts b/zephyr/projects/herobrine/battery_evoker.dts deleted file mode 100644 index 0e09616c1d..0000000000 --- a/zephyr/projects/herobrine/battery_evoker.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: pc_vp_bp153 { - compatible = "smp,pc-vp-bp153", "battery-smart"; - }; - ap16l5j { - compatible = "panasonic,ap16l5j", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/battery_herobrine.dts b/zephyr/projects/herobrine/battery_herobrine.dts deleted file mode 100644 index b347ec4c3c..0000000000 --- a/zephyr/projects/herobrine/battery_herobrine.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap16l5j { - compatible = "panasonic,ap16l5j", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/battery_hoglin.dts b/zephyr/projects/herobrine/battery_hoglin.dts deleted file mode 100644 index 11180c3988..0000000000 --- a/zephyr/projects/herobrine/battery_hoglin.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: 7c01 { - compatible = "ganfeng,7c01", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/battery_villager.dts b/zephyr/projects/herobrine/battery_villager.dts deleted file mode 100644 index dafd473a6e..0000000000 --- a/zephyr/projects/herobrine/battery_villager.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap19a5k { - compatible = "panasonic,ap19a5k", "battery-smart"; - }; - ap19a8k { - compatible = "lgc,ap19a8k", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/battery_zombie.dts b/zephyr/projects/herobrine/battery_zombie.dts deleted file mode 100644 index dafd473a6e..0000000000 --- a/zephyr/projects/herobrine/battery_zombie.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap19a5k { - compatible = "panasonic,ap19a5k", "battery-smart"; - }; - ap19a8k { - compatible = "lgc,ap19a8k", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/common.dts b/zephyr/projects/herobrine/common.dts deleted file mode 100644 index a722f1dfa2..0000000000 --- a/zephyr/projects/herobrine/common.dts +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - chosen { - cros,rtc = &pcf85063a; - }; - - ec-console { - compatible = "ec-console"; - disabled = "hostcmd"; - }; - - ec-mkbp-host-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <( - HOST_EVENT_LID_OPEN | - HOST_EVENT_POWER_BUTTON | - HOST_EVENT_AC_CONNECTED | - HOST_EVENT_AC_DISCONNECTED | - HOST_EVENT_HANG_DETECT | - HOST_EVENT_RTC | - HOST_EVENT_MODE_CHANGE | - HOST_EVENT_DEVICE)>; - }; - - ec-mkbp-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \ - MKBP_EVENT_HOST_EVENT | \ - MKBP_EVENT_SENSOR_FIFO)>; - }; -}; - -&shi { - status = "okay"; - pinctrl-0 = <&shi_gp46_47_53_55>; - pinctrl-1 = <&shi_gpio_gp46_47_53_55>; - pinctrl-names = "default", "sleep"; -}; diff --git a/zephyr/projects/herobrine/common.dtsi b/zephyr/projects/herobrine/common.dtsi new file mode 100644 index 0000000000..a722f1dfa2 --- /dev/null +++ b/zephyr/projects/herobrine/common.dtsi @@ -0,0 +1,44 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + chosen { + cros,rtc = &pcf85063a; + }; + + ec-console { + compatible = "ec-console"; + disabled = "hostcmd"; + }; + + ec-mkbp-host-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <( + HOST_EVENT_LID_OPEN | + HOST_EVENT_POWER_BUTTON | + HOST_EVENT_AC_CONNECTED | + HOST_EVENT_AC_DISCONNECTED | + HOST_EVENT_HANG_DETECT | + HOST_EVENT_RTC | + HOST_EVENT_MODE_CHANGE | + HOST_EVENT_DEVICE)>; + }; + + ec-mkbp-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \ + MKBP_EVENT_HOST_EVENT | \ + MKBP_EVENT_SENSOR_FIFO)>; + }; +}; + +&shi { + status = "okay"; + pinctrl-0 = <&shi_gp46_47_53_55>; + pinctrl-1 = <&shi_gpio_gp46_47_53_55>; + pinctrl-names = "default", "sleep"; +}; diff --git a/zephyr/projects/herobrine/default_gpio_pinctrl.dts b/zephyr/projects/herobrine/default_gpio_pinctrl.dts deleted file mode 100644 index 604658a145..0000000000 --- a/zephyr/projects/herobrine/default_gpio_pinctrl.dts +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ -&{/def-io-conf-list} { - pinmux = <&alt0_gpio_no_spip - &alt0_gpio_no_fpip - &alt1_no_pwrgd - &alt1_no_lpc_espi - &alta_no_peci_en - &altd_npsl_in1_sl - &altd_npsl_in2_sl - &altd_psl_in3_sl - &altd_psl_in4_sl - &alt7_no_ksi0_sl - &alt7_no_ksi1_sl - &alt7_no_ksi2_sl - &alt7_no_ksi3_sl - &alt7_no_ksi4_sl - &alt7_no_ksi5_sl - &alt7_no_ksi6_sl - &alt7_no_ksi7_sl - &alt8_no_kso00_sl - &alt8_no_kso01_sl - &alt8_no_kso02_sl - &alt8_no_kso03_sl - &alt8_no_kso04_sl - &alt8_no_kso05_sl - &alt8_no_kso06_sl - &alt8_no_kso07_sl - &alt9_no_kso08_sl - &alt9_no_kso09_sl - &alt9_no_kso10_sl - &alt9_no_kso11_sl - &alt9_no_kso12_sl - &alt9_no_kso13_sl - &alt9_no_kso14_sl - &alt9_no_kso15_sl - &alta_no_kso16_sl - &alta_no_kso17_sl - &altg_psl_gpo_sl>; -}; diff --git a/zephyr/projects/herobrine/default_gpio_pinctrl.dtsi b/zephyr/projects/herobrine/default_gpio_pinctrl.dtsi new file mode 100644 index 0000000000..604658a145 --- /dev/null +++ b/zephyr/projects/herobrine/default_gpio_pinctrl.dtsi @@ -0,0 +1,44 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ +&{/def-io-conf-list} { + pinmux = <&alt0_gpio_no_spip + &alt0_gpio_no_fpip + &alt1_no_pwrgd + &alt1_no_lpc_espi + &alta_no_peci_en + &altd_npsl_in1_sl + &altd_npsl_in2_sl + &altd_psl_in3_sl + &altd_psl_in4_sl + &alt7_no_ksi0_sl + &alt7_no_ksi1_sl + &alt7_no_ksi2_sl + &alt7_no_ksi3_sl + &alt7_no_ksi4_sl + &alt7_no_ksi5_sl + &alt7_no_ksi6_sl + &alt7_no_ksi7_sl + &alt8_no_kso00_sl + &alt8_no_kso01_sl + &alt8_no_kso02_sl + &alt8_no_kso03_sl + &alt8_no_kso04_sl + &alt8_no_kso05_sl + &alt8_no_kso06_sl + &alt8_no_kso07_sl + &alt9_no_kso08_sl + &alt9_no_kso09_sl + &alt9_no_kso10_sl + &alt9_no_kso11_sl + &alt9_no_kso12_sl + &alt9_no_kso13_sl + &alt9_no_kso14_sl + &alt9_no_kso15_sl + &alta_no_kso16_sl + &alta_no_kso17_sl + &altg_psl_gpo_sl>; +}; diff --git a/zephyr/projects/herobrine/display.dts b/zephyr/projects/herobrine/display.dts deleted file mode 100644 index 65d3a2d91b..0000000000 --- a/zephyr/projects/herobrine/display.dts +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - displight { - compatible = "cros-ec,displight"; - pwms = <&pwm5 0 PWM_HZ(4800) PWM_POLARITY_NORMAL>; - generic-pwm-channel = <1>; - }; -}; - -&pwm5 { - status = "okay"; - pinctrl-0 = <&pwm5_gpb7>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/herobrine/display.dtsi b/zephyr/projects/herobrine/display.dtsi new file mode 100644 index 0000000000..65d3a2d91b --- /dev/null +++ b/zephyr/projects/herobrine/display.dtsi @@ -0,0 +1,18 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + displight { + compatible = "cros-ec,displight"; + pwms = <&pwm5 0 PWM_HZ(4800) PWM_POLARITY_NORMAL>; + generic-pwm-channel = <1>; + }; +}; + +&pwm5 { + status = "okay"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; diff --git a/zephyr/projects/herobrine/evoker/battery.dtsi b/zephyr/projects/herobrine/evoker/battery.dtsi new file mode 100644 index 0000000000..0e09616c1d --- /dev/null +++ b/zephyr/projects/herobrine/evoker/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: pc_vp_bp153 { + compatible = "smp,pc-vp-bp153", "battery-smart"; + }; + ap16l5j { + compatible = "panasonic,ap16l5j", "battery-smart"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/evoker/gpio.dtsi b/zephyr/projects/herobrine/evoker/gpio.dtsi new file mode 100644 index 0000000000..d60fdf93c7 --- /dev/null +++ b/zephyr/projects/herobrine/evoker/gpio.dtsi @@ -0,0 +1,329 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { + #led-pin-cells = <1>; + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpio5 0 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; diff --git a/zephyr/projects/herobrine/evoker/i2c.dtsi b/zephyr/projects/herobrine/evoker/i2c.dtsi new file mode 100644 index 0000000000..6de6863f60 --- /dev/null +++ b/zephyr/projects/herobrine/evoker/i2c.dtsi @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + ppc_port0_alt: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; + +&i2c2_0 { + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + ppc_port1_alt: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; diff --git a/zephyr/projects/herobrine/evoker/led_pins.dtsi b/zephyr/projects/herobrine/evoker/led_pins.dtsi new file mode 100644 index 0000000000..ff2dc0e36c --- /dev/null +++ b/zephyr/projects/herobrine/evoker/led_pins.dtsi @@ -0,0 +1,54 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_power_off: color-power-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&gpio_ec_chg_led_w_c1 0>; + }; + + color_power_white: color-power-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&gpio_ec_chg_led_w_c1 1>; + }; + + color_battery_off: color-battery-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 0>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_battery_amber: color-battery-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 1>, + <&gpio_ec_chg_led_w_c0 0>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_battery_white: color-battery-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 1>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_battery_red: color-battery-red { + led-color = "LED_RED"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 0>, + <&gpio_ec_chg_led_r_c0 1>; + }; + }; +}; diff --git a/zephyr/projects/herobrine/evoker/led_policy.dtsi b/zephyr/projects/herobrine/evoker/led_policy.dtsi new file mode 100644 index 0000000000..fc17755ede --- /dev/null +++ b/zephyr/projects/herobrine/evoker/led_policy.dtsi @@ -0,0 +1,86 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + battery-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + battery-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + battery-state-discharge { + charge-state = "PWR_STATE_DISCHARGE"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + + battery-state-error { + charge-state = "PWR_STATE_ERROR"; + + color-0 { + led-color = <&color_battery_red>; + }; + }; + + /* force idle mode */ + battery-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Red 1 sec, White 1 sec */ + color-0 { + led-color = <&color_battery_red>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + }; + + pwr-power-state-s0 { + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_power_white>; + }; + }; + + power-state-s3 { + chipset-state = "POWER_S3"; + + /* white LED - on 1 sec, off 1 sec */ + color-0 { + led-color = <&color_power_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_power_off>; + period-ms = <1000>; + }; + }; + + power-state-s5 { + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_power_off>; + }; + }; + }; +}; diff --git a/zephyr/projects/herobrine/evoker/motionsense.dtsi b/zephyr/projects/herobrine/evoker/motionsense.dtsi new file mode 100644 index 0000000000..aa7646e0b3 --- /dev/null +++ b/zephyr/projects/herobrine/evoker/motionsense.dtsi @@ -0,0 +1,148 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma4xx_data>; + i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/projects/herobrine/evoker/project.conf b/zephyr/projects/herobrine/evoker/project.conf new file mode 100644 index 0000000000..b4a5fce160 --- /dev/null +++ b/zephyr/projects/herobrine/evoker/project.conf @@ -0,0 +1,16 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Evoker board-specific Kconfig settings. +CONFIG_BOARD_EVOKER=y + +# Disable type-c port sourcing 3A +CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0 + +CONFIG_PLATFORM_EC_ACCEL_BMA255=n +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y + +# ISL9238C disable the CMOUT latch function. +CONFIG_PLATFORM_EC_ISL9238C_DISABLE_CMOUT_LATCH=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y \ No newline at end of file diff --git a/zephyr/projects/herobrine/evoker/project.overlay b/zephyr/projects/herobrine/evoker/project.overlay new file mode 100644 index 0000000000..5731bf3312 --- /dev/null +++ b/zephyr/projects/herobrine/evoker/project.overlay @@ -0,0 +1,22 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" +#include "../display.dtsi" +#include "../switchcap.dtsi" + +/* Evoker project DTS includes*/ +#include "battery.dtsi" +#include "gpio.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/evoker/usbc.dtsi b/zephyr/projects/herobrine/evoker/usbc.dtsi new file mode 100644 index 0000000000..20bd48382f --- /dev/null +++ b/zephyr/projects/herobrine/evoker/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/gpio.dts b/zephyr/projects/herobrine/gpio.dts deleted file mode 100644 index a355aaf099..0000000000 --- a/zephyr/projects/herobrine/gpio.dts +++ /dev/null @@ -1,329 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { - #led-pin-cells = <1>; - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { - #led-pin-cells = <1>; - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpio5 0 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; \ No newline at end of file diff --git a/zephyr/projects/herobrine/gpio.dtsi b/zephyr/projects/herobrine/gpio.dtsi new file mode 100644 index 0000000000..a355aaf099 --- /dev/null +++ b/zephyr/projects/herobrine/gpio.dtsi @@ -0,0 +1,329 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { + #led-pin-cells = <1>; + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { + #led-pin-cells = <1>; + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpio5 0 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; \ No newline at end of file diff --git a/zephyr/projects/herobrine/gpio_evoker.dts b/zephyr/projects/herobrine/gpio_evoker.dts deleted file mode 100644 index d60fdf93c7..0000000000 --- a/zephyr/projects/herobrine/gpio_evoker.dts +++ /dev/null @@ -1,329 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { - #led-pin-cells = <1>; - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpio5 0 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; diff --git a/zephyr/projects/herobrine/gpio_hoglin.dts b/zephyr/projects/herobrine/gpio_hoglin.dts deleted file mode 100644 index cb7babc9cf..0000000000 --- a/zephyr/projects/herobrine/gpio_hoglin.dts +++ /dev/null @@ -1,327 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpio5 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_y_c1: ec_chg_led_b_c1 { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c1: ec_chg_led_r_c1 { - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpiod 5 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; diff --git a/zephyr/projects/herobrine/gpio_villager.dts b/zephyr/projects/herobrine/gpio_villager.dts deleted file mode 100644 index 1e7625ff6a..0000000000 --- a/zephyr/projects/herobrine/gpio_villager.dts +++ /dev/null @@ -1,323 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 3 0>, - <&gpioc 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpio5 0 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; diff --git a/zephyr/projects/herobrine/gpio_zombie.dts b/zephyr/projects/herobrine/gpio_zombie.dts deleted file mode 100644 index 14ed1f54d6..0000000000 --- a/zephyr/projects/herobrine/gpio_zombie.dts +++ /dev/null @@ -1,323 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 3 0>, - <&gpioc 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpio5 0 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; diff --git a/zephyr/projects/herobrine/herobrine/CMakeLists.txt b/zephyr/projects/herobrine/herobrine/CMakeLists.txt new file mode 100644 index 0000000000..5524db7215 --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/alt_dev_replacement.c") diff --git a/zephyr/projects/herobrine/herobrine/battery.dtsi b/zephyr/projects/herobrine/herobrine/battery.dtsi new file mode 100644 index 0000000000..b347ec4c3c --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/battery.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: ap16l5j { + compatible = "panasonic,ap16l5j", "battery-smart"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/herobrine/i2c.dtsi b/zephyr/projects/herobrine/herobrine/i2c.dtsi new file mode 100644 index 0000000000..6f2d89aa71 --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/i2c.dtsi @@ -0,0 +1,39 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + ppc_port0_alt: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; + +&i2c2_0 { + ppc_port1: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; diff --git a/zephyr/projects/herobrine/herobrine/led_pins.dtsi b/zephyr/projects/herobrine/herobrine/led_pins.dtsi new file mode 100644 index 0000000000..c509ab1a64 --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/led_pins.dtsi @@ -0,0 +1,56 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off_left: color-off-left { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_LEFT_LED"; + led-pins = <&gpio_ec_chg_led_y_c1 0>, + <&gpio_ec_chg_led_w_c1 0>; + }; + + color_off_right: color-off-right { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_RIGHT_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 0>; + }; + + color_amber_left: color-amber-left { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_LEFT_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c1 1>, + <&gpio_ec_chg_led_w_c1 0>; + }; + + color_amber_right: color-amber-right { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_RIGHT_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c0 1>, + <&gpio_ec_chg_led_w_c0 0>; + }; + + color_white_left: color-white-left { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_LEFT_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&gpio_ec_chg_led_y_c1 0>, + <&gpio_ec_chg_led_w_c1 1>; + }; + + color_white_right: color-white-right { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_RIGHT_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 1>; + }; + }; +}; diff --git a/zephyr/projects/herobrine/herobrine/led_policy.dtsi b/zephyr/projects/herobrine/herobrine/led_policy.dtsi new file mode 100644 index 0000000000..13e5306deb --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/led_policy.dtsi @@ -0,0 +1,202 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge-left { + charge-state = "PWR_STATE_CHARGE"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED to Amber */ + color-1 { + led-color = <&color_amber_left>; + }; + }; + + power-state-charge-right { + charge-state = "PWR_STATE_CHARGE"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED to Amber */ + color-1 { + led-color = <&color_amber_right>; + }; + }; + + power-state-discharge-right-low { + charge-state = "PWR_STATE_DISCHARGE"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED - White 1 sec, off 3 sec */ + color-1 { + led-color = <&color_white_right>; + period-ms = <1000>; + }; + color-2 { + led-color = <&color_off_right>; + period-ms = <3000>; + }; + }; + + power-state-discharge-right { + charge-state = "PWR_STATE_DISCHARGE"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Turn off the right LED */ + color-1 { + led-color = <&color_off_right>; + }; + }; + + power-state-error-left { + charge-state = "PWR_STATE_ERROR"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED - White 2 sec, off 2 sec */ + color-1 { + led-color = <&color_white_left>; + period-ms = <2000>; + }; + color-2 { + led-color = <&color_off_right>; + period-ms = <2000>; + }; + }; + + power-state-error-right { + charge-state = "PWR_STATE_ERROR"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED - White 2 sec, off 2 sec */ + color-1 { + led-color = <&color_white_right>; + period-ms = <2000>; + }; + color-2 { + led-color = <&color_off_right>; + period-ms = <2000>; + }; + }; + + power-state-near-full-left { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED to White */ + color-1 { + led-color = <&color_white_left>; + }; + }; + + power-state-near-full-right { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED to White */ + color-1 { + led-color = <&color_white_right>; + }; + }; + + power-state-forced-idle-left { + charge-state = "PWR_STATE_FORCED_IDLE"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED - Amber 3 sec, Off 1 sec */ + color-1 { + led-color = <&color_amber_left>; + period-ms = <3000>; + }; + color-2 { + led-color = <&color_off_left>; + period-ms = <1000>; + }; + }; + + power-state-forced-idle-right { + charge-state = "PWR_STATE_FORCED_IDLE"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED - Amber 3 sec, Off 1 sec */ + color-1 { + led-color = <&color_amber_right>; + period-ms = <3000>; + }; + color-2 { + led-color = <&color_off_right>; + period-ms = <1000>; + }; + }; + + power-state-idle-left { + charge-state = "PWR_STATE_IDLE"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED to White */ + color-1 { + led-color = <&color_white_left>; + }; + }; + + power-state-idle-right { + charge-state = "PWR_STATE_IDLE"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED to White */ + color-1 { + led-color = <&color_white_right>; + }; + }; + }; +}; diff --git a/zephyr/projects/herobrine/herobrine/project.conf b/zephyr/projects/herobrine/herobrine/project.conf new file mode 100644 index 0000000000..bf39f65692 --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/project.conf @@ -0,0 +1,13 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Herobrine-NPCX9 reference-board-specific Kconfig settings. +CONFIG_BOARD_HEROBRINE=y + +# Sensors +CONFIG_PLATFORM_EC_ALS=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ALS_TCS3400=y +CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/herobrine/project.overlay b/zephyr/projects/herobrine/herobrine/project.overlay new file mode 100644 index 0000000000..a74db66815 --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/project.overlay @@ -0,0 +1,22 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" +#include "../display.dtsi" +#include "../gpio.dtsi" +#include "../motionsense.dtsi" +#include "../switchcap.dtsi" + +/* Herobrine project DTS includes*/ +#include "battery.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/herobrine/src/alt_dev_replacement.c b/zephyr/projects/herobrine/herobrine/src/alt_dev_replacement.c new file mode 100644 index 0000000000..00acd509f4 --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/src/alt_dev_replacement.c @@ -0,0 +1,36 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include +#include "usbc/ppc.h" +#include "hooks.h" +#include "cros_board_info.h" + +LOG_MODULE_REGISTER(alt_dev_replacement); + +#define BOARD_VERSION_UNKNOWN 0xffffffff + +/* Check board version to decide which ppc is used. */ +static bool board_has_alt_ppc(void) +{ + static uint32_t board_version = BOARD_VERSION_UNKNOWN; + + if (board_version == BOARD_VERSION_UNKNOWN) { + if (cbi_get_board_version(&board_version) != EC_SUCCESS) { + LOG_ERR("Failed to get board version."); + board_version = 0; + } + } + + return (board_version >= 1); +} + +static void check_alternate_devices(void) +{ + /* Configure the PPC driver */ + if (board_has_alt_ppc()) + /* Arg is the USB port number */ + PPC_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/herobrine/herobrine/usbc.dtsi b/zephyr/projects/herobrine/herobrine/usbc.dtsi new file mode 100644 index 0000000000..675286ecd7 --- /dev/null +++ b/zephyr/projects/herobrine/herobrine/usbc.dtsi @@ -0,0 +1,43 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + ppc_alt = <&ppc_port0_alt>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/hoglin/battery.dtsi b/zephyr/projects/herobrine/hoglin/battery.dtsi new file mode 100644 index 0000000000..11180c3988 --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/battery.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: 7c01 { + compatible = "ganfeng,7c01", "battery-smart"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/hoglin/gpio.dtsi b/zephyr/projects/herobrine/hoglin/gpio.dtsi new file mode 100644 index 0000000000..cb7babc9cf --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/gpio.dtsi @@ -0,0 +1,327 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpio5 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_y_c1: ec_chg_led_b_c1 { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c1: ec_chg_led_r_c1 { + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpiod 5 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; diff --git a/zephyr/projects/herobrine/hoglin/i2c.dtsi b/zephyr/projects/herobrine/hoglin/i2c.dtsi new file mode 100644 index 0000000000..ca2529cbaa --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/i2c.dtsi @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@1b { + compatible = "parade,ps8xxx"; + reg = <0x1b>; + }; +}; + +&i2c2_0 { + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + tcpc_port1: ps8xxx@1b { + compatible = "parade,ps8xxx"; + reg = <0x1b>; + }; +}; diff --git a/zephyr/projects/herobrine/hoglin/led_pins.dtsi b/zephyr/projects/herobrine/hoglin/led_pins.dtsi new file mode 100644 index 0000000000..7b125c5cac --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/led_pins.dtsi @@ -0,0 +1,33 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_b_c0 0>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_blue: color-blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pins = <&gpio_ec_chg_led_b_c0 1>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_red: color-red { + led-color = "LED_RED"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_RED"; + led-pins = <&gpio_ec_chg_led_b_c0 0>, + <&gpio_ec_chg_led_r_c0 1>; + }; + }; +}; diff --git a/zephyr/projects/herobrine/hoglin/led_policy.dtsi b/zephyr/projects/herobrine/hoglin/led_policy.dtsi new file mode 100644 index 0000000000..043dfbcaa5 --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/led_policy.dtsi @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* Blue 1 sec, off 3 sec */ + color-0 { + led-color = <&color_blue>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Red 1 sec, off 1 sec */ + color-0 { + led-color = <&color_red>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_red>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Red 2 sec, Blue 2 sec */ + color-0 { + led-color = <&color_red>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_blue>; + period-ms = <2000>; + }; + }; + + power-state-idle-default { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_red>; + }; + }; + }; +}; diff --git a/zephyr/projects/herobrine/hoglin/motionsense.dtsi b/zephyr/projects/herobrine/hoglin/motionsense.dtsi new file mode 100644 index 0000000000..c3935178ff --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/motionsense.dtsi @@ -0,0 +1,241 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + tcs3400-int = &als_clear; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + + tcs_clear_data: tcs3400-clear-drv-data { + compatible = "cros-ec,drvdata-tcs3400-clear"; + status = "okay"; + + als-drv-data { + compatible = "cros-ec,accelgyro-als-drv-data"; + als-cal { + scale = <1>; + uscale = <0>; + offset = <0>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + + tcs_rgb_data: tcs3400-rgb-drv-data { + compatible = "cros-ec,drvdata-tcs3400-rgb"; + status = "okay"; + + /* node for rgb_calibration_t defined in accelgyro.h */ + rgb_calibration { + compatible = + "cros-ec,accelgyro-rgb-calibration"; + + irt = <1>; + + rgb-cal-x { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-y { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-z { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma4xx_data>; + i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + + als_clear: base-als-clear { + compatible = "cros-ec,tcs3400-clear"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + port = <&i2c_sensor>; + default-range = <0x10000>; + drv-data = <&tcs_clear_data>; + i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + /* Run ALS sensor in S0 */ + odr = <1000>; + }; + }; + }; + + base-als-rgb { + compatible = "cros-ec,tcs3400-rgb"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + default-range = <0x10000>; /* scale = 1x, uscale = 0 */ + drv-data = <&tcs_rgb_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* list of entries for motion_als_sensors */ + als-sensors = <&als_clear>; + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel &als_clear>; + }; +}; diff --git a/zephyr/projects/herobrine/hoglin/project.conf b/zephyr/projects/herobrine/hoglin/project.conf new file mode 100644 index 0000000000..c6e20937c0 --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/project.conf @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Hoglin reference-board-specific Kconfig settings. +CONFIG_BOARD_HOGLIN=y +CONFIG_PLATFORM_EC_ACCEL_BMA255=n +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y + +# Sensors +CONFIG_PLATFORM_EC_ALS=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ALS_TCS3400=y +CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/hoglin/project.overlay b/zephyr/projects/herobrine/hoglin/project.overlay new file mode 100644 index 0000000000..d68a5a80d1 --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" + +/* Hoglin project DTS includes*/ +#include "battery.dtsi" +#include "gpio.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "switchcap.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/hoglin/switchcap.dtsi b/zephyr/projects/herobrine/hoglin/switchcap.dtsi new file mode 100644 index 0000000000..7c083667a1 --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/switchcap.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + switchcap { + compatible = "switchcap-gpio"; + enable-pin = <&gpio_switchcap_on>; + poff-delay-ms = <550>; + }; +}; diff --git a/zephyr/projects/herobrine/hoglin/usbc.dtsi b/zephyr/projects/herobrine/hoglin/usbc.dtsi new file mode 100644 index 0000000000..20bd48382f --- /dev/null +++ b/zephyr/projects/herobrine/hoglin/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/i2c.dtsi b/zephyr/projects/herobrine/i2c.dtsi new file mode 100644 index 0000000000..b1ed0242c0 --- /dev/null +++ b/zephyr/projects/herobrine/i2c.dtsi @@ -0,0 +1,157 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + i2c-0 = &i2c0_0; + i2c-1 = &i2c1_0; + i2c-2 = &i2c2_0; + i2c-3 = &i2c3_0; + i2c-4 = &i2c4_1; + i2c-5 = &i2c5_0; + i2c-7 = &i2c7_0; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_power: power { + i2c-port = <&i2c0_0>; + remote-port = <0>; + enum-names = "I2C_PORT_POWER", + "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY", + "I2C_PORT_CHARGER"; + }; + i2c_tcpc0: tcpc0 { + i2c-port = <&i2c1_0>; + dynamic-speed; + enum-names = "I2C_PORT_TCPC0"; + }; + i2c_tcpc1: tcpc1 { + i2c-port = <&i2c2_0>; + dynamic-speed; + enum-names = "I2C_PORT_TCPC1"; + }; + rtc { + i2c-port = <&i2c4_1>; + enum-names = "I2C_PORT_RTC"; + }; + i2c_eeprom: eeprom { + i2c-port = <&i2c5_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_sensor: sensor { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_SENSOR", + "I2C_PORT_ACCEL"; + }; + }; + + +}; + +&i2c0_0 { + label = "I2C_POWER"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + charger: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + label = "I2C_USB_C0_PD"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + label = "I2C_USB_C1_PD"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + /* Not used as no WLC connected */ + clock-frequency = ; +}; + +&i2c4_1 { + label = "I2C_RTC"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; + pinctrl-names = "default"; + + pcf85063a: pcf85063a@51 { + compatible = "nxp,rtc-pcf85063a"; + reg = <0x51>; + int-pin = <&gpio_rtc_ec_wake_odl>; + }; +}; + +&i2c_ctrl4 { + status = "okay"; +}; + +&i2c5_0 { + label = "I2C_EEPROM"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c1_bc12>; + }; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c7_0 { + label = "I2C_SENSOR"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/projects/herobrine/i2c_common.dtsi b/zephyr/projects/herobrine/i2c_common.dtsi deleted file mode 100644 index b1ed0242c0..0000000000 --- a/zephyr/projects/herobrine/i2c_common.dtsi +++ /dev/null @@ -1,157 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - i2c-0 = &i2c0_0; - i2c-1 = &i2c1_0; - i2c-2 = &i2c2_0; - i2c-3 = &i2c3_0; - i2c-4 = &i2c4_1; - i2c-5 = &i2c5_0; - i2c-7 = &i2c7_0; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_power: power { - i2c-port = <&i2c0_0>; - remote-port = <0>; - enum-names = "I2C_PORT_POWER", - "I2C_PORT_BATTERY", - "I2C_PORT_VIRTUAL_BATTERY", - "I2C_PORT_CHARGER"; - }; - i2c_tcpc0: tcpc0 { - i2c-port = <&i2c1_0>; - dynamic-speed; - enum-names = "I2C_PORT_TCPC0"; - }; - i2c_tcpc1: tcpc1 { - i2c-port = <&i2c2_0>; - dynamic-speed; - enum-names = "I2C_PORT_TCPC1"; - }; - rtc { - i2c-port = <&i2c4_1>; - enum-names = "I2C_PORT_RTC"; - }; - i2c_eeprom: eeprom { - i2c-port = <&i2c5_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_sensor: sensor { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_SENSOR", - "I2C_PORT_ACCEL"; - }; - }; - - -}; - -&i2c0_0 { - label = "I2C_POWER"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - charger: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - label = "I2C_USB_C0_PD"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - label = "I2C_USB_C1_PD"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - /* Not used as no WLC connected */ - clock-frequency = ; -}; - -&i2c4_1 { - label = "I2C_RTC"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; - pinctrl-names = "default"; - - pcf85063a: pcf85063a@51 { - compatible = "nxp,rtc-pcf85063a"; - reg = <0x51>; - int-pin = <&gpio_rtc_ec_wake_odl>; - }; -}; - -&i2c_ctrl4 { - status = "okay"; -}; - -&i2c5_0 { - label = "I2C_EEPROM"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c1_bc12>; - }; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c7_0 { - label = "I2C_SENSOR"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/herobrine/i2c_evoker.dts b/zephyr/projects/herobrine/i2c_evoker.dts deleted file mode 100644 index 7023d08c8d..0000000000 --- a/zephyr/projects/herobrine/i2c_evoker.dts +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "i2c_common.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - ppc_port0_alt: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - ppc_port1_alt: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/projects/herobrine/i2c_herobrine.dts b/zephyr/projects/herobrine/i2c_herobrine.dts deleted file mode 100644 index 92c68f4215..0000000000 --- a/zephyr/projects/herobrine/i2c_herobrine.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "i2c_common.dtsi" - -&i2c1_0 { - ppc_port0: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - ppc_port0_alt: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/projects/herobrine/i2c_hoglin.dts b/zephyr/projects/herobrine/i2c_hoglin.dts deleted file mode 100644 index 504dbb9248..0000000000 --- a/zephyr/projects/herobrine/i2c_hoglin.dts +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "i2c_common.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@1b { - compatible = "parade,ps8xxx"; - reg = <0x1b>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@1b { - compatible = "parade,ps8xxx"; - reg = <0x1b>; - }; -}; diff --git a/zephyr/projects/herobrine/i2c_villager.dts b/zephyr/projects/herobrine/i2c_villager.dts deleted file mode 100644 index efdf88ac38..0000000000 --- a/zephyr/projects/herobrine/i2c_villager.dts +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "i2c_common.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/projects/herobrine/i2c_zombie.dts b/zephyr/projects/herobrine/i2c_zombie.dts deleted file mode 100644 index efdf88ac38..0000000000 --- a/zephyr/projects/herobrine/i2c_zombie.dts +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "i2c_common.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/projects/herobrine/interrupts.dts b/zephyr/projects/herobrine/interrupts.dts deleted file mode 100644 index 82650bfc51..0000000000 --- a/zephyr/projects/herobrine/interrupts.dts +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp_l; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_ac_present: ac_present { - irq-pin = <&gpio_chg_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open_ec>; - flags = ; - handler = "lid_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_ec_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_ec_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_ap_rst: ap_rst { - irq-pin = <&gpio_ap_rst_l>; - flags = ; - handler = "chipset_ap_rst_interrupt"; - }; - int_ap_suspend: ap_suspend { - irq-pin = <&gpio_ap_suspend>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_power_good: power_good { - irq-pin = <&gpio_mb_power_good>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ps_hold: ps_hold { - irq-pin = <&gpio_ps_hold>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_warm_reset: warm_reset { - irq-pin = <&gpio_warm_reset_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_usb_c0_pd: usb_c0_pd { - irq-pin = <&gpio_usb_c0_pd_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_pd: usb_c1_pd { - irq-pin = <&gpio_usb_c1_pd_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_swctl: usb_c0_swctl { - irq-pin = <&gpio_usb_c0_swctl_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_swctl: usb_c1_swctl { - irq-pin = <&gpio_usb_c1_swctl_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_l>; - flags = ; - handler = "usb0_evt"; - }; - int_usb_c1_bc12: usb_c1_bc12 { - irq-pin = <&gpio_usb_c1_bc12_int_l>; - flags = ; - handler = "usb1_evt"; - }; - int_usb_a0_oc: usb_a0_oc { - irq-pin = <&gpio_usb_a0_oc_odl>; - flags = ; - handler = "usba_oc_interrupt"; - }; - int_accel_gyro: accel_gyro { - irq-pin = <&gpio_accel_gyro_int_l>; - flags = ; - handler = "bmi260_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/interrupts.dtsi b/zephyr/projects/herobrine/interrupts.dtsi new file mode 100644 index 0000000000..82650bfc51 --- /dev/null +++ b/zephyr/projects/herobrine/interrupts.dtsi @@ -0,0 +1,115 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp_l; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_ac_present: ac_present { + irq-pin = <&gpio_chg_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open_ec>; + flags = ; + handler = "lid_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_ec_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_ec_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_ap_rst: ap_rst { + irq-pin = <&gpio_ap_rst_l>; + flags = ; + handler = "chipset_ap_rst_interrupt"; + }; + int_ap_suspend: ap_suspend { + irq-pin = <&gpio_ap_suspend>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_power_good: power_good { + irq-pin = <&gpio_mb_power_good>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ps_hold: ps_hold { + irq-pin = <&gpio_ps_hold>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_warm_reset: warm_reset { + irq-pin = <&gpio_warm_reset_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_usb_c0_pd: usb_c0_pd { + irq-pin = <&gpio_usb_c0_pd_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_pd: usb_c1_pd { + irq-pin = <&gpio_usb_c1_pd_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_swctl: usb_c0_swctl { + irq-pin = <&gpio_usb_c0_swctl_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_swctl: usb_c1_swctl { + irq-pin = <&gpio_usb_c1_swctl_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_l>; + flags = ; + handler = "usb0_evt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_l>; + flags = ; + handler = "usb1_evt"; + }; + int_usb_a0_oc: usb_a0_oc { + irq-pin = <&gpio_usb_a0_oc_odl>; + flags = ; + handler = "usba_oc_interrupt"; + }; + int_accel_gyro: accel_gyro { + irq-pin = <&gpio_accel_gyro_int_l>; + flags = ; + handler = "bmi260_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/keyboard.dts b/zephyr/projects/herobrine/keyboard.dts deleted file mode 100644 index 3b7e830f2f..0000000000 --- a/zephyr/projects/herobrine/keyboard.dts +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm3 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; - generic-pwm-channel = <0>; - }; -}; - -&pwm3 { - status = "okay"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/herobrine/keyboard.dtsi b/zephyr/projects/herobrine/keyboard.dtsi new file mode 100644 index 0000000000..3b7e830f2f --- /dev/null +++ b/zephyr/projects/herobrine/keyboard.dtsi @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm3 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; + generic-pwm-channel = <0>; + }; +}; + +&pwm3 { + status = "okay"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/projects/herobrine/led_pins_evoker.dts b/zephyr/projects/herobrine/led_pins_evoker.dts deleted file mode 100644 index ff2dc0e36c..0000000000 --- a/zephyr/projects/herobrine/led_pins_evoker.dts +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_power_off: color-power-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&gpio_ec_chg_led_w_c1 0>; - }; - - color_power_white: color-power-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&gpio_ec_chg_led_w_c1 1>; - }; - - color_battery_off: color-battery-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_battery_amber: color-battery-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_battery_white: color-battery-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 1>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_battery_red: color-battery-red { - led-color = "LED_RED"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_pins_herobrine.dts b/zephyr/projects/herobrine/led_pins_herobrine.dts deleted file mode 100644 index c509ab1a64..0000000000 --- a/zephyr/projects/herobrine/led_pins_herobrine.dts +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off_left: color-off-left { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_LEFT_LED"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_w_c1 0>; - }; - - color_off_right: color-off-right { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_RIGHT_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>; - }; - - color_amber_left: color-amber-left { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_LEFT_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_w_c1 0>; - }; - - color_amber_right: color-amber-right { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_RIGHT_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_w_c0 0>; - }; - - color_white_left: color-white-left { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_LEFT_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_w_c1 1>; - }; - - color_white_right: color-white-right { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_RIGHT_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_pins_hoglin.dts b/zephyr/projects/herobrine/led_pins_hoglin.dts deleted file mode 100644 index 7b125c5cac..0000000000 --- a/zephyr/projects/herobrine/led_pins_hoglin.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_b_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_b_c0 1>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_red: color-red { - led-color = "LED_RED"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_RED"; - led-pins = <&gpio_ec_chg_led_b_c0 0>, - <&gpio_ec_chg_led_r_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_pins_villager.dts b/zephyr/projects/herobrine/led_pins_villager.dts deleted file mode 100644 index b0913cdbce..0000000000 --- a/zephyr/projects/herobrine/led_pins_villager.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_b_c0 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_pins_zombie.dts b/zephyr/projects/herobrine/led_pins_zombie.dts deleted file mode 100644 index b0913cdbce..0000000000 --- a/zephyr/projects/herobrine/led_pins_zombie.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_b_c0 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_policy_evoker.dts b/zephyr/projects/herobrine/led_policy_evoker.dts deleted file mode 100644 index fc17755ede..0000000000 --- a/zephyr/projects/herobrine/led_policy_evoker.dts +++ /dev/null @@ -1,86 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - battery-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_battery_amber>; - }; - }; - - battery-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_battery_white>; - }; - }; - - battery-state-discharge { - charge-state = "PWR_STATE_DISCHARGE"; - - color-0 { - led-color = <&color_battery_off>; - }; - }; - - battery-state-error { - charge-state = "PWR_STATE_ERROR"; - - color-0 { - led-color = <&color_battery_red>; - }; - }; - - /* force idle mode */ - battery-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Red 1 sec, White 1 sec */ - color-0 { - led-color = <&color_battery_red>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - }; - - pwr-power-state-s0 { - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_power_white>; - }; - }; - - power-state-s3 { - chipset-state = "POWER_S3"; - - /* white LED - on 1 sec, off 1 sec */ - color-0 { - led-color = <&color_power_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_power_off>; - period-ms = <1000>; - }; - }; - - power-state-s5 { - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_power_off>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_policy_herobrine.dts b/zephyr/projects/herobrine/led_policy_herobrine.dts deleted file mode 100644 index 13e5306deb..0000000000 --- a/zephyr/projects/herobrine/led_policy_herobrine.dts +++ /dev/null @@ -1,202 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge-left { - charge-state = "PWR_STATE_CHARGE"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED to Amber */ - color-1 { - led-color = <&color_amber_left>; - }; - }; - - power-state-charge-right { - charge-state = "PWR_STATE_CHARGE"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED to Amber */ - color-1 { - led-color = <&color_amber_right>; - }; - }; - - power-state-discharge-right-low { - charge-state = "PWR_STATE_DISCHARGE"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED - White 1 sec, off 3 sec */ - color-1 { - led-color = <&color_white_right>; - period-ms = <1000>; - }; - color-2 { - led-color = <&color_off_right>; - period-ms = <3000>; - }; - }; - - power-state-discharge-right { - charge-state = "PWR_STATE_DISCHARGE"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Turn off the right LED */ - color-1 { - led-color = <&color_off_right>; - }; - }; - - power-state-error-left { - charge-state = "PWR_STATE_ERROR"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED - White 2 sec, off 2 sec */ - color-1 { - led-color = <&color_white_left>; - period-ms = <2000>; - }; - color-2 { - led-color = <&color_off_right>; - period-ms = <2000>; - }; - }; - - power-state-error-right { - charge-state = "PWR_STATE_ERROR"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED - White 2 sec, off 2 sec */ - color-1 { - led-color = <&color_white_right>; - period-ms = <2000>; - }; - color-2 { - led-color = <&color_off_right>; - period-ms = <2000>; - }; - }; - - power-state-near-full-left { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED to White */ - color-1 { - led-color = <&color_white_left>; - }; - }; - - power-state-near-full-right { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED to White */ - color-1 { - led-color = <&color_white_right>; - }; - }; - - power-state-forced-idle-left { - charge-state = "PWR_STATE_FORCED_IDLE"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED - Amber 3 sec, Off 1 sec */ - color-1 { - led-color = <&color_amber_left>; - period-ms = <3000>; - }; - color-2 { - led-color = <&color_off_left>; - period-ms = <1000>; - }; - }; - - power-state-forced-idle-right { - charge-state = "PWR_STATE_FORCED_IDLE"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED - Amber 3 sec, Off 1 sec */ - color-1 { - led-color = <&color_amber_right>; - period-ms = <3000>; - }; - color-2 { - led-color = <&color_off_right>; - period-ms = <1000>; - }; - }; - - power-state-idle-left { - charge-state = "PWR_STATE_IDLE"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED to White */ - color-1 { - led-color = <&color_white_left>; - }; - }; - - power-state-idle-right { - charge-state = "PWR_STATE_IDLE"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED to White */ - color-1 { - led-color = <&color_white_right>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_policy_hoglin.dts b/zephyr/projects/herobrine/led_policy_hoglin.dts deleted file mode 100644 index 043dfbcaa5..0000000000 --- a/zephyr/projects/herobrine/led_policy_hoglin.dts +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* Blue 1 sec, off 3 sec */ - color-0 { - led-color = <&color_blue>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Red 1 sec, off 1 sec */ - color-0 { - led-color = <&color_red>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_red>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Red 2 sec, Blue 2 sec */ - color-0 { - led-color = <&color_red>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_blue>; - period-ms = <2000>; - }; - }; - - power-state-idle-default { - charge-state = "PWR_STATE_IDLE"; - - color-0 { - led-color = <&color_red>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_policy_villager.dts b/zephyr/projects/herobrine/led_policy_villager.dts deleted file mode 100644 index f8996a3f4b..0000000000 --- a/zephyr/projects/herobrine/led_policy_villager.dts +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Blue 2 sec, Amber 2 sec */ - color-0 { - led-color = <&color_blue>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - }; - - power-state-idle { - charge-state = "PWR_STATE_IDLE"; - - color-0 { - led-color = <&color_blue>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/led_policy_zombie.dts b/zephyr/projects/herobrine/led_policy_zombie.dts deleted file mode 100644 index f8996a3f4b..0000000000 --- a/zephyr/projects/herobrine/led_policy_zombie.dts +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Blue 2 sec, Amber 2 sec */ - color-0 { - led-color = <&color_blue>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - }; - - power-state-idle { - charge-state = "PWR_STATE_IDLE"; - - color-0 { - led-color = <&color_blue>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/motionsense.dts b/zephyr/projects/herobrine/motionsense.dts deleted file mode 100644 index 1955f43284..0000000000 --- a/zephyr/projects/herobrine/motionsense.dts +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - tcs3400-int = &als_clear; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma255_data: bma255-drv-data { - compatible = "cros-ec,drvdata-bma255"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - - tcs_clear_data: tcs3400-clear-drv-data { - compatible = "cros-ec,drvdata-tcs3400-clear"; - status = "okay"; - - als-drv-data { - compatible = "cros-ec,accelgyro-als-drv-data"; - als-cal { - scale = <1>; - uscale = <0>; - offset = <0>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - - tcs_rgb_data: tcs3400-rgb-drv-data { - compatible = "cros-ec,drvdata-tcs3400-rgb"; - status = "okay"; - - /* node for rgb_calibration_t defined in accelgyro.h */ - rgb_calibration { - compatible = - "cros-ec,accelgyro-rgb-calibration"; - - irt = <1>; - - rgb-cal-x { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-y { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-z { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma255"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma255_data>; - i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - - als_clear: base-als-clear { - compatible = "cros-ec,tcs3400-clear"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - port = <&i2c_sensor>; - default-range = <0x10000>; - drv-data = <&tcs_clear_data>; - i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - /* Run ALS sensor in S0 */ - odr = <1000>; - }; - }; - }; - - base-als-rgb { - compatible = "cros-ec,tcs3400-rgb"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - default-range = <0x10000>; /* scale = 1x, uscale = 0 */ - drv-data = <&tcs_rgb_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* list of entries for motion_als_sensors */ - als-sensors = <&als_clear>; - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel &als_clear>; - }; -}; diff --git a/zephyr/projects/herobrine/motionsense.dtsi b/zephyr/projects/herobrine/motionsense.dtsi new file mode 100644 index 0000000000..1955f43284 --- /dev/null +++ b/zephyr/projects/herobrine/motionsense.dtsi @@ -0,0 +1,241 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + tcs3400-int = &als_clear; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma255_data: bma255-drv-data { + compatible = "cros-ec,drvdata-bma255"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + + tcs_clear_data: tcs3400-clear-drv-data { + compatible = "cros-ec,drvdata-tcs3400-clear"; + status = "okay"; + + als-drv-data { + compatible = "cros-ec,accelgyro-als-drv-data"; + als-cal { + scale = <1>; + uscale = <0>; + offset = <0>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + + tcs_rgb_data: tcs3400-rgb-drv-data { + compatible = "cros-ec,drvdata-tcs3400-rgb"; + status = "okay"; + + /* node for rgb_calibration_t defined in accelgyro.h */ + rgb_calibration { + compatible = + "cros-ec,accelgyro-rgb-calibration"; + + irt = <1>; + + rgb-cal-x { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-y { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-z { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma255"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma255_data>; + i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + + als_clear: base-als-clear { + compatible = "cros-ec,tcs3400-clear"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + port = <&i2c_sensor>; + default-range = <0x10000>; + drv-data = <&tcs_clear_data>; + i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + /* Run ALS sensor in S0 */ + odr = <1000>; + }; + }; + }; + + base-als-rgb { + compatible = "cros-ec,tcs3400-rgb"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + default-range = <0x10000>; /* scale = 1x, uscale = 0 */ + drv-data = <&tcs_rgb_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* list of entries for motion_als_sensors */ + als-sensors = <&als_clear>; + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel &als_clear>; + }; +}; diff --git a/zephyr/projects/herobrine/motionsense_evoker.dts b/zephyr/projects/herobrine/motionsense_evoker.dts deleted file mode 100644 index aa7646e0b3..0000000000 --- a/zephyr/projects/herobrine/motionsense_evoker.dts +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <(-1) 0 0 - 0 (-1) 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma4xx_data>; - i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/herobrine/motionsense_hoglin.dts b/zephyr/projects/herobrine/motionsense_hoglin.dts deleted file mode 100644 index c3935178ff..0000000000 --- a/zephyr/projects/herobrine/motionsense_hoglin.dts +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - tcs3400-int = &als_clear; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <(-1) 0 0 - 0 (-1) 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - - tcs_clear_data: tcs3400-clear-drv-data { - compatible = "cros-ec,drvdata-tcs3400-clear"; - status = "okay"; - - als-drv-data { - compatible = "cros-ec,accelgyro-als-drv-data"; - als-cal { - scale = <1>; - uscale = <0>; - offset = <0>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - - tcs_rgb_data: tcs3400-rgb-drv-data { - compatible = "cros-ec,drvdata-tcs3400-rgb"; - status = "okay"; - - /* node for rgb_calibration_t defined in accelgyro.h */ - rgb_calibration { - compatible = - "cros-ec,accelgyro-rgb-calibration"; - - irt = <1>; - - rgb-cal-x { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-y { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-z { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma4xx_data>; - i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - - als_clear: base-als-clear { - compatible = "cros-ec,tcs3400-clear"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - port = <&i2c_sensor>; - default-range = <0x10000>; - drv-data = <&tcs_clear_data>; - i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - /* Run ALS sensor in S0 */ - odr = <1000>; - }; - }; - }; - - base-als-rgb { - compatible = "cros-ec,tcs3400-rgb"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - default-range = <0x10000>; /* scale = 1x, uscale = 0 */ - drv-data = <&tcs_rgb_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* list of entries for motion_als_sensors */ - als-sensors = <&als_clear>; - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel &als_clear>; - }; -}; diff --git a/zephyr/projects/herobrine/motionsense_villager.dts b/zephyr/projects/herobrine/motionsense_villager.dts deleted file mode 100644 index 31d00e04a5..0000000000 --- a/zephyr/projects/herobrine/motionsense_villager.dts +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - kx022_data: kx022-drv-data { - compatible = "cros-ec,drvdata-kionix"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,kx022"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&kx022_data>; - i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/herobrine/motionsense_zombie.dts b/zephyr/projects/herobrine/motionsense_zombie.dts deleted file mode 100644 index e069564b35..0000000000 --- a/zephyr/projects/herobrine/motionsense_zombie.dts +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - kx022_data: kx022-drv-data { - compatible = "cros-ec,drvdata-kionix"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,kx022"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&kx022_data>; - i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/herobrine/prj.conf b/zephyr/projects/herobrine/prj.conf deleted file mode 100644 index 3391e60dce..0000000000 --- a/zephyr/projects/herobrine/prj.conf +++ /dev/null @@ -1,160 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_BRINGUP=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_CBI_GPIO=y -CONFIG_KERNEL_SHELL=y -CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y - -# I2C options -CONFIG_I2C=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y -CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y - -# Shell history and tab autocompletion (for convenience) -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=n -CONFIG_PLATFORM_EC_LED_DT=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# Application Processor is Qualcomm SC7280 -CONFIG_AP_ARM_QUALCOMM_SC7280=y - -# GPIO Switchcap -CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y - -# Board version is selected over GPIO board ID pins. -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y - -# Power Sequencing -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y -CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y - -# MKBP event -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_CMD_BUTTON=y -CONFIG_CROS_KB_RAW_NPCX=y - -# ADC -CONFIG_ADC=y -CONFIG_ADC_SHELL=n - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y -CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y -CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y -CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y -CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION" -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=12500 -CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y - -# USB-A -CONFIG_PLATFORM_EC_USBA=y - -# USB-C -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n -CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y -CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y -CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_DPS=y -CONFIG_PLATFORM_EC_USB_PD_REV30=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=2 - -# USB ID -# This is allocated specifically for Herobrine -# http://google3/hardware/standards/usb/ -# TODO(b/183608112): Move to device tree -CONFIG_PLATFORM_EC_USB_PID=0x5055 - -# RTC -CONFIG_PLATFORM_EC_RTC=y -CONFIG_CROS_RTC_NXP_PCF85063A=y -CONFIG_PLATFORM_EC_HOSTCMD_RTC=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM=y - -# EC software sync -CONFIG_PLATFORM_EC_VBOOT_HASH=y - -# Sensors -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 - -# Sensor Drivers -CONFIG_PLATFORM_EC_ACCEL_BMA255=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -CONFIG_SYSCON=y -CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y diff --git a/zephyr/projects/herobrine/prj_evoker.conf b/zephyr/projects/herobrine/prj_evoker.conf deleted file mode 100644 index b4a5fce160..0000000000 --- a/zephyr/projects/herobrine/prj_evoker.conf +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Evoker board-specific Kconfig settings. -CONFIG_BOARD_EVOKER=y - -# Disable type-c port sourcing 3A -CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0 - -CONFIG_PLATFORM_EC_ACCEL_BMA255=n -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y - -# ISL9238C disable the CMOUT latch function. -CONFIG_PLATFORM_EC_ISL9238C_DISABLE_CMOUT_LATCH=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y \ No newline at end of file diff --git a/zephyr/projects/herobrine/prj_herobrine.conf b/zephyr/projects/herobrine/prj_herobrine.conf deleted file mode 100644 index bf39f65692..0000000000 --- a/zephyr/projects/herobrine/prj_herobrine.conf +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Herobrine-NPCX9 reference-board-specific Kconfig settings. -CONFIG_BOARD_HEROBRINE=y - -# Sensors -CONFIG_PLATFORM_EC_ALS=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ALS_TCS3400=y -CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/prj_hoglin.conf b/zephyr/projects/herobrine/prj_hoglin.conf deleted file mode 100644 index c6e20937c0..0000000000 --- a/zephyr/projects/herobrine/prj_hoglin.conf +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Hoglin reference-board-specific Kconfig settings. -CONFIG_BOARD_HOGLIN=y -CONFIG_PLATFORM_EC_ACCEL_BMA255=n -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y - -# Sensors -CONFIG_PLATFORM_EC_ALS=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ALS_TCS3400=y -CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/prj_villager.conf b/zephyr/projects/herobrine/prj_villager.conf deleted file mode 100644 index 35eebe6d99..0000000000 --- a/zephyr/projects/herobrine/prj_villager.conf +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Villager board-specific Kconfig settings. -CONFIG_BOARD_VILLAGER=y - -CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/projects/herobrine/prj_zoglin.conf b/zephyr/projects/herobrine/prj_zoglin.conf deleted file mode 100644 index 7f96cf6c79..0000000000 --- a/zephyr/projects/herobrine/prj_zoglin.conf +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Zoglin reference-board-specific Kconfig settings. -CONFIG_BOARD_ZOGLIN=y -CONFIG_PLATFORM_EC_ACCEL_BMA255=n -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y - -# Sensors -CONFIG_PLATFORM_EC_ALS=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ALS_TCS3400=y -CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/prj_zombie.conf b/zephyr/projects/herobrine/prj_zombie.conf deleted file mode 100644 index 037ab5cc05..0000000000 --- a/zephyr/projects/herobrine/prj_zombie.conf +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Zombie board-specific Kconfig settings. -CONFIG_BOARD_ZOMBIE=y - -CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/projects/herobrine/program.conf b/zephyr/projects/herobrine/program.conf new file mode 100644 index 0000000000..3391e60dce --- /dev/null +++ b/zephyr/projects/herobrine/program.conf @@ -0,0 +1,160 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_BRINGUP=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_CBI_GPIO=y +CONFIG_KERNEL_SHELL=y +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y + +# I2C options +CONFIG_I2C=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y +CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y + +# Shell history and tab autocompletion (for convenience) +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=n +CONFIG_PLATFORM_EC_LED_DT=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# Application Processor is Qualcomm SC7280 +CONFIG_AP_ARM_QUALCOMM_SC7280=y + +# GPIO Switchcap +CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y + +# Board version is selected over GPIO board ID pins. +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y + +# Power Sequencing +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y +CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y +CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y + +# MKBP event +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_CMD_BUTTON=y +CONFIG_CROS_KB_RAW_NPCX=y + +# ADC +CONFIG_ADC=y +CONFIG_ADC_SHELL=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y +CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y +CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y +CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION" +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=12500 +CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y + +# USB-A +CONFIG_PLATFORM_EC_USBA=y + +# USB-C +CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n +CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y +CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y +CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_DPS=y +CONFIG_PLATFORM_EC_USB_PD_REV30=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=2 + +# USB ID +# This is allocated specifically for Herobrine +# http://google3/hardware/standards/usb/ +# TODO(b/183608112): Move to device tree +CONFIG_PLATFORM_EC_USB_PID=0x5055 + +# RTC +CONFIG_PLATFORM_EC_RTC=y +CONFIG_CROS_RTC_NXP_PCF85063A=y +CONFIG_PLATFORM_EC_HOSTCMD_RTC=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM=y + +# EC software sync +CONFIG_PLATFORM_EC_VBOOT_HASH=y + +# Sensors +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# Sensor Drivers +CONFIG_PLATFORM_EC_ACCEL_BMA255=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +CONFIG_SYSCON=y +CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y diff --git a/zephyr/projects/herobrine/src/herobrine/alt_dev_replacement.c b/zephyr/projects/herobrine/src/herobrine/alt_dev_replacement.c deleted file mode 100644 index 00acd509f4..0000000000 --- a/zephyr/projects/herobrine/src/herobrine/alt_dev_replacement.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include -#include "usbc/ppc.h" -#include "hooks.h" -#include "cros_board_info.h" - -LOG_MODULE_REGISTER(alt_dev_replacement); - -#define BOARD_VERSION_UNKNOWN 0xffffffff - -/* Check board version to decide which ppc is used. */ -static bool board_has_alt_ppc(void) -{ - static uint32_t board_version = BOARD_VERSION_UNKNOWN; - - if (board_version == BOARD_VERSION_UNKNOWN) { - if (cbi_get_board_version(&board_version) != EC_SUCCESS) { - LOG_ERR("Failed to get board version."); - board_version = 0; - } - } - - return (board_version >= 1); -} - -static void check_alternate_devices(void) -{ - /* Configure the PPC driver */ - if (board_has_alt_ppc()) - /* Arg is the USB port number */ - PPC_ENABLE_ALTERNATE(0); -} -DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/herobrine/switchcap.dts b/zephyr/projects/herobrine/switchcap.dts deleted file mode 100644 index ed200a0c6f..0000000000 --- a/zephyr/projects/herobrine/switchcap.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - switchcap { - compatible = "switchcap-gpio"; - enable-pin = <&gpio_switchcap_on>; - power-good-pin = <&gpio_switchcap_pg>; - }; -}; diff --git a/zephyr/projects/herobrine/switchcap.dtsi b/zephyr/projects/herobrine/switchcap.dtsi new file mode 100644 index 0000000000..ed200a0c6f --- /dev/null +++ b/zephyr/projects/herobrine/switchcap.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + switchcap { + compatible = "switchcap-gpio"; + enable-pin = <&gpio_switchcap_on>; + power-good-pin = <&gpio_switchcap_pg>; + }; +}; diff --git a/zephyr/projects/herobrine/switchcap_hoglin.dts b/zephyr/projects/herobrine/switchcap_hoglin.dts deleted file mode 100644 index 7c083667a1..0000000000 --- a/zephyr/projects/herobrine/switchcap_hoglin.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - switchcap { - compatible = "switchcap-gpio"; - enable-pin = <&gpio_switchcap_on>; - poff-delay-ms = <550>; - }; -}; diff --git a/zephyr/projects/herobrine/usbc_evoker.dts b/zephyr/projects/herobrine/usbc_evoker.dts deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/projects/herobrine/usbc_evoker.dts +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/usbc_herobrine.dts b/zephyr/projects/herobrine/usbc_herobrine.dts deleted file mode 100644 index 675286ecd7..0000000000 --- a/zephyr/projects/herobrine/usbc_herobrine.dts +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - ppc_alt = <&ppc_port0_alt>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/usbc_hoglin.dts b/zephyr/projects/herobrine/usbc_hoglin.dts deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/projects/herobrine/usbc_hoglin.dts +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/usbc_villager.dts b/zephyr/projects/herobrine/usbc_villager.dts deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/projects/herobrine/usbc_villager.dts +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/usbc_zombie.dts b/zephyr/projects/herobrine/usbc_zombie.dts deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/projects/herobrine/usbc_zombie.dts +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/villager/battery.dtsi b/zephyr/projects/herobrine/villager/battery.dtsi new file mode 100644 index 0000000000..dafd473a6e --- /dev/null +++ b/zephyr/projects/herobrine/villager/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: ap19a5k { + compatible = "panasonic,ap19a5k", "battery-smart"; + }; + ap19a8k { + compatible = "lgc,ap19a8k", "battery-smart"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/villager/gpio.dtsi b/zephyr/projects/herobrine/villager/gpio.dtsi new file mode 100644 index 0000000000..1e7625ff6a --- /dev/null +++ b/zephyr/projects/herobrine/villager/gpio.dtsi @@ -0,0 +1,323 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 3 0>, + <&gpioc 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpio5 0 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; diff --git a/zephyr/projects/herobrine/villager/i2c.dtsi b/zephyr/projects/herobrine/villager/i2c.dtsi new file mode 100644 index 0000000000..02d1729dd1 --- /dev/null +++ b/zephyr/projects/herobrine/villager/i2c.dtsi @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; + +&i2c2_0 { + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; diff --git a/zephyr/projects/herobrine/villager/led_pins.dtsi b/zephyr/projects/herobrine/villager/led_pins.dtsi new file mode 100644 index 0000000000..b0913cdbce --- /dev/null +++ b/zephyr/projects/herobrine/villager/led_pins.dtsi @@ -0,0 +1,33 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_b_c0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c0 1>, + <&gpio_ec_chg_led_b_c0 0>; + }; + + color_blue: color-blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_b_c0 1>; + }; + }; +}; diff --git a/zephyr/projects/herobrine/villager/led_policy.dtsi b/zephyr/projects/herobrine/villager/led_policy.dtsi new file mode 100644 index 0000000000..f8996a3f4b --- /dev/null +++ b/zephyr/projects/herobrine/villager/led_policy.dtsi @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Blue 2 sec, Amber 2 sec */ + color-0 { + led-color = <&color_blue>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + }; + + power-state-idle { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_blue>; + }; + }; + }; +}; diff --git a/zephyr/projects/herobrine/villager/motionsense.dtsi b/zephyr/projects/herobrine/villager/motionsense.dtsi new file mode 100644 index 0000000000..31d00e04a5 --- /dev/null +++ b/zephyr/projects/herobrine/villager/motionsense.dtsi @@ -0,0 +1,148 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + kx022_data: kx022-drv-data { + compatible = "cros-ec,drvdata-kionix"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,kx022"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&kx022_data>; + i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/projects/herobrine/villager/project.conf b/zephyr/projects/herobrine/villager/project.conf new file mode 100644 index 0000000000..35eebe6d99 --- /dev/null +++ b/zephyr/projects/herobrine/villager/project.conf @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Villager board-specific Kconfig settings. +CONFIG_BOARD_VILLAGER=y + +CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/projects/herobrine/villager/project.overlay b/zephyr/projects/herobrine/villager/project.overlay new file mode 100644 index 0000000000..a18d6416dd --- /dev/null +++ b/zephyr/projects/herobrine/villager/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" +#include "../switchcap.dtsi" + +/* Villager project DTS includes*/ +#include "battery.dtsi" +#include "gpio.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/villager/usbc.dtsi b/zephyr/projects/herobrine/villager/usbc.dtsi new file mode 100644 index 0000000000..20bd48382f --- /dev/null +++ b/zephyr/projects/herobrine/villager/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/zoglin/project.conf b/zephyr/projects/herobrine/zoglin/project.conf new file mode 100644 index 0000000000..7f96cf6c79 --- /dev/null +++ b/zephyr/projects/herobrine/zoglin/project.conf @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Zoglin reference-board-specific Kconfig settings. +CONFIG_BOARD_ZOGLIN=y +CONFIG_PLATFORM_EC_ACCEL_BMA255=n +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y + +# Sensors +CONFIG_PLATFORM_EC_ALS=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ALS_TCS3400=y +CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/zoglin/project.overlay b/zephyr/projects/herobrine/zoglin/project.overlay new file mode 100644 index 0000000000..55f7dd73fc --- /dev/null +++ b/zephyr/projects/herobrine/zoglin/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" + +/* Zoglin project DTS includes*/ +#include "../hoglin/battery.dtsi" +#include "../hoglin/gpio.dtsi" +#include "../hoglin/i2c.dtsi" +#include "../hoglin/led_pins.dtsi" +#include "../hoglin/led_policy.dtsi" +#include "../hoglin/motionsense.dtsi" +#include "../hoglin/switchcap.dtsi" +#include "../hoglin/usbc.dtsi" diff --git a/zephyr/projects/herobrine/zombie/battery.dtsi b/zephyr/projects/herobrine/zombie/battery.dtsi new file mode 100644 index 0000000000..dafd473a6e --- /dev/null +++ b/zephyr/projects/herobrine/zombie/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: ap19a5k { + compatible = "panasonic,ap19a5k", "battery-smart"; + }; + ap19a8k { + compatible = "lgc,ap19a8k", "battery-smart"; + }; + }; +}; diff --git a/zephyr/projects/herobrine/zombie/gpio.dtsi b/zephyr/projects/herobrine/zombie/gpio.dtsi new file mode 100644 index 0000000000..14ed1f54d6 --- /dev/null +++ b/zephyr/projects/herobrine/zombie/gpio.dtsi @@ -0,0 +1,323 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 3 0>, + <&gpioc 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpio5 0 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; diff --git a/zephyr/projects/herobrine/zombie/i2c.dtsi b/zephyr/projects/herobrine/zombie/i2c.dtsi new file mode 100644 index 0000000000..02d1729dd1 --- /dev/null +++ b/zephyr/projects/herobrine/zombie/i2c.dtsi @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; + +&i2c2_0 { + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; diff --git a/zephyr/projects/herobrine/zombie/led_pins.dtsi b/zephyr/projects/herobrine/zombie/led_pins.dtsi new file mode 100644 index 0000000000..b0913cdbce --- /dev/null +++ b/zephyr/projects/herobrine/zombie/led_pins.dtsi @@ -0,0 +1,33 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_b_c0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c0 1>, + <&gpio_ec_chg_led_b_c0 0>; + }; + + color_blue: color-blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_b_c0 1>; + }; + }; +}; diff --git a/zephyr/projects/herobrine/zombie/led_policy.dtsi b/zephyr/projects/herobrine/zombie/led_policy.dtsi new file mode 100644 index 0000000000..f8996a3f4b --- /dev/null +++ b/zephyr/projects/herobrine/zombie/led_policy.dtsi @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Blue 2 sec, Amber 2 sec */ + color-0 { + led-color = <&color_blue>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + }; + + power-state-idle { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_blue>; + }; + }; + }; +}; diff --git a/zephyr/projects/herobrine/zombie/motionsense.dtsi b/zephyr/projects/herobrine/zombie/motionsense.dtsi new file mode 100644 index 0000000000..e069564b35 --- /dev/null +++ b/zephyr/projects/herobrine/zombie/motionsense.dtsi @@ -0,0 +1,148 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + kx022_data: kx022-drv-data { + compatible = "cros-ec,drvdata-kionix"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,kx022"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&kx022_data>; + i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/projects/herobrine/zombie/project.conf b/zephyr/projects/herobrine/zombie/project.conf new file mode 100644 index 0000000000..037ab5cc05 --- /dev/null +++ b/zephyr/projects/herobrine/zombie/project.conf @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Zombie board-specific Kconfig settings. +CONFIG_BOARD_ZOMBIE=y + +CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/projects/herobrine/zombie/project.overlay b/zephyr/projects/herobrine/zombie/project.overlay new file mode 100644 index 0000000000..7b44350e5a --- /dev/null +++ b/zephyr/projects/herobrine/zombie/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" +#include "../switchcap.dtsi" + +/* Zombie project DTS includes*/ +#include "battery.dtsi" +#include "gpio.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/zombie/usbc.dtsi b/zephyr/projects/herobrine/zombie/usbc.dtsi new file mode 100644 index 0000000000..20bd48382f --- /dev/null +++ b/zephyr/projects/herobrine/zombie/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; -- cgit v1.2.1 From 35e6179e8a2fed88461ec16e52618c74bf52dfe6 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 1 Nov 2022 22:50:24 -0600 Subject: test: Add tests to the debug host commands Enable the charge state debug host commands and run them to make sure that they all succeed. This test is more of a general check to make sure that these constant IDs remain working and return an OK. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I9e91f8f932042666de3a80c2b505e3725ccecb05 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3998266 Commit-Queue: Jeremy Bettis Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- util/config_allowed.txt | 1 - zephyr/Kconfig.charger | 8 +++++ zephyr/shim/include/config_chip.h | 5 +++ zephyr/test/drivers/Kconfig | 1 + zephyr/test/drivers/host_cmd/src/charge_manager.c | 44 +++++++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/util/config_allowed.txt b/util/config_allowed.txt index 074490612e..a98833624e 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -169,7 +169,6 @@ CONFIG_CHARGE_MANAGER_BAT_PCT_SAFE_MODE_EXIT CONFIG_CHARGE_MANAGER_DRP_CHARGING CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT CONFIG_CHARGE_MANAGER_SAFE_MODE -CONFIG_CHARGE_STATE_DEBUG CONFIG_CHIPSET_ALDERLAKE CONFIG_CHIPSET_APL_GLK CONFIG_CHIPSET_APOLLOLAKE diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger index f408797d17..58a094e553 100644 --- a/zephyr/Kconfig.charger +++ b/zephyr/Kconfig.charger @@ -63,6 +63,14 @@ config PLATFORM_EC_CHARGE_MANAGER source is available on the hardware, so cannot be built without PLATFORM_EC_USBC. +config PLATFORM_EC_CHARGE_STATE_DEBUG + bool "Debug information about the charge state" + depends on PLATFORM_EC_CHARGE_MANAGER + help + Enables debug information regarding the current charge state. Enabling + this config will allow the EC_CMD_CHARGE_STATE host command to use the + CHARGE_STATE_CMD_GET_PARAM command to query the current charge state. + config PLATFORM_EC_CHARGESPLASH bool "Charging splashscreen support" help diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index bfef3427a8..f69713fada 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1029,6 +1029,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #endif +#undef CONFIG_CHARGE_STATE_DEBUG +#ifdef CONFIG_PLATFORM_EC_CHARGE_STATE_DEBUG +#define CONFIG_CHARGE_STATE_DEBUG +#endif + #undef CONFIG_CHARGESPLASH #ifdef CONFIG_PLATFORM_EC_CHARGESPLASH #define CONFIG_CHARGESPLASH diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index ed57c7c16e..a256c0b700 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -36,6 +36,7 @@ config LINK_TEST_SUITE_COMMON_CHARGER bool "Link and execute the common/charger.c tests" config LINK_TEST_SUITE_HOST_COMMANDS + select PLATFORM_EC_CHARGE_STATE_DEBUG bool "Link and test the host command tests" config LINK_TEST_SUITE_ISL923X diff --git a/zephyr/test/drivers/host_cmd/src/charge_manager.c b/zephyr/test/drivers/host_cmd/src/charge_manager.c index 7298b8e135..50a476dd99 100644 --- a/zephyr/test/drivers/host_cmd/src/charge_manager.c +++ b/zephyr/test/drivers/host_cmd/src/charge_manager.c @@ -44,5 +44,49 @@ ZTEST_USER(charge_manager, test_port_override__0_from_off) zassert_ok(host_command_process(&args)); } +ZTEST_USER(charge_manager, test_charge_state_get_debug_params) +{ + struct ec_params_charge_state params = { + .cmd = CHARGE_STATE_CMD_GET_PARAM, + }; + struct ec_response_charge_state response = { 0 }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params); + + /* Check that the following get commands work on these debug parameters. + * The values being asserted are the default values when nothing is + * plugged in. This should be enough since the test only needs to verify + * that the command gets the current value. Tests that verify the + * charging behavior exist elsewhere (under + * default/src/integration/usbc). + */ + params.get_param.param = CS_PARAM_DEBUG_CTL_MODE; + zassert_ok(host_command_process(&args)); + zassert_equal(0, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_MANUAL_CURRENT; + zassert_ok(host_command_process(&args)); + zassert_equal(0xffffffff, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_MANUAL_VOLTAGE; + zassert_ok(host_command_process(&args)); + zassert_equal(0xffffffff, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_SEEMS_DEAD; + zassert_ok(host_command_process(&args)); + zassert_equal(0, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_SEEMS_DISCONNECTED; + zassert_ok(host_command_process(&args)); + zassert_equal(0, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_BATT_REMOVED; + zassert_ok(host_command_process(&args)); + zassert_equal(0, response.get_param.value); + + params.get_param.param = CS_PARAM_DEBUG_MAX; + zassert_equal(EC_ERROR_INVAL, host_command_process(&args)); +} + ZTEST_SUITE(charge_manager, drivers_predicate_post_main, NULL, NULL, NULL, NULL); -- cgit v1.2.1 From 640434be3f364234f29576b7c3ab7b9417259175 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Thu, 3 Nov 2022 13:35:25 -0600 Subject: zephyr/test: Fix struct initializer Gcc-10 doesn't like this initializer. Correct it. BRANCH=None BUG=None TEST=./twister with gcc Signed-off-by: Jeremy Bettis Change-Id: Ie7576eef5ff8aad41f7ccc47c2774186a5af16a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4004759 Tested-by: Jeremy Bettis Commit-Queue: Jeremy Bettis Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c b/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c index 847326c0ba..b30ae6db6c 100644 --- a/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c +++ b/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c @@ -35,8 +35,8 @@ ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__kblight) ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__displight) { struct ec_params_pwm_set_duty p = { - p.index = DT_REG_ADDR(DT_NODELABEL(pwm_displight)), - p.pwm_type = EC_PWM_TYPE_DISPLAY_LIGHT, + .index = DT_REG_ADDR(DT_NODELABEL(pwm_displight)), + .pwm_type = EC_PWM_TYPE_DISPLAY_LIGHT, /* Arbitrary 72% */ .duty = PWM_PERCENT_TO_RAW(72) }; -- cgit v1.2.1 From 5e39fae931d7fe889fd073f1ba3016f84855a61b Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Thu, 3 Nov 2022 16:07:19 +1100 Subject: nissa/npcx: re-enable some shell conveniences We've received complaints from other developers that the minimal shell isn't nice to use. Since we can turn on a number of the conveniences without losing all of the gains from turning on minimal shell, do that. Summarized effect of various options on flash size: | Configuration | Flash used | Size increase | |--------------------------------------|------------|---------------| | Baseline | 245084 | 0 | | SHELL_HISTORY | 245936 | 852 | | SHELL_TAB | 245944 | 860 | | SHELL_TAB + SHELL_TAB_AUTOCOMPLETION | 246176 | 1092 | | SHELL_HELP | 248592 | 3508 | | KERNEL_SHELL | 247448 | 2364 | | all of the above | 252844 | 7760 | | SHELL_MINIMAL=n | 260396 | 15312 | BUG=b:230486318 TEST=zmake build nivviks BRANCH=none Change-Id: I7ffb89b5d1dd437f300724334337d64e6110c6d1 Signed-off-by: Peter Marheine Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000344 Code-Coverage: Zoss Reviewed-by: Andrew McRae --- zephyr/projects/nissa/npcx_program.conf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/zephyr/projects/nissa/npcx_program.conf b/zephyr/projects/nissa/npcx_program.conf index d1b7a56bcc..ae672cb63a 100644 --- a/zephyr/projects/nissa/npcx_program.conf +++ b/zephyr/projects/nissa/npcx_program.conf @@ -30,8 +30,14 @@ CONFIG_PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US=100000 CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y # type C port 1 redriver CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y -# Save some space + +# Save some flash space, but retain some useful features CONFIG_SHELL_MINIMAL=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y +CONFIG_SHELL_HELP=y +CONFIG_KERNEL_SHELL=y # FRS enable CONFIG_PLATFORM_EC_USB_PD_FRS=y -- cgit v1.2.1 From 85f233b5bb37f3a337abaef4f6aaa0a46fda6f0b Mon Sep 17 00:00:00 2001 From: Bernardo Perez Priego Date: Wed, 1 Jun 2022 19:14:29 -0700 Subject: zephyr: ap_pwrseq: Add Power Signals Emulator Power Signal Emulator provides an engine in which a given set of defined power signals connection is instantiated to simulate platform behavior. This emulator is created to supports executing AP Power Sequence test by configuring power signals behavior using devicetree. BUG=b:222933615 TEST=zmake test test-ap_power BRANCH=None Signed-off-by: Bernardo Perez Priego Change-Id: If1b1af2d287e23fe73e77986356bd3c50d56f148 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3684435 Code-Coverage: Zoss Reviewed-by: Peter Marheine Reviewed-by: Andrew McRae --- zephyr/Kconfig | 1 + .../bindings/power/intel,ap-pwr-signal-emul.yaml | 124 +++++ .../bindings/power/intel,ap-pwr-test-platform.yaml | 18 + zephyr/include/emul/emul_power_signals.h | 49 ++ zephyr/subsys/CMakeLists.txt | 1 + zephyr/subsys/emul/CMakeLists.txt | 2 + zephyr/subsys/emul/Kconfig | 5 + zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt | 1 + zephyr/subsys/emul/ap_pwrseq/Kconfig | 34 ++ zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c | 550 +++++++++++++++++++++ 10 files changed, 785 insertions(+) create mode 100644 zephyr/dts/bindings/power/intel,ap-pwr-signal-emul.yaml create mode 100644 zephyr/dts/bindings/power/intel,ap-pwr-test-platform.yaml create mode 100644 zephyr/include/emul/emul_power_signals.h create mode 100644 zephyr/subsys/emul/CMakeLists.txt create mode 100644 zephyr/subsys/emul/Kconfig create mode 100644 zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt create mode 100644 zephyr/subsys/emul/ap_pwrseq/Kconfig create mode 100644 zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 1daeb0d0c4..98f40aaa97 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -8,6 +8,7 @@ rsource "emul/Kconfig" rsource "fake/Kconfig" rsource "mock/Kconfig" rsource "subsys/Kconfig" +rsource "subsys/emul/Kconfig" if ZTEST diff --git a/zephyr/dts/bindings/power/intel,ap-pwr-signal-emul.yaml b/zephyr/dts/bindings/power/intel,ap-pwr-signal-emul.yaml new file mode 100644 index 0000000000..1863349892 --- /dev/null +++ b/zephyr/dts/bindings/power/intel,ap-pwr-signal-emul.yaml @@ -0,0 +1,124 @@ + # Copyright 2022 The ChromiumOS Authors + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. + +description: | + Power Signal Emulator Node + + Power signal emulator allows executing AP Power Sequence in a virtual + environment by simulating power signals behavior. + + This file defines a node to bind two or more power signals. A node connects + one input-signal with one or more output-signals. When a node is loaded and + initialized by power signal emulator, its input-signal state will control + the value of its children output-signals. Behavior of output-signals are + configurable to meet AP power sequence test cases. + + Power Signals direction is determined from emulator node perspective. An input + signal in a node, is the one to be monitored by the emulator, while an output + signal gets its value altered when corresponding input signal's state changes. + +compatible: "intel,ap-pwr-signal-emul" + +properties: + input-signal: + type: phandle + required: true + description: | + Input signal whose value is monitored to control children output-signal`s + value. + + assert-value: + type: int + required: false + default: 1 + description: | + Value that indicates `input-signal` must be ASSERTED. + + A power signal state can be ASSERTED or DEASSERTED.`input-signal` is only + considered asserted if its new value is equal to `assert-value`, any + other value makes it deasserted. + + edge: + type: string + required: false + description: | + Controls when to trigger children value change, based on `input-signal` + new state. + + EDGE_ACTIVE_ON_ASSERT: Children value changes only when `input-signal` + state changes into asserted. + + EDGE_ACTIVE_ON_DEASSERT: Children value changes only when `input-signal` + state changes into deasserted. + + EDGE_ACTIVE_ON_DEASSERT: Children value changes everytime `input-signal` + state changes. + + default: EDGE_ACTIVE_ON_BOTH + enum: + - EDGE_ACTIVE_ON_ASSERT + - EDGE_ACTIVE_ON_DEASSERT + - EDGE_ACTIVE_ON_BOTH + + init-value: + type: int + required: false + description: | + Initial value of `input-signal`. + +child-binding: + description: | + Child power signals configuration. + + properties: + output-signal: + type: phandle + required: true + description: | + Output signal whose value will be controlled by parent `input-signal` + state. + + assert-value: + type: int + required: false + default: 1 + description: | + Value that will be assigned to this signal when parent `input-signal` + state is asserted. + + assert-delay-ms: + type: int + required: false + default: 10 + description: | + Milliseconds to delay setting this signal to its `assert-value` + after `input-signal` is asserted. + + deassert-value: + type: int + required: false + default: 0 + description: | + Value that will be assigned to this signal when parent `input-signal` + state is deasserted. + + deassert-delay-ms: + type: int + required: false + default: 10 + description: | + Milliseconds to delay setting this signal to its `deassert-value` + after `input-signal` is deasserted. + + init-value: + type: int + required: false + description: | + Value set to this power signal when initializing this node. + + invert-value: + type: boolean + description: | + Invert this power signal assertion logic, this applies to both values + and delays. diff --git a/zephyr/dts/bindings/power/intel,ap-pwr-test-platform.yaml b/zephyr/dts/bindings/power/intel,ap-pwr-test-platform.yaml new file mode 100644 index 0000000000..c2f7e10cd1 --- /dev/null +++ b/zephyr/dts/bindings/power/intel,ap-pwr-test-platform.yaml @@ -0,0 +1,18 @@ + # 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. + +description: | + Power Signal Test Platform + + This is a virtual representation of platform comprised of one or more power + signal emulator nodes. Test platform is loaded into power signal emulator. + +compatible: "intel,ap-pwr-test-platform" + +properties: + nodes: + type: phandles + required: true + description: | + phandle array of power signals nodes to be run by emulator. diff --git a/zephyr/include/emul/emul_power_signals.h b/zephyr/include/emul/emul_power_signals.h new file mode 100644 index 0000000000..7dea6079f0 --- /dev/null +++ b/zephyr/include/emul/emul_power_signals.h @@ -0,0 +1,49 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef EMUL_POWER_SIGNALS_H_ +#define EMUL_POWER_SIGNALS_H_ + +/** + * @brief Test platform definition, + * This structure contains all power signal nodes associated to one + * test. + */ +struct power_signal_emul_test_platform { + char *name_id; + int nodes_count; + struct power_signal_emul_node **nodes; +}; + +#define EMUL_POWER_SIGNAL_TEST_PLATFORM_DECL(inst) \ + extern const struct power_signal_emul_test_platform inst; + +#define EMUL_POWER_SIGNAL_TEST_PLATFORM(inst) (&DT_CAT(DT_N_S_, inst)) + +DT_FOREACH_STATUS_OKAY(intel_ap_pwr_test_platform, + EMUL_POWER_SIGNAL_TEST_PLATFORM_DECL) +/** + * @brief Load test platform. + * + * This initializes each of the test platform nodes. + * + * @param test_platform Pointer to test platform structure. + * + * @return 0 indicating success. + * @return -EINVAL `test_id` parameter is invalid. + * @return -EBUSY `test_id` One test platform is currently loaded. + */ +int power_signal_emul_load( + const struct power_signal_emul_test_platform *test_platform); + +/** + * @brief Unload test platform. + * + * @return 0 indicating success. + * @return -EINVAL no test platform has been loaded. + */ +int power_signal_emul_unload(void); + +#endif /* EMUL_POWER_SIGNALS_H_ */ diff --git a/zephyr/subsys/CMakeLists.txt b/zephyr/subsys/CMakeLists.txt index a3837b94e8..dfd1a35871 100644 --- a/zephyr/subsys/CMakeLists.txt +++ b/zephyr/subsys/CMakeLists.txt @@ -1,3 +1,4 @@ # SPDX-License-Identifier: Apache-2.0 add_subdirectory(ap_pwrseq) +add_subdirectory(emul) diff --git a/zephyr/subsys/emul/CMakeLists.txt b/zephyr/subsys/emul/CMakeLists.txt new file mode 100644 index 0000000000..3394afcc94 --- /dev/null +++ b/zephyr/subsys/emul/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory("ap_pwrseq") diff --git a/zephyr/subsys/emul/Kconfig b/zephyr/subsys/emul/Kconfig new file mode 100644 index 0000000000..48011312d5 --- /dev/null +++ b/zephyr/subsys/emul/Kconfig @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +rsource "ap_pwrseq/Kconfig" diff --git a/zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt b/zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt new file mode 100644 index 0000000000..476232d13b --- /dev/null +++ b/zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt @@ -0,0 +1 @@ +zephyr_library_sources_ifdef(CONFIG_EMUL_POWER_SIGNALS emul_power_signals.c) diff --git a/zephyr/subsys/emul/ap_pwrseq/Kconfig b/zephyr/subsys/emul/ap_pwrseq/Kconfig new file mode 100644 index 0000000000..309ee08eae --- /dev/null +++ b/zephyr/subsys/emul/ap_pwrseq/Kconfig @@ -0,0 +1,34 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +if ZTEST + +config EMUL_POWER_SIGNALS + bool "Enable Power Signals Emulator" + help + Power signals emulator imitates the behavior of power signals + that interact with the EC within a given platform. It enables testing + AP Power Sequence execution in a virtual environment. + +if EMUL_POWER_SIGNALS + +module = EMUL_POWER_SIGNALS +module-str = Power Signals Emulator +source "subsys/logging/Kconfig.template.log_config" + +config EMUL_POWER_SIGNALS_WORK_QUEUE_STACK_SIZE + int "Power Signals Emulator internal work queue stack size" + default 1024 + help + Power Signal Emulator has its own dedicated work queue, this defines + work queue thread stack size. + +config EMUL_POWER_SIGNALS_WORK_QUEUE_PRIO + int "Power Signals Emulator internal work queue thread priority" + default 0 + help + Defines work queue thread thread priority. + +endif # EMUL_POWER_SIGNALS +endif # ZTEST diff --git a/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c b/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c new file mode 100644 index 0000000000..9f68a18bdc --- /dev/null +++ b/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c @@ -0,0 +1,550 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include +#include +#include + +#include "ap_power/ap_power.h" +#include "ap_power/ap_power_events.h" +#include +#include "chipset.h" +#include "emul/emul_power_signals.h" +#include "power_signals.h" +#include "test_state.h" + +LOG_MODULE_REGISTER(emul_power_signal, CONFIG_EMUL_POWER_SIGNALS_LOG_LEVEL); + +/** + * @brief Power signal source type. + */ +enum power_signal_emul_source { + PWR_SIG_EMUL_SRC_GPIO, + PWR_SIG_EMUL_SRC_VW, + PWR_SIG_EMUL_SRC_EXT, + PWR_SIG_EMUL_SRC_ADC, +}; + +/** + * @brief Power signal containers definition. + */ +union power_signal_emul_signal_spec { + struct gpio_dt_spec gpio; + struct adc_dt_spec adc; +}; + +/** + * @brief Power signal descriptor. + */ +struct power_signal_emul_signal_desc { + const enum power_signal enum_id; + const char *name; + const enum power_signal_emul_source source; + const union power_signal_emul_signal_spec spec; +}; + +/** + * @brief Power signal output definition. + */ +struct power_signal_emul_output { + struct power_signal_emul_signal_desc desc; + const int assert_value; + const int assert_delay_ms; + const int deassert_value; + const int deassert_delay_ms; + const int init_value; + const bool retain; + const bool invert; + struct k_work_delayable d_work; + int value; +}; + +enum power_signal_edge { + EDGE_ACTIVE_ON_ASSERT, + EDGE_ACTIVE_ON_DEASSERT, + EDGE_ACTIVE_ON_BOTH, +}; + +/** + * @brief Power signal input definition. + */ +struct power_signal_emul_input { + struct power_signal_emul_signal_desc desc; + const int assert_value; + const int init_value; + const bool retain; + const enum power_signal_edge edge; + struct gpio_callback cb; + int value; +}; + +/** + * @brief Power signal node definition, + * One node contains at least one input signal and one or more output + * signals. + */ +struct power_signal_emul_node { + const char *name; + struct power_signal_emul_input input; + const int outputs_count; + struct power_signal_emul_output *const outputs; +}; + +#define EMUL_POWER_SIGNAL_GET_SOURCE(inst) \ + COND_CODE_1( \ + DT_NODE_HAS_COMPAT(inst, intel_ap_pwrseq_gpio), \ + (PWR_SIG_EMUL_SRC_GPIO), \ + (COND_CODE_1( \ + DT_NODE_HAS_COMPAT(inst, intel_ap_pwrseq_vw), \ + (PWR_SIG_EMUL_SRC_VW), \ + (COND_CODE_1(DT_NODE_HAS_COMPAT( \ + inst, intel_ap_pwrseq_external), \ + (PWR_SIG_EMUL_SRC_EXT), \ + (PWR_SIG_EMUL_SRC_ADC)))))) + +#define EMUL_POWER_SIGNAL_GET_SIGNAL_SPEC(inst, dir_signal) \ + { \ + COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PROP(inst, dir_signal), \ + intel_ap_pwrseq_gpio), \ + (.gpio = GPIO_DT_SPEC_GET( \ + DT_PROP(inst, dir_signal), gpios)), \ + ()) \ + } + +#define EMUL_POWER_SIGNAL_GET_SIGNAL(inst, dir) \ + { \ + .enum_id = PWR_SIGNAL_ENUM(DT_PROP(inst, dir)), \ + .name = DT_PROP(DT_PROP(inst, dir), enum_name), \ + .source = EMUL_POWER_SIGNAL_GET_SOURCE(DT_PROP(inst, dir)), \ + .spec = EMUL_POWER_SIGNAL_GET_SIGNAL_SPEC(inst, dir), \ + } + +#define EMUL_POWER_SIGNAL_IN_DEF(inst) \ + { \ + .desc = EMUL_POWER_SIGNAL_GET_SIGNAL(inst, input_signal), \ + .assert_value = DT_PROP(inst, assert_value), \ + .init_value = DT_PROP_OR(inst, init_value, 0), \ + .edge = DT_STRING_TOKEN(inst, edge), \ + .retain = !DT_NODE_HAS_PROP(inst, init_value), \ + } + +#define EMUL_POWER_SIGNAL_OUT_DEF(inst) \ + { \ + .desc = EMUL_POWER_SIGNAL_GET_SIGNAL(inst, output_signal), \ + .assert_value = DT_PROP(inst, assert_value), \ + .assert_delay_ms = DT_PROP(inst, assert_delay_ms), \ + .deassert_value = DT_PROP(inst, deassert_value), \ + .deassert_delay_ms = DT_PROP(inst, deassert_delay_ms), \ + .init_value = DT_PROP_OR(inst, init_value, 0), \ + .retain = !DT_NODE_HAS_PROP(inst, init_value), \ + .invert = DT_PROP(inst, invert_value), \ + }, + +#define EMUL_POWER_SIGNAL_OUT_ARRAY_DEF(inst) \ + static struct power_signal_emul_output DT_CAT(inst, _output)[] = { \ + DT_FOREACH_CHILD_STATUS_OKAY(inst, EMUL_POWER_SIGNAL_OUT_DEF) \ + }; + +#define EMUL_POWER_SIGNAL_GET_INPUT_ENUM(inst) ENUM_##inst##_OUTPUT, + +#define EMUL_POWER_SIGNAL_NODES_DEF(inst) \ + enum { \ + DT_FOREACH_CHILD_STATUS_OKAY(inst, \ + EMUL_POWER_SIGNAL_GET_INPUT_ENUM) \ + DT_CAT(inst, _OUTPUT_COUNT), \ + }; \ + __COND_CODE(IS_EQ(DT_CAT(inst, _OUTPUT_COUNT), 0), (), \ + (EMUL_POWER_SIGNAL_OUT_ARRAY_DEF(inst))) \ + static struct power_signal_emul_node DT_CAT(inst, _node) = { \ + .name = DT_NODE_FULL_NAME(inst), \ + .input = EMUL_POWER_SIGNAL_IN_DEF(inst), \ + .outputs_count = inst##_OUTPUT_COUNT, \ + .outputs = __COND_CODE(IS_EQ(DT_CAT(inst, _OUTPUT_COUNT), 0), \ + (NULL), (DT_CAT(inst, _output))), \ + }; + +DT_FOREACH_STATUS_OKAY(intel_ap_pwr_signal_emul, EMUL_POWER_SIGNAL_NODES_DEF) + +#define EMUL_POWER_SIGNAL_NODES_ARRAY_GET_NODES_REFS_WITH_COMMA(inst) \ + (&DT_CAT(inst, _node)), + +#define EMUL_POWER_SIGNAL_NODES_ARRAY_GET_NODES_REFS(inst) \ + EMUL_POWER_SIGNAL_NODES_ARRAY_GET_NODES_REFS_WITH_COMMA(inst) + +#define EMUL_POWER_SIGNAL_NODES_ARRAY_GET_IO_SIGNALS(inst, prop, idx) \ + EMUL_POWER_SIGNAL_NODES_ARRAY_GET_NODES_REFS( \ + DT_PHANDLE_BY_IDX(inst, prop, idx)) + +#define EMUL_POWER_SIGNAL_NODES_ARRAY_DEF(inst) \ + static struct power_signal_emul_node *DT_CAT(inst, _nodes)[] = { \ + DT_FOREACH_PROP_ELEM( \ + inst, nodes, \ + EMUL_POWER_SIGNAL_NODES_ARRAY_GET_IO_SIGNALS) \ + }; + +DT_FOREACH_STATUS_OKAY(intel_ap_pwr_test_platform, + EMUL_POWER_SIGNAL_NODES_ARRAY_DEF) + +#define EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES_REFS_ITEM(inst) \ + DT_CAT(inst, _nodes), + +#define EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES_REFS(inst) \ + EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES_REFS_ITEM(inst) + +#define EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_IO_SIGNALS(inst, prop, idx) \ + EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES_REFS( \ + DT_PHANDLE_BY_IDX(inst, prop, idx)) + +#define EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES(inst) \ + { \ + DT_FOREACH_PROP_ELEM( \ + inst, nodes, \ + EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_IO_SIGNALS) \ + } + +#define EMUL_POWER_SIGNAL_TEST_PLATFORM_DEF(inst) \ + const struct power_signal_emul_test_platform inst = { \ + .name_id = DT_NODE_FULL_NAME(inst), \ + .nodes_count = DT_PROP_LEN(inst, nodes), \ + .nodes = DT_CAT(inst, _nodes), \ + }; + +DT_FOREACH_STATUS_OKAY(intel_ap_pwr_test_platform, + EMUL_POWER_SIGNAL_TEST_PLATFORM_DEF) + +static K_KERNEL_STACK_DEFINE(work_q_stack, + CONFIG_EMUL_POWER_SIGNALS_WORK_QUEUE_STACK_SIZE); + +struct k_work_q work_q; + +static const struct power_signal_emul_test_platform *cur_test_platform; + +static bool emul_ready; + +/** + * @brief Set GPIO type power signal to specified value. + * + * @param spec Pointer to container for GPIO pin information specified in + * devicetree. + * @param value Value to be set on GPIO. + */ +static void power_signal_emul_set_gpio_value(const struct gpio_dt_spec *spec, + int value) +{ + gpio_flags_t gpio_flags; + int ret; + + ret = gpio_emul_flags_get(spec->port, spec->pin, &gpio_flags); + zassert_ok(ret, "Getting GPIO flags!!"); + + if (gpio_flags & GPIO_INPUT) { + ret = gpio_emul_input_set(spec->port, spec->pin, value); + } else if (gpio_flags & GPIO_OUTPUT) { + ret = gpio_pin_set(spec->port, spec->pin, value); + } + zassert_ok(ret, "Setting GPIO value!!"); +} + +/** + * @brief Set power signal to specified value. + * + * @param desc Pointer to power signal descriptor. + * @param value Value to be set on power signal. + */ +static void +power_signal_emul_set_value(struct power_signal_emul_signal_desc *desc, + int value) +{ + LOG_DBG("Set Signal %s -> %d", desc->name, value); + + switch (desc->source) { + case PWR_SIG_EMUL_SRC_GPIO: + power_signal_emul_set_gpio_value(&desc->spec.gpio, !!value); + break; + + case PWR_SIG_EMUL_SRC_EXT: + zassert_ok(power_signal_set(desc->enum_id, value), + "Setting %s Signal value!!", desc->name); + __fallthrough; + + case PWR_SIG_EMUL_SRC_VW: + power_signal_interrupt(desc->enum_id, value); + break; + + default: + zassert_unreachable("Undefined Signal %s!!", desc->name); + } +} + +/** + * @brief Get GPIO type power signal value. + * + * @param spec Pointer to container for GPIO pin information specified in + * devicetree. + * + * @return GPIO type power signal value. + */ +static int power_signal_emul_get_gpio_value(const struct gpio_dt_spec *spec) +{ + gpio_flags_t gpio_flags; + int ret; + + ret = gpio_emul_flags_get(spec->port, spec->pin, &gpio_flags); + zassert_ok(ret, "Getting GPIO flags!!"); + + if (gpio_flags & GPIO_INPUT) { + ret = gpio_pin_get(spec->port, spec->pin); + } else if (gpio_flags & GPIO_OUTPUT) { + ret = gpio_emul_output_get(spec->port, spec->pin); + } + + return ret; +} + +/** + * @brief Get power signal value. + * + * @param desc Pointer to power signal descriptor. + * + * @return Power signal value. + */ +static int +power_signal_emul_get_value(struct power_signal_emul_signal_desc *desc) +{ + int ret; + + if (desc->source == PWR_SIG_EMUL_SRC_GPIO) { + ret = power_signal_emul_get_gpio_value(&desc->spec.gpio); + } else { + ret = power_signal_get(desc->enum_id); + } + + return ret; +} + +/** + * @brief Handle GPIO type power signal interrupt. + * + * @param port Pointer to GPIO device. + * @param cb Original struct gpio_callback owning this handler. + * @param pins Mask of pins that triggers the callback handler. + */ +static void emul_power_signal_gpio_interrupt(const struct device *port, + struct gpio_callback *cb, + gpio_port_pins_t pins) +{ + struct power_signal_emul_input *in_signal = + CONTAINER_OF(cb, struct power_signal_emul_input, cb); + struct power_signal_emul_node *node = + CONTAINER_OF(in_signal, struct power_signal_emul_node, input); + int value; + int delay; + + value = power_signal_emul_get_value(&in_signal->desc); + if (value == in_signal->value) { + return; + } + + in_signal->value = value; + + if (!emul_ready) { + return; + } + + if (in_signal->edge == EDGE_ACTIVE_ON_DEASSERT && + value == in_signal->assert_value) { + return; + } else if (in_signal->edge == EDGE_ACTIVE_ON_ASSERT && + value != in_signal->assert_value) { + return; + } + + LOG_DBG("INT: Set Signal %s -> %d", in_signal->desc.name, value); + for (int i = 0; i < node->outputs_count; i++) { + struct power_signal_emul_output *out_signal = &node->outputs[i]; + + out_signal->value = (value == in_signal->assert_value) ^ + out_signal->invert ? + out_signal->assert_value : + out_signal->deassert_value; + + delay = (value == in_signal->assert_value) ? + out_signal->assert_delay_ms : + out_signal->deassert_delay_ms; + + LOG_DBG("INT: Delay Signal %s", out_signal->desc.name); + k_work_schedule_for_queue(&work_q, &out_signal->d_work, + K_MSEC(delay)); + } +} + +/** + * @brief Handle power signal delayed work. + * + * This will set power signal value accordingly. + * + * @param work Pointer to work structure. + */ +static void emul_signal_work_hanlder(struct k_work *work) +{ + struct k_work_delayable *d_work = k_work_delayable_from_work(work); + struct power_signal_emul_output *out_signal = + CONTAINER_OF(d_work, struct power_signal_emul_output, d_work); + + power_signal_emul_set_value(&out_signal->desc, out_signal->value); +} + +/** + * @brief Initialize power signal emulator node. + * + * This will enable corresponding initiator power signal interruption and + * its handler's power signals work structures. + * + * @param node Pointer to node containing power signals. + */ +static int power_signal_init_node(struct power_signal_emul_node *node) +{ + struct power_signal_emul_input *in_signal = &node->input; + struct power_signal_emul_output *out_signal; + + if (!node->outputs_count) { + LOG_ERR("Node does not have output signal!!"); + return -EINVAL; + } + + LOG_DBG("Initializing node: %s", node->name); + for (int i = 0; i < node->outputs_count; i++) { + out_signal = &node->outputs[i]; + + if (out_signal->retain) { + out_signal->value = + power_signal_emul_get_value(&out_signal->desc); + } else { + /* Not retaining previous value, override */ + power_signal_emul_set_value(&out_signal->desc, + out_signal->init_value); + out_signal->value = out_signal->init_value; + } + k_work_init_delayable(&out_signal->d_work, + emul_signal_work_hanlder); + } + + if (in_signal->retain) { + in_signal->value = + power_signal_emul_get_value(&in_signal->desc); + } else { + /* Not retaining previous value, override */ + power_signal_emul_set_value(&in_signal->desc, + in_signal->init_value); + in_signal->value = in_signal->init_value; + } + if (in_signal->desc.source == PWR_SIG_EMUL_SRC_GPIO) { + gpio_init_callback(&in_signal->cb, + emul_power_signal_gpio_interrupt, + BIT(in_signal->desc.spec.gpio.pin)); + + gpio_add_callback(in_signal->desc.spec.gpio.port, + &in_signal->cb); + + gpio_pin_interrupt_configure_dt(&in_signal->desc.spec.gpio, + GPIO_INT_EDGE_BOTH); + } + return 0; +} + +/** See description in emul_power_signals.h */ +int power_signal_emul_load( + const struct power_signal_emul_test_platform *test_platform) +{ + int ret; + + if (cur_test_platform) { + LOG_ERR("Power Signal Emulator Busy!!"); + return -EBUSY; + } + + cur_test_platform = test_platform; + + LOG_DBG("Loading Emulator test: %s", cur_test_platform->name_id); + + for (int i = 0; i < cur_test_platform->nodes_count; i++) { + ret = power_signal_init_node(cur_test_platform->nodes[i]); + if (ret) { + power_signal_emul_unload(); + return ret; + } + } + + emul_ready = true; + LOG_DBG("Loading Emulator test Done"); + return 0; +} + +/** See description in emul_power_signals.h */ +int power_signal_emul_unload(void) +{ + struct power_signal_emul_node *node; + struct power_signal_emul_output *out_signal; + struct power_signal_emul_input *in_signal; + + if (!cur_test_platform) { + LOG_ERR("No Test Platform Loaded!!"); + return -EINVAL; + } + + emul_ready = false; + for (int i = 0; i < cur_test_platform->nodes_count; i++) { + node = cur_test_platform->nodes[i]; + in_signal = &node->input; + + if (in_signal->desc.source != PWR_SIG_EMUL_SRC_GPIO) { + /* Currently, Only output GPIO signals are supported */ + continue; + } + + for (int j = 0; j < node->outputs_count; j++) { + static struct k_work_sync work_sync; + + out_signal = &node->outputs[j]; + k_work_cancel_delayable_sync(&out_signal->d_work, + &work_sync); + } + gpio_pin_interrupt_configure_dt(&in_signal->desc.spec.gpio, + GPIO_INT_DISABLE); + if (in_signal->cb.handler) { + gpio_remove_callback(in_signal->desc.spec.gpio.port, + &in_signal->cb); + } + } + cur_test_platform = NULL; + return 0; +} + +/** + * @brief Initialize power signal emulator internal work queue. + * + * @param dev Unused parameter. + * + * @return 0 Return success only. + */ +static int power_signal_emul_work_q_init(const struct device *dev) +{ + ARG_UNUSED(dev); + struct k_work_queue_config cfg = { + .name = "psignal_emul", + .no_yield = true, + }; + + k_work_queue_start(&work_q, work_q_stack, + K_KERNEL_STACK_SIZEOF(work_q_stack), + CONFIG_EMUL_POWER_SIGNALS_WORK_QUEUE_PRIO, &cfg); + return 0; +} + +SYS_INIT(power_signal_emul_work_q_init, POST_KERNEL, + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); -- cgit v1.2.1 From 77259a664a84061ce47eff42d0fd47efea5c4800 Mon Sep 17 00:00:00 2001 From: Bernardo Perez Priego Date: Mon, 6 Jun 2022 17:52:53 -0700 Subject: zephyr: ap_pwrseq: Enable power sequence unit test This will utilize power signal emulator to test power sequence execution flow in alderlake platform. Test Cases: - AP from G3 to S0 - AP in S0 to handle power failure - AP from G3 to S0 and back to G3 BUG=b:222933615 TEST=zmake test test-ap_power BRANCH=None Signed-off-by: Bernardo Perez Priego Change-Id: I6ebd2f0fcb5c67093cc5aaaa758a4b091515d429 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3688195 Code-Coverage: Zoss Reviewed-by: Peter Marheine --- zephyr/test/ap_power/boards/alderlake.dts | 269 +++++++++++++++++++++++ zephyr/test/ap_power/boards/native_posix.overlay | 125 ----------- zephyr/test/ap_power/prj.conf | 4 - zephyr/test/ap_power/src/ap_pwrseq.c | 140 ++++++++++++ zephyr/test/ap_power/src/board.c | 22 +- zephyr/test/ap_power/src/events.c | 1 + zephyr/test/ap_power/testcase.yaml | 8 +- 7 files changed, 438 insertions(+), 131 deletions(-) create mode 100644 zephyr/test/ap_power/boards/alderlake.dts create mode 100644 zephyr/test/ap_power/src/ap_pwrseq.c diff --git a/zephyr/test/ap_power/boards/alderlake.dts b/zephyr/test/ap_power/boards/alderlake.dts new file mode 100644 index 0000000000..30432a9c72 --- /dev/null +++ b/zephyr/test/ap_power/boards/alderlake.dts @@ -0,0 +1,269 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + common-pwrseq { + compatible = "intel,ap-pwrseq"; + s5-inactivity-timeout = <1>; + }; + + en_pp5000: pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpio0 10 0>; + output; + }; + en_pp3300: pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpio0 11 0>; + output; + }; + rsmrst: pwr-pg-ec-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpio0 12 0>; + interrupt-flags = ; + }; + ec_pch_rsmrst: pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpio0 13 0>; + output; + }; + slp_s0: pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + no-enable; + }; + slp_s3: pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + slp_sus: pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpio0 16 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + ec_soc_dsw_pwrok: pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpio0 17 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpio0 18 0>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpio0 19 0>; + }; + pch_pwrok: pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpio0 20 0>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpio0 21 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpio0 22 GPIO_ACTIVE_LOW>; + output; + }; + slp_s4: pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + slp_s5: pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + all_sys_pwrgd: pwr-all-sys-pwrgd { + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + dsw_pwrok: pwr-pp3300-pwrok { + compatible = "intel,ap-pwrseq-external"; + dbg-label = "PP3300 PWROK"; + enum-name = "PWR_DSW_PWROK"; + }; + pwr-pp1p05-pwrok { + compatible = "intel,ap-pwrseq-external"; + dbg-label = "PP1P05 PWROK"; + enum-name = "PWR_PG_PP1P05"; + }; + + en_pp3300_emul: en-pp3300-emul { + compatible = "intel,ap-pwr-signal-emul"; + input-signal = <&en_pp3300>; + init-value = <0>; + pp3300-dsw-pwrok-emul { + output-signal = <&dsw_pwrok>; + assert-delay-ms = <10>; + init-value= <0>; + }; + }; + + en_pp5000_emul: en-pp5000-emul { + compatible = "intel,ap-pwr-signal-emul"; + input-signal = <&en_pp5000>; + init-value = <0>; + pp5000-rsmrst-emul { + output-signal = <&rsmrst>; + assert-delay-ms = <40>; + init-value= <0>; + }; + }; + + ec_soc_dsw_pwrok_emul: ec-soc-dsw-pwrok-emul { + compatible = "intel,ap-pwr-signal-emul"; + input-signal = <&ec_soc_dsw_pwrok>; + init-value = <0>; + ec-dsw-pwrok-slp-sus-emul { + output-signal = <&slp_sus>; + assert-delay-ms = <20>; + init-value= <0>; + }; + }; + + ec_pch_rsmrst_emul: ec-pch-rsmrst-emul { + compatible = "intel,ap-pwr-signal-emul"; + input-signal = <&ec_pch_rsmrst>; + init-value = <0>; + ec-pch-rsmrst-slp-s5-emul { + output-signal = <&slp_s5>; + assert-delay-ms = <20>; + invert-value; + init-value= <1>; + }; + ec-pch-rsmrst-slp-s4-emul { + output-signal = <&slp_s4>; + assert-delay-ms = <30>; + invert-value; + init-value= <1>; + }; + ec-pch-rsmrst-slp-s3-emul { + output-signal = <&slp_s3>; + assert-delay-ms = <40>; + init-value= <0>; + }; + ec-pch-rsmrst-slp-s0-emul { + output-signal = <&slp_s0>; + assert-delay-ms = <45>; + init-value= <0>; + }; + ec-pch-rsmrst-all-sys-pwrgd { + output-signal = <&all_sys_pwrgd>; + assert-delay-ms = <50>; + init-value= <0>; + }; + }; + + tp-sys-g3-to-s0 { + compatible = "intel,ap-pwr-test-platform"; + nodes = <&en_pp3300_emul &en_pp5000_emul + &ec_soc_dsw_pwrok_emul &ec_pch_rsmrst_emul>; + }; + + pch_pwrok_power_fail_emul: pch-pwrok-power-fail-emul { + compatible = "intel,ap-pwr-signal-emul"; + input-signal = <&pch_pwrok>; + init-value = <0>; + pch-pwrok-dsw-pwrok-emul { + output-signal = <&dsw_pwrok>; + assert-delay-ms = <50>; + invert-value; + }; + }; + + tp-sys-s0-power-fail { + compatible = "intel,ap-pwr-test-platform"; + nodes = <&pch_pwrok_power_fail_emul>; + }; + + pch_pwrok_power_down_emul: pch-pwrok-power-down-emul { + compatible = "intel,ap-pwr-signal-emul"; + input-signal = <&pch_pwrok>; + init-value = <0>; + edge = "EDGE_ACTIVE_ON_ASSERT"; + pch-pwrok-dsw-pwrok-emul { + output-signal = <&dsw_pwrok>; + assert-delay-ms = <70>; + invert-value; + }; + + pch_pwrok-rsmrst-emul { + output-signal = <&rsmrst>; + assert-delay-ms = <60>; + invert-value; + }; + + pch-pwrok-slp-s5-emul { + output-signal = <&slp_s5>; + assert-delay-ms = <50>; + }; + + pch-pwrok-slp-s4-emul { + output-signal = <&slp_s4>; + assert-delay-ms = <30>; + }; + + pch-pwrok-slp-s3-emul { + output-signal = <&slp_s3>; + assert-delay-ms = <20>; + invert-value; + }; + + pch-pwrok-slp-s0-emul { + output-signal = <&slp_s0>; + assert-delay-ms = <15>; + invert-value; + }; + }; + + tp-sys-g3-to-s0-power-down { + compatible = "intel,ap-pwr-test-platform"; + nodes = <&en_pp3300_emul &en_pp5000_emul + &ec_soc_dsw_pwrok_emul &ec_pch_rsmrst_emul + &pch_pwrok_power_down_emul>; + }; +}; diff --git a/zephyr/test/ap_power/boards/native_posix.overlay b/zephyr/test/ap_power/boards/native_posix.overlay index c6cd8c3790..b30240a094 100644 --- a/zephyr/test/ap_power/boards/native_posix.overlay +++ b/zephyr/test/ap_power/boards/native_posix.overlay @@ -52,131 +52,6 @@ }; }; - common-pwrseq { - compatible = "intel,ap-pwrseq"; - }; - - pwr-en-pp5000-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP5000_S5 enable output to regulator"; - enum-name = "PWR_EN_PP5000_A"; - gpios = <&gpio0 10 0>; - output; - }; - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpio0 11 0>; - output; - }; - pwr-pg-ec-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpio0 12 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpio0 13 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - no-enable; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-sus-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_SUS_L input from PCH"; - enum-name = "PWR_SLP_SUS"; - gpios = <&gpio0 16 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-ec-soc-dsw-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "DSW_PWROK output to PCH"; - enum-name = "PWR_EC_SOC_DSW_PWROK"; - gpios = <&gpio0 17 0>; - output; - }; - pwr-vccst-pwrgd-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VCCST_PWRGD output to PCH"; - enum-name = "PWR_VCCST_PWRGD"; - gpios = <&gpio0 18 0>; - output; - }; - pwr-imvp9-vrrdy-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VRRDY input from IMVP9"; - enum-name = "PWR_IMVP9_VRRDY"; - gpios = <&gpio0 19 0>; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpio0 20 0>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpio0 21 0>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpio0 22 GPIO_ACTIVE_LOW>; - output; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - compatible = "intel,ap-pwrseq-external"; - dbg-label = "Combined all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - }; - pwr-pp3300-pwrok { - compatible = "intel,ap-pwrseq-external"; - dbg-label = "PP3300 PWROK"; - enum-name = "PWR_DSW_PWROK"; - }; - pwr-pp1p05-pwrok { - compatible = "intel,ap-pwrseq-external"; - dbg-label = "PP1P05 PWROK"; - enum-name = "PWR_PG_PP1P05"; - }; - clock: clock { compatible = "cros,clock-control-emul"; clock-frequency = ; /* 100 MHz */ diff --git a/zephyr/test/ap_power/prj.conf b/zephyr/test/ap_power/prj.conf index 0bd0b6e8d3..122b84e877 100644 --- a/zephyr/test/ap_power/prj.conf +++ b/zephyr/test/ap_power/prj.conf @@ -41,10 +41,6 @@ CONFIG_GPIO_EMUL=y CONFIG_HEAP_MEM_POOL_SIZE=1024 CONFIG_AP_PWRSEQ=y -CONFIG_X86_NON_DSX_PWRSEQ_ADL=y -CONFIG_AP_X86_INTEL_ADL=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y CONFIG_AP_PWRSEQ_STACK_SIZE=1024 CONFIG_ESPI=y diff --git a/zephyr/test/ap_power/src/ap_pwrseq.c b/zephyr/test/ap_power/src/ap_pwrseq.c new file mode 100644 index 0000000000..d7a4042ca3 --- /dev/null +++ b/zephyr/test/ap_power/src/ap_pwrseq.c @@ -0,0 +1,140 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include +#include +#include + +#include "ap_power/ap_power.h" +#include +#include "ap_power/ap_power_interface.h" +#include "chipset.h" +#include "emul/emul_power_signals.h" +#include "test_state.h" + +static struct ap_power_ev_callback test_cb; +static int power_resume_count; +static int power_start_up_count; +static int power_hard_off_count; +static int power_shutdown_count; +static int power_shutdown_complete_count; +static int power_suspend_count; + +static void emul_ev_handler(struct ap_power_ev_callback *callback, + struct ap_power_ev_data data) +{ + switch (data.event) { + case AP_POWER_RESUME: + power_resume_count++; + break; + + case AP_POWER_STARTUP: + power_start_up_count++; + break; + + case AP_POWER_HARD_OFF: + power_hard_off_count++; + break; + + case AP_POWER_SHUTDOWN: + power_shutdown_count++; + break; + + case AP_POWER_SHUTDOWN_COMPLETE: + power_shutdown_complete_count++; + break; + + case AP_POWER_SUSPEND: + power_suspend_count++; + break; + default: + break; + }; +} + +ZTEST(ap_pwrseq, test_ap_pwrseq_0) +{ + zassert_equal(0, + power_signal_emul_load( + EMUL_POWER_SIGNAL_TEST_PLATFORM(tp_sys_g3_to_s0)), + "Unable to load test platfform `tp_sys_g3_to_s0`"); + + k_msleep(500); + + zassert_equal(1, power_start_up_count, + "AP_POWER_STARTUP event not generated"); + zassert_equal(1, power_resume_count, + "AP_POWER_RESUME event not generated"); +} + +ZTEST(ap_pwrseq, test_ap_pwrseq_1) +{ + zassert_equal(0, + power_signal_emul_load(EMUL_POWER_SIGNAL_TEST_PLATFORM( + tp_sys_s0_power_fail)), + "Unable to load test platfform `tp_sys_s0_power_fail`"); + + /* + * Once emulated power signals are loaded, we need to wake AP power + * Sequence thread up to start executing new set of power signals + */ + ap_pwrseq_wake(); + k_msleep(500); + zassert_equal(1, power_shutdown_count, + "AP_POWER_SHUTDOWN event not generated"); + zassert_equal(1, power_shutdown_complete_count, + "AP_POWER_SHUTDOWN_COMPLETE event not generated"); + zassert_equal(0, power_suspend_count, + "AP_POWER_SUSPEND event generated"); +} + +ZTEST(ap_pwrseq, test_ap_pwrseq_2) +{ + zassert_equal( + 0, + power_signal_emul_load(EMUL_POWER_SIGNAL_TEST_PLATFORM( + tp_sys_g3_to_s0_power_down)), + "Unable to load test platfform `tp_sys_g3_to_s0_power_down`"); + + ap_power_exit_hardoff(); + k_msleep(2000); + zassert_equal(3, power_shutdown_count, + "AP_POWER_SHUTDOWN event not generated"); + zassert_equal(3, power_shutdown_complete_count, + "AP_POWER_SHUTDOWN_COMPLETE event not generated"); + zassert_equal(1, power_suspend_count, + "AP_POWER_SUSPEND event generated"); + zassert_equal(1, power_hard_off_count, + "AP_POWER_HARD_OFF event generated"); +} + +void ap_pwrseq_after_test(void *data) +{ + power_signal_emul_unload(); +} + +void *ap_pwrseq_setup_suite(void) +{ + ap_power_ev_init_callback(&test_cb, emul_ev_handler, + AP_POWER_RESUME | AP_POWER_STARTUP | + AP_POWER_HARD_OFF | AP_POWER_SUSPEND | + AP_POWER_SHUTDOWN | + AP_POWER_SHUTDOWN_COMPLETE); + + ap_power_ev_add_callback(&test_cb); + + return NULL; +} + +void ap_pwrseq_teardown_suite(void *data) +{ + ap_power_ev_remove_callback(&test_cb); +} + +ZTEST_SUITE(ap_pwrseq, ap_power_predicate_post_main, ap_pwrseq_setup_suite, + NULL, ap_pwrseq_after_test, NULL); diff --git a/zephyr/test/ap_power/src/board.c b/zephyr/test/ap_power/src/board.c index 78732b5125..bada154bb3 100644 --- a/zephyr/test/ap_power/src/board.c +++ b/zephyr/test/ap_power/src/board.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include static bool signal_PWR_ALL_SYS_PWRGD; static bool signal_PWR_DSW_PWROK; @@ -59,11 +61,29 @@ void board_ap_power_force_shutdown(void) int board_ap_power_assert_pch_power_ok(void) { + power_signal_set(PWR_PCH_PWROK, 1); return 0; } +static void generate_ec_soc_dsw_pwrok_handler(void) +{ + int in_sig_val = power_signal_get(PWR_DSW_PWROK); + + if (in_sig_val != power_signal_get(PWR_EC_SOC_DSW_PWROK)) { + power_signal_set(PWR_EC_SOC_DSW_PWROK, 1); + } +} + void board_ap_power_action_g3_s5(void) { + power_signal_enable(PWR_DSW_PWROK); + + power_signal_set(PWR_EN_PP3300_A, 1); + power_signal_set(PWR_EN_PP5000_A, 1); + + power_wait_signals_timeout(IN_PGOOD_ALL_CORE, 100 * MSEC); + + generate_ec_soc_dsw_pwrok_handler(); } void board_ap_power_action_s3_s0(void) @@ -80,5 +100,5 @@ void board_ap_power_action_s0(void) bool board_ap_power_check_power_rails_enabled(void) { - return false; + return true; } diff --git a/zephyr/test/ap_power/src/events.c b/zephyr/test/ap_power/src/events.c index ae7d2b870f..b5dfdec50f 100644 --- a/zephyr/test/ap_power/src/events.c +++ b/zephyr/test/ap_power/src/events.c @@ -173,6 +173,7 @@ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, hook_startup, HOOK_PRIO_DEFAULT); */ ZTEST(events, test_hooks) { + count_hook_startup = count_hook_shutdown = 0; ap_power_ev_send_callbacks(AP_POWER_STARTUP); zassert_equal(0, count_hook_shutdown, "shutdown hook called"); zassert_equal(1, count_hook_startup, "startup hook not called"); diff --git a/zephyr/test/ap_power/testcase.yaml b/zephyr/test/ap_power/testcase.yaml index aaf8a530a6..b55e2f3f47 100644 --- a/zephyr/test/ap_power/testcase.yaml +++ b/zephyr/test/ap_power/testcase.yaml @@ -1,4 +1,10 @@ common: platform_allow: native_posix tests: - ap_power.default: {} + ap_power.alderlake: + extra_args: CONFIG_EMUL_POWER_SIGNALS=y + CONFIG_X86_NON_DSX_PWRSEQ_ADL=y + CONFIG_AP_X86_INTEL_ADL=y + CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y + CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y + DTC_OVERLAY_FILE="boards/native_posix.overlay";"boards/alderlake.dts" -- cgit v1.2.1 From 98342b4a1dace372041b937fcc2e7b5bac5f14a6 Mon Sep 17 00:00:00 2001 From: Sue Chen Date: Tue, 18 Oct 2022 08:48:07 +0800 Subject: Craask: update thermal table TEMP_SENSOR_0: memory threshold high 75'C halt 85'C high_release 70'C halt_release 80'C BUG=b:253998681 BRANCH=none TEST=none Signed-off-by: Sue Chen Change-Id: I45a2b6efae422aa040acaaac3a784b277729dc0f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3960511 Reviewed-by: Andrew McRae Code-Coverage: Zoss --- zephyr/projects/nissa/craask/overlay.dtsi | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/zephyr/projects/nissa/craask/overlay.dtsi b/zephyr/projects/nissa/craask/overlay.dtsi index b3a510c111..257dc299e3 100644 --- a/zephyr/projects/nissa/craask/overlay.dtsi +++ b/zephyr/projects/nissa/craask/overlay.dtsi @@ -165,29 +165,18 @@ named-temp-sensors { compatible = "cros-ec,temp-sensors"; memory { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; + temp_host_high = <75>; + temp_host_halt = <85>; + temp_host_release_high = <70>; + temp_host_release_halt = <80>; power-good-pin = <&gpio_ec_soc_dsw_pwrok>; sensor = <&temp_memory>; }; charger { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; power-good-pin = <&gpio_ec_soc_dsw_pwrok>; sensor = <&temp_charger>; }; ambient { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; power-good-pin = <&gpio_ec_soc_dsw_pwrok>; sensor = <&temp_ambient>; }; -- cgit v1.2.1 From 3dcbbe1f41af95beb807f5f4f01143a6b7d3f88f Mon Sep 17 00:00:00 2001 From: Leila Lin Date: Thu, 3 Nov 2022 11:23:10 +0800 Subject: Winterhold: Update fan config Fine-tune fan config for winterhold LOW_COVERAGE_REASON=no unit tests for skyrim yet, b/247151116 BUG=b:255732503 BRANCH=none TEST=verify the thermal config on winterhold is correct Signed-off-by: Leila Lin Change-Id: If89205c9f9ecef07a01e13b900f47ea51b4363e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000346 Reviewed-by: Isaac Lee Tested-by: LeilaCY Lin Tested-by: Elthan Huang Reviewed-by: Elthan Huang Code-Coverage: Zoss Commit-Queue: LeilaCY Lin --- zephyr/projects/skyrim/winterhold.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/projects/skyrim/winterhold.dts b/zephyr/projects/skyrim/winterhold.dts index ece5bc66da..8a182ab835 100644 --- a/zephyr/projects/skyrim/winterhold.dts +++ b/zephyr/projects/skyrim/winterhold.dts @@ -29,8 +29,8 @@ temp_host_release_warn = <45>; temp_host_release_high = <95>; temp_host_release_halt = <100>; - temp_fan_off = <43>; - temp_fan_max = <53>; + temp_fan_off = <35>; + temp_fan_max = <40>; power-good-pin = <&gpio_pg_pwr_s5>; sensor = <&amb_pct2075>; }; -- cgit v1.2.1 From 1ce62eb825053fcc11ed4b1b53b48b0f0afb6b23 Mon Sep 17 00:00:00 2001 From: ben chen Date: Fri, 28 Oct 2022 14:38:26 +0800 Subject: kuldax: modify ADC channel 3 configuration modify ADC channel 3 IMON scale, be sure the retuened value will not overflow integer. V,rsense = 0.005 * 1 V,ina_output = 50 * 0.005 (or 50/200) = 0.25v V,ec = (20/(20+8.66)) * 0.25 = 0.17446v To scale the result to 1amp then V,ec * 1/((20/(20+8.66))*50/200) ,or V,ec * 143/25. BUG=b:255902516 BRANCH=none TEST=use "adc" console command check value. Change-Id: I1e76b93cb85edd3c4096f1413d6d4313c6eb8583 Signed-off-by: Ben Chen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3990465 Reviewed-by: Derek Huang Reviewed-by: Daniel Coggin Commit-Queue: Derek Huang Code-Coverage: Zoss --- board/kuldax/sensors.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/board/kuldax/sensors.c b/board/kuldax/sensors.c index 96f49de8a3..a41d5be713 100644 --- a/board/kuldax/sensors.c +++ b/board/kuldax/sensors.c @@ -46,11 +46,11 @@ const struct adc_t adc_channels[] = { .factor_mul = ADC_MAX_VOLT * 39, .factor_div = (ADC_READ_MAX + 1) * 5, }, - [ADC_PPVAR_IMON] = { /* 872.3 mV/A */ + [ADC_PPVAR_IMON] = { /* 20/(20+8.66)*50/200 */ .name = "PPVAR_IMON", .input_ch = NPCX_ADC_CH3, - .factor_mul = ADC_MAX_VOLT * 1433, - .factor_div = (ADC_READ_MAX + 1) * 1250, + .factor_mul = ADC_MAX_VOLT * 143, + .factor_div = (ADC_READ_MAX + 1) * 25, }, }; -- cgit v1.2.1 From 6604ab511794f526d2d8ec06cb41ed4bde0a1cc5 Mon Sep 17 00:00:00 2001 From: Li Feng Date: Wed, 26 Oct 2022 23:22:08 -0700 Subject: chip/ish: implement full config in pm_init Both ISH shim loader and main firmware have PM initialization. Main firmware doesn't do a full configuration because some are done in shim loader. This is working fine if we use host loading main firmware scheme. We observed problem in IPAPG if stitching main firmware to coreboot and skip shim loader. This CL modifies pm_init to fully configure PM. So ISH main firmware functions correctly in both loading methods. BUG=b:234136500 BRANCH=none TEST=make buildall TEST=on ADL-P RVP, ISH enter IPAPG state in host loading case, and also stitching to coreboot case. Signed-off-by: Leifu Zhao Signed-off-by: Li Feng Change-Id: I603e2f107fdce672ac12bac9d848820f58474910 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3985606 Reviewed-by: Kyoung Kim Reviewed-by: Reka Norman Code-Coverage: Zoss Commit-Queue: Reka Norman --- chip/ish/power_mgt.c | 30 ++++++++++++++++++++++++++++-- chip/ish/registers.h | 24 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/chip/ish/power_mgt.c b/chip/ish/power_mgt.c index 83ef0fc91b..b3e2a407ad 100644 --- a/chip/ish/power_mgt.c +++ b/chip/ish/power_mgt.c @@ -612,8 +612,18 @@ void ish_pm_init(void) /* clear reset history register in CCU */ CCU_RST_HST = CCU_RST_HST; +#if defined(CHIP_VARIANT_ISH5P4) + if (IS_ENABLED(CONFIG_ISH_NEW_PM)) + PMU_D3_STATUS_1 = 0xffffffff; +#endif + /* disable TCG and disable BCG */ - CCU_TCG_EN = 0; + CCU_TCG_ENABLE = 0; + CCU_BCG_ENABLE = 0; + + /* Disable power gate of CACHE and ROM */ + PMU_RF_ROM_PWR_CTRL = 0; + reset_bcg(); if (IS_ENABLED(CONFIG_ISH_PM_AONTASK)) @@ -624,8 +634,15 @@ void ish_pm_init(void) PMU_GPIO_WAKE_MASK1 = 0; } - /* unmask all wake up events */ + /* Unmask all wake up events in event1 */ PMU_MASK_EVENT = ~PMU_MASK_EVENT_BIT_ALL; + /* Mask events in event2 */ + PMU_MASK_EVENT2 = PMU_MASK2_ALL_EVENTS; + +#if defined(CHIP_VARIANT_ISH5P4) + SBEP_REG_CLK_GATE_ENABLE = + (SB_CLK_GATE_EN_LOCAL_CLK_GATE | SB_CLK_GATE_EN_TRUNK_CLK_GATE); +#endif if (IS_ENABLED(CONFIG_ISH_NEW_PM)) { PMU_ISH_FABRIC_CNT = (PMU_ISH_FABRIC_CNT & 0xffff0000) | @@ -648,6 +665,15 @@ void ish_pm_init(void) (PMU_D3_STATUS & PMU_BME_BIT_SET)) PMU_D3_STATUS = PMU_D3_STATUS; +#if defined(CHIP_VARIANT_ISH5P4) + if (IS_ENABLED(CONFIG_ISH_NEW_PM)) { + /* Mask all function1 */ + PMU_REG_MASK_D3_RISE = 0x2; + PMU_REG_MASK_D3_FALL = 0x2; + PMU_REG_MASK_BME_RISE = 0x2; + PMU_REG_MASK_BME_FALL = 0x2; + } +#endif enable_d3bme_irqs(); } } diff --git a/chip/ish/registers.h b/chip/ish/registers.h index bdd04a7cb2..ba83b7bef8 100644 --- a/chip/ish/registers.h +++ b/chip/ish/registers.h @@ -48,6 +48,7 @@ enum ish_i2c_port { #define ISH_IOAPIC_BASE 0xFEC00000 #define ISH_HPET_BASE 0x04700000 #define ISH_LAPIC_BASE 0xFEE00000 +#define ISH_SBEP_BASE 0x04500000 #else #define ISH_I2C0_BASE 0x00100000 #define ISH_I2C1_BASE 0x00102000 @@ -128,6 +129,13 @@ enum ish_i2c_port { #define ISH_GPIO_GWSR REG32(ISH_GPIO_BASE + 0x118) /* Wake Source */ #define ISH_GPIO_GSEC REG32(ISH_GPIO_BASE + 0x130) /* Secure Input */ +#if defined(CHIP_VARIANT_ISH5P4) +/* Side Band End Point registers */ +#define SBEP_REG_CLK_GATE_ENABLE REG32(ISH_SBEP_BASE + 0x006C) +#define SB_CLK_GATE_EN_LOCAL_CLK_GATE BIT(0) +#define SB_CLK_GATE_EN_TRUNK_CLK_GATE BIT(1) +#endif + /* APIC interrupt vectors */ #define ISH_TS_VECTOR 0x20 /* Task switch vector */ #define LAPIC_LVT_ERROR_VECTOR 0x21 /* Clears IOAPIC/LAPIC sync errors */ @@ -208,6 +216,7 @@ enum ish_i2c_port { #define PMU_PMC_PG_WAKE REG32(ISH_PMU_BASE + 0xF18) #define PMU_INTERNAL_PCE REG32(ISH_PMU_BASE + 0xF30) #define PMU_D3_STATUS REG32(ISH_PMU_BASE + 0x100) +#define PMU_D3_STATUS_1 REG32(ISH_PMU_BASE + 0x104) #define PMU_HOST_RST_B BIT(0) #define PMU_PCE_SHADOW_MASK 0x1F #define PMU_PCE_PG_ALLOWED BIT(4) @@ -232,6 +241,10 @@ enum ish_i2c_port { #define PMU_BME_BIT_FALLING_EDGE_STATUS BIT(26) #define PMU_BME_BIT_RISING_EDGE_MASK BIT(27) #define PMU_BME_BIT_FALLING_EDGE_MASK BIT(28) +#define PMU_REG_MASK_D3_RISE REG32(ISH_PMU_BASE + 0x200) +#define PMU_REG_MASK_D3_FALL REG32(ISH_PMU_BASE + 0x208) +#define PMU_REG_MASK_BME_RISE REG32(ISH_PMU_BASE + 0x220) +#define PMU_REG_MASK_BME_FALL REG32(ISH_PMU_BASE + 0x228) #endif #define PMU_GPIO_WAKE_MASK0 REG32(ISH_PMU_BASE + 0x250) @@ -322,6 +335,7 @@ enum ish_i2c_port { #define DEST_BURST_SIZE 3 #define PMU_MASK_EVENT REG32(ISH_PMU_BASE + 0x10) +#define PMU_MASK_EVENT2 REG32(ISH_PMU_BASE + 0x4C) #define PMU_MASK_EVENT_BIT_GPIO(pin) BIT(pin) #define PMU_MASK_EVENT_BIT_HPET BIT(16) #define PMU_MASK_EVENT_BIT_IPC BIT(17) @@ -332,6 +346,16 @@ enum ish_i2c_port { #define PMU_MASK_EVENT_BIT_SPI BIT(22) #define PMU_MASK_EVENT_BIT_UART BIT(23) #define PMU_MASK_EVENT_BIT_ALL (0xffffffff) +#define PMU_MASK_EVENT2_SRAM_ERASE1 BIT(3) +#define PMU_MASK_EVENT2_SRAM_ERASE0 BIT(4) +#define PMU_MASK_EVENT2_ISOL_ACK_RISE BIT(14) +#define PMU_MASK_EVENT2_ISOL_ACK_FALL BIT(15) +#define PMU_MASK_EVENT2_HOST_RST_RISE BIT(16) +#define PMU_MASK_EVENT2_HOST_RST_FALL BIT(17) +#define PMU_MASK2_ALL_EVENTS \ + (PMU_MASK_EVENT2_SRAM_ERASE0 | PMU_MASK_EVENT2_SRAM_ERASE1 | \ + PMU_MASK_EVENT2_ISOL_ACK_RISE | PMU_MASK_EVENT2_ISOL_ACK_FALL | \ + PMU_MASK_EVENT2_HOST_RST_RISE | PMU_MASK_EVENT2_HOST_RST_FALL) #define PMU_RF_ROM_PWR_CTRL REG32(ISH_PMU_BASE + 0x30) -- cgit v1.2.1 From 62b71b15e13f41e5403c6d9abe216bf8c88af444 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 1 Nov 2022 11:37:22 -0700 Subject: common/uart_printf: Change uart_put/uart_put_raw return value Instead of returning EC_SUCCESS/EC_ERROR_OVERFLOW, return the number of characters written. This makes retrying for the failures possible and is compatible with the semantics of write(). This should have no effect on existing code, since uart_put() is not used anywhere. The only place that uart_put_raw is used, the return value is ignored. BRANCH=none BUG=b:234181908, b:254530679 TEST=make buildall LOW_COVERAGE_REASON=legacy code Signed-off-by: Tom Hughes Change-Id: If9e8f01663f160b44bbcc4bb313327486dd0d4d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997614 Reviewed-by: Keith Short --- common/uart_printf.c | 14 ++++++++------ include/uart.h | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/common/uart_printf.c b/common/uart_printf.c index 6f8ebb5cbc..01fd1353d2 100644 --- a/common/uart_printf.c +++ b/common/uart_printf.c @@ -44,30 +44,32 @@ int uart_puts(const char *outstr) int uart_put(const char *out, int len) { + int written; + /* Put all characters in the output buffer */ - while (len--) { + for (written = 0; written < len; written++) { if (__tx_char(NULL, *out++) != 0) break; } uart_tx_start(); - /* Successful if we consumed all output */ - return len ? EC_ERROR_OVERFLOW : EC_SUCCESS; + return written; } int uart_put_raw(const char *out, int len) { + int written; + /* Put all characters in the output buffer */ - while (len--) { + for (written = 0; written < len; written++) { if (uart_tx_char_raw(NULL, *out++) != 0) break; } uart_tx_start(); - /* Successful if we consumed all output */ - return len ? EC_ERROR_OVERFLOW : EC_SUCCESS; + return written; } int uart_vprintf(const char *format, va_list args) diff --git a/include/uart.h b/include/uart.h index 851b331fd2..5af95df98d 100644 --- a/include/uart.h +++ b/include/uart.h @@ -52,7 +52,7 @@ int uart_puts(const char *outstr); * * @param out Pointer to data to send * @param len Length of transfer in bytes - * @return EC_SUCCESS, or non-zero if output was truncated. + * @return number of characters successfully written. */ int uart_put(const char *out, int len); @@ -61,7 +61,7 @@ int uart_put(const char *out, int len); * * @param out Pointer to data to send * @param len Length of transfer in bytes - * @return EC_SUCCESS, or non-zero if output was truncated. + * @return number of characters successfully written. */ int uart_put_raw(const char *out, int len); -- cgit v1.2.1 From d05099c826aed67f4b132c44d8e18a2fc1e6c489 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 1 Nov 2022 11:40:30 -0700 Subject: libc/syscalls: Implement _write All output goes to the UART. _write is used by printf(), so this allows printf() to work correctly. BRANCH=none BUG=b:234181908, b:254530679 TEST=./test/run_device_tests.py --board dartmonkey -t libc_printf Signed-off-by: Tom Hughes Change-Id: I60a5f283975c21dabac395f00b4738a6db083d29 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997615 Reviewed-by: Bobby Casey Code-Coverage: Zoss Reviewed-by: Andrea Grandi --- libc/syscalls.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libc/syscalls.c b/libc/syscalls.c index 9c683a2732..43955a0ddd 100644 --- a/libc/syscalls.c +++ b/libc/syscalls.c @@ -14,6 +14,7 @@ #include "panic.h" #include "software_panic.h" #include "task.h" +#include "uart.h" /** * Reboot the system. @@ -27,3 +28,18 @@ void _exit(int rc) panic_printf("%s called with rc: %d\n", __func__, rc); software_panic(PANIC_SW_EXIT, task_get_current()); } + +/** + * Write to the UART. + * + * This function is called from libc functions such as printf(). + * + * @param fd ignored + * @param buf buffer to write + * @param len number of bytes in @buf to write + * @return number of bytes successfully written + */ +int _write(int fd, char *buf, int len) +{ + return uart_put(buf, len); +} -- cgit v1.2.1 From 3136b90d32c48ad4c788e99bf5fbffc8d72580b4 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 1 Nov 2022 13:08:27 -0700 Subject: test: Add libc_printf test BRANCH=none BUG=b:234181908, b:254530679 TEST=./test/run_device_tests.py --board dartmonkey -t libc_printf Signed-off-by: Tom Hughes Change-Id: I5ac9838dd59cb048325a27cc28d7859da040b52d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997616 Code-Coverage: Zoss Reviewed-by: Bobby Casey Reviewed-by: Andrea Grandi --- board/hatch_fp/build.mk | 1 + board/nocturne_fp/build.mk | 1 + board/nucleo-dartmonkey/build.mk | 1 + board/nucleo-f412zg/build.mk | 1 + board/nucleo-h743zi/build.mk | 1 + test/build.mk | 3 +++ test/libc_printf.c | 28 ++++++++++++++++++++++++++++ test/libc_printf.tasklist | 9 +++++++++ test/run_device_tests.py | 5 +++++ 9 files changed, 50 insertions(+) create mode 100644 test/libc_printf.c create mode 100644 test/libc_printf.tasklist diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk index 8ff7ec6cfb..17e85cfb05 100644 --- a/board/hatch_fp/build.mk +++ b/board/hatch_fp/build.mk @@ -40,6 +40,7 @@ test-list-y=\ flash_write_protect \ fpsensor \ fpsensor_hw \ + libc_printf \ mpu \ mutex \ panic \ diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk index cd3981263c..d91229c7e3 100644 --- a/board/nocturne_fp/build.mk +++ b/board/nocturne_fp/build.mk @@ -40,6 +40,7 @@ test-list-y=\ flash_write_protect \ fpsensor \ fpsensor_hw \ + libc_printf \ mpu \ mutex \ panic \ diff --git a/board/nucleo-dartmonkey/build.mk b/board/nucleo-dartmonkey/build.mk index 2e3e1f31d2..809db95260 100644 --- a/board/nucleo-dartmonkey/build.mk +++ b/board/nucleo-dartmonkey/build.mk @@ -22,6 +22,7 @@ test-list-y=\ flash_write_protect \ fpsensor \ fpsensor_hw \ + libc_printf \ mpu \ mutex \ pingpong \ diff --git a/board/nucleo-f412zg/build.mk b/board/nucleo-f412zg/build.mk index 21a2955bc4..37402b7e68 100644 --- a/board/nucleo-f412zg/build.mk +++ b/board/nucleo-f412zg/build.mk @@ -19,6 +19,7 @@ test-list-y=\ exception \ flash_physical \ flash_write_protect \ + libc_printf \ mpu \ mutex \ pingpong \ diff --git a/board/nucleo-h743zi/build.mk b/board/nucleo-h743zi/build.mk index 6153d85d8a..3a59c5d47d 100644 --- a/board/nucleo-h743zi/build.mk +++ b/board/nucleo-h743zi/build.mk @@ -19,6 +19,7 @@ test-list-y=\ exception \ flash_physical \ flash_write_protect \ + libc_printf \ mpu \ mutex \ pingpong \ diff --git a/test/build.mk b/test/build.mk index a4f9ee74b8..eee0e86179 100644 --- a/test/build.mk +++ b/test/build.mk @@ -223,6 +223,9 @@ online_calibration-y=online_calibration.o online_calibration_spoof-y=online_calibration_spoof.o gyro_cal_init_for_test.o rgb_keyboard-y=rgb_keyboard.o kasa-y=kasa.o +ifeq ($(USE_BUILTIN_STDLIB), 0) +libc_printf-y=libc_printf.o +endif mpu-y=mpu.o mutex-y=mutex.o newton_fit-y=newton_fit.o diff --git a/test/libc_printf.c b/test/libc_printf.c new file mode 100644 index 0000000000..b3f5f03605 --- /dev/null +++ b/test/libc_printf.c @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "test_util.h" + +test_static int test_printf(void) +{ + /* + * The test itself is not verifying that printing works (according to + * the test framework, this will always pass). + * + * Instead, the test runner (test/run_device_tests.py) looks for the + * printed string in the test output to determine if the test passed. + */ + printf("printf called\n"); + return EC_SUCCESS; +} + +void run_test(int argc, const char **argv) +{ + test_reset(); + RUN_TEST(test_printf); + test_print_result(); +} diff --git a/test/libc_printf.tasklist b/test/libc_printf.tasklist new file mode 100644 index 0000000000..959f62ef79 --- /dev/null +++ b/test/libc_printf.tasklist @@ -0,0 +1,9 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * See CONFIG_TASK_LIST in config.h for details. + */ +#define CONFIG_TEST_TASK_LIST diff --git a/test/run_device_tests.py b/test/run_device_tests.py index 0aee1428f5..cfa034ac91 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -91,6 +91,7 @@ DATA_ACCESS_VIOLATION_20000000_REGEX = re.compile( DATA_ACCESS_VIOLATION_24000000_REGEX = re.compile( r"Data access violation, mfar = 24000000\r\n" ) +PRINTF_CALLED_REGEX = re.compile(r"printf called\r\n") BLOONCHIPPER = "bloonchipper" DARTMONKEY = "dartmonkey" @@ -235,6 +236,10 @@ class AllTests: test_name="fpsensor", test_args=["uart"], ), + TestConfig( + test_name="libc_printf", + finish_regexes=[PRINTF_CALLED_REGEX], + ), TestConfig( config_name="mpu_ro", test_name="mpu", -- cgit v1.2.1 From 1a7cf3ec154c635565abdfe9f9682523ac42e258 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Thu, 3 Nov 2022 13:36:31 -0600 Subject: zephyr/test: Add missing header Gcc-10 was reporting an implicit declaration of function, include the header that defines it. BRANCH=None BUG=None TEST=./twister with gcc Signed-off-by: Jeremy Bettis Change-Id: Ic910826da6c8c65c48b6fc6e83b50c77310a65fb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4004760 Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Reviewed-by: Madhu P Reviewed-by: Keith Short Commit-Queue: Keith Short Code-Coverage: Zoss --- zephyr/test/rex/src/usb_pd_policy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/test/rex/src/usb_pd_policy.c b/zephyr/test/rex/src/usb_pd_policy.c index d977bec0a1..f6a5ce4ee7 100644 --- a/zephyr/test/rex/src/usb_pd_policy.c +++ b/zephyr/test/rex/src/usb_pd_policy.c @@ -10,6 +10,7 @@ #include "chipset.h" #include "ec_commands.h" #include "usb_pd.h" +#include "usb_charge.h" #include "usbc_ppc.h" DECLARE_FAKE_VALUE_FUNC(int, chipset_in_state, int); -- cgit v1.2.1 From a00dcdf628affb00ddf719d49bb8b5e3bec92930 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Thu, 3 Nov 2022 13:29:40 -0600 Subject: util: Use correct output dir When twister_launcher.py looks at the output to determine if there were skipped tests or to upload results, it hardcoded the output dir. Instead, inspect the command line to see if the user modified the output dir and look there for the results instead. BRANCH=None BUG=None TEST=./twister --outdir twister-out-foobar Signed-off-by: Jeremy Bettis Change-Id: Ia5c15dfe3eb954df29c3912d037abebfc0b209f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4004757 Commit-Queue: Al Semjonovs Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Commit-Queue: Jeremy Bettis Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- util/twister_launcher.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/util/twister_launcher.py b/util/twister_launcher.py index 033b4c59dd..48c9a0e960 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -77,6 +77,7 @@ parameters that may be used, please consult the Twister documentation. import argparse import json import os +import pathlib import re import shlex import subprocess @@ -167,12 +168,12 @@ def is_rdb_login(): return ret.returncode == 0 -def upload_results(ec_base): +def upload_results(ec_base, outdir): """Uploads Zephyr Test results to ResultDB""" flag = False if is_rdb_login(): - json_path = ec_base / "twister-out" / "twister.json" + json_path = pathlib.Path(outdir) / "twister.json" cmd = [ "rdb", "stream", @@ -201,10 +202,10 @@ def upload_results(ec_base): return flag -def check_for_skipped_tests(ec_base): +def check_for_skipped_tests(outdir): """Checks Twister json test report for skipped tests""" found_skipped = False - json_path = ec_base / "twister-out" / "twister.json" + json_path = pathlib.Path(outdir) / "twister.json" with open(json_path) as file: data = json.load(file) @@ -282,6 +283,11 @@ def main(): parser.add_argument( "--no-upload-cros-rdb", dest="upload_cros_rdb", action="store_false" ) + parser.add_argument( + "-O", + "--outdir", + default=os.path.join(os.getcwd(), "twister-out"), + ) intercepted_args, other_args = parser.parse_known_args() @@ -316,6 +322,8 @@ def main(): twister_cli.extend(["-p", "native_posix"]) twister_cli.extend(["-p", "unit_testing"]) + twister_cli.extend(["--outdir", intercepted_args.outdir]) + # Append additional user-supplied args twister_cli.extend(other_args) @@ -334,7 +342,7 @@ def main(): # Invoke Twister and wait for it to exit. result = subprocess.run(twister_cli, env=twister_env, check=False) - if check_for_skipped_tests(ec_base): + if check_for_skipped_tests(intercepted_args.outdir): result.returncode = 1 if result.returncode == 0: @@ -343,7 +351,7 @@ def main(): print("TEST EXECUTION FAILED") if is_tool("rdb") and intercepted_args.upload_cros_rdb: - upload_results(ec_base) + upload_results(ec_base, intercepted_args.outdir) sys.exit(result.returncode) -- cgit v1.2.1 From d889135ff840ec5055023a7c68522d4481286392 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Thu, 3 Nov 2022 13:32:55 -0600 Subject: zephyr/test: Increase buffer size The expected buffer is too small for the format string. Increase it and add header for snprintf. BRANCH=None BUG=None TEST=./twister with gcc Signed-off-by: Jeremy Bettis Change-Id: I27310ae77db004e2b1aafa0aa95eefd40a4011d7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4004758 Auto-Submit: Jeremy Bettis Commit-Queue: Al Semjonovs Code-Coverage: Zoss Reviewed-by: Yuval Peress Tested-by: Jeremy Bettis Commit-Queue: Yuval Peress Reviewed-by: Al Semjonovs Commit-Queue: Jeremy Bettis --- zephyr/test/drivers/default/src/console_cmd/ec_features.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/zephyr/test/drivers/default/src/console_cmd/ec_features.c b/zephyr/test/drivers/default/src/console_cmd/ec_features.c index b33ca565bc..3e355af988 100644 --- a/zephyr/test/drivers/default/src/console_cmd/ec_features.c +++ b/zephyr/test/drivers/default/src/console_cmd/ec_features.c @@ -6,6 +6,7 @@ #include #include +#include "builtin/stdio.h" #include "console.h" #include "host_command.h" #include "test/drivers/test_state.h" @@ -16,10 +17,13 @@ ZTEST_SUITE(console_cmd_ec_features, drivers_predicate_post_main, NULL, NULL, ZTEST_USER(console_cmd_ec_features, test_feat) { - char expected[32]; + char expected[50]; + int ret; - snprintf(expected, sizeof(expected), " 0-31: 0x%08x\r\n32-63: 0x%08x", - get_feature_flags0(), get_feature_flags1()); + ret = snprintf(expected, sizeof(expected), + " 0-31: 0x%08x\r\n32-63: 0x%08x", get_feature_flags0(), + get_feature_flags1()); + zassert_true(ret >= 0 && ret < sizeof(expected)); CHECK_CONSOLE_CMD("feat", expected, EC_SUCCESS); } -- cgit v1.2.1 From f4ba6864765f18ef970793d24ecedc5711f490a7 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 11:29:19 +0000 Subject: zephyr: dts: fix various dts syntax inconsistencies Fix various dts syntax inconsistencies. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I0e921d9929ccc1f18b1b45e8b877cb20cd6205fb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999723 Code-Coverage: Zoss Reviewed-by: Wai-Hong Tam --- .../intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts | 4 ++-- zephyr/projects/rex/power_signals.dts | 16 ++++++++-------- zephyr/projects/rex/rex.dts | 6 +++--- zephyr/projects/skyrim/battery_winterhold.dts | 12 ++++++------ zephyr/projects/skyrim/i2c_common.dtsi | 12 ++++++------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts index 86a46e3e7a..44f283071b 100644 --- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts +++ b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts @@ -162,7 +162,7 @@ reg = <0x73>; label = "NCT38XX_C0"; - ioex_c0:gpio@0 { + ioex_c0: gpio@0 { compatible = "nuvoton,nct38xx-gpio-port"; reg = <0x0>; label = "NCT38XX_C0_GPIO0"; @@ -188,7 +188,7 @@ reg = <0x77>; label = "NCT38XX_C1"; - ioex_c1:gpio@0 { + ioex_c1: gpio@0 { compatible = "nuvoton,nct38xx-gpio-port"; reg = <0x0>; label = "NCT38XX_C1_GPIO0"; diff --git a/zephyr/projects/rex/power_signals.dts b/zephyr/projects/rex/power_signals.dts index 860c316795..09c84b8558 100644 --- a/zephyr/projects/rex/power_signals.dts +++ b/zephyr/projects/rex/power_signals.dts @@ -111,42 +111,42 @@ }; /* pwr-pg-ec-rsmrst-od */ -&gpio_seq_ec_rsmrst_odl{ +&gpio_seq_ec_rsmrst_odl { no-auto-init; }; /* pwr-ec-pch-rsmrst-odl */ -&gpio_ec_soc_rsmrst_l{ +&gpio_ec_soc_rsmrst_l { no-auto-init; }; /* pwr-pch-pwrok */ -&gpio_soc_pwrok{ +&gpio_soc_pwrok { no-auto-init; }; /* pwr-ec-pch-sys-pwrok */ -&gpio_sys_pwrok{ +&gpio_sys_pwrok { no-auto-init; }; /* pwr-sys-rst-l */ -&gpio_sys_rst_odl{ +&gpio_sys_rst_odl { no-auto-init; }; /* pwr-slp-s0-l */ -&gpio_sys_slp_s0ix_3v3_l{ +&gpio_sys_slp_s0ix_3v3_l { no-auto-init; }; /* pwr-slp-s3-l */ -&gpio_slp_s3_ls_l{ +&gpio_slp_s3_ls_l { no-auto-init; }; /* pwr-all-sys-pwrgd */ -&gpio_seq_ec_all_sys_pg{ +&gpio_seq_ec_all_sys_pg { no-auto-init; }; diff --git a/zephyr/projects/rex/rex.dts b/zephyr/projects/rex/rex.dts index 0db4b96aa7..2d7e1b89ba 100644 --- a/zephyr/projects/rex/rex.dts +++ b/zephyr/projects/rex/rex.dts @@ -117,14 +117,14 @@ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; }; - nct3807_C0:nct3807_C0@70 { + nct3807_C0: nct3807_C0@70 { #address-cells = <1>; #size-cells = <0>; compatible = "nuvoton,nct38xx-gpio"; reg = <0x70>; label = "NCT3807_C0"; - ioex_c0_port0:gpio@0 { + ioex_c0_port0: gpio@0 { compatible = "nuvoton,nct38xx-gpio-port"; reg = <0x0>; label = "NCT3807_C0_GPIO0"; @@ -134,7 +134,7 @@ pin_mask = <0xff>; pinmux_mask = <0xf7>; }; - ioex_c0_port1:gpio@1 { + ioex_c0_port1: gpio@1 { compatible = "nuvoton,nct38xx-gpio-port"; reg = <0x1>; label = "NCT3807_C0_GPIO1"; diff --git a/zephyr/projects/skyrim/battery_winterhold.dts b/zephyr/projects/skyrim/battery_winterhold.dts index d923243d45..8e82e0d1f2 100644 --- a/zephyr/projects/skyrim/battery_winterhold.dts +++ b/zephyr/projects/skyrim/battery_winterhold.dts @@ -11,22 +11,22 @@ smp_atlxdy9k { compatible = "smp,atlxdy9k", "battery-smart"; }; - smp_cosxdy9k{ + smp_cosxdy9k { compatible = "smp,cosxdy9k", "battery-smart"; }; - byd_wv3k8{ + byd_wv3k8 { compatible = "byd,wv3k8", "battery-smart"; }; - cosmx_mvk11{ + cosmx_mvk11 { compatible = "cosmx,mvk11", "battery-smart"; }; - sunwoda_atlvkyjx{ + sunwoda_atlvkyjx { compatible = "sunwoda,atlvkyjx", "battery-smart"; }; - sunwoda_cosvkyjx{ + sunwoda_cosvkyjx { compatible = "sunwoda,cosvkyjx", "battery-smart"; }; - atl_cfd72{ + atl_cfd72 { compatible = "atl,cfd72", "battery-smart"; }; }; diff --git a/zephyr/projects/skyrim/i2c_common.dtsi b/zephyr/projects/skyrim/i2c_common.dtsi index aaf54a161b..460a6bcfd2 100644 --- a/zephyr/projects/skyrim/i2c_common.dtsi +++ b/zephyr/projects/skyrim/i2c_common.dtsi @@ -85,14 +85,14 @@ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; }; - nct3807_C0:nct3807_C0@70 { + nct3807_C0: nct3807_C0@70 { #address-cells = <1>; #size-cells = <0>; compatible = "nuvoton,nct38xx-gpio"; reg = <0x70>; label = "NCT3807_C0"; - ioex_c0_port0:gpio@0 { + ioex_c0_port0: gpio@0 { compatible = "nuvoton,nct38xx-gpio-port"; reg = <0x0>; label = "NCT3807_C0_GPIO0"; @@ -102,7 +102,7 @@ pin_mask = <0xff>; pinmux_mask = <0xf7>; }; - ioex_c0_port1:gpio@1 { + ioex_c0_port1: gpio@1 { compatible = "nuvoton,nct38xx-gpio-port"; reg = <0x1>; label = "NCT3807_C0_GPIO1"; @@ -146,14 +146,14 @@ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; }; - nct3807_C1:nct3807_C1@70 { + nct3807_C1: nct3807_C1@70 { #address-cells = <1>; #size-cells = <0>; compatible = "nuvoton,nct38xx-gpio"; reg = <0x70>; label = "NCT3807_C1"; - ioex_c1_port0:gpio@0 { + ioex_c1_port0: gpio@0 { compatible = "nuvoton,nct38xx-gpio-port"; reg = <0x0>; label = "NCT3807_C1_GPIO0"; @@ -163,7 +163,7 @@ pin_mask = <0xff>; pinmux_mask = <0xf7>; }; - ioex_c1_port1:gpio@1 { + ioex_c1_port1: gpio@1 { compatible = "nuvoton,nct38xx-gpio-port"; reg = <0x1>; label = "NCT3807_C1_GPIO1"; -- cgit v1.2.1 From 23fd725b83abdcb50eb99f69e6a4b102489ba3f7 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 4 Nov 2022 09:50:52 -0600 Subject: cq: Run verbose make for better debugging There have been several mysterious failures in the CQ and it's hard to see what is going on since make doesn't print the commands by default. BRANCH=None BUG=b:257393779 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: I4e4db7ef328b01f52d820405db036ef881d06405 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005654 Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Reviewed-by: Al Semjonovs Code-Coverage: Zoss Commit-Queue: Al Semjonovs --- firmware_builder.py | 10 +++++----- zephyr/firmware_builder.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware_builder.py b/firmware_builder.py index ff7f524d78..e24d87459e 100755 --- a/firmware_builder.py +++ b/firmware_builder.py @@ -74,11 +74,11 @@ def build(opts): ec_dir = pathlib.Path(__file__).parent subprocess.run([ec_dir / "util" / "check_clang_format.py"], check=True) - cmd = ["make", "clobber"] + cmd = ["make", "clobber", "V=1"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) - cmd = ["make", "buildall_only", f"-j{opts.cpus}"] + cmd = ["make", "buildall_only", f"-j{opts.cpus}", "V=1"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) @@ -239,7 +239,7 @@ def test(opts): # Otherwise, build the 'runtests' target, which verifies all # posix-based unit tests build and pass. target = "coverage" if opts.code_coverage else "runtests" - cmd = ["make", target, f"-j{opts.cpus}"] + cmd = ["make", target, f"-j{opts.cpus}", "V=1"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) @@ -247,13 +247,13 @@ def test(opts): # Verify compilation of the on-device unit test binaries. # TODO(b/172501728) These should build for all boards, but they've bit # rotted, so we only build the ones that compile. - cmd = ["make", f"-j{opts.cpus}"] + cmd = ["make", f"-j{opts.cpus}", "V=1"] cmd.extend(["tests-" + b for b in BOARDS_UNIT_TEST]) print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) # Verify the tests pass with ASan also - cmd = ["make", "TEST_ASAN=y", target, f"-j{opts.cpus}"] + cmd = ["make", "TEST_ASAN=y", target, f"-j{opts.cpus}", "V=1"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index 5173313b58..fd46f200f9 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -79,7 +79,7 @@ def build(opts): ) # Start with a clean build environment - cmd = ["make", "clobber"] + cmd = ["make", "clobber", "V=1"] log_cmd(cmd) subprocess.run(cmd, cwd=platform_ec, check=True, stdin=subprocess.DEVNULL) @@ -269,7 +269,7 @@ def test(opts): ).stdout _extract_lcov_summary("EC_ZEPHYR_TESTS", metrics, output) - cmd = ["make", "test-coverage", f"-j{opts.cpus}"] + cmd = ["make", "test-coverage", f"-j{opts.cpus}", "V=1"] log_cmd(cmd) subprocess.run( cmd, cwd=platform_ec, check=True, stdin=subprocess.DEVNULL -- cgit v1.2.1 From 408ac447c3796300d11e2c5585fc5742a9b4de53 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Wed, 2 Nov 2022 15:34:36 -0600 Subject: usb_common: Remove pd_is_debug_acc This function is not used anywhere. BUG=b:256182103 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I8fbf1ed2f0f3006f8899b638138d0d2374e85a5a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000784 Reviewed-by: Diana Z Code-Coverage: Zoss --- common/usb_common.c | 12 ------------ include/usb_pd.h | 7 ------- 2 files changed, 19 deletions(-) diff --git a/common/usb_common.c b/common/usb_common.c index 2ef12e9412..9d7159f81d 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -198,18 +198,6 @@ enum pd_cc_states pd_get_cc_state(enum tcpc_cc_voltage_status cc1, return PD_CC_NONE; } -/** - * This function checks the current CC status of the port partner - * and returns true if the attached partner is debug accessory. - */ -bool pd_is_debug_acc(int port) -{ - enum pd_cc_states cc_state = pd_get_task_cc_state(port); - - return cc_state == PD_CC_UFP_DEBUG_ACC || - cc_state == PD_CC_DFP_DEBUG_ACC; -} - __overridable int pd_board_check_request(uint32_t rdo, int pdo_cnt) { return EC_SUCCESS; diff --git a/include/usb_pd.h b/include/usb_pd.h index bf385c19c2..b2cadbc0d7 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -3188,13 +3188,6 @@ __override_proto void board_process_pd_alert(int port); */ void board_reset_pd_mcu(void); -/** - * Return true if specified PD port is debug accessory. - * - * @param port USB-C port number - */ -bool pd_is_debug_acc(int port); - /* * Notify the AP that we have entered into DisplayPort Alternate Mode. This * sets a DP_ALT_MODE_ENTERED MKBP event which may wake the AP. -- cgit v1.2.1 From 366174d656fbc6d853f8d31e0751c35bff5aeaaf Mon Sep 17 00:00:00 2001 From: Allen Webb Date: Fri, 4 Nov 2022 13:03:31 -0500 Subject: Use the sdk pkg-config when building gen_touchpad_hash. `gen_touchpad_hash` is compiled to run on the builder, so use pkg-config from the builder to avoid races such as openssl not being installed for the target when it is installed for the SDK. BRANCH=none BUG=b:257362347 TEST=emerge-strongbad chromeos-ec # and strongbad-cq passes Change-Id: I59464cda5b1842b9aafc20244e4218f8a80f7442 Signed-off-by: Allen Webb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4006181 Reviewed-by: Gregory Nisbet Code-Coverage: Zoss Reviewed-by: George Engelbrecht Reviewed-by: Jack Rosenthal --- util/build.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/build.mk b/util/build.mk index 2f7f6c48ff..12479d4a7c 100644 --- a/util/build.mk +++ b/util/build.mk @@ -97,11 +97,11 @@ build-util-bin-y += gen_touchpad_hash # Assume RW section (touchpad FW must be identical for both RO+RW) $(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += -DSECTION_IS_RW=$(EMPTY) -HOST_OPENSSL_CFLAGS := $(shell $(HOST_PKG_CONFIG) --cflags openssl) -HOST_OPENSSL_LDFLAGS := $(shell $(HOST_PKG_CONFIG) --libs openssl) +BUILD_OPENSSL_CFLAGS := $(shell $(BUILD_PKG_CONFIG) --cflags openssl) +BUILD_OPENSSL_LDFLAGS := $(shell $(BUILD_PKG_CONFIG) --libs openssl) -$(out)/util/gen_touchpad_hash: BUILD_CFLAGS += $(HOST_OPENSSL_CFLAGS) -$(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += $(HOST_OPENSSL_LDFLAGS) +$(out)/util/gen_touchpad_hash: BUILD_CFLAGS += $(BUILD_OPENSSL_CFLAGS) +$(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += $(BUILD_OPENSSL_LDFLAGS) deps-y += $(out)/util/gen_touchpad_hash.d endif # CONFIG_TOUCHPAD_VIRTUAL_OFF -- cgit v1.2.1 From bfb09dd789ef4eedcc213abe0aacb2646874626b Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 28 Oct 2022 11:38:13 -0600 Subject: zephyr: Create CMake variable for the program directory Many board tests need a path to the board specific sources. Add PROGRAM_EC_PROGRAM_DIR as a helper variable BUG=b:254097139 BRANCH=none TEST=twister -v -i -c Signed-off-by: Keith Short Change-Id: I71a7c555101fff3ba6158962cd333da642562b24 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000782 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- CMakeLists.txt | 3 +++ zephyr/test/herobrine/CMakeLists.txt | 4 ++-- zephyr/test/kingler/CMakeLists.txt | 8 ++++---- zephyr/test/krabby/CMakeLists.txt | 8 ++++---- zephyr/test/rex/CMakeLists.txt | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b2f3525fe..e4d48e00b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,9 @@ endif() set(PLATFORM_EC "${ZEPHYR_CURRENT_MODULE_DIR}" CACHE PATH "Path to the platform/ec repo.") +set(PLATFORM_EC_PROGRAM_DIR "${PLATFORM_EC}/zephyr/projects" CACHE PATH + "Path to the root directory containing all Zephyr EC programs and projects.") + if(NOT EXISTS "${PLATFORM_EC}/zephyr/module.yml") message(FATAL_ERROR "Failed to resolve PLATFORM_EC at ${PLATFORM_EC}/zephyr/module.yml") diff --git a/zephyr/test/herobrine/CMakeLists.txt b/zephyr/test/herobrine/CMakeLists.txt index 800762ed8e..17b3d973a1 100644 --- a/zephyr/test/herobrine/CMakeLists.txt +++ b/zephyr/test/herobrine/CMakeLists.txt @@ -6,9 +6,9 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(herobrine) -zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/herobrine/include") +zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/herobrine/include") target_sources_ifdef(CONFIG_TEST_BOARD_CHIPSET app PRIVATE src/board_chipset.c) target_sources_ifdef(CONFIG_TEST_BOARD_CHIPSET - app PRIVATE ${PLATFORM_EC}/zephyr/projects/herobrine/src/board_chipset.c) + app PRIVATE ${PLATFORM_EC_PROGRAM_DIR}/herobrine/src/board_chipset.c) diff --git a/zephyr/test/kingler/CMakeLists.txt b/zephyr/test/kingler/CMakeLists.txt index 4a30d06a61..725831d2db 100644 --- a/zephyr/test/kingler/CMakeLists.txt +++ b/zephyr/test/kingler/CMakeLists.txt @@ -8,18 +8,18 @@ project(kingler) add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) -zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/corsola/include") +zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/corsola/include") target_sources(app PRIVATE src/fakes.c) target_sources_ifdef(CONFIG_TEST_STEELIX_RUSTY -app PRIVATE ${PLATFORM_EC}/zephyr/projects/corsola/src/kingler/board_steelix.c) +app PRIVATE ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/kingler/board_steelix.c) target_sources_ifdef(CONFIG_TEST_FORM_FACTOR_CONVERTIBLE app PRIVATE src/tablet.c) target_sources_ifdef(CONFIG_TEST_FORM_FACTOR_CLAMSHELL app PRIVATE src/clamshell.c) target_sources_ifdef(CONFIG_VARIANT_CORSOLA_DB_DETECTION -app PRIVATE ${PLATFORM_EC}/zephyr/projects/corsola/src/variant_db_detection.c) +app PRIVATE ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/variant_db_detection.c) target_sources_ifdef(CONFIG_TEST_DB_DETECT_TYPEC app PRIVATE src/db_detect_typec.c) target_sources_ifdef(CONFIG_TEST_DB_DETECT_HDMI @@ -32,4 +32,4 @@ target_sources_ifdef(CONFIG_TEST_DB_DETECT_NONE target_sources_ifdef(CONFIG_TEST_ALT_SENSOR_PROBE app PRIVATE src/alt_sensor.c) target_sources_ifdef(CONFIG_TEST_KINGLER_CCD -app PRIVATE src/ccd.c ${PLATFORM_EC}/zephyr/projects/corsola/src/board.c) +app PRIVATE src/ccd.c ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/board.c) diff --git a/zephyr/test/krabby/CMakeLists.txt b/zephyr/test/krabby/CMakeLists.txt index bb96633d5b..ce13e9520a 100644 --- a/zephyr/test/krabby/CMakeLists.txt +++ b/zephyr/test/krabby/CMakeLists.txt @@ -8,19 +8,19 @@ project(krabby) add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) -zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/corsola/include") +zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/corsola/include") target_sources(app PRIVATE src/stubs.c - ${PLATFORM_EC}/zephyr/projects/corsola/src/krabby/usbc_config.c) + ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/usbc_config.c) target_sources_ifdef(CONFIG_TEST_KRABBY app PRIVATE src/charger_workaround.c src/usb_mux_init.c - ${PLATFORM_EC}/zephyr/projects/corsola/src/krabby/charger_workaround.c) + ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/charger_workaround.c) target_sources_ifdef(CONFIG_TEST_TENTACRUEL app PRIVATE src/temp_tentacruel.c - ${PLATFORM_EC}/zephyr/projects/corsola/src/krabby/temp_tentacruel.c) + ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/temp_tentacruel.c) diff --git a/zephyr/test/rex/CMakeLists.txt b/zephyr/test/rex/CMakeLists.txt index 89d646a747..ddee5d0120 100644 --- a/zephyr/test/rex/CMakeLists.txt +++ b/zephyr/test/rex/CMakeLists.txt @@ -6,9 +6,9 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(rex) -zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/rex/include") +zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/rex/include") add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) target_sources_ifdef(CONFIG_TEST_USB_PD_POLICY app PRIVATE src/usb_pd_policy.c) -target_sources_ifdef(CONFIG_TEST_USB_PD_POLICY app PRIVATE ${PLATFORM_EC}/zephyr/projects/rex/src/usb_pd_policy.c) +target_sources_ifdef(CONFIG_TEST_USB_PD_POLICY app PRIVATE ${PLATFORM_EC_PROGRAM_DIR}/rex/src/usb_pd_policy.c) -- cgit v1.2.1 From 0c59f9fb3291e529bd223c52f328e3b9d673ceb0 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 1 Nov 2022 23:23:12 -0600 Subject: test: add tests for console command pwr_avg Add tests for all but the error case for the pwr_avg console command. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: Icddfbf8341ad5dfb2f4bbfeee2026ea1b0165c96 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3998267 Code-Coverage: Zoss Reviewed-by: Jeremy Bettis Commit-Queue: Jeremy Bettis --- util/config_allowed.txt | 1 - zephyr/Kconfig.charger | 7 ++++ zephyr/shim/include/config_chip.h | 5 +++ zephyr/test/drivers/default/CMakeLists.txt | 1 + .../test/drivers/default/src/console_cmd/pwr_avg.c | 47 ++++++++++++++++++++++ zephyr/test/drivers/prj.conf | 1 + 6 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 zephyr/test/drivers/default/src/console_cmd/pwr_avg.c diff --git a/util/config_allowed.txt b/util/config_allowed.txt index a98833624e..fd5fcc2e30 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -286,7 +286,6 @@ CONFIG_CMD_POWERLED CONFIG_CMD_POWER_AP CONFIG_CMD_PPC_DUMP CONFIG_CMD_PS2 -CONFIG_CMD_PWR_AVG CONFIG_CMD_RAND CONFIG_CMD_REGULATOR CONFIG_CMD_RESET_FLAGS diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger index 58a094e553..4f231c5e68 100644 --- a/zephyr/Kconfig.charger +++ b/zephyr/Kconfig.charger @@ -71,6 +71,13 @@ config PLATFORM_EC_CHARGE_STATE_DEBUG this config will allow the EC_CMD_CHARGE_STATE host command to use the CHARGE_STATE_CMD_GET_PARAM command to query the current charge state. +config PLATFORM_EC_CMD_PWR_AVG + bool "Enable the console command to print power average" + depends on PLATFORM_EC_CHARGE_MANAGER + help + Enables the console command which prints out the current (past 1 + minute) power average. + config PLATFORM_EC_CHARGESPLASH bool "Charging splashscreen support" help diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index f69713fada..2680e647d5 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1034,6 +1034,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #define CONFIG_CHARGE_STATE_DEBUG #endif +#undef CONFIG_CMD_PWR_AVG +#ifdef CONFIG_PLATFORM_EC_CMD_PWR_AVG +#define CONFIG_CMD_PWR_AVG +#endif + #undef CONFIG_CHARGESPLASH #ifdef CONFIG_PLATFORM_EC_CHARGESPLASH #define CONFIG_CHARGESPLASH diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt index 17016e04ea..617dbe7df5 100644 --- a/zephyr/test/drivers/default/CMakeLists.txt +++ b/zephyr/test/drivers/default/CMakeLists.txt @@ -36,6 +36,7 @@ target_sources(app PRIVATE src/console_cmd/port80.c src/console_cmd/powerindebug.c src/console_cmd/power_button.c + src/console_cmd/pwr_avg.c src/console_cmd/rtc.c src/console_cmd/rw.c src/console_cmd/shared_mem.c diff --git a/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c b/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c new file mode 100644 index 0000000000..737fff14d7 --- /dev/null +++ b/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c @@ -0,0 +1,47 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include +#include /* nocheck */ +#include + +#include "battery.h" +#include "console.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" + +ZTEST_SUITE(console_cmd_pwr_avg, drivers_predicate_post_main, NULL, NULL, NULL, + NULL); + +ZTEST_USER(console_cmd_pwr_avg, test_too_many_args) +{ + zassert_equal(EC_ERROR_PARAM_COUNT, + shell_execute_cmd(get_ec_shell(), "pwr_avg 5")); +} + +ZTEST_USER(console_cmd_pwr_avg, test_printout) +{ + int mv = battery_get_avg_voltage(); + int ma = battery_get_avg_current(); + char expected_output[1024]; + const char *buffer; + size_t buffer_size; + + shell_backend_dummy_clear_output(get_ec_shell()); + zassert_ok(shell_execute_cmd(get_ec_shell(), "pwr_avg")); + + buffer = shell_backend_dummy_get_output(get_ec_shell(), &buffer_size); + + sprintf(expected_output, "mv = %d", mv); + zassert_true(strstr(buffer, expected_output)); + + sprintf(expected_output, "ma = %d", ma); + zassert_true(strstr(buffer, expected_output)); + + sprintf(expected_output, "mw = %d", mv * ma / 1000); + zassert_true(strstr(buffer, expected_output)); +} diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 87a6be322b..97257c1c75 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -73,6 +73,7 @@ CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y CONFIG_PLATFORM_EC_CHARGESPLASH=y CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_CMD_PWR_AVG=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -- cgit v1.2.1 From 77859839bdcba8e4d4b92c6324badb18e9fce5a7 Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Fri, 4 Nov 2022 13:41:35 -0600 Subject: include/ec_commands.h: Clean up kernel-doc warnings `repo upload` is failing due to: [FAILED] chromiumos/platform/ec: kerneldoc_check kernel-doc errors/warnings: include/ec_commands.h:1745: warning: Function parameter or member 'data' not described in 'ec_params_flash_write' include/ec_commands.h:1745: warning: Function parameter or member 'data.words32' not described in 'ec_params_flash_write' include/ec_commands.h:1745: warning: Function parameter or member 'data.bytes' not described in 'ec_params_flash_write' Add kernel-doc entries to fix these warnings. BRANCH=none BUG=none TEST=repo upload Signed-off-by: Tim Van Patten Change-Id: I339fe5b67efa8de4579a0f944e3f212a26eb7835 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4006953 Code-Coverage: Zoss Reviewed-by: Raul Rangel --- include/ec_commands.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/ec_commands.h b/include/ec_commands.h index c6f89cd172..82df1e6b54 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -1731,6 +1731,9 @@ struct ec_params_flash_read { * struct ec_params_flash_write - Parameters for the flash write command. * @offset: Byte offset to write. * @size: Size to write in bytes. + * @data: Data to write. + * @data.words32: uint32_t data to write. + * @data.bytes: uint8_t data to write. */ struct ec_params_flash_write { uint32_t offset; -- cgit v1.2.1 From 76c5b9b4048363b1cf87bc1a4dd70162c56079fa Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Thu, 3 Nov 2022 13:38:38 -0600 Subject: cq: Run tests with both gcc and clang. To ensure compatibility with gitlab, run all the zephyr tests with both gcc and llvm/clang. This adds 6 minutes to the build time on my machine but adds 0.4% coverage overall, and 1.7% to herobrine, since it fixes all the uncovered switch case labels. BRANCH=None BUG=None TEST=Ran firmware_builder.py locally Signed-off-by: Jeremy Bettis Change-Id: I5a7c1f2e8f226e18d642eb886fd90c778c7e77d2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4004761 Reviewed-by: Al Semjonovs Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- zephyr/firmware_builder.py | 79 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 11 deletions(-) diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index fd46f200f9..7f0776e2be 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -10,6 +10,7 @@ This is the entry point for the custom firmware builder workflow recipe. import argparse import multiprocessing +import os import pathlib import re import shlex @@ -27,18 +28,45 @@ DEFAULT_BUNDLE_METADATA_FILE = "/tmp/artifact_bundle_metadata" SPECIAL_BOARDS = ["herobrine", "krabby", "nivviks", "skyrim", "kingler"] -def log_cmd(cmd): +def log_cmd(cmd, env=None): """Log subprocess command.""" + if env is not None: + print("env", end=" ") + [ # pylint:disable=expression-not-assigned + print(key + "=" + shlex.quote(str(value)), end=" ") + for key, value in env.items() + ] print(" ".join(shlex.quote(str(x)) for x in cmd)) sys.stdout.flush() -def run_twister(platform_ec, code_coverage=False, extra_args=None): - """Build the tests using twister.""" +def run_twister( + platform_ec, code_coverage=False, extra_args=None, use_gcc=False +): + """Build the tests using twister. + + Returns the path to the twister-out dir. + """ + + third_party_zephyr = platform_ec.parent.parent / "third_party/zephyr/main" + if use_gcc: + c_compiler = "/usr/bin/x86_64-pc-linux-gnu-gcc" + cxx_compiler = "/usr/bin/x86_64-pc-linux-gnu-g++" + outdir = "twister-out-gcc" + env = { + "ZEPHYR_TOOLCHAIN_VARIANT": "host", + "TOOLCHAIN_ROOT": third_party_zephyr, + } + else: + c_compiler = "/usr/bin/x86_64-pc-linux-gnu-clang" + cxx_compiler = "/usr/bin/x86_64-pc-linux-gnu-clang++" + outdir = "twister-out-llvm" + env = {} + cmd = [ platform_ec / "twister", "--outdir", - platform_ec / "twister-out", + platform_ec / outdir, "-v", "-i", "-p", @@ -46,8 +74,8 @@ def run_twister(platform_ec, code_coverage=False, extra_args=None): "-p", "unit_testing", "--no-upload-cros-rdb", - "-x=CMAKE_C_COMPILER=/usr/bin/x86_64-pc-linux-gnu-gcc", - "-x=CMAKE_CXX_COMPILER=/usr/bin/x86_64-pc-linux-gnu-g++", + "-x=CMAKE_C_COMPILER=" + c_compiler, + "-x=CMAKE_CXX_COMPILER=" + cxx_compiler, ] if extra_args: @@ -61,8 +89,18 @@ def run_twister(platform_ec, code_coverage=False, extra_args=None): "--coverage", ] ) - log_cmd(cmd) - subprocess.run(cmd, check=True, cwd=platform_ec, stdin=subprocess.DEVNULL) + log_cmd(cmd, env=env) + my_env = os.environ.copy() + my_env.update(env) + + subprocess.run( + cmd, + check=True, + cwd=platform_ec, + stdin=subprocess.DEVNULL, + env=my_env, + ) + return platform_ec / outdir def build(opts): @@ -250,7 +288,10 @@ def test(opts): # Twister-based tests platform_ec = zephyr_dir.parent third_party = platform_ec.parent.parent / "third_party" - run_twister(platform_ec, opts.code_coverage) + twister_out_dir = run_twister(platform_ec, opts.code_coverage) + twister_out_dir_gcc = run_twister( + platform_ec, opts.code_coverage, use_gcc=True + ) if opts.code_coverage: build_dir = platform_ec / "build" / "zephyr" @@ -259,7 +300,7 @@ def test(opts): [ "/usr/bin/lcov", "--summary", - platform_ec / "twister-out" / "coverage.info", + twister_out_dir / "coverage.info", ], cwd=zephyr_dir, check=True, @@ -269,6 +310,20 @@ def test(opts): ).stdout _extract_lcov_summary("EC_ZEPHYR_TESTS", metrics, output) + output = subprocess.run( + [ + "/usr/bin/lcov", + "--summary", + twister_out_dir_gcc / "coverage.info", + ], + cwd=zephyr_dir, + check=True, + stdout=subprocess.PIPE, + universal_newlines=True, + stdin=subprocess.DEVNULL, + ).stdout + _extract_lcov_summary("EC_ZEPHYR_TESTS_GCC", metrics, output) + cmd = ["make", "test-coverage", f"-j{opts.cpus}", "V=1"] log_cmd(cmd) subprocess.run( @@ -298,7 +353,9 @@ def test(opts): "-a", platform_ec / "build/coverage/lcov.info", "-a", - platform_ec / "twister-out" / "coverage.info", + twister_out_dir / "coverage.info", + "-a", + twister_out_dir_gcc / "coverage.info", ] log_cmd(cmd) output = subprocess.run( -- cgit v1.2.1 From fba4956a5c7c7df15822a721310bc46b93ded47c Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 4 Nov 2022 11:04:52 -0600 Subject: ec: Double timeout of ec tests The fan test sometimes times out in the CQ, so double the default timeout to 2m. BRANCH=None BUG=b:256073822 TEST=make clobber && make run-fan run-crypto_benchmark Signed-off-by: Jeremy Bettis Change-Id: Id51e5e2cf4387dbd19ce227d83393f5f6637b076 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005656 Reviewed-by: Keith Short Auto-Submit: Jeremy Bettis Commit-Queue: Keith Short Tested-by: Jeremy Bettis Commit-Queue: Jeremy Bettis Code-Coverage: Zoss --- util/run_host_test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/run_host_test b/util/run_host_test index 3108da1852..d1fac8f2ac 100755 --- a/util/run_host_test +++ b/util/run_host_test @@ -89,7 +89,7 @@ def run_test(path, timeout=10): def parse_options(argv): parser = argparse.ArgumentParser() - parser.add_argument('-t', '--timeout', type=float, default=60, + parser.add_argument('-t', '--timeout', type=float, default=120, help='Timeout to kill test after.') parser.add_argument('--coverage', action='store_const', const='coverage', default='host', dest='test_target', -- cgit v1.2.1 From 13c68a3e7a85119367ddbcd130518163e4dcd619 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 20 Oct 2022 11:35:45 -0600 Subject: zephyr: rename projects folder to program Renme the projects folder to program for consistency with the name scheme used by the boxster configuration. BUG=b:254097139 BRANCH=none TEST=zmake compare-builds -a TEST=twister Signed-off-by: Keith Short Change-Id: Ib56a57f1e5942e6dd0460e3be81722896eed72af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3968444 Reviewed-by: Jeremy Bettis Commit-Queue: Jeremy Bettis --- .gitlab-ci.yml | 4 +- CMakeLists.txt | 2 +- util/clangd_config.py | 2 +- util/kconfig_check.py | 4 +- zephyr/firmware_builder.py | 2 +- zephyr/program/.pylintrc | 28 ++ zephyr/program/brya/BUILD.py | 43 ++ zephyr/program/brya/CMakeLists.txt | 39 ++ zephyr/program/brya/Kconfig | 11 + zephyr/program/brya/adc.dts | 36 ++ zephyr/program/brya/battery.dts | 15 + zephyr/program/brya/battery_present.c | 21 + zephyr/program/brya/brya.dts | 24 ++ zephyr/program/brya/fan.dts | 39 ++ zephyr/program/brya/gpio.dts | 341 ++++++++++++++++ zephyr/program/brya/i2c.dts | 285 +++++++++++++ zephyr/program/brya/interrupts.dts | 150 +++++++ zephyr/program/brya/kblight_hooks.c | 67 ++++ zephyr/program/brya/keyboard.dts | 47 +++ zephyr/program/brya/motionsense.dts | 257 ++++++++++++ zephyr/program/brya/prj.conf | 200 +++++++++ zephyr/program/brya/prj_brya.conf | 6 + zephyr/program/brya/pwm_leds.dts | 79 ++++ zephyr/program/brya/temp_sensors.dts | 75 ++++ zephyr/program/brya/usbc.dts | 69 ++++ zephyr/program/corsola/BUILD.py | 142 +++++++ zephyr/program/corsola/CMakeLists.txt | 81 ++++ zephyr/program/corsola/Kconfig | 52 +++ zephyr/program/corsola/adc_kingler.dts | 46 +++ zephyr/program/corsola/adc_krabby.dts | 38 ++ zephyr/program/corsola/adc_magikarp.dts | 63 +++ zephyr/program/corsola/adc_tentacruel.dts | 72 ++++ zephyr/program/corsola/battery_kingler.dts | 15 + zephyr/program/corsola/battery_krabby.dts | 12 + zephyr/program/corsola/battery_magikarp.dts | 12 + zephyr/program/corsola/battery_steelix.dts | 24 ++ zephyr/program/corsola/battery_tentacruel.dts | 12 + zephyr/program/corsola/cbi_magikarp.dts | 36 ++ zephyr/program/corsola/cbi_steelix.dts | 95 +++++ zephyr/program/corsola/cbi_tentacruel.dts | 36 ++ zephyr/program/corsola/common.dts | 25 ++ .../corsola/default_gpio_pinctrl_kingler.dts | 44 ++ zephyr/program/corsola/gpio_kingler.dts | 249 ++++++++++++ zephyr/program/corsola/gpio_krabby.dts | 231 +++++++++++ zephyr/program/corsola/gpio_magikarp.dts | 237 +++++++++++ zephyr/program/corsola/gpio_steelix.dts | 255 ++++++++++++ zephyr/program/corsola/gpio_tentacruel.dts | 235 +++++++++++ zephyr/program/corsola/host_interface_npcx.dts | 12 + zephyr/program/corsola/i2c_kingler.dts | 169 ++++++++ zephyr/program/corsola/i2c_krabby.dts | 22 + zephyr/program/corsola/i2c_krabby_tentacruel.dtsi | 138 +++++++ zephyr/program/corsola/i2c_magikarp.dts | 36 ++ zephyr/program/corsola/i2c_tentacruel.dts | 38 ++ .../corsola/include/baseboard_usbc_config.h | 42 ++ .../program/corsola/include/variant_db_detection.h | 37 ++ zephyr/program/corsola/interrupts_kingler.dts | 114 ++++++ zephyr/program/corsola/interrupts_krabby.dts | 110 +++++ zephyr/program/corsola/interrupts_magikarp.dts | 115 ++++++ zephyr/program/corsola/interrupts_steelix.dts | 10 + zephyr/program/corsola/interrupts_tentacruel.dts | 115 ++++++ zephyr/program/corsola/keyboard_krabby.dts | 28 ++ zephyr/program/corsola/keyboard_steelix.dts | 29 ++ zephyr/program/corsola/led_it81202_base.dtsi | 184 +++++++++ zephyr/program/corsola/led_kingler.dts | 71 ++++ zephyr/program/corsola/led_krabby.dts | 5 + zephyr/program/corsola/led_magikarp.dts | 136 +++++++ zephyr/program/corsola/led_steelix.dts | 55 +++ zephyr/program/corsola/led_tentacruel.dts | 118 ++++++ zephyr/program/corsola/motionsense_kingler.dts | 150 +++++++ zephyr/program/corsola/motionsense_krabby.dts | 146 +++++++ zephyr/program/corsola/motionsense_magikarp.dts | 199 +++++++++ zephyr/program/corsola/motionsense_steelix.dts | 133 ++++++ zephyr/program/corsola/motionsense_tentacruel.dts | 199 +++++++++ zephyr/program/corsola/npcx_keyboard.dts | 32 ++ zephyr/program/corsola/power_signal.dts | 26 ++ zephyr/program/corsola/prj.conf | 101 +++++ zephyr/program/corsola/prj_it81202_base.conf | 93 +++++ zephyr/program/corsola/prj_kingler.conf | 12 + zephyr/program/corsola/prj_krabby.conf | 9 + zephyr/program/corsola/prj_magikarp.conf | 27 ++ zephyr/program/corsola/prj_npcx993_base.conf | 95 +++++ zephyr/program/corsola/prj_steelix.conf | 35 ++ zephyr/program/corsola/prj_tentacruel.conf | 26 ++ zephyr/program/corsola/src/board.c | 37 ++ zephyr/program/corsola/src/board_chipset.c | 49 +++ zephyr/program/corsola/src/hibernate.c | 22 + zephyr/program/corsola/src/kingler/board_steelix.c | 76 ++++ zephyr/program/corsola/src/kingler/button.c | 35 ++ zephyr/program/corsola/src/kingler/i2c.c | 21 + zephyr/program/corsola/src/kingler/led.c | 52 +++ zephyr/program/corsola/src/kingler/led_steelix.c | 181 +++++++++ zephyr/program/corsola/src/kingler/usb_pd_policy.c | 74 ++++ zephyr/program/corsola/src/kingler/usbc_config.c | 318 +++++++++++++++ .../corsola/src/krabby/charger_workaround.c | 93 +++++ zephyr/program/corsola/src/krabby/hooks.c | 90 +++++ zephyr/program/corsola/src/krabby/i2c.c | 19 + .../program/corsola/src/krabby/keyboard_magikarp.c | 29 ++ zephyr/program/corsola/src/krabby/ppc_krabby.c | 31 ++ zephyr/program/corsola/src/krabby/ppc_magikarp.c | 44 ++ zephyr/program/corsola/src/krabby/ppc_tentacruel.c | 89 +++++ .../program/corsola/src/krabby/sensor_magikarp.c | 41 ++ .../program/corsola/src/krabby/sensor_tentacruel.c | 41 ++ .../program/corsola/src/krabby/temp_tentacruel.c | 129 ++++++ zephyr/program/corsola/src/krabby/usb_pd_policy.c | 88 ++++ zephyr/program/corsola/src/krabby/usbc_config.c | 145 +++++++ zephyr/program/corsola/src/usb_pd_policy.c | 226 +++++++++++ zephyr/program/corsola/src/usbc_config.c | 258 ++++++++++++ zephyr/program/corsola/src/variant_db_detection.c | 211 ++++++++++ zephyr/program/corsola/thermistor_tentacruel.dts | 140 +++++++ zephyr/program/corsola/usba.dts | 11 + zephyr/program/corsola/usba_steelix.dts | 10 + zephyr/program/corsola/usbc_kingler.dts | 56 +++ zephyr/program/corsola/usbc_krabby.dts | 59 +++ zephyr/program/corsola/usbc_magikarp.dts | 59 +++ zephyr/program/corsola/usbc_tentacruel.dts | 60 +++ zephyr/program/herobrine/BUILD.py | 49 +++ zephyr/program/herobrine/CMakeLists.txt | 36 ++ zephyr/program/herobrine/Kconfig | 41 ++ zephyr/program/herobrine/adc.dtsi | 47 +++ zephyr/program/herobrine/common.dtsi | 44 ++ zephyr/program/herobrine/default_gpio_pinctrl.dtsi | 44 ++ zephyr/program/herobrine/display.dtsi | 18 + zephyr/program/herobrine/evoker/battery.dtsi | 15 + zephyr/program/herobrine/evoker/gpio.dtsi | 329 +++++++++++++++ zephyr/program/herobrine/evoker/i2c.dtsi | 46 +++ zephyr/program/herobrine/evoker/led_pins.dtsi | 54 +++ zephyr/program/herobrine/evoker/led_policy.dtsi | 86 ++++ zephyr/program/herobrine/evoker/motionsense.dtsi | 148 +++++++ zephyr/program/herobrine/evoker/project.conf | 16 + zephyr/program/herobrine/evoker/project.overlay | 22 + zephyr/program/herobrine/evoker/usbc.dtsi | 42 ++ zephyr/program/herobrine/gpio.dtsi | 329 +++++++++++++++ zephyr/program/herobrine/herobrine/CMakeLists.txt | 6 + zephyr/program/herobrine/herobrine/battery.dtsi | 12 + zephyr/program/herobrine/herobrine/i2c.dtsi | 39 ++ zephyr/program/herobrine/herobrine/led_pins.dtsi | 56 +++ zephyr/program/herobrine/herobrine/led_policy.dtsi | 202 ++++++++++ zephyr/program/herobrine/herobrine/project.conf | 13 + zephyr/program/herobrine/herobrine/project.overlay | 22 + .../herobrine/herobrine/src/alt_dev_replacement.c | 36 ++ zephyr/program/herobrine/herobrine/usbc.dtsi | 43 ++ zephyr/program/herobrine/hoglin/battery.dtsi | 12 + zephyr/program/herobrine/hoglin/gpio.dtsi | 327 +++++++++++++++ zephyr/program/herobrine/hoglin/i2c.dtsi | 34 ++ zephyr/program/herobrine/hoglin/led_pins.dtsi | 33 ++ zephyr/program/herobrine/hoglin/led_policy.dtsi | 95 +++++ zephyr/program/herobrine/hoglin/motionsense.dtsi | 241 +++++++++++ zephyr/program/herobrine/hoglin/project.conf | 15 + zephyr/program/herobrine/hoglin/project.overlay | 21 + zephyr/program/herobrine/hoglin/switchcap.dtsi | 12 + zephyr/program/herobrine/hoglin/usbc.dtsi | 42 ++ zephyr/program/herobrine/i2c.dtsi | 157 ++++++++ zephyr/program/herobrine/include/board_chipset.h | 11 + zephyr/program/herobrine/interrupts.dtsi | 115 ++++++ zephyr/program/herobrine/keyboard.dtsi | 46 +++ zephyr/program/herobrine/motionsense.dtsi | 241 +++++++++++ zephyr/program/herobrine/program.conf | 160 ++++++++ zephyr/program/herobrine/src/board_chipset.c | 83 ++++ zephyr/program/herobrine/src/i2c.c | 17 + zephyr/program/herobrine/src/usb_pd_policy.c | 254 ++++++++++++ zephyr/program/herobrine/src/usbc_config.c | 278 +++++++++++++ zephyr/program/herobrine/switchcap.dtsi | 12 + zephyr/program/herobrine/villager/battery.dtsi | 15 + zephyr/program/herobrine/villager/gpio.dtsi | 323 +++++++++++++++ zephyr/program/herobrine/villager/i2c.dtsi | 34 ++ zephyr/program/herobrine/villager/led_pins.dtsi | 33 ++ zephyr/program/herobrine/villager/led_policy.dtsi | 95 +++++ zephyr/program/herobrine/villager/motionsense.dtsi | 148 +++++++ zephyr/program/herobrine/villager/project.conf | 8 + zephyr/program/herobrine/villager/project.overlay | 21 + zephyr/program/herobrine/villager/usbc.dtsi | 42 ++ zephyr/program/herobrine/zoglin/project.conf | 15 + zephyr/program/herobrine/zoglin/project.overlay | 21 + zephyr/program/herobrine/zombie/battery.dtsi | 15 + zephyr/program/herobrine/zombie/gpio.dtsi | 323 +++++++++++++++ zephyr/program/herobrine/zombie/i2c.dtsi | 34 ++ zephyr/program/herobrine/zombie/led_pins.dtsi | 33 ++ zephyr/program/herobrine/zombie/led_policy.dtsi | 95 +++++ zephyr/program/herobrine/zombie/motionsense.dtsi | 148 +++++++ zephyr/program/herobrine/zombie/project.conf | 8 + zephyr/program/herobrine/zombie/project.overlay | 21 + zephyr/program/herobrine/zombie/usbc.dtsi | 42 ++ zephyr/program/intelrvp/BUILD.py | 98 +++++ zephyr/program/intelrvp/CMakeLists.txt | 32 ++ zephyr/program/intelrvp/Kconfig | 26 ++ zephyr/program/intelrvp/adlrvp/CMakeLists.txt | 6 + .../intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts | 201 ++++++++++ .../intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts | 28 ++ .../program/intelrvp/adlrvp/adlrvp_mchp/gpio.dts | 299 ++++++++++++++ .../intelrvp/adlrvp/adlrvp_mchp/interrupts.dts | 80 ++++ .../intelrvp/adlrvp/adlrvp_mchp/keyboard.dts | 31 ++ .../program/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 84 ++++ .../program/intelrvp/adlrvp/adlrvp_mchp/usbc.dts | 89 +++++ .../intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts | 258 ++++++++++++ zephyr/program/intelrvp/adlrvp/adlrvp_npcx/fan.dts | 36 ++ .../program/intelrvp/adlrvp/adlrvp_npcx/gpio.dts | 344 ++++++++++++++++ .../intelrvp/adlrvp/adlrvp_npcx/interrupts.dts | 100 +++++ .../intelrvp/adlrvp/adlrvp_npcx/keyboard.dts | 59 +++ .../program/intelrvp/adlrvp/adlrvp_npcx/prj.conf | 24 ++ .../intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts | 57 +++ .../intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts | 89 +++++ .../program/intelrvp/adlrvp/adlrvp_npcx/usbc.dts | 89 +++++ zephyr/program/intelrvp/adlrvp/battery.dts | 20 + .../intelrvp/adlrvp/include/adlrvp_zephyr.h | 58 +++ zephyr/program/intelrvp/adlrvp/ioex.dts | 78 ++++ zephyr/program/intelrvp/adlrvp/prj.conf | 76 ++++ zephyr/program/intelrvp/adlrvp/src/adlrvp.c | 430 ++++++++++++++++++++ .../program/intelrvp/include/intel_rvp_board_id.h | 17 + zephyr/program/intelrvp/include/intelrvp.h | 35 ++ zephyr/program/intelrvp/led.md | 44 ++ zephyr/program/intelrvp/legacy_ec_pwrseq.conf | 12 + zephyr/program/intelrvp/mtlrvp/CMakeLists.txt | 6 + zephyr/program/intelrvp/mtlrvp/ioex.dts | 71 ++++ .../program/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts | 36 ++ .../program/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts | 366 +++++++++++++++++ .../intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts | 60 +++ .../intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts | 59 +++ .../intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts | 273 +++++++++++++ .../mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts | 125 ++++++ .../program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf | 18 + zephyr/program/intelrvp/mtlrvp/prj.conf | 80 ++++ zephyr/program/intelrvp/mtlrvp/src/board_power.c | 61 +++ zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c | 331 +++++++++++++++ zephyr/program/intelrvp/mtlrvp/usbc.dts | 76 ++++ zephyr/program/intelrvp/prj.conf | 72 ++++ zephyr/program/intelrvp/src/chg_usb_pd.c | 129 ++++++ zephyr/program/intelrvp/src/chg_usb_pd_mecc_1_1.c | 92 +++++ zephyr/program/intelrvp/src/intel_rvp_board_id.c | 30 ++ zephyr/program/intelrvp/src/intel_rvp_led.c | 168 ++++++++ zephyr/program/intelrvp/src/intelrvp.c | 25 ++ .../program/intelrvp/src/usb_pd_policy_mecc_1_1.c | 106 +++++ zephyr/program/intelrvp/zephyr_ap_pwrseq.conf | 9 + zephyr/program/it8xxx2_evb/BUILD.py | 18 + zephyr/program/it8xxx2_evb/CMakeLists.txt | 11 + zephyr/program/it8xxx2_evb/adc.dts | 41 ++ zephyr/program/it8xxx2_evb/fan.dts | 27 ++ zephyr/program/it8xxx2_evb/gpio.dts | 169 ++++++++ zephyr/program/it8xxx2_evb/i2c.dts | 59 +++ zephyr/program/it8xxx2_evb/include/i2c_map.h | 16 + zephyr/program/it8xxx2_evb/interrupts.dts | 26 ++ zephyr/program/it8xxx2_evb/prj.conf | 44 ++ zephyr/program/it8xxx2_evb/pwm.dts | 31 ++ zephyr/program/minimal/BUILD.py | 22 + zephyr/program/minimal/CMakeLists.txt | 9 + zephyr/program/minimal/README.md | 32 ++ zephyr/program/minimal/it8xxx2.dts | 22 + zephyr/program/minimal/npcx9.dts | 28 ++ zephyr/program/minimal/prj.conf | 18 + zephyr/program/nissa/BUILD.py | 66 +++ zephyr/program/nissa/CMakeLists.txt | 84 ++++ zephyr/program/nissa/Kconfig | 52 +++ zephyr/program/nissa/cbi.dtsi | 61 +++ zephyr/program/nissa/craask/cbi.dtsi | 107 +++++ zephyr/program/nissa/craask/generated.dtsi | 288 +++++++++++++ zephyr/program/nissa/craask/keyboard.dtsi | 32 ++ zephyr/program/nissa/craask/motionsense.dtsi | 257 ++++++++++++ zephyr/program/nissa/craask/overlay.dtsi | 349 ++++++++++++++++ zephyr/program/nissa/craask/power_signals.dtsi | 220 ++++++++++ zephyr/program/nissa/craask/project.conf | 15 + zephyr/program/nissa/craask/project.overlay | 14 + zephyr/program/nissa/craask/pwm_leds.dtsi | 62 +++ zephyr/program/nissa/craask/src/charger.c | 56 +++ zephyr/program/nissa/craask/src/form_factor.c | 121 ++++++ zephyr/program/nissa/craask/src/keyboard.c | 29 ++ zephyr/program/nissa/craask/src/led.c | 56 +++ zephyr/program/nissa/craask/src/usbc.c | 277 +++++++++++++ zephyr/program/nissa/include/nissa_common.h | 23 ++ zephyr/program/nissa/include/nissa_hdmi.h | 55 +++ zephyr/program/nissa/it8xxx2_program.conf | 62 +++ zephyr/program/nissa/joxer/cbi.dtsi | 32 ++ zephyr/program/nissa/joxer/generated.dtsi | 260 ++++++++++++ zephyr/program/nissa/joxer/joxer_vif.xml | 346 ++++++++++++++++ zephyr/program/nissa/joxer/keyboard.dtsi | 22 + zephyr/program/nissa/joxer/motionsense.dtsi | 149 +++++++ zephyr/program/nissa/joxer/overlay.dtsi | 445 +++++++++++++++++++++ zephyr/program/nissa/joxer/power_signals.dtsi | 223 +++++++++++ zephyr/program/nissa/joxer/project.conf | 19 + zephyr/program/nissa/joxer/project.overlay | 14 + zephyr/program/nissa/joxer/pwm_leds.dtsi | 60 +++ zephyr/program/nissa/joxer/src/charger.c | 56 +++ zephyr/program/nissa/joxer/src/fan.c | 43 ++ zephyr/program/nissa/joxer/src/keyboard.c | 68 ++++ zephyr/program/nissa/joxer/src/led.c | 181 +++++++++ zephyr/program/nissa/joxer/src/usbc.c | 392 ++++++++++++++++++ zephyr/program/nissa/nereid/generated.dtsi | 260 ++++++++++++ zephyr/program/nissa/nereid/keyboard.dtsi | 22 + zephyr/program/nissa/nereid/motionsense.dtsi | 147 +++++++ zephyr/program/nissa/nereid/nereid_vif.xml | 350 ++++++++++++++++ zephyr/program/nissa/nereid/overlay.dtsi | 400 ++++++++++++++++++ zephyr/program/nissa/nereid/power_signals.dtsi | 223 +++++++++++ zephyr/program/nissa/nereid/project.conf | 17 + zephyr/program/nissa/nereid/project.overlay | 13 + zephyr/program/nissa/nereid/pwm_leds.dtsi | 60 +++ zephyr/program/nissa/nereid/src/charger.c | 56 +++ zephyr/program/nissa/nereid/src/hdmi.c | 28 ++ zephyr/program/nissa/nereid/src/keyboard.c | 29 ++ zephyr/program/nissa/nereid/src/usbc.c | 393 ++++++++++++++++++ zephyr/program/nissa/nissa.csv | 122 ++++++ zephyr/program/nissa/nivviks/cbi.dtsi | 30 ++ zephyr/program/nissa/nivviks/generated.dtsi | 291 ++++++++++++++ zephyr/program/nissa/nivviks/keyboard.dtsi | 48 +++ zephyr/program/nissa/nivviks/motionsense.dtsi | 166 ++++++++ zephyr/program/nissa/nivviks/overlay.dtsi | 418 +++++++++++++++++++ zephyr/program/nissa/nivviks/power_signals.dtsi | 220 ++++++++++ zephyr/program/nissa/nivviks/project.conf | 8 + zephyr/program/nissa/nivviks/project.overlay | 14 + zephyr/program/nissa/nivviks/pwm_leds.dtsi | 62 +++ zephyr/program/nissa/nivviks/src/charger.c | 56 +++ zephyr/program/nissa/nivviks/src/fan.c | 43 ++ zephyr/program/nissa/nivviks/src/form_factor.c | 47 +++ zephyr/program/nissa/nivviks/src/keyboard.c | 29 ++ zephyr/program/nissa/nivviks/src/led.c | 51 +++ zephyr/program/nissa/nivviks/src/usbc.c | 277 +++++++++++++ zephyr/program/nissa/npcx_program.conf | 55 +++ zephyr/program/nissa/program.conf | 156 ++++++++ zephyr/program/nissa/pujjo/cbi.dtsi | 190 +++++++++ zephyr/program/nissa/pujjo/generated.dtsi | 277 +++++++++++++ zephyr/program/nissa/pujjo/keyboard.dtsi | 48 +++ zephyr/program/nissa/pujjo/motionsense.dtsi | 245 ++++++++++++ zephyr/program/nissa/pujjo/overlay.dtsi | 350 ++++++++++++++++ zephyr/program/nissa/pujjo/power_signals.dtsi | 220 ++++++++++ zephyr/program/nissa/pujjo/project.conf | 33 ++ zephyr/program/nissa/pujjo/project.overlay | 13 + zephyr/program/nissa/pujjo/pujjo_vif.xml | 350 ++++++++++++++++ zephyr/program/nissa/pujjo/src/charger.c | 64 +++ zephyr/program/nissa/pujjo/src/fan.c | 43 ++ zephyr/program/nissa/pujjo/src/form_factor.c | 66 +++ zephyr/program/nissa/pujjo/src/hdmi.c | 12 + zephyr/program/nissa/pujjo/src/keyboard.c | 29 ++ zephyr/program/nissa/pujjo/src/led.c | 134 +++++++ zephyr/program/nissa/pujjo/src/usbc.c | 242 +++++++++++ zephyr/program/nissa/src/board_power.c | 169 ++++++++ zephyr/program/nissa/src/common.c | 154 +++++++ zephyr/program/nissa/src/led.c | 52 +++ zephyr/program/nissa/src/sub_board.c | 298 ++++++++++++++ zephyr/program/nissa/xivu/cbi.dtsi | 77 ++++ zephyr/program/nissa/xivu/generated.dtsi | 291 ++++++++++++++ zephyr/program/nissa/xivu/keyboard.dtsi | 34 ++ zephyr/program/nissa/xivu/led_pins.dtsi | 94 +++++ zephyr/program/nissa/xivu/led_policy.dtsi | 122 ++++++ zephyr/program/nissa/xivu/motionsense.dtsi | 156 ++++++++ zephyr/program/nissa/xivu/overlay.dtsi | 357 +++++++++++++++++ zephyr/program/nissa/xivu/power_signals.dtsi | 220 ++++++++++ zephyr/program/nissa/xivu/project.conf | 17 + zephyr/program/nissa/xivu/project.overlay | 15 + zephyr/program/nissa/xivu/src/charger.c | 69 ++++ zephyr/program/nissa/xivu/src/keyboard.c | 29 ++ zephyr/program/nissa/xivu/src/usbc.c | 362 +++++++++++++++++ zephyr/program/nissa/yaviks/cbi.dtsi | 99 +++++ zephyr/program/nissa/yaviks/gpio.dtsi | 232 +++++++++++ zephyr/program/nissa/yaviks/keyboard.dtsi | 22 + zephyr/program/nissa/yaviks/overlay.dtsi | 402 +++++++++++++++++++ zephyr/program/nissa/yaviks/power_signals.dtsi | 180 +++++++++ zephyr/program/nissa/yaviks/project.conf | 33 ++ zephyr/program/nissa/yaviks/project.overlay | 12 + zephyr/program/nissa/yaviks/src/charger.c | 74 ++++ zephyr/program/nissa/yaviks/src/fan.c | 36 ++ zephyr/program/nissa/yaviks/src/keyboard.c | 106 +++++ zephyr/program/nissa/yaviks/src/led.c | 231 +++++++++++ zephyr/program/nissa/yaviks/src/usbc.c | 393 ++++++++++++++++++ zephyr/program/nissa/yaviks/yaviks_vif.xml | 350 ++++++++++++++++ zephyr/program/npcx_evb/npcx7/BUILD.py | 11 + zephyr/program/npcx_evb/npcx7/CMakeLists.txt | 10 + zephyr/program/npcx_evb/npcx7/fan.dts | 39 ++ zephyr/program/npcx_evb/npcx7/gpio.dts | 68 ++++ zephyr/program/npcx_evb/npcx7/interrupts.dts | 26 ++ zephyr/program/npcx_evb/npcx7/keyboard.dts | 42 ++ zephyr/program/npcx_evb/npcx7/prj.conf | 60 +++ zephyr/program/npcx_evb/npcx9/BUILD.py | 16 + zephyr/program/npcx_evb/npcx9/CMakeLists.txt | 10 + zephyr/program/npcx_evb/npcx9/fan.dts | 39 ++ zephyr/program/npcx_evb/npcx9/gpio.dts | 72 ++++ zephyr/program/npcx_evb/npcx9/interrupts.dts | 26 ++ zephyr/program/npcx_evb/npcx9/keyboard.dts | 42 ++ zephyr/program/npcx_evb/npcx9/prj.conf | 64 +++ zephyr/program/rex/BUILD.py | 45 +++ zephyr/program/rex/CMakeLists.txt | 12 + zephyr/program/rex/Kconfig | 11 + zephyr/program/rex/battery.dts | 12 + zephyr/program/rex/fan.dts | 39 ++ zephyr/program/rex/generated.dts | 363 +++++++++++++++++ zephyr/program/rex/include/gpio_map.h | 9 + zephyr/program/rex/interrupts.dts | 80 ++++ zephyr/program/rex/keyboard.dts | 47 +++ zephyr/program/rex/led.dts | 138 +++++++ zephyr/program/rex/motionsense.dts | 257 ++++++++++++ zephyr/program/rex/power_signals.dts | 152 +++++++ zephyr/program/rex/prj.conf | 180 +++++++++ zephyr/program/rex/prj_rex.conf | 9 + zephyr/program/rex/rex.dts | 262 ++++++++++++ zephyr/program/rex/rex0_gpio.csv | 122 ++++++ zephyr/program/rex/src/board_power.c | 61 +++ zephyr/program/rex/src/usb_pd_policy.c | 77 ++++ zephyr/program/rex/src/usbc_config.c | 300 ++++++++++++++ zephyr/program/rex/temp_sensors.dts | 69 ++++ zephyr/program/rex/usbc.dts | 51 +++ zephyr/program/skyrim/BUILD.py | 86 ++++ zephyr/program/skyrim/CMakeLists.txt | 62 +++ zephyr/program/skyrim/Kconfig | 46 +++ zephyr/program/skyrim/adc.dts | 82 ++++ zephyr/program/skyrim/battery_frostflow.dts | 12 + zephyr/program/skyrim/battery_morthal.dts | 15 + zephyr/program/skyrim/battery_skyrim.dts | 15 + zephyr/program/skyrim/battery_winterhold.dts | 33 ++ zephyr/program/skyrim/fan.dts | 39 ++ zephyr/program/skyrim/frostflow.dts | 136 +++++++ zephyr/program/skyrim/gpio.dts | 370 +++++++++++++++++ zephyr/program/skyrim/i2c_common.dtsi | 294 ++++++++++++++ .../include/frostflow/keyboard_customization.h | 78 ++++ zephyr/program/skyrim/interrupts.dts | 146 +++++++ zephyr/program/skyrim/keyboard.dts | 46 +++ zephyr/program/skyrim/led_pins_frostflow.dts | 63 +++ zephyr/program/skyrim/led_pins_morthal.dts | 63 +++ zephyr/program/skyrim/led_pins_skyrim.dts | 63 +++ zephyr/program/skyrim/led_pins_winterhold.dts | 63 +++ zephyr/program/skyrim/led_policy_frostflow.dts | 122 ++++++ zephyr/program/skyrim/led_policy_morthal.dts | 103 +++++ zephyr/program/skyrim/led_policy_skyrim.dts | 103 +++++ zephyr/program/skyrim/led_policy_winterhold.dts | 103 +++++ zephyr/program/skyrim/morthal.dts | 183 +++++++++ zephyr/program/skyrim/motionsense.dts | 135 +++++++ zephyr/program/skyrim/prj.conf | 167 ++++++++ zephyr/program/skyrim/prj_frostflow.conf | 30 ++ zephyr/program/skyrim/prj_morthal.conf | 23 ++ zephyr/program/skyrim/prj_skyrim.conf | 26 ++ zephyr/program/skyrim/prj_winterhold.conf | 26 ++ zephyr/program/skyrim/skyrim.dts | 207 ++++++++++ zephyr/program/skyrim/src/common.c | 8 + zephyr/program/skyrim/src/frostflow/keyboard.c | 74 ++++ .../skyrim/src/frostflow/keyboard_customization.c | 85 ++++ zephyr/program/skyrim/src/frostflow/ppc_config.c | 46 +++ .../program/skyrim/src/frostflow/usb_mux_config.c | 123 ++++++ zephyr/program/skyrim/src/morthal/ppc_config.c | 46 +++ zephyr/program/skyrim/src/morthal/usb_mux_config.c | 142 +++++++ zephyr/program/skyrim/src/power_signals.c | 245 ++++++++++++ zephyr/program/skyrim/src/skyrim/alt_charger.c | 31 ++ zephyr/program/skyrim/src/skyrim/fan.c | 62 +++ zephyr/program/skyrim/src/skyrim/form_factor.c | 37 ++ zephyr/program/skyrim/src/skyrim/keyboard.c | 29 ++ zephyr/program/skyrim/src/skyrim/ppc_config.c | 46 +++ zephyr/program/skyrim/src/skyrim/usb_mux_config.c | 142 +++++++ zephyr/program/skyrim/src/stt.c | 28 ++ zephyr/program/skyrim/src/usb_pd_policy.c | 93 +++++ zephyr/program/skyrim/src/usbc_config.c | 403 +++++++++++++++++++ .../program/skyrim/src/winterhold/kb_backlight.c | 34 ++ zephyr/program/skyrim/src/winterhold/keyboard.c | 29 ++ zephyr/program/skyrim/src/winterhold/ppc_config.c | 27 ++ .../program/skyrim/src/winterhold/usb_mux_config.c | 107 +++++ zephyr/program/skyrim/usbc.dts | 26 ++ zephyr/program/skyrim/winterhold.dts | 161 ++++++++ zephyr/program/trogdor/lazor/BUILD.py | 25 ++ zephyr/program/trogdor/lazor/CMakeLists.txt | 23 ++ zephyr/program/trogdor/lazor/adc.dts | 48 +++ zephyr/program/trogdor/lazor/battery.dts | 24 ++ .../program/trogdor/lazor/default_gpio_pinctrl.dts | 43 ++ zephyr/program/trogdor/lazor/display.dts | 18 + zephyr/program/trogdor/lazor/gpio.dts | 320 +++++++++++++++ zephyr/program/trogdor/lazor/gpio_led.dts | 33 ++ .../program/trogdor/lazor/host_interface_npcx.dts | 12 + zephyr/program/trogdor/lazor/i2c.dts | 145 +++++++ zephyr/program/trogdor/lazor/include/sku.h | 17 + zephyr/program/trogdor/lazor/interrupts.dts | 140 +++++++ zephyr/program/trogdor/lazor/keyboard.dts | 38 ++ zephyr/program/trogdor/lazor/led.dts | 90 +++++ zephyr/program/trogdor/lazor/motionsense.dts | 181 +++++++++ zephyr/program/trogdor/lazor/prj.conf | 164 ++++++++ zephyr/program/trogdor/lazor/pwm_led.dts | 59 +++ zephyr/program/trogdor/lazor/src/hibernate.c | 48 +++ zephyr/program/trogdor/lazor/src/i2c.c | 17 + zephyr/program/trogdor/lazor/src/power.c | 58 +++ zephyr/program/trogdor/lazor/src/sku.c | 92 +++++ zephyr/program/trogdor/lazor/src/switchcap.c | 128 ++++++ zephyr/program/trogdor/lazor/src/usb_pd_policy.c | 261 ++++++++++++ zephyr/program/trogdor/lazor/src/usbc_config.c | 335 ++++++++++++++++ zephyr/program/trogdor/lazor/usbc.dts | 36 ++ zephyr/projects/.pylintrc | 28 -- zephyr/projects/brya/BUILD.py | 43 -- zephyr/projects/brya/CMakeLists.txt | 39 -- zephyr/projects/brya/Kconfig | 11 - zephyr/projects/brya/adc.dts | 36 -- zephyr/projects/brya/battery.dts | 15 - zephyr/projects/brya/battery_present.c | 21 - zephyr/projects/brya/brya.dts | 24 -- zephyr/projects/brya/fan.dts | 39 -- zephyr/projects/brya/gpio.dts | 341 ---------------- zephyr/projects/brya/i2c.dts | 285 ------------- zephyr/projects/brya/interrupts.dts | 150 ------- zephyr/projects/brya/kblight_hooks.c | 67 ---- zephyr/projects/brya/keyboard.dts | 47 --- zephyr/projects/brya/motionsense.dts | 257 ------------ zephyr/projects/brya/prj.conf | 200 --------- zephyr/projects/brya/prj_brya.conf | 6 - zephyr/projects/brya/pwm_leds.dts | 79 ---- zephyr/projects/brya/temp_sensors.dts | 75 ---- zephyr/projects/brya/usbc.dts | 69 ---- zephyr/projects/corsola/BUILD.py | 142 ------- zephyr/projects/corsola/CMakeLists.txt | 81 ---- zephyr/projects/corsola/Kconfig | 52 --- zephyr/projects/corsola/adc_kingler.dts | 46 --- zephyr/projects/corsola/adc_krabby.dts | 38 -- zephyr/projects/corsola/adc_magikarp.dts | 63 --- zephyr/projects/corsola/adc_tentacruel.dts | 72 ---- zephyr/projects/corsola/battery_kingler.dts | 15 - zephyr/projects/corsola/battery_krabby.dts | 12 - zephyr/projects/corsola/battery_magikarp.dts | 12 - zephyr/projects/corsola/battery_steelix.dts | 24 -- zephyr/projects/corsola/battery_tentacruel.dts | 12 - zephyr/projects/corsola/cbi_magikarp.dts | 36 -- zephyr/projects/corsola/cbi_steelix.dts | 95 ----- zephyr/projects/corsola/cbi_tentacruel.dts | 36 -- zephyr/projects/corsola/common.dts | 25 -- .../corsola/default_gpio_pinctrl_kingler.dts | 44 -- zephyr/projects/corsola/gpio_kingler.dts | 249 ------------ zephyr/projects/corsola/gpio_krabby.dts | 231 ----------- zephyr/projects/corsola/gpio_magikarp.dts | 237 ----------- zephyr/projects/corsola/gpio_steelix.dts | 255 ------------ zephyr/projects/corsola/gpio_tentacruel.dts | 235 ----------- zephyr/projects/corsola/host_interface_npcx.dts | 12 - zephyr/projects/corsola/i2c_kingler.dts | 169 -------- zephyr/projects/corsola/i2c_krabby.dts | 22 - zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi | 138 ------- zephyr/projects/corsola/i2c_magikarp.dts | 36 -- zephyr/projects/corsola/i2c_tentacruel.dts | 38 -- .../corsola/include/baseboard_usbc_config.h | 42 -- .../corsola/include/variant_db_detection.h | 37 -- zephyr/projects/corsola/interrupts_kingler.dts | 114 ------ zephyr/projects/corsola/interrupts_krabby.dts | 110 ----- zephyr/projects/corsola/interrupts_magikarp.dts | 115 ------ zephyr/projects/corsola/interrupts_steelix.dts | 10 - zephyr/projects/corsola/interrupts_tentacruel.dts | 115 ------ zephyr/projects/corsola/keyboard_krabby.dts | 28 -- zephyr/projects/corsola/keyboard_steelix.dts | 29 -- zephyr/projects/corsola/led_it81202_base.dtsi | 184 --------- zephyr/projects/corsola/led_kingler.dts | 71 ---- zephyr/projects/corsola/led_krabby.dts | 5 - zephyr/projects/corsola/led_magikarp.dts | 136 ------- zephyr/projects/corsola/led_steelix.dts | 55 --- zephyr/projects/corsola/led_tentacruel.dts | 118 ------ zephyr/projects/corsola/motionsense_kingler.dts | 150 ------- zephyr/projects/corsola/motionsense_krabby.dts | 146 ------- zephyr/projects/corsola/motionsense_magikarp.dts | 199 --------- zephyr/projects/corsola/motionsense_steelix.dts | 133 ------ zephyr/projects/corsola/motionsense_tentacruel.dts | 199 --------- zephyr/projects/corsola/npcx_keyboard.dts | 32 -- zephyr/projects/corsola/power_signal.dts | 26 -- zephyr/projects/corsola/prj.conf | 101 ----- zephyr/projects/corsola/prj_it81202_base.conf | 93 ----- zephyr/projects/corsola/prj_kingler.conf | 12 - zephyr/projects/corsola/prj_krabby.conf | 9 - zephyr/projects/corsola/prj_magikarp.conf | 27 -- zephyr/projects/corsola/prj_npcx993_base.conf | 95 ----- zephyr/projects/corsola/prj_steelix.conf | 35 -- zephyr/projects/corsola/prj_tentacruel.conf | 26 -- zephyr/projects/corsola/src/board.c | 37 -- zephyr/projects/corsola/src/board_chipset.c | 49 --- zephyr/projects/corsola/src/hibernate.c | 22 - .../projects/corsola/src/kingler/board_steelix.c | 76 ---- zephyr/projects/corsola/src/kingler/button.c | 35 -- zephyr/projects/corsola/src/kingler/i2c.c | 21 - zephyr/projects/corsola/src/kingler/led.c | 52 --- zephyr/projects/corsola/src/kingler/led_steelix.c | 181 --------- .../projects/corsola/src/kingler/usb_pd_policy.c | 74 ---- zephyr/projects/corsola/src/kingler/usbc_config.c | 318 --------------- .../corsola/src/krabby/charger_workaround.c | 93 ----- zephyr/projects/corsola/src/krabby/hooks.c | 90 ----- zephyr/projects/corsola/src/krabby/i2c.c | 19 - .../corsola/src/krabby/keyboard_magikarp.c | 29 -- zephyr/projects/corsola/src/krabby/ppc_krabby.c | 31 -- zephyr/projects/corsola/src/krabby/ppc_magikarp.c | 44 -- .../projects/corsola/src/krabby/ppc_tentacruel.c | 89 ----- .../projects/corsola/src/krabby/sensor_magikarp.c | 41 -- .../corsola/src/krabby/sensor_tentacruel.c | 41 -- .../projects/corsola/src/krabby/temp_tentacruel.c | 129 ------ zephyr/projects/corsola/src/krabby/usb_pd_policy.c | 88 ---- zephyr/projects/corsola/src/krabby/usbc_config.c | 145 ------- zephyr/projects/corsola/src/usb_pd_policy.c | 226 ----------- zephyr/projects/corsola/src/usbc_config.c | 258 ------------ zephyr/projects/corsola/src/variant_db_detection.c | 211 ---------- zephyr/projects/corsola/thermistor_tentacruel.dts | 140 ------- zephyr/projects/corsola/usba.dts | 11 - zephyr/projects/corsola/usba_steelix.dts | 10 - zephyr/projects/corsola/usbc_kingler.dts | 56 --- zephyr/projects/corsola/usbc_krabby.dts | 59 --- zephyr/projects/corsola/usbc_magikarp.dts | 59 --- zephyr/projects/corsola/usbc_tentacruel.dts | 60 --- zephyr/projects/herobrine/BUILD.py | 49 --- zephyr/projects/herobrine/CMakeLists.txt | 36 -- zephyr/projects/herobrine/Kconfig | 41 -- zephyr/projects/herobrine/adc.dtsi | 47 --- zephyr/projects/herobrine/common.dtsi | 44 -- .../projects/herobrine/default_gpio_pinctrl.dtsi | 44 -- zephyr/projects/herobrine/display.dtsi | 18 - zephyr/projects/herobrine/evoker/battery.dtsi | 15 - zephyr/projects/herobrine/evoker/gpio.dtsi | 329 --------------- zephyr/projects/herobrine/evoker/i2c.dtsi | 46 --- zephyr/projects/herobrine/evoker/led_pins.dtsi | 54 --- zephyr/projects/herobrine/evoker/led_policy.dtsi | 86 ---- zephyr/projects/herobrine/evoker/motionsense.dtsi | 148 ------- zephyr/projects/herobrine/evoker/project.conf | 16 - zephyr/projects/herobrine/evoker/project.overlay | 22 - zephyr/projects/herobrine/evoker/usbc.dtsi | 42 -- zephyr/projects/herobrine/gpio.dtsi | 329 --------------- zephyr/projects/herobrine/herobrine/CMakeLists.txt | 6 - zephyr/projects/herobrine/herobrine/battery.dtsi | 12 - zephyr/projects/herobrine/herobrine/i2c.dtsi | 39 -- zephyr/projects/herobrine/herobrine/led_pins.dtsi | 56 --- .../projects/herobrine/herobrine/led_policy.dtsi | 202 ---------- zephyr/projects/herobrine/herobrine/project.conf | 13 - .../projects/herobrine/herobrine/project.overlay | 22 - .../herobrine/herobrine/src/alt_dev_replacement.c | 36 -- zephyr/projects/herobrine/herobrine/usbc.dtsi | 43 -- zephyr/projects/herobrine/hoglin/battery.dtsi | 12 - zephyr/projects/herobrine/hoglin/gpio.dtsi | 327 --------------- zephyr/projects/herobrine/hoglin/i2c.dtsi | 34 -- zephyr/projects/herobrine/hoglin/led_pins.dtsi | 33 -- zephyr/projects/herobrine/hoglin/led_policy.dtsi | 95 ----- zephyr/projects/herobrine/hoglin/motionsense.dtsi | 241 ----------- zephyr/projects/herobrine/hoglin/project.conf | 15 - zephyr/projects/herobrine/hoglin/project.overlay | 21 - zephyr/projects/herobrine/hoglin/switchcap.dtsi | 12 - zephyr/projects/herobrine/hoglin/usbc.dtsi | 42 -- zephyr/projects/herobrine/i2c.dtsi | 157 -------- zephyr/projects/herobrine/include/board_chipset.h | 11 - zephyr/projects/herobrine/interrupts.dtsi | 115 ------ zephyr/projects/herobrine/keyboard.dtsi | 46 --- zephyr/projects/herobrine/motionsense.dtsi | 241 ----------- zephyr/projects/herobrine/program.conf | 160 -------- zephyr/projects/herobrine/src/board_chipset.c | 83 ---- zephyr/projects/herobrine/src/i2c.c | 17 - zephyr/projects/herobrine/src/usb_pd_policy.c | 254 ------------ zephyr/projects/herobrine/src/usbc_config.c | 278 ------------- zephyr/projects/herobrine/switchcap.dtsi | 12 - zephyr/projects/herobrine/villager/battery.dtsi | 15 - zephyr/projects/herobrine/villager/gpio.dtsi | 323 --------------- zephyr/projects/herobrine/villager/i2c.dtsi | 34 -- zephyr/projects/herobrine/villager/led_pins.dtsi | 33 -- zephyr/projects/herobrine/villager/led_policy.dtsi | 95 ----- .../projects/herobrine/villager/motionsense.dtsi | 148 ------- zephyr/projects/herobrine/villager/project.conf | 8 - zephyr/projects/herobrine/villager/project.overlay | 21 - zephyr/projects/herobrine/villager/usbc.dtsi | 42 -- zephyr/projects/herobrine/zoglin/project.conf | 15 - zephyr/projects/herobrine/zoglin/project.overlay | 21 - zephyr/projects/herobrine/zombie/battery.dtsi | 15 - zephyr/projects/herobrine/zombie/gpio.dtsi | 323 --------------- zephyr/projects/herobrine/zombie/i2c.dtsi | 34 -- zephyr/projects/herobrine/zombie/led_pins.dtsi | 33 -- zephyr/projects/herobrine/zombie/led_policy.dtsi | 95 ----- zephyr/projects/herobrine/zombie/motionsense.dtsi | 148 ------- zephyr/projects/herobrine/zombie/project.conf | 8 - zephyr/projects/herobrine/zombie/project.overlay | 21 - zephyr/projects/herobrine/zombie/usbc.dtsi | 42 -- zephyr/projects/intelrvp/BUILD.py | 98 ----- zephyr/projects/intelrvp/CMakeLists.txt | 32 -- zephyr/projects/intelrvp/Kconfig | 26 -- zephyr/projects/intelrvp/adlrvp/CMakeLists.txt | 6 - .../intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts | 201 ---------- .../intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts | 28 -- .../projects/intelrvp/adlrvp/adlrvp_mchp/gpio.dts | 299 -------------- .../intelrvp/adlrvp/adlrvp_mchp/interrupts.dts | 80 ---- .../intelrvp/adlrvp/adlrvp_mchp/keyboard.dts | 31 -- .../projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 84 ---- .../projects/intelrvp/adlrvp/adlrvp_mchp/usbc.dts | 89 ----- .../intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts | 258 ------------ .../projects/intelrvp/adlrvp/adlrvp_npcx/fan.dts | 36 -- .../projects/intelrvp/adlrvp/adlrvp_npcx/gpio.dts | 344 ---------------- .../intelrvp/adlrvp/adlrvp_npcx/interrupts.dts | 100 ----- .../intelrvp/adlrvp/adlrvp_npcx/keyboard.dts | 59 --- .../projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf | 24 -- .../intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts | 57 --- .../intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts | 89 ----- .../projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts | 89 ----- zephyr/projects/intelrvp/adlrvp/battery.dts | 20 - .../intelrvp/adlrvp/include/adlrvp_zephyr.h | 58 --- zephyr/projects/intelrvp/adlrvp/ioex.dts | 78 ---- zephyr/projects/intelrvp/adlrvp/prj.conf | 76 ---- zephyr/projects/intelrvp/adlrvp/src/adlrvp.c | 430 -------------------- .../projects/intelrvp/include/intel_rvp_board_id.h | 17 - zephyr/projects/intelrvp/include/intelrvp.h | 35 -- zephyr/projects/intelrvp/led.md | 44 -- zephyr/projects/intelrvp/legacy_ec_pwrseq.conf | 12 - zephyr/projects/intelrvp/mtlrvp/CMakeLists.txt | 6 - zephyr/projects/intelrvp/mtlrvp/ioex.dts | 71 ---- .../projects/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts | 36 -- .../projects/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts | 366 ----------------- .../intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts | 60 --- .../intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts | 59 --- .../intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts | 273 ------------- .../mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts | 125 ------ .../projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf | 18 - zephyr/projects/intelrvp/mtlrvp/prj.conf | 80 ---- zephyr/projects/intelrvp/mtlrvp/src/board_power.c | 61 --- zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c | 331 --------------- zephyr/projects/intelrvp/mtlrvp/usbc.dts | 76 ---- zephyr/projects/intelrvp/prj.conf | 72 ---- zephyr/projects/intelrvp/src/chg_usb_pd.c | 129 ------ zephyr/projects/intelrvp/src/chg_usb_pd_mecc_1_1.c | 92 ----- zephyr/projects/intelrvp/src/intel_rvp_board_id.c | 30 -- zephyr/projects/intelrvp/src/intel_rvp_led.c | 168 -------- zephyr/projects/intelrvp/src/intelrvp.c | 25 -- .../projects/intelrvp/src/usb_pd_policy_mecc_1_1.c | 106 ----- zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf | 9 - zephyr/projects/it8xxx2_evb/BUILD.py | 18 - zephyr/projects/it8xxx2_evb/CMakeLists.txt | 11 - zephyr/projects/it8xxx2_evb/adc.dts | 41 -- zephyr/projects/it8xxx2_evb/fan.dts | 27 -- zephyr/projects/it8xxx2_evb/gpio.dts | 169 -------- zephyr/projects/it8xxx2_evb/i2c.dts | 59 --- zephyr/projects/it8xxx2_evb/include/i2c_map.h | 16 - zephyr/projects/it8xxx2_evb/interrupts.dts | 26 -- zephyr/projects/it8xxx2_evb/prj.conf | 44 -- zephyr/projects/it8xxx2_evb/pwm.dts | 31 -- zephyr/projects/minimal/BUILD.py | 22 - zephyr/projects/minimal/CMakeLists.txt | 9 - zephyr/projects/minimal/README.md | 32 -- zephyr/projects/minimal/it8xxx2.dts | 22 - zephyr/projects/minimal/npcx9.dts | 28 -- zephyr/projects/minimal/prj.conf | 18 - zephyr/projects/nissa/BUILD.py | 66 --- zephyr/projects/nissa/CMakeLists.txt | 84 ---- zephyr/projects/nissa/Kconfig | 52 --- zephyr/projects/nissa/cbi.dtsi | 61 --- zephyr/projects/nissa/craask/cbi.dtsi | 107 ----- zephyr/projects/nissa/craask/generated.dtsi | 288 ------------- zephyr/projects/nissa/craask/keyboard.dtsi | 32 -- zephyr/projects/nissa/craask/motionsense.dtsi | 257 ------------ zephyr/projects/nissa/craask/overlay.dtsi | 349 ---------------- zephyr/projects/nissa/craask/power_signals.dtsi | 220 ---------- zephyr/projects/nissa/craask/project.conf | 15 - zephyr/projects/nissa/craask/project.overlay | 14 - zephyr/projects/nissa/craask/pwm_leds.dtsi | 62 --- zephyr/projects/nissa/craask/src/charger.c | 56 --- zephyr/projects/nissa/craask/src/form_factor.c | 121 ------ zephyr/projects/nissa/craask/src/keyboard.c | 29 -- zephyr/projects/nissa/craask/src/led.c | 56 --- zephyr/projects/nissa/craask/src/usbc.c | 277 ------------- zephyr/projects/nissa/include/nissa_common.h | 23 -- zephyr/projects/nissa/include/nissa_hdmi.h | 55 --- zephyr/projects/nissa/it8xxx2_program.conf | 62 --- zephyr/projects/nissa/joxer/cbi.dtsi | 32 -- zephyr/projects/nissa/joxer/generated.dtsi | 260 ------------ zephyr/projects/nissa/joxer/joxer_vif.xml | 346 ---------------- zephyr/projects/nissa/joxer/keyboard.dtsi | 22 - zephyr/projects/nissa/joxer/motionsense.dtsi | 149 ------- zephyr/projects/nissa/joxer/overlay.dtsi | 445 --------------------- zephyr/projects/nissa/joxer/power_signals.dtsi | 223 ----------- zephyr/projects/nissa/joxer/project.conf | 19 - zephyr/projects/nissa/joxer/project.overlay | 14 - zephyr/projects/nissa/joxer/pwm_leds.dtsi | 60 --- zephyr/projects/nissa/joxer/src/charger.c | 56 --- zephyr/projects/nissa/joxer/src/fan.c | 43 -- zephyr/projects/nissa/joxer/src/keyboard.c | 68 ---- zephyr/projects/nissa/joxer/src/led.c | 181 --------- zephyr/projects/nissa/joxer/src/usbc.c | 392 ------------------ zephyr/projects/nissa/nereid/generated.dtsi | 260 ------------ zephyr/projects/nissa/nereid/keyboard.dtsi | 22 - zephyr/projects/nissa/nereid/motionsense.dtsi | 147 ------- zephyr/projects/nissa/nereid/nereid_vif.xml | 350 ---------------- zephyr/projects/nissa/nereid/overlay.dtsi | 400 ------------------ zephyr/projects/nissa/nereid/power_signals.dtsi | 223 ----------- zephyr/projects/nissa/nereid/project.conf | 17 - zephyr/projects/nissa/nereid/project.overlay | 13 - zephyr/projects/nissa/nereid/pwm_leds.dtsi | 60 --- zephyr/projects/nissa/nereid/src/charger.c | 56 --- zephyr/projects/nissa/nereid/src/hdmi.c | 28 -- zephyr/projects/nissa/nereid/src/keyboard.c | 29 -- zephyr/projects/nissa/nereid/src/usbc.c | 393 ------------------ zephyr/projects/nissa/nissa.csv | 122 ------ zephyr/projects/nissa/nivviks/cbi.dtsi | 30 -- zephyr/projects/nissa/nivviks/generated.dtsi | 291 -------------- zephyr/projects/nissa/nivviks/keyboard.dtsi | 48 --- zephyr/projects/nissa/nivviks/motionsense.dtsi | 166 -------- zephyr/projects/nissa/nivviks/overlay.dtsi | 418 ------------------- zephyr/projects/nissa/nivviks/power_signals.dtsi | 220 ---------- zephyr/projects/nissa/nivviks/project.conf | 8 - zephyr/projects/nissa/nivviks/project.overlay | 14 - zephyr/projects/nissa/nivviks/pwm_leds.dtsi | 62 --- zephyr/projects/nissa/nivviks/src/charger.c | 56 --- zephyr/projects/nissa/nivviks/src/fan.c | 43 -- zephyr/projects/nissa/nivviks/src/form_factor.c | 47 --- zephyr/projects/nissa/nivviks/src/keyboard.c | 29 -- zephyr/projects/nissa/nivviks/src/led.c | 51 --- zephyr/projects/nissa/nivviks/src/usbc.c | 277 ------------- zephyr/projects/nissa/npcx_program.conf | 55 --- zephyr/projects/nissa/program.conf | 156 -------- zephyr/projects/nissa/pujjo/cbi.dtsi | 190 --------- zephyr/projects/nissa/pujjo/generated.dtsi | 277 ------------- zephyr/projects/nissa/pujjo/keyboard.dtsi | 48 --- zephyr/projects/nissa/pujjo/motionsense.dtsi | 245 ------------ zephyr/projects/nissa/pujjo/overlay.dtsi | 350 ---------------- zephyr/projects/nissa/pujjo/power_signals.dtsi | 220 ---------- zephyr/projects/nissa/pujjo/project.conf | 33 -- zephyr/projects/nissa/pujjo/project.overlay | 13 - zephyr/projects/nissa/pujjo/pujjo_vif.xml | 350 ---------------- zephyr/projects/nissa/pujjo/src/charger.c | 64 --- zephyr/projects/nissa/pujjo/src/fan.c | 43 -- zephyr/projects/nissa/pujjo/src/form_factor.c | 66 --- zephyr/projects/nissa/pujjo/src/hdmi.c | 12 - zephyr/projects/nissa/pujjo/src/keyboard.c | 29 -- zephyr/projects/nissa/pujjo/src/led.c | 134 ------- zephyr/projects/nissa/pujjo/src/usbc.c | 242 ----------- zephyr/projects/nissa/src/board_power.c | 169 -------- zephyr/projects/nissa/src/common.c | 154 ------- zephyr/projects/nissa/src/led.c | 52 --- zephyr/projects/nissa/src/sub_board.c | 298 -------------- zephyr/projects/nissa/xivu/cbi.dtsi | 77 ---- zephyr/projects/nissa/xivu/generated.dtsi | 291 -------------- zephyr/projects/nissa/xivu/keyboard.dtsi | 34 -- zephyr/projects/nissa/xivu/led_pins.dtsi | 94 ----- zephyr/projects/nissa/xivu/led_policy.dtsi | 122 ------ zephyr/projects/nissa/xivu/motionsense.dtsi | 156 -------- zephyr/projects/nissa/xivu/overlay.dtsi | 357 ----------------- zephyr/projects/nissa/xivu/power_signals.dtsi | 220 ---------- zephyr/projects/nissa/xivu/project.conf | 17 - zephyr/projects/nissa/xivu/project.overlay | 15 - zephyr/projects/nissa/xivu/src/charger.c | 69 ---- zephyr/projects/nissa/xivu/src/keyboard.c | 29 -- zephyr/projects/nissa/xivu/src/usbc.c | 362 ----------------- zephyr/projects/nissa/yaviks/cbi.dtsi | 99 ----- zephyr/projects/nissa/yaviks/gpio.dtsi | 232 ----------- zephyr/projects/nissa/yaviks/keyboard.dtsi | 22 - zephyr/projects/nissa/yaviks/overlay.dtsi | 402 ------------------- zephyr/projects/nissa/yaviks/power_signals.dtsi | 180 --------- zephyr/projects/nissa/yaviks/project.conf | 33 -- zephyr/projects/nissa/yaviks/project.overlay | 12 - zephyr/projects/nissa/yaviks/src/charger.c | 74 ---- zephyr/projects/nissa/yaviks/src/fan.c | 36 -- zephyr/projects/nissa/yaviks/src/keyboard.c | 106 ----- zephyr/projects/nissa/yaviks/src/led.c | 231 ----------- zephyr/projects/nissa/yaviks/src/usbc.c | 393 ------------------ zephyr/projects/nissa/yaviks/yaviks_vif.xml | 350 ---------------- zephyr/projects/npcx_evb/npcx7/BUILD.py | 11 - zephyr/projects/npcx_evb/npcx7/CMakeLists.txt | 10 - zephyr/projects/npcx_evb/npcx7/fan.dts | 39 -- zephyr/projects/npcx_evb/npcx7/gpio.dts | 68 ---- zephyr/projects/npcx_evb/npcx7/interrupts.dts | 26 -- zephyr/projects/npcx_evb/npcx7/keyboard.dts | 42 -- zephyr/projects/npcx_evb/npcx7/prj.conf | 60 --- zephyr/projects/npcx_evb/npcx9/BUILD.py | 16 - zephyr/projects/npcx_evb/npcx9/CMakeLists.txt | 10 - zephyr/projects/npcx_evb/npcx9/fan.dts | 39 -- zephyr/projects/npcx_evb/npcx9/gpio.dts | 72 ---- zephyr/projects/npcx_evb/npcx9/interrupts.dts | 26 -- zephyr/projects/npcx_evb/npcx9/keyboard.dts | 42 -- zephyr/projects/npcx_evb/npcx9/prj.conf | 64 --- zephyr/projects/rex/BUILD.py | 45 --- zephyr/projects/rex/CMakeLists.txt | 12 - zephyr/projects/rex/Kconfig | 11 - zephyr/projects/rex/battery.dts | 12 - zephyr/projects/rex/fan.dts | 39 -- zephyr/projects/rex/generated.dts | 363 ----------------- zephyr/projects/rex/include/gpio_map.h | 9 - zephyr/projects/rex/interrupts.dts | 80 ---- zephyr/projects/rex/keyboard.dts | 47 --- zephyr/projects/rex/led.dts | 138 ------- zephyr/projects/rex/motionsense.dts | 257 ------------ zephyr/projects/rex/power_signals.dts | 152 ------- zephyr/projects/rex/prj.conf | 180 --------- zephyr/projects/rex/prj_rex.conf | 9 - zephyr/projects/rex/rex.dts | 262 ------------ zephyr/projects/rex/rex0_gpio.csv | 122 ------ zephyr/projects/rex/src/board_power.c | 61 --- zephyr/projects/rex/src/usb_pd_policy.c | 77 ---- zephyr/projects/rex/src/usbc_config.c | 300 -------------- zephyr/projects/rex/temp_sensors.dts | 69 ---- zephyr/projects/rex/usbc.dts | 51 --- zephyr/projects/skyrim/BUILD.py | 86 ---- zephyr/projects/skyrim/CMakeLists.txt | 62 --- zephyr/projects/skyrim/Kconfig | 46 --- zephyr/projects/skyrim/adc.dts | 82 ---- zephyr/projects/skyrim/battery_frostflow.dts | 12 - zephyr/projects/skyrim/battery_morthal.dts | 15 - zephyr/projects/skyrim/battery_skyrim.dts | 15 - zephyr/projects/skyrim/battery_winterhold.dts | 33 -- zephyr/projects/skyrim/fan.dts | 39 -- zephyr/projects/skyrim/frostflow.dts | 136 ------- zephyr/projects/skyrim/gpio.dts | 370 ----------------- zephyr/projects/skyrim/i2c_common.dtsi | 294 -------------- .../include/frostflow/keyboard_customization.h | 78 ---- zephyr/projects/skyrim/interrupts.dts | 146 ------- zephyr/projects/skyrim/keyboard.dts | 46 --- zephyr/projects/skyrim/led_pins_frostflow.dts | 63 --- zephyr/projects/skyrim/led_pins_morthal.dts | 63 --- zephyr/projects/skyrim/led_pins_skyrim.dts | 63 --- zephyr/projects/skyrim/led_pins_winterhold.dts | 63 --- zephyr/projects/skyrim/led_policy_frostflow.dts | 122 ------ zephyr/projects/skyrim/led_policy_morthal.dts | 103 ----- zephyr/projects/skyrim/led_policy_skyrim.dts | 103 ----- zephyr/projects/skyrim/led_policy_winterhold.dts | 103 ----- zephyr/projects/skyrim/morthal.dts | 183 --------- zephyr/projects/skyrim/motionsense.dts | 135 ------- zephyr/projects/skyrim/prj.conf | 167 -------- zephyr/projects/skyrim/prj_frostflow.conf | 30 -- zephyr/projects/skyrim/prj_morthal.conf | 23 -- zephyr/projects/skyrim/prj_skyrim.conf | 26 -- zephyr/projects/skyrim/prj_winterhold.conf | 26 -- zephyr/projects/skyrim/skyrim.dts | 207 ---------- zephyr/projects/skyrim/src/common.c | 8 - zephyr/projects/skyrim/src/frostflow/keyboard.c | 74 ---- .../skyrim/src/frostflow/keyboard_customization.c | 85 ---- zephyr/projects/skyrim/src/frostflow/ppc_config.c | 46 --- .../projects/skyrim/src/frostflow/usb_mux_config.c | 123 ------ zephyr/projects/skyrim/src/morthal/ppc_config.c | 46 --- .../projects/skyrim/src/morthal/usb_mux_config.c | 142 ------- zephyr/projects/skyrim/src/power_signals.c | 245 ------------ zephyr/projects/skyrim/src/skyrim/alt_charger.c | 31 -- zephyr/projects/skyrim/src/skyrim/fan.c | 62 --- zephyr/projects/skyrim/src/skyrim/form_factor.c | 37 -- zephyr/projects/skyrim/src/skyrim/keyboard.c | 29 -- zephyr/projects/skyrim/src/skyrim/ppc_config.c | 46 --- zephyr/projects/skyrim/src/skyrim/usb_mux_config.c | 142 ------- zephyr/projects/skyrim/src/stt.c | 28 -- zephyr/projects/skyrim/src/usb_pd_policy.c | 93 ----- zephyr/projects/skyrim/src/usbc_config.c | 403 ------------------- .../projects/skyrim/src/winterhold/kb_backlight.c | 34 -- zephyr/projects/skyrim/src/winterhold/keyboard.c | 29 -- zephyr/projects/skyrim/src/winterhold/ppc_config.c | 27 -- .../skyrim/src/winterhold/usb_mux_config.c | 107 ----- zephyr/projects/skyrim/usbc.dts | 26 -- zephyr/projects/skyrim/winterhold.dts | 161 -------- zephyr/projects/trogdor/lazor/BUILD.py | 25 -- zephyr/projects/trogdor/lazor/CMakeLists.txt | 23 -- zephyr/projects/trogdor/lazor/adc.dts | 48 --- zephyr/projects/trogdor/lazor/battery.dts | 24 -- .../trogdor/lazor/default_gpio_pinctrl.dts | 43 -- zephyr/projects/trogdor/lazor/display.dts | 18 - zephyr/projects/trogdor/lazor/gpio.dts | 320 --------------- zephyr/projects/trogdor/lazor/gpio_led.dts | 33 -- .../projects/trogdor/lazor/host_interface_npcx.dts | 12 - zephyr/projects/trogdor/lazor/i2c.dts | 145 ------- zephyr/projects/trogdor/lazor/include/sku.h | 17 - zephyr/projects/trogdor/lazor/interrupts.dts | 140 ------- zephyr/projects/trogdor/lazor/keyboard.dts | 38 -- zephyr/projects/trogdor/lazor/led.dts | 90 ----- zephyr/projects/trogdor/lazor/motionsense.dts | 181 --------- zephyr/projects/trogdor/lazor/prj.conf | 164 -------- zephyr/projects/trogdor/lazor/pwm_led.dts | 59 --- zephyr/projects/trogdor/lazor/src/hibernate.c | 48 --- zephyr/projects/trogdor/lazor/src/i2c.c | 17 - zephyr/projects/trogdor/lazor/src/power.c | 58 --- zephyr/projects/trogdor/lazor/src/sku.c | 92 ----- zephyr/projects/trogdor/lazor/src/switchcap.c | 128 ------ zephyr/projects/trogdor/lazor/src/usb_pd_policy.c | 261 ------------ zephyr/projects/trogdor/lazor/src/usbc_config.c | 335 ---------------- zephyr/projects/trogdor/lazor/usbc.dts | 36 -- zephyr/test/drivers/led_driver/led_pins.dts | 2 +- zephyr/test/drivers/led_driver/led_policy.dts | 2 +- zephyr/test/herobrine/README.md | 2 +- zephyr/test/kingler/README.md | 2 +- zephyr/test/kingler/src/alt_sensor.c | 2 +- zephyr/test/kingler/testcase.yaml | 14 +- zephyr/test/krabby/README.md | 2 +- zephyr/test/krabby/testcase.yaml | 4 +- zephyr/test/rex/README.md | 2 +- 954 files changed, 46398 insertions(+), 46398 deletions(-) create mode 100644 zephyr/program/.pylintrc create mode 100644 zephyr/program/brya/BUILD.py create mode 100644 zephyr/program/brya/CMakeLists.txt create mode 100644 zephyr/program/brya/Kconfig create mode 100644 zephyr/program/brya/adc.dts create mode 100644 zephyr/program/brya/battery.dts create mode 100644 zephyr/program/brya/battery_present.c create mode 100644 zephyr/program/brya/brya.dts create mode 100644 zephyr/program/brya/fan.dts create mode 100644 zephyr/program/brya/gpio.dts create mode 100644 zephyr/program/brya/i2c.dts create mode 100644 zephyr/program/brya/interrupts.dts create mode 100644 zephyr/program/brya/kblight_hooks.c create mode 100644 zephyr/program/brya/keyboard.dts create mode 100644 zephyr/program/brya/motionsense.dts create mode 100644 zephyr/program/brya/prj.conf create mode 100644 zephyr/program/brya/prj_brya.conf create mode 100644 zephyr/program/brya/pwm_leds.dts create mode 100644 zephyr/program/brya/temp_sensors.dts create mode 100644 zephyr/program/brya/usbc.dts create mode 100644 zephyr/program/corsola/BUILD.py create mode 100644 zephyr/program/corsola/CMakeLists.txt create mode 100644 zephyr/program/corsola/Kconfig create mode 100644 zephyr/program/corsola/adc_kingler.dts create mode 100644 zephyr/program/corsola/adc_krabby.dts create mode 100644 zephyr/program/corsola/adc_magikarp.dts create mode 100644 zephyr/program/corsola/adc_tentacruel.dts create mode 100644 zephyr/program/corsola/battery_kingler.dts create mode 100644 zephyr/program/corsola/battery_krabby.dts create mode 100644 zephyr/program/corsola/battery_magikarp.dts create mode 100644 zephyr/program/corsola/battery_steelix.dts create mode 100644 zephyr/program/corsola/battery_tentacruel.dts create mode 100644 zephyr/program/corsola/cbi_magikarp.dts create mode 100644 zephyr/program/corsola/cbi_steelix.dts create mode 100644 zephyr/program/corsola/cbi_tentacruel.dts create mode 100644 zephyr/program/corsola/common.dts create mode 100644 zephyr/program/corsola/default_gpio_pinctrl_kingler.dts create mode 100644 zephyr/program/corsola/gpio_kingler.dts create mode 100644 zephyr/program/corsola/gpio_krabby.dts create mode 100644 zephyr/program/corsola/gpio_magikarp.dts create mode 100644 zephyr/program/corsola/gpio_steelix.dts create mode 100644 zephyr/program/corsola/gpio_tentacruel.dts create mode 100644 zephyr/program/corsola/host_interface_npcx.dts create mode 100644 zephyr/program/corsola/i2c_kingler.dts create mode 100644 zephyr/program/corsola/i2c_krabby.dts create mode 100644 zephyr/program/corsola/i2c_krabby_tentacruel.dtsi create mode 100644 zephyr/program/corsola/i2c_magikarp.dts create mode 100644 zephyr/program/corsola/i2c_tentacruel.dts create mode 100644 zephyr/program/corsola/include/baseboard_usbc_config.h create mode 100644 zephyr/program/corsola/include/variant_db_detection.h create mode 100644 zephyr/program/corsola/interrupts_kingler.dts create mode 100644 zephyr/program/corsola/interrupts_krabby.dts create mode 100644 zephyr/program/corsola/interrupts_magikarp.dts create mode 100644 zephyr/program/corsola/interrupts_steelix.dts create mode 100644 zephyr/program/corsola/interrupts_tentacruel.dts create mode 100644 zephyr/program/corsola/keyboard_krabby.dts create mode 100644 zephyr/program/corsola/keyboard_steelix.dts create mode 100644 zephyr/program/corsola/led_it81202_base.dtsi create mode 100644 zephyr/program/corsola/led_kingler.dts create mode 100644 zephyr/program/corsola/led_krabby.dts create mode 100644 zephyr/program/corsola/led_magikarp.dts create mode 100644 zephyr/program/corsola/led_steelix.dts create mode 100644 zephyr/program/corsola/led_tentacruel.dts create mode 100644 zephyr/program/corsola/motionsense_kingler.dts create mode 100644 zephyr/program/corsola/motionsense_krabby.dts create mode 100644 zephyr/program/corsola/motionsense_magikarp.dts create mode 100644 zephyr/program/corsola/motionsense_steelix.dts create mode 100644 zephyr/program/corsola/motionsense_tentacruel.dts create mode 100644 zephyr/program/corsola/npcx_keyboard.dts create mode 100644 zephyr/program/corsola/power_signal.dts create mode 100644 zephyr/program/corsola/prj.conf create mode 100644 zephyr/program/corsola/prj_it81202_base.conf create mode 100644 zephyr/program/corsola/prj_kingler.conf create mode 100644 zephyr/program/corsola/prj_krabby.conf create mode 100644 zephyr/program/corsola/prj_magikarp.conf create mode 100644 zephyr/program/corsola/prj_npcx993_base.conf create mode 100644 zephyr/program/corsola/prj_steelix.conf create mode 100644 zephyr/program/corsola/prj_tentacruel.conf create mode 100644 zephyr/program/corsola/src/board.c create mode 100644 zephyr/program/corsola/src/board_chipset.c create mode 100644 zephyr/program/corsola/src/hibernate.c create mode 100644 zephyr/program/corsola/src/kingler/board_steelix.c create mode 100644 zephyr/program/corsola/src/kingler/button.c create mode 100644 zephyr/program/corsola/src/kingler/i2c.c create mode 100644 zephyr/program/corsola/src/kingler/led.c create mode 100644 zephyr/program/corsola/src/kingler/led_steelix.c create mode 100644 zephyr/program/corsola/src/kingler/usb_pd_policy.c create mode 100644 zephyr/program/corsola/src/kingler/usbc_config.c create mode 100644 zephyr/program/corsola/src/krabby/charger_workaround.c create mode 100644 zephyr/program/corsola/src/krabby/hooks.c create mode 100644 zephyr/program/corsola/src/krabby/i2c.c create mode 100644 zephyr/program/corsola/src/krabby/keyboard_magikarp.c create mode 100644 zephyr/program/corsola/src/krabby/ppc_krabby.c create mode 100644 zephyr/program/corsola/src/krabby/ppc_magikarp.c create mode 100644 zephyr/program/corsola/src/krabby/ppc_tentacruel.c create mode 100644 zephyr/program/corsola/src/krabby/sensor_magikarp.c create mode 100644 zephyr/program/corsola/src/krabby/sensor_tentacruel.c create mode 100644 zephyr/program/corsola/src/krabby/temp_tentacruel.c create mode 100644 zephyr/program/corsola/src/krabby/usb_pd_policy.c create mode 100644 zephyr/program/corsola/src/krabby/usbc_config.c create mode 100644 zephyr/program/corsola/src/usb_pd_policy.c create mode 100644 zephyr/program/corsola/src/usbc_config.c create mode 100644 zephyr/program/corsola/src/variant_db_detection.c create mode 100644 zephyr/program/corsola/thermistor_tentacruel.dts create mode 100644 zephyr/program/corsola/usba.dts create mode 100644 zephyr/program/corsola/usba_steelix.dts create mode 100644 zephyr/program/corsola/usbc_kingler.dts create mode 100644 zephyr/program/corsola/usbc_krabby.dts create mode 100644 zephyr/program/corsola/usbc_magikarp.dts create mode 100644 zephyr/program/corsola/usbc_tentacruel.dts create mode 100644 zephyr/program/herobrine/BUILD.py create mode 100644 zephyr/program/herobrine/CMakeLists.txt create mode 100644 zephyr/program/herobrine/Kconfig create mode 100644 zephyr/program/herobrine/adc.dtsi create mode 100644 zephyr/program/herobrine/common.dtsi create mode 100644 zephyr/program/herobrine/default_gpio_pinctrl.dtsi create mode 100644 zephyr/program/herobrine/display.dtsi create mode 100644 zephyr/program/herobrine/evoker/battery.dtsi create mode 100644 zephyr/program/herobrine/evoker/gpio.dtsi create mode 100644 zephyr/program/herobrine/evoker/i2c.dtsi create mode 100644 zephyr/program/herobrine/evoker/led_pins.dtsi create mode 100644 zephyr/program/herobrine/evoker/led_policy.dtsi create mode 100644 zephyr/program/herobrine/evoker/motionsense.dtsi create mode 100644 zephyr/program/herobrine/evoker/project.conf create mode 100644 zephyr/program/herobrine/evoker/project.overlay create mode 100644 zephyr/program/herobrine/evoker/usbc.dtsi create mode 100644 zephyr/program/herobrine/gpio.dtsi create mode 100644 zephyr/program/herobrine/herobrine/CMakeLists.txt create mode 100644 zephyr/program/herobrine/herobrine/battery.dtsi create mode 100644 zephyr/program/herobrine/herobrine/i2c.dtsi create mode 100644 zephyr/program/herobrine/herobrine/led_pins.dtsi create mode 100644 zephyr/program/herobrine/herobrine/led_policy.dtsi create mode 100644 zephyr/program/herobrine/herobrine/project.conf create mode 100644 zephyr/program/herobrine/herobrine/project.overlay create mode 100644 zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c create mode 100644 zephyr/program/herobrine/herobrine/usbc.dtsi create mode 100644 zephyr/program/herobrine/hoglin/battery.dtsi create mode 100644 zephyr/program/herobrine/hoglin/gpio.dtsi create mode 100644 zephyr/program/herobrine/hoglin/i2c.dtsi create mode 100644 zephyr/program/herobrine/hoglin/led_pins.dtsi create mode 100644 zephyr/program/herobrine/hoglin/led_policy.dtsi create mode 100644 zephyr/program/herobrine/hoglin/motionsense.dtsi create mode 100644 zephyr/program/herobrine/hoglin/project.conf create mode 100644 zephyr/program/herobrine/hoglin/project.overlay create mode 100644 zephyr/program/herobrine/hoglin/switchcap.dtsi create mode 100644 zephyr/program/herobrine/hoglin/usbc.dtsi create mode 100644 zephyr/program/herobrine/i2c.dtsi create mode 100644 zephyr/program/herobrine/include/board_chipset.h create mode 100644 zephyr/program/herobrine/interrupts.dtsi create mode 100644 zephyr/program/herobrine/keyboard.dtsi create mode 100644 zephyr/program/herobrine/motionsense.dtsi create mode 100644 zephyr/program/herobrine/program.conf create mode 100644 zephyr/program/herobrine/src/board_chipset.c create mode 100644 zephyr/program/herobrine/src/i2c.c create mode 100644 zephyr/program/herobrine/src/usb_pd_policy.c create mode 100644 zephyr/program/herobrine/src/usbc_config.c create mode 100644 zephyr/program/herobrine/switchcap.dtsi create mode 100644 zephyr/program/herobrine/villager/battery.dtsi create mode 100644 zephyr/program/herobrine/villager/gpio.dtsi create mode 100644 zephyr/program/herobrine/villager/i2c.dtsi create mode 100644 zephyr/program/herobrine/villager/led_pins.dtsi create mode 100644 zephyr/program/herobrine/villager/led_policy.dtsi create mode 100644 zephyr/program/herobrine/villager/motionsense.dtsi create mode 100644 zephyr/program/herobrine/villager/project.conf create mode 100644 zephyr/program/herobrine/villager/project.overlay create mode 100644 zephyr/program/herobrine/villager/usbc.dtsi create mode 100644 zephyr/program/herobrine/zoglin/project.conf create mode 100644 zephyr/program/herobrine/zoglin/project.overlay create mode 100644 zephyr/program/herobrine/zombie/battery.dtsi create mode 100644 zephyr/program/herobrine/zombie/gpio.dtsi create mode 100644 zephyr/program/herobrine/zombie/i2c.dtsi create mode 100644 zephyr/program/herobrine/zombie/led_pins.dtsi create mode 100644 zephyr/program/herobrine/zombie/led_policy.dtsi create mode 100644 zephyr/program/herobrine/zombie/motionsense.dtsi create mode 100644 zephyr/program/herobrine/zombie/project.conf create mode 100644 zephyr/program/herobrine/zombie/project.overlay create mode 100644 zephyr/program/herobrine/zombie/usbc.dtsi create mode 100644 zephyr/program/intelrvp/BUILD.py create mode 100644 zephyr/program/intelrvp/CMakeLists.txt create mode 100644 zephyr/program/intelrvp/Kconfig create mode 100644 zephyr/program/intelrvp/adlrvp/CMakeLists.txt create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_mchp/gpio.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_mchp/usbc.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/fan.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/gpio.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts create mode 100644 zephyr/program/intelrvp/adlrvp/adlrvp_npcx/usbc.dts create mode 100644 zephyr/program/intelrvp/adlrvp/battery.dts create mode 100644 zephyr/program/intelrvp/adlrvp/include/adlrvp_zephyr.h create mode 100644 zephyr/program/intelrvp/adlrvp/ioex.dts create mode 100644 zephyr/program/intelrvp/adlrvp/prj.conf create mode 100644 zephyr/program/intelrvp/adlrvp/src/adlrvp.c create mode 100644 zephyr/program/intelrvp/include/intel_rvp_board_id.h create mode 100644 zephyr/program/intelrvp/include/intelrvp.h create mode 100644 zephyr/program/intelrvp/led.md create mode 100644 zephyr/program/intelrvp/legacy_ec_pwrseq.conf create mode 100644 zephyr/program/intelrvp/mtlrvp/CMakeLists.txt create mode 100644 zephyr/program/intelrvp/mtlrvp/ioex.dts create mode 100644 zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts create mode 100644 zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts create mode 100644 zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts create mode 100644 zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts create mode 100644 zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts create mode 100644 zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts create mode 100644 zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf create mode 100644 zephyr/program/intelrvp/mtlrvp/prj.conf create mode 100644 zephyr/program/intelrvp/mtlrvp/src/board_power.c create mode 100644 zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c create mode 100644 zephyr/program/intelrvp/mtlrvp/usbc.dts create mode 100644 zephyr/program/intelrvp/prj.conf create mode 100644 zephyr/program/intelrvp/src/chg_usb_pd.c create mode 100644 zephyr/program/intelrvp/src/chg_usb_pd_mecc_1_1.c create mode 100644 zephyr/program/intelrvp/src/intel_rvp_board_id.c create mode 100644 zephyr/program/intelrvp/src/intel_rvp_led.c create mode 100644 zephyr/program/intelrvp/src/intelrvp.c create mode 100644 zephyr/program/intelrvp/src/usb_pd_policy_mecc_1_1.c create mode 100644 zephyr/program/intelrvp/zephyr_ap_pwrseq.conf create mode 100644 zephyr/program/it8xxx2_evb/BUILD.py create mode 100644 zephyr/program/it8xxx2_evb/CMakeLists.txt create mode 100644 zephyr/program/it8xxx2_evb/adc.dts create mode 100644 zephyr/program/it8xxx2_evb/fan.dts create mode 100644 zephyr/program/it8xxx2_evb/gpio.dts create mode 100644 zephyr/program/it8xxx2_evb/i2c.dts create mode 100644 zephyr/program/it8xxx2_evb/include/i2c_map.h create mode 100644 zephyr/program/it8xxx2_evb/interrupts.dts create mode 100644 zephyr/program/it8xxx2_evb/prj.conf create mode 100644 zephyr/program/it8xxx2_evb/pwm.dts create mode 100644 zephyr/program/minimal/BUILD.py create mode 100644 zephyr/program/minimal/CMakeLists.txt create mode 100644 zephyr/program/minimal/README.md create mode 100644 zephyr/program/minimal/it8xxx2.dts create mode 100644 zephyr/program/minimal/npcx9.dts create mode 100644 zephyr/program/minimal/prj.conf create mode 100644 zephyr/program/nissa/BUILD.py create mode 100644 zephyr/program/nissa/CMakeLists.txt create mode 100644 zephyr/program/nissa/Kconfig create mode 100644 zephyr/program/nissa/cbi.dtsi create mode 100644 zephyr/program/nissa/craask/cbi.dtsi create mode 100644 zephyr/program/nissa/craask/generated.dtsi create mode 100644 zephyr/program/nissa/craask/keyboard.dtsi create mode 100644 zephyr/program/nissa/craask/motionsense.dtsi create mode 100644 zephyr/program/nissa/craask/overlay.dtsi create mode 100644 zephyr/program/nissa/craask/power_signals.dtsi create mode 100644 zephyr/program/nissa/craask/project.conf create mode 100644 zephyr/program/nissa/craask/project.overlay create mode 100644 zephyr/program/nissa/craask/pwm_leds.dtsi create mode 100644 zephyr/program/nissa/craask/src/charger.c create mode 100644 zephyr/program/nissa/craask/src/form_factor.c create mode 100644 zephyr/program/nissa/craask/src/keyboard.c create mode 100644 zephyr/program/nissa/craask/src/led.c create mode 100644 zephyr/program/nissa/craask/src/usbc.c create mode 100644 zephyr/program/nissa/include/nissa_common.h create mode 100644 zephyr/program/nissa/include/nissa_hdmi.h create mode 100644 zephyr/program/nissa/it8xxx2_program.conf create mode 100644 zephyr/program/nissa/joxer/cbi.dtsi create mode 100644 zephyr/program/nissa/joxer/generated.dtsi create mode 100644 zephyr/program/nissa/joxer/joxer_vif.xml create mode 100644 zephyr/program/nissa/joxer/keyboard.dtsi create mode 100644 zephyr/program/nissa/joxer/motionsense.dtsi create mode 100644 zephyr/program/nissa/joxer/overlay.dtsi create mode 100644 zephyr/program/nissa/joxer/power_signals.dtsi create mode 100644 zephyr/program/nissa/joxer/project.conf create mode 100644 zephyr/program/nissa/joxer/project.overlay create mode 100644 zephyr/program/nissa/joxer/pwm_leds.dtsi create mode 100644 zephyr/program/nissa/joxer/src/charger.c create mode 100644 zephyr/program/nissa/joxer/src/fan.c create mode 100644 zephyr/program/nissa/joxer/src/keyboard.c create mode 100644 zephyr/program/nissa/joxer/src/led.c create mode 100644 zephyr/program/nissa/joxer/src/usbc.c create mode 100644 zephyr/program/nissa/nereid/generated.dtsi create mode 100644 zephyr/program/nissa/nereid/keyboard.dtsi create mode 100644 zephyr/program/nissa/nereid/motionsense.dtsi create mode 100644 zephyr/program/nissa/nereid/nereid_vif.xml create mode 100644 zephyr/program/nissa/nereid/overlay.dtsi create mode 100644 zephyr/program/nissa/nereid/power_signals.dtsi create mode 100644 zephyr/program/nissa/nereid/project.conf create mode 100644 zephyr/program/nissa/nereid/project.overlay create mode 100644 zephyr/program/nissa/nereid/pwm_leds.dtsi create mode 100644 zephyr/program/nissa/nereid/src/charger.c create mode 100644 zephyr/program/nissa/nereid/src/hdmi.c create mode 100644 zephyr/program/nissa/nereid/src/keyboard.c create mode 100644 zephyr/program/nissa/nereid/src/usbc.c create mode 100644 zephyr/program/nissa/nissa.csv create mode 100644 zephyr/program/nissa/nivviks/cbi.dtsi create mode 100644 zephyr/program/nissa/nivviks/generated.dtsi create mode 100644 zephyr/program/nissa/nivviks/keyboard.dtsi create mode 100644 zephyr/program/nissa/nivviks/motionsense.dtsi create mode 100644 zephyr/program/nissa/nivviks/overlay.dtsi create mode 100644 zephyr/program/nissa/nivviks/power_signals.dtsi create mode 100644 zephyr/program/nissa/nivviks/project.conf create mode 100644 zephyr/program/nissa/nivviks/project.overlay create mode 100644 zephyr/program/nissa/nivviks/pwm_leds.dtsi create mode 100644 zephyr/program/nissa/nivviks/src/charger.c create mode 100644 zephyr/program/nissa/nivviks/src/fan.c create mode 100644 zephyr/program/nissa/nivviks/src/form_factor.c create mode 100644 zephyr/program/nissa/nivviks/src/keyboard.c create mode 100644 zephyr/program/nissa/nivviks/src/led.c create mode 100644 zephyr/program/nissa/nivviks/src/usbc.c create mode 100644 zephyr/program/nissa/npcx_program.conf create mode 100644 zephyr/program/nissa/program.conf create mode 100644 zephyr/program/nissa/pujjo/cbi.dtsi create mode 100644 zephyr/program/nissa/pujjo/generated.dtsi create mode 100644 zephyr/program/nissa/pujjo/keyboard.dtsi create mode 100644 zephyr/program/nissa/pujjo/motionsense.dtsi create mode 100644 zephyr/program/nissa/pujjo/overlay.dtsi create mode 100644 zephyr/program/nissa/pujjo/power_signals.dtsi create mode 100644 zephyr/program/nissa/pujjo/project.conf create mode 100644 zephyr/program/nissa/pujjo/project.overlay create mode 100644 zephyr/program/nissa/pujjo/pujjo_vif.xml create mode 100644 zephyr/program/nissa/pujjo/src/charger.c create mode 100644 zephyr/program/nissa/pujjo/src/fan.c create mode 100644 zephyr/program/nissa/pujjo/src/form_factor.c create mode 100644 zephyr/program/nissa/pujjo/src/hdmi.c create mode 100644 zephyr/program/nissa/pujjo/src/keyboard.c create mode 100644 zephyr/program/nissa/pujjo/src/led.c create mode 100644 zephyr/program/nissa/pujjo/src/usbc.c create mode 100644 zephyr/program/nissa/src/board_power.c create mode 100644 zephyr/program/nissa/src/common.c create mode 100644 zephyr/program/nissa/src/led.c create mode 100644 zephyr/program/nissa/src/sub_board.c create mode 100644 zephyr/program/nissa/xivu/cbi.dtsi create mode 100644 zephyr/program/nissa/xivu/generated.dtsi create mode 100644 zephyr/program/nissa/xivu/keyboard.dtsi create mode 100644 zephyr/program/nissa/xivu/led_pins.dtsi create mode 100644 zephyr/program/nissa/xivu/led_policy.dtsi create mode 100644 zephyr/program/nissa/xivu/motionsense.dtsi create mode 100644 zephyr/program/nissa/xivu/overlay.dtsi create mode 100644 zephyr/program/nissa/xivu/power_signals.dtsi create mode 100644 zephyr/program/nissa/xivu/project.conf create mode 100644 zephyr/program/nissa/xivu/project.overlay create mode 100644 zephyr/program/nissa/xivu/src/charger.c create mode 100644 zephyr/program/nissa/xivu/src/keyboard.c create mode 100644 zephyr/program/nissa/xivu/src/usbc.c create mode 100644 zephyr/program/nissa/yaviks/cbi.dtsi create mode 100644 zephyr/program/nissa/yaviks/gpio.dtsi create mode 100644 zephyr/program/nissa/yaviks/keyboard.dtsi create mode 100644 zephyr/program/nissa/yaviks/overlay.dtsi create mode 100644 zephyr/program/nissa/yaviks/power_signals.dtsi create mode 100644 zephyr/program/nissa/yaviks/project.conf create mode 100644 zephyr/program/nissa/yaviks/project.overlay create mode 100644 zephyr/program/nissa/yaviks/src/charger.c create mode 100644 zephyr/program/nissa/yaviks/src/fan.c create mode 100644 zephyr/program/nissa/yaviks/src/keyboard.c create mode 100644 zephyr/program/nissa/yaviks/src/led.c create mode 100644 zephyr/program/nissa/yaviks/src/usbc.c create mode 100644 zephyr/program/nissa/yaviks/yaviks_vif.xml create mode 100644 zephyr/program/npcx_evb/npcx7/BUILD.py create mode 100644 zephyr/program/npcx_evb/npcx7/CMakeLists.txt create mode 100644 zephyr/program/npcx_evb/npcx7/fan.dts create mode 100644 zephyr/program/npcx_evb/npcx7/gpio.dts create mode 100644 zephyr/program/npcx_evb/npcx7/interrupts.dts create mode 100644 zephyr/program/npcx_evb/npcx7/keyboard.dts create mode 100644 zephyr/program/npcx_evb/npcx7/prj.conf create mode 100644 zephyr/program/npcx_evb/npcx9/BUILD.py create mode 100644 zephyr/program/npcx_evb/npcx9/CMakeLists.txt create mode 100644 zephyr/program/npcx_evb/npcx9/fan.dts create mode 100644 zephyr/program/npcx_evb/npcx9/gpio.dts create mode 100644 zephyr/program/npcx_evb/npcx9/interrupts.dts create mode 100644 zephyr/program/npcx_evb/npcx9/keyboard.dts create mode 100644 zephyr/program/npcx_evb/npcx9/prj.conf create mode 100644 zephyr/program/rex/BUILD.py create mode 100644 zephyr/program/rex/CMakeLists.txt create mode 100644 zephyr/program/rex/Kconfig create mode 100644 zephyr/program/rex/battery.dts create mode 100644 zephyr/program/rex/fan.dts create mode 100644 zephyr/program/rex/generated.dts create mode 100644 zephyr/program/rex/include/gpio_map.h create mode 100644 zephyr/program/rex/interrupts.dts create mode 100644 zephyr/program/rex/keyboard.dts create mode 100644 zephyr/program/rex/led.dts create mode 100644 zephyr/program/rex/motionsense.dts create mode 100644 zephyr/program/rex/power_signals.dts create mode 100644 zephyr/program/rex/prj.conf create mode 100644 zephyr/program/rex/prj_rex.conf create mode 100644 zephyr/program/rex/rex.dts create mode 100644 zephyr/program/rex/rex0_gpio.csv create mode 100644 zephyr/program/rex/src/board_power.c create mode 100644 zephyr/program/rex/src/usb_pd_policy.c create mode 100644 zephyr/program/rex/src/usbc_config.c create mode 100644 zephyr/program/rex/temp_sensors.dts create mode 100644 zephyr/program/rex/usbc.dts create mode 100644 zephyr/program/skyrim/BUILD.py create mode 100644 zephyr/program/skyrim/CMakeLists.txt create mode 100644 zephyr/program/skyrim/Kconfig create mode 100644 zephyr/program/skyrim/adc.dts create mode 100644 zephyr/program/skyrim/battery_frostflow.dts create mode 100644 zephyr/program/skyrim/battery_morthal.dts create mode 100644 zephyr/program/skyrim/battery_skyrim.dts create mode 100644 zephyr/program/skyrim/battery_winterhold.dts create mode 100644 zephyr/program/skyrim/fan.dts create mode 100644 zephyr/program/skyrim/frostflow.dts create mode 100644 zephyr/program/skyrim/gpio.dts create mode 100644 zephyr/program/skyrim/i2c_common.dtsi create mode 100644 zephyr/program/skyrim/include/frostflow/keyboard_customization.h create mode 100644 zephyr/program/skyrim/interrupts.dts create mode 100644 zephyr/program/skyrim/keyboard.dts create mode 100644 zephyr/program/skyrim/led_pins_frostflow.dts create mode 100644 zephyr/program/skyrim/led_pins_morthal.dts create mode 100644 zephyr/program/skyrim/led_pins_skyrim.dts create mode 100644 zephyr/program/skyrim/led_pins_winterhold.dts create mode 100644 zephyr/program/skyrim/led_policy_frostflow.dts create mode 100644 zephyr/program/skyrim/led_policy_morthal.dts create mode 100644 zephyr/program/skyrim/led_policy_skyrim.dts create mode 100644 zephyr/program/skyrim/led_policy_winterhold.dts create mode 100644 zephyr/program/skyrim/morthal.dts create mode 100644 zephyr/program/skyrim/motionsense.dts create mode 100644 zephyr/program/skyrim/prj.conf create mode 100644 zephyr/program/skyrim/prj_frostflow.conf create mode 100644 zephyr/program/skyrim/prj_morthal.conf create mode 100644 zephyr/program/skyrim/prj_skyrim.conf create mode 100644 zephyr/program/skyrim/prj_winterhold.conf create mode 100644 zephyr/program/skyrim/skyrim.dts create mode 100644 zephyr/program/skyrim/src/common.c create mode 100644 zephyr/program/skyrim/src/frostflow/keyboard.c create mode 100644 zephyr/program/skyrim/src/frostflow/keyboard_customization.c create mode 100644 zephyr/program/skyrim/src/frostflow/ppc_config.c create mode 100644 zephyr/program/skyrim/src/frostflow/usb_mux_config.c create mode 100644 zephyr/program/skyrim/src/morthal/ppc_config.c create mode 100644 zephyr/program/skyrim/src/morthal/usb_mux_config.c create mode 100644 zephyr/program/skyrim/src/power_signals.c create mode 100644 zephyr/program/skyrim/src/skyrim/alt_charger.c create mode 100644 zephyr/program/skyrim/src/skyrim/fan.c create mode 100644 zephyr/program/skyrim/src/skyrim/form_factor.c create mode 100644 zephyr/program/skyrim/src/skyrim/keyboard.c create mode 100644 zephyr/program/skyrim/src/skyrim/ppc_config.c create mode 100644 zephyr/program/skyrim/src/skyrim/usb_mux_config.c create mode 100644 zephyr/program/skyrim/src/stt.c create mode 100644 zephyr/program/skyrim/src/usb_pd_policy.c create mode 100644 zephyr/program/skyrim/src/usbc_config.c create mode 100644 zephyr/program/skyrim/src/winterhold/kb_backlight.c create mode 100644 zephyr/program/skyrim/src/winterhold/keyboard.c create mode 100644 zephyr/program/skyrim/src/winterhold/ppc_config.c create mode 100644 zephyr/program/skyrim/src/winterhold/usb_mux_config.c create mode 100644 zephyr/program/skyrim/usbc.dts create mode 100644 zephyr/program/skyrim/winterhold.dts create mode 100644 zephyr/program/trogdor/lazor/BUILD.py create mode 100644 zephyr/program/trogdor/lazor/CMakeLists.txt create mode 100644 zephyr/program/trogdor/lazor/adc.dts create mode 100644 zephyr/program/trogdor/lazor/battery.dts create mode 100644 zephyr/program/trogdor/lazor/default_gpio_pinctrl.dts create mode 100644 zephyr/program/trogdor/lazor/display.dts create mode 100644 zephyr/program/trogdor/lazor/gpio.dts create mode 100644 zephyr/program/trogdor/lazor/gpio_led.dts create mode 100644 zephyr/program/trogdor/lazor/host_interface_npcx.dts create mode 100644 zephyr/program/trogdor/lazor/i2c.dts create mode 100644 zephyr/program/trogdor/lazor/include/sku.h create mode 100644 zephyr/program/trogdor/lazor/interrupts.dts create mode 100644 zephyr/program/trogdor/lazor/keyboard.dts create mode 100644 zephyr/program/trogdor/lazor/led.dts create mode 100644 zephyr/program/trogdor/lazor/motionsense.dts create mode 100644 zephyr/program/trogdor/lazor/prj.conf create mode 100644 zephyr/program/trogdor/lazor/pwm_led.dts create mode 100644 zephyr/program/trogdor/lazor/src/hibernate.c create mode 100644 zephyr/program/trogdor/lazor/src/i2c.c create mode 100644 zephyr/program/trogdor/lazor/src/power.c create mode 100644 zephyr/program/trogdor/lazor/src/sku.c create mode 100644 zephyr/program/trogdor/lazor/src/switchcap.c create mode 100644 zephyr/program/trogdor/lazor/src/usb_pd_policy.c create mode 100644 zephyr/program/trogdor/lazor/src/usbc_config.c create mode 100644 zephyr/program/trogdor/lazor/usbc.dts delete mode 100644 zephyr/projects/.pylintrc delete mode 100644 zephyr/projects/brya/BUILD.py delete mode 100644 zephyr/projects/brya/CMakeLists.txt delete mode 100644 zephyr/projects/brya/Kconfig delete mode 100644 zephyr/projects/brya/adc.dts delete mode 100644 zephyr/projects/brya/battery.dts delete mode 100644 zephyr/projects/brya/battery_present.c delete mode 100644 zephyr/projects/brya/brya.dts delete mode 100644 zephyr/projects/brya/fan.dts delete mode 100644 zephyr/projects/brya/gpio.dts delete mode 100644 zephyr/projects/brya/i2c.dts delete mode 100644 zephyr/projects/brya/interrupts.dts delete mode 100644 zephyr/projects/brya/kblight_hooks.c delete mode 100644 zephyr/projects/brya/keyboard.dts delete mode 100644 zephyr/projects/brya/motionsense.dts delete mode 100644 zephyr/projects/brya/prj.conf delete mode 100644 zephyr/projects/brya/prj_brya.conf delete mode 100644 zephyr/projects/brya/pwm_leds.dts delete mode 100644 zephyr/projects/brya/temp_sensors.dts delete mode 100644 zephyr/projects/brya/usbc.dts delete mode 100644 zephyr/projects/corsola/BUILD.py delete mode 100644 zephyr/projects/corsola/CMakeLists.txt delete mode 100644 zephyr/projects/corsola/Kconfig delete mode 100644 zephyr/projects/corsola/adc_kingler.dts delete mode 100644 zephyr/projects/corsola/adc_krabby.dts delete mode 100644 zephyr/projects/corsola/adc_magikarp.dts delete mode 100644 zephyr/projects/corsola/adc_tentacruel.dts delete mode 100644 zephyr/projects/corsola/battery_kingler.dts delete mode 100644 zephyr/projects/corsola/battery_krabby.dts delete mode 100644 zephyr/projects/corsola/battery_magikarp.dts delete mode 100644 zephyr/projects/corsola/battery_steelix.dts delete mode 100644 zephyr/projects/corsola/battery_tentacruel.dts delete mode 100644 zephyr/projects/corsola/cbi_magikarp.dts delete mode 100644 zephyr/projects/corsola/cbi_steelix.dts delete mode 100644 zephyr/projects/corsola/cbi_tentacruel.dts delete mode 100644 zephyr/projects/corsola/common.dts delete mode 100644 zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts delete mode 100644 zephyr/projects/corsola/gpio_kingler.dts delete mode 100644 zephyr/projects/corsola/gpio_krabby.dts delete mode 100644 zephyr/projects/corsola/gpio_magikarp.dts delete mode 100644 zephyr/projects/corsola/gpio_steelix.dts delete mode 100644 zephyr/projects/corsola/gpio_tentacruel.dts delete mode 100644 zephyr/projects/corsola/host_interface_npcx.dts delete mode 100644 zephyr/projects/corsola/i2c_kingler.dts delete mode 100644 zephyr/projects/corsola/i2c_krabby.dts delete mode 100644 zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi delete mode 100644 zephyr/projects/corsola/i2c_magikarp.dts delete mode 100644 zephyr/projects/corsola/i2c_tentacruel.dts delete mode 100644 zephyr/projects/corsola/include/baseboard_usbc_config.h delete mode 100644 zephyr/projects/corsola/include/variant_db_detection.h delete mode 100644 zephyr/projects/corsola/interrupts_kingler.dts delete mode 100644 zephyr/projects/corsola/interrupts_krabby.dts delete mode 100644 zephyr/projects/corsola/interrupts_magikarp.dts delete mode 100644 zephyr/projects/corsola/interrupts_steelix.dts delete mode 100644 zephyr/projects/corsola/interrupts_tentacruel.dts delete mode 100644 zephyr/projects/corsola/keyboard_krabby.dts delete mode 100644 zephyr/projects/corsola/keyboard_steelix.dts delete mode 100644 zephyr/projects/corsola/led_it81202_base.dtsi delete mode 100644 zephyr/projects/corsola/led_kingler.dts delete mode 100644 zephyr/projects/corsola/led_krabby.dts delete mode 100644 zephyr/projects/corsola/led_magikarp.dts delete mode 100644 zephyr/projects/corsola/led_steelix.dts delete mode 100644 zephyr/projects/corsola/led_tentacruel.dts delete mode 100644 zephyr/projects/corsola/motionsense_kingler.dts delete mode 100644 zephyr/projects/corsola/motionsense_krabby.dts delete mode 100644 zephyr/projects/corsola/motionsense_magikarp.dts delete mode 100644 zephyr/projects/corsola/motionsense_steelix.dts delete mode 100644 zephyr/projects/corsola/motionsense_tentacruel.dts delete mode 100644 zephyr/projects/corsola/npcx_keyboard.dts delete mode 100644 zephyr/projects/corsola/power_signal.dts delete mode 100644 zephyr/projects/corsola/prj.conf delete mode 100644 zephyr/projects/corsola/prj_it81202_base.conf delete mode 100644 zephyr/projects/corsola/prj_kingler.conf delete mode 100644 zephyr/projects/corsola/prj_krabby.conf delete mode 100644 zephyr/projects/corsola/prj_magikarp.conf delete mode 100644 zephyr/projects/corsola/prj_npcx993_base.conf delete mode 100644 zephyr/projects/corsola/prj_steelix.conf delete mode 100644 zephyr/projects/corsola/prj_tentacruel.conf delete mode 100644 zephyr/projects/corsola/src/board.c delete mode 100644 zephyr/projects/corsola/src/board_chipset.c delete mode 100644 zephyr/projects/corsola/src/hibernate.c delete mode 100644 zephyr/projects/corsola/src/kingler/board_steelix.c delete mode 100644 zephyr/projects/corsola/src/kingler/button.c delete mode 100644 zephyr/projects/corsola/src/kingler/i2c.c delete mode 100644 zephyr/projects/corsola/src/kingler/led.c delete mode 100644 zephyr/projects/corsola/src/kingler/led_steelix.c delete mode 100644 zephyr/projects/corsola/src/kingler/usb_pd_policy.c delete mode 100644 zephyr/projects/corsola/src/kingler/usbc_config.c delete mode 100644 zephyr/projects/corsola/src/krabby/charger_workaround.c delete mode 100644 zephyr/projects/corsola/src/krabby/hooks.c delete mode 100644 zephyr/projects/corsola/src/krabby/i2c.c delete mode 100644 zephyr/projects/corsola/src/krabby/keyboard_magikarp.c delete mode 100644 zephyr/projects/corsola/src/krabby/ppc_krabby.c delete mode 100644 zephyr/projects/corsola/src/krabby/ppc_magikarp.c delete mode 100644 zephyr/projects/corsola/src/krabby/ppc_tentacruel.c delete mode 100644 zephyr/projects/corsola/src/krabby/sensor_magikarp.c delete mode 100644 zephyr/projects/corsola/src/krabby/sensor_tentacruel.c delete mode 100644 zephyr/projects/corsola/src/krabby/temp_tentacruel.c delete mode 100644 zephyr/projects/corsola/src/krabby/usb_pd_policy.c delete mode 100644 zephyr/projects/corsola/src/krabby/usbc_config.c delete mode 100644 zephyr/projects/corsola/src/usb_pd_policy.c delete mode 100644 zephyr/projects/corsola/src/usbc_config.c delete mode 100644 zephyr/projects/corsola/src/variant_db_detection.c delete mode 100644 zephyr/projects/corsola/thermistor_tentacruel.dts delete mode 100644 zephyr/projects/corsola/usba.dts delete mode 100644 zephyr/projects/corsola/usba_steelix.dts delete mode 100644 zephyr/projects/corsola/usbc_kingler.dts delete mode 100644 zephyr/projects/corsola/usbc_krabby.dts delete mode 100644 zephyr/projects/corsola/usbc_magikarp.dts delete mode 100644 zephyr/projects/corsola/usbc_tentacruel.dts delete mode 100644 zephyr/projects/herobrine/BUILD.py delete mode 100644 zephyr/projects/herobrine/CMakeLists.txt delete mode 100644 zephyr/projects/herobrine/Kconfig delete mode 100644 zephyr/projects/herobrine/adc.dtsi delete mode 100644 zephyr/projects/herobrine/common.dtsi delete mode 100644 zephyr/projects/herobrine/default_gpio_pinctrl.dtsi delete mode 100644 zephyr/projects/herobrine/display.dtsi delete mode 100644 zephyr/projects/herobrine/evoker/battery.dtsi delete mode 100644 zephyr/projects/herobrine/evoker/gpio.dtsi delete mode 100644 zephyr/projects/herobrine/evoker/i2c.dtsi delete mode 100644 zephyr/projects/herobrine/evoker/led_pins.dtsi delete mode 100644 zephyr/projects/herobrine/evoker/led_policy.dtsi delete mode 100644 zephyr/projects/herobrine/evoker/motionsense.dtsi delete mode 100644 zephyr/projects/herobrine/evoker/project.conf delete mode 100644 zephyr/projects/herobrine/evoker/project.overlay delete mode 100644 zephyr/projects/herobrine/evoker/usbc.dtsi delete mode 100644 zephyr/projects/herobrine/gpio.dtsi delete mode 100644 zephyr/projects/herobrine/herobrine/CMakeLists.txt delete mode 100644 zephyr/projects/herobrine/herobrine/battery.dtsi delete mode 100644 zephyr/projects/herobrine/herobrine/i2c.dtsi delete mode 100644 zephyr/projects/herobrine/herobrine/led_pins.dtsi delete mode 100644 zephyr/projects/herobrine/herobrine/led_policy.dtsi delete mode 100644 zephyr/projects/herobrine/herobrine/project.conf delete mode 100644 zephyr/projects/herobrine/herobrine/project.overlay delete mode 100644 zephyr/projects/herobrine/herobrine/src/alt_dev_replacement.c delete mode 100644 zephyr/projects/herobrine/herobrine/usbc.dtsi delete mode 100644 zephyr/projects/herobrine/hoglin/battery.dtsi delete mode 100644 zephyr/projects/herobrine/hoglin/gpio.dtsi delete mode 100644 zephyr/projects/herobrine/hoglin/i2c.dtsi delete mode 100644 zephyr/projects/herobrine/hoglin/led_pins.dtsi delete mode 100644 zephyr/projects/herobrine/hoglin/led_policy.dtsi delete mode 100644 zephyr/projects/herobrine/hoglin/motionsense.dtsi delete mode 100644 zephyr/projects/herobrine/hoglin/project.conf delete mode 100644 zephyr/projects/herobrine/hoglin/project.overlay delete mode 100644 zephyr/projects/herobrine/hoglin/switchcap.dtsi delete mode 100644 zephyr/projects/herobrine/hoglin/usbc.dtsi delete mode 100644 zephyr/projects/herobrine/i2c.dtsi delete mode 100644 zephyr/projects/herobrine/include/board_chipset.h delete mode 100644 zephyr/projects/herobrine/interrupts.dtsi delete mode 100644 zephyr/projects/herobrine/keyboard.dtsi delete mode 100644 zephyr/projects/herobrine/motionsense.dtsi delete mode 100644 zephyr/projects/herobrine/program.conf delete mode 100644 zephyr/projects/herobrine/src/board_chipset.c delete mode 100644 zephyr/projects/herobrine/src/i2c.c delete mode 100644 zephyr/projects/herobrine/src/usb_pd_policy.c delete mode 100644 zephyr/projects/herobrine/src/usbc_config.c delete mode 100644 zephyr/projects/herobrine/switchcap.dtsi delete mode 100644 zephyr/projects/herobrine/villager/battery.dtsi delete mode 100644 zephyr/projects/herobrine/villager/gpio.dtsi delete mode 100644 zephyr/projects/herobrine/villager/i2c.dtsi delete mode 100644 zephyr/projects/herobrine/villager/led_pins.dtsi delete mode 100644 zephyr/projects/herobrine/villager/led_policy.dtsi delete mode 100644 zephyr/projects/herobrine/villager/motionsense.dtsi delete mode 100644 zephyr/projects/herobrine/villager/project.conf delete mode 100644 zephyr/projects/herobrine/villager/project.overlay delete mode 100644 zephyr/projects/herobrine/villager/usbc.dtsi delete mode 100644 zephyr/projects/herobrine/zoglin/project.conf delete mode 100644 zephyr/projects/herobrine/zoglin/project.overlay delete mode 100644 zephyr/projects/herobrine/zombie/battery.dtsi delete mode 100644 zephyr/projects/herobrine/zombie/gpio.dtsi delete mode 100644 zephyr/projects/herobrine/zombie/i2c.dtsi delete mode 100644 zephyr/projects/herobrine/zombie/led_pins.dtsi delete mode 100644 zephyr/projects/herobrine/zombie/led_policy.dtsi delete mode 100644 zephyr/projects/herobrine/zombie/motionsense.dtsi delete mode 100644 zephyr/projects/herobrine/zombie/project.conf delete mode 100644 zephyr/projects/herobrine/zombie/project.overlay delete mode 100644 zephyr/projects/herobrine/zombie/usbc.dtsi delete mode 100644 zephyr/projects/intelrvp/BUILD.py delete mode 100644 zephyr/projects/intelrvp/CMakeLists.txt delete mode 100644 zephyr/projects/intelrvp/Kconfig delete mode 100644 zephyr/projects/intelrvp/adlrvp/CMakeLists.txt delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/gpio.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/usbc.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/fan.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/gpio.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/battery.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/include/adlrvp_zephyr.h delete mode 100644 zephyr/projects/intelrvp/adlrvp/ioex.dts delete mode 100644 zephyr/projects/intelrvp/adlrvp/prj.conf delete mode 100644 zephyr/projects/intelrvp/adlrvp/src/adlrvp.c delete mode 100644 zephyr/projects/intelrvp/include/intel_rvp_board_id.h delete mode 100644 zephyr/projects/intelrvp/include/intelrvp.h delete mode 100644 zephyr/projects/intelrvp/led.md delete mode 100644 zephyr/projects/intelrvp/legacy_ec_pwrseq.conf delete mode 100644 zephyr/projects/intelrvp/mtlrvp/CMakeLists.txt delete mode 100644 zephyr/projects/intelrvp/mtlrvp/ioex.dts delete mode 100644 zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts delete mode 100644 zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts delete mode 100644 zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts delete mode 100644 zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts delete mode 100644 zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts delete mode 100644 zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts delete mode 100644 zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf delete mode 100644 zephyr/projects/intelrvp/mtlrvp/prj.conf delete mode 100644 zephyr/projects/intelrvp/mtlrvp/src/board_power.c delete mode 100644 zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c delete mode 100644 zephyr/projects/intelrvp/mtlrvp/usbc.dts delete mode 100644 zephyr/projects/intelrvp/prj.conf delete mode 100644 zephyr/projects/intelrvp/src/chg_usb_pd.c delete mode 100644 zephyr/projects/intelrvp/src/chg_usb_pd_mecc_1_1.c delete mode 100644 zephyr/projects/intelrvp/src/intel_rvp_board_id.c delete mode 100644 zephyr/projects/intelrvp/src/intel_rvp_led.c delete mode 100644 zephyr/projects/intelrvp/src/intelrvp.c delete mode 100644 zephyr/projects/intelrvp/src/usb_pd_policy_mecc_1_1.c delete mode 100644 zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf delete mode 100644 zephyr/projects/it8xxx2_evb/BUILD.py delete mode 100644 zephyr/projects/it8xxx2_evb/CMakeLists.txt delete mode 100644 zephyr/projects/it8xxx2_evb/adc.dts delete mode 100644 zephyr/projects/it8xxx2_evb/fan.dts delete mode 100644 zephyr/projects/it8xxx2_evb/gpio.dts delete mode 100644 zephyr/projects/it8xxx2_evb/i2c.dts delete mode 100644 zephyr/projects/it8xxx2_evb/include/i2c_map.h delete mode 100644 zephyr/projects/it8xxx2_evb/interrupts.dts delete mode 100644 zephyr/projects/it8xxx2_evb/prj.conf delete mode 100644 zephyr/projects/it8xxx2_evb/pwm.dts delete mode 100644 zephyr/projects/minimal/BUILD.py delete mode 100644 zephyr/projects/minimal/CMakeLists.txt delete mode 100644 zephyr/projects/minimal/README.md delete mode 100644 zephyr/projects/minimal/it8xxx2.dts delete mode 100644 zephyr/projects/minimal/npcx9.dts delete mode 100644 zephyr/projects/minimal/prj.conf delete mode 100644 zephyr/projects/nissa/BUILD.py delete mode 100644 zephyr/projects/nissa/CMakeLists.txt delete mode 100644 zephyr/projects/nissa/Kconfig delete mode 100644 zephyr/projects/nissa/cbi.dtsi delete mode 100644 zephyr/projects/nissa/craask/cbi.dtsi delete mode 100644 zephyr/projects/nissa/craask/generated.dtsi delete mode 100644 zephyr/projects/nissa/craask/keyboard.dtsi delete mode 100644 zephyr/projects/nissa/craask/motionsense.dtsi delete mode 100644 zephyr/projects/nissa/craask/overlay.dtsi delete mode 100644 zephyr/projects/nissa/craask/power_signals.dtsi delete mode 100644 zephyr/projects/nissa/craask/project.conf delete mode 100644 zephyr/projects/nissa/craask/project.overlay delete mode 100644 zephyr/projects/nissa/craask/pwm_leds.dtsi delete mode 100644 zephyr/projects/nissa/craask/src/charger.c delete mode 100644 zephyr/projects/nissa/craask/src/form_factor.c delete mode 100644 zephyr/projects/nissa/craask/src/keyboard.c delete mode 100644 zephyr/projects/nissa/craask/src/led.c delete mode 100644 zephyr/projects/nissa/craask/src/usbc.c delete mode 100644 zephyr/projects/nissa/include/nissa_common.h delete mode 100644 zephyr/projects/nissa/include/nissa_hdmi.h delete mode 100644 zephyr/projects/nissa/it8xxx2_program.conf delete mode 100644 zephyr/projects/nissa/joxer/cbi.dtsi delete mode 100644 zephyr/projects/nissa/joxer/generated.dtsi delete mode 100644 zephyr/projects/nissa/joxer/joxer_vif.xml delete mode 100644 zephyr/projects/nissa/joxer/keyboard.dtsi delete mode 100644 zephyr/projects/nissa/joxer/motionsense.dtsi delete mode 100644 zephyr/projects/nissa/joxer/overlay.dtsi delete mode 100644 zephyr/projects/nissa/joxer/power_signals.dtsi delete mode 100644 zephyr/projects/nissa/joxer/project.conf delete mode 100644 zephyr/projects/nissa/joxer/project.overlay delete mode 100644 zephyr/projects/nissa/joxer/pwm_leds.dtsi delete mode 100644 zephyr/projects/nissa/joxer/src/charger.c delete mode 100644 zephyr/projects/nissa/joxer/src/fan.c delete mode 100644 zephyr/projects/nissa/joxer/src/keyboard.c delete mode 100644 zephyr/projects/nissa/joxer/src/led.c delete mode 100644 zephyr/projects/nissa/joxer/src/usbc.c delete mode 100644 zephyr/projects/nissa/nereid/generated.dtsi delete mode 100644 zephyr/projects/nissa/nereid/keyboard.dtsi delete mode 100644 zephyr/projects/nissa/nereid/motionsense.dtsi delete mode 100644 zephyr/projects/nissa/nereid/nereid_vif.xml delete mode 100644 zephyr/projects/nissa/nereid/overlay.dtsi delete mode 100644 zephyr/projects/nissa/nereid/power_signals.dtsi delete mode 100644 zephyr/projects/nissa/nereid/project.conf delete mode 100644 zephyr/projects/nissa/nereid/project.overlay delete mode 100644 zephyr/projects/nissa/nereid/pwm_leds.dtsi delete mode 100644 zephyr/projects/nissa/nereid/src/charger.c delete mode 100644 zephyr/projects/nissa/nereid/src/hdmi.c delete mode 100644 zephyr/projects/nissa/nereid/src/keyboard.c delete mode 100644 zephyr/projects/nissa/nereid/src/usbc.c delete mode 100644 zephyr/projects/nissa/nissa.csv delete mode 100644 zephyr/projects/nissa/nivviks/cbi.dtsi delete mode 100644 zephyr/projects/nissa/nivviks/generated.dtsi delete mode 100644 zephyr/projects/nissa/nivviks/keyboard.dtsi delete mode 100644 zephyr/projects/nissa/nivviks/motionsense.dtsi delete mode 100644 zephyr/projects/nissa/nivviks/overlay.dtsi delete mode 100644 zephyr/projects/nissa/nivviks/power_signals.dtsi delete mode 100644 zephyr/projects/nissa/nivviks/project.conf delete mode 100644 zephyr/projects/nissa/nivviks/project.overlay delete mode 100644 zephyr/projects/nissa/nivviks/pwm_leds.dtsi delete mode 100644 zephyr/projects/nissa/nivviks/src/charger.c delete mode 100644 zephyr/projects/nissa/nivviks/src/fan.c delete mode 100644 zephyr/projects/nissa/nivviks/src/form_factor.c delete mode 100644 zephyr/projects/nissa/nivviks/src/keyboard.c delete mode 100644 zephyr/projects/nissa/nivviks/src/led.c delete mode 100644 zephyr/projects/nissa/nivviks/src/usbc.c delete mode 100644 zephyr/projects/nissa/npcx_program.conf delete mode 100644 zephyr/projects/nissa/program.conf delete mode 100644 zephyr/projects/nissa/pujjo/cbi.dtsi delete mode 100644 zephyr/projects/nissa/pujjo/generated.dtsi delete mode 100644 zephyr/projects/nissa/pujjo/keyboard.dtsi delete mode 100644 zephyr/projects/nissa/pujjo/motionsense.dtsi delete mode 100644 zephyr/projects/nissa/pujjo/overlay.dtsi delete mode 100644 zephyr/projects/nissa/pujjo/power_signals.dtsi delete mode 100644 zephyr/projects/nissa/pujjo/project.conf delete mode 100644 zephyr/projects/nissa/pujjo/project.overlay delete mode 100644 zephyr/projects/nissa/pujjo/pujjo_vif.xml delete mode 100644 zephyr/projects/nissa/pujjo/src/charger.c delete mode 100644 zephyr/projects/nissa/pujjo/src/fan.c delete mode 100644 zephyr/projects/nissa/pujjo/src/form_factor.c delete mode 100644 zephyr/projects/nissa/pujjo/src/hdmi.c delete mode 100644 zephyr/projects/nissa/pujjo/src/keyboard.c delete mode 100644 zephyr/projects/nissa/pujjo/src/led.c delete mode 100644 zephyr/projects/nissa/pujjo/src/usbc.c delete mode 100644 zephyr/projects/nissa/src/board_power.c delete mode 100644 zephyr/projects/nissa/src/common.c delete mode 100644 zephyr/projects/nissa/src/led.c delete mode 100644 zephyr/projects/nissa/src/sub_board.c delete mode 100644 zephyr/projects/nissa/xivu/cbi.dtsi delete mode 100644 zephyr/projects/nissa/xivu/generated.dtsi delete mode 100644 zephyr/projects/nissa/xivu/keyboard.dtsi delete mode 100644 zephyr/projects/nissa/xivu/led_pins.dtsi delete mode 100644 zephyr/projects/nissa/xivu/led_policy.dtsi delete mode 100644 zephyr/projects/nissa/xivu/motionsense.dtsi delete mode 100644 zephyr/projects/nissa/xivu/overlay.dtsi delete mode 100644 zephyr/projects/nissa/xivu/power_signals.dtsi delete mode 100644 zephyr/projects/nissa/xivu/project.conf delete mode 100644 zephyr/projects/nissa/xivu/project.overlay delete mode 100644 zephyr/projects/nissa/xivu/src/charger.c delete mode 100644 zephyr/projects/nissa/xivu/src/keyboard.c delete mode 100644 zephyr/projects/nissa/xivu/src/usbc.c delete mode 100644 zephyr/projects/nissa/yaviks/cbi.dtsi delete mode 100644 zephyr/projects/nissa/yaviks/gpio.dtsi delete mode 100644 zephyr/projects/nissa/yaviks/keyboard.dtsi delete mode 100644 zephyr/projects/nissa/yaviks/overlay.dtsi delete mode 100644 zephyr/projects/nissa/yaviks/power_signals.dtsi delete mode 100644 zephyr/projects/nissa/yaviks/project.conf delete mode 100644 zephyr/projects/nissa/yaviks/project.overlay delete mode 100644 zephyr/projects/nissa/yaviks/src/charger.c delete mode 100644 zephyr/projects/nissa/yaviks/src/fan.c delete mode 100644 zephyr/projects/nissa/yaviks/src/keyboard.c delete mode 100644 zephyr/projects/nissa/yaviks/src/led.c delete mode 100644 zephyr/projects/nissa/yaviks/src/usbc.c delete mode 100644 zephyr/projects/nissa/yaviks/yaviks_vif.xml delete mode 100644 zephyr/projects/npcx_evb/npcx7/BUILD.py delete mode 100644 zephyr/projects/npcx_evb/npcx7/CMakeLists.txt delete mode 100644 zephyr/projects/npcx_evb/npcx7/fan.dts delete mode 100644 zephyr/projects/npcx_evb/npcx7/gpio.dts delete mode 100644 zephyr/projects/npcx_evb/npcx7/interrupts.dts delete mode 100644 zephyr/projects/npcx_evb/npcx7/keyboard.dts delete mode 100644 zephyr/projects/npcx_evb/npcx7/prj.conf delete mode 100644 zephyr/projects/npcx_evb/npcx9/BUILD.py delete mode 100644 zephyr/projects/npcx_evb/npcx9/CMakeLists.txt delete mode 100644 zephyr/projects/npcx_evb/npcx9/fan.dts delete mode 100644 zephyr/projects/npcx_evb/npcx9/gpio.dts delete mode 100644 zephyr/projects/npcx_evb/npcx9/interrupts.dts delete mode 100644 zephyr/projects/npcx_evb/npcx9/keyboard.dts delete mode 100644 zephyr/projects/npcx_evb/npcx9/prj.conf delete mode 100644 zephyr/projects/rex/BUILD.py delete mode 100644 zephyr/projects/rex/CMakeLists.txt delete mode 100644 zephyr/projects/rex/Kconfig delete mode 100644 zephyr/projects/rex/battery.dts delete mode 100644 zephyr/projects/rex/fan.dts delete mode 100644 zephyr/projects/rex/generated.dts delete mode 100644 zephyr/projects/rex/include/gpio_map.h delete mode 100644 zephyr/projects/rex/interrupts.dts delete mode 100644 zephyr/projects/rex/keyboard.dts delete mode 100644 zephyr/projects/rex/led.dts delete mode 100644 zephyr/projects/rex/motionsense.dts delete mode 100644 zephyr/projects/rex/power_signals.dts delete mode 100644 zephyr/projects/rex/prj.conf delete mode 100644 zephyr/projects/rex/prj_rex.conf delete mode 100644 zephyr/projects/rex/rex.dts delete mode 100644 zephyr/projects/rex/rex0_gpio.csv delete mode 100644 zephyr/projects/rex/src/board_power.c delete mode 100644 zephyr/projects/rex/src/usb_pd_policy.c delete mode 100644 zephyr/projects/rex/src/usbc_config.c delete mode 100644 zephyr/projects/rex/temp_sensors.dts delete mode 100644 zephyr/projects/rex/usbc.dts delete mode 100644 zephyr/projects/skyrim/BUILD.py delete mode 100644 zephyr/projects/skyrim/CMakeLists.txt delete mode 100644 zephyr/projects/skyrim/Kconfig delete mode 100644 zephyr/projects/skyrim/adc.dts delete mode 100644 zephyr/projects/skyrim/battery_frostflow.dts delete mode 100644 zephyr/projects/skyrim/battery_morthal.dts delete mode 100644 zephyr/projects/skyrim/battery_skyrim.dts delete mode 100644 zephyr/projects/skyrim/battery_winterhold.dts delete mode 100644 zephyr/projects/skyrim/fan.dts delete mode 100644 zephyr/projects/skyrim/frostflow.dts delete mode 100644 zephyr/projects/skyrim/gpio.dts delete mode 100644 zephyr/projects/skyrim/i2c_common.dtsi delete mode 100644 zephyr/projects/skyrim/include/frostflow/keyboard_customization.h delete mode 100644 zephyr/projects/skyrim/interrupts.dts delete mode 100644 zephyr/projects/skyrim/keyboard.dts delete mode 100644 zephyr/projects/skyrim/led_pins_frostflow.dts delete mode 100644 zephyr/projects/skyrim/led_pins_morthal.dts delete mode 100644 zephyr/projects/skyrim/led_pins_skyrim.dts delete mode 100644 zephyr/projects/skyrim/led_pins_winterhold.dts delete mode 100644 zephyr/projects/skyrim/led_policy_frostflow.dts delete mode 100644 zephyr/projects/skyrim/led_policy_morthal.dts delete mode 100644 zephyr/projects/skyrim/led_policy_skyrim.dts delete mode 100644 zephyr/projects/skyrim/led_policy_winterhold.dts delete mode 100644 zephyr/projects/skyrim/morthal.dts delete mode 100644 zephyr/projects/skyrim/motionsense.dts delete mode 100644 zephyr/projects/skyrim/prj.conf delete mode 100644 zephyr/projects/skyrim/prj_frostflow.conf delete mode 100644 zephyr/projects/skyrim/prj_morthal.conf delete mode 100644 zephyr/projects/skyrim/prj_skyrim.conf delete mode 100644 zephyr/projects/skyrim/prj_winterhold.conf delete mode 100644 zephyr/projects/skyrim/skyrim.dts delete mode 100644 zephyr/projects/skyrim/src/common.c delete mode 100644 zephyr/projects/skyrim/src/frostflow/keyboard.c delete mode 100644 zephyr/projects/skyrim/src/frostflow/keyboard_customization.c delete mode 100644 zephyr/projects/skyrim/src/frostflow/ppc_config.c delete mode 100644 zephyr/projects/skyrim/src/frostflow/usb_mux_config.c delete mode 100644 zephyr/projects/skyrim/src/morthal/ppc_config.c delete mode 100644 zephyr/projects/skyrim/src/morthal/usb_mux_config.c delete mode 100644 zephyr/projects/skyrim/src/power_signals.c delete mode 100644 zephyr/projects/skyrim/src/skyrim/alt_charger.c delete mode 100644 zephyr/projects/skyrim/src/skyrim/fan.c delete mode 100644 zephyr/projects/skyrim/src/skyrim/form_factor.c delete mode 100644 zephyr/projects/skyrim/src/skyrim/keyboard.c delete mode 100644 zephyr/projects/skyrim/src/skyrim/ppc_config.c delete mode 100644 zephyr/projects/skyrim/src/skyrim/usb_mux_config.c delete mode 100644 zephyr/projects/skyrim/src/stt.c delete mode 100644 zephyr/projects/skyrim/src/usb_pd_policy.c delete mode 100644 zephyr/projects/skyrim/src/usbc_config.c delete mode 100644 zephyr/projects/skyrim/src/winterhold/kb_backlight.c delete mode 100644 zephyr/projects/skyrim/src/winterhold/keyboard.c delete mode 100644 zephyr/projects/skyrim/src/winterhold/ppc_config.c delete mode 100644 zephyr/projects/skyrim/src/winterhold/usb_mux_config.c delete mode 100644 zephyr/projects/skyrim/usbc.dts delete mode 100644 zephyr/projects/skyrim/winterhold.dts delete mode 100644 zephyr/projects/trogdor/lazor/BUILD.py delete mode 100644 zephyr/projects/trogdor/lazor/CMakeLists.txt delete mode 100644 zephyr/projects/trogdor/lazor/adc.dts delete mode 100644 zephyr/projects/trogdor/lazor/battery.dts delete mode 100644 zephyr/projects/trogdor/lazor/default_gpio_pinctrl.dts delete mode 100644 zephyr/projects/trogdor/lazor/display.dts delete mode 100644 zephyr/projects/trogdor/lazor/gpio.dts delete mode 100644 zephyr/projects/trogdor/lazor/gpio_led.dts delete mode 100644 zephyr/projects/trogdor/lazor/host_interface_npcx.dts delete mode 100644 zephyr/projects/trogdor/lazor/i2c.dts delete mode 100644 zephyr/projects/trogdor/lazor/include/sku.h delete mode 100644 zephyr/projects/trogdor/lazor/interrupts.dts delete mode 100644 zephyr/projects/trogdor/lazor/keyboard.dts delete mode 100644 zephyr/projects/trogdor/lazor/led.dts delete mode 100644 zephyr/projects/trogdor/lazor/motionsense.dts delete mode 100644 zephyr/projects/trogdor/lazor/prj.conf delete mode 100644 zephyr/projects/trogdor/lazor/pwm_led.dts delete mode 100644 zephyr/projects/trogdor/lazor/src/hibernate.c delete mode 100644 zephyr/projects/trogdor/lazor/src/i2c.c delete mode 100644 zephyr/projects/trogdor/lazor/src/power.c delete mode 100644 zephyr/projects/trogdor/lazor/src/sku.c delete mode 100644 zephyr/projects/trogdor/lazor/src/switchcap.c delete mode 100644 zephyr/projects/trogdor/lazor/src/usb_pd_policy.c delete mode 100644 zephyr/projects/trogdor/lazor/src/usbc_config.c delete mode 100644 zephyr/projects/trogdor/lazor/usbc.dts diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6f218c8cc..4f65ddfa9e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -159,7 +159,7 @@ before_script: "${MODULES_DIR}/**" "${EC_DIR}/zephyr/drivers/**" "${EC_DIR}/zephyr/include/drivers/**" "${EC_DIR}/zephyr/shim/chip/**" "${EC_DIR}/zephyr/shim/core/**" - "${EC_DIR}/zephyr/projects/**" "/usr/include/**" + "${EC_DIR}/zephyr/program/**" "/usr/include/**" "${EC_DIR}/build/**" "${EC_DIR}/twister-out*/**" "${EC_DIR}/test/**" "${EC_DIR}/zephyr/shim/chip/npcx/npcx_monitor/**" @@ -174,7 +174,7 @@ before_script: "${ZEPHYR_BASE}/**" "${MODULES_DIR}/**" "${EC_DIR}/zephyr/drivers/**" "${EC_DIR}/zephyr/include/drivers/**" "${EC_DIR}/zephyr/shim/chip/**" "${EC_DIR}/zephyr/shim/core/**" - "${EC_DIR}/zephyr/projects/**" "/usr/include/**" + "${EC_DIR}/zephyr/program/**" "/usr/include/**" "${EC_DIR}/build/**" "${EC_DIR}/twister-out*/**" "${EC_DIR}/zephyr/shim/chip/npcx/npcx_monitor/**" "${EC_DIR}/test/**" diff --git a/CMakeLists.txt b/CMakeLists.txt index e4d48e00b4..34e81f2be9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ endif() set(PLATFORM_EC "${ZEPHYR_CURRENT_MODULE_DIR}" CACHE PATH "Path to the platform/ec repo.") -set(PLATFORM_EC_PROGRAM_DIR "${PLATFORM_EC}/zephyr/projects" CACHE PATH +set(PLATFORM_EC_PROGRAM_DIR "${PLATFORM_EC}/zephyr/program" CACHE PATH "Path to the root directory containing all Zephyr EC programs and projects.") if(NOT EXISTS "${PLATFORM_EC}/zephyr/module.yml") diff --git a/util/clangd_config.py b/util/clangd_config.py index 2553707c43..1e013b4159 100755 --- a/util/clangd_config.py +++ b/util/clangd_config.py @@ -32,7 +32,7 @@ def ec_fetch_boards(ec_root: Path) -> Optional[List[str]]: def zephyr_fetch_projects(ec_root: Path) -> Optional[List[str]]: """Return a list of Zephyr projects seen.""" - base = str(ec_root) + "/zephyr/projects/" + base = str(ec_root) + "/zephyr/program/" boards = glob.glob(base + "*") if boards is None: diff --git a/util/kconfig_check.py b/util/kconfig_check.py index e745b3aeca..f3d127175c 100755 --- a/util/kconfig_check.py +++ b/util/kconfig_check.py @@ -259,8 +259,8 @@ class KconfigCheck: dirs.remove("Kconfig") if "boards" in dirs: dirs.remove("boards") - if "projects" in dirs: - dirs.remove("projects") + if "program" in dirs: + dirs.remove("program") if "test" in dirs: dirs.remove("test") if "chip" in dirs: diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index 7f0776e2be..3a709d231e 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -534,7 +534,7 @@ def test(opts): # These are questionable, but they are essentially untestable zephyr_dir / "drivers/**", zephyr_dir / "include/drivers/**", - zephyr_dir / "projects/**", + zephyr_dir / "program/**", zephyr_dir / "shim/chip/**", zephyr_dir / "shim/chip/npcx/npcx_monitor/**", zephyr_dir / "shim/core/**", diff --git a/zephyr/program/.pylintrc b/zephyr/program/.pylintrc new file mode 100644 index 0000000000..8bdb6378e4 --- /dev/null +++ b/zephyr/program/.pylintrc @@ -0,0 +1,28 @@ +[BASIC] +additional-builtins= + here, + register_binman_project, + register_host_project, + register_host_test, + register_mchp_project, + register_npcx_project, + register_raw_project, +good-names=BUILD + +# cros lint doesn't inherit the pylintrc from the parent dir. +# These settings are copied from platform/ec/pylintrc +[MESSAGES CONTROL] + +disable= + bad-continuation, + bad-whitespace, + # These have nothing to do with black, they are just annoying + fixme, + too-many-arguments, + too-many-statements, + too-many-branches, + too-many-locals + +[format] + +string-quote=double diff --git a/zephyr/program/brya/BUILD.py b/zephyr/program/brya/BUILD.py new file mode 100644 index 0000000000..9991335ca7 --- /dev/null +++ b/zephyr/program/brya/BUILD.py @@ -0,0 +1,43 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for brya.""" + + +def register_npcx9_variant( + project_name, extra_dts_overlays=(), extra_kconfig_files=() +): + """Register a variant of a brya, even though this is not named as such.""" + return register_npcx_project( + project_name=project_name, + zephyr_board="npcx9m3f", + dts_overlays=[ + "adc.dts", + "battery.dts", + "fan.dts", + "gpio.dts", + "i2c.dts", + "interrupts.dts", + "keyboard.dts", + "motionsense.dts", + "pwm_leds.dts", + "temp_sensors.dts", + "usbc.dts", + # Project-specific DTS customization. + *extra_dts_overlays, + ], + kconfig_files=[ + # Common to all projects. + here / "prj.conf", + # Project-specific KConfig customization. + *extra_kconfig_files, + ], + ) + + +brya = register_npcx9_variant( + project_name="brya", + extra_dts_overlays=[here / "brya.dts"], + extra_kconfig_files=[here / "prj_brya.conf"], +) diff --git a/zephyr/program/brya/CMakeLists.txt b/zephyr/program/brya/CMakeLists.txt new file mode 100644 index 0000000000..11c1a8386f --- /dev/null +++ b/zephyr/program/brya/CMakeLists.txt @@ -0,0 +1,39 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(brya) + +set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/brya" CACHE PATH + "Path to the platform/ec board directory") +set(PLATFORM_EC_BASEBOARD "${PLATFORM_EC}/baseboard/brya" CACHE PATH + "Path to the platform/ec baseboard directory") + +# Include board specific header files +zephyr_include_directories( + include + "${PLATFORM_EC}/driver/tcpm" + "${PLATFORM_EC_BASEBOARD}" + "${PLATFORM_EC_BOARD}") + +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY + "${PLATFORM_EC_BASEBOARD}/battery_presence.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM + "${PLATFORM_EC_BASEBOARD}/cbi.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_KBLIGHT + "kblight_hooks.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY + "${PLATFORM_EC_BASEBOARD}/battery_presence.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY + "battery_present.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_POWER_DELIVERY + "${PLATFORM_EC_BASEBOARD}/usb_pd_policy.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "${PLATFORM_EC_BOARD}/usbc_config.c" + "${PLATFORM_EC_BOARD}/fw_config.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_MANAGER + "${PLATFORM_EC_BOARD}/charger.c" + "${PLATFORM_EC}/common/math_util.c") diff --git a/zephyr/program/brya/Kconfig b/zephyr/program/brya/Kconfig new file mode 100644 index 0000000000..4dd8e23443 --- /dev/null +++ b/zephyr/program/brya/Kconfig @@ -0,0 +1,11 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config BOARD_BRYA + bool "Google Brya Baseboard" + help + Build Google Brya reference board. The board uses the Nuvuton NPCX9 + chip as the EC. + +source "Kconfig.zephyr" diff --git a/zephyr/program/brya/adc.dts b/zephyr/program/brya/adc.dts new file mode 100644 index 0000000000..f3f0d1e064 --- /dev/null +++ b/zephyr/program/brya/adc.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ddr_soc: ddr_soc { + enum-name = "ADC_TEMP_SENSOR_1_DDR_SOC"; + io-channels = <&adc0 0>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; + io-channels = <&adc0 1>; + }; + adc_charger: charger { + enum-name = "ADC_TEMP_SENSOR_3_CHARGER"; + io-channels = <&adc0 6>; + }; + adc_wwan: wwan { + enum-name = "ADC_TEMP_SENSOR_4_WWAN"; + io-channels = <&adc0 7>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan6_gp34 + &adc0_chan7_gpe1>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/brya/battery.dts b/zephyr/program/brya/battery.dts new file mode 100644 index 0000000000..4844d88d92 --- /dev/null +++ b/zephyr/program/brya/battery.dts @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: batgqa05l22 { + compatible = "powertech,batgqa05l22", "battery-smart"; + }; + lgc_ac17a8m { + compatible = "lgc,ac17a8m", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/brya/battery_present.c b/zephyr/program/brya/battery_present.c new file mode 100644 index 0000000000..c487a01f36 --- /dev/null +++ b/zephyr/program/brya/battery_present.c @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include + +#include "battery.h" +#include "cbi.h" + +enum battery_present battery_hw_present(void) +{ + const struct gpio_dt_spec *batt_pres; + + if (get_board_id() == 1) + batt_pres = GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_batt_pres_odl); + else + batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl); + + /* The GPIO is low when the battery is physically present */ + return gpio_pin_get_dt(batt_pres) ? BP_NO : BP_YES; +} diff --git a/zephyr/program/brya/brya.dts b/zephyr/program/brya/brya.dts new file mode 100644 index 0000000000..4b0490afa9 --- /dev/null +++ b/zephyr/program/brya/brya.dts @@ -0,0 +1,24 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + model = "Google Brya Baseboard"; + + chosen { + cros,rtc = &mtc; + }; + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/brya/fan.dts b/zephyr/program/brya/fan.dts new file mode 100644 index 0000000000..aa6dcfde7d --- /dev/null +++ b/zephyr/program/brya/fan.dts @@ -0,0 +1,39 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm5 0 PWM_KHZ(1) PWM_POLARITY_NORMAL>; + rpm_min = <2200>; + rpm_start = <2200>; + rpm_max = <4200>; + tach = <&tach1>; + enable_gpio = <&gpio_en_pp5000_fan>; + }; + }; +}; + +/* Tachemeter for fan speed measurement */ +&tach1 { + status = "okay"; + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm5_gpb7 { + drive-open-drain; +}; + +&pwm5 { + status = "okay"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/brya/gpio.dts b/zephyr/program/brya/gpio.dts new file mode 100644 index 0000000000..6c6a2ac054 --- /dev/null +++ b/zephyr/program/brya/gpio.dts @@ -0,0 +1,341 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_wp_l: ec_wp_odl { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + charger_vap_otg_en { + gpios = <&gpio7 3 GPIO_OUTPUT_LOW>; + }; + gpio_ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioa 3 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + /* + * Same GPIO as gpio_ec_batt_pres_odl, + * but only enabled for board id 1. + */ + gpio_id_1_ec_kb_bl_en: id_1_ec_kb_bl_en { + gpios = <&gpioa 3 GPIO_OUTPUT_LOW>; + no-auto-init; + }; + gpio_id_1_ec_batt_pres_odl: id_1_ec_batt_pres_odl { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + ec_i2c_bat_scl { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + ec_i2c_bat_sda { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + gpio_ec_kb_bl_en_l: ec_kb_bl_en_l { + gpios = <&gpio8 6 GPIO_OUTPUT_HIGH>; + }; + ec_i2c_misc_scl_r { + gpios = <&gpiob 3 GPIO_INPUT>; + }; + ec_i2c_misc_sda_r { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + ec_i2c_sensor_scl { + gpios = <&gpiob 5 GPIO_INPUT>; + }; + ec_i2c_sensor_sda { + gpios = <&gpiob 4 GPIO_INPUT>; + }; + ec_i2c_usb_c0_c2_ppc_bc_scl { + gpios = <&gpio9 2 GPIO_INPUT>; + }; + ec_i2c_usb_c0_c2_ppc_bc_sda { + gpios = <&gpio9 1 GPIO_INPUT>; + }; + ec_i2c_usb_c0_c2_rt_scl { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + ec_i2c_usb_c0_c2_rt_sda { + gpios = <&gpiod 0 GPIO_INPUT>; + }; + ec_i2c_usb_c0_c2_tcpc_scl { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + ec_i2c_usb_c0_c2_tcpc_sda { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + ec_i2c_usb_c1_mix_scl { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + ec_i2c_usb_c1_mix_sda { + gpios = <&gpioe 3 GPIO_INPUT>; + }; + ec_i2c_usb_c1_tcpc_scl { + gpios = <&gpiof 3 GPIO_INPUT>; + }; + ec_i2c_usb_c1_tcpc_sda { + gpios = <&gpiof 2 GPIO_INPUT>; + }; + ec_chg_led_y_c1 { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_chg_led_b_c1 { + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + ec_gsc_packet_mode { + gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_accel_int_l: ec_accel_int_l { + gpios = <&gpio8 1 GPIO_INPUT>; + }; + gpio_ec_imu_int_l: gpio_ec_imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + gpio_ec_als_rgb_int_l: gpio_ec_als_rgb_int_l { + gpios = <&gpiod 4 GPIO_INPUT>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpio9 5 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_r_odl { + gpios = <&gpioc 0 GPIO_ODR_HIGH>; + }; + ec_pch_int_odl { + gpios = <&gpiob 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_pg_ec_dsw_pwrok: pg_ec_dsw_pwrok { + gpios = <&gpioc 7 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_DSW_PWROK"; + alias = "GPIO_SEQ_EC_DSW_PWROK"; + }; + en_s5_rails { + gpios = <&gpiob 6 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_S5_RAILS"; + alias = "GPIO_TEMP_SENSOR_POWER"; + }; + sys_rst_odl { + gpios = <&gpioc 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_SYS_RESET_L"; + }; + gpio_pg_ec_rsmrst_odl: pg_ec_rsmrst_odl { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_RSMRST_ODL"; + }; + ec_pch_rsmrst_odl { + gpios = <&gpioa 6 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_RSMRST_L"; + }; + gpio_pg_ec_all_sys_pwrgd: pg_ec_all_sys_pwrgd { + gpios = <&gpiof 4 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD"; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S0_L"; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S3_L"; + }; + vccst_pwrgd_od { + gpios = <&gpioa 4 GPIO_ODR_LOW>; + enum-name = "GPIO_VCCST_PWRGD_OD"; + }; + ec_prochot_odl { + gpios = <&gpio6 3 GPIO_ODR_HIGH>; + enum-name = "GPIO_CPU_PROCHOT"; + }; + ec_pch_pwr_btn_odl { + gpios = <&gpioc 1 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpiof 1 GPIO_INPUT>; + enum-name = "GPIO_SLP_SUS_L"; + }; + pch_pwrok { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_PWROK"; + }; + ec_pch_sys_pwrok { + gpios = <&gpio3 7 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EC_PCH_SYS_PWROK"; + }; + imvp9_vrrdy_od { + gpios = <&gpio4 3 GPIO_INPUT>; + enum-name = "GPIO_IMVP9_VRRDY_OD"; + }; + ec_edp_bl_en { + gpios = <&gpiod 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_prochot_in_l: ec_prochot_in_l { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_en_pp5000_fan: en_pp5000_fan { + gpios = <&gpio6 1 GPIO_OUTPUT_HIGH>; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpio9 7 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_usb_c0_c2_tcpc_int_odl: usb_c0_c2_tcpc_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_C2_TCPC_INT_ODL"; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpioa 2 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio6 2 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PPC_INT_ODL"; + }; + gpio_usb_c2_ppc_int_odl: usb_c2_ppc_int_odl { + gpios = <&gpio7 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C2_PPC_INT_ODL"; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { + gpios = <&gpio5 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_BC12_INT_ODL"; + }; + gpio_usb_c2_bc12_int_odl: usb_c2_bc12_int_odl { + gpios = <&gpio8 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C2_BC12_INT_ODL"; + }; + gpio_en_pp5000_usba_r: en_pp5000_usba_r { + gpios = <&gpiod 7 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PP5000_USBA_R"; + }; + usb_c1_rt_rst_r_odl { + gpios = <&gpio0 2 GPIO_ODR_LOW>; + enum-name = "GPIO_USB_C1_RT_RST_R_ODL"; + }; + usb_c1_rst_odl { + gpios = <&gpio9 6 GPIO_ODR_LOW>; + enum-name = "GPIO_USB_C1_RST_ODL"; + }; + usb_c0_c2_tcpc_rst_odl { + gpios = <&gpioa 7 GPIO_ODR_HIGH>; + enum-name = "GPIO_USB_C0_C2_TCPC_RST_ODL"; + }; + id_1_usb_c0_c2_tcpc_rst_odl { + gpios = <&gpio3 4 GPIO_ODR_LOW>; + }; + usb_c0_int_odl { + gpios = <&gpiob 1 GPIO_INPUT>; + }; + usb_c2_int_odl { + gpios = <&gpio4 1 GPIO_INPUT>; + }; + usb_c0_rt_int_odl: usb_c0_rt_int_odl { + gpios = <&gpiob 1 GPIO_INPUT>; + }; + usb_c2_rt_int_odl: usb_c2_rt_int_odl { + gpios = <&gpio4 1 GPIO_INPUT>; + }; + usb_c0_oc_odl { + gpios = <&ioex_port1 4 GPIO_ODR_HIGH>; + no-auto-init; + }; + usb_c0_frs_en: usb_c0_frs_en { + gpios = <&ioex_port1 6 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_FRS_EN"; + no-auto-init; + }; + usb_c0_rt_rst_odl: usb_c0_rt_rst_odl { + gpios = <&ioex_port1 7 GPIO_ODR_LOW>; + no-auto-init; + }; + usb_c2_rt_rst_odl: usb_c2_rt_rst_odl { + gpios = <&ioex_port2 2 GPIO_ODR_LOW>; + no-auto-init; + }; + usb_c1_oc_odl { + gpios = <&ioex_port2 3 GPIO_ODR_HIGH>; + no-auto-init; + }; + usb_c2_oc_odl { + gpios = <&ioex_port2 4 GPIO_ODR_HIGH>; + no-auto-init; + }; + usb_c2_frs_en: usb_c2_frs_en { + gpios = <&ioex_port2 6 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C2_FRS_EN"; + no-auto-init; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_pp5000_usba_r>; + }; +}; + +/* Power switch logic input pads */ +/* LID_OPEN_OD */ +&psl_in1_gpd2 { + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +/* ACOK_EC_OD */ +&psl_in2_gp00 { + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +/* GSC_EC_PWR_BTN_ODL */ +&psl_in3_gp01 { + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01>; +}; diff --git a/zephyr/program/brya/i2c.dts b/zephyr/program/brya/i2c.dts new file mode 100644 index 0000000000..7284d80870 --- /dev/null +++ b/zephyr/program/brya/i2c.dts @@ -0,0 +1,285 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + #include + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + i2c_sensor: sensor { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + tcpc0_2: tcpc0_2 { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_USB_C0_C2_TCPC"; + }; + tcpc1: tcpc1 { + i2c-port = <&i2c4_1>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + dynamic-speed; + }; + c0_c2_bc12: c0_c2_bc12 { + i2c-port = <&i2c2_0>; + enum-names = "I2C_PORT_USB_C0_C2_PPC", + "I2C_PORT_USB_C0_C2_BC12"; + }; + c1_bc12: c1_bc12 { + i2c-port = <&i2c6_1>; + enum-names = "I2C_PORT_USB_C1_PPC", + "I2C_PORT_USB_C1_BC12"; + dynamic-speed; + }; + retimer0_2: retimer0_2 { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_C0_C2_MUX"; + }; + battery { + i2c-port = <&i2c5_0>; + enum-names = "I2C_PORT_BATTERY"; + }; + i2c_charger: charger { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_CHARGER", + "I2C_PORT_EEPROM", + "I2C_PORT_MP2964"; + }; + }; +}; + +&i2c0_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + tcpc_port0: nct38xx@70 { + compatible = "nuvoton,nct38xx"; + reg = <0x70>; + gpio-dev = <&nct3808_0_P1>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>; + }; + + nct3808_0_P1: nct3808_0_P1@70 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x70>; + label = "NCT3808_0_P1"; + + ioex_port1: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3808_0_P1_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xdc>; + pinmux_mask = <0xff>; + }; + }; + + tcpc_port2: nct38xx@74 { + compatible = "nuvoton,nct38xx"; + reg = <0x74>; + gpio-dev = <&nct3808_0_P2>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct3808_0_P2: nct3808_0_P2@74 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x74>; + label = "NCT3808_0_P2"; + + ioex_port2: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3808_0_P2_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xdc>; + pinmux_mask = <0xff>; + }; + }; + + nct3808_alert_1 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpioe 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + nct38xx-dev = <&nct3808_0_P1 &nct3808_0_P2>; + label = "NCT3808_ALERT_1"; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; + + ppc_port0: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&usb_c0_frs_en>; + }; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + ppc_port2: syv682x@42 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x42>; + frs_en_gpio = <&usb_c2_frs_en>; + }; + + bc12_port2: pi3usb9201@5d { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5d>; + irq = <&int_usb_c2_bc12>; + }; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; + + usb_c0_bb_retimer: jhl8040r-c0@56 { + compatible = "intel,jhl8040r"; + reg = <0x56>; + int-pin = <&usb_c0_rt_int_odl>; + reset-pin = <&usb_c0_rt_rst_odl>; + }; + + usb_c2_bb_retimer: jhl8040r-c2@57 { + compatible = "intel,jhl8040r"; + reg = <0x57>; + int-pin = <&usb_c2_rt_int_odl>; + reset-pin = <&usb_c2_rt_rst_odl>; + }; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c4_1 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; + pinctrl-names = "default"; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS)>; + }; +}; + +&i2c_ctrl4 { + status = "okay"; +}; + +&i2c5_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c6_1 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; + pinctrl-names = "default"; + + ppc_port1: nx20p348x@72 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x72>; + }; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c1_bc12>; + }; +}; + +&i2c_ctrl6 { + status = "okay"; +}; + +&i2c7_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; + + pmic_mp2964: pmic_mp2964@20 { + compatible = "mps,mp2964"; + reg = <0x20>; + label = "I2C_ADDR_MP2964_FLAGS"; + }; + + charger: bq25710@9 { + compatible = "ti,bq25710"; + status = "okay"; + reg = <0x9>; + }; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/brya/interrupts.dts b/zephyr/program/brya/interrupts.dts new file mode 100644 index 0000000000..1adca3e035 --- /dev/null +++ b/zephyr/program/brya/interrupts.dts @@ -0,0 +1,150 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_wp: wp { + irq-pin = <&gpio_ec_wp_l>; + flags = ; + handler = "switch_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_ec_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_ec_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_accel: accel { + irq-pin = <&gpio_ec_accel_int_l>; + flags = ; + handler = "lis2dw12_interrupt"; + }; + int_imu: imu { + irq-pin = <&gpio_ec_imu_int_l>; + flags = ; + handler = "lsm6dso_interrupt"; + }; + int_slp_s0: slp_s0 { + irq-pin = <&gpio_slp_s0_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_slp_s3: slp_s3 { + irq-pin = <&gpio_slp_s3_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_slp_sus: slp_sus { + irq-pin = <&gpio_slp_sus_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_pg_dsw_pwrok: pg_dsw_pwrok { + irq-pin = <&gpio_pg_ec_dsw_pwrok>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_pg_rsmrst_odl: pg_rsmrst_odl { + irq-pin = <&gpio_pg_ec_rsmrst_odl>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_pg_all_sys_pwrgd: pg_all_sys_pwrgd { + irq-pin = <&gpio_pg_ec_all_sys_pwrgd>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_als_rgb: als_rgb { + irq-pin = <&gpio_ec_als_rgb_int_l>; + flags = ; + handler = "tcs3400_interrupt"; + }; + int_prochot: prochot { + irq-pin = <&gpio_ec_prochot_in_l>; + flags = ; + handler = "throttle_ap_prochot_input_interrupt"; + }; + int_usb_c0_c2_tcpc: usb_c0_c2_tcpc { + irq-pin = <&gpio_usb_c0_c2_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-pin = <&gpio_usb_c1_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&gpio_usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_ppc: usb_c1_ppc { + irq-pin = <&gpio_usb_c1_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c2_ppc: usb_c2_ppc { + irq-pin = <&gpio_usb_c2_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c2_bc12: usb_c2_bc12 { + irq-pin = <&gpio_usb_c2_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c0_rt: usb_c0_rt { + irq-pin = <&usb_c0_rt_int_odl>; + flags = ; + handler = "retimer_interrupt"; + }; + int_usb_c2_rt: usb_c2_rt { + irq-pin = <&usb_c2_rt_int_odl>; + flags = ; + handler = "retimer_interrupt"; + }; + }; +}; diff --git a/zephyr/program/brya/kblight_hooks.c b/zephyr/program/brya/kblight_hooks.c new file mode 100644 index 0000000000..d6d795f28e --- /dev/null +++ b/zephyr/program/brya/kblight_hooks.c @@ -0,0 +1,67 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include +#include "cbi.h" +#include "hooks.h" + +/* Enable/Disable keyboard backlight gpio */ +static inline void kbd_backlight_enable(bool enable) +{ + if (get_board_id() == 1) + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_kb_bl_en), + enable); + else + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_kb_bl_en_l), + !enable); +} + +static void board_backlight_handler(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + bool enable; + + switch (data.event) { + default: + return; + + case AP_POWER_RESUME: + /* Called on AP S3 -> S0 transition */ + enable = true; + break; + + case AP_POWER_SUSPEND: + /* Called on AP S0 -> S3 transition */ + enable = false; + break; + } + kbd_backlight_enable(enable); +} + +/* + * Explicitly apply the board ID 1 *gpio.inc settings to pins that + * were reassigned on current boards. + */ +static void set_board_id_1_gpios(void) +{ + static struct ap_power_ev_callback cb; + + /* + * Add a callback for suspend/resume to + * control the keyboard backlight. + */ + ap_power_ev_init_callback(&cb, board_backlight_handler, + AP_POWER_RESUME | AP_POWER_SUSPEND); + ap_power_ev_add_callback(&cb); + + if (get_board_id() != 1) + return; + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_kb_bl_en), + GPIO_OUTPUT_LOW); +} +DECLARE_HOOK(HOOK_INIT, set_board_id_1_gpios, HOOK_PRIO_FIRST); diff --git a/zephyr/program/brya/keyboard.dts b/zephyr/program/brya/keyboard.dts new file mode 100644 index 0000000000..91fad2db92 --- /dev/null +++ b/zephyr/program/brya/keyboard.dts @@ -0,0 +1,47 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm3 0 PWM_HZ(2400) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm3 { + status = "okay"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/brya/motionsense.dts b/zephyr/program/brya/motionsense.dts new file mode 100644 index 0000000000..08994e30cc --- /dev/null +++ b/zephyr/program/brya/motionsense.dts @@ -0,0 +1,257 @@ +/* + * Copyright 2022 The ChromiumOS Authors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + lsm6dso-int = &base_accel; + lis2dw12-int = &lid_accel; + tcs3400-int = &als_clear; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + mutex_lis2dw12: lis2dw12-mutex { + }; + + mutex_lsm6dso: lsm6dso-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + lsm6dso_accel_data: lsm6dso-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lsm6dso_gyro_data: lsm6dso-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + tcs_clear_data: tcs3400-clear-drv-data { + compatible = "cros-ec,drvdata-tcs3400-clear"; + status = "okay"; + + als-drv-data { + compatible = "cros-ec,accelgyro-als-drv-data"; + als-cal { + scale = <1>; + uscale = <0>; + offset = <0>; + als-channel-scale { + compatible = + "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + + tcs_rgb_data: tcs3400-rgb-drv-data { + compatible = "cros-ec,drvdata-tcs3400-rgb"; + status = "okay"; + + /* node for rgb_calibration_t defined in accelgyro.h */ + rgb_calibration { + compatible = + "cros-ec,accelgyro-rgb-calibration"; + + irt = <1>; + + rgb-cal-x { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = + "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-y { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = + "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-z { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = + "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&mutex_lis2dw12>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,lsm6dso-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_lsm6dso>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <4>; + drv-data = <&lsm6dso_accel_data>; + i2c-spi-addr-flags = "LSM6DSO_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(13000 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,lsm6dso-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_lsm6dso>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dso_gyro_data>; + i2c-spi-addr-flags = "LSM6DSO_ADDR0_FLAGS"; + }; + + als_clear: base-als-clear { + compatible = "cros-ec,tcs3400-clear"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + port = <&i2c_sensor>; + default-range = <0x10000>; + drv-data = <&tcs_clear_data>; + i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + /* Run ALS sensor in S0 */ + odr = <1000>; + }; + }; + }; + + base-als-rgb { + compatible = "cros-ec,tcs3400-rgb"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + default-range = <0x10000>; /* scale = 1x, uscale = 0 */ + drv-data = <&tcs_rgb_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* list of entries for motion_als_sensors */ + als-sensors = <&als_clear>; + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu &int_als_rgb &int_accel>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel &als_clear>; + }; +}; diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf new file mode 100644 index 0000000000..422f862809 --- /dev/null +++ b/zephyr/program/brya/prj.conf @@ -0,0 +1,200 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_LTO=y +CONFIG_CROS_FLASH_NPCX=y +CONFIG_CROS_SYSTEM_NPCX=y +CONFIG_PLATFORM_EC_VBOOT_EFS2=y +CONFIG_PLATFORM_EC_VBOOT_HASH=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y + +CONFIG_PLATFORM_EC_ADC_CHANNELS_RUNTIME_CONFIG=y + +CONFIG_KERNEL_SHELL=y + +# SoC configuration +CONFIG_AP=y +CONFIG_AP_X86_INTEL_ADL=y +CONFIG_FPU=y +CONFIG_ARM_MPU=y + +# CBI +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_CBI_EEPROM=y +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y + +# eSPI +CONFIG_ESPI=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150 + +# I2C +CONFIG_I2C=y + +# Power Sequencing +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=y +CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y +CONFIG_PLATFORM_EC_POWERSEQ_S4=y +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y +CONFIG_PLATFORM_EC_THROTTLE_AP=y + +# Host command +CONFIG_PLATFORM_EC_HOSTCMD=y +CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=y + +# Console command +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y + +# Sensors +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_ALS=y +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y +CONFIG_PLATFORM_EC_ALS_TCS3400=y + +# Fan +CONFIG_TACH_NPCX=y + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y +CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y + +# MKBP event +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y + +# PMIC +CONFIG_PLATFORM_EC_PMIC=y +CONFIG_PLATFORM_EC_MP2964=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y +CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_CMD_BUTTON=n +CONFIG_CROS_KB_RAW_NPCX=y + +CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y + +# USB-C and charging +CONFIG_PLATFORM_EC_CHARGER_BQ25720=y +CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y +CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70 +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=3 +CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC=1 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 +CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_PID=0x504F +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y +CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y +CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_MUX_TASK=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2 +CONFIG_PLATFORM_EC_USB_PD_ALT_MODE_UFP=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_PPC=y +CONFIG_PLATFORM_EC_USB_PD_REV30=y +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y +CONFIG_PLATFORM_EC_USB_PD_USB4=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1715=n +CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=n +CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y +CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT=y +CONFIG_PLATFORM_EC_USBA=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP=n +CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y +CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y +CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y +CONFIG_PLATFORM_EC_USB_PD_PORT_2_SHARED=y + +CONFIG_SYSCON=y + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=y +CONFIG_PLATFORM_EC_LED_PWM=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n +CONFIG_PLATFORM_EC_LED_PWM_NEAR_FULL_COLOR=4 +CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR=4 +CONFIG_PLATFORM_EC_LED_PWM_SOC_SUSPEND_COLOR=4 +CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR=5 + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +#IOEX +CONFIG_GPIO_NCT38XX=y + +# TODO(b/188605676): bring these features up +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n + +# Power Sequencing +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n +CONFIG_CHIPSET_ALDERLAKE_SLG4BD44540=y +CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=n +CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y +# Treat 2nd reset from H1 as Power-On +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y +CONFIG_PLATFORM_EC_THROTTLE_AP=y + +# RTC +CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/program/brya/prj_brya.conf b/zephyr/program/brya/prj_brya.conf new file mode 100644 index 0000000000..5aaf86a8c9 --- /dev/null +++ b/zephyr/program/brya/prj_brya.conf @@ -0,0 +1,6 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# BRYA-NPCX9 reference-board-specific Kconfig settings. +CONFIG_BOARD_BRYA=y diff --git a/zephyr/program/brya/pwm_leds.dts b/zephyr/program/brya/pwm_leds.dts new file mode 100644 index 0000000000..4321b4bd34 --- /dev/null +++ b/zephyr/program/brya/pwm_leds.dts @@ -0,0 +1,79 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm2 0 PWM_HZ(4800) PWM_POLARITY_INVERTED + &pwm0 0 PWM_HZ(4800) PWM_POLARITY_INVERTED>; + }; + pwm_led1: pwm_led_1 { + pwms = <&pwm1 0 PWM_HZ(4800) PWM_POLARITY_INVERTED + &pwm7 0 PWM_HZ(4800) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0 &pwm_led1>; + + /**/ + color-map-red = <0 0>; + color-map-green = <0 0>; + color-map-blue = <0 0>; + color-map-yellow = <0 0>; + color-map-white = <0 50>; + color-map-amber = <50 0>; + + brightness-range = <0 0 0 0 100 100>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_LEFT_LED"; + }; + + pwm_led_1@1 { + reg = <1>; + ec-led-name = "EC_LED_ID_RIGHT_LED"; + }; + }; +}; + +/* LED2 */ +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* LED3 */ +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* LED1 */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* LED4 */ +&pwm7 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm7_gp60>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/brya/temp_sensors.dts b/zephyr/program/brya/temp_sensors.dts new file mode 100644 index 0000000000..ae436a2c6b --- /dev/null +++ b/zephyr/program/brya/temp_sensors.dts @@ -0,0 +1,75 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + temp_ddr_soc: ddr_soc { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_ddr_soc>; + }; + + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_ambient>; + }; + + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_charger>; + }; + + temp_wwan: wwan { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_wwan>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ddr_soc { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + sensor = <&temp_ddr_soc>; + }; + + ambient { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + sensor = <&temp_ambient>; + }; + + charger { + temp_fan_off = <35>; + temp_fan_max = <65>; + temp_host_high = <105>; + temp_host_halt = <120>; + temp_host_release_high = <90>; + sensor = <&temp_charger>; + }; + + wwan { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <130>; + temp_host_halt = <130>; + temp_host_release_high = <100>; + sensor = <&temp_wwan>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_4050B { + status = "okay"; +}; diff --git a/zephyr/program/brya/usbc.dts b/zephyr/program/brya/usbc.dts new file mode 100644 index 0000000000..1be9ac94ac --- /dev/null +++ b/zephyr/program/brya/usbc.dts @@ -0,0 +1,69 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c0_bb_retimer + &virtual_mux_c0>; + }; + ppc = <&ppc_port0>; + }; + port0-muxes { + virtual_mux_c0: virtual-mux-c0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_c1 &tcpci_mux_c1>; + }; + ppc = <&ppc_port1>; + }; + port1-muxes { + tcpci_mux_c1: tcpci-mux-c1 { + compatible = "cros-ec,usbc-mux-tcpci"; + hpd-update = "ps8xxx_tcpc_update_hpd_status"; + }; + virtual_mux_c1: virtual-mux-c1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port2@2 { + compatible = "named-usbc-port"; + reg = <2>; + bc12 = <&bc12_port2>; + tcpc = <&tcpc_port2>; + usb-mux-chain-2 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c2_bb_retimer + &virtual_mux_c2>; + }; + ppc = <&ppc_port2>; + }; + port2-muxes { + virtual_mux_c2: virtual-mux-c2 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/BUILD.py b/zephyr/program/corsola/BUILD.py new file mode 100644 index 0000000000..91bd8ab062 --- /dev/null +++ b/zephyr/program/corsola/BUILD.py @@ -0,0 +1,142 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for corsola.""" + +# Default chip is it81202bx, some variants will use NPCX9X. + + +def register_corsola_project( + project_name, + chip="it81202bx", + extra_dts_overlays=(), + extra_kconfig_files=(), +): + """Register a variant of corsola.""" + register_func = register_binman_project + if chip.startswith("npcx"): + register_func = register_npcx_project + + register_func( + project_name=project_name, + zephyr_board=chip, + dts_overlays=[ + here / "common.dts", + here / "power_signal.dts", + here / "usba.dts", + *extra_dts_overlays, + ], + kconfig_files=[here / "prj.conf", *extra_kconfig_files], + ) + + +register_corsola_project( + "krabby", + extra_dts_overlays=[ + here / "adc_krabby.dts", + here / "battery_krabby.dts", + here / "gpio_krabby.dts", + here / "keyboard_krabby.dts", + here / "i2c_krabby.dts", + here / "interrupts_krabby.dts", + here / "led_krabby.dts", + here / "motionsense_krabby.dts", + here / "usbc_krabby.dts", + ], + extra_kconfig_files=[ + here / "prj_it81202_base.conf", + here / "prj_krabby.conf", + ], +) + +register_corsola_project( + project_name="kingler", + chip="npcx9m3f", + extra_dts_overlays=[ + here / "adc_kingler.dts", + here / "battery_kingler.dts", + here / "host_interface_npcx.dts", + here / "i2c_kingler.dts", + here / "interrupts_kingler.dts", + here / "gpio_kingler.dts", + here / "npcx_keyboard.dts", + here / "led_kingler.dts", + here / "motionsense_kingler.dts", + here / "usbc_kingler.dts", + here / "default_gpio_pinctrl_kingler.dts", + ], + extra_kconfig_files=[ + here / "prj_npcx993_base.conf", + here / "prj_kingler.conf", + ], +) + +register_corsola_project( + project_name="steelix", + chip="npcx9m3f", + extra_dts_overlays=[ + here / "adc_kingler.dts", + here / "battery_steelix.dts", + here / "host_interface_npcx.dts", + here / "i2c_kingler.dts", + here / "interrupts_kingler.dts", + here / "interrupts_steelix.dts", + here / "cbi_steelix.dts", + here / "gpio_steelix.dts", + here / "npcx_keyboard.dts", + here / "keyboard_steelix.dts", + here / "led_steelix.dts", + here / "motionsense_kingler.dts", + here / "motionsense_steelix.dts", + here / "usba_steelix.dts", + here / "usbc_kingler.dts", + here / "default_gpio_pinctrl_kingler.dts", + ], + extra_kconfig_files=[ + here / "prj_npcx993_base.conf", + here / "prj_steelix.conf", + ], +) + + +register_corsola_project( + "tentacruel", + extra_dts_overlays=[ + here / "adc_tentacruel.dts", + here / "battery_tentacruel.dts", + here / "cbi_tentacruel.dts", + here / "gpio_tentacruel.dts", + here / "keyboard_krabby.dts", + here / "i2c_tentacruel.dts", + here / "interrupts_tentacruel.dts", + here / "led_tentacruel.dts", + here / "motionsense_tentacruel.dts", + here / "usbc_tentacruel.dts", + here / "thermistor_tentacruel.dts", + ], + extra_kconfig_files=[ + here / "prj_it81202_base.conf", + here / "prj_tentacruel.conf", + ], +) + +register_corsola_project( + "magikarp", + extra_dts_overlays=[ + here / "adc_magikarp.dts", + here / "battery_magikarp.dts", + here / "cbi_magikarp.dts", + here / "gpio_magikarp.dts", + here / "keyboard_krabby.dts", + here / "i2c_magikarp.dts", + here / "interrupts_magikarp.dts", + here / "led_magikarp.dts", + here / "motionsense_magikarp.dts", + here / "usbc_magikarp.dts", + ], + extra_kconfig_files=[ + here / "prj_it81202_base.conf", + here / "prj_magikarp.conf", + ], +) diff --git a/zephyr/program/corsola/CMakeLists.txt b/zephyr/program/corsola/CMakeLists.txt new file mode 100644 index 0000000000..fa899a0e77 --- /dev/null +++ b/zephyr/program/corsola/CMakeLists.txt @@ -0,0 +1,81 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") + +cros_ec_library_include_directories(include) + +# Include selected EC source from the baseboard +zephyr_library_sources( + "src/board.c" + "src/board_chipset.c" + "src/hibernate.c" +) + +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usbc_config.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy.c") +zephyr_library_sources_ifdef(CONFIG_VARIANT_CORSOLA_DB_DETECTION + "src/variant_db_detection.c") + +if(DEFINED CONFIG_BOARD_KRABBY) + project(krabby) + zephyr_library_sources("src/krabby/hooks.c" + "src/krabby/charger_workaround.c" + "src/krabby/ppc_krabby.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usb_pd_policy.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "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_LED_COMMON + "src/kingler/led.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/kingler/usb_pd_policy.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/kingler/usbc_config.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG + "src/kingler/button.c") +elseif(DEFINED CONFIG_BOARD_STEELIX) + project(steelix) + zephyr_library_sources("src/kingler/board_steelix.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON + "src/kingler/led_steelix.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/kingler/usb_pd_policy.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/kingler/usbc_config.c") + +elseif(DEFINED CONFIG_BOARD_TENTACRUEL) + project(tentacruel) + zephyr_library_sources("src/krabby/hooks.c" + "src/krabby/charger_workaround.c" + "src/krabby/sensor_tentacruel.c" + "src/krabby/temp_tentacruel.c" + "src/krabby/ppc_tentacruel.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usb_pd_policy.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usbc_config.c") + +elseif(DEFINED CONFIG_BOARD_MAGIKARP) + project(magikarp) + zephyr_library_sources("src/krabby/hooks.c" + "src/krabby/sensor_magikarp.c" + "src/krabby/ppc_magikarp.c" + "src/krabby/keyboard_magikarp.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usb_pd_policy.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usbc_config.c") + +endif() + diff --git a/zephyr/program/corsola/Kconfig b/zephyr/program/corsola/Kconfig new file mode 100644 index 0000000000..4f66601c20 --- /dev/null +++ b/zephyr/program/corsola/Kconfig @@ -0,0 +1,52 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config BOARD_KRABBY + bool "Google Krabby Board" + help + Build Google Krabby reference board. Krabby has MediaTek MT8186 SoC + with ITE it81202-bx EC. + +config BOARD_KINGLER + bool "Google Kingler Board" + help + Build Google Kingler reference board. Krabby has MediaTek MT8186 SoC + with NPCX993FA0BX EC. + +config BOARD_STEELIX + bool "Google Steelix Board" + help + Build Google Steelix variant board. Steelix is a variant of Kingler + and has MediaTek MT8186 SoC with NPCX993FA0BX EC. + +config BOARD_TENTACRUEL + bool "Google Tentacruel Board" + help + Build Google Tentacruel variant board. Tentacruel is a variant of Krabby + and has MediaTek MT8186 SoC with ITE it81202-bx EC. + +config BOARD_MAGIKARP + bool "Google Magikarp Board" + help + Build Google Magikarp variant board. Magikarp is a variant of Krabby + and has MediaTek MT8186 SoC with ITE it81202-bx EC. + +config VARIANT_CORSOLA_DB_DETECTION + bool "Corsola Platform Runtime Daughter Board Detection" + depends on PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG + depends on PLATFORM_EC_USB_MUX_RUNTIME_CONFIG + help + Daughter board detection for Type-C subboard or HDMI subboard. This + includes pin configuration and driver loading. + default y + +config VARIANT_CORSOLA_USBA + bool "Corsola Platform USB-A support" + help + Support Corsola USB-A related functions. Enable this function if + it has USB-A ports. + depends on PLATFORM_EC_USBC + default y + +source "Kconfig.zephyr" diff --git a/zephyr/program/corsola/adc_kingler.dts b/zephyr/program/corsola/adc_kingler.dts new file mode 100644 index 0000000000..7b69abe48a --- /dev/null +++ b/zephyr/program/corsola/adc_kingler.dts @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * Kingler and Steelix use the same dts, take care of this when modify it. + */ + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_charger_pmon_r { + enum-name = "ADC_PSYS"; + io-channels = <&adc0 0>; + /* + * ISL9238C PSYS output is 1.44 uA/W over 33K resistor. + */ + mul = <21043>; + }; + adc_ec_id0 { + enum-name = "ADC_ID_0"; + io-channels = <&adc0 1>; + }; + adc_ec_id1 { + enum-name = "ADC_ID_1"; + io-channels = <&adc0 2>; + }; + adc_charger_amon_r { + enum-name = "ADC_AMON_BMON"; + io-channels = <&adc0 3>; + mul = <1000>; + div = <18>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/adc_krabby.dts b/zephyr/program/corsola/adc_krabby.dts new file mode 100644 index 0000000000..be65e9eea7 --- /dev/null +++ b/zephyr/program/corsola/adc_krabby.dts @@ -0,0 +1,38 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch1_gpi1_default + &adc0_ch2_gpi2_default + &adc0_ch7_gpi7_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/adc_magikarp.dts b/zephyr/program/corsola/adc_magikarp.dts new file mode 100644 index 0000000000..358af6f0f4 --- /dev/null +++ b/zephyr/program/corsola/adc_magikarp.dts @@ -0,0 +1,63 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; + io-channels = <&adc0 5>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch1_gpi1_default + &adc0_ch2_gpi2_default + &adc0_ch5_gpi5_default + &adc0_ch7_gpi7_default>; + pinctrl-names = "default"; +}; + +/ { + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; + adc = <&adc_ambient>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ambient { + sensor = <&temp_ambient>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_NCP15WB { + status = "okay"; +}; diff --git a/zephyr/program/corsola/adc_tentacruel.dts b/zephyr/program/corsola/adc_tentacruel.dts new file mode 100644 index 0000000000..7ab6f8817b --- /dev/null +++ b/zephyr/program/corsola/adc_tentacruel.dts @@ -0,0 +1,72 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; + io-channels = <&adc0 5>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch1_gpi1_default + &adc0_ch2_gpi2_default + &adc0_ch5_gpi5_default + &adc0_ch7_gpi7_default>; + pinctrl-names = "default"; +}; + +/ { + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; + adc = <&adc_ambient>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ambient { + temp_host_high = <56>; + temp_host_halt = <80>; + temp_host_release_high = <42>; + sensor = <&temp_ambient>; + }; + temp_charger: charger { + temp_host_high = <68>; + temp_host_halt = <90>; + temp_host_release_high = <59>; + sensor = <&charger>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_NCP15WB { + status = "okay"; +}; diff --git a/zephyr/program/corsola/battery_kingler.dts b/zephyr/program/corsola/battery_kingler.dts new file mode 100644 index 0000000000..b01fb8a46d --- /dev/null +++ b/zephyr/program/corsola/battery_kingler.dts @@ -0,0 +1,15 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: smp_l20m3pg2 { + compatible = "smp,l20m3pg2", "battery-smart"; + }; + lgc_l20l3pg2 { + compatible = "lgc,l20l3pg2", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/battery_krabby.dts b/zephyr/program/corsola/battery_krabby.dts new file mode 100644 index 0000000000..ce41859182 --- /dev/null +++ b/zephyr/program/corsola/battery_krabby.dts @@ -0,0 +1,12 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: c235 { + compatible = "celxpert,c235-41", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/battery_magikarp.dts b/zephyr/program/corsola/battery_magikarp.dts new file mode 100644 index 0000000000..bbdd6ac0c5 --- /dev/null +++ b/zephyr/program/corsola/battery_magikarp.dts @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: smp_c31n1915 { + compatible = "smp,c31n1915", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/battery_steelix.dts b/zephyr/program/corsola/battery_steelix.dts new file mode 100644 index 0000000000..594c83478c --- /dev/null +++ b/zephyr/program/corsola/battery_steelix.dts @@ -0,0 +1,24 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: byd_l22b3pg0 { + compatible = "byd,l22b3pg0", "battery-smart"; + }; + celxpert_l22c3pg0 { + compatible = "celxpert,l22c3pg0", "battery-smart"; + }; + cosmx_l22x3pg0 { + compatible = "cosmx,l22x3pg0", "battery-smart"; + }; + smp_l22m3pg0 { + compatible = "smp,l22m3pg0", "battery-smart"; + }; + sunwoda_l22d3pg0 { + compatible = "sunwoda,l22d3pg0", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/battery_tentacruel.dts b/zephyr/program/corsola/battery_tentacruel.dts new file mode 100644 index 0000000000..f116c20a51 --- /dev/null +++ b/zephyr/program/corsola/battery_tentacruel.dts @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: dynapack_c140254 { + compatible = "dynapack,c140254", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/cbi_magikarp.dts b/zephyr/program/corsola/cbi_magikarp.dts new file mode 100644 index 0000000000..5eac6b82c6 --- /dev/null +++ b/zephyr/program/corsola/cbi_magikarp.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* magikarp-specific fw_config fields. */ + magikarp-fw-config { + compatible = "cros-ec,cbi-fw-config"; + /* + * FW_CONFIG field to describe mainboard orientation in chassis. + */ + base-gyro { + enum-name = "FW_BASE_GYRO"; + start = <0>; + size = <2>; + + None { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_NONE"; + value = <0>; + }; + icm42607 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_ICM42607"; + value = <1>; + default; + }; + bmi323 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_BMI323"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/cbi_steelix.dts b/zephyr/program/corsola/cbi_steelix.dts new file mode 100644 index 0000000000..f4918b1577 --- /dev/null +++ b/zephyr/program/corsola/cbi_steelix.dts @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + steelix-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to indicate the device is clamshell + * or convertible. + */ + form_factor { + enum-name = "FORM_FACTOR"; + start = <13>; + size = <3>; + + convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CONVERTIBLE"; + value = <1>; + }; + clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CLAMSHELL"; + value = <0>; + }; + }; + + /* FW_CONFIG field to indicate which DB is attached. */ + db_config: db { + enum-name = "DB"; + start = <0>; + size = <4>; + + sub-board-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_NONE"; + value = <0>; + }; + sub-board-2 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_USBA_HDMI"; + value = <1>; + }; + sub-board-3 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_USBA_HDMI_LTE"; + value = <2>; + }; + }; + }; + + /* Steelix-specific ssfc fields. */ + steelix-ssfc { + compatible = "named-cbi-ssfc"; + + /* SSFC field to identify BASE motion sensor. */ + base-sensor { + enum-name = "BASE_SENSOR"; + size = <3>; + + base_sensor_0: bmi323 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + base_sensor_1: lsm6dsm { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + + /* SSFC field to identify LID motion sensor. */ + lid-sensor { + enum-name = "LID_SENSOR"; + size = <3>; + + lid_sensor_0: bma422 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + lid_sensor_1: lis2dw12 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/cbi_tentacruel.dts b/zephyr/program/corsola/cbi_tentacruel.dts new file mode 100644 index 0000000000..2cd4594417 --- /dev/null +++ b/zephyr/program/corsola/cbi_tentacruel.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* tentacruel-specific fw_config fields. */ + tentacruel-fw-config { + compatible = "cros-ec,cbi-fw-config"; + /* + * FW_CONFIG field to describe mainboard orientation in chassis. + */ + base-gyro { + enum-name = "FW_BASE_GYRO"; + start = <8>; + size = <2>; + + None { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_NONE"; + value = <0>; + }; + icm42607 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_ICM42607"; + value = <1>; + default; + }; + bmi323 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_BMI323"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/common.dts b/zephyr/program/corsola/common.dts new file mode 100644 index 0000000000..001dcc7ce3 --- /dev/null +++ b/zephyr/program/corsola/common.dts @@ -0,0 +1,25 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + ec-mkbp-host-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <( + HOST_EVENT_AC_CONNECTED | + HOST_EVENT_AC_DISCONNECTED | + HOST_EVENT_LID_OPEN | + HOST_EVENT_POWER_BUTTON | + HOST_EVENT_HANG_DETECT | + HOST_EVENT_MODE_CHANGE)>; + }; + + ec-mkbp-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | + MKBP_EVENT_HOST_EVENT)>; + }; +}; diff --git a/zephyr/program/corsola/default_gpio_pinctrl_kingler.dts b/zephyr/program/corsola/default_gpio_pinctrl_kingler.dts new file mode 100644 index 0000000000..604658a145 --- /dev/null +++ b/zephyr/program/corsola/default_gpio_pinctrl_kingler.dts @@ -0,0 +1,44 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ +&{/def-io-conf-list} { + pinmux = <&alt0_gpio_no_spip + &alt0_gpio_no_fpip + &alt1_no_pwrgd + &alt1_no_lpc_espi + &alta_no_peci_en + &altd_npsl_in1_sl + &altd_npsl_in2_sl + &altd_psl_in3_sl + &altd_psl_in4_sl + &alt7_no_ksi0_sl + &alt7_no_ksi1_sl + &alt7_no_ksi2_sl + &alt7_no_ksi3_sl + &alt7_no_ksi4_sl + &alt7_no_ksi5_sl + &alt7_no_ksi6_sl + &alt7_no_ksi7_sl + &alt8_no_kso00_sl + &alt8_no_kso01_sl + &alt8_no_kso02_sl + &alt8_no_kso03_sl + &alt8_no_kso04_sl + &alt8_no_kso05_sl + &alt8_no_kso06_sl + &alt8_no_kso07_sl + &alt9_no_kso08_sl + &alt9_no_kso09_sl + &alt9_no_kso10_sl + &alt9_no_kso11_sl + &alt9_no_kso12_sl + &alt9_no_kso13_sl + &alt9_no_kso14_sl + &alt9_no_kso15_sl + &alta_no_kso16_sl + &alta_no_kso17_sl + &altg_psl_gpo_sl>; +}; diff --git a/zephyr/program/corsola/gpio_kingler.dts b/zephyr/program/corsola/gpio_kingler.dts new file mode 100644 index 0000000000..9a827a06dd --- /dev/null +++ b/zephyr/program/corsola/gpio_kingler.dts @@ -0,0 +1,249 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + /* + * In npcx9 series, gpio46, gpio47, and the whole gpio5 port + * belong to VHIF power well. On kingler, it is connencted to + * 1.8V. + */ + base_imu_int_l: base_imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + spi_ap_clk_ec { + gpios = <&gpio5 5 GPIO_INPUT>; + }; + spi_ap_cs_ec_l { + gpios = <&gpio5 3 GPIO_INPUT>; + }; + spi_ap_do_ec_di { + gpios = <&gpio4 6 GPIO_INPUT>; + }; + spi_ap_di_ec_do { + gpios = <&gpio4 7 GPIO_INPUT>; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; + }; + en_ec_id_odl { + gpios = <&gpio7 6 GPIO_ODR_HIGH>; + }; + sys_rst_odl { + gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + ec_i2c_sensor_scl { + gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_sensor_sda { + gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_usb_c0_scl { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + ec_i2c_usb_c0_sda { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + ec_i2c_usb_c1_scl { + gpios = <&gpio9 2 GPIO_INPUT>; + }; + ec_i2c_usb_c1_sda { + gpios = <&gpio9 1 GPIO_INPUT>; + }; + ec_i2c_pwr_cbi_scl { + gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_pwr_cbi_sda { + gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_batt_scl { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + ec_i2c_batt_sda { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + ec_pen_chg_dis_odl { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_wp_l: ec_wp_odl { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | + GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpiob 2 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ec_ap_int_odl { + gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpio8 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; + }; + charger_prochot_odl { + gpios = <&gpiob 1 GPIO_INPUT>; + }; + ec_rst_odl { + gpios = <&gpio7 7 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; + }; + packet_mode_en { + gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiod 4 GPIO_INPUT>; + }; + /* + * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 + * belong to VSPI power rail. On kingler, it is connencted to + * 1.8V. + */ + ap_sysrst_odl_r: ap_sysrst_odl_r { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio6 7 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + pg_pp5000_z2_od { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + gpios = <&gpio7 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; + }; + gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpio3 7 GPIO_INPUT>; + }; + en_pp5000_z2 { + gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + ec_batt_pres_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + usb_a0_fault_odl { + gpios = <&gpioc 7 GPIO_INPUT>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpio6 1 GPIO_ODR_HIGH>; + }; + ec_pmic_en_odl { + gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + }; + + /* + * aliases for sub-board GPIOs + */ + aliases { + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_power_button + &int_lid_open + >; + }; +}; diff --git a/zephyr/program/corsola/gpio_krabby.dts b/zephyr/program/corsola/gpio_krabby.dts new file mode 100644 index 0000000000..5f06609f43 --- /dev/null +++ b/zephyr/program/corsola/gpio_krabby.dts @@ -0,0 +1,231 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &ec_flash_wp_odl; + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + base_imu_int_l: base_imu_int_l { + gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l: lid_accel_int_l { + gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + volume_down_l: volume_down_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + volume_up_l: volume_up_l { + gpios = <&gpiod 6 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ac_present: ac_present { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_flash_wp_odl: ec_flash_wp_odl { + gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usb_c0_ppc_bc12_int_odl: usb_c0_ppc_bc12_int_odl { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + ec_pmic_en_odl: ec_pmic_en_odl { + gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + en_pp5000_z2: en_pp5000_z2 { + gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; + }; + sys_rst_odl: sys_rst_odl { + gpios = <&gpiog 1 GPIO_ODR_LOW>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + ap_sysrst_odl_r: ap_ec_sysrst_odl { + gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ec_int_l: ec_int_l { + gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + }; + usb_c0_ppc_frsinfo: usb_c0_ppc_frsinfo { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + en_ec_id_odl: en_ec_id_odl { + gpios = <&gpioh 5 GPIO_ODR_HIGH>; + }; + entering_rw: entering_rw { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; + }; + usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&gpioj 6 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpioj 3 GPIO_INPUT>; + }; + gpio_packet_mode_en: packet_mode_en { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioc 4 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_ac_present + &int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* pg_pp5000_z2_od */ + <&gpiod 2 GPIO_INPUT>, + /* pg_mt6315_proc_b_odl */ + <&gpioe 1 GPIO_INPUT>, + /* ec_pen_chg_dis_odl */ + <&gpioh 3 GPIO_ODR_HIGH>, + /* unnamed nc pins */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + <&gpioa 6 GPIO_INPUT_PULL_DOWN>, + <&gpioa 7 GPIO_INPUT_PULL_DOWN>, + <&gpiod 7 GPIO_INPUT_PULL_DOWN>, + <&gpiof 1 GPIO_INPUT_PULL_DOWN>, + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + <&gpioi 3 GPIO_INPUT_PULL_DOWN>, + <&gpioi 5 GPIO_INPUT_PULL_DOWN>, + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, + /* spi_clk_gpg6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + /* spi_mosi_gpg4 */ + <&gpiog 4 GPIO_OUTPUT_LOW>, + /* spi_miso_gpg5 */ + <&gpiog 5 GPIO_OUTPUT_LOW>, + /* spi_cs_gpg7 */ + <&gpiog 7 GPIO_OUTPUT_LOW>; + }; +}; + +&pinctrl { + /* I2C property setting */ + i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { + gpio-voltage = "1v8"; + }; + i2c0_data_gpb4_default: i2c0_data_gpb4_default { + gpio-voltage = "1v8"; + }; + i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { + gpio-voltage = "1v8"; + }; + i2c3_data_gpf3_default: i2c3_data_gpf3_default { + gpio-voltage = "1v8"; + }; + /* SHI property setting */ + shi_mosi_gpm0_default: shi_mosi_gpm0_default { + gpio-voltage = "1v8"; + }; + shi_miso_gpm1_default: shi_miso_gpm1_default { + gpio-voltage = "1v8"; + }; + shi_clk_gpm4_default: shi_clk_gpm4_default { + gpio-voltage = "1v8"; + }; + shi_cs_gpm5_default: shi_cs_gpm5_default { + gpio-voltage = "1v8"; + }; +}; diff --git a/zephyr/program/corsola/gpio_magikarp.dts b/zephyr/program/corsola/gpio_magikarp.dts new file mode 100644 index 0000000000..cb9f6f1a0a --- /dev/null +++ b/zephyr/program/corsola/gpio_magikarp.dts @@ -0,0 +1,237 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &ec_flash_wp_odl; + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + base_imu_int_l: base_imu_int_l { + gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l: lid_accel_int_l { + gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + volume_down_l: volume_down_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + volume_up_l: volume_up_l { + gpios = <&gpiod 6 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ac_present: ac_present { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_flash_wp_odl: ec_flash_wp_odl { + gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpiod 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpiof 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + ec_pmic_en_odl: ec_pmic_en_odl { + gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + en_pp5000_z2: en_pp5000_z2 { + gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; + }; + sys_rst_odl: sys_rst_odl { + gpios = <&gpiog 1 GPIO_ODR_LOW>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + ap_sysrst_odl_r: ap_ec_sysrst_odl { + gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ec_int_l: ec_int_l { + gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + }; + usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + en_ec_id_odl: en_ec_id_odl { + gpios = <&gpioh 5 GPIO_ODR_HIGH>; + }; + entering_rw: entering_rw { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; + }; + usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&gpioj 6 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpioj 3 GPIO_INPUT>; + }; + gpio_packet_mode_en: packet_mode_en { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioc 4 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_ac_present + &int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* pg_pp5000_z2_od */ + <&gpiod 2 GPIO_INPUT>, + /* pg_mt6315_proc_b_odl */ + <&gpioe 1 GPIO_INPUT>, + /* ec_pen_chg_dis_odl */ + <&gpioh 3 GPIO_ODR_HIGH>, + /* unnamed nc pins */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + <&gpioa 6 GPIO_INPUT_PULL_DOWN>, + <&gpioa 7 GPIO_INPUT_PULL_DOWN>, + /* reserved for b:241345809 */ + <&gpiod 7 GPIO_OUTPUT_LOW>, + <&gpiog 2 GPIO_INPUT_PULL_DOWN>, + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + <&gpioi 3 GPIO_INPUT_PULL_DOWN>, + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, + /* spi_clk_gpg6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + /* spi_mosi_gpg4 */ + <&gpiog 4 GPIO_OUTPUT_LOW>, + /* spi_miso_gpg5 */ + <&gpiog 5 GPIO_OUTPUT_LOW>, + /* spi_cs_gpg7 */ + <&gpiog 7 GPIO_OUTPUT_LOW>; + }; +}; + +&pinctrl { + /* I2C property setting */ + i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { + gpio-voltage = "1v8"; + }; + i2c0_data_gpb4_default: i2c0_data_gpb4_default { + gpio-voltage = "1v8"; + }; + i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { + gpio-voltage = "1v8"; + }; + i2c3_data_gpf3_default: i2c3_data_gpf3_default { + gpio-voltage = "1v8"; + }; + /* SHI property setting */ + shi_mosi_gpm0_default: shi_mosi_gpm0_default { + gpio-voltage = "1v8"; + }; + shi_miso_gpm1_default: shi_miso_gpm1_default { + gpio-voltage = "1v8"; + }; + shi_clk_gpm4_default: shi_clk_gpm4_default { + gpio-voltage = "1v8"; + }; + shi_cs_gpm5_default: shi_cs_gpm5_default { + gpio-voltage = "1v8"; + }; +}; diff --git a/zephyr/program/corsola/gpio_steelix.dts b/zephyr/program/corsola/gpio_steelix.dts new file mode 100644 index 0000000000..14120e6d7d --- /dev/null +++ b/zephyr/program/corsola/gpio_steelix.dts @@ -0,0 +1,255 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + /* + * In npcx9 series, gpio46, gpio47, and the whole gpio5 port + * belong to VHIF power well. On steelix, it is connencted to + * 1.8V. + */ + base_imu_int_l: base_imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + spi_ap_clk_ec { + gpios = <&gpio5 5 GPIO_INPUT>; + }; + spi_ap_cs_ec_l { + gpios = <&gpio5 3 GPIO_INPUT>; + }; + spi_ap_do_ec_di { + gpios = <&gpio4 6 GPIO_INPUT>; + }; + spi_ap_di_ec_do { + gpios = <&gpio4 7 GPIO_INPUT>; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; + }; + en_ec_id_odl { + gpios = <&gpio7 6 GPIO_ODR_HIGH>; + }; + sys_rst_odl { + gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + ec_i2c_sensor_scl { + gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_sensor_sda { + gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_usb_c0_scl { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + ec_i2c_usb_c0_sda { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + ec_i2c_usb_c1_scl { + gpios = <&gpio9 2 GPIO_INPUT>; + }; + ec_i2c_usb_c1_sda { + gpios = <&gpio9 1 GPIO_INPUT>; + }; + ec_i2c_pwr_cbi_scl { + gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_pwr_cbi_sda { + gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_batt_scl { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + ec_i2c_batt_sda { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x { + gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; + }; + usb_a1_fault_odl { + gpios = <&gpiof 4 GPIO_INPUT>; + }; + ec_pen_chg_dis_odl { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_wp_l: ec_wp_odl { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | + GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpiob 2 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ec_ap_int_odl { + gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpio8 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; + }; + charger_prochot_odl { + gpios = <&gpiob 1 GPIO_INPUT>; + }; + ec_rst_odl { + gpios = <&gpio7 7 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; + }; + packet_mode_en { + gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiod 4 GPIO_INPUT>; + }; + /* + * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 + * belong to VSPI power well. On steelix, it is connencted to + * 1.8V. + */ + ap_sysrst_odl_r: ap_sysrst_odl_r { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio6 7 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + pg_pp5000_z2_od { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + gpios = <&gpio7 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; + }; + gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpio3 7 GPIO_INPUT>; + }; + en_pp5000_z2 { + gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + ec_batt_pres_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + usb_a0_fault_odl { + gpios = <&gpioc 7 GPIO_INPUT>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpio6 1 GPIO_ODR_HIGH>; + }; + ec_pmic_en_odl { + gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + }; + + /* + * aliases for sub-board GPIOs + */ + aliases { + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_power_button + &int_lid_open + >; + }; +}; diff --git a/zephyr/program/corsola/gpio_tentacruel.dts b/zephyr/program/corsola/gpio_tentacruel.dts new file mode 100644 index 0000000000..a9ac9e8eac --- /dev/null +++ b/zephyr/program/corsola/gpio_tentacruel.dts @@ -0,0 +1,235 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &ec_flash_wp_odl; + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + base_imu_int_l: base_imu_int_l { + gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l: lid_accel_int_l { + gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + volume_down_l: volume_down_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + volume_up_l: volume_up_l { + gpios = <&gpiod 6 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ac_present: ac_present { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_flash_wp_odl: ec_flash_wp_odl { + gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpiod 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpiof 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + ec_pmic_en_odl: ec_pmic_en_odl { + gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + en_pp5000_z2: en_pp5000_z2 { + gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; + }; + sys_rst_odl: sys_rst_odl { + gpios = <&gpiog 1 GPIO_ODR_LOW>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + ap_sysrst_odl_r: ap_ec_sysrst_odl { + gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ec_int_l: ec_int_l { + gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + }; + usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + en_ec_id_odl: en_ec_id_odl { + gpios = <&gpioh 5 GPIO_ODR_HIGH>; + }; + entering_rw: entering_rw { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; + }; + usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&gpioj 6 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpioj 3 GPIO_INPUT>; + }; + gpio_packet_mode_en: packet_mode_en { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioc 4 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_ac_present + &int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* pg_pp5000_z2_od */ + <&gpiod 2 GPIO_INPUT>, + /* pg_mt6315_proc_b_odl */ + <&gpioe 1 GPIO_INPUT>, + /* ec_pen_chg_dis_odl */ + <&gpioh 3 GPIO_ODR_HIGH>, + /* unnamed nc pins */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + <&gpioa 6 GPIO_INPUT_PULL_DOWN>, + <&gpioa 7 GPIO_INPUT_PULL_DOWN>, + <&gpiod 7 GPIO_INPUT_PULL_DOWN>, + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + <&gpioi 3 GPIO_INPUT_PULL_DOWN>, + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, + /* spi_clk_gpg6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + /* spi_mosi_gpg4 */ + <&gpiog 4 GPIO_OUTPUT_LOW>, + /* spi_miso_gpg5 */ + <&gpiog 5 GPIO_OUTPUT_LOW>, + /* spi_cs_gpg7 */ + <&gpiog 7 GPIO_OUTPUT_LOW>; + }; +}; + +&pinctrl { + /* I2C property setting */ + i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { + gpio-voltage = "1v8"; + }; + i2c0_data_gpb4_default: i2c0_data_gpb4_default { + gpio-voltage = "1v8"; + }; + i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { + gpio-voltage = "1v8"; + }; + i2c3_data_gpf3_default: i2c3_data_gpf3_default { + gpio-voltage = "1v8"; + }; + /* SHI property setting */ + shi_mosi_gpm0_default: shi_mosi_gpm0_default { + gpio-voltage = "1v8"; + }; + shi_miso_gpm1_default: shi_miso_gpm1_default { + gpio-voltage = "1v8"; + }; + shi_clk_gpm4_default: shi_clk_gpm4_default { + gpio-voltage = "1v8"; + }; + shi_cs_gpm5_default: shi_cs_gpm5_default { + gpio-voltage = "1v8"; + }; +}; diff --git a/zephyr/program/corsola/host_interface_npcx.dts b/zephyr/program/corsola/host_interface_npcx.dts new file mode 100644 index 0000000000..14efa3c6b2 --- /dev/null +++ b/zephyr/program/corsola/host_interface_npcx.dts @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* host interface */ +&shi { + status = "okay"; + pinctrl-0 = <&shi_gp46_47_53_55>; + pinctrl-1 = <&shi_gpio_gp46_47_53_55>; + pinctrl-names = "default", "sleep"; +}; diff --git a/zephyr/program/corsola/i2c_kingler.dts b/zephyr/program/corsola/i2c_kingler.dts new file mode 100644 index 0000000000..90390ab8a0 --- /dev/null +++ b/zephyr/program/corsola/i2c_kingler.dts @@ -0,0 +1,169 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/* + * Kingler and Steelix use the same dts, take care of this when modify it. + */ + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_sensor: sensor { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_usb_c0: usb-c0 { + i2c-port = <&i2c1_0>; + remote-port = <7>; + enum-names = "I2C_PORT_USB_C0"; + }; + i2c_usb_c1: usb-c1 { + i2c-port = <&i2c2_0>; + enum-names = "I2C_PORT_USB_C1", + "I2C_PORT_USB_C1_TCPC", + "I2C_PORT_USB_C1_PPC"; + }; + i2c_charger: charger { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_POWER", + "I2C_PORT_EEPROM"; + }; + battery { + i2c-port = <&i2c5_0>; + remote-port = <1>; + enum-names = "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY"; + }; + }; +}; + +&i2c0_0 { + label = "I2C_SENSOR"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + label = "I2C_USB_C0"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + tcpc_port0: anx7447-tcpc@2c { + compatible = "analogix,anx7447-tcpc"; + status = "okay"; + reg = <0x2c>; + tcpc-flags = <( + TCPC_FLAGS_VBUS_MONITOR | + TCPC_FLAGS_ALERT_OD | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS)>; + }; + + ppc_port0: nx20p348x@72 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x72>; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + label = "I2C_USB_C1"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; + + bc12_port1: rt1718s-bc12@40 { + compatible = "richtek,rt1718s-bc12"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port1: rt1718s-tcpc@40 { + compatible = "richtek,rt1718s-tcpc"; + reg = <0x40>; + tcpc-flags = <( + TCPC_FLAGS_ALERT_OD | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS)>; + }; + + ppc_port1: nx20p348x@72 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x72>; + }; + + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + board-init = "ps8743_mux_1_board_init"; + }; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + label = "I2C_PWR_CBI"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; + + charger: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c5_0 { + label = "I2C_BATTERY"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; +}; + +&i2c_ctrl5 { + status = "okay"; +}; diff --git a/zephyr/program/corsola/i2c_krabby.dts b/zephyr/program/corsola/i2c_krabby.dts new file mode 100644 index 0000000000..a5dc03b655 --- /dev/null +++ b/zephyr/program/corsola/i2c_krabby.dts @@ -0,0 +1,22 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "i2c_krabby_tentacruel.dtsi" + +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; + }; +}; + +&i2c4 { + tusb1064_mux_1: tusb1064-mux-1@44 { + compatible = "ti,tusb1064"; + reg = <0x44>; + board-init = "tusb1064_mux_1_board_init"; + }; +}; diff --git a/zephyr/program/corsola/i2c_krabby_tentacruel.dtsi b/zephyr/program/corsola/i2c_krabby_tentacruel.dtsi new file mode 100644 index 0000000000..6fd153e1fa --- /dev/null +++ b/zephyr/program/corsola/i2c_krabby_tentacruel.dtsi @@ -0,0 +1,138 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + + battery { + i2c-port = <&i2c1>; + remote-port = <1>; + enum-names = "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY"; + }; + i2c_charger: charger { + i2c-port = <&i2c0>; + enum-names = "I2C_PORT_CHARGER", + "I2C_PORT_EEPROM"; + }; + i2c_sensor: sensor { + i2c-port = <&i2c3>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_usb_c0: usb-c0 { + i2c-port = <&i2c2>; + enum-names = "I2C_PORT_USB_C0", + "I2C_PORT_USB_MUX0"; + }; + i2c_usb_c1: usb-c1 { + i2c-port = <&i2c4>; + enum-names = "I2C_PORT_USB_C1", + "I2C_PORT_USB_MUX1"; + }; + }; + +}; + +&pinctrl { + i2c3_clk_gpf2_sleep: i2c3_clk_gpf2_sleep { + pinmuxs = <&pinctrlf 2 IT8XXX2_ALT_DEFAULT>; + }; + i2c3_data_gpf3_sleep: i2c3_data_gpf3_sleep { + pinmuxs = <&pinctrlf 3 IT8XXX2_ALT_DEFAULT>; + }; +}; + +&i2c0 { + /* EC_I2C_PWR_CBI */ + label = "I2C_PWR_CBI"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_clk_gpb3_default + &i2c0_data_gpb4_default>; + pinctrl-names = "default"; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; + + bc12_port1: rt9490-bc12@53 { + compatible = "richtek,rt9490-bc12"; + status = "okay"; + reg = <0x53>; + irq = <&int_usb_c1_bc12_charger>; + }; +}; + +&i2c1 { + /* EC_I2C_BATTERY */ + label = "I2C_BATTERY"; + status = "okay"; + clock-frequency = <50000>; + pinctrl-0 = <&i2c1_clk_gpc1_default + &i2c1_data_gpc2_default>; + pinctrl-names = "default"; + fifo-enable; +}; + +&i2c2 { + /* EC_I2C_USB_C0 */ + label = "I2C_USB_C0"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_clk_gpf6_default + &i2c2_data_gpf7_default>; + pinctrl-names = "default"; + /delete-property/ fifo-enable; + + bc12_ppc_port0: rt1739@70 { + compatible = "richtek,rt1739"; + status = "okay"; + reg = <0x70>; + }; + + it5205_mux_0: it5205-mux-0@48 { + compatible = "ite,it5205"; + reg = <0x48>; + }; +}; + +&i2c3 { + /* EC_I2C_SENSOR */ + label = "I2C_SENSOR"; + status = "okay"; + clock-frequency = ; + scl-gpios = <&gpiof 2 0>; + sda-gpios = <&gpiof 3 0>; + pinctrl-0 = <&i2c3_clk_gpf2_default + &i2c3_data_gpf3_default>; + pinctrl-1 = <&i2c3_clk_gpf2_sleep + &i2c3_data_gpf3_sleep>; + pinctrl-names = "default", "sleep"; + prescale-scl-low = <1>; +}; + +&i2c4 { + /* EC_I2C_USB_C1 */ + label = "I2C_USB_C1"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c4_clk_gpe0_default + &i2c4_data_gpe7_default>; + pinctrl-names = "default"; + prescale-scl-low = <1>; + + ppc_port1: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&gpio_ec_x_gpio1>; + }; +}; diff --git a/zephyr/program/corsola/i2c_magikarp.dts b/zephyr/program/corsola/i2c_magikarp.dts new file mode 100644 index 0000000000..fbf5ed6337 --- /dev/null +++ b/zephyr/program/corsola/i2c_magikarp.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "i2c_krabby_tentacruel.dtsi" + +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; + }; +}; + +&i2c2 { + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + ppc_port0: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&usb_c0_frs_en>; + }; +}; + +&i2c4 { + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + }; +}; diff --git a/zephyr/program/corsola/i2c_tentacruel.dts b/zephyr/program/corsola/i2c_tentacruel.dts new file mode 100644 index 0000000000..a635adcf5c --- /dev/null +++ b/zephyr/program/corsola/i2c_tentacruel.dts @@ -0,0 +1,38 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "i2c_krabby_tentacruel.dtsi" + +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; + thermistor = <&thermistor_rt9490>; + }; +}; + +&i2c2 { + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + ppc_port0: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&usb_c0_frs_en>; + }; +}; + +&i2c4 { + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + board-init = "ps8743_eq_c1_setting"; + }; +}; diff --git a/zephyr/program/corsola/include/baseboard_usbc_config.h b/zephyr/program/corsola/include/baseboard_usbc_config.h new file mode 100644 index 0000000000..a80aa10446 --- /dev/null +++ b/zephyr/program/corsola/include/baseboard_usbc_config.h @@ -0,0 +1,42 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola daughter board detection */ + +#ifndef __CROS_EC_BASEBOARD_USBC_CONFIG_H +#define __CROS_EC_BASEBOARD_USBC_CONFIG_H + +#include "gpio.h" + +#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S +#define GPIO_EN_USB_C1_SINK RT1718S_GPIO1 +#define GPIO_EN_USB_C1_SOURCE RT1718S_GPIO2 +#define GPIO_EN_USB_C1_FRS RT1718S_GPIO3 +#endif + +void ppc_interrupt(enum gpio_signal signal); +void ccd_interrupt(enum gpio_signal signal); +void hdmi_hpd_interrupt(enum gpio_signal signal); +void ps185_hdmi_hpd_mux_set(void); +int corsola_is_dp_muxable(int port); + +/* USB-A ports */ +enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_COUNT }; + +/* USB-C ports */ +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; +BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); + +/** + * Is the port fine to be muxed its DisplayPort lines? + * + * Only one port can be muxed to DisplayPort at a time. + * + * @param port Port number of TCPC. + * @return 1 is fine; 0 is bad as other port is already muxed; + */ +int corsola_is_dp_muxable(int port); + +#endif /* __CROS_EC_BASEBOARD_USBC_CONFIG_H */ diff --git a/zephyr/program/corsola/include/variant_db_detection.h b/zephyr/program/corsola/include/variant_db_detection.h new file mode 100644 index 0000000000..e98ba3067d --- /dev/null +++ b/zephyr/program/corsola/include/variant_db_detection.h @@ -0,0 +1,37 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola daughter board detection */ + +#ifndef __CROS_EC_CORSOLA_DB_DETECTION_H +#define __CROS_EC_CORSOLA_DB_DETECTION_H + +enum corsola_db_type { + CORSOLA_DB_UNINIT = -1, + CORSOLA_DB_NONE, + CORSOLA_DB_TYPEC, + CORSOLA_DB_HDMI, + CORSOLA_DB_COUNT, +}; + +#ifdef CONFIG_VARIANT_CORSOLA_DB_DETECTION +/* + * Get the connected daughterboard type. + * + * @return The daughterboard type. + */ +enum corsola_db_type corsola_get_db_type(void); +#else +inline enum corsola_db_type corsola_get_db_type(void) +{ + return CORSOLA_DB_NONE; +}; +#endif /* CONFIG_VARIANT_CORSOLA_DB_DETECTION */ + +/* return the adjusted port count for board overridden usbc/charger functions. + */ +uint8_t board_get_adjusted_usb_pd_port_count(void); + +#endif /* __CROS_EC_CORSOLA_DB_DETECTION_H */ diff --git a/zephyr/program/corsola/interrupts_kingler.dts b/zephyr/program/corsola/interrupts_kingler.dts new file mode 100644 index 0000000000..f3da785a60 --- /dev/null +++ b/zephyr/program/corsola/interrupts_kingler.dts @@ -0,0 +1,114 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * Kingler and Steelix use the same dts, take care of this when modify it. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_ec_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_ec_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = ; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = ; + handler = "chipset_watchdog_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&gpio_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = ; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&gpio_ec_wp_l>; + flags = ; + handler = "switch_interrupt"; + }; + int_usb_c0_tcpc: usb_c0_tcpc { + irq-pin = <&gpio_usb_c0_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-pin = <&gpio_usb_c1_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&gpio_usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = ; + handler = "x_ec_interrupt"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "bmi3xx_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "ccd_interrupt"; + }; + }; +}; diff --git a/zephyr/program/corsola/interrupts_krabby.dts b/zephyr/program/corsola/interrupts_krabby.dts new file mode 100644 index 0000000000..3caf4660ae --- /dev/null +++ b/zephyr/program/corsola/interrupts_krabby.dts @@ -0,0 +1,110 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&volume_up_l>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&volume_down_l>; + flags = ; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = ; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = ; + handler = "chipset_watchdog_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "icm42607_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&lid_accel_int_l>; + flags = ; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&ac_present>; + flags = ; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = ; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&ec_flash_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = ; + handler = "spi_event"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = ; + handler = "x_ec_interrupt"; + }; + int_usb_c0_ppc_bc12: usb_c0_ppc_bc12 { + irq-pin = <&usb_c0_ppc_bc12_int_odl>; + flags = ; + handler = "c0_bc12_interrupt"; + }; + int_usb_c1_bc12_charger: usb_c1_bc12_charger { + irq-pin = <&usb_c1_bc12_charger_int_odl>; + flags = ; + handler = "rt9490_bc12_dt_interrupt"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "ccd_interrupt"; + }; + }; +}; diff --git a/zephyr/program/corsola/interrupts_magikarp.dts b/zephyr/program/corsola/interrupts_magikarp.dts new file mode 100644 index 0000000000..4f4e0ba100 --- /dev/null +++ b/zephyr/program/corsola/interrupts_magikarp.dts @@ -0,0 +1,115 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&volume_up_l>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&volume_down_l>; + flags = ; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = ; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = ; + handler = "chipset_watchdog_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "motion_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&lid_accel_int_l>; + flags = ; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&ac_present>; + flags = ; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = ; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&ec_flash_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = ; + handler = "spi_event"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = ; + handler = "x_ec_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_bc12_charger: usb_c1_bc12_charger { + irq-pin = <&usb_c1_bc12_charger_int_odl>; + flags = ; + handler = "rt9490_bc12_dt_interrupt"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "ccd_interrupt"; + }; + }; +}; diff --git a/zephyr/program/corsola/interrupts_steelix.dts b/zephyr/program/corsola/interrupts_steelix.dts new file mode 100644 index 0000000000..816beb95f4 --- /dev/null +++ b/zephyr/program/corsola/interrupts_steelix.dts @@ -0,0 +1,10 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +&int_base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "motion_interrupt"; +}; diff --git a/zephyr/program/corsola/interrupts_tentacruel.dts b/zephyr/program/corsola/interrupts_tentacruel.dts new file mode 100644 index 0000000000..11229daf36 --- /dev/null +++ b/zephyr/program/corsola/interrupts_tentacruel.dts @@ -0,0 +1,115 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&volume_up_l>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&volume_down_l>; + flags = ; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = ; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = ; + handler = "chipset_watchdog_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "motion_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&lid_accel_int_l>; + flags = ; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&ac_present>; + flags = ; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = ; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&ec_flash_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = ; + handler = "spi_event"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = ; + handler = "x_ec_interrupt"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c1_bc12_charger: usb_c1_bc12_charger { + irq-pin = <&usb_c1_bc12_charger_int_odl>; + flags = ; + handler = "rt9490_bc12_dt_interrupt"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "ccd_interrupt"; + }; + }; +}; diff --git a/zephyr/program/corsola/keyboard_krabby.dts b/zephyr/program/corsola/keyboard_krabby.dts new file mode 100644 index 0000000000..b1a9af6330 --- /dev/null +++ b/zephyr/program/corsola/keyboard_krabby.dts @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + scan-period = <10000>; + + actual-key-mask = < + 0x1c /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; diff --git a/zephyr/program/corsola/keyboard_steelix.dts b/zephyr/program/corsola/keyboard_steelix.dts new file mode 100644 index 0000000000..9a0dca3e05 --- /dev/null +++ b/zephyr/program/corsola/keyboard_steelix.dts @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + debounce-down = <15000>; + debounce-up = <15000>; + + actual-key-mask = < + 0x1c /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; diff --git a/zephyr/program/corsola/led_it81202_base.dtsi b/zephyr/program/corsola/led_it81202_base.dtsi new file mode 100644 index 0000000000..dce7bb4f95 --- /dev/null +++ b/zephyr/program/corsola/led_it81202_base.dtsi @@ -0,0 +1,184 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include + +/ { + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + bat-power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + bat-power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + bat-power-state-discharge { + charge-state = "PWR_STATE_DISCHARGE"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + + bat-power-state-discharge-s0-bat-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + batt-lvl = ; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <1000>; + }; + }; + + pwr-power-state-off { + color-0 { + led-color = <&color_power_off>; + }; + }; + + pwr-power-state-on { + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_power_white>; + }; + }; + + pwr-power-state-s3 { + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_power_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_power_off>; + period-ms = <3000>; + }; + }; + }; + + pwmleds { + compatible = "cros-ec,pwm-pin-config"; + + /* NOTE: &pwm number needs same with channel number */ + led_power_white: ec_led1_odl { + #led-pin-cells = <1>; + pwms = <&pwm0 + PWM_CHANNEL_0 + PWM_HZ(324) + PWM_POLARITY_INVERTED>; + }; + led_battery_amber: ec_led2_odl { + #led-pin-cells = <1>; + pwms = <&pwm1 + PWM_CHANNEL_1 + PWM_HZ(324) + PWM_POLARITY_INVERTED>; + }; + led_battery_white: ec_led3_odl { + #led-pin-cells = <1>; + pwms = <&pwm2 + PWM_CHANNEL_2 + PWM_HZ(324) + PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_power_off: color-power-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 0>; + }; + + color_power_white: color-power-white { + led-color = "LED_WHITE"; + br-color = "EC_LED_COLOR_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 100>; + }; + + color_battery_off: color-battery-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&led_battery_amber 0>, + <&led_battery_white 0>; + }; + + color_battery_amber: color-battery-amber { + led-color = "LED_AMBER"; + br-color = "EC_LED_COLOR_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&led_battery_amber 100>, + <&led_battery_white 0>; + }; + + color_battery_white: color-battery-white { + led-color = "LED_WHITE"; + br-color = "EC_LED_COLOR_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&led_battery_amber 0>, + <&led_battery_white 100>; + }; + }; +}; + +/* LED1 */ +&pwm0 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm0_gpa0_default>; + pinctrl-names = "default"; +}; + +/* LED2 */ +&pwm1 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm1_gpa1_default>; + pinctrl-names = "default"; +}; + +/* LED3 */ +&pwm2 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm2_gpa2_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/led_kingler.dts b/zephyr/program/corsola/led_kingler.dts new file mode 100644 index 0000000000..92f6c4d4fe --- /dev/null +++ b/zephyr/program/corsola/led_kingler.dts @@ -0,0 +1,71 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED + &pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED + &pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0>; + + color-map-red = <100 0 0>; + color-map-green = < 0 100 0>; + color-map-amber = <100 20 0>; + + brightness-range = <255 255 0 0 0 255>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + }; +}; + +/* Red LED */ +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* Green LED */ +&pwm1_gpc2 { + drive-open-drain; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* Blue LED */ +&pwm2_gpc4 { + drive-open-drain; +}; + +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/led_krabby.dts b/zephyr/program/corsola/led_krabby.dts new file mode 100644 index 0000000000..b16bff3cac --- /dev/null +++ b/zephyr/program/corsola/led_krabby.dts @@ -0,0 +1,5 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "led_it81202_base.dtsi" diff --git a/zephyr/program/corsola/led_magikarp.dts b/zephyr/program/corsola/led_magikarp.dts new file mode 100644 index 0000000000..0e2b0aca52 --- /dev/null +++ b/zephyr/program/corsola/led_magikarp.dts @@ -0,0 +1,136 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "led_it81202_base.dtsi" + +/ { + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + /* Magikarp LED bat charge */ + bat-power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = ; + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + bat-power-state-charge-near-full { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) + BATTERY_LEVEL_FULL>; + color-0 { + led-color = <&color_battery_white>; + }; + }; + + /* Magikarp LED bat discharge */ + bat-power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + + bat-power-state-discharge-s0-bat-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= 10%) */ + batt-lvl = ; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + color-0 { + led-color = <&color_battery_off>; + }; + }; + + /* Magikarp LED bat error */ + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <1000>; + }; + }; + + bat-power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + /* Overwrite Power LED white to off */ + color_power_white: color-power-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 0>; + }; + }; +}; diff --git a/zephyr/program/corsola/led_steelix.dts b/zephyr/program/corsola/led_steelix.dts new file mode 100644 index 0000000000..6a25929327 --- /dev/null +++ b/zephyr/program/corsola/led_steelix.dts @@ -0,0 +1,55 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + led_battery_red: ec_led1_odl { + pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + led_battery_green: ec_led2_odl { + pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + led_power_white: ec_led3_odl { + pwms = <&pwm4 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; +}; + +/* Red LED */ +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* Green LED */ +&pwm1_gpc2 { + drive-open-drain; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* White LED */ +&pwm4_gpb6 { + drive-open-drain; +}; + +&pwm4 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm4_gpb6>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/led_tentacruel.dts b/zephyr/program/corsola/led_tentacruel.dts new file mode 100644 index 0000000000..5569a956f6 --- /dev/null +++ b/zephyr/program/corsola/led_tentacruel.dts @@ -0,0 +1,118 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "led_it81202_base.dtsi" + +/ { + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + /* Tentacruel LED bat charge */ + bat-power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = ; + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + bat-power-state-charge-near-full { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) + BATTERY_LEVEL_FULL>; + color-0 { + led-color = <&color_battery_white>; + }; + }; + + /* Tentacruel LED bat discharge */ + bat-power-state-discharge { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + bat-power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + color-0 { + led-color = <&color_battery_off>; + }; + }; + + /* Tentacruel LED bat error */ + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <1000>; + }; + }; + + bat-power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + /* Overwrite Power LED white to off */ + color_power_white: color-power-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 0>; + }; + }; +}; diff --git a/zephyr/program/corsola/motionsense_kingler.dts b/zephyr/program/corsola/motionsense_kingler.dts new file mode 100644 index 0000000000..a7f674e01f --- /dev/null +++ b/zephyr/program/corsola/motionsense_kingler.dts @@ -0,0 +1,150 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * Kingler and Steelix use the same dts, take care of this when modify it. + */ + +#include + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + (-1) 0 0 + 0 0 (-1)>; + }; + base_rot_ref: base-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma4xx_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <0>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/corsola/motionsense_krabby.dts b/zephyr/program/corsola/motionsense_krabby.dts new file mode 100644 index 0000000000..1c7d5b2df4 --- /dev/null +++ b/zephyr/program/corsola/motionsense_krabby.dts @@ -0,0 +1,146 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + icm42607-int = &base_accel; + lis2dw12-int = &lid_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: icm42607-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + icm42607_data: icm42607-drv-data { + compatible = "cros-ec,drvdata-icm42607"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,icm42607-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,icm42607-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/program/corsola/motionsense_magikarp.dts b/zephyr/program/corsola/motionsense_magikarp.dts new file mode 100644 index 0000000000..92e73bd2c6 --- /dev/null +++ b/zephyr/program/corsola/motionsense_magikarp.dts @@ -0,0 +1,199 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + icm42607-int = &base_accel; + lis2dw12-int = &lid_accel; + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: icm42607-mutex { + }; + + base_mutex_bmi323: bmi323-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref_bmi: base-rotation-ref-bmi { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + icm42607_data: icm42607-drv-data { + compatible = "cros-ec,drvdata-icm42607"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,icm42607-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,icm42607-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + }; + }; + + motionsense-sensor-alt { + alt_base_accel: alt-base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_gyro>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/program/corsola/motionsense_steelix.dts b/zephyr/program/corsola/motionsense_steelix.dts new file mode 100644 index 0000000000..df96fc2e42 --- /dev/null +++ b/zephyr/program/corsola/motionsense_steelix.dts @@ -0,0 +1,133 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/* inherit the rot_ref from Kingler and overwrite it */ +&lid_rot_ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; +}; + +&base_rot_ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; +}; + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + lsm6dsm-int = &base_accel; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + base_rot_ref_lsm6dsm: base-rotation-ref-lsm6dsm { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + lsm6dsm_data_accel: lsm6dsm-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dsm"; + status = "okay"; + }; + lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dsm"; + status = "okay"; + }; + }; + + motionsense-sensor-alt { + alt_lid_accel: alt-lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + alternate-for = <&lid_accel>; + alternate-ssfc-indicator = <&lid_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_accel: alt-base-accel { + compatible = "cros-ec,lsm6dsm-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_lsm6dsm>; + drv-data = <&lsm6dsm_data_accel>; + alternate-for = <&base_accel>; + alternate-ssfc-indicator = <&base_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <0>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,lsm6dsm-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_lsm6dsm>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dsm_data_gyro>; + alternate-for = <&base_gyro>; + alternate-ssfc-indicator = <&base_sensor_1>; + }; + }; +}; diff --git a/zephyr/program/corsola/motionsense_tentacruel.dts b/zephyr/program/corsola/motionsense_tentacruel.dts new file mode 100644 index 0000000000..68b2c023df --- /dev/null +++ b/zephyr/program/corsola/motionsense_tentacruel.dts @@ -0,0 +1,199 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + icm42607-int = &base_accel; + lis2dw12-int = &lid_accel; + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: icm42607-mutex { + }; + + base_mutex_bmi323: bmi323-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref_bmi: base-rotation-ref-bmi { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + icm42607_data: icm42607-drv-data { + compatible = "cros-ec,drvdata-icm42607"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,icm42607-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,icm42607-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + }; + }; + + motionsense-sensor-alt { + alt_base_accel: alt-base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_gyro>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/program/corsola/npcx_keyboard.dts b/zephyr/program/corsola/npcx_keyboard.dts new file mode 100644 index 0000000000..f9e46de1f2 --- /dev/null +++ b/zephyr/program/corsola/npcx_keyboard.dts @@ -0,0 +1,32 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/power_signal.dts b/zephyr/program/corsola/power_signal.dts new file mode 100644 index 0000000000..181d7cf96e --- /dev/null +++ b/zephyr/program/corsola/power_signal.dts @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + power_signal_list: power-signal-list { + compatible = "mt8186,power-signal-list"; + ap_in_rst { + power-enum-name = "AP_IN_RST"; + power-gpio-pin = <&ap_sysrst_odl_r>; + }; + ap_in_s3 { + power-enum-name = "AP_IN_S3"; + power-gpio-pin = <&ap_in_sleep_l>; + }; + ap_wdt_asserted { + power-enum-name = "AP_WDT_ASSERTED"; + power-gpio-pin = <&ap_ec_wdtrst_l>; + }; + ap_warm_rst_req { + power-enum-name = "AP_WARM_RST_REQ"; + power-gpio-pin = <&ap_ec_warm_rst_req>; + }; + }; +}; diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf new file mode 100644 index 0000000000..110b91bbbb --- /dev/null +++ b/zephyr/program/corsola/prj.conf @@ -0,0 +1,101 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# + +# http://google3/hardware/standards/usb/ +CONFIG_PLATFORM_EC_USB_PID=0x505C + +# CROS EC +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_SHIMMED_TASKS=y + +# AP SoC configuration +CONFIG_AP=y +CONFIG_AP_ARM_MTK_MT8186=y + +# Variant config +CONFIG_VARIANT_CORSOLA_DB_DETECTION=y + +# Shell features +CONFIG_KERNEL_SHELL=y +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y + +# CBI +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y +CONFIG_PLATFORM_EC_CBI_EEPROM=y + +# I2C +CONFIG_I2C=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y + +# MKBP +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y + +# EFS2 +CONFIG_PLATFORM_EC_VBOOT_EFS2=y + +# USB +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK=y + +# USB-C +CONFIG_PLATFORM_EC_USBC=y +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_PD_DPS=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_FRS=y + +# Power Seq +CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y + +# Optional features +CONFIG_FLASH_SHELL=n + +# EEPROM +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# Host Commands +CONFIG_PLATFORM_EC_HOSTCMD=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=9000 +CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y +CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y + +# Charger +CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y +CONFIG_PLATFORM_EC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGE_MANAGER=y + +# Button +CONFIG_PLATFORM_EC_CMD_BUTTON=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y diff --git a/zephyr/program/corsola/prj_it81202_base.conf b/zephyr/program/corsola/prj_it81202_base.conf new file mode 100644 index 0000000000..04283bcf5c --- /dev/null +++ b/zephyr/program/corsola/prj_it81202_base.conf @@ -0,0 +1,93 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Bring up options +CONFIG_SHELL_HISTORY_BUFFER=256 +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y +CONFIG_PLATFORM_EC_BRINGUP=y + +# Power Sequencing +CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y + +# Lid Switch +CONFIG_PLATFORM_EC_LID_SWITCH=y + +# Charger +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_RT9490=y +CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +# BOARD_RS2 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +# BOARD_RS1 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y + +# Host Commands +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y +CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# Sensors +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# Sensor Drivers +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y +CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=y +CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=y + +# Tasks +CONFIG_TASK_CHARGER_STACK_SIZE=1024 +CONFIG_TASK_CHIPSET_STACK_SIZE=1440 +CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024 +CONFIG_TASK_PD_STACK_SIZE=1280 + +# USB-A +CONFIG_PLATFORM_EC_USBA=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n +CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y +CONFIG_PLATFORM_EC_USB_MUX_IT5205=y +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y +CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n +CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0 +CONFIG_PLATFORM_EC_USB_PD_PULLUP=1 + +CONFIG_PLATFORM_EC_SHA256_UNROLLED=y + +# TODO(b/180980668): bring these features up +CONFIG_LTO=n +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n diff --git a/zephyr/program/corsola/prj_kingler.conf b/zephyr/program/corsola/prj_kingler.conf new file mode 100644 index 0000000000..d7de991e93 --- /dev/null +++ b/zephyr/program/corsola/prj_kingler.conf @@ -0,0 +1,12 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_KINGLER=y + +# LED +CONFIG_PLATFORM_EC_LED_PWM=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/program/corsola/prj_krabby.conf b/zephyr/program/corsola/prj_krabby.conf new file mode 100644 index 0000000000..c4cde05c16 --- /dev/null +++ b/zephyr/program/corsola/prj_krabby.conf @@ -0,0 +1,9 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_KRABBY=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/program/corsola/prj_magikarp.conf b/zephyr/program/corsola/prj_magikarp.conf new file mode 100644 index 0000000000..a5ec9ede3b --- /dev/null +++ b/zephyr/program/corsola/prj_magikarp.conf @@ -0,0 +1,27 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_MAGIKARP=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y + +# Sensor +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y diff --git a/zephyr/program/corsola/prj_npcx993_base.conf b/zephyr/program/corsola/prj_npcx993_base.conf new file mode 100644 index 0000000000..0642bcd331 --- /dev/null +++ b/zephyr/program/corsola/prj_npcx993_base.conf @@ -0,0 +1,95 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +# Bring up options +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# Debug options and features; can be disabled to save memory or once bringup +# is complete. +CONFIG_SHELL_MINIMAL=n +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y + +# ADC +CONFIG_ADC=y + +# Charger +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=y +CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y + +# Math +CONFIG_PLATFORM_EC_MATH_UTIL=y + +# Power sequencing +CONFIG_PLATFORM_EC_POWERSEQ_MT8186=y +CONFIG_PLATFORM_EC_POWERSEQ_S4=n + +# Button +CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y + +# Sensors +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y + +# USBA +CONFIG_PLATFORM_EC_USBA=y + +# USBC +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n +CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY=15000 +CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY=15000 +CONFIG_PLATFORM_EC_USBC_PPC=y +CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y +CONFIG_PLATFORM_EC_USBC_PPC_RT1718S=y +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2 +CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447_AUX_PU_PD=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y + +# External power +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n + +# Keyboard +CONFIG_CROS_KB_RAW_NPCX=y +CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y + +CONFIG_SYSCON=y + +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n diff --git a/zephyr/program/corsola/prj_steelix.conf b/zephyr/program/corsola/prj_steelix.conf new file mode 100644 index 0000000000..16f622989f --- /dev/null +++ b/zephyr/program/corsola/prj_steelix.conf @@ -0,0 +1,35 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_STEELIX=y + +# steelix only use D2, drop the workaround config for H1 +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n + +# Motion sensor +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM=y +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y + +# USBC +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250 +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 + +# Remove bring up options for FW QUAL +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n + +# Remove debug options and features for FW QUAL +CONFIG_LOG=n +CONFIG_LOG_MODE_MINIMAL=n +CONFIG_SHELL_MINIMAL=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=0 + +# AC_OK debounce time +CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 diff --git a/zephyr/program/corsola/prj_tentacruel.conf b/zephyr/program/corsola/prj_tentacruel.conf new file mode 100644 index 0000000000..71cc9d9694 --- /dev/null +++ b/zephyr/program/corsola/prj_tentacruel.conf @@ -0,0 +1,26 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_TENTACRUEL=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y + +# Sensor +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y + +# Battery +CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/program/corsola/src/board.c b/zephyr/program/corsola/src/board.c new file mode 100644 index 0000000000..93a2443191 --- /dev/null +++ b/zephyr/program/corsola/src/board.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "console.h" +#include "hooks.h" +#include "typec_control.h" +#include "usb_dp_alt_mode.h" +#include "usb_mux.h" +#include "usb_pd.h" +#include "usbc_ppc.h" + +#include "baseboard_usbc_config.h" + +#define CPRINTS(format, args...) cprints(CC_USB, format, ##args) + +static void ccd_interrupt_deferred(void) +{ + /* + * If CCD_MODE_ODL asserts, it means there's a debug accessory connected + * and we should enable the SBU FETs. + */ + typec_set_sbu(CONFIG_CCD_USBC_PORT_NUMBER, 1); + + /* Mux DP AUX away when CCD enabled to prevent the AUX channel + * interferes the SBU pins. + */ + CPRINTS("CCD Enabled, mux DP_AUX_PATH_SEL to 1"); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), 1); +} +DECLARE_DEFERRED(ccd_interrupt_deferred); + +void ccd_interrupt(enum gpio_signal signal) +{ + hook_call_deferred(&ccd_interrupt_deferred_data, 0); +} diff --git a/zephyr/program/corsola/src/board_chipset.c b/zephyr/program/corsola/src/board_chipset.c new file mode 100644 index 0000000000..54e96bc631 --- /dev/null +++ b/zephyr/program/corsola/src/board_chipset.c @@ -0,0 +1,49 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola baseboard-chipset specific configuration */ + +#include +#include +#include +#include "gpio.h" + +static void board_backlight_handler(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + int value; + + switch (data.event) { + default: + return; + + case AP_POWER_RESUME: + /* Called on AP S3 -> S0 transition */ + value = 1; + break; + + case AP_POWER_SUSPEND: + /* Called on AP S0 -> S3 transition */ + value = 0; + break; + } + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_bl_en_od), value); +} + +static int install_backlight_handler(const struct device *unused) +{ + static struct ap_power_ev_callback cb; + + /* + * Add a callback for suspend/resume to + * control the keyboard backlight. + */ + ap_power_ev_init_callback(&cb, board_backlight_handler, + AP_POWER_RESUME | AP_POWER_SUSPEND); + ap_power_ev_add_callback(&cb); + return 0; +} + +SYS_INIT(install_backlight_handler, APPLICATION, 1); diff --git a/zephyr/program/corsola/src/hibernate.c b/zephyr/program/corsola/src/hibernate.c new file mode 100644 index 0000000000..56c085e077 --- /dev/null +++ b/zephyr/program/corsola/src/hibernate.c @@ -0,0 +1,22 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include + +#include "charger.h" +#include "driver/charger/isl923x_public.h" +#include "system.h" + +/* Corsola board specific hibernate implementation */ +__override void board_hibernate(void) +{ +#ifdef CONFIG_CHARGER_ISL9238C + isl9238c_hibernate(CHARGER_SOLO); +#endif +} + +__override void board_hibernate_late(void) +{ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_ulp), 1); +} diff --git a/zephyr/program/corsola/src/kingler/board_steelix.c b/zephyr/program/corsola/src/kingler/board_steelix.c new file mode 100644 index 0000000000..8b88a6d7c7 --- /dev/null +++ b/zephyr/program/corsola/src/kingler/board_steelix.c @@ -0,0 +1,76 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Board re-init for Rusty board + * Rusty shares the firmware with Steelix. + * Steelix is convertible but Rusty is clamshell + * so some functions should be disabled for clamshell. + */ +#include +#include + +#include "accelgyro.h" +#include "common.h" +#include "cros_cbi.h" +#include "driver/accelgyro_bmi3xx.h" +#include "driver/accelgyro_lsm6dsm.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "motion_sense.h" +#include "motionsense_sensors.h" +#include "tablet_mode.h" + +LOG_MODULE_REGISTER(board_init, LOG_LEVEL_ERR); + +static bool board_is_clamshell; + +static void board_setup_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FORM_FACTOR, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR); + return; + } + if (val == CLAMSHELL) { + board_is_clamshell = true; + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + } +} +DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_PRE_DEFAULT); + +static void disable_base_imu_irq(void) +{ + if (board_is_clamshell) { + gpio_disable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_base_imu)); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(base_imu_int_l), + GPIO_INPUT | GPIO_PULL_UP); + } +} +DECLARE_HOOK(HOOK_INIT, disable_base_imu_irq, HOOK_PRIO_POST_DEFAULT); + +static bool base_use_alt_sensor; + +void motion_interrupt(enum gpio_signal signal) +{ + if (base_use_alt_sensor) { + lsm6dsm_interrupt(signal); + } else { + bmi3xx_interrupt(signal); + } +} + +static void alt_sensor_init(void) +{ + base_use_alt_sensor = cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); + + motion_sensors_check_ssfc(); +} +DECLARE_HOOK(HOOK_INIT, alt_sensor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/corsola/src/kingler/button.c b/zephyr/program/corsola/src/kingler/button.c new file mode 100644 index 0000000000..920069bef6 --- /dev/null +++ b/zephyr/program/corsola/src/kingler/button.c @@ -0,0 +1,35 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* kingler button */ + +#include "button.h" +#include "cros_board_info.h" +#include "gpio.h" +#include "hooks.h" + +static void buttons_hook(void) +{ + int version; + + if (cbi_get_board_version(&version)) { + return; + } + + /* b:219891339: drop this workaround when we deprecate rev0 */ + if (version == 0) { + /* swap VOLUP/VOLDN */ + button_reassign_gpio(BUTTON_VOLUME_DOWN, GPIO_VOLUME_UP_L); + button_reassign_gpio(BUTTON_VOLUME_UP, GPIO_VOLUME_DOWN_L); + /* + * button_reassign_gpio will disable the old button interrupt + * and then enable the new button interrupt which cause the + * GPIO_VOLUME_UP_L interrupt disabled after we reassign + * BUTTON_VOLUME_UP, so we need to re-enable it here. + */ + gpio_enable_interrupt(GPIO_VOLUME_UP_L); + } +} +DECLARE_HOOK(HOOK_INIT, buttons_hook, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/corsola/src/kingler/i2c.c b/zephyr/program/corsola/src/kingler/i2c.c new file mode 100644 index 0000000000..f2bbff3749 --- /dev/null +++ b/zephyr/program/corsola/src/kingler/i2c.c @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * 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 and Steelix board specific i2c implementation */ + +#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED +int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) +{ + return (i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) || + i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_EEPROM) || + i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_USB_C0)); +} +#endif diff --git a/zephyr/program/corsola/src/kingler/led.c b/zephyr/program/corsola/src/kingler/led.c new file mode 100644 index 0000000000..4e2c5b12fb --- /dev/null +++ b/zephyr/program/corsola/src/kingler/led.c @@ -0,0 +1,52 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery LED control for Kingler + */ +#include "common.h" +#include "ec_commands.h" +#include "led_common.h" +#include "led_onoff_states.h" +#include "led_pwm.h" + +__override const int led_charge_lvl_1 = 5; +__override const int led_charge_lvl_2 = 97; +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 3 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_RED: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_RED); + break; + case EC_LED_COLOR_GREEN: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_GREEN); + break; + case EC_LED_COLOR_AMBER: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); + break; + default: /* LED_OFF and other unsupported colors */ + set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); + break; + } +} diff --git a/zephyr/program/corsola/src/kingler/led_steelix.c b/zephyr/program/corsola/src/kingler/led_steelix.c new file mode 100644 index 0000000000..87b76128e8 --- /dev/null +++ b/zephyr/program/corsola/src/kingler/led_steelix.c @@ -0,0 +1,181 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery LED control for Steelix + */ + +#include +#include + +#include "board_led.h" +#include "common.h" +#include "cros_cbi.h" +#include "led_common.h" +#include "led_onoff_states.h" +#include "util.h" + +LOG_MODULE_REGISTER(board_led, LOG_LEVEL_ERR); + +#define BOARD_LED_PWM_PERIOD_NS BOARD_LED_HZ_TO_PERIOD_NS(100) + +static const struct board_led_pwm_dt_channel board_led_battery_red = + BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_red)); +static const struct board_led_pwm_dt_channel board_led_battery_green = + BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_green)); +static const struct board_led_pwm_dt_channel board_led_power_white = + BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_power_white)); + +__override const int led_charge_lvl_1 = 5; +__override const int led_charge_lvl_2 = 97; +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; + +__override const struct led_descriptor + led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { + [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, + [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, 0.5 * LED_ONE_SEC } }, + [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, + 0.5 * LED_ONE_SEC } }, + [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, + }; + +const enum ec_led_id supported_led_ids[] = { + EC_LED_ID_BATTERY_LED, + EC_LED_ID_POWER_LED, +}; + +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +static void board_led_pwm_set_duty(const struct board_led_pwm_dt_channel *ch, + int percent) +{ + uint32_t pulse_ns; + int rv; + + if (!device_is_ready(ch->dev)) { + LOG_ERR("PWM device %s not ready", ch->dev->name); + return; + } + + pulse_ns = DIV_ROUND_NEAREST(BOARD_LED_PWM_PERIOD_NS * percent, 100); + + LOG_DBG("Board LED PWM %s set percent (%d), pulse %d", ch->dev->name, + percent, pulse_ns); + + rv = pwm_set(ch->dev, ch->channel, BOARD_LED_PWM_PERIOD_NS, pulse_ns, + ch->flags); + if (rv) { + LOG_ERR("pwm_set() failed %s (%d)", ch->dev->name, rv); + } +} + +static bool device_is_clamshell(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FORM_FACTOR, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR); + return false; + } + + return val == CLAMSHELL; +} + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_RED: + board_led_pwm_set_duty(&board_led_battery_red, 100); + board_led_pwm_set_duty(&board_led_battery_green, 0); + break; + case EC_LED_COLOR_GREEN: + board_led_pwm_set_duty(&board_led_battery_red, 0); + board_led_pwm_set_duty(&board_led_battery_green, 100); + break; + case EC_LED_COLOR_AMBER: + board_led_pwm_set_duty(&board_led_battery_red, 100); + board_led_pwm_set_duty(&board_led_battery_green, 20); + break; + default: /* LED_OFF and other unsupported colors */ + board_led_pwm_set_duty(&board_led_battery_red, 0); + board_led_pwm_set_duty(&board_led_battery_green, 0); + break; + } +} + +__override void led_set_color_power(enum ec_led_colors color) +{ + if (device_is_clamshell()) { + board_led_pwm_set_duty(&board_led_power_white, 0); + } else { + switch (color) { + case EC_LED_COLOR_WHITE: + board_led_pwm_set_duty(&board_led_power_white, 100); + break; + default: + board_led_pwm_set_duty(&board_led_power_white, 0); + break; + } + } +} + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + if (led_id == EC_LED_ID_BATTERY_LED) { + brightness_range[EC_LED_COLOR_RED] = 1; + brightness_range[EC_LED_COLOR_GREEN] = 1; + brightness_range[EC_LED_COLOR_AMBER] = 1; + } else if (led_id == EC_LED_ID_POWER_LED) { + if (device_is_clamshell()) { + brightness_range[EC_LED_COLOR_WHITE] = 0; + } else { + brightness_range[EC_LED_COLOR_WHITE] = 1; + } + } +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + if (led_id == EC_LED_ID_BATTERY_LED) { + if (brightness[EC_LED_COLOR_RED] != 0) { + led_set_color_battery(EC_LED_COLOR_RED); + } else if (brightness[EC_LED_COLOR_GREEN] != 0) { + led_set_color_battery(EC_LED_COLOR_GREEN); + } else if (brightness[EC_LED_COLOR_AMBER] != 0) { + led_set_color_battery(EC_LED_COLOR_AMBER); + } else { + led_set_color_battery(LED_OFF); + } + } else if (led_id == EC_LED_ID_POWER_LED) { + if (brightness[EC_LED_COLOR_WHITE] != 0) { + led_set_color_power(EC_LED_COLOR_WHITE); + } else { + led_set_color_power(LED_OFF); + } + } + + return EC_SUCCESS; +} diff --git a/zephyr/program/corsola/src/kingler/usb_pd_policy.c b/zephyr/program/corsola/src/kingler/usb_pd_policy.c new file mode 100644 index 0000000000..3de2857ad1 --- /dev/null +++ b/zephyr/program/corsola/src/kingler/usb_pd_policy.c @@ -0,0 +1,74 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charge_manager.h" +#include "console.h" +#include "driver/ppc/rt1718s.h" +#include "system.h" +#include "usb_mux.h" +#include "usb_pd.h" +#include "usbc_ppc.h" +#include "util.h" + +#include "baseboard_usbc_config.h" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +void pd_power_supply_reset(int port) +{ + int prev_en; + + prev_en = ppc_is_sourcing_vbus(port); + + if (port == USBC_PORT_C1) { + rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 0); + } + + /* Disable VBUS. */ + ppc_vbus_source_enable(port, 0); + + /* Enable discharge if we were previously sourcing 5V */ + if (prev_en) { + pd_set_vbus_discharge(port, 1); + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + /* Disable charging. */ + rv = ppc_vbus_sink_enable(port, 0); + if (rv) { + return rv; + } + + pd_set_vbus_discharge(port, 0); + + /* Provide Vbus. */ + if (port == USBC_PORT_C1) { + rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 1); + } + + rv = ppc_vbus_source_enable(port, 1); + if (rv) { + return rv; + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +int pd_snk_is_vbus_provided(int port) +{ + /* TODO: use ADC? */ + return tcpm_check_vbus_level(port, VBUS_PRESENT); +} diff --git a/zephyr/program/corsola/src/kingler/usbc_config.c b/zephyr/program/corsola/src/kingler/usbc_config.c new file mode 100644 index 0000000000..7531904c4a --- /dev/null +++ b/zephyr/program/corsola/src/kingler/usbc_config.c @@ -0,0 +1,318 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Kingler board-specific USB-C configuration */ + +#include "charger.h" +#include "console.h" +#include "driver/bc12/pi3usb9201_public.h" +#include "driver/charger/isl923x_public.h" +#include "driver/ppc/nx20p348x.h" +#include "driver/ppc/rt1718s.h" +#include "driver/tcpm/anx7447.h" +#include "driver/tcpm/rt1718s.h" +#include "driver/usb_mux/ps8743.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "timer.h" +#include "usb_charge.h" +#include "usb_mux.h" +#include "usb_pd_tcpm.h" +#include "usbc_ppc.h" + +#include "baseboard_usbc_config.h" +#include "variant_db_detection.h" + +/* TODO(b/220196310): Create GPIO driver for RT17181S TCPC */ +#ifdef __REQUIRE_ZEPHYR_GPIOS__ +#undef __REQUIRE_ZEPHYR_GPIOS__ +#endif +#include "gpio.h" + +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) + +/* USB Mux */ + +/* USB Mux C1 : board_init of PS8743 */ +int ps8743_mux_1_board_init(const struct usb_mux *me) +{ + ps8743_tune_usb_eq(me, PS8743_USB_EQ_TX_3_6_DB, + PS8743_USB_EQ_RX_16_0_DB); + + return EC_SUCCESS; +} + +void board_usb_mux_init(void) +{ + if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { + /* Disable DCI function. This is not needed for ARM. */ + ps8743_field_update(usb_muxes[1].mux, PS8743_REG_DCI_CONFIG_2, + PS8743_AUTO_DCI_MODE_MASK, + PS8743_AUTO_DCI_MODE_FORCE_USB); + } +} +DECLARE_HOOK(HOOK_INIT, board_usb_mux_init, HOOK_PRIO_INIT_I2C + 1); + +void board_tcpc_init(void) +{ + /* Only reset TCPC if not sysjump */ + if (!system_jumped_late()) { + /* TODO(crosbug.com/p/61098): How long do we need to wait? */ + board_reset_pd_mcu(); + } + + /* Enable TCPC interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); + if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc)); + } + + /* Enable BC1.2 interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); + + /* + * Initialize HPD to low; after sysjump SOC needs to see + * HPD pulse to enable video path + */ + for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) { + usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | + USB_PD_MUX_HPD_IRQ_DEASSERTED); + } +} +DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C); + +__override int board_rt1718s_init(int port) +{ + static bool gpio_initialized; + + if (!system_jumped_late() && !gpio_initialized) { + /* set GPIO 1~3 as push pull, as output, output low. */ + rt1718s_gpio_set_flags(port, RT1718S_GPIO1, GPIO_OUT_LOW); + rt1718s_gpio_set_flags(port, RT1718S_GPIO2, GPIO_OUT_LOW); + rt1718s_gpio_set_flags(port, RT1718S_GPIO3, GPIO_OUT_LOW); + gpio_initialized = true; + } + + /* gpio1 low, gpio2 output high when receiving frs signal */ + RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO1_VBUS_CTRL, + RT1718S_GPIO1_VBUS_CTRL_FRS_RX_VBUS, + 0)); + RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO2_VBUS_CTRL, + RT1718S_GPIO2_VBUS_CTRL_FRS_RX_VBUS, + 0xFF)); + + /* Trigger GPIO 1/2 change when FRS signal received */ + RETURN_ERROR(rt1718s_update_bits8( + port, RT1718S_FRS_CTRL3, + RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 | + RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1, + RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 | + RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1)); + /* Set FRS signal detect time to 46.875us */ + RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_FRS_CTRL1, + RT1718S_FRS_CTRL1_FRSWAPRX_MASK, + 0xFF)); + + /* Disable BC1.2 SRC mode */ + RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_RT2_BC12_SRC_FUNC, + RT1718S_RT2_BC12_SRC_FUNC_BC12_SRC_EN, + 0)); + + return EC_SUCCESS; +} + +__override int board_rt1718s_set_frs_enable(int port, int enable) +{ + if (port == USBC_PORT_C1) + /* + * Use set_flags (implemented by a single i2c write) instead + * of set_level (= i2c_update) to save one read operation in + * FRS path. + */ + rt1718s_gpio_set_flags(port, GPIO_EN_USB_C1_FRS, + enable ? GPIO_OUT_HIGH : GPIO_OUT_LOW); + return EC_SUCCESS; +} + +void board_reset_pd_mcu(void) +{ + CPRINTS("Resetting TCPCs..."); + /* reset C0 ANX3447 */ + /* Assert reset */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst), 1); + msleep(1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst), 0); + /* After TEST_R release, anx7447/3447 needs 2ms to finish eFuse + * loading. + */ + msleep(2); + + /* reset C1 RT1718s */ + rt1718s_sw_reset(USBC_PORT_C1); +} + +/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */ +int board_vbus_source_enabled(int port) +{ + return ppc_is_sourcing_vbus(port); +} + +__override int board_rt1718s_set_snk_enable(int port, int enable) +{ + if (port == USBC_PORT_C1) { + rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SINK, enable); + } + + return EC_SUCCESS; +} + +int board_set_active_charge_port(int port) +{ + int i; + bool is_valid_port = + (port >= 0 && port < board_get_adjusted_usb_pd_port_count()); + /* adjust the actual port count when not the type-c db connected. */ + + if (!is_valid_port && port != CHARGE_PORT_NONE) { + return EC_ERROR_INVAL; + } + + if (port == CHARGE_PORT_NONE) { + CPRINTS("Disabling all charger ports"); + + /* Disable all ports. */ + for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (ppc_vbus_sink_enable(i, 0)) { + CPRINTS("Disabling C%d as sink failed.", i); + } + } + + return EC_SUCCESS; + } + + /* Check if the port is sourcing VBUS. */ + if (ppc_is_sourcing_vbus(port)) { + CPRINTS("Skip enable C%d", port); + return EC_ERROR_INVAL; + } + + CPRINTS("New charge port: C%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { + if (i == port) { + continue; + } + + if (ppc_vbus_sink_enable(i, 0)) { + CPRINTS("C%d: sink path disable failed.", i); + } + } + + /* Enable requested charge port. */ + if (ppc_vbus_sink_enable(port, 1)) { + CPRINTS("C%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + + if (!gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) { + if (!gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst))) { + status |= PD_STATUS_TCPC_ALERT_0; + } + } + + if (!gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) { + return status |= PD_STATUS_TCPC_ALERT_1; + } + return status; +} + +void tcpc_alert_event(enum gpio_signal signal) +{ + int port; + + switch (signal) { + case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_tcpc_int_odl)): + port = 0; + break; + case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_tcpc_int_odl)): + port = 1; + break; + default: + return; + } + + schedule_deferred_pd_interrupt(port); +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_ppc_int_odl)): + ppc_chips[0].drv->interrupt(0); + break; + case GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl)): + ppc_chips[1].drv->interrupt(1); + break; + default: + break; + } +} + +void bc12_interrupt(enum gpio_signal signal) +{ + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); +} + +__override int board_get_vbus_voltage(int port) +{ + int voltage = 0; + int rv; + + switch (port) { + case USBC_PORT_C0: + rv = tcpc_config[USBC_PORT_C0].drv->get_vbus_voltage(port, + &voltage); + if (rv) + return 0; + break; + case USBC_PORT_C1: + rt1718s_get_adc(port, RT1718S_ADC_VBUS1, &voltage); + break; + default: + return 0; + } + return voltage; +} + +__override int board_nx20p348x_init(int port) +{ + int rv; + + rv = i2c_update8(ppc_chips[port].i2c_port, + ppc_chips[port].i2c_addr_flags, + NX20P348X_DEVICE_CONTROL_REG, NX20P348X_CTRL_LDO_SD, + MASK_SET); + return rv; +} diff --git a/zephyr/program/corsola/src/krabby/charger_workaround.c b/zephyr/program/corsola/src/krabby/charger_workaround.c new file mode 100644 index 0000000000..d7fd05cc00 --- /dev/null +++ b/zephyr/program/corsola/src/krabby/charger_workaround.c @@ -0,0 +1,93 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charger.h" +#include "driver/charger/rt9490.h" +#include "hooks.h" +#include "i2c.h" +#include "system.h" + +/* + * This workaround and the board id checks only apply to krabby and early + * tentacruel devices. + * Newer project should have all of these fixed. + */ +BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_KRABBY) || + IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST)); + +/* b/194967754#comment5: work around for IBUS ADC unstable issue */ +static void ibus_adc_workaround(void) +{ + if (system_get_board_version() != 0) { + return; + } + + i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, + chg_chips[CHARGER_SOLO].i2c_addr_flags, + RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_SET); + + rt9490_enable_hidden_mode(CHARGER_SOLO, true); + /* undocumented registers... */ + i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, + chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x52, 0xC4); + + i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, + chg_chips[CHARGER_SOLO].i2c_addr_flags, + RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_CLR); + rt9490_enable_hidden_mode(CHARGER_SOLO, false); +} + +/* b/214880220#comment44: lock i2c at 400khz */ +static void i2c_speed_workaround(void) +{ + if (system_get_board_version() >= 3) { + return; + } + + rt9490_enable_hidden_mode(CHARGER_SOLO, true); + /* Set to Auto mode, default run at 400kHz */ + i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, + chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x71, 0x22); + /* Manually select for 400kHz, valid only when 0x71[7] == 1 */ + i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, + chg_chips[CHARGER_SOLO].i2c_addr_flags, 0xF7, 0x14); + rt9490_enable_hidden_mode(CHARGER_SOLO, false); +} + +static void eoc_deglitch_workaround(void) +{ + if (system_get_board_version() != 1) { + return; + } + + /* set end-of-charge deglitch time to 2ms */ + i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, + chg_chips[CHARGER_SOLO].i2c_addr_flags, + RT9490_REG_ADD_CTRL0, RT9490_TD_EOC, MASK_CLR); +} + +static void disable_safety_timer(void) +{ + if (system_get_board_version() >= 2) { + return; + } + /* Disable charge timer */ + i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, + chg_chips[CHARGER_SOLO].i2c_addr_flags, + RT9490_REG_SAFETY_TMR_CTRL, + RT9490_EN_TRICHG_TMR | RT9490_EN_PRECHG_TMR | + RT9490_EN_FASTCHG_TMR); +} + +static void board_rt9490_workaround(void) +{ + ibus_adc_workaround(); + i2c_speed_workaround(); + eoc_deglitch_workaround(); + disable_safety_timer(); +} +DECLARE_HOOK(HOOK_INIT, board_rt9490_workaround, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/corsola/src/krabby/hooks.c b/zephyr/program/corsola/src/krabby/hooks.c new file mode 100644 index 0000000000..1eb4f600f2 --- /dev/null +++ b/zephyr/program/corsola/src/krabby/hooks.c @@ -0,0 +1,90 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include +#include "charger.h" +#include "driver/charger/rt9490.h" +#include "extpower.h" +#include "gpio.h" +#include "hooks.h" + +#define I2C3_NODE DT_NODELABEL(i2c3) +PINCTRL_DT_DEFINE(I2C3_NODE); + +static void board_i2c3_ctrl(bool enable) +{ + if (DEVICE_DT_GET( + DT_GPIO_CTLR_BY_IDX(DT_NODELABEL(i2c3), scl_gpios, 0)) == + DEVICE_DT_GET(DT_NODELABEL(gpiof))) { + const struct pinctrl_dev_config *pcfg = + PINCTRL_DT_DEV_CONFIG_GET(I2C3_NODE); + + if (enable) { + pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT); + } else { + pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP); + } + } +} + +static void board_enable_i2c3(void) +{ + board_i2c3_ctrl(1); +} +DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_enable_i2c3, HOOK_PRIO_FIRST); + +static void board_disable_i2c3(void) +{ + board_i2c3_ctrl(0); +} +DECLARE_HOOK(HOOK_CHIPSET_HARD_OFF, board_disable_i2c3, HOOK_PRIO_LAST); + +static void board_suspend_handler(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + int value; + + switch (data.event) { + default: + return; + + case AP_POWER_RESUME: + value = 1; + break; + + case AP_POWER_SUSPEND: + value = 0; + break; + } + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_5v_usm), value); +} + +static int install_suspend_handler(const struct device *unused) +{ + static struct ap_power_ev_callback cb; + + /* + * Add a callback for suspend/resume. + */ + ap_power_ev_init_callback(&cb, board_suspend_handler, + AP_POWER_RESUME | AP_POWER_SUSPEND); + ap_power_ev_add_callback(&cb); + return 0; +} + +SYS_INIT(install_suspend_handler, APPLICATION, 1); + +static void board_hook_ac_change(void) +{ + if (system_get_board_version() >= 1) { + rt9490_enable_adc(CHARGER_SOLO, extpower_is_present()); + } +} +DECLARE_HOOK(HOOK_AC_CHANGE, board_hook_ac_change, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_INIT, board_hook_ac_change, HOOK_PRIO_LAST); diff --git a/zephyr/program/corsola/src/krabby/i2c.c b/zephyr/program/corsola/src/krabby/i2c.c new file mode 100644 index 0000000000..a83af77dbd --- /dev/null +++ b/zephyr/program/corsola/src/krabby/i2c.c @@ -0,0 +1,19 @@ +/* Copyright 2021 The ChromiumOS Authors + * 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" + +/* Krabby board specific i2c implementation */ + +#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED +int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) +{ + return (i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) || + i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_EEPROM)); +} +#endif diff --git a/zephyr/program/corsola/src/krabby/keyboard_magikarp.c b/zephyr/program/corsola/src/krabby/keyboard_magikarp.c new file mode 100644 index 0000000000..bcb706bba3 --- /dev/null +++ b/zephyr/program/corsola/src/krabby/keyboard_magikarp.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config magikarp_kb_legacy = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &magikarp_kb_legacy; +} diff --git a/zephyr/program/corsola/src/krabby/ppc_krabby.c b/zephyr/program/corsola/src/krabby/ppc_krabby.c new file mode 100644 index 0000000000..d4f574a725 --- /dev/null +++ b/zephyr/program/corsola/src/krabby/ppc_krabby.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Krabby PPC/BC12 (RT1739) configuration */ + +#include "baseboard_usbc_config.h" +#include "gpio/gpio_int.h" +#include "driver/ppc/rt1739.h" +#include "driver/ppc/syv682x.h" +#include "hooks.h" +#include "variant_db_detection.h" + +void c0_bc12_interrupt(enum gpio_signal signal) +{ + rt1739_interrupt(0); +} + +static void board_usbc_init(void) +{ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc_bc12)); +} +DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT); + +void ppc_interrupt(enum gpio_signal signal) +{ + if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) { + syv682x_interrupt(1); + } +} diff --git a/zephyr/program/corsola/src/krabby/ppc_magikarp.c b/zephyr/program/corsola/src/krabby/ppc_magikarp.c new file mode 100644 index 0000000000..41cce3f73d --- /dev/null +++ b/zephyr/program/corsola/src/krabby/ppc_magikarp.c @@ -0,0 +1,44 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Tentacruel PPC/BC12 (mixed RT1739 or PI3USB9201+SYV682X) configuration */ + +#include "baseboard_usbc_config.h" +#include "console.h" +#include "cros_board_info.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "usbc/ppc.h" +#include "variant_db_detection.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) + +void bc12_interrupt(enum gpio_signal signal) +{ + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); +} + +static void board_usbc_init(void) +{ + /* Enable PPC interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); + + /* Enable BC1.2 interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); +} +DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT); + +void ppc_interrupt(enum gpio_signal signal) +{ + if (signal == GPIO_SIGNAL(DT_NODELABEL(usb_c0_ppc_int_odl))) { + syv682x_interrupt(0); + } else if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) { + syv682x_interrupt(1); + } +} diff --git a/zephyr/program/corsola/src/krabby/ppc_tentacruel.c b/zephyr/program/corsola/src/krabby/ppc_tentacruel.c new file mode 100644 index 0000000000..877b9940b4 --- /dev/null +++ b/zephyr/program/corsola/src/krabby/ppc_tentacruel.c @@ -0,0 +1,89 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Tentacruel PPC/BC12 (mixed RT1739 or PI3USB9201+SYV682X) configuration */ + +#include "baseboard_usbc_config.h" +#include "console.h" +#include "cros_board_info.h" +#include "driver/usb_mux/ps8743.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "usb_mux.h" +#include "usbc/ppc.h" +#include "variant_db_detection.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) + +LOG_MODULE_REGISTER(alt_dev_replacement); + +#define BOARD_VERSION_UNKNOWN 0xffffffff + +/* Check board version to decide which ppc/bc12 is used. */ +static bool board_has_syv_ppc(void) +{ + static uint32_t board_version = BOARD_VERSION_UNKNOWN; + + if (board_version == BOARD_VERSION_UNKNOWN) { + if (cbi_get_board_version(&board_version) != EC_SUCCESS) { + LOG_ERR("Failed to get board version."); + board_version = 0; + } + } + + return (board_version >= 3); +} + +static void check_alternate_devices(void) +{ + /* Configure the PPC driver */ + if (board_has_syv_ppc()) + /* Arg is the USB port number */ + PPC_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT); + +void bc12_interrupt(enum gpio_signal signal) +{ + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); +} + +/* USB Mux C1 : board_init of PS8743 */ +int ps8743_eq_c1_setting(void) +{ + ps8743_write(usb_muxes[1].mux, PS8743_REG_USB_EQ_RX, 0x90); + return EC_SUCCESS; +} + +static void board_usbc_init(void) +{ + if (board_has_syv_ppc()) { + /* Enable PPC interrupts. */ + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); + + /* Enable BC1.2 interrupts. */ + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); + } else { + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); + } +} +DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT); + +void ppc_interrupt(enum gpio_signal signal) +{ + if (signal == GPIO_SIGNAL(DT_NODELABEL(usb_c0_ppc_int_odl))) { + ppc_chips[0].drv->interrupt(0); + } + if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) { + ppc_chips[1].drv->interrupt(1); + } +} diff --git a/zephyr/program/corsola/src/krabby/sensor_magikarp.c b/zephyr/program/corsola/src/krabby/sensor_magikarp.c new file mode 100644 index 0000000000..269bc26fae --- /dev/null +++ b/zephyr/program/corsola/src/krabby/sensor_magikarp.c @@ -0,0 +1,41 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "accelgyro.h" +#include "cros_cbi.h" +#include "driver/accelgyro_bmi323.h" +#include "driver/accelgyro_icm42607.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +void motion_interrupt(enum gpio_signal signal) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_BASE_GYRO, &val); + if (val == FW_BASE_ICM42607) { + icm42607_interrupt(signal); + } else if (val == FW_BASE_BMI323) { + bmi3xx_interrupt(signal); + } +} + +static void motionsense_init(void) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_BASE_GYRO, &val); + if (val == FW_BASE_ICM42607) { + ccprints("BASE ACCEL is ICM42607"); + } else if (val == FW_BASE_BMI323) { + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro); + ccprints("BASE ACCEL IS BMI323"); + } else { + ccprints("no motionsense"); + } +} +DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/corsola/src/krabby/sensor_tentacruel.c b/zephyr/program/corsola/src/krabby/sensor_tentacruel.c new file mode 100644 index 0000000000..269bc26fae --- /dev/null +++ b/zephyr/program/corsola/src/krabby/sensor_tentacruel.c @@ -0,0 +1,41 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "accelgyro.h" +#include "cros_cbi.h" +#include "driver/accelgyro_bmi323.h" +#include "driver/accelgyro_icm42607.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +void motion_interrupt(enum gpio_signal signal) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_BASE_GYRO, &val); + if (val == FW_BASE_ICM42607) { + icm42607_interrupt(signal); + } else if (val == FW_BASE_BMI323) { + bmi3xx_interrupt(signal); + } +} + +static void motionsense_init(void) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_BASE_GYRO, &val); + if (val == FW_BASE_ICM42607) { + ccprints("BASE ACCEL is ICM42607"); + } else if (val == FW_BASE_BMI323) { + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro); + ccprints("BASE ACCEL IS BMI323"); + } else { + ccprints("no motionsense"); + } +} +DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/corsola/src/krabby/temp_tentacruel.c b/zephyr/program/corsola/src/krabby/temp_tentacruel.c new file mode 100644 index 0000000000..5d2c304f76 --- /dev/null +++ b/zephyr/program/corsola/src/krabby/temp_tentacruel.c @@ -0,0 +1,129 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charger.h" +#include "charge_state.h" +#include "common.h" +#include "config.h" +#include "console.h" +#include "driver/charger/rt9490.h" +#include "hooks.h" +#include "temp_sensor/temp_sensor.h" +#include "thermal.h" +#include "util.h" + +#define NUM_CURRENT_LEVELS ARRAY_SIZE(current_table) +#define TEMP_THRESHOLD 50 +#define TEMP_BUFF_SIZE 60 +#define KEEP_TIME 5 + +BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST)); +/* calculate current average temperature */ +static int average_tempature(void) +{ + static int temp_history_buffer[TEMP_BUFF_SIZE]; + static int buff_ptr; + static int temp_sum; + static int past_temp; + static int avg_temp; + int cur_temp, t; + + temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)), &t); + cur_temp = K_TO_C(t); + past_temp = temp_history_buffer[buff_ptr]; + temp_history_buffer[buff_ptr] = cur_temp; + temp_sum = temp_sum + temp_history_buffer[buff_ptr] - past_temp; + buff_ptr++; + if (buff_ptr >= TEMP_BUFF_SIZE) { + buff_ptr = 0; + } + /* Calculate per minute temperature. + * It's expected low temperature when the first 60 seconds. + */ + avg_temp = temp_sum / TEMP_BUFF_SIZE; + return avg_temp; +} + +static int current_level; + +/* Limit charging current table : 3600/3000/2400/1800 + * note this should be in descending order. + */ +static uint16_t current_table[] = { + 3600, + 3000, + 2400, + 1600, +}; + +/* Called by hook task every hook second (1 sec) */ +static void current_update(void) +{ + int temp; + static uint8_t uptime; + static uint8_t dntime; + + temp = average_tempature(); +#ifndef CONFIG_TEST + if (charge_get_state() == PWR_STATE_DISCHARGE) { + current_level = 0; + uptime = 0; + dntime = 0; + return; + } +#endif + if (temp >= TEMP_THRESHOLD) { + dntime = 0; + if (uptime < KEEP_TIME) { + uptime++; + } else { + uptime = 0; + current_level++; + } + } else if (current_level != 0 && temp < TEMP_THRESHOLD) { + uptime = 0; + if (dntime < KEEP_TIME) { + dntime++; + } else { + dntime = 0; + current_level--; + } + } else { + uptime = 0; + dntime = 0; + } + if (current_level > NUM_CURRENT_LEVELS) { + current_level = NUM_CURRENT_LEVELS; + } +} +DECLARE_HOOK(HOOK_SECOND, current_update, HOOK_PRIO_DEFAULT); + +int charger_profile_override(struct charge_state_data *curr) +{ + /* + * Precharge must be executed when communication is failed on + * dead battery. + */ + if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE)) + return 0; + if (current_level != 0) { + if (curr->requested_current > current_table[current_level - 1]) + curr->requested_current = + current_table[current_level - 1]; + } + return 0; +} + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} diff --git a/zephyr/program/corsola/src/krabby/usb_pd_policy.c b/zephyr/program/corsola/src/krabby/usb_pd_policy.c new file mode 100644 index 0000000000..8f2a2c3515 --- /dev/null +++ b/zephyr/program/corsola/src/krabby/usb_pd_policy.c @@ -0,0 +1,88 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "adc.h" +#include "charge_manager.h" +#include "chipset.h" +#include "usb_charge.h" +#include "usb_pd.h" +#include "usbc_ppc.h" + +int pd_snk_is_vbus_provided(int port) +{ + static atomic_t vbus_prev[CONFIG_USB_PD_PORT_MAX_COUNT]; + int vbus; + + /* + * (b:181203590#comment20) TODO(yllin): use + * PD_VSINK_DISCONNECT_PD for non-5V case. + */ + vbus = adc_read_channel(board_get_vbus_adc(port)) >= + PD_V_SINK_DISCONNECT_MAX; + +#ifdef CONFIG_USB_CHARGER + /* + * There's no PPC to inform VBUS change for usb_charger, so inform + * the usb_charger now. + */ + if (!!(vbus_prev[port] != vbus)) { + usb_charger_vbus_change(port, vbus); + } + + if (vbus) { + atomic_or(&vbus_prev[port], 1); + } else { + atomic_clear(&vbus_prev[port]); + } +#endif + return vbus; +} + +void pd_power_supply_reset(int port) +{ + int prev_en; + + prev_en = ppc_is_sourcing_vbus(port); + + /* Disable VBUS. */ + ppc_vbus_source_enable(port, 0); + + /* Enable discharge if we were previously sourcing 5V */ + if (prev_en) { + pd_set_vbus_discharge(port, 1); + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + /* Disable charging. */ + rv = ppc_vbus_sink_enable(port, 0); + if (rv) { + return rv; + } + + pd_set_vbus_discharge(port, 0); + + /* Provide Vbus. */ + rv = ppc_vbus_source_enable(port, 1); + if (rv) { + return rv; + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +int board_vbus_source_enabled(int port) +{ + return ppc_is_sourcing_vbus(port); +} diff --git a/zephyr/program/corsola/src/krabby/usbc_config.c b/zephyr/program/corsola/src/krabby/usbc_config.c new file mode 100644 index 0000000000..8e03e8dbad --- /dev/null +++ b/zephyr/program/corsola/src/krabby/usbc_config.c @@ -0,0 +1,145 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Krabby board-specific USB-C configuration */ + +#include "adc.h" +#include "baseboard_usbc_config.h" +#include "charge_manager.h" +#include "console.h" +#include "driver/tcpm/it83xx_pd.h" +#include "driver/usb_mux/tusb1064.h" +#include "i2c.h" +#include "usb_pd.h" +#include "usbc_ppc.h" + +#include "variant_db_detection.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) + +int tusb1064_mux_1_board_init(const struct usb_mux *me) +{ + int rv; + + rv = i2c_write8(me->i2c_port, me->i2c_addr_flags, + TUSB1064_REG_DP1DP3EQ_SEL, + TUSB1064_DP1EQ(TUSB1064_DP_EQ_RX_8_9_DB) | + TUSB1064_DP3EQ(TUSB1064_DP_EQ_RX_5_4_DB)); + if (rv) + return rv; + + /* Enable EQ_OVERRIDE so the gain registers are used */ + return i2c_update8(me->i2c_port, me->i2c_addr_flags, + TUSB1064_REG_GENERAL, REG_GENERAL_EQ_OVERRIDE, + MASK_SET); +} + +#ifdef CONFIG_USB_PD_TCPM_ITE_ON_CHIP +const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port) +{ + const static struct cc_para_t + cc_parameter[CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT] = { + { + .rising_time = + IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, + .falling_time = + IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, + }, + { + .rising_time = + IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, + .falling_time = + IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, + }, + }; + + return &cc_parameter[port]; +} +#endif + +void board_reset_pd_mcu(void) +{ + /* + * C0 & C1: TCPC is embedded in the EC and processes interrupts in the + * chip code (it83xx/intc.c) + */ +} + +#ifndef CONFIG_TEST +int board_set_active_charge_port(int port) +{ + int i; + int is_valid_port = + (port >= 0 && port < board_get_adjusted_usb_pd_port_count()); + /* adjust the actual port count when not the type-c db connected. */ + + if (!is_valid_port && port != CHARGE_PORT_NONE) { + return EC_ERROR_INVAL; + } + + if (port == CHARGE_PORT_NONE) { + CPRINTS("Disabling all charger ports"); + + /* Disable all ports. */ + for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (ppc_vbus_sink_enable(i, 0)) { + CPRINTS("Disabling C%d as sink failed.", i); + } + } + + return EC_SUCCESS; + } + + /* Check if the port is sourcing VBUS. */ + if (ppc_is_sourcing_vbus(port)) { + CPRINTS("Skip enable C%d", port); + return EC_ERROR_INVAL; + } + + CPRINTS("New charge port: C%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { + if (i == port) { + continue; + } + + if (ppc_vbus_sink_enable(i, 0)) { + CPRINTS("C%d: sink path disable failed.", i); + } + } + + /* Enable requested charge port. */ + if (ppc_vbus_sink_enable(port, 1)) { + CPRINTS("C%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} +#endif + +#ifdef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT +enum adc_channel board_get_vbus_adc(int port) +{ + if (port == 0) { + return ADC_VBUS_C0; + } + if (port == 1) { + return ADC_VBUS_C1; + } + CPRINTSUSB("Unknown vbus adc port id: %d", port); + return ADC_VBUS_C0; +} +#endif /* CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT */ diff --git a/zephyr/program/corsola/src/usb_pd_policy.c b/zephyr/program/corsola/src/usb_pd_policy.c new file mode 100644 index 0000000000..a885362c61 --- /dev/null +++ b/zephyr/program/corsola/src/usb_pd_policy.c @@ -0,0 +1,226 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "atomic.h" +#include "console.h" +#include "chipset.h" +#include "hooks.h" +#include "timer.h" +#include "typec_control.h" +#include "usb_dp_alt_mode.h" +#include "usb_mux.h" +#include "usb_pd.h" +#include "usbc_ppc.h" + +#include "baseboard_usbc_config.h" + +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) + +static int active_aux_port = -1; + +int pd_check_vconn_swap(int port) +{ + /* Allow Vconn swap if AP is on. */ + return chipset_in_state(CHIPSET_STATE_SUSPEND | CHIPSET_STATE_ON); +} + +static void set_dp_aux_path_sel(int port) +{ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), port); + CPRINTS("Set DP_AUX_PATH_SEL: %d", port); +} + +int svdm_get_hpd_gpio(int port) +{ + /* HPD is low active, inverse the result */ + return !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl)); +} + +static void reset_aux_deferred(void) +{ + if (active_aux_port == -1) + /* reset to 1 for lower power consumption. */ + set_dp_aux_path_sel(1); +} +DECLARE_DEFERRED(reset_aux_deferred); + +void svdm_set_hpd_gpio(int port, int en) +{ + /* + * HPD is low active, inverse the en. + * + * Implement FCFS policy: + * 1) Enable hpd if no active port. + * 2) Disable hpd if active port is the given port. + */ + if (en && active_aux_port < 0) { + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), 0); + active_aux_port = port; + hook_call_deferred(&reset_aux_deferred_data, -1); + } + + if (!en && active_aux_port == port) { + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), 1); + active_aux_port = -1; + /* + * This might be a HPD debounce to send a HPD IRQ (500us), so + * do not reset the aux path immediately. Defer this call and + * re-check if this is a real disable. + */ + hook_call_deferred(&reset_aux_deferred_data, 1 * MSEC); + } +} + +__override int svdm_dp_config(int port, uint32_t *payload) +{ + int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); + uint8_t pin_mode = get_dp_pin_mode(port); + mux_state_t mux_mode = svdm_dp_get_mux_mode(port); + int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]); + + if (!pin_mode) { + return 0; + } + + CPRINTS("pin_mode: %x, mf: %d, mux: %d", pin_mode, mf_pref, mux_mode); + /* + * Defer setting the usb_mux until HPD goes high, svdm_dp_attention(). + * The AP only supports one DP phy. An external DP mux switches between + * the two ports. Should switch those muxes when it is really used, + * i.e. HPD high; otherwise, the real use case is preempted, like: + * (1) plug a dongle without monitor connected to port-0, + * (2) plug a dongle without monitor connected to port-1, + * (3) plug a monitor to the port-1 dongle. + */ + + payload[0] = + VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); + payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ + 1, /* DPv1.3 signaling */ + 2); /* UFP connected */ + return 2; +}; + +__override void svdm_dp_post_config(int port) +{ + mux_state_t mux_mode = svdm_dp_get_mux_mode(port); + + typec_set_sbu(port, true); + + /* + * Prior to post-config, the mux will be reset to safe mode, and this + * will break mux config and aux path config we did in the first DP + * status command. Only enable this if the port is the current aux-port. + */ + if (port == active_aux_port) { + usb_mux_set(port, mux_mode, USB_SWITCH_CONNECT, + polarity_rm_dts(pd_get_polarity(port))); + usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL | + USB_PD_MUX_HPD_IRQ_DEASSERTED); + } + + dp_flags[port] |= DP_FLAGS_DP_ON; +} + +int corsola_is_dp_muxable(int port) +{ + int i; + + for (i = 0; i < board_get_usb_pd_port_count(); i++) { + if (i != port) { + if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED) { + return 0; + } + } + } + + return 1; +} + +__override int svdm_dp_attention(int port, uint32_t *payload) +{ + int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); + int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); +#ifdef CONFIG_USB_PD_DP_HPD_GPIO + int cur_lvl = svdm_get_hpd_gpio(port); +#endif /* CONFIG_USB_PD_DP_HPD_GPIO */ + mux_state_t mux_state; + + dp_status[port] = payload[1]; + + if (!corsola_is_dp_muxable(port)) { + /* TODO(waihong): Info user? */ + CPRINTS("p%d: The other port is already muxed.", port); + return 0; /* nak */ + } + + if (lvl) { + set_dp_aux_path_sel(port); + + usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT, + polarity_rm_dts(pd_get_polarity(port))); + } else { + usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, + polarity_rm_dts(pd_get_polarity(port))); + } + + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) { + /* + * Wake up the AP. IRQ or level high indicates a DP sink is now + * present. + */ + if (IS_ENABLED(CONFIG_MKBP_EVENT)) { + pd_notify_dp_alt_mode_entry(port); + } + } + +#ifdef CONFIG_USB_PD_DP_HPD_GPIO + if (irq && !lvl) { + /* + * IRQ can only be generated when the level is high, because + * the IRQ is signaled by a short low pulse from the high level. + */ + CPRINTF("ERR:HPD:IRQ&LOW\n"); + return 0; /* nak */ + } + + if (irq && cur_lvl) { + uint64_t now = get_time().val; + /* wait for the minimum spacing between IRQ_HPD if needed */ + if (now < svdm_hpd_deadline[port]) { + usleep(svdm_hpd_deadline[port] - now); + } + + /* generate IRQ_HPD pulse */ + svdm_set_hpd_gpio(port, 0); + /* + * b/171172053#comment14: since the HPD_DSTREAM_DEBOUNCE_IRQ is + * very short (500us), we can use udelay instead of usleep for + * more stable pulse period. + */ + udelay(HPD_DSTREAM_DEBOUNCE_IRQ); + svdm_set_hpd_gpio(port, 1); + } else { + svdm_set_hpd_gpio(port, lvl); + } + + /* set the minimum time delay (2ms) for the next HPD IRQ */ + svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; +#endif /* CONFIG_USB_PD_DP_HPD_GPIO */ + + mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) | + (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED); + usb_mux_hpd_update(port, mux_state); + +#ifdef USB_PD_PORT_TCPC_MST + if (port == USB_PD_PORT_TCPC_MST) { + baseboard_mst_enable_control(port, lvl); + } +#endif + + /* ack */ + return 1; +} diff --git a/zephyr/program/corsola/src/usbc_config.c b/zephyr/program/corsola/src/usbc_config.c new file mode 100644 index 0000000000..b776bc1ca9 --- /dev/null +++ b/zephyr/program/corsola/src/usbc_config.c @@ -0,0 +1,258 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola baseboard-specific USB-C configuration */ + +#include +#include + +#include "adc.h" +#include "baseboard_usbc_config.h" +#include "button.h" +#include "charger.h" +#include "charge_state_v2.h" +#include "console.h" +#include "ec_commands.h" +#include "extpower.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "i2c.h" +#include "lid_switch.h" +#include "task.h" +#include "ppc/syv682x_public.h" +#include "power.h" +#include "power_button.h" +#include "spi.h" +#include "switch.h" +#include "tablet_mode.h" +#include "uart.h" +#include "usb_charge.h" +#include "usb_mux.h" +#include "usb_pd_tcpm.h" +#include "usb_tc_sm.h" +#include "usbc/usb_muxes.h" +#include "usbc_ppc.h" + +#include "variant_db_detection.h" + +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) + +/* a flag for indicating the tasks are inited. */ +static bool tasks_inited; + +/* Baseboard */ +static void baseboard_init(void) +{ +#ifdef CONFIG_VARIANT_CORSOLA_USBA + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usba)); +#endif + /* If CCD mode has enabled before init, force the ccd_interrupt. */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ccd_mode_odl))) { + ccd_interrupt(GPIO_CCD_MODE_ODL); + } + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode_odl)); +} +DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_PRE_DEFAULT); + +__override uint8_t board_get_usb_pd_port_count(void) +{ + /* This function returns the PORT_COUNT+1 when HDMI db is connected. + * This is a trick to ensure the usb_mux_set being set properley. + * HDMI display functions using the USB virtual mux to * communicate + * with the DP bridge. + */ + if (corsola_get_db_type() == CORSOLA_DB_HDMI) { + if (tasks_inited) { + return CONFIG_USB_PD_PORT_MAX_COUNT; + } else { + return CONFIG_USB_PD_PORT_MAX_COUNT - 1; + } + } else if (corsola_get_db_type() == CORSOLA_DB_NONE) { + return CONFIG_USB_PD_PORT_MAX_COUNT - 1; + } + + return CONFIG_USB_PD_PORT_MAX_COUNT; +} + +uint8_t board_get_adjusted_usb_pd_port_count(void) +{ + if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { + return CONFIG_USB_PD_PORT_MAX_COUNT; + } else { + return CONFIG_USB_PD_PORT_MAX_COUNT - 1; + } +} + +/* USB-A */ +void usb_a0_interrupt(enum gpio_signal signal) +{ + enum usb_charge_mode mode = gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( + gpio_ap_xhci_init_done)) ? + USB_CHARGE_MODE_ENABLED : + USB_CHARGE_MODE_DISABLED; + + const int xhci_stat = gpio_get_level(signal); + + for (int i = 0; i < USB_PORT_COUNT; i++) { + usb_charge_set_mode(i, mode, USB_ALLOW_SUSPEND_CHARGE); + } + + for (int i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + /* + * Enable DRP toggle after XHCI inited. This is used to follow + * USB 3.2 spec 10.3.1.1. + */ + if (xhci_stat) { + pd_set_dual_role(i, PD_DRP_TOGGLE_ON); + } else if (tc_is_attached_src(i)) { + /* + * This is a AP reset S0->S0 transition. + * We should set the role back to sink. + */ + pd_set_dual_role(i, PD_DRP_FORCE_SINK); + } + } +} + +__override enum pd_dual_role_states pd_get_drp_state_in_s0(void) +{ + if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ap_xhci_init_done))) { + return PD_DRP_TOGGLE_ON; + } else { + return PD_DRP_FORCE_SINK; + } +} + +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + int icl = charge_ma * 97 / 100; + /* + * b:257167723: Adapter output current exceeds the spec on heavy-load. + * Preserve a margin in case of charger overdraw. + */ + charge_set_input_current_limit(icl, charge_mv); +} + +void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) +{ + /* + * We ignore the cc_pin and PPC vconn because polarity and PPC vconn + * should already be set correctly in the PPC driver via the pd + * state machine. + */ +} + +/* HDMI/TYPE-C function shared subboard interrupt */ +void x_ec_interrupt(enum gpio_signal signal) +{ + int sub = corsola_get_db_type(); + + if (sub == CORSOLA_DB_TYPEC) { + /* C1: PPC interrupt */ + ppc_interrupt(signal); + } else if (sub == CORSOLA_DB_HDMI) { + hdmi_hpd_interrupt(signal); + } else { + CPRINTS("Undetected subboard interrupt."); + } +} + +static void board_hdmi_handler(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + int value; + + switch (data.event) { + default: + return; + + case AP_POWER_RESUME: + value = 1; + break; + + case AP_POWER_SUSPEND: + value = 0; + break; + } + gpio_pin_set_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr), value); + gpio_pin_set_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl), value); +} + +static void tasks_init_deferred(void) +{ + tasks_inited = true; + if (corsola_get_db_type() == CORSOLA_DB_HDMI) { + /* If the HDMI port is plugged on-boot, and the usb_mux won't + * be configured before the task inited. Re-invoke the + * HPD configuration after task inited. + */ + ps185_hdmi_hpd_mux_set(); + } +} +DECLARE_DEFERRED(tasks_init_deferred); + +static void baseboard_x_ec_gpio2_init(void) +{ + static struct ppc_drv virtual_ppc_drv = { 0 }; + static struct tcpm_drv virtual_tcpc_drv = { 0 }; + static struct bc12_drv virtual_bc12_drv = { 0 }; + + /* no sub board */ + if (corsola_get_db_type() == CORSOLA_DB_NONE) { + return; + } + + /* type-c: USB_C1_PPC_INT_ODL / hdmi: PS185_EC_DP_HPD */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); + + if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { + gpio_pin_interrupt_configure_dt( + GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl), + GPIO_INT_EDGE_FALLING); + return; + } + if (corsola_get_db_type() == CORSOLA_DB_HDMI) { + static struct ap_power_ev_callback cb; + + ap_power_ev_init_callback(&cb, board_hdmi_handler, + AP_POWER_RESUME | AP_POWER_SUSPEND); + ap_power_ev_add_callback(&cb); + } + + /* drop related C1 port drivers when it's a HDMI DB. */ + ppc_chips[USBC_PORT_C1] = + (const struct ppc_config_t){ .drv = &virtual_ppc_drv }; + tcpc_config[USBC_PORT_C1] = + (const struct tcpc_config_t){ .drv = &virtual_tcpc_drv }; + bc12_ports[USBC_PORT_C1] = + (const struct bc12_config){ .drv = &virtual_bc12_drv }; + /* Use virtual mux to notify AP the mainlink direction. */ + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_hdmi_db); + + /* + * If a HDMI DB is attached, C1 port tasks will be exiting in that + * the port number is larger than board_get_usb_pd_port_count(). + * After C1 port tasks finished, we intentionally increase the port + * count by 1 for usb_mux to access the C1 virtual mux for notifying + * mainlink direction. + */ + hook_call_deferred(&tasks_init_deferred_data, 2 * SECOND); +} +DECLARE_HOOK(HOOK_INIT, baseboard_x_ec_gpio2_init, HOOK_PRIO_DEFAULT); + +__override uint8_t get_dp_pin_mode(int port) +{ + if (corsola_get_db_type() == CORSOLA_DB_HDMI && port == USBC_PORT_C1) { + if (usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED) { + return MODE_DP_PIN_E; + } else { + return 0; + } + } + + return pd_dfp_dp_get_pin_mode(port, dp_status[port]); +} diff --git a/zephyr/program/corsola/src/variant_db_detection.c b/zephyr/program/corsola/src/variant_db_detection.c new file mode 100644 index 0000000000..f68d9c8fad --- /dev/null +++ b/zephyr/program/corsola/src/variant_db_detection.c @@ -0,0 +1,211 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola daughter board detection */ +#include + +#include "baseboard_usbc_config.h" +#include "console.h" +#include "cros_cbi.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "usb_mux.h" + +#include "variant_db_detection.h" + +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) + +#ifdef TEST_BUILD +uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; +#endif + +static void corsola_db_config(enum corsola_db_type type) +{ + switch (type) { + case CORSOLA_DB_HDMI: + /* EC_X_GPIO1 */ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr), + GPIO_OUTPUT_HIGH); + /* X_EC_GPIO2 */ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd), + GPIO_INPUT); + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); + /* EC_X_GPIO3 */ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl), + GPIO_OUTPUT_HIGH | GPIO_OPEN_DRAIN); + return; + case CORSOLA_DB_TYPEC: + /* EC_X_GPIO1 */ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_frs_en), + GPIO_OUTPUT_LOW); + /* X_EC_GPIO2 */ + gpio_pin_configure_dt( + GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl), + GPIO_INPUT | GPIO_PULL_UP); + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); + /* EC_X_GPIO3 */ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_dp_in_hpd), + GPIO_OUTPUT_LOW); + return; + case CORSOLA_DB_NONE: + /* Set floating pins as input with PU to prevent leakage */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio1), + GPIO_INPUT | GPIO_PULL_UP); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_x_ec_gpio2), + GPIO_INPUT | GPIO_PULL_UP); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio3), + GPIO_INPUT | GPIO_PULL_UP); + return; + default: + break; + } +} + +enum corsola_db_type corsola_get_db_type(void) +{ +#if DT_NODE_EXISTS(DT_NODELABEL(db_config)) + int ret; + uint32_t val; +#endif + static enum corsola_db_type db = CORSOLA_DB_UNINIT; + + if (db != CORSOLA_DB_UNINIT) { + return db; + } + + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_hdmi_prsnt_odl))) { + db = CORSOLA_DB_HDMI; + } else { + db = CORSOLA_DB_TYPEC; + } + +/* Detect for no sub board case by FW_CONFIG */ +#if DT_NODE_EXISTS(DT_NODELABEL(db_config)) + ret = cros_cbi_get_fw_config(DB, &val); + if (ret != 0) { + CPRINTS("Error retrieving CBI FW_CONFIG field %d", DB); + } else if (val == DB_NONE) { + db = CORSOLA_DB_NONE; + } +#endif + + corsola_db_config(db); + + switch (db) { + case CORSOLA_DB_NONE: + CPRINTS("Detect %s DB", "NONE"); + break; + case CORSOLA_DB_TYPEC: + CPRINTS("Detect %s DB", "TYPEC"); + break; + case CORSOLA_DB_HDMI: + CPRINTS("Detect %s DB", "HDMI"); + break; + default: + CPRINTS("DB UNINIT"); + break; + } + + return db; +} + +static void corsola_db_init(void) +{ + corsola_get_db_type(); +} +DECLARE_HOOK(HOOK_INIT, corsola_db_init, HOOK_PRIO_PRE_I2C); + +/** + * Handle PS185 HPD changing state. + */ +void ps185_hdmi_hpd_mux_set(void) +{ + const int hpd = + gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); + + if (!corsola_is_dp_muxable(USBC_PORT_C1)) { + return; + } + + if (hpd && !(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { + dp_status[USBC_PORT_C1] = + VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ + 0, /* HPD level ... not applicable */ + 0, /* exit DP? ... no */ + 0, /* usb mode? ... no */ + 0, /* multi-function ... no */ + 1, /* DP enabled ... yes */ + 0, /* power low? ... no */ + (!!DP_FLAGS_DP_ON)); + /* update C1 virtual mux */ + usb_mux_set(USBC_PORT_C1, USB_PD_MUX_DP_ENABLED, + USB_SWITCH_DISCONNECT, + 0 /* polarity, don't care */); + CPRINTS("HDMI plug"); + } +} + +static void ps185_hdmi_hpd_deferred(void) +{ + const int hpd = + gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); + + if (!hpd && (usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { + dp_status[USBC_PORT_C1] = + VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ + 0, /* HPD level ... not applicable */ + 0, /* exit DP? ... no */ + 0, /* usb mode? ... no */ + 0, /* multi-function ... no */ + 0, /* DP enabled ... no */ + 0, /* power low? ... no */ + (!DP_FLAGS_DP_ON)); + usb_mux_set(USBC_PORT_C1, USB_PD_MUX_NONE, + USB_SWITCH_DISCONNECT, + 0 /* polarity, don't care */); + CPRINTS("HDMI unplug"); + + return; + } + + ps185_hdmi_hpd_mux_set(); +} +DECLARE_DEFERRED(ps185_hdmi_hpd_deferred); + +#define HPD_SINK_ABSENCE_DEBOUNCE (2 * MSEC) + +void hdmi_hpd_interrupt(enum gpio_signal signal) +{ + const int hpd = + gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); + + if (!hpd) { + hook_call_deferred(&ps185_hdmi_hpd_deferred_data, + HPD_SINK_ABSENCE_DEBOUNCE); + } else { + hook_call_deferred(&ps185_hdmi_hpd_deferred_data, -1); + } + + /* C0 DP is muxed, we should not send HPD to the AP */ + if (!corsola_is_dp_muxable(USBC_PORT_C1)) { + if (hpd) { + CPRINTS("C0 port is already muxed."); + } + return; + } + + if (hpd && !(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { + /* set dp_aux_path_sel first, and configure the usb_mux in the + * deferred hook to prevent from dead locking. + */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), hpd); + hook_call_deferred(&ps185_hdmi_hpd_deferred_data, 0); + } + + svdm_set_hpd_gpio(USBC_PORT_C1, hpd); +} diff --git a/zephyr/program/corsola/thermistor_tentacruel.dts b/zephyr/program/corsola/thermistor_tentacruel.dts new file mode 100644 index 0000000000..f9e5306f24 --- /dev/null +++ b/zephyr/program/corsola/thermistor_tentacruel.dts @@ -0,0 +1,140 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + thermistor_rt9490: thermistor-rt9490 { + status = "okay"; + compatible = "cros-ec,thermistor"; + scaling-factor = <3>; + num-pairs = <21>; + steinhart-reference-mv = <4900>; + steinhart-reference-res = <10000>; + + sample-datum-0 { + milivolt = <(731 / 3)>; + temp = <0>; + sample-index = <0>; + }; + + sample-datum-1 { + milivolt = <(708 / 3)>; + temp = <5>; + sample-index = <1>; + }; + + sample-datum-2 { + milivolt = <(682 / 3)>; + temp = <10>; + sample-index = <2>; + }; + + sample-datum-3 { + milivolt = <(653 / 3)>; + temp = <15>; + sample-index = <3>; + }; + + sample-datum-4 { + milivolt = <(622 / 3)>; + temp = <20>; + sample-index = <4>; + }; + + sample-datum-5 { + milivolt = <(589 / 3)>; + temp = <25>; + sample-index = <5>; + }; + + sample-datum-6 { + milivolt = <(554 / 3)>; + temp = <30>; + sample-index = <6>; + }; + + sample-datum-7 { + milivolt = <(519 / 3)>; + temp = <35>; + sample-index = <7>; + }; + + sample-datum-8 { + milivolt = <(483 / 3)>; + temp = <40>; + sample-index = <8>; + }; + + sample-datum-9 { + milivolt = <(446 / 3)>; + temp = <45>; + sample-index = <9>; + }; + + sample-datum-10 { + milivolt = <(411 / 3)>; + temp = <50>; + sample-index = <10>; + }; + sample-datum-11 { + milivolt = <(376 / 3)>; + temp = <55>; + sample-index = <11>; + }; + + sample-datum-12 { + milivolt = <(343 / 3)>; + temp = <60>; + sample-index = <12>; + }; + + sample-datum-13 { + milivolt = <(312 / 3)>; + temp = <65>; + sample-index = <13>; + }; + + sample-datum-14 { + milivolt = <(284 / 3)>; + temp = <70>; + sample-index = <14>; + }; + + sample-datum-15 { + milivolt = <(257 / 3)>; + temp = <75>; + sample-index = <15>; + }; + + sample-datum-16 { + milivolt = <(232 / 3)>; + temp = <80>; + sample-index = <16>; + }; + + sample-datum-17 { + milivolt = <(209 / 3)>; + temp = <85>; + sample-index = <17>; + }; + + sample-datum-18 { + milivolt = <(188 / 3)>; + temp = <90>; + sample-index = <18>; + }; + + sample-datum-19 { + milivolt = <(169 / 3)>; + temp = <95>; + sample-index = <19>; + }; + + sample-datum-20 { + milivolt = <(152 / 3)>; + temp = <100>; + sample-index = <20>; + }; + }; +}; diff --git a/zephyr/program/corsola/usba.dts b/zephyr/program/corsola/usba.dts new file mode 100644 index 0000000000..2ecb3b7d5a --- /dev/null +++ b/zephyr/program/corsola/usba.dts @@ -0,0 +1,11 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usba_port_enable_list: usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&en_pp5000_usb_a0_vbus>; + }; +}; diff --git a/zephyr/program/corsola/usba_steelix.dts b/zephyr/program/corsola/usba_steelix.dts new file mode 100644 index 0000000000..0ddd67f664 --- /dev/null +++ b/zephyr/program/corsola/usba_steelix.dts @@ -0,0 +1,10 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* steelix usba port enable config */ +&usba_port_enable_list { + enable-pins = <&en_pp5000_usb_a0_vbus + &en_pp5000_usb_a1_vbus>; +}; diff --git a/zephyr/program/corsola/usbc_kingler.dts b/zephyr/program/corsola/usbc_kingler.dts new file mode 100644 index 0000000000..18bc6ce303 --- /dev/null +++ b/zephyr/program/corsola/usbc_kingler.dts @@ -0,0 +1,56 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + tcpc = <&tcpc_port0>; + ppc = <&ppc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&anx7447_mux_0 &virtual_mux_0>; + }; + }; + + port0-muxes { + anx7447_mux_0: anx7447-mux-0 { + compatible = "analogix,usbc-mux-anx7447"; + }; + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + tcpc = <&tcpc_port1>; + ppc = <&ppc_port1>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/usbc_krabby.dts b/zephyr/program/corsola/usbc_krabby.dts new file mode 100644 index 0000000000..a72864da35 --- /dev/null +++ b/zephyr/program/corsola/usbc_krabby.dts @@ -0,0 +1,59 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_ppc_port0>; + ppc = <&bc12_ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; diff --git a/zephyr/program/corsola/usbc_magikarp.dts b/zephyr/program/corsola/usbc_magikarp.dts new file mode 100644 index 0000000000..c94db15b3a --- /dev/null +++ b/zephyr/program/corsola/usbc_magikarp.dts @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; diff --git a/zephyr/program/corsola/usbc_tentacruel.dts b/zephyr/program/corsola/usbc_tentacruel.dts new file mode 100644 index 0000000000..bb105a8e08 --- /dev/null +++ b/zephyr/program/corsola/usbc_tentacruel.dts @@ -0,0 +1,60 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&bc12_ppc_port0>; + ppc_alt = <&ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; diff --git a/zephyr/program/herobrine/BUILD.py b/zephyr/program/herobrine/BUILD.py new file mode 100644 index 0000000000..0bee6ffe2a --- /dev/null +++ b/zephyr/program/herobrine/BUILD.py @@ -0,0 +1,49 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for herobrine.""" + + +def register_variant( + project_name, +): + """Register a variant of herobrine.""" + register_npcx_project( + project_name=project_name, + zephyr_board="npcx9m3f", + dts_overlays=[ + here / project_name / "project.overlay", + ], + kconfig_files=[ + # Common to all projects. + here / "program.conf", + # Project-specific KConfig customization. + here / project_name / "project.conf", + ], + ) + + +register_variant( + project_name="evoker", +) + +register_variant( + project_name="herobrine", +) + +register_variant( + project_name="hoglin", +) + +register_variant( + project_name="villager", +) + +register_variant( + project_name="zoglin", +) + +register_variant( + project_name="zombie", +) diff --git a/zephyr/program/herobrine/CMakeLists.txt b/zephyr/program/herobrine/CMakeLists.txt new file mode 100644 index 0000000000..90a49a053e --- /dev/null +++ b/zephyr/program/herobrine/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") + +cros_ec_library_include_directories(include) + +# Common Herobrine implementation +zephyr_library_sources( + "src/board_chipset.c" +) + +# Board specific implementation +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/usbc_config.c" + "src/usb_pd_policy.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C + "src/i2c.c") + +if(DEFINED CONFIG_BOARD_EVOKER) + project(evoker) +elseif(DEFINED CONFIG_BOARD_HEROBRINE) + project(herobrine) + add_subdirectory(herobrine) +elseif(DEFINED CONFIG_BOARD_HOGLIN) + project(hoglin) +elseif(DEFINED CONFIG_BOARD_VILLAGER) + project(villager) +elseif(DEFINED CONFIG_BOARD_ZOGLIN) + project(zoglin) +elseif(DEFINED CONFIG_BOARD_ZOMBIE) + project(zombie) +endif() diff --git a/zephyr/program/herobrine/Kconfig b/zephyr/program/herobrine/Kconfig new file mode 100644 index 0000000000..d0056288d5 --- /dev/null +++ b/zephyr/program/herobrine/Kconfig @@ -0,0 +1,41 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config BOARD_EVOKER + bool "Evoker Board" + help + Build the Evoker board. The board is based on the Herobrine + reference design. + +config BOARD_HEROBRINE + bool "Google Herobrine Baseboard" + help + Build Google Herobrine reference board. The board uses Nuvoton + NPCX9 chip as the EC. + +config BOARD_HOGLIN + bool "Qualcomm Hoglin Baseboard" + help + Build Qualcomm Hoglin reference board. The board uses Nuvoton + NPCX9 chip as the EC. + +config BOARD_VILLAGER + bool "Villager Board" + help + Build the Villager board. The board is based on the Herobrine + reference design. + +config BOARD_ZOGLIN + bool "Qualcomm Zoglin Baseboard" + help + Build Qualcomm Zoglin reference board. The board uses Nuvoton + NPCX9 chip as the EC. + +config BOARD_ZOMBIE + bool "Zombie Board" + help + Build the Zombie board. The board is based on the Herobrine + reference design. + +source "Kconfig.zephyr" diff --git a/zephyr/program/herobrine/adc.dtsi b/zephyr/program/herobrine/adc.dtsi new file mode 100644 index 0000000000..16a5434e9d --- /dev/null +++ b/zephyr/program/herobrine/adc.dtsi @@ -0,0 +1,47 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + vbus { + enum-name = "ADC_VBUS"; + io-channels = <&adc0 1>; + /* Measure VBUS through a 1/10 voltage divider */ + mul = <10>; + }; + amon_bmon { + enum-name = "ADC_AMON_BMON"; + io-channels = <&adc0 2>; + /* + * Adapter current output or battery charging/ + * discharging current (uV) 18x amplification on + * charger side. + */ + mul = <1000>; + div = <18>; + }; + psys { + enum-name = "ADC_PSYS"; + io-channels = <&adc0 3>; + /* + * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor, + * to read 0.8V @ 99 W, i.e. 124000 uW/mV. + */ + mul = <124000>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/herobrine/common.dtsi b/zephyr/program/herobrine/common.dtsi new file mode 100644 index 0000000000..a722f1dfa2 --- /dev/null +++ b/zephyr/program/herobrine/common.dtsi @@ -0,0 +1,44 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + chosen { + cros,rtc = &pcf85063a; + }; + + ec-console { + compatible = "ec-console"; + disabled = "hostcmd"; + }; + + ec-mkbp-host-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <( + HOST_EVENT_LID_OPEN | + HOST_EVENT_POWER_BUTTON | + HOST_EVENT_AC_CONNECTED | + HOST_EVENT_AC_DISCONNECTED | + HOST_EVENT_HANG_DETECT | + HOST_EVENT_RTC | + HOST_EVENT_MODE_CHANGE | + HOST_EVENT_DEVICE)>; + }; + + ec-mkbp-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \ + MKBP_EVENT_HOST_EVENT | \ + MKBP_EVENT_SENSOR_FIFO)>; + }; +}; + +&shi { + status = "okay"; + pinctrl-0 = <&shi_gp46_47_53_55>; + pinctrl-1 = <&shi_gpio_gp46_47_53_55>; + pinctrl-names = "default", "sleep"; +}; diff --git a/zephyr/program/herobrine/default_gpio_pinctrl.dtsi b/zephyr/program/herobrine/default_gpio_pinctrl.dtsi new file mode 100644 index 0000000000..604658a145 --- /dev/null +++ b/zephyr/program/herobrine/default_gpio_pinctrl.dtsi @@ -0,0 +1,44 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ +&{/def-io-conf-list} { + pinmux = <&alt0_gpio_no_spip + &alt0_gpio_no_fpip + &alt1_no_pwrgd + &alt1_no_lpc_espi + &alta_no_peci_en + &altd_npsl_in1_sl + &altd_npsl_in2_sl + &altd_psl_in3_sl + &altd_psl_in4_sl + &alt7_no_ksi0_sl + &alt7_no_ksi1_sl + &alt7_no_ksi2_sl + &alt7_no_ksi3_sl + &alt7_no_ksi4_sl + &alt7_no_ksi5_sl + &alt7_no_ksi6_sl + &alt7_no_ksi7_sl + &alt8_no_kso00_sl + &alt8_no_kso01_sl + &alt8_no_kso02_sl + &alt8_no_kso03_sl + &alt8_no_kso04_sl + &alt8_no_kso05_sl + &alt8_no_kso06_sl + &alt8_no_kso07_sl + &alt9_no_kso08_sl + &alt9_no_kso09_sl + &alt9_no_kso10_sl + &alt9_no_kso11_sl + &alt9_no_kso12_sl + &alt9_no_kso13_sl + &alt9_no_kso14_sl + &alt9_no_kso15_sl + &alta_no_kso16_sl + &alta_no_kso17_sl + &altg_psl_gpo_sl>; +}; diff --git a/zephyr/program/herobrine/display.dtsi b/zephyr/program/herobrine/display.dtsi new file mode 100644 index 0000000000..65d3a2d91b --- /dev/null +++ b/zephyr/program/herobrine/display.dtsi @@ -0,0 +1,18 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + displight { + compatible = "cros-ec,displight"; + pwms = <&pwm5 0 PWM_HZ(4800) PWM_POLARITY_NORMAL>; + generic-pwm-channel = <1>; + }; +}; + +&pwm5 { + status = "okay"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/herobrine/evoker/battery.dtsi b/zephyr/program/herobrine/evoker/battery.dtsi new file mode 100644 index 0000000000..0e09616c1d --- /dev/null +++ b/zephyr/program/herobrine/evoker/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: pc_vp_bp153 { + compatible = "smp,pc-vp-bp153", "battery-smart"; + }; + ap16l5j { + compatible = "panasonic,ap16l5j", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/herobrine/evoker/gpio.dtsi b/zephyr/program/herobrine/evoker/gpio.dtsi new file mode 100644 index 0000000000..d60fdf93c7 --- /dev/null +++ b/zephyr/program/herobrine/evoker/gpio.dtsi @@ -0,0 +1,329 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { + #led-pin-cells = <1>; + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpio5 0 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; diff --git a/zephyr/program/herobrine/evoker/i2c.dtsi b/zephyr/program/herobrine/evoker/i2c.dtsi new file mode 100644 index 0000000000..6de6863f60 --- /dev/null +++ b/zephyr/program/herobrine/evoker/i2c.dtsi @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + ppc_port0_alt: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; + +&i2c2_0 { + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + ppc_port1_alt: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; diff --git a/zephyr/program/herobrine/evoker/led_pins.dtsi b/zephyr/program/herobrine/evoker/led_pins.dtsi new file mode 100644 index 0000000000..ff2dc0e36c --- /dev/null +++ b/zephyr/program/herobrine/evoker/led_pins.dtsi @@ -0,0 +1,54 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_power_off: color-power-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&gpio_ec_chg_led_w_c1 0>; + }; + + color_power_white: color-power-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&gpio_ec_chg_led_w_c1 1>; + }; + + color_battery_off: color-battery-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 0>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_battery_amber: color-battery-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 1>, + <&gpio_ec_chg_led_w_c0 0>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_battery_white: color-battery-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 1>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_battery_red: color-battery-red { + led-color = "LED_RED"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 0>, + <&gpio_ec_chg_led_r_c0 1>; + }; + }; +}; diff --git a/zephyr/program/herobrine/evoker/led_policy.dtsi b/zephyr/program/herobrine/evoker/led_policy.dtsi new file mode 100644 index 0000000000..fc17755ede --- /dev/null +++ b/zephyr/program/herobrine/evoker/led_policy.dtsi @@ -0,0 +1,86 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + battery-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + battery-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + battery-state-discharge { + charge-state = "PWR_STATE_DISCHARGE"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + + battery-state-error { + charge-state = "PWR_STATE_ERROR"; + + color-0 { + led-color = <&color_battery_red>; + }; + }; + + /* force idle mode */ + battery-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Red 1 sec, White 1 sec */ + color-0 { + led-color = <&color_battery_red>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + }; + + pwr-power-state-s0 { + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_power_white>; + }; + }; + + power-state-s3 { + chipset-state = "POWER_S3"; + + /* white LED - on 1 sec, off 1 sec */ + color-0 { + led-color = <&color_power_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_power_off>; + period-ms = <1000>; + }; + }; + + power-state-s5 { + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_power_off>; + }; + }; + }; +}; diff --git a/zephyr/program/herobrine/evoker/motionsense.dtsi b/zephyr/program/herobrine/evoker/motionsense.dtsi new file mode 100644 index 0000000000..aa7646e0b3 --- /dev/null +++ b/zephyr/program/herobrine/evoker/motionsense.dtsi @@ -0,0 +1,148 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma4xx_data>; + i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/herobrine/evoker/project.conf b/zephyr/program/herobrine/evoker/project.conf new file mode 100644 index 0000000000..b4a5fce160 --- /dev/null +++ b/zephyr/program/herobrine/evoker/project.conf @@ -0,0 +1,16 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Evoker board-specific Kconfig settings. +CONFIG_BOARD_EVOKER=y + +# Disable type-c port sourcing 3A +CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0 + +CONFIG_PLATFORM_EC_ACCEL_BMA255=n +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y + +# ISL9238C disable the CMOUT latch function. +CONFIG_PLATFORM_EC_ISL9238C_DISABLE_CMOUT_LATCH=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y \ No newline at end of file diff --git a/zephyr/program/herobrine/evoker/project.overlay b/zephyr/program/herobrine/evoker/project.overlay new file mode 100644 index 0000000000..5731bf3312 --- /dev/null +++ b/zephyr/program/herobrine/evoker/project.overlay @@ -0,0 +1,22 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" +#include "../display.dtsi" +#include "../switchcap.dtsi" + +/* Evoker project DTS includes*/ +#include "battery.dtsi" +#include "gpio.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/program/herobrine/evoker/usbc.dtsi b/zephyr/program/herobrine/evoker/usbc.dtsi new file mode 100644 index 0000000000..20bd48382f --- /dev/null +++ b/zephyr/program/herobrine/evoker/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/program/herobrine/gpio.dtsi b/zephyr/program/herobrine/gpio.dtsi new file mode 100644 index 0000000000..a355aaf099 --- /dev/null +++ b/zephyr/program/herobrine/gpio.dtsi @@ -0,0 +1,329 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { + #led-pin-cells = <1>; + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { + #led-pin-cells = <1>; + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpio5 0 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; \ No newline at end of file diff --git a/zephyr/program/herobrine/herobrine/CMakeLists.txt b/zephyr/program/herobrine/herobrine/CMakeLists.txt new file mode 100644 index 0000000000..5524db7215 --- /dev/null +++ b/zephyr/program/herobrine/herobrine/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/alt_dev_replacement.c") diff --git a/zephyr/program/herobrine/herobrine/battery.dtsi b/zephyr/program/herobrine/herobrine/battery.dtsi new file mode 100644 index 0000000000..b347ec4c3c --- /dev/null +++ b/zephyr/program/herobrine/herobrine/battery.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: ap16l5j { + compatible = "panasonic,ap16l5j", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/herobrine/herobrine/i2c.dtsi b/zephyr/program/herobrine/herobrine/i2c.dtsi new file mode 100644 index 0000000000..6f2d89aa71 --- /dev/null +++ b/zephyr/program/herobrine/herobrine/i2c.dtsi @@ -0,0 +1,39 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + ppc_port0_alt: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; + +&i2c2_0 { + ppc_port1: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; diff --git a/zephyr/program/herobrine/herobrine/led_pins.dtsi b/zephyr/program/herobrine/herobrine/led_pins.dtsi new file mode 100644 index 0000000000..c509ab1a64 --- /dev/null +++ b/zephyr/program/herobrine/herobrine/led_pins.dtsi @@ -0,0 +1,56 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off_left: color-off-left { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_LEFT_LED"; + led-pins = <&gpio_ec_chg_led_y_c1 0>, + <&gpio_ec_chg_led_w_c1 0>; + }; + + color_off_right: color-off-right { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_RIGHT_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 0>; + }; + + color_amber_left: color-amber-left { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_LEFT_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c1 1>, + <&gpio_ec_chg_led_w_c1 0>; + }; + + color_amber_right: color-amber-right { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_RIGHT_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c0 1>, + <&gpio_ec_chg_led_w_c0 0>; + }; + + color_white_left: color-white-left { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_LEFT_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&gpio_ec_chg_led_y_c1 0>, + <&gpio_ec_chg_led_w_c1 1>; + }; + + color_white_right: color-white-right { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_RIGHT_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_w_c0 1>; + }; + }; +}; diff --git a/zephyr/program/herobrine/herobrine/led_policy.dtsi b/zephyr/program/herobrine/herobrine/led_policy.dtsi new file mode 100644 index 0000000000..13e5306deb --- /dev/null +++ b/zephyr/program/herobrine/herobrine/led_policy.dtsi @@ -0,0 +1,202 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge-left { + charge-state = "PWR_STATE_CHARGE"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED to Amber */ + color-1 { + led-color = <&color_amber_left>; + }; + }; + + power-state-charge-right { + charge-state = "PWR_STATE_CHARGE"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED to Amber */ + color-1 { + led-color = <&color_amber_right>; + }; + }; + + power-state-discharge-right-low { + charge-state = "PWR_STATE_DISCHARGE"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED - White 1 sec, off 3 sec */ + color-1 { + led-color = <&color_white_right>; + period-ms = <1000>; + }; + color-2 { + led-color = <&color_off_right>; + period-ms = <3000>; + }; + }; + + power-state-discharge-right { + charge-state = "PWR_STATE_DISCHARGE"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Turn off the right LED */ + color-1 { + led-color = <&color_off_right>; + }; + }; + + power-state-error-left { + charge-state = "PWR_STATE_ERROR"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED - White 2 sec, off 2 sec */ + color-1 { + led-color = <&color_white_left>; + period-ms = <2000>; + }; + color-2 { + led-color = <&color_off_right>; + period-ms = <2000>; + }; + }; + + power-state-error-right { + charge-state = "PWR_STATE_ERROR"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED - White 2 sec, off 2 sec */ + color-1 { + led-color = <&color_white_right>; + period-ms = <2000>; + }; + color-2 { + led-color = <&color_off_right>; + period-ms = <2000>; + }; + }; + + power-state-near-full-left { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED to White */ + color-1 { + led-color = <&color_white_left>; + }; + }; + + power-state-near-full-right { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED to White */ + color-1 { + led-color = <&color_white_right>; + }; + }; + + power-state-forced-idle-left { + charge-state = "PWR_STATE_FORCED_IDLE"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED - Amber 3 sec, Off 1 sec */ + color-1 { + led-color = <&color_amber_left>; + period-ms = <3000>; + }; + color-2 { + led-color = <&color_off_left>; + period-ms = <1000>; + }; + }; + + power-state-forced-idle-right { + charge-state = "PWR_STATE_FORCED_IDLE"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED - Amber 3 sec, Off 1 sec */ + color-1 { + led-color = <&color_amber_right>; + period-ms = <3000>; + }; + color-2 { + led-color = <&color_off_right>; + period-ms = <1000>; + }; + }; + + power-state-idle-left { + charge-state = "PWR_STATE_IDLE"; + charge-port = <1>; /* Left port */ + + /* Turn off the right LED */ + color-0 { + led-color = <&color_off_right>; + }; + /* Left LED to White */ + color-1 { + led-color = <&color_white_left>; + }; + }; + + power-state-idle-right { + charge-state = "PWR_STATE_IDLE"; + charge-port = <0>; /* Right port */ + + /* Turn off the left LED */ + color-0 { + led-color = <&color_off_left>; + }; + /* Right LED to White */ + color-1 { + led-color = <&color_white_right>; + }; + }; + }; +}; diff --git a/zephyr/program/herobrine/herobrine/project.conf b/zephyr/program/herobrine/herobrine/project.conf new file mode 100644 index 0000000000..bf39f65692 --- /dev/null +++ b/zephyr/program/herobrine/herobrine/project.conf @@ -0,0 +1,13 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Herobrine-NPCX9 reference-board-specific Kconfig settings. +CONFIG_BOARD_HEROBRINE=y + +# Sensors +CONFIG_PLATFORM_EC_ALS=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ALS_TCS3400=y +CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/program/herobrine/herobrine/project.overlay b/zephyr/program/herobrine/herobrine/project.overlay new file mode 100644 index 0000000000..a74db66815 --- /dev/null +++ b/zephyr/program/herobrine/herobrine/project.overlay @@ -0,0 +1,22 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" +#include "../display.dtsi" +#include "../gpio.dtsi" +#include "../motionsense.dtsi" +#include "../switchcap.dtsi" + +/* Herobrine project DTS includes*/ +#include "battery.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c b/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c new file mode 100644 index 0000000000..00acd509f4 --- /dev/null +++ b/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c @@ -0,0 +1,36 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include +#include "usbc/ppc.h" +#include "hooks.h" +#include "cros_board_info.h" + +LOG_MODULE_REGISTER(alt_dev_replacement); + +#define BOARD_VERSION_UNKNOWN 0xffffffff + +/* Check board version to decide which ppc is used. */ +static bool board_has_alt_ppc(void) +{ + static uint32_t board_version = BOARD_VERSION_UNKNOWN; + + if (board_version == BOARD_VERSION_UNKNOWN) { + if (cbi_get_board_version(&board_version) != EC_SUCCESS) { + LOG_ERR("Failed to get board version."); + board_version = 0; + } + } + + return (board_version >= 1); +} + +static void check_alternate_devices(void) +{ + /* Configure the PPC driver */ + if (board_has_alt_ppc()) + /* Arg is the USB port number */ + PPC_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/herobrine/herobrine/usbc.dtsi b/zephyr/program/herobrine/herobrine/usbc.dtsi new file mode 100644 index 0000000000..675286ecd7 --- /dev/null +++ b/zephyr/program/herobrine/herobrine/usbc.dtsi @@ -0,0 +1,43 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + ppc_alt = <&ppc_port0_alt>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/program/herobrine/hoglin/battery.dtsi b/zephyr/program/herobrine/hoglin/battery.dtsi new file mode 100644 index 0000000000..11180c3988 --- /dev/null +++ b/zephyr/program/herobrine/hoglin/battery.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: 7c01 { + compatible = "ganfeng,7c01", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/herobrine/hoglin/gpio.dtsi b/zephyr/program/herobrine/hoglin/gpio.dtsi new file mode 100644 index 0000000000..cb7babc9cf --- /dev/null +++ b/zephyr/program/herobrine/hoglin/gpio.dtsi @@ -0,0 +1,327 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpio5 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_y_c1: ec_chg_led_b_c1 { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_w_c1: ec_chg_led_r_c1 { + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpiod 5 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; diff --git a/zephyr/program/herobrine/hoglin/i2c.dtsi b/zephyr/program/herobrine/hoglin/i2c.dtsi new file mode 100644 index 0000000000..ca2529cbaa --- /dev/null +++ b/zephyr/program/herobrine/hoglin/i2c.dtsi @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@1b { + compatible = "parade,ps8xxx"; + reg = <0x1b>; + }; +}; + +&i2c2_0 { + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + tcpc_port1: ps8xxx@1b { + compatible = "parade,ps8xxx"; + reg = <0x1b>; + }; +}; diff --git a/zephyr/program/herobrine/hoglin/led_pins.dtsi b/zephyr/program/herobrine/hoglin/led_pins.dtsi new file mode 100644 index 0000000000..7b125c5cac --- /dev/null +++ b/zephyr/program/herobrine/hoglin/led_pins.dtsi @@ -0,0 +1,33 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_b_c0 0>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_blue: color-blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pins = <&gpio_ec_chg_led_b_c0 1>, + <&gpio_ec_chg_led_r_c0 0>; + }; + + color_red: color-red { + led-color = "LED_RED"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_RED"; + led-pins = <&gpio_ec_chg_led_b_c0 0>, + <&gpio_ec_chg_led_r_c0 1>; + }; + }; +}; diff --git a/zephyr/program/herobrine/hoglin/led_policy.dtsi b/zephyr/program/herobrine/hoglin/led_policy.dtsi new file mode 100644 index 0000000000..043dfbcaa5 --- /dev/null +++ b/zephyr/program/herobrine/hoglin/led_policy.dtsi @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* Blue 1 sec, off 3 sec */ + color-0 { + led-color = <&color_blue>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Red 1 sec, off 1 sec */ + color-0 { + led-color = <&color_red>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_red>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Red 2 sec, Blue 2 sec */ + color-0 { + led-color = <&color_red>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_blue>; + period-ms = <2000>; + }; + }; + + power-state-idle-default { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_red>; + }; + }; + }; +}; diff --git a/zephyr/program/herobrine/hoglin/motionsense.dtsi b/zephyr/program/herobrine/hoglin/motionsense.dtsi new file mode 100644 index 0000000000..c3935178ff --- /dev/null +++ b/zephyr/program/herobrine/hoglin/motionsense.dtsi @@ -0,0 +1,241 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + tcs3400-int = &als_clear; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + + tcs_clear_data: tcs3400-clear-drv-data { + compatible = "cros-ec,drvdata-tcs3400-clear"; + status = "okay"; + + als-drv-data { + compatible = "cros-ec,accelgyro-als-drv-data"; + als-cal { + scale = <1>; + uscale = <0>; + offset = <0>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + + tcs_rgb_data: tcs3400-rgb-drv-data { + compatible = "cros-ec,drvdata-tcs3400-rgb"; + status = "okay"; + + /* node for rgb_calibration_t defined in accelgyro.h */ + rgb_calibration { + compatible = + "cros-ec,accelgyro-rgb-calibration"; + + irt = <1>; + + rgb-cal-x { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-y { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-z { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma4xx_data>; + i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + + als_clear: base-als-clear { + compatible = "cros-ec,tcs3400-clear"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + port = <&i2c_sensor>; + default-range = <0x10000>; + drv-data = <&tcs_clear_data>; + i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + /* Run ALS sensor in S0 */ + odr = <1000>; + }; + }; + }; + + base-als-rgb { + compatible = "cros-ec,tcs3400-rgb"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + default-range = <0x10000>; /* scale = 1x, uscale = 0 */ + drv-data = <&tcs_rgb_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* list of entries for motion_als_sensors */ + als-sensors = <&als_clear>; + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel &als_clear>; + }; +}; diff --git a/zephyr/program/herobrine/hoglin/project.conf b/zephyr/program/herobrine/hoglin/project.conf new file mode 100644 index 0000000000..c6e20937c0 --- /dev/null +++ b/zephyr/program/herobrine/hoglin/project.conf @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Hoglin reference-board-specific Kconfig settings. +CONFIG_BOARD_HOGLIN=y +CONFIG_PLATFORM_EC_ACCEL_BMA255=n +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y + +# Sensors +CONFIG_PLATFORM_EC_ALS=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ALS_TCS3400=y +CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/program/herobrine/hoglin/project.overlay b/zephyr/program/herobrine/hoglin/project.overlay new file mode 100644 index 0000000000..d68a5a80d1 --- /dev/null +++ b/zephyr/program/herobrine/hoglin/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" + +/* Hoglin project DTS includes*/ +#include "battery.dtsi" +#include "gpio.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "switchcap.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/program/herobrine/hoglin/switchcap.dtsi b/zephyr/program/herobrine/hoglin/switchcap.dtsi new file mode 100644 index 0000000000..7c083667a1 --- /dev/null +++ b/zephyr/program/herobrine/hoglin/switchcap.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + switchcap { + compatible = "switchcap-gpio"; + enable-pin = <&gpio_switchcap_on>; + poff-delay-ms = <550>; + }; +}; diff --git a/zephyr/program/herobrine/hoglin/usbc.dtsi b/zephyr/program/herobrine/hoglin/usbc.dtsi new file mode 100644 index 0000000000..20bd48382f --- /dev/null +++ b/zephyr/program/herobrine/hoglin/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/program/herobrine/i2c.dtsi b/zephyr/program/herobrine/i2c.dtsi new file mode 100644 index 0000000000..b1ed0242c0 --- /dev/null +++ b/zephyr/program/herobrine/i2c.dtsi @@ -0,0 +1,157 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + i2c-0 = &i2c0_0; + i2c-1 = &i2c1_0; + i2c-2 = &i2c2_0; + i2c-3 = &i2c3_0; + i2c-4 = &i2c4_1; + i2c-5 = &i2c5_0; + i2c-7 = &i2c7_0; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_power: power { + i2c-port = <&i2c0_0>; + remote-port = <0>; + enum-names = "I2C_PORT_POWER", + "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY", + "I2C_PORT_CHARGER"; + }; + i2c_tcpc0: tcpc0 { + i2c-port = <&i2c1_0>; + dynamic-speed; + enum-names = "I2C_PORT_TCPC0"; + }; + i2c_tcpc1: tcpc1 { + i2c-port = <&i2c2_0>; + dynamic-speed; + enum-names = "I2C_PORT_TCPC1"; + }; + rtc { + i2c-port = <&i2c4_1>; + enum-names = "I2C_PORT_RTC"; + }; + i2c_eeprom: eeprom { + i2c-port = <&i2c5_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_sensor: sensor { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_SENSOR", + "I2C_PORT_ACCEL"; + }; + }; + + +}; + +&i2c0_0 { + label = "I2C_POWER"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + charger: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + label = "I2C_USB_C0_PD"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + label = "I2C_USB_C1_PD"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + /* Not used as no WLC connected */ + clock-frequency = ; +}; + +&i2c4_1 { + label = "I2C_RTC"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; + pinctrl-names = "default"; + + pcf85063a: pcf85063a@51 { + compatible = "nxp,rtc-pcf85063a"; + reg = <0x51>; + int-pin = <&gpio_rtc_ec_wake_odl>; + }; +}; + +&i2c_ctrl4 { + status = "okay"; +}; + +&i2c5_0 { + label = "I2C_EEPROM"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c1_bc12>; + }; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c7_0 { + label = "I2C_SENSOR"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/herobrine/include/board_chipset.h b/zephyr/program/herobrine/include/board_chipset.h new file mode 100644 index 0000000000..81c0dd1a40 --- /dev/null +++ b/zephyr/program/herobrine/include/board_chipset.h @@ -0,0 +1,11 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __CROS_EC_HEROBRINE_BOARD_CHIPSET_H +#define __CROS_EC_HEROBRINE_BOARD_CHIPSET_H + +__test_only void reset_pp5000_inited(void); + +#endif /* __CROS_EC_HEROBRINE_BOARD_CHIPSET_H */ diff --git a/zephyr/program/herobrine/interrupts.dtsi b/zephyr/program/herobrine/interrupts.dtsi new file mode 100644 index 0000000000..82650bfc51 --- /dev/null +++ b/zephyr/program/herobrine/interrupts.dtsi @@ -0,0 +1,115 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp_l; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_ac_present: ac_present { + irq-pin = <&gpio_chg_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open_ec>; + flags = ; + handler = "lid_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_ec_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_ec_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_ap_rst: ap_rst { + irq-pin = <&gpio_ap_rst_l>; + flags = ; + handler = "chipset_ap_rst_interrupt"; + }; + int_ap_suspend: ap_suspend { + irq-pin = <&gpio_ap_suspend>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_power_good: power_good { + irq-pin = <&gpio_mb_power_good>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ps_hold: ps_hold { + irq-pin = <&gpio_ps_hold>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_warm_reset: warm_reset { + irq-pin = <&gpio_warm_reset_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_usb_c0_pd: usb_c0_pd { + irq-pin = <&gpio_usb_c0_pd_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_pd: usb_c1_pd { + irq-pin = <&gpio_usb_c1_pd_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_swctl: usb_c0_swctl { + irq-pin = <&gpio_usb_c0_swctl_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_swctl: usb_c1_swctl { + irq-pin = <&gpio_usb_c1_swctl_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_l>; + flags = ; + handler = "usb0_evt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_l>; + flags = ; + handler = "usb1_evt"; + }; + int_usb_a0_oc: usb_a0_oc { + irq-pin = <&gpio_usb_a0_oc_odl>; + flags = ; + handler = "usba_oc_interrupt"; + }; + int_accel_gyro: accel_gyro { + irq-pin = <&gpio_accel_gyro_int_l>; + flags = ; + handler = "bmi260_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + }; +}; diff --git a/zephyr/program/herobrine/keyboard.dtsi b/zephyr/program/herobrine/keyboard.dtsi new file mode 100644 index 0000000000..3b7e830f2f --- /dev/null +++ b/zephyr/program/herobrine/keyboard.dtsi @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm3 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; + generic-pwm-channel = <0>; + }; +}; + +&pwm3 { + status = "okay"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/herobrine/motionsense.dtsi b/zephyr/program/herobrine/motionsense.dtsi new file mode 100644 index 0000000000..1955f43284 --- /dev/null +++ b/zephyr/program/herobrine/motionsense.dtsi @@ -0,0 +1,241 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + tcs3400-int = &als_clear; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma255_data: bma255-drv-data { + compatible = "cros-ec,drvdata-bma255"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + + tcs_clear_data: tcs3400-clear-drv-data { + compatible = "cros-ec,drvdata-tcs3400-clear"; + status = "okay"; + + als-drv-data { + compatible = "cros-ec,accelgyro-als-drv-data"; + als-cal { + scale = <1>; + uscale = <0>; + offset = <0>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + + tcs_rgb_data: tcs3400-rgb-drv-data { + compatible = "cros-ec,drvdata-tcs3400-rgb"; + status = "okay"; + + /* node for rgb_calibration_t defined in accelgyro.h */ + rgb_calibration { + compatible = + "cros-ec,accelgyro-rgb-calibration"; + + irt = <1>; + + rgb-cal-x { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-y { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-z { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma255"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma255_data>; + i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + + als_clear: base-als-clear { + compatible = "cros-ec,tcs3400-clear"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + port = <&i2c_sensor>; + default-range = <0x10000>; + drv-data = <&tcs_clear_data>; + i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + /* Run ALS sensor in S0 */ + odr = <1000>; + }; + }; + }; + + base-als-rgb { + compatible = "cros-ec,tcs3400-rgb"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + default-range = <0x10000>; /* scale = 1x, uscale = 0 */ + drv-data = <&tcs_rgb_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* list of entries for motion_als_sensors */ + als-sensors = <&als_clear>; + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel &als_clear>; + }; +}; diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf new file mode 100644 index 0000000000..3391e60dce --- /dev/null +++ b/zephyr/program/herobrine/program.conf @@ -0,0 +1,160 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_BRINGUP=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_CBI_GPIO=y +CONFIG_KERNEL_SHELL=y +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y + +# I2C options +CONFIG_I2C=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y +CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y + +# Shell history and tab autocompletion (for convenience) +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=n +CONFIG_PLATFORM_EC_LED_DT=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# Application Processor is Qualcomm SC7280 +CONFIG_AP_ARM_QUALCOMM_SC7280=y + +# GPIO Switchcap +CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y + +# Board version is selected over GPIO board ID pins. +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y + +# Power Sequencing +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y +CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y +CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y + +# MKBP event +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_CMD_BUTTON=y +CONFIG_CROS_KB_RAW_NPCX=y + +# ADC +CONFIG_ADC=y +CONFIG_ADC_SHELL=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y +CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y +CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y +CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION" +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=12500 +CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y + +# USB-A +CONFIG_PLATFORM_EC_USBA=y + +# USB-C +CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n +CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y +CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y +CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_DPS=y +CONFIG_PLATFORM_EC_USB_PD_REV30=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=2 + +# USB ID +# This is allocated specifically for Herobrine +# http://google3/hardware/standards/usb/ +# TODO(b/183608112): Move to device tree +CONFIG_PLATFORM_EC_USB_PID=0x5055 + +# RTC +CONFIG_PLATFORM_EC_RTC=y +CONFIG_CROS_RTC_NXP_PCF85063A=y +CONFIG_PLATFORM_EC_HOSTCMD_RTC=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM=y + +# EC software sync +CONFIG_PLATFORM_EC_VBOOT_HASH=y + +# Sensors +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# Sensor Drivers +CONFIG_PLATFORM_EC_ACCEL_BMA255=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +CONFIG_SYSCON=y +CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y diff --git a/zephyr/program/herobrine/src/board_chipset.c b/zephyr/program/herobrine/src/board_chipset.c new file mode 100644 index 0000000000..2312bdb1c4 --- /dev/null +++ b/zephyr/program/herobrine/src/board_chipset.c @@ -0,0 +1,83 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine chipset-specific configuration */ + +#include "charger.h" +#include "common.h" +#include "console.h" +#include "battery.h" +#include "gpio.h" +#include "hooks.h" +#include "timer.h" +#include "usb_pd.h" + +#include "board_chipset.h" + +#define CPRINTS(format, args...) cprints(CC_HOOK, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_HOOK, format, ##args) + +/* + * A window of PD negotiation. It starts from the Type-C state reaching + * Attached.SNK, and ends when the PD contract is created. The VBUS may be + * raised anytime in this window. + * + * The current implementation is the worst case scenario: every message the PD + * negotiation is received at the last moment before timeout. More extra time + * is added to compensate the delay internally, like the decision of the DPM. + * + * TODO(waihong): Cancel this timer when the PD contract is negotiated. + */ +#define PD_READY_TIMEOUT \ + (PD_T_SINK_WAIT_CAP + PD_T_SENDER_RESPONSE + PD_T_SINK_TRANSITION + \ + 20 * MSEC) + +#define PD_READY_POLL_DELAY (10 * MSEC) + +static timestamp_t pd_ready_timeout; + +static bool pp5000_inited; + +__test_only void reset_pp5000_inited(void) +{ + pp5000_inited = false; +} + +/* Called on USB PD connected */ +static void board_usb_pd_connect(void) +{ + int soc = -1; + + /* First boot, battery unattached or low SOC */ + if (!pp5000_inited && + ((battery_state_of_charge_abs(&soc) != EC_SUCCESS || + soc < charger_get_min_bat_pct_for_power_on()))) { + pd_ready_timeout = get_time(); + pd_ready_timeout.val += PD_READY_TIMEOUT; + } +} +DECLARE_HOOK(HOOK_USB_PD_CONNECT, board_usb_pd_connect, HOOK_PRIO_DEFAULT); + +static void wait_pd_ready(void) +{ + CPRINTS("Wait PD negotiated VBUS transition %u", + pd_ready_timeout.le.lo); + while (pd_ready_timeout.val && get_time().val < pd_ready_timeout.val) + usleep(PD_READY_POLL_DELAY); +} + +/* Called on AP S5 -> S3 transition */ +static void board_chipset_pre_init(void) +{ + if (!pp5000_inited) { + if (pd_ready_timeout.val) { + wait_pd_ready(); + } + CPRINTS("Enable 5V rail"); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_s5), 1); + pp5000_inited = true; + } +} +DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/herobrine/src/i2c.c b/zephyr/program/herobrine/src/i2c.c new file mode 100644 index 0000000000..88b722c42d --- /dev/null +++ b/zephyr/program/herobrine/src/i2c.c @@ -0,0 +1,17 @@ +/* Copyright 2021 The ChromiumOS Authors + * 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" + +/* Herobrine-NPCX9 board specific i2c implementation */ + +#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED +int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) +{ + return (i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY)); +} +#endif diff --git a/zephyr/program/herobrine/src/usb_pd_policy.c b/zephyr/program/herobrine/src/usb_pd_policy.c new file mode 100644 index 0000000000..adc517d3cb --- /dev/null +++ b/zephyr/program/herobrine/src/usb_pd_policy.c @@ -0,0 +1,254 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charge_manager.h" +#include "chipset.h" +#include "console.h" +#include "system.h" +#include "usb_mux.h" +#include "usbc_ppc.h" +#include "util.h" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +int pd_check_vconn_swap(int port) +{ + /* In G3, do not allow vconn swap since PP5000 rail is off */ + return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_s5)); +} + +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; + +static void board_vbus_update_source_current(int port) +{ + ppc_vbus_source_enable(port, vbus_en[port]); +} + +void pd_power_supply_reset(int port) +{ + int prev_en; + + prev_en = vbus_en[port]; + + /* Disable VBUS */ + vbus_en[port] = 0; + board_vbus_update_source_current(port); + + /* Enable discharge if we were previously sourcing 5V */ + if (prev_en) + pd_set_vbus_discharge(port, 1); + + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + /* Disable charging */ + board_vbus_sink_enable(port, 0); + + pd_set_vbus_discharge(port, 0); + + /* Provide VBUS */ + vbus_en[port] = 1; + board_vbus_update_source_current(port); + + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; /* we are ready */ +} + +int board_vbus_source_enabled(int port) +{ + return vbus_en[port]; +} + +int pd_snk_is_vbus_provided(int port) +{ + return tcpm_check_vbus_level(port, VBUS_PRESENT); +} + +/* ----------------- Vendor Defined Messages ------------------ */ +#ifdef CONFIG_USB_PD_ALT_MODE_DFP +__override int svdm_dp_config(int port, uint32_t *payload) +{ + int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); + uint8_t pin_mode = get_dp_pin_mode(port); + + if (!pin_mode) + return 0; + + /* + * Defer setting the usb_mux until HPD goes high, svdm_dp_attention(). + * The AP only supports one DP phy. An external DP mux switches between + * the two ports. Should switch those muxes when it is really used, + * i.e. HPD high; otherwise, the real use case is preempted, like: + * (1) plug a dongle without monitor connected to port-0, + * (2) plug a dongle without monitor connected to port-1, + * (3) plug a monitor to the port-1 dongle. + */ + + payload[0] = + VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); + payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ + 1, /* DPv1.3 signaling */ + 2); /* UFP connected */ + return 2; +}; + +__override void svdm_dp_post_config(int port) +{ + dp_flags[port] |= DP_FLAGS_DP_ON; +} + +/** + * Is the port fine to be muxed its DisplayPort lines? + * + * Only one port can be muxed to DisplayPort at a time. + * + * @param port Port number of TCPC. + * @return 1 is fine; 0 is bad as other port is already muxed; + */ +static int is_dp_muxable(int port) +{ + int i; + + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) + if (i != port) { + if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED) + return 0; + } + + return 1; +} + +__override int svdm_dp_attention(int port, uint32_t *payload) +{ + const struct gpio_dt_spec *hpd = + GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det_r); + int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); + int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); + int cur_lvl = gpio_pin_get_dt(hpd); + mux_state_t mux_state; + + dp_status[port] = payload[1]; + + if (!is_dp_muxable(port)) { + /* TODO(waihong): Info user? */ + CPRINTS("p%d: The other port is already muxed.", port); + return 0; + } + + /* + * Initial implementation to handle HPD. Only the first-plugged port + * works, i.e. sending HPD signal to AP. The second-plugged port + * will be ignored. + * + * TODO(waihong): Continue the above case, if the first-plugged port + * is then unplugged, switch to the second-plugged port and signal AP? + */ + if (lvl) { + /* + * Enable and switch the DP port selection mux to the + * correct port. + * + * TODO(waihong): Better to move switching DP mux to + * the usb_mux abstraction. + */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), + port == 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0); + + /* Connect the SBU lines in PPC chip. */ + if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) + ppc_set_sbu(port, 1); + + /* + * Connect the USB SS/DP lines in TCPC chip. + * + * When mf_pref not true, still use the dock muxing + * because of the board USB-C topology (limited to 2 + * lanes DP). + */ + usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT, + polarity_rm_dts(pd_get_polarity(port))); + } else { + /* Disconnect the DP port selection mux. */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); + + /* Disconnect the SBU lines in PPC chip. */ + if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) + ppc_set_sbu(port, 0); + + /* Disconnect the DP but keep the USB SS lines in TCPC chip. */ + usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, + polarity_rm_dts(pd_get_polarity(port))); + } + + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) + /* + * Wake up the AP. IRQ or level high indicates a DP sink is now + * present. + */ + pd_notify_dp_alt_mode_entry(port); + + /* Configure TCPC for the HPD event, for proper muxing */ + mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) | + (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED); + usb_mux_hpd_update(port, mux_state); + + /* Signal AP for the HPD event, through GPIO to AP */ + if (irq & cur_lvl) { + uint64_t now = get_time().val; + /* Wait for the minimum spacing between IRQ_HPD if needed */ + if (now < svdm_hpd_deadline[port]) + usleep(svdm_hpd_deadline[port] - now); + + /* Generate IRQ_HPD pulse */ + CPRINTS("C%d: Recv IRQ. HPD->0", port); + gpio_pin_set_dt(hpd, 0); + usleep(HPD_DSTREAM_DEBOUNCE_IRQ); + gpio_pin_set_dt(hpd, 1); + CPRINTS("C%d: Recv IRQ. HPD->1", port); + + /* Set the minimum time delay (2ms) for the next HPD IRQ */ + svdm_hpd_deadline[port] = + get_time().val + HPD_USTREAM_DEBOUNCE_LVL; + } else if (irq & !lvl) { + CPRINTF("ERR:HPD:IRQ&LOW\n"); + return 0; + } else { + CPRINTS("C%d: Recv lvl. HPD->%d", port, lvl); + gpio_pin_set_dt(hpd, lvl); + /* Set the minimum time delay (2ms) for the next HPD IRQ */ + svdm_hpd_deadline[port] = + get_time().val + HPD_USTREAM_DEBOUNCE_LVL; + } + + return 1; +} + +__override void svdm_exit_dp_mode(int port) +{ + CPRINTS("%s(%d)", __func__, port); + if (is_dp_muxable(port)) { + /* Disconnect the DP port selection mux. */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); + + /* Signal AP for the HPD low event */ + usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | + USB_PD_MUX_HPD_IRQ_DEASSERTED); + CPRINTS("C%d: DP exit. HPD->0", port); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det_r), + 0); + } +} +#endif /* CONFIG_USB_PD_ALT_MODE_DFP */ diff --git a/zephyr/program/herobrine/src/usbc_config.c b/zephyr/program/herobrine/src/usbc_config.c new file mode 100644 index 0000000000..f040ab12cb --- /dev/null +++ b/zephyr/program/herobrine/src/usbc_config.c @@ -0,0 +1,278 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine board-specific USB-C configuration */ + +#include + +#include "charger.h" +#include "charger/isl923x_public.h" +#include "charge_manager.h" +#include "charge_state.h" +#include "common.h" +#include "config.h" +#include "cros_board_info.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "ppc/sn5s330_public.h" +#include "ppc/syv682x_public.h" +#include "system.h" +#include "tcpm/ps8xxx_public.h" +#include "tcpm/tcpci.h" +#include "timer.h" +#include "usb_pd.h" +#include "usb_mux.h" +#include "usbc_ocp.h" +#include "usbc_ppc.h" +#include "usbc/ppc.h" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* GPIO Interrupt Handlers */ +void tcpc_alert_event(enum gpio_signal signal) +{ + int port = -1; + + switch (signal) { + case GPIO_USB_C0_PD_INT_ODL: + port = 0; + break; + case GPIO_USB_C1_PD_INT_ODL: + port = 1; + break; + default: + return; + } + + schedule_deferred_pd_interrupt(port); +} + +static void usba_oc_deferred(void) +{ + /* Use next number after all USB-C ports to indicate the USB-A port */ + board_overcurrent_event( + CONFIG_USB_PD_PORT_MAX_COUNT, + !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_a0_oc_odl))); +} +DECLARE_DEFERRED(usba_oc_deferred); + +void usba_oc_interrupt(enum gpio_signal signal) +{ + hook_call_deferred(&usba_oc_deferred_data, 0); +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_SWCTL_INT_ODL: + ppc_chips[0].drv->interrupt(0); + break; + + case GPIO_USB_C1_SWCTL_INT_ODL: + ppc_chips[1].drv->interrupt(1); + break; + + default: + break; + } +} + +int charger_profile_override(struct charge_state_data *curr) +{ + int usb_mv; + int port; + + if (curr->state != ST_CHARGE) + return 0; + + /* Lower the max requested voltage to 5V when battery is full. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF) && + !(curr->batt.flags & BATT_FLAG_BAD_STATUS) && + !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) && + (curr->batt.status & STATUS_FULLY_CHARGED)) + usb_mv = 5000; + else + usb_mv = PD_MAX_VOLTAGE_MV; + + if (pd_get_max_voltage() != usb_mv) { + CPRINTS("VBUS limited to %dmV", usb_mv); + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) + pd_set_external_voltage_limit(port, usb_mv); + } + + return 0; +} + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} + +/* Initialize board USC-C things */ +static void board_init_usbc(void) +{ + /* Enable USB-A overcurrent interrupt */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc)); +} +DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT); + +void board_tcpc_init(void) +{ + /* Only reset TCPC if not sysjump */ + if (!system_jumped_late()) { + /* TODO(crosbug.com/p/61098): How long do we need to wait? */ + board_reset_pd_mcu(); + } + + /* Enable PPC interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl)); + + /* Enable TCPC interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_pd)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_pd)); + + /* + * Initialize HPD to low; after sysjump SOC needs to see + * HPD pulse to enable video path + */ + for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) + usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | + USB_PD_MUX_HPD_IRQ_DEASSERTED); +} +DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C); + +void board_reset_pd_mcu(void) +{ + cprints(CC_USB, "Resetting TCPCs..."); + cflush(); + + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0); + msleep(PS8XXX_RESET_DELAY_MS); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1); + msleep(PS8805_FW_INIT_DELAY_MS); +} + +void board_set_tcpc_power_mode(int port, int mode) +{ + /* Ignore the "mode" to turn the chip on. We can only do a reset. */ + if (mode) + return; + + board_reset_pd_mcu(); +} + +int board_vbus_sink_enable(int port, int enable) +{ + /* Both ports are controlled by PPC SN5S330 */ + return ppc_vbus_sink_enable(port, enable); +} + +int board_is_sourcing_vbus(int port) +{ + /* Both ports are controlled by PPC SN5S330 */ + return ppc_is_sourcing_vbus(port); +} + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* TODO(b/120231371): Notify AP */ + CPRINTS("p%d: overcurrent!", port); +} + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + if (port == CHARGE_PORT_NONE) { + CPRINTS("Disabling all charging port"); + + /* Disable all ports. */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (board_vbus_sink_enable(i, 0)) + CPRINTS("Disabling p%d sink path failed.", i); + } + + return EC_SUCCESS; + } + + /* Check if the port is sourcing VBUS. */ + if (board_is_sourcing_vbus(port)) { + CPRINTS("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + + CPRINTS("New charge port: p%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i == port) + continue; + + if (board_vbus_sink_enable(i, 0)) + CPRINTS("p%d: sink path disable failed.", i); + } + + /* Enable requested charge port. */ + if (board_vbus_sink_enable(port, 1)) { + CPRINTS("p%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} + +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) +{ + /* + * Ignore lower charge ceiling on PD transition if our battery is + * critical, as we may brownout. + */ + if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 && + charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) { + CPRINTS("Using max ilim %d", max_ma); + charge_ma = max_ma; + } + + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) + if (gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l))) + status |= PD_STATUS_TCPC_ALERT_0; + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_int_odl))) + if (gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l))) + status |= PD_STATUS_TCPC_ALERT_1; + + return status; +} diff --git a/zephyr/program/herobrine/switchcap.dtsi b/zephyr/program/herobrine/switchcap.dtsi new file mode 100644 index 0000000000..ed200a0c6f --- /dev/null +++ b/zephyr/program/herobrine/switchcap.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + switchcap { + compatible = "switchcap-gpio"; + enable-pin = <&gpio_switchcap_on>; + power-good-pin = <&gpio_switchcap_pg>; + }; +}; diff --git a/zephyr/program/herobrine/villager/battery.dtsi b/zephyr/program/herobrine/villager/battery.dtsi new file mode 100644 index 0000000000..dafd473a6e --- /dev/null +++ b/zephyr/program/herobrine/villager/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: ap19a5k { + compatible = "panasonic,ap19a5k", "battery-smart"; + }; + ap19a8k { + compatible = "lgc,ap19a8k", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/herobrine/villager/gpio.dtsi b/zephyr/program/herobrine/villager/gpio.dtsi new file mode 100644 index 0000000000..1e7625ff6a --- /dev/null +++ b/zephyr/program/herobrine/villager/gpio.dtsi @@ -0,0 +1,323 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 3 0>, + <&gpioc 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpio5 0 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; diff --git a/zephyr/program/herobrine/villager/i2c.dtsi b/zephyr/program/herobrine/villager/i2c.dtsi new file mode 100644 index 0000000000..02d1729dd1 --- /dev/null +++ b/zephyr/program/herobrine/villager/i2c.dtsi @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; + +&i2c2_0 { + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; diff --git a/zephyr/program/herobrine/villager/led_pins.dtsi b/zephyr/program/herobrine/villager/led_pins.dtsi new file mode 100644 index 0000000000..b0913cdbce --- /dev/null +++ b/zephyr/program/herobrine/villager/led_pins.dtsi @@ -0,0 +1,33 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_b_c0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c0 1>, + <&gpio_ec_chg_led_b_c0 0>; + }; + + color_blue: color-blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_b_c0 1>; + }; + }; +}; diff --git a/zephyr/program/herobrine/villager/led_policy.dtsi b/zephyr/program/herobrine/villager/led_policy.dtsi new file mode 100644 index 0000000000..f8996a3f4b --- /dev/null +++ b/zephyr/program/herobrine/villager/led_policy.dtsi @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Blue 2 sec, Amber 2 sec */ + color-0 { + led-color = <&color_blue>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + }; + + power-state-idle { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_blue>; + }; + }; + }; +}; diff --git a/zephyr/program/herobrine/villager/motionsense.dtsi b/zephyr/program/herobrine/villager/motionsense.dtsi new file mode 100644 index 0000000000..31d00e04a5 --- /dev/null +++ b/zephyr/program/herobrine/villager/motionsense.dtsi @@ -0,0 +1,148 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + kx022_data: kx022-drv-data { + compatible = "cros-ec,drvdata-kionix"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,kx022"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&kx022_data>; + i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/herobrine/villager/project.conf b/zephyr/program/herobrine/villager/project.conf new file mode 100644 index 0000000000..35eebe6d99 --- /dev/null +++ b/zephyr/program/herobrine/villager/project.conf @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Villager board-specific Kconfig settings. +CONFIG_BOARD_VILLAGER=y + +CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/program/herobrine/villager/project.overlay b/zephyr/program/herobrine/villager/project.overlay new file mode 100644 index 0000000000..a18d6416dd --- /dev/null +++ b/zephyr/program/herobrine/villager/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" +#include "../switchcap.dtsi" + +/* Villager project DTS includes*/ +#include "battery.dtsi" +#include "gpio.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/program/herobrine/villager/usbc.dtsi b/zephyr/program/herobrine/villager/usbc.dtsi new file mode 100644 index 0000000000..20bd48382f --- /dev/null +++ b/zephyr/program/herobrine/villager/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/program/herobrine/zoglin/project.conf b/zephyr/program/herobrine/zoglin/project.conf new file mode 100644 index 0000000000..7f96cf6c79 --- /dev/null +++ b/zephyr/program/herobrine/zoglin/project.conf @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Zoglin reference-board-specific Kconfig settings. +CONFIG_BOARD_ZOGLIN=y +CONFIG_PLATFORM_EC_ACCEL_BMA255=n +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y + +# Sensors +CONFIG_PLATFORM_EC_ALS=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ALS_TCS3400=y +CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/program/herobrine/zoglin/project.overlay b/zephyr/program/herobrine/zoglin/project.overlay new file mode 100644 index 0000000000..55f7dd73fc --- /dev/null +++ b/zephyr/program/herobrine/zoglin/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" + +/* Zoglin project DTS includes*/ +#include "../hoglin/battery.dtsi" +#include "../hoglin/gpio.dtsi" +#include "../hoglin/i2c.dtsi" +#include "../hoglin/led_pins.dtsi" +#include "../hoglin/led_policy.dtsi" +#include "../hoglin/motionsense.dtsi" +#include "../hoglin/switchcap.dtsi" +#include "../hoglin/usbc.dtsi" diff --git a/zephyr/program/herobrine/zombie/battery.dtsi b/zephyr/program/herobrine/zombie/battery.dtsi new file mode 100644 index 0000000000..dafd473a6e --- /dev/null +++ b/zephyr/program/herobrine/zombie/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: ap19a5k { + compatible = "panasonic,ap19a5k", "battery-smart"; + }; + ap19a8k { + compatible = "lgc,ap19a8k", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/herobrine/zombie/gpio.dtsi b/zephyr/program/herobrine/zombie/gpio.dtsi new file mode 100644 index 0000000000..14ed1f54d6 --- /dev/null +++ b/zephyr/program/herobrine/zombie/gpio.dtsi @@ -0,0 +1,323 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; + }; + gpio_chg_acok_od: chg_acok_od { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpio5 1 GPIO_INPUT>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_mb_power_good: mb_power_good { + gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + ec_gsc_packet_mode { + gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + pmic_resin_l { + gpios = <&gpioa 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ap_ec_int_l { + gpios = <&gpio5 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + /* The PMIC controls backlight enable and this pin must + * be HiZ for normal operation. But the backlight can + * be enabled by setting this pin low and configuring it + * as an output. + */ + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + lid_accel_int_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + tp_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpiob 1 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en_l { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_FRS_EN"; + }; + gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { + #led-pin-cells = <1>; + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { + #led-pin-cells = <1>; + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + ap_ec_spi_mosi { + gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_miso { + gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; + }; + ap_ec_spi_clk { + gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpioa 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + gpio_switchcap_pg: src_vph_pwr_pg { + gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_SWITCHCAP_PG"; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "ternary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "ternary"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 2 0>, + <&gpio5 4 0>, + <&gpio7 6 0>, + <&gpiod 1 0>, + <&gpiod 0 0>, + <&gpioe 3 0>, + <&gpio0 4 0>, + <&gpiod 6 0>, + <&gpio3 2 0>, + <&gpio3 5 0>, + <&gpiod 7 0>, + <&gpio8 6 0>, + <&gpiod 4 0>, + <&gpio4 1 0>, + <&gpio3 4 0>, + <&gpioc 3 0>, + <&gpioc 4 0>, + <&gpioc 7 0>, + <&gpioa 4 0>, + <&gpio9 6 0>, + <&gpio9 3 0>, + <&gpioa 7 0>, + <&gpio5 0 0>, + <&gpio8 1 0>, + <&gpiob 7 0>; + }; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* EC_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in3_gp01 { + /* LID_OPEN_EC */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* RTC_EC_WAKE_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; diff --git a/zephyr/program/herobrine/zombie/i2c.dtsi b/zephyr/program/herobrine/zombie/i2c.dtsi new file mode 100644 index 0000000000..02d1729dd1 --- /dev/null +++ b/zephyr/program/herobrine/zombie/i2c.dtsi @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../i2c.dtsi" + +&i2c1_0 { + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; + +&i2c2_0 { + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; +}; diff --git a/zephyr/program/herobrine/zombie/led_pins.dtsi b/zephyr/program/herobrine/zombie/led_pins.dtsi new file mode 100644 index 0000000000..b0913cdbce --- /dev/null +++ b/zephyr/program/herobrine/zombie/led_pins.dtsi @@ -0,0 +1,33 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_b_c0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c0 1>, + <&gpio_ec_chg_led_b_c0 0>; + }; + + color_blue: color-blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pins = <&gpio_ec_chg_led_y_c0 0>, + <&gpio_ec_chg_led_b_c0 1>; + }; + }; +}; diff --git a/zephyr/program/herobrine/zombie/led_policy.dtsi b/zephyr/program/herobrine/zombie/led_policy.dtsi new file mode 100644 index 0000000000..f8996a3f4b --- /dev/null +++ b/zephyr/program/herobrine/zombie/led_policy.dtsi @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Blue 2 sec, Amber 2 sec */ + color-0 { + led-color = <&color_blue>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + }; + + power-state-idle { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_blue>; + }; + }; + }; +}; diff --git a/zephyr/program/herobrine/zombie/motionsense.dtsi b/zephyr/program/herobrine/zombie/motionsense.dtsi new file mode 100644 index 0000000000..e069564b35 --- /dev/null +++ b/zephyr/program/herobrine/zombie/motionsense.dtsi @@ -0,0 +1,148 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi260-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi260: bmi260-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + kx022_data: kx022-drv-data { + compatible = "cros-ec,drvdata-kionix"; + status = "okay"; + }; + + bmi260_data: bmi260-drv-data { + compatible = "cros-ec,drvdata-bmi260"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,kx022"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&kx022_data>; + i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi260-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi260-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi260>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi260_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/herobrine/zombie/project.conf b/zephyr/program/herobrine/zombie/project.conf new file mode 100644 index 0000000000..037ab5cc05 --- /dev/null +++ b/zephyr/program/herobrine/zombie/project.conf @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Zombie board-specific Kconfig settings. +CONFIG_BOARD_ZOMBIE=y + +CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/program/herobrine/zombie/project.overlay b/zephyr/program/herobrine/zombie/project.overlay new file mode 100644 index 0000000000..7b44350e5a --- /dev/null +++ b/zephyr/program/herobrine/zombie/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Herobrine program common DTS includes */ +#include "../adc.dtsi" +#include "../common.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../default_gpio_pinctrl.dtsi" +#include "../switchcap.dtsi" + +/* Zombie project DTS includes*/ +#include "battery.dtsi" +#include "gpio.dtsi" +#include "i2c.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "usbc.dtsi" diff --git a/zephyr/program/herobrine/zombie/usbc.dtsi b/zephyr/program/herobrine/zombie/usbc.dtsi new file mode 100644 index 0000000000..20bd48382f --- /dev/null +++ b/zephyr/program/herobrine/zombie/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/program/intelrvp/BUILD.py b/zephyr/program/intelrvp/BUILD.py new file mode 100644 index 0000000000..f129b3d2d2 --- /dev/null +++ b/zephyr/program/intelrvp/BUILD.py @@ -0,0 +1,98 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for intelrvp.""" + +# intelrvp has adlrvp_npcx, adlrvpp_ite, adlrvpp_mchp etc + + +def register_intelrvp_project( + project_name, + chip="npcx9m3f", + extra_dts_overlays=(), + extra_kconfig_files=(), +): + """Register a variant of intelrvp.""" + register_func = register_binman_project + if chip.startswith("mec1727"): + register_func = register_mchp_project + elif chip.startswith("npcx"): + register_func = register_npcx_project + + kconfig_files = [here / "prj.conf"] + dts_overlays = [] + if project_name.startswith("adlrvp"): + kconfig_files.append(here / "adlrvp/prj.conf") + dts_overlays.append(here / "adlrvp/battery.dts") + dts_overlays.append(here / "adlrvp/ioex.dts") + if project_name.startswith("mtlrvp"): + kconfig_files.append(here / "mtlrvp/prj.conf") + dts_overlays.append(here / "adlrvp/battery.dts") + kconfig_files.extend(extra_kconfig_files) + dts_overlays.extend(extra_dts_overlays) + + register_func( + project_name=project_name, + zephyr_board=chip, + dts_overlays=dts_overlays, + kconfig_files=kconfig_files, + ) + + +register_intelrvp_project( + project_name="adlrvp_mchp", + chip="mec1727", + extra_dts_overlays=[ + here / "adlrvp/adlrvp_mchp/adlrvp_mchp.dts", + here / "adlrvp/adlrvp_mchp/gpio.dts", + here / "adlrvp/adlrvp_mchp/interrupts.dts", + here / "adlrvp/adlrvp_mchp/keyboard.dts", + here / "adlrvp/adlrvp_mchp/usbc.dts", + ], + extra_kconfig_files=[ + here / "legacy_ec_pwrseq.conf", + here / "adlrvp/adlrvp_mchp/prj.conf", + ], +) + + +register_intelrvp_project( + project_name="adlrvp_npcx", + chip="npcx9m7f", + extra_dts_overlays=[ + here / "adlrvp/adlrvp_npcx/adlrvp_npcx.dts", + here / "adlrvp/adlrvp_npcx/fan.dts", + here / "adlrvp/adlrvp_npcx/gpio.dts", + here / "adlrvp/adlrvp_npcx/interrupts.dts", + here / "adlrvp/adlrvp_npcx/keyboard.dts", + here / "adlrvp/adlrvp_npcx/temp_sensor.dts", + here / "adlrvp/adlrvp_npcx/usbc.dts", + here / "adlrvp/adlrvp_npcx/pwm_leds.dts", + ], + extra_kconfig_files=[ + here / "legacy_ec_pwrseq.conf", + here / "adlrvp/adlrvp_npcx/prj.conf", + ], +) + + +register_intelrvp_project( + project_name="mtlrvpp_npcx", + chip="npcx9m3f", + extra_dts_overlays=[ + here / "mtlrvp/mtlrvpp_npcx/fan.dts", + here / "mtlrvp/mtlrvpp_npcx/gpio.dts", + here / "mtlrvp/mtlrvpp_npcx/keyboard.dts", + here / "mtlrvp/mtlrvpp_npcx/interrupts.dts", + here / "mtlrvp/ioex.dts", + here / "mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts", + here / "mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts", + here / "adlrvp/adlrvp_npcx/temp_sensor.dts", + here / "mtlrvp/usbc.dts", + ], + extra_kconfig_files=[ + here / "zephyr_ap_pwrseq.conf", + here / "mtlrvp/mtlrvpp_npcx/prj.conf", + ], +) diff --git a/zephyr/program/intelrvp/CMakeLists.txt b/zephyr/program/intelrvp/CMakeLists.txt new file mode 100644 index 0000000000..039627dec6 --- /dev/null +++ b/zephyr/program/intelrvp/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(intelrvp) + +cros_ec_library_include_directories(include) +cros_ec_library_include_directories("${PLATFORM_EC}/driver/charger") +cros_ec_library_include_directories("${PLATFORM_EC}/driver/ppc") +cros_ec_library_include_directories("${PLATFORM_EC}/driver/tcpm") +cros_ec_library_include_directories("${PLATFORM_EC}/driver/usb_mux") +zephyr_library_sources("src/intel_rvp_board_id.c") + +if((DEFINED CONFIG_BOARD_ADLRVP_MCHP) OR (DEFINED CONFIG_BOARD_ADLRVP_NPCX)) + add_subdirectory(adlrvp) + zephyr_library_sources("src/intelrvp.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "${PLATFORM_EC}/baseboard/intelrvp/usb_pd_policy_mecc_1_0.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "${PLATFORM_EC}/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "${PLATFORM_EC}/baseboard/intelrvp/chg_usb_pd.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM "src/intel_rvp_led.c") +endif() + +if(DEFINED CONFIG_BOARD_MTLRVP_NPCX) + add_subdirectory(mtlrvp) + zephyr_library_sources("src/intelrvp.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy_mecc_1_1.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/chg_usb_pd_mecc_1_1.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/chg_usb_pd.c") +endif() diff --git a/zephyr/program/intelrvp/Kconfig b/zephyr/program/intelrvp/Kconfig new file mode 100644 index 0000000000..605f57c054 --- /dev/null +++ b/zephyr/program/intelrvp/Kconfig @@ -0,0 +1,26 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config BOARD_ADLRVP_MCHP + bool "Intel ADLRVP_MCHP board" + depends on SOC_MEC172X_NSZ + help + Build Intel ADLRVP_MCHP reference board. This board has Intel ADL RVP + SoC with MEC1727 EC. + +config BOARD_ADLRVP_NPCX + bool "Intel ADLRVP_NPCX board" + depends on SOC_NPCX9M7F + help + Build Intel ADLRVP_NPCX reference board. This board has Intel ADL RVP + SoC with NPCX9M37F EC. + +config BOARD_MTLRVP_NPCX + bool "Intel MTLRVP_NPCX board" + depends on SOC_NPCX9M3F + help + Build Intel MTLRVP_NPCX reference board. This board is Intel MTL RVP + SOC with NPCX_NPCX9M3F + +source "Kconfig.zephyr" diff --git a/zephyr/program/intelrvp/adlrvp/CMakeLists.txt b/zephyr/program/intelrvp/adlrvp/CMakeLists.txt new file mode 100644 index 0000000000..71dee29552 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cros_ec_library_include_directories("include") +zephyr_library_sources("src/adlrvp.c") diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts new file mode 100644 index 0000000000..527a62e776 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts @@ -0,0 +1,201 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_lid_open + &int_power_button + >; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_charger: charger { + i2c-port = <&i2c_smb_0>; + enum-names = "I2C_PORT_BATTERY", + "I2C_PORT_CHARGER", + "I2C_PORT_EEPROM", + "I2C_PORT_PORT80"; + }; + typec_0: typec-0 { + i2c-port = <&i2c_smb_1>; + enum-names = "I2C_PORT_TYPEC_0"; + }; + typec_1: typec-1 { + i2c-port = <&i2c_smb_2>; + enum-names = "I2C_PORT_TYPEC_1"; + }; + typec_2: typec-2 { + i2c-port = <&i2c_smb_3>; + enum-names = "I2C_PORT_TYPEC_2"; + }; + typec_3: typec-3 { + i2c-port = <&i2c_smb_4>; + enum-names = "I2C_PORT_TYPEC_3"; + }; + }; +}; + +/* charger */ +&i2c_smb_0 { + status = "okay"; + clock-frequency = ; + port_sel = <0>; + pinctrl-0 = <&i2c00_scl_gpio004 &i2c00_sda_gpio003>; + pinctrl-names = "default"; + + pca95xx: pca95xx@22 { + compatible = "nxp,pca95xx"; + label = "PCA95XX"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <16>; + }; + + rvp_board_id: rvp-board-id { + compatible = "intel,rvp-board-id"; + + /* + * BOM ID [2] : IOEX[0] + * BOM ID [1:0] : IOEX[15:14] + */ + bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>; + + /* + * FAB ID [1:0] : IOEX[2:1] + */ + fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>; + + /* + * BOARD ID[5:0] : IOEX[13:8] + */ + board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>, + <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>; + }; + + seven_seg_display: max695x-seven-seg-display@38 { + compatible = "maxim,seven-seg-display"; + reg = <0x38>; + label = "MAX695X_SEVEN_SEG_DISPLAY"; + }; + + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +/* typec_0 */ +&i2c_smb_1 { + status = "okay"; + clock-frequency = ; + port_sel = <6>; + pinctrl-0 = <&i2c06_scl_gpio140 &i2c06_sda_gpio132>; + pinctrl-names = "default"; + + tcpc_port0: fusb302@22 { + compatible = "fairchild,fusb302"; + reg = <0x22>; + }; + + usb_c0_soc_side_bb_retimer: jhl8040r-c0-soc-side@54 { + compatible = "intel,jhl8040r"; + reg = <0x54>; + reset-pin = <&usb_c0_bb_retimer_rst>; + ls-en-pin = <&usb_c0_bb_retimer_ls_en>; + }; + + usb_c0_bb_retimer: jhl8040r-c0@56 { + compatible = "intel,jhl8040r"; + reg = <0x56>; + reset-pin = <&usb_c0_bb_retimer_rst>; + ls-en-pin = <&usb_c0_bb_retimer_ls_en>; + }; +}; + +/* typec_1 */ +&i2c_smb_2 { + status = "okay"; + clock-frequency = ; + port_sel = <3>; + pinctrl-0 = <&i2c03_scl_gpio010 &i2c03_sda_gpio007>; + pinctrl-names = "default"; + + tcpc_port1: fusb302@22 { + compatible = "fairchild,fusb302"; + reg = <0x22>; + }; + + usb_c1_soc_side_bb_retimer: jhl8040r-c1-soc-side@55 { + compatible = "intel,jhl8040r"; + reg = <0x55>; + reset-pin = <&usb_c1_bb_retimer_rst>; + ls-en-pin = <&usb_c1_bb_retimer_ls_en>; + }; + + usb_c1_bb_retimer: jhl8040r-c1@57 { + compatible = "intel,jhl8040r"; + reg = <0x57>; + reset-pin = <&usb_c1_bb_retimer_rst>; + ls-en-pin = <&usb_c1_bb_retimer_ls_en>; + }; +}; + +/* typec_2 */ +&i2c_smb_3 { + status = "okay"; + clock-frequency = ; + port_sel = <7>; + pinctrl-0 = <&i2c07_scl_gpio013 &i2c07_sda_gpio012>; + pinctrl-names = "default"; + + tcpc_port2: fusb302@22 { + compatible = "fairchild,fusb302"; + reg = <0x22>; + }; + + usb_c2_bb_retimer: jhl8040r-c2@58 { + compatible = "intel,jhl8040r"; + reg = <0x58>; + reset-pin = <&usb_c2_bb_retimer_rst>; + ls-en-pin = <&usb_c2_bb_retimer_ls_en>; + }; +}; + +/* typec_3 */ +&i2c_smb_4 { + status = "okay"; + clock-frequency = ; + port_sel = <2>; + pinctrl-0 = <&i2c02_scl_gpio155 &i2c02_sda_gpio154>; + pinctrl-names = "default"; + + tcpc_port3: fusb302@22 { + compatible = "fairchild,fusb302"; + reg = <0x22>; + }; + + usb_c3_bb_retimer: jhl8040r-c3@59 { + compatible = "intel,jhl8040r"; + reg = <0x59>; + reset-pin = <&usb_c3_bb_retimer_rst>; + ls-en-pin = <&usb_c3_bb_retimer_ls_en>; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts new file mode 100644 index 0000000000..1c760120f1 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +&i2c_smb_1 { + status = "okay"; + clock-frequency = ; + + usb_c0_bb_retimer: jhl8040r@56 { + compatible = "intel,jhl8040r"; + reg = <0x56>; + label = "USB_C0_BB_RETIMER"; + reset-pin = <&usb_c0_bb_retimer_rst>; + }; +}; + +&i2c_smb_2 { + status = "okay"; + clock-frequency = ; + + usb_c1_bb_retimer: jhl8040r@57 { + compatible = "intel,jhl8040r"; + reg = <0x57>; + label = "USB_C1_BB_RETIMER"; + reset-pin = <&usb_c1_bb_retimer_rst>; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/gpio.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/gpio.dts new file mode 100644 index 0000000000..d526fdcb3b --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/gpio.dts @@ -0,0 +1,299 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_wp; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + all_sys_pwrgd: all-sys-pwrgd { + gpios = <&gpio_040_076 15 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD"; + }; /* GPIO057 */ + rsmrst_pwrgd: rsmrst-pwrgd { + gpios = <&gpio_200_236 17 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_RSMRST_ODL"; + }; /* GPIO221 */ + pch_slp_s0_n: pch-slp-s0-n { + gpios = <&gpio_240_276 3 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S0_L"; + }; /* GPIO243 */ + vccpdsw_3p3: vccpdsw-3p3 { + gpios = <&gpio_200_236 1 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_DSW_PWROK"; + }; /* GPIO201 */ + pm_slp_sus_ec_n: pm-slp-sus-ec-n { + gpios = <&gpio_200_236 23 GPIO_INPUT>; + enum-name = "GPIO_SLP_SUS_L"; + }; /* GPIO227 */ + pm_slp_s3_n: pm-slp-s3-n { + gpios = <&gpio_140_176 17 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S3_L"; + }; /* GPIO161 */ + pm_slp_s4_n: pm-slp-s4-n { + gpios = <&gpio_140_176 18 GPIO_INPUT>; + }; /* GPIO162 */ + volume_up { + gpios = <&gpio_000_036 30 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; /* GPIO036 */ + vol_dn_ec { + gpios = <&gpio_240_276 12 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; /* GPIO254 */ + smc_lid: smc-lid { + gpios = <&gpio_200_236 22 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_LID_OPEN"; + }; /* GPIO226 */ + mech_pwr_btn_odl: mech-pwr-btn-odl { + gpios = <&gpio_100_136 13 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; /* GPIO115 */ + std_adp_prsnt: std-adp-prsnt { + gpios = <&gpio_040_076 3 GPIO_INPUT>; + enum-name= "GPIO_DC_JACK_PRESENT"; + }; /* GPIO043 */ + bc_acok: bc-acok { + gpios = <&gpio_140_176 14 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; /* GPIO156 */ + usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { + gpios = <&gpio_140_176 3 GPIO_INPUT>; + }; /* GPIO143 */ + usbc_tcpc_alrt_p1: usbc-tcpc-alrt-p1 { + gpios = <&gpio_240_276 1 GPIO_INPUT>; + }; /* GPIO241 */ + usbc_tcpc_alrt_p2: usbc-tcpc-alrt-p2 { + gpios = <&gpio_100_136 24 GPIO_INPUT>; + }; /* GPIO130 */ + usbc_tcpc_alrt_p3: usbc-tcpc-alrt-p3 { + gpios = <&gpio_240_276 2 GPIO_INPUT>; + }; /* GPIO242 */ + usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { + gpios = <&gpio_240_276 0 GPIO_INPUT>; + }; /* GPIO240 */ + usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { + gpios = <&gpio_100_136 1 GPIO_INPUT>; + }; /* GPIO101 */ + usbc_tcpc_ppc_alrt_p2: usbc-tcpc-ppc-alrt-p2 { + gpios = <&gpio_140_176 4 GPIO_INPUT>; + }; /* GPIO144 */ + usbc_tcpc_ppc_alrt_p3: usbc-tcpc-ppc-alrt-p3 { + gpios = <&gpio_140_176 2 GPIO_INPUT>; + }; /* GPIO142 */ + gpio_ec_pch_wake_odl: smc-wake-sci-n-mecc { + gpios = <&gpio_040_076 9 GPIO_ODR_HIGH>; + }; /* GPIO051 */ + ec_pch_mkbp_int_odl { + gpios = <&gpio_100_136 23 GPIO_ODR_HIGH>; + }; /* GPIO127 */ + lpc_espi_rst_n { + gpios = <&gpio_040_076 17 GPIO_INPUT>; + }; /* GPIO061 NANA */ + plt_rst_l { + gpios = <&gpio_040_076 10 GPIO_INPUT>; + }; /* GPIO052 NANA */ + slate_mode_indication { + gpios = <&gpio_200_236 18 GPIO_INPUT>; + }; /* GPIO222 */ + prochot_ec_n { + gpios = <&gpio_000_036 2 GPIO_INPUT>; + enum-name = "GPIO_CPU_PROCHOT"; + }; /* GPIO002 ???? */ + sys_rst_odl { + gpios = <&gpio_040_076 16 GPIO_ODR_HIGH>; + enum-name = "GPIO_SYS_RESET_L"; + }; /* GPIO060 */ + pm_rsmrst_n { + gpios = <&gpio_040_076 12 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_RSMRST_L"; + }; /* GPIO054 */ + pm_pwrbtn_n { + gpios = <&gpio_000_036 14 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; /* GPIO016 */ + ec_spi_oe_mecc: ec-spi-oe-mecc { + gpios = <&gpio_040_076 2 GPIO_OUTPUT_LOW>; + }; /* GPIO042 */ + ec_ds3 { + gpios = <&gpio_000_036 21 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PP3300_A"; + }; /* GPIO025 */ + pch_pwrok_ec { + gpios = <&gpio_100_136 6 GPIO_INPUT>; + enum-name = "GPIO_PCH_PWROK"; + }; /* GPIO106 */ + sys_pwrok { + gpios = <&gpio_200_236 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_SYS_PWROK"; + }; /* GPIO202 */ + ec_dsw_pwrok { + gpios = <&gpio_000_036 28 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_DSW_PWROK"; + }; /* GPIO034 */ + gpio_wp: ec-flash-wp-odl { + gpios = <&gpio_000_036 12 GPIO_INPUT>; + }; /* GPIO014 */ + ec_h1_packet_mode { + gpios = <&gpio_000_036 29 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; /* GPIO035 */ + ec_entering_rw { + gpios = <&gpio_100_136 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; /* GPIO102 */ + ccd_mode_odl: ccd-mode-odl { + gpios = <&gpio_140_176 29 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; /* GPIO175 */ + bat_det { + gpios = <&gpio_200_236 6 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; /* GPIO206 */ + edp_bklt_en_mecc { + gpios = <&gpio_000_036 18 GPIO_OUTPUT_HIGH>; + }; /* GPIO022 */ + led_1_l { + gpios = <&gpio_140_176 15 GPIO_OUTPUT_HIGH>; + }; /* GPIO157 */ + led_2_l { + gpios = <&gpio_140_176 11 GPIO_OUTPUT_HIGH>; + }; /* GPIO153 */ + therm_sen_mecc { + gpios = <&gpio_140_176 1 GPIO_OUTPUT_LOW>; + }; /* GPIO141 */ + smb_bs_clk { + gpios = <&gpio_000_036 4 GPIO_INPUT>; + }; /* GPIO004 */ + smb_bs_data { + gpios = <&gpio_000_036 3 GPIO_INPUT>; + }; /* GPIO003 */ + usbc_tcpc_i2c_clk_p0 { + gpios = <&gpio_140_176 0 GPIO_INPUT>; + }; /* GPIO140 */ + usbc_tcpc_i2c_data_p0 { + gpios = <&gpio_100_136 26 GPIO_INPUT>; + }; /* GPIO132 */ + usbc_tcpc_i2c_clk_p2 { + gpios = <&gpio_000_036 8 GPIO_INPUT>; + }; /* GPIO010 */ + usbc_tcpc_i2c_data_p2 { + gpios = <&gpio_000_036 7 GPIO_INPUT>; + }; /* GPIO007 */ + usbc_tcpc_i2c_clk_p1 { + gpios = <&gpio_000_036 11 GPIO_INPUT>; + }; /* GPIO013 */ + usbc_tcpc_i2c_data_p1 { + gpios = <&gpio_000_036 10 GPIO_INPUT>; + }; /* GPIO012 */ + usbc_tcpc_i2c_clk_p3 { + gpios = <&gpio_140_176 13 GPIO_INPUT>; + }; /* GPIO155 */ + usbc_tcpc_i2c_data_p3 { + gpios = <&gpio_140_176 12 GPIO_INPUT>; + }; /* GPIO154 */ + sml1_clk_mecc { + gpios = <&gpio_100_136 25 GPIO_INPUT>; + }; /* GPIO131 */ + cpu_cat_err_mecc { + gpios = <&gpio_000_036 0 GPIO_INPUT>; + }; /* GPIO000 */ + espi_alert0_n { + gpios = <&gpio_040_076 19 GPIO_INPUT>; + }; /* GPIO063 NANA */ + batt_disable_ec { + gpios = <&gpio_040_076 23 GPIO_INPUT>; + }; /* GPIO067 */ + cpu_c10_gate_mecc { + gpios = <&gpio_000_036 19 GPIO_INPUT>; + }; /* GPIO023 */ + smc_sdown_mecc { + gpios = <&gpio_240_276 13 GPIO_INPUT>; + }; /* GPIO255 */ + std_adpt_cntrl_gpio { + gpios = <&gpio_240_276 4 GPIO_INPUT>; + }; /* GPIO244 */ + smc_onoff_n { + gpios = <&gpio_100_136 12 GPIO_INPUT>; + }; /* GPIO114 */ + suswarn { + gpios = <&gpio_000_036 20 GPIO_INPUT>; + }; /* GPIO024 */ + me_g3_to_m3_ec { + gpios = <&gpio_000_036 27 GPIO_INPUT>; + }; /* GPIO033 */ + gpio_ec_kso_02_inv: ec-kso-02-inv { + gpios = <&gpio_040_076 6 (GPIO_OUTPUT_LOW + | GPIO_ACTIVE_LOW)>; + }; /* GPIO046 */ + + usb_c0_bb_retimer_rst: usb-c0-bb-retimer-rst { + gpios = <&ioex_c0_port 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_BB_RETIMER_RST"; + }; + usb_c0_bb_retimer_ls_en: usb-c0-bb-retimer-ls-en { + gpios = <&ioex_c0_port 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_BB_RETIMER_LS_EN"; + }; + usb-c0-usb-mux-cntrl-1 { + gpios = <&ioex_c0_port 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_USB_MUX_CNTRL_1"; + }; + usb-c0-usb-mux-cntrl-0 { + gpios = <&ioex_c0_port 5 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_USB_MUX_CNTRL_0"; + }; + usb_c1_bb_retimer_rst: usb-c1-bb-retimer-rst { + gpios = <&ioex_c1_port 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_BB_RETIMER_RST"; + }; + usb_c1_bb_retimer_ls_en: usb-c1-bb-retimer-ls-en { + gpios = <&ioex_c1_port 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_BB_RETIMER_LS_EN"; + }; + usb-c1-hpd { + gpios = <&ioex_c1_port 2 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_HPD"; + }; + usb-c0-c1-oc { + gpios = <&ioex_c1_port 8 GPIO_OUTPUT_HIGH>; + enum-name = "IOEX_USB_C0_C1_OC"; + }; + usb_c2_bb_retimer_rst: usb-c2-bb-retimer-rst { + gpios = <&ioex_c2_port 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C2_BB_RETIMER_RST"; + }; + usb_c2_bb_retimer_ls_en: usb-c2-bb-retimer-ls-en { + gpios = <&ioex_c2_port 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C2_BB_RETIMER_LS_EN"; + }; + usb-c2-usb-mux-cntrl-1 { + gpios = <&ioex_c2_port 4 GPIO_OUTPUT_LOW>; + }; + usb-c2-usb-mux-cntrl-0 { + gpios = <&ioex_c2_port 5 GPIO_OUTPUT_LOW>; + }; + usb_c3_bb_retimer_rst: usb-c3-bb-retimer-rst { + gpios = <&ioex_c3_port 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C3_BB_RETIMER_RST"; + }; + usb_c3_bb_retimer_ls_en: usb-c3-bb-retimer-ls-en { + gpios = <&ioex_c3_port 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C3_BB_RETIMER_LS_EN"; + }; + usb-c2-c3-oc { + gpios = <&ioex_c3_port 8 GPIO_OUTPUT_HIGH>; + enum-name = "IOEX_USB_C2_C3_OC"; + }; + /* unimplemented GPIOs */ + en-pp5000 { + enum-name = "GPIO_EN_PP5000"; + }; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts new file mode 100644 index 0000000000..17986fe2c7 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts @@ -0,0 +1,80 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_lid_open: lid-open { + irq-pin = <&smc_lid>; + flags = ; + handler = "lid_interrupt"; + }; + int_power_button: power-button { + irq-pin = <&mech_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_ac_present: ac-present { + irq-pin = <&bc_acok>; + flags = ; + handler = "extpower_interrupt"; + }; + int_slp_s0: slp-s0 { + irq-pin = <&pch_slp_s0_n>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_slp_sus: slp-sus { + irq-pin = <&pm_slp_sus_ec_n>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_pg_dsw_pwrok: pg-dsw-pwrok { + irq-pin = <&vccpdsw_3p3>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_rsmrst_pwrgd: rsmrst-pwrgd { + irq-pin = <&rsmrst_pwrgd>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_all_sys_pwrgd: all-sys-pwrgd { + irq-pin = <&all_sys_pwrgd>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { + irq-pin = <&usbc_tcpc_alrt_p0>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usbc_tcpc_alrt_p1: usbc-tcpc-alrt-p1 { + irq-pin = <&usbc_tcpc_alrt_p1>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { + irq-pin = <&usbc_tcpc_ppc_alrt_p0>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { + irq-pin = <&usbc_tcpc_ppc_alrt_p1>; + flags = ; + handler = "ppc_interrupt"; + }; + int_std_adp_prsnt: std-adp-prsnt { + irq-pin = <&std_adp_prsnt>; + flags = ; + handler = "board_dc_jack_interrupt"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&ccd_mode_odl>; + flags = ; + handler = "board_connect_c0_sbu"; + }; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts new file mode 100644 index 0000000000..b3577e6afd --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + output-settle = <80>; + debounce-down = <9000>; + debounce-up = <30000>; + poll-timeout = <100000>; + + actual-key-mask = < + 0x14 /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf new file mode 100644 index 0000000000..083530c858 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf @@ -0,0 +1,84 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_ADLRVP_MCHP=y +CONFIG_CROS_FLASH_XEC=y +CONFIG_CROS_SYSTEM_XEC=y +CONFIG_CROS_KB_RAW_XEC=y + +# For MCHP ESPI Drivers +CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y +CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION=y +CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE=y +CONFIG_ESPI_PERIPHERAL_XEC_EMI0=y +CONFIG_ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA=y +CONFIG_ESPI_PERIPHERAL_KBC_OBE_CBK=y +CONFIG_ESPI_PERIPHERAL_KBC_IBF_EVT_DATA=y + +# Invoke SoC Python script to create zephyr.mchp.bin which +# is zephyr.bin processed for Boot-ROM loading. +CONFIG_MCHP_MEC_UNSIGNED_HEADER=y +CONFIG_MCHP_MEC_HEADER_FLASH_SIZE_256K=y + +# Support Zephyr SPI NOR driver to work with MCHP SPI driver +CONFIG_SPI_NOR=y +CONFIG_SPI_XEC_QMSPI_FULL_DUPLEX=y + +# Sensors - MCHP TACH driver under sensor +CONFIG_SENSOR=n +CONFIG_SENSOR_SHELL=n + +# Debug option +# Enable flash console commands +CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y + + +## TODO - support following features next +# Fan +CONFIG_PLATFORM_EC_FAN=n + +# RTC +CONFIG_PLATFORM_EC_RTC=n + +# PWM +CONFIG_PWM=n +CONFIG_PWM_SHELL=n + +## INTEL RVP +# Host command +CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=n + +# Power Sequencing +CONFIG_PLATFORM_EC_THROTTLE_AP=n + +## ADL RVP +# CBI +CONFIG_EEPROM=n +CONFIG_EEPROM_AT24=n +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_CBI_EEPROM=n + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=n +CONFIG_PLATFORM_EC_LED_PWM=n +CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=n + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=n +CONFIG_PLATFORM_EC_THERMISTOR=n +CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=n + +# Charger +CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y + +# H1 issues second reset +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n + +# 7-Segment Display +CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=n + +# Debug options +# Enable flash console commands +CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y +CONFIG_WDT_DISABLE_AT_BOOT=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/usbc.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/usbc.dts new file mode 100644 index 0000000000..471a1f52e9 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/usbc.dts @@ -0,0 +1,89 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + usbc_port0: port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb_mux_chain_0: usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c0_bb_retimer + &virtual_mux_c0>; + }; + usb_mux_alt_chain_0: usb-mux-alt-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&usb_c0_bb_retimer + &usb_c0_soc_side_bb_retimer + &virtual_mux_c0>; + }; + }; + port0-muxes { + virtual_mux_c0: virtual-mux-c0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + usbc_port1: port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + tcpc = <&tcpc_port1>; + usb_mux_chain_1: usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c1_bb_retimer + &virtual_mux_c1>; + }; + usb_mux_alt_chain_1: usb-mux-alt-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&usb_c1_bb_retimer + &usb_c1_soc_side_bb_retimer + &virtual_mux_c1>; + }; + }; + port1-muxes { + virtual_mux_c1: virtual-mux-c1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port2@2 { + compatible = "named-usbc-port"; + reg = <2>; + tcpc = <&tcpc_port2>; + usb_mux_chain_2: usb-mux-chain-2 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c2_bb_retimer + &virtual_mux_c2>; + }; + }; + port2-muxes { + virtual_mux_c2: virtual-mux-c2 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port3@3 { + compatible = "named-usbc-port"; + reg = <3>; + tcpc = <&tcpc_port3>; + usb_mux_chain_3: usb-mux-chain-3 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c3_bb_retimer + &virtual_mux_c3>; + }; + }; + port3-muxes { + virtual_mux_c3: virtual-mux-c3 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts new file mode 100644 index 0000000000..79723beabd --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts @@ -0,0 +1,258 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + cros,rtc = &mtc; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_lid_open + &int_power_button + >; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_charger: charger { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_BATTERY", + "I2C_PORT_CHARGER", + "I2C_PORT_EEPROM", + "I2C_PORT_PORT80"; + }; + typec_0: typec-0 { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_TYPEC_0"; + }; + typec_1: typec-1 { + i2c-port = <&i2c2_0>; + enum-names = "I2C_PORT_TYPEC_1"; + }; + typec_2: typec-2 { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_TYPEC_2"; + }; + typec_3: typec-3 { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_TYPEC_3"; + }; + }; + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 3>; + }; + adc_ddr: ddr { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 4>; + }; + adc_skin: skin { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 2>; + }; + adc_vr: vr { + enum-name = "ADC_TEMP_SENSOR_4"; + io-channels = <&adc0 1>; + }; + }; + +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; + +/* charger */ +&i2c7_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; + + pca95xx: pca95xx@22 { + compatible = "nxp,pca95xx"; + label = "PCA95XX"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <16>; + }; + + rvp_board_id: rvp-board-id { + compatible = "intel,rvp-board-id"; + + /* + * BOM ID [2] : IOEX[0] + * BOM ID [1:0] : IOEX[15:14] + */ + bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>; + + /* + * FAB ID [1:0] : IOEX[2:1] + */ + fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>; + + /* + * BOARD ID[5:0] : IOEX[13:8] + */ + board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>, + <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>; + }; + + seven_seg_display: max695x-seven-seg-display@38 { + compatible = "maxim,seven-seg-display"; + reg = <0x38>; + label = "MAX695X_SEVEN_SEG_DISPLAY"; + }; + + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c_ctrl7 { + status = "okay"; +}; + +/* typec_0 */ +&i2c0_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + + tcpc_port0: fusb302@22 { + compatible = "fairchild,fusb302"; + reg = <0x22>; + }; + + usb_c0_soc_side_bb_retimer: jhl8040r-c0-soc-side@54 { + compatible = "intel,jhl8040r"; + reg = <0x54>; + reset-pin = <&usb_c0_bb_retimer_rst>; + ls-en-pin = <&usb_c0_bb_retimer_ls_en>; + }; + + usb_c0_bb_retimer: jhl8040r-c0@56 { + compatible = "intel,jhl8040r"; + reg = <0x56>; + reset-pin = <&usb_c0_bb_retimer_rst>; + ls-en-pin = <&usb_c0_bb_retimer_ls_en>; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +/* typec_1 */ +&i2c2_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; + + tcpc_port1: fusb302@22 { + compatible = "fairchild,fusb302"; + reg = <0x22>; + }; + + usb_c1_soc_side_bb_retimer: jhl8040r-c1-soc-side@55 { + compatible = "intel,jhl8040r"; + reg = <0x55>; + reset-pin = <&usb_c1_bb_retimer_rst>; + ls-en-pin = <&usb_c1_bb_retimer_ls_en>; + }; + + usb_c1_bb_retimer: jhl8040r-c1@57 { + compatible = "intel,jhl8040r"; + reg = <0x57>; + reset-pin = <&usb_c1_bb_retimer_rst>; + ls-en-pin = <&usb_c1_bb_retimer_ls_en>; + }; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +/* typec_2 */ +&i2c1_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + tcpc_port2: fusb302@22 { + compatible = "fairchild,fusb302"; + reg = <0x22>; + }; + + usb_c2_bb_retimer: jhl8040r-c2@58 { + compatible = "intel,jhl8040r"; + reg = <0x58>; + reset-pin = <&usb_c2_bb_retimer_rst>; + ls-en-pin = <&usb_c2_bb_retimer_ls_en>; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +/* typec_3 */ +&i2c3_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; + + tcpc_port3: fusb302@22 { + compatible = "fairchild,fusb302"; + reg = <0x22>; + }; + + usb_c3_bb_retimer: jhl8040r-c3@59 { + compatible = "intel,jhl8040r"; + reg = <0x59>; + reset-pin = <&usb_c3_bb_retimer_rst>; + ls-en-pin = <&usb_c3_bb_retimer_ls_en>; + }; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42 + &adc0_chan4_gp41>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/fan.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/fan.dts new file mode 100644 index 0000000000..8babe53903 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/fan.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm3 0 PWM_KHZ(30) PWM_POLARITY_NORMAL>; + rpm_min = <3000>; + rpm_start = <3000>; + rpm_max = <10000>; + tach = <&tach2>; + pgood_gpio = <&all_sys_pwrgd>; + enable_gpio = <&gpio_fan_control>; + }; + }; +}; + +/* Tachemeter for fan speed measurement */ +&tach2 { + status = "okay"; + pinctrl-0 = <&ta2_2_in_gpa6>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm3 { + status = "okay"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/gpio.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/gpio.dts new file mode 100644 index 0000000000..1d38fc877c --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/gpio.dts @@ -0,0 +1,344 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_wp; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + all_sys_pwrgd: all-sys-pwrgd { + gpios = <&gpio7 0 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD"; + }; + rsmrst_pwrgd: rsmrst-pwrgd { + gpios = <&gpio3 7 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_RSMRST_ODL"; + }; + pch_slp_s0_n: pch-slp-s0-n { + gpios = <&gpioa 1 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S0_L"; + }; + vccpdsw_3p3: vccpdsw-3p3 { + gpios = <&gpio4 5 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_DSW_PWROK"; + }; + pm_slp_sus_ec_n: pm-slp-sus-ec-n { + gpios = <&gpio8 6 GPIO_INPUT>; + enum-name = "GPIO_SLP_SUS_L"; + }; + pm-slp-s3-n { + gpios = <&gpiob 0 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S3_L"; + }; + pm-slp-s4-n { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + volume-up { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + vol-dn-ec { + gpios = <&gpio0 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + smc_lid: smc-lid { + gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_LID_OPEN"; + }; + mech_pwr_btn_odl: mech-pwr-btn-odl { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + std_adp_prsnt: std-adp-prsnt { + gpios = <&gpio0 2 GPIO_INPUT>; + enum-name= "GPIO_DC_JACK_PRESENT"; + }; + bc_acok: bc-acok { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { + gpios = <&gpio4 0 GPIO_INPUT>; + }; + usbc_tcpc_alrt_p1: usbc-tcpc-alrt-p1 { + gpios = <&gpio6 2 GPIO_INPUT>; + }; + usbc_tcpc_alrt_p2: usbc-tcpc-alrt-p2 { + gpios = <&gpio6 3 GPIO_INPUT>; + }; + usbc_tcpc_alrt_p3: usbc-tcpc-alrt-p3 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { + gpios = <&gpiof 1 GPIO_INPUT>; + }; + usbc_tcpc_ppc_alrt_p2: usbc-tcpc-ppc-alrt-p2 { + gpios = <&gpiof 2 GPIO_INPUT>; + }; + usbc_tcpc_ppc_alrt_p3: usbc-tcpc-ppc-alrt-p3 { + gpios = <&gpiof 3 GPIO_INPUT>; + }; + gpio_ec_pch_wake_odl: smc-wake-sci-n-mecc { + gpios = <&gpioa 4 GPIO_ODR_HIGH>; + }; + ec-pch-mkbp-int-odl { + gpios = <&gpiof 5 GPIO_ODR_HIGH>; + }; + lpc-espi-rst-n { + gpios = <&gpio5 4 GPIO_INPUT>; + }; + plt-rst-l { + gpios = <&gpioa 2 GPIO_INPUT>; + }; + slate-mode-indication { + gpios = <&gpioe 5 GPIO_INPUT>; + }; + prochot-ec-n { + gpios = <&gpioa 7 GPIO_INPUT>; + enum-name = "GPIO_CPU_PROCHOT"; + }; + sys-rst-odl { + gpios = <&gpioc 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_SYS_RESET_L"; + }; + pm-rsmrst-n { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_RSMRST_L"; + }; + pm-pwrbtn-n { + gpios = <&gpio9 7 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + ec_spi_oe_mecc: ec-spi-oe-mecc { + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + ec-ds3 { + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PP3300_A"; + alias = "GPIO_TEMP_SENSOR_POWER"; + }; + pch-pwrok-ec { + gpios = <&gpioa 0 GPIO_INPUT>; + enum-name = "GPIO_PCH_PWROK"; + }; + sys-pwrok { + gpios = <&gpio9 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_SYS_PWROK"; + }; + ec-dsw-pwrok { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_DSW_PWROK"; + }; + gpio_wp: ec-flash-wp-odl { + gpios = <&gpio9 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + ec-h1-packet-mode { + gpios = <&gpioe 2 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + ec-entering-rw { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ccd_mode_odl: ccd-mode-odl { + gpios = <&gpiof 4 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + bat-det { + gpios = <&gpio7 6 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + edp-bklt-en-mecc { + gpios = <&gpioe 1 GPIO_OUTPUT_HIGH>; + }; + led_red_l: led-1-l { + gpios = <&gpiob 6 GPIO_OUTPUT_HIGH>; + }; + led_white_l: led-2-l { + gpios = <&gpiob 7 GPIO_OUTPUT_HIGH>; + }; + gpio_fan_control: therm-sen-mecc { + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + smb-bs-clk { + gpios = <&gpiob 3 GPIO_INPUT>; + }; + smb-bs-data { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usbc-tcpc-i2c-clk-p0 { + gpios = <&gpiob 5 GPIO_INPUT>; + }; + usbc-tcpc-i2c-data-p0 { + gpios = <&gpiob 4 GPIO_INPUT>; + }; + usbc-tcpc-i2c-clk-p2 { + gpios = <&gpio9 2 GPIO_INPUT>; + }; + usbc-tcpc-i2c-data-p2 { + gpios = <&gpio9 1 GPIO_INPUT>; + }; + usbc-tcpc-i2c-clk-p1 { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + usbc-tcpc-i2c-data-p1 { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + usbc-tcpc-i2c-clk-p3 { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + usbc-tcpc-i2c-data-p3 { + gpios = <&gpiod 0 GPIO_INPUT>; + }; + sml1-clk-mecc { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + sml1-data-mecc { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + smb-pch-clk { + gpios = <&gpioc 2 GPIO_INPUT>; + }; + smb-pch-data { + gpios = <&gpioc 1 GPIO_INPUT>; + }; + i3c-0-scl { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + i3c-0-sda { + gpios = <&gpioe 3 GPIO_INPUT>; + }; + cpu-cat-err-mecc { + gpios = <&gpio3 4 GPIO_INPUT>; + }; + tp29 { + gpios = <&gpio5 0 GPIO_INPUT>; + }; + tp28 { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + espi-alert0-n { + gpios = <&gpio5 7 GPIO_INPUT>; + }; + batt-disable-ec { + gpios = <&gpio6 6 GPIO_INPUT>; + }; + tp33 { + gpios = <&gpio7 2 GPIO_INPUT>; + }; + tp26 { + gpios = <&gpio7 3 GPIO_INPUT>; + }; + slp-s0-cs-n { + gpios = <&gpio7 4 GPIO_INPUT>; + }; + ec-peci { + gpios = <&gpio8 1 GPIO_INPUT>; + }; + cpu-c10-gate-mecc { + gpios = <&gpio9 6 GPIO_INPUT>; + }; + smb-pch-alrt { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + smc-sdown-mecc { + gpios = <&gpiob 1 GPIO_INPUT>; + }; + std-adpt-cntrl-gpio { + gpios = <&gpioc 3 GPIO_INPUT>; + }; + sml1-alert { + gpios = <&gpioc 7 GPIO_INPUT>; + }; + smc-onoff-n { + gpios = <&gpiod 2 GPIO_INPUT>; + }; + suswarn { + gpios = <&gpiod 5 GPIO_INPUT>; + }; + tp-gpiod6-ec { + gpios = <&gpiod 6 GPIO_INPUT>; + }; + tp-gpiod7-ec { + gpios = <&gpiod 7 GPIO_INPUT>; + }; + me-g3-to-m3-ec { + gpios = <&gpioe 0 GPIO_INPUT>; + }; + gpio_ec_kso_02_inv: ec-kso-02-inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + + usb_c0_bb_retimer_rst: usb-c0-bb-retimer-rst { + gpios = <&ioex_c0_port 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_BB_RETIMER_RST"; + }; + usb_c0_bb_retimer_ls_en: usb-c0-bb-retimer-ls-en { + gpios = <&ioex_c0_port 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_BB_RETIMER_LS_EN"; + }; + usb-c0-usb-mux-cntrl-1 { + gpios = <&ioex_c0_port 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_USB_MUX_CNTRL_1"; + }; + usb-c0-usb-mux-cntrl-0 { + gpios = <&ioex_c0_port 5 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_USB_MUX_CNTRL_0"; + }; + usb_c1_bb_retimer_rst: usb-c1-bb-retimer-rst { + gpios = <&ioex_c1_port 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_BB_RETIMER_RST"; + }; + usb_c1_bb_retimer_ls_en: usb-c1-bb-retimer-ls-en { + gpios = <&ioex_c1_port 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_BB_RETIMER_LS_EN"; + }; + usb-c1-hpd { + gpios = <&ioex_c1_port 2 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_HPD"; + }; + usb-c0-c1-oc { + gpios = <&ioex_c1_port 8 GPIO_OUTPUT_HIGH>; + enum-name = "IOEX_USB_C0_C1_OC"; + }; + usb_c2_bb_retimer_rst: usb-c2-bb-retimer-rst { + gpios = <&ioex_c2_port 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C2_BB_RETIMER_RST"; + }; + usb_c2_bb_retimer_ls_en: usb-c2-bb-retimer-ls-en { + gpios = <&ioex_c2_port 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C2_BB_RETIMER_LS_EN"; + }; + usb-c2-usb-mux-cntrl-1 { + gpios = <&ioex_c2_port 4 GPIO_OUTPUT_LOW>; + }; + usb-c2-usb-mux-cntrl-0 { + gpios = <&ioex_c2_port 5 GPIO_OUTPUT_LOW>; + }; + usb_c3_bb_retimer_rst: usb-c3-bb-retimer-rst { + gpios = <&ioex_c3_port 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C3_BB_RETIMER_RST"; + }; + usb_c3_bb_retimer_ls_en: usb-c3-bb-retimer-ls-en { + gpios = <&ioex_c3_port 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C3_BB_RETIMER_LS_EN"; + }; + usb-c2-c3-oc { + gpios = <&ioex_c3_port 8 GPIO_OUTPUT_HIGH>; + enum-name = "IOEX_USB_C2_C3_OC"; + }; + /* unimplemented GPIOs */ + en-pp5000 { + enum-name = "GPIO_EN_PP5000"; + }; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts new file mode 100644 index 0000000000..d7bb40fad2 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts @@ -0,0 +1,100 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_lid_open: lid-open { + irq-pin = <&smc_lid>; + flags = ; + handler = "lid_interrupt"; + }; + int_power_button: power-button { + irq-pin = <&mech_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_ac_present: ac-present { + irq-pin = <&bc_acok>; + flags = ; + handler = "extpower_interrupt"; + }; + int_slp_s0: slp-s0 { + irq-pin = <&pch_slp_s0_n>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_slp_sus: slp-sus { + irq-pin = <&pm_slp_sus_ec_n>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_pg_dsw_pwrok: pg-dsw-pwrok { + irq-pin = <&vccpdsw_3p3>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_rsmrst_pwrgd: rsmrst-pwrgd { + irq-pin = <&rsmrst_pwrgd>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_all_sys_pwrgd: all-sys-pwrgd { + irq-pin = <&all_sys_pwrgd>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { + irq-pin = <&usbc_tcpc_alrt_p0>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usbc_tcpc_alrt_p1: usbc-tcpc-alrt-p1 { + irq-pin = <&usbc_tcpc_alrt_p1>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usbc_tcpc_alrt_p2: usbc-tcpc-alrt-p2 { + irq-pin = <&usbc_tcpc_alrt_p2>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usbc_tcpc_alrt_p3: usbc-tcpc-alrt-p3 { + irq-pin = <&usbc_tcpc_alrt_p3>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { + irq-pin = <&usbc_tcpc_ppc_alrt_p0>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { + irq-pin = <&usbc_tcpc_ppc_alrt_p1>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usbc_tcpc_ppc_alrt_p2: usbc-tcpc-ppc-alrt-p2 { + irq-pin = <&usbc_tcpc_ppc_alrt_p2>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usbc_tcpc_ppc_alrt_p3: usbc-tcpc-ppc-alrt-p3 { + irq-pin = <&usbc_tcpc_ppc_alrt_p3>; + flags = ; + handler = "ppc_interrupt"; + }; + int_std_adp_prsnt: std-adp-prsnt { + irq-pin = <&std_adp_prsnt>; + flags = ; + handler = "board_dc_jack_interrupt"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&ccd_mode_odl>; + flags = ; + handler = "board_connect_c0_sbu"; + }; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts new file mode 100644 index 0000000000..81d6e82f48 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + output-settle = <35>; + debounce-down = <5000>; + debounce-up = <40000>; + poll-timeout = <100000>; + + actual-key-mask = < + 0x14 /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf new file mode 100644 index 0000000000..2c98fd9330 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf @@ -0,0 +1,24 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_ADLRVP_NPCX=y +CONFIG_CROS_FLASH_NPCX=y +CONFIG_CROS_SYSTEM_NPCX=y +CONFIG_SYSCON=y + +# Charger +CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y + +# FAN +CONFIG_TACH_NPCX=y + +# Keyboard +CONFIG_CROS_KB_RAW_NPCX=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# RTC +CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts new file mode 100644 index 0000000000..eb1576dbff --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts @@ -0,0 +1,57 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm4 0 PWM_HZ(4800) PWM_POLARITY_INVERTED>; + }; + pwm_led1: pwm_led_1 { + pwms = <&pwm5 0 PWM_HZ(4800) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0 &pwm_led1>; + + color-map-green = <100>; + + /* brightness-range = */ + brightness-range = <0 100 0 0 0 0>; + + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + + pwm_led_1@1 { + reg = <1>; + ec-led-name = "EC_LED_ID_POWER_LED"; + }; + }; +}; + +/* LED1 */ +&pwm4 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm4_gpb6>; + pinctrl-names = "default"; +}; + +/* LED2 */ +&pwm5 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts new file mode 100644 index 0000000000..93ecaa02f6 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts @@ -0,0 +1,89 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V0_22K6_47K_4050B>; + adc = <&adc_ambient>; + }; + temp_ddr: ddr { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V0_22K6_47K_4050B>; + adc = <&adc_ddr>; + }; + temp_skin: skin { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V0_22K6_47K_4050B>; + adc = <&adc_skin>; + }; + temp_vr: vr { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V0_22K6_47K_4050B>; + adc = <&adc_vr>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ambient { + temp_fan_off = <15>; + temp_fan_max = <50>; + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + sensor = <&temp_ambient>; + }; + + /* + * TDB: battery temp read api is not using thermistor and + * zephyr shim layer doesn't support to configure custom read + * function. + * + * battery { + * compatible = "cros-ec,temp-sensor-thermistor", + * "cros-ec,temp-sensor"; + * thermistor = < >; + * enum-name = ""; + * temp_fan_off = <15>; + * temp_fan_max = <50>; + * temp_host_high = <75>; + * temp_host_halt = <80>; + * temp_host_release_high = <65>; + * adc = <&adc_battery>; + * }; + */ + + ddr { + temp_fan_off = <15>; + temp_fan_max = <50>; + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + sensor = <&temp_ddr>; + }; + skin { + temp_fan_off = <15>; + temp_fan_max = <50>; + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + sensor = <&temp_skin>; + }; + vr { + temp_fan_off = <15>; + temp_fan_max = <50>; + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + sensor = <&temp_vr>; + }; + }; +}; + +&thermistor_3V0_22K6_47K_4050B { + status = "okay"; +}; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/usbc.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/usbc.dts new file mode 100644 index 0000000000..471a1f52e9 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/usbc.dts @@ -0,0 +1,89 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + usbc_port0: port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb_mux_chain_0: usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c0_bb_retimer + &virtual_mux_c0>; + }; + usb_mux_alt_chain_0: usb-mux-alt-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&usb_c0_bb_retimer + &usb_c0_soc_side_bb_retimer + &virtual_mux_c0>; + }; + }; + port0-muxes { + virtual_mux_c0: virtual-mux-c0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + usbc_port1: port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + tcpc = <&tcpc_port1>; + usb_mux_chain_1: usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c1_bb_retimer + &virtual_mux_c1>; + }; + usb_mux_alt_chain_1: usb-mux-alt-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&usb_c1_bb_retimer + &usb_c1_soc_side_bb_retimer + &virtual_mux_c1>; + }; + }; + port1-muxes { + virtual_mux_c1: virtual-mux-c1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port2@2 { + compatible = "named-usbc-port"; + reg = <2>; + tcpc = <&tcpc_port2>; + usb_mux_chain_2: usb-mux-chain-2 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c2_bb_retimer + &virtual_mux_c2>; + }; + }; + port2-muxes { + virtual_mux_c2: virtual-mux-c2 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port3@3 { + compatible = "named-usbc-port"; + reg = <3>; + tcpc = <&tcpc_port3>; + usb_mux_chain_3: usb-mux-chain-3 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c3_bb_retimer + &virtual_mux_c3>; + }; + }; + port3-muxes { + virtual_mux_c3: virtual-mux-c3 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/battery.dts b/zephyr/program/intelrvp/adlrvp/battery.dts new file mode 100644 index 0000000000..1de4111791 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/battery.dts @@ -0,0 +1,20 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + getac-3s = &default_battery; + getac-2s = &getac_smp_hhp_408_2s; + }; + + batteries { + default_battery: getac-smp-hhp-408-3s { + compatible = "getac,bq40z50-R3-S3", "battery-smart"; + }; + getac_smp_hhp_408_2s: getac-smp-hhp-408-2s { + compatible = "getac,bq40z50-R3-S2", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/include/adlrvp_zephyr.h b/zephyr/program/intelrvp/adlrvp/include/adlrvp_zephyr.h new file mode 100644 index 0000000000..135fd4ef4f --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/include/adlrvp_zephyr.h @@ -0,0 +1,58 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Intel ADL-RVP specific configuration */ + +#ifndef __ADLRVP_BOARD_H +#define __ADLRVP_BOARD_H + +#include "config.h" + +#define I2C_ADDR_FUSB302_TCPC_AIC 0x22 +#define I2C_ADDR_SN5S330_TCPC_AIC_PPC 0x40 + +#define I2C_ADDR_PCA9675_TCPC_AIC_IOEX 0x21 + +/* SOC side BB retimers (dual retimer config) */ +#define I2C_PORT0_BB_RETIMER_SOC_ADDR 0x54 +#if defined(HAS_TASK_PD_C1) +#define I2C_PORT1_BB_RETIMER_SOC_ADDR 0x55 +#endif + +#define ADLM_LP4_RVP1_SKU_BOARD_ID 0x01 +#define ADLM_LP5_RVP2_SKU_BOARD_ID 0x02 +#define ADLM_LP5_RVP3_SKU_BOARD_ID 0x03 +#define ADLN_LP5_ERB_SKU_BOARD_ID 0x06 +#define ADLN_LP5_RVP_SKU_BOARD_ID 0x07 +#define ADLP_DDR5_RVP_SKU_BOARD_ID 0x12 +#define ADLP_LP5_T4_RVP_SKU_BOARD_ID 0x13 +#define ADL_RVP_BOARD_ID(id) ((id)&0x3F) + +#define CONFIG_BATTERY_TYPE_NO_AUTO_DETECT + +enum adlrvp_charge_ports { + TYPE_C_PORT_0, +#if defined(HAS_TASK_PD_C1) + TYPE_C_PORT_1, +#endif +#if defined(HAS_TASK_PD_C2) + TYPE_C_PORT_2, +#endif +#if defined(HAS_TASK_PD_C3) + TYPE_C_PORT_3, +#endif +}; + +enum ioex_port { + IOEX_C0_PCA9675, + IOEX_C1_PCA9675, +#if defined(HAS_TASK_PD_C2) + IOEX_C2_PCA9675, + IOEX_C3_PCA9675, +#endif + IOEX_PORT_COUNT +}; + +#endif /* __ADLRVP_BOARD_H */ diff --git a/zephyr/program/intelrvp/adlrvp/ioex.dts b/zephyr/program/intelrvp/adlrvp/ioex.dts new file mode 100644 index 0000000000..3e2227dacb --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/ioex.dts @@ -0,0 +1,78 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* IOEX_C0_PCA9675 */ + ioex-c0 { + compatible = "cros,ioex-chip"; + i2c-port = <&typec_0>; + i2c-addr = <0x21>; + drv = "pca9675_ioexpander_drv"; + flags = <0x00>; + #address-cells = <1>; + #size-cells = <0>; + ioex_c0_port: ioex-c0-port@0 { + compatible = "cros,ioex-port"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <16>; + }; + }; + + /* IOEX_C1_PCA9675 */ + ioex-c1 { + compatible = "cros,ioex-chip"; + i2c-port = <&typec_1>; + i2c-addr = <0x21>; + drv = "pca9675_ioexpander_drv"; + flags = <0x00>; + #address-cells = <1>; + #size-cells = <0>; + ioex_c1_port: ioex-c1-port@0 { + compatible = "cros,ioex-port"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <16>; + }; + }; + + /* IOEX_C2_PCA9675 */ + ioex-c2 { + compatible = "cros,ioex-chip"; + i2c-port = <&typec_2>; + i2c-addr = <0x21>; + drv = "pca9675_ioexpander_drv"; + flags = <0x00>; + #address-cells = <1>; + #size-cells = <0>; + ioex_c2_port: ioex-c2-port@0 { + compatible = "cros,ioex-port"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <16>; + }; + }; + + /* IOEX_C3_PCA9675 */ + ioex-c3 { + compatible = "cros,ioex-chip"; + i2c-port = <&typec_3>; + i2c-addr = <0x21>; + drv = "pca9675_ioexpander_drv"; + flags = <0x00>; + #address-cells = <1>; + #size-cells = <0>; + ioex_c3_port: ioex-c3-port@0 { + compatible = "cros,ioex-port"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <16>; + }; + }; +}; diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf new file mode 100644 index 0000000000..4bcee4a953 --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -0,0 +1,76 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Power Sequencing +CONFIG_AP_X86_INTEL_TGL=y +CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n +CONFIG_PLATFORM_EC_POWERSEQ_ICELAKE=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y +CONFIG_PLATFORM_EC_BATTERY_V2=y + +# BC1.2 +CONFIG_PLATFORM_EC_USB_CHARGER=n + +# CBI +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_CBI_EEPROM=y + +# Charger +CONFIG_PLATFORM_EC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=n +CONFIG_PLATFORM_EC_CHARGER_BQ25720=y +CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y +CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70 +CONFIG_PLATFORM_EC_CHARGER_ISL9241=y +CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=y +CONFIG_PLATFORM_EC_LED_PWM=y +CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=y + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y +CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y + +# USB-C and PD +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_MUX_TUSB1044=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_REV30=y +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y +CONFIG_PLATFORM_EC_USB_PD_USB4=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_FUSB302=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y +CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y +CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y + +# IOEX +CONFIG_PLATFORM_EC_IOEX_CROS_DRV=y +CONFIG_PLATFORM_EC_IOEX_PCA9675=y +CONFIG_GPIO_PCA95XX=y + +# 7-Segment Display +CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y + +# eSPI +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150 diff --git a/zephyr/program/intelrvp/adlrvp/src/adlrvp.c b/zephyr/program/intelrvp/adlrvp/src/adlrvp.c new file mode 100644 index 0000000000..ce5196c60d --- /dev/null +++ b/zephyr/program/intelrvp/adlrvp/src/adlrvp.c @@ -0,0 +1,430 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* TODO: b/218904113: Convert to using Zephyr GPIOs */ +#include "gpio_signal.h" +#include "adlrvp_zephyr.h" +#include "common.h" +#include "console.h" +#include "intelrvp.h" +#include "intel_rvp_board_id.h" +#include "battery_fuel_gauge.h" +#include "charger.h" +#include "battery.h" +#include "bq25710.h" +#include "driver/retimer/bb_retimer_public.h" +#include "extpower.h" +#include "hooks.h" +#include "ioexpander.h" +#include "isl9241.h" +#include "power/icelake.h" +#include "sn5s330.h" +#include "system.h" +#include "task.h" +#include "tusb1064.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" +#include "usbc_ppc.h" +#include "util.h" + +#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ##args) +#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ##args) + +/* TCPC AIC GPIO Configuration */ +const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[] = { + [TYPE_C_PORT_0] = { + .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)), + .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p0)), + .ppc_intr_handler = sn5s330_interrupt, + }, +#if defined(HAS_TASK_PD_C1) + [TYPE_C_PORT_1] = { + .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p1)), + .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p1)), + .ppc_intr_handler = sn5s330_interrupt, + }, +#endif +#if defined(HAS_TASK_PD_C2) + [TYPE_C_PORT_2] = { + .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p2)), + .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p2)), + .ppc_intr_handler = sn5s330_interrupt, + }, +#endif +#if defined(HAS_TASK_PD_C3) + [TYPE_C_PORT_3] = { + .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p3)), + .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p3)), + .ppc_intr_handler = sn5s330_interrupt, + }, +#endif +}; +BUILD_ASSERT(ARRAY_SIZE(tcpc_aic_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT); + +/* USB-C PPC configuration */ +struct ppc_config_t ppc_chips[] = { + [TYPE_C_PORT_0] = { + .i2c_port = I2C_PORT_TYPEC_0, + .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC, + .drv = &sn5s330_drv, + }, +#if defined(HAS_TASK_PD_C1) + [TYPE_C_PORT_1] = { + .i2c_port = I2C_PORT_TYPEC_1, + .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC, + .drv = &sn5s330_drv + }, +#endif +#if defined(HAS_TASK_PD_C2) + [TYPE_C_PORT_2] = { + .i2c_port = I2C_PORT_TYPEC_2, + .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC, + .drv = &sn5s330_drv, + }, +#endif +#if defined(HAS_TASK_PD_C3) + [TYPE_C_PORT_3] = { + .i2c_port = I2C_PORT_TYPEC_3, + .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC, + .drv = &sn5s330_drv, + }, +#endif +}; +BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == CONFIG_USB_PD_PORT_MAX_COUNT); +unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); + +/* Cache BB retimer power state */ +static bool cache_bb_enable[CONFIG_USB_PD_PORT_MAX_COUNT]; + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* Port 0 & 1 and 2 & 3 share same line for over current indication */ +#if defined(HAS_TASK_PD_C2) + enum ioex_signal oc_signal = port < TYPE_C_PORT_2 ? IOEX_USB_C0_C1_OC : + IOEX_USB_C2_C3_OC; +#else + enum ioex_signal oc_signal = IOEX_USB_C0_C1_OC; +#endif + + /* Overcurrent indication is active low signal */ + ioex_set_level(oc_signal, is_overcurrented ? 0 : 1); +} + +__override int bb_retimer_power_enable(const struct usb_mux *me, bool enable) +{ + /* + * ADL-P-DDR5 RVP SKU has cascaded retimer topology. + * Ports with cascaded retimers share common load switch and reset pin + * hence no need to set the power state again if the 1st retimer's power + * status has already changed. + */ + if (cache_bb_enable[me->usb_port] == enable) + return EC_SUCCESS; + + cache_bb_enable[me->usb_port] = enable; + + /* Handle retimer's power domain.*/ + if (enable) { + ioex_set_level(bb_controls[me->usb_port].usb_ls_en_gpio, 1); + + /* + * minimum time from VCC to RESET_N de-assertion is 100us + * For boards that don't provide a load switch control, the + * retimer_init() function ensures power is up before calling + * this function. + */ + msleep(1); + ioex_set_level(bb_controls[me->usb_port].retimer_rst_gpio, 1); + + /* + * Allow 1ms time for the retimer to power up lc_domain + * which powers I2C controller within retimer + */ + msleep(1); + + } else { + ioex_set_level(bb_controls[me->usb_port].retimer_rst_gpio, 0); + msleep(1); + ioex_set_level(bb_controls[me->usb_port].usb_ls_en_gpio, 0); + } + return EC_SUCCESS; +} + +static void board_connect_c0_sbu_deferred(void) +{ + int ccd_intr_level = gpio_get_level(GPIO_CCD_MODE_ODL); + + if (ccd_intr_level) { + /* Default set the SBU lines to AUX mode on TCPC-AIC */ + ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_1, 0); + ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_0, 0); + } else { + /* Set the SBU lines to CCD mode on TCPC-AIC */ + ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_1, 1); + ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_0, 0); + } +} +DECLARE_DEFERRED(board_connect_c0_sbu_deferred); + +void board_connect_c0_sbu(enum gpio_signal s) +{ + hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0); +} + +static void enable_h1_irq(void) +{ + gpio_enable_interrupt(GPIO_CCD_MODE_ODL); +} +DECLARE_HOOK(HOOK_INIT, enable_h1_irq, HOOK_PRIO_LAST); + +void set_charger_system_voltage(void) +{ + switch (ADL_RVP_BOARD_ID(board_get_version())) { + case ADLN_LP5_ERB_SKU_BOARD_ID: + case ADLN_LP5_RVP_SKU_BOARD_ID: + /* + * As per b:196184163 configure the PPVAR_SYS depend + * on AC or AC+battery + */ + if (extpower_is_present() && battery_is_present()) { + bq25710_set_min_system_voltage( + CHARGER_SOLO, battery_get_info()->voltage_min); + } else { + bq25710_set_min_system_voltage( + CHARGER_SOLO, battery_get_info()->voltage_max); + } + break; + + /* Add additional board SKUs */ + default: + break; + } +} +DECLARE_HOOK(HOOK_AC_CHANGE, set_charger_system_voltage, HOOK_PRIO_DEFAULT); + +static void configure_charger(void) +{ + switch (ADL_RVP_BOARD_ID(board_get_version())) { + case ADLN_LP5_ERB_SKU_BOARD_ID: + case ADLN_LP5_RVP_SKU_BOARD_ID: + /* charger chip BQ25720 support */ + chg_chips[0].i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS; + chg_chips[0].drv = &bq25710_drv; + set_charger_system_voltage(); + break; + + /* Add additional board SKUs */ + default: + break; + } +} + +static void configure_retimer_usbmux(void) +{ + struct usb_mux *mux; + + switch (ADL_RVP_BOARD_ID(board_get_version())) { + case ADLN_LP5_ERB_SKU_BOARD_ID: + case ADLN_LP5_RVP_SKU_BOARD_ID: + /* enable TUSB1044RNQR redriver on Port0 */ + mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_0), 0); + mux->i2c_addr_flags = TUSB1064_I2C_ADDR14_FLAGS; + mux->driver = &tusb1064_usb_mux_driver; + mux->hpd_update = tusb1044_hpd_update; + +#if defined(HAS_TASK_PD_C1) + mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_1), 0); + mux->driver = NULL; + mux->hpd_update = NULL; +#endif + break; + + case ADLP_LP5_T4_RVP_SKU_BOARD_ID: + /* No retimer on Port-2 */ +#if defined(HAS_TASK_PD_C2) + mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_2), 0); + mux->driver = NULL; +#endif + break; + + case ADLP_DDR5_RVP_SKU_BOARD_ID: + /* + * ADL-P-DDR5 RVP has dual BB-retimers for port0 & port1. + * Change the default usb mux config on runtime to support + * dual retimer topology. + */ + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_alt_chain_0); +#if defined(HAS_TASK_PD_C1) + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_alt_chain_1); +#endif + break; + + /* Add additional board SKUs */ + + default: + break; + } +} + +static void configure_battery_type(void) +{ + int bat_cell_type; + + switch (ADL_RVP_BOARD_ID(board_get_version())) { + case ADLM_LP4_RVP1_SKU_BOARD_ID: + case ADLM_LP5_RVP2_SKU_BOARD_ID: + case ADLM_LP5_RVP3_SKU_BOARD_ID: + case ADLN_LP5_ERB_SKU_BOARD_ID: + case ADLN_LP5_RVP_SKU_BOARD_ID: + /* configure Battery to 2S based */ + bat_cell_type = BATTERY_TYPE(DT_ALIAS(getac_2s)); + break; + default: + /* configure Battery to 3S based */ + bat_cell_type = BATTERY_TYPE(DT_ALIAS(getac_3s)); + break; + } + + /* Set the fixed battery type */ + battery_set_fixed_battery_type(bat_cell_type); +} +/******************************************************************************/ +/* PWROK signal configuration */ +/* + * On ADLRVP, SYS_PWROK_EC is an output controlled by EC and uses ALL_SYS_PWRGD + * as input. + */ +const struct intel_x86_pwrok_signal pwrok_signal_assert_list[] = { + { + .gpio = GPIO_PCH_SYS_PWROK, + .delay_ms = 3, + }, +}; +const int pwrok_signal_assert_count = ARRAY_SIZE(pwrok_signal_assert_list); + +const struct intel_x86_pwrok_signal pwrok_signal_deassert_list[] = { + { + .gpio = GPIO_PCH_SYS_PWROK, + }, +}; +const int pwrok_signal_deassert_count = ARRAY_SIZE(pwrok_signal_deassert_list); + +/* + * Returns board information (board id[7:0] and Fab id[15:8]) on success + * -1 on error. + */ +__override int board_get_version(void) +{ + /* Cache the board ID */ + static int adlrvp_board_id; + + int i; + int rv = EC_ERROR_UNKNOWN; + + int fab_id, board_id, bom_id; + + /* Board ID is already read */ + if (adlrvp_board_id) + return adlrvp_board_id; + + /* + * IOExpander that has Board ID information is on DSW-VAL rail on + * ADL RVP. On cold boot cycles, DSW-VAL rail is taking time to settle. + * This loop retries to ensure rail is settled and read is successful + */ + for (i = 0; i < RVP_VERSION_READ_RETRY_CNT; i++) { + rv = gpio_pin_get_dt(&bom_id_config[0]); + + if (rv >= 0) + break; + + k_msleep(1); + } + + /* retrun -1 if failed to read board id */ + if (rv < 0) + return -1; + + /* + * BOM ID [2] : IOEX[0] + * BOM ID [1:0] : IOEX[15:14] + */ + bom_id = gpio_pin_get_dt(&bom_id_config[0]) << 2; + bom_id |= gpio_pin_get_dt(&bom_id_config[1]) << 1; + bom_id |= gpio_pin_get_dt(&bom_id_config[2]); + + /* + * FAB ID [1:0] : IOEX[2:1] + 1 + */ + fab_id = gpio_pin_get_dt(&fab_id_config[0]) << 1; + fab_id |= gpio_pin_get_dt(&fab_id_config[1]); + fab_id += 1; + + /* + * BOARD ID[5:0] : IOEX[13:8] + */ + board_id = gpio_pin_get_dt(&board_id_config[0]) << 5; + board_id |= gpio_pin_get_dt(&board_id_config[1]) << 4; + board_id |= gpio_pin_get_dt(&board_id_config[2]) << 3; + board_id |= gpio_pin_get_dt(&board_id_config[3]) << 2; + board_id |= gpio_pin_get_dt(&board_id_config[4]) << 1; + board_id |= gpio_pin_get_dt(&board_id_config[5]); + + CPRINTF("BID:0x%x, FID:0x%x, BOM:0x%x", board_id, fab_id, bom_id); + + adlrvp_board_id = board_id | (fab_id << 8); + return adlrvp_board_id; +} + +__override bool board_is_tbt_usb4_port(int port) +{ + bool tbt_usb4 = true; + + switch (ADL_RVP_BOARD_ID(board_get_version())) { + case ADLN_LP5_ERB_SKU_BOARD_ID: + case ADLN_LP5_RVP_SKU_BOARD_ID: + /* No retimer on both ports */ + tbt_usb4 = false; + break; + + case ADLP_LP5_T4_RVP_SKU_BOARD_ID: + /* No retimer on Port-2 hence no platform level AUX & LSx mux */ +#if defined(HAS_TASK_PD_C2) + if (port == TYPE_C_PORT_2) + tbt_usb4 = false; +#endif + break; + + /* Add additional board SKUs */ + default: + break; + } + + return tbt_usb4; +} + +static int board_pre_task_peripheral_init(const struct device *unused) +{ + ARG_UNUSED(unused); + + /* Initialized IOEX-0 to access IOEX-GPIOs needed pre-task */ + ioex_init(IOEX_C0_PCA9675); + + /* Make sure SBU are routed to CCD or AUX based on CCD status at init */ + board_connect_c0_sbu_deferred(); + + /* Configure battery type */ + configure_battery_type(); + + /* Reconfigure board specific charger drivers */ + configure_charger(); + + /* Configure board specific retimer & mux */ + configure_retimer_usbmux(); + + return 0; +} +SYS_INIT(board_pre_task_peripheral_init, APPLICATION, + CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/zephyr/program/intelrvp/include/intel_rvp_board_id.h b/zephyr/program/intelrvp/include/intel_rvp_board_id.h new file mode 100644 index 0000000000..7825b272e3 --- /dev/null +++ b/zephyr/program/intelrvp/include/intel_rvp_board_id.h @@ -0,0 +1,17 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __INTEL_RVP_BOARD_ID_H +#define __INTEL_RVP_BOARD_ID_H + +#include + +extern const struct gpio_dt_spec bom_id_config[]; + +extern const struct gpio_dt_spec fab_id_config[]; + +extern const struct gpio_dt_spec board_id_config[]; + +#endif /* __INTEL_RVP_BOARD_ID_H */ diff --git a/zephyr/program/intelrvp/include/intelrvp.h b/zephyr/program/intelrvp/include/intelrvp.h new file mode 100644 index 0000000000..9b6dc98485 --- /dev/null +++ b/zephyr/program/intelrvp/include/intelrvp.h @@ -0,0 +1,35 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef __INTELRVP_BOARD_H +#define __INTELRVP_BOARD_H + +#include "compiler.h" +#include "gpio_signal.h" +#include "stdbool.h" + +/* RVP ID read retry count */ +#define RVP_VERSION_READ_RETRY_CNT 2 + +#define DC_JACK_MAX_VOLTAGE_MV 19000 + +FORWARD_DECLARE_ENUM(tcpc_rp_value); + +struct tcpc_aic_gpio_config_t { + /* TCPC interrupt */ + enum gpio_signal tcpc_alert; + /* PPC interrupt */ + enum gpio_signal ppc_alert; + /* PPC interrupt handler */ + void (*ppc_intr_handler)(int port); +}; +extern const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[]; + +void board_charging_enable(int port, int enable); +void board_vbus_enable(int port, int enable); +void board_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp); +void board_dc_jack_interrupt(enum gpio_signal signal); +void tcpc_alert_event(enum gpio_signal signal); +bool is_typec_port(int port); +#endif /* __INTELRVP_BOARD_H */ diff --git a/zephyr/program/intelrvp/led.md b/zephyr/program/intelrvp/led.md new file mode 100644 index 0000000000..c36bc6b36c --- /dev/null +++ b/zephyr/program/intelrvp/led.md @@ -0,0 +1,44 @@ +## LED behavior on Intel RVP + +There are two LEDs on RVP, they represent battery and charger status +respectively. + +LED | Description +------------|------------------------ +CHARGER_LED | Represent charger state +BATTERY_LED | Represent battery state + +LEDs on RVP emit a single color (green). Rather than just using the on and off +state of the LED, PWM is used to blink the LED to represent multiple states and +the below table represents the multiple LED states. + +LED State | Description +---------------|------------------------------ +LED_ON | Switch On using gpio/pwmduty +LED_OFF | Switch Off using gpio/pwmduty +LED_FLASH_SLOW | Flashing with 2 sec period +LED_FLASH_FAST | Flashing with 250ms period + +### LED Behavior : Charger + +CHARGER_LED is dedicated to represent Charger status and the below table +represents the LED states for the Charger. + +Charger Status | LED States +---------------------|--------------- +Charging | LED_ON +Discharging | LED_FLASH_SLOW +Charging error | LED_FLASH_FAST +No Charger Connected | LED_OFF + +### LED Behavior : Battery + +BATTERY_LED is dedicated to represent Battery status and the below table +represents the LED states for the Battery. + +Battery Status | LED States +----------------------------|--------------- +Battery Low (<10%) | LED_FLASH_FAST +Battery Normal (10% to 90%) | LED_FLASH_SLOW +Battery Full (>90%) | LED_ON +Battery Not Present | LED_OFF diff --git a/zephyr/program/intelrvp/legacy_ec_pwrseq.conf b/zephyr/program/intelrvp/legacy_ec_pwrseq.conf new file mode 100644 index 0000000000..331afb637d --- /dev/null +++ b/zephyr/program/intelrvp/legacy_ec_pwrseq.conf @@ -0,0 +1,12 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Legacy EC Power Sequencing Common Config +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y +CONFIG_PLATFORM_EC_POWERSEQ_INTEL=y +CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y +CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y +CONFIG_PLATFORM_EC_POWERSEQ_S4=y +CONFIG_PLATFORM_EC_THROTTLE_AP=y diff --git a/zephyr/program/intelrvp/mtlrvp/CMakeLists.txt b/zephyr/program/intelrvp/mtlrvp/CMakeLists.txt new file mode 100644 index 0000000000..c6729af776 --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +zephyr_library_sources("src/mtlrvp.c") +zephyr_library_sources("src/board_power.c") diff --git a/zephyr/program/intelrvp/mtlrvp/ioex.dts b/zephyr/program/intelrvp/mtlrvp/ioex.dts new file mode 100644 index 0000000000..7d2f4b5820 --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/ioex.dts @@ -0,0 +1,71 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* IOEX_KBD_GPIO IT8801 */ + ioex-kbd-gpio { + compatible = "cros,ioex-chip"; + i2c-port = <&i2c_charger>; + i2c-addr = <0x39>; + drv = "it8801_ioexpander_drv"; + flags = <0x00>; + #address-cells = <1>; + #size-cells = <0>; + + ioex_it8801_port0: it8801_port@0 { + compatible = "cros,ioex-port"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + }; + + ioex_it8801_port1: it8801_port@1 { + compatible = "cros,ioex-port"; + reg = <1>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + }; + }; + /* IOEX_C2_CCGXXF */ + ioex-c2 { + compatible = "cros,ioex-chip"; + i2c-port = <&typec_aic2>; + i2c-addr = <0x0B>; + drv = "ccgxxf_ioexpander_drv"; + flags = <0x00>; + #address-cells = <1>; + #size-cells = <0>; + ioex_c2_port0: ioex-c2-port@0 { + compatible = "cros,ioex-port"; + reg = <0>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + }; + ioex_c2_port1: ioex-c2-port@1 { + compatible = "cros,ioex-port"; + reg = <1>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + }; + ioex_c2_port2: ioex-c2-port@2 { + compatible = "cros,ioex-port"; + reg = <2>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + }; + ioex_c2_port3: ioex-c2-port@3 { + compatible = "cros,ioex-port"; + reg = <3>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + }; + }; +}; diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts new file mode 100644 index 0000000000..cf85dd3413 --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm3 0 PWM_KHZ(30) PWM_POLARITY_NORMAL>; + rpm_min = <3200>; + rpm_start = <2200>; + rpm_max = <6600>; + tach = <&tach2>; + pgood_gpio = <&all_sys_pwrgd>; + enable_gpio = <&gpio_fan_control>; + }; + }; +}; + +/* Tachemeter for fan speed measurement */ +&tach2 { + status = "okay"; + pinctrl-0 = <&ta2_1_in_gp73>; /* TA2 input on GPIO73 */ + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm3 { + status = "okay"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts new file mode 100644 index 0000000000..77b4cf0573 --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts @@ -0,0 +1,366 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_wp; + }; + + named-gpios { + compatible = "named-gpios"; + + ioex_kbd_intr_n: ioex-kbd-intr-n { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_KB_DISCRETE_INT"; + }; + all_sys_pwrgd: all-sys-pwrgd { + gpios = <&gpio7 0 GPIO_INPUT>; + enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD"; + }; + rsmrst_pwrgd: rsmrst-pwrgd { + gpios = <&gpio6 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_PG_EC_RSMRST_ODL"; + }; + pch_slp_s0_n: pch-slp-s0-n-ec { + gpios = <&gpioa 1 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S0_L"; /* 1.8V */ + }; + pm-slp-s3-n-ec { + gpios = <&gpiob 0 GPIO_INPUT>; /* 1.8V */ + enum-name = "GPIO_PCH_SLP_S3_L"; + }; + pm-slp-s4-n-ec { + gpios = <&gpioa 5 GPIO_INPUT>; /* 1.8V */ + }; + volume-up { + gpios = <&gpio6 1 (GPIO_INPUT | GPIO_PULL_UP)>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + vol-dn-ec-r { + gpios = <&gpio0 3 (GPIO_INPUT | GPIO_PULL_UP)>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + smc_lid: smc-lid { + gpios = <&gpio0 1 (GPIO_INPUT | GPIO_PULL_UP)>; + enum-name = "GPIO_LID_OPEN"; + }; + smc_onoff_n: smc-onoff-n { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_wp: wp-l { + gpios = <&gpiod 5 GPIO_INPUT>; + }; + std_adp_prsnt: std-adp-prsnt { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_DC_JACK_PRESENT"; + }; + bc_acok: bc-acok-ec { + gpios = <&gpio0 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { + gpios = <&gpio4 0 GPIO_INPUT>; + }; + /* NOTE: Netname is USBC_TCPC_PPC_ALRT_P0 */ + usb_c0_c1_tcpc_rst_odl: usb-c0-c1-tcpc-rst-odl { + gpios = <&gpiod 0 GPIO_ODR_HIGH>; + }; + /* NOTE: Netname is USBC_TCPC_ALRT_P1 */ + usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + usbc_tcpc_alrt_p2: usbc-tcpc-alrt-p2 { + gpios = <&gpio9 1 GPIO_INPUT>; + }; + /* NOTE: Netname is USBC_TCPC_PPC_ALRT_P3 */ + usbc_tcpc_alrt_p3: usbc-tcpc-alrt-p3 { + gpios = <&gpiof 3 GPIO_INPUT>; + }; + gpio_ec_pch_wake_odl: pch-wake-n { + gpios = <&gpio7 4 GPIO_ODR_HIGH>; + }; + espi-rst-n { + gpios = <&gpio5 4 GPIO_INPUT>; /* 1.8V */ + }; + plt-rst-l { + gpios = <&gpioa 2 GPIO_INPUT>; /* 1.8V */ + }; + slate-mode-indication { + gpios = <&gpio9 4 GPIO_INPUT>; /* 1.8V */ + }; + prochot-ec { + gpios = <&gpio6 0 GPIO_INPUT>; + enum-name = "GPIO_CPU_PROCHOT"; + }; + sys_rst_odl: sys-rst-odl-ec { + gpios = <&gpioc 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_SYS_RESET_L"; + }; + ec_pch_rsmrst_l: pm-rsmrst-r-n { + gpios = <&gpioa 4 GPIO_OUTPUT_LOW>; /* 1.8V */ + enum-name = "GPIO_PCH_RSMRST_L"; + }; + pm-pwrbtn-n-ec { + gpios = <&gpiod 4 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + ec_spi_oe_mecc: ec-spi-oe-mecc-r { + gpios = <&gpioa 7 GPIO_OUTPUT_LOW>; /* 1.8V */ + }; + en_pp3300_a: ec-ds3-r { + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PP3300_A"; + alias = "GPIO_TEMP_SENSOR_POWER"; + }; + ec_pch_pwrok_od: pch-pwrok-ec-r { + gpios = <&gpiod 3 GPIO_ODR_LOW>; + enum-name = "GPIO_PCH_PWROK"; + }; + sys_pwrok_ec: sys-pwrok-ec { + gpios = <&gpiof 5 GPIO_ODR_LOW>; + enum-name = "GPIO_PCH_SYS_PWROK"; + }; + bat-det-ec { + gpios = <&gpio7 6 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + edp-bklt-en { + gpios = <&gpioe 1 GPIO_OUTPUT_HIGH>; + }; + /* TODO: move both LEDs to PWM */ + led-1-l-ec { + gpios = <&gpiob 6 GPIO_OUTPUT_HIGH>; + }; + led-2-l-ec { + gpios = <&gpiob 7 GPIO_OUTPUT_HIGH>; + }; + gpio_fan_control: therm-sen-mecc-r { + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + /* NOTE: Netname is USBC_TCPC_ALRT_P3 */ + ccd_mode_odl: ccd-mode-odl { + gpios = <&gpio9 2 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + smb-bs-clk { + gpios = <&gpiob 3 GPIO_INPUT>; + }; + smb-bs-data { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usbc-tcpc-i2c-clk-aic1 { + gpios = <&gpiob 5 GPIO_INPUT>; + }; + usbc-tcpc-i2c-data-aic1 { + gpios = <&gpiob 4 GPIO_INPUT>; + }; + usbc-tcpc-i2c-clk-aic2 { + gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + usbc-tcpc-i2c-data-aic2 { + gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + /* Unused 1.8V pins */ + i3c-1-sda-r { + gpios = <&gpio5 0 GPIO_INPUT>; + }; + i3c-1-scl-r { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + espi-alert0-n-r { + gpios = <&gpio5 7 GPIO_INPUT>; + }; + tp-gpio95 { + gpios = <&gpio9 5 GPIO_INPUT>; + }; + cpu-c10-gate { + gpios = <&gpio9 6 GPIO_INPUT>; + }; + slp-s0-cs-n-ec { + gpios = <&gpio9 7 GPIO_INPUT>; + }; + rtc-rst-n-r { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + tp-gpioa6 { + gpios = <&gpioa 6 GPIO_INPUT>; + }; + sml1-clk-mecc { + gpios = <&gpio3 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + sml1-data-mecc { + gpios = <&gpio3 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + sml1-alert { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + smb-pch-alrt { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + smb-pch-data { + gpios = <&gpioc 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + smb-pch-clk { + gpios = <&gpioc 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + /* Unused 3.3V pins */ + cpu-cat-err-mecc { + gpios = <&gpio3 4 GPIO_INPUT>; + }; + tp-gpio37 { + gpios = <&gpio3 7 GPIO_INPUT>; + }; + tp-vccpdsw-3p3-ec { + gpios = <&gpio4 5 GPIO_INPUT>; + }; + mech-pwr-btn-in-odl { + gpios = <&gpio6 2 GPIO_INPUT>; + }; + tp-gpio63 { + gpios = <&gpio6 3 GPIO_INPUT>; + }; + tp-gpio67 { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + tp-gpio72 { + gpios = <&gpio7 2 GPIO_INPUT>; + }; + tp-gpio75 { + gpios = <&gpio7 5 GPIO_INPUT>; + }; + ec-peci-ec { + gpios = <&gpio8 1 GPIO_INPUT>; + }; + tp-gpiob1 { + gpios = <&gpiob 1 GPIO_INPUT>; + }; + std-adpt-cntrl-GPIO_r { + gpios = <&gpioc 3 GPIO_INPUT>; + }; + ec-packet-mode-ec { + gpios = <&gpioe 2 GPIO_INPUT>; + }; + tp-gpioe3 { + gpios = <&gpioe 3 GPIO_INPUT>; + }; + boot-stall-r { + gpios = <&gpioe 5 GPIO_INPUT>; + }; + tp-gpiof0 { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + tp-gpiof1 { + gpios = <&gpiof 1 GPIO_INPUT>; + }; + usbc_tcpc_ppc_alrt_p2: usbc-tcpc-ppc-alrt-p2 { + gpios = <&gpiof 2 GPIO_INPUT>; + }; + tp-gpiof4 { + gpios = <&gpiof 4 GPIO_INPUT>; + }; + + /* KBD IOEX configuration */ + srtc-rst { + gpios = <&ioex_it8801_port0 3 GPIO_OUTPUT_LOW>; + }; + ec-h1-packet-mode { + gpios = <&ioex_it8801_port0 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + rtc-rst { + gpios = <&ioex_it8801_port0 6 GPIO_OUTPUT_LOW>; + }; + ec-entering-rw { + gpios = <&ioex_it8801_port0 7 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ioex-sys-rst-odl-ec { + gpios = <&ioex_it8801_port1 0 GPIO_INPUT>; + }; + ioex-slate-mode-indication { + gpios = <&ioex_it8801_port1 2 GPIO_INPUT>; + }; + + /* USB C IOEX configuration */ + usb_c0_hb_retimer_ls_en: usb-c0-hbr-ls-en { + gpios = <&ioex_c0 2 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_HBR_LS_EN"; + no-auto-init; + }; + usb_c0_hb_retimer_rst: usb-c0-hbr-rst { + gpios = <&ioex_c0 3 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_HBR_RST"; + no-auto-init; + }; + usb_c1_hb_retimer_ls_en: usb-c1-hbr-ls-en { + gpios = <&ioex_c1 2 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_HBR_LS_EN"; + no-auto-init; + }; + usb_c1_hb_retimer_rst: usb-c1-hbr-rst { + gpios = <&ioex_c1 3 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_HBR_RST"; + no-auto-init; + }; + usb-c0-mux-oe-n { + gpios = <&ioex_c0 4 GPIO_OUTPUT_LOW>; + no-auto-init; + }; + usb-c0-mux-sbu-sel-0 { + gpios = <&ioex_c0 6 GPIO_OUTPUT_HIGH>; + enum-name = "IOEX_USB_C0_MUX_SBU_SEL_0"; + no-auto-init; + }; + usb-c0-mux-sbu-sel-1 { + gpios = <&ioex_c1 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_MUX_SBU_SEL_1"; + no-auto-init; + }; + usb-c0-c1-prochot-n { + gpios = <&ioex_c1 6 GPIO_INPUT>; + no-auto-init; + }; + dg-bssb-sbu-sel { + gpios = <&ioex_c2_port1 4 GPIO_INPUT>; + no-auto-init; + }; + usb_c2_hb_retimer_rst: usb-c2-hbr-rst { + gpios = <&ioex_c2_port1 1 (GPIO_ODR_LOW | \ + GPIO_VOLTAGE_1P8)>; + enum-name = "IOEX_USB_C2_HBR_RST"; + no-auto-init; + }; + usb_c2_hb_retimer_ls_en: usb-c2-hbr-ls-en { + gpios = <&ioex_c2_port2 0 (GPIO_ODR_LOW | \ + GPIO_VOLTAGE_1P8)>; + enum-name = "IOEX_USB_C2_HBR_LS_EN"; + no-auto-init; + }; + usb_c3_hb_retimer_rst: usb-c3-hbr-rst { + gpios = <&ioex_c2_port1 3 (GPIO_ODR_LOW | \ + GPIO_VOLTAGE_1P8)>; + enum-name = "IOEX_USB_C3_HBR_RST"; + no-auto-init; + }; + usb_c3_hb_retimer_ls_en: usb-c3-hbr-ls-en { + gpios = <&ioex_c2_port3 3 (GPIO_ODR_LOW | \ + GPIO_VOLTAGE_1P8)>; + enum-name = "IOEX_USB_C3_HBR_LS_EN"; + no-auto-init; + }; + usb-c2-c3-prochot-n { + gpios = <&ioex_c2_port0 0 GPIO_INPUT>; + no-auto-init; + }; + /* unimplemented GPIOs */ + en-pp5000 { + enum-name = "GPIO_EN_PP5000"; + }; + }; +}; diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts new file mode 100644 index 0000000000..b120f6c05e --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts @@ -0,0 +1,60 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_lid_open: lid_open { + irq-pin = <&smc_lid>; + flags = ; + handler = "lid_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&smc_onoff_n>; + flags = ; + handler = "power_button_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&bc_acok>; + flags = ; + handler = "extpower_interrupt"; + }; + int_ioex_kbd_intr_n: ioex_kbd_intr_n { + irq-pin = <&ioex_kbd_intr_n>; + flags = ; + handler = "io_expander_it8801_interrupt"; + }; + int_usb_c0_c1_tcpc: usb_c0_tcpc { + irq-pin = <&usbc_tcpc_alrt_p0>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&usbc_tcpc_ppc_alrt_p0>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_ppc: usb_c1_ppc { + irq-pin = <&usbc_tcpc_ppc_alrt_p1>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c2_tcpc: usb_c2_tcpc { + irq-pin = <&usbc_tcpc_alrt_p2>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c3_tcpc: usb_c3_tcpc { + irq-pin = <&usbc_tcpc_alrt_p3>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_ccd_mode: ccd_mode { + irq-pin = <&ccd_mode_odl>; + flags = ; + handler = "board_connect_c0_sbu"; + }; + }; +}; diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts new file mode 100644 index 0000000000..81d6e82f48 --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + output-settle = <35>; + debounce-down = <5000>; + debounce-up = <40000>; + poll-timeout = <100000>; + + actual-key-mask = < + 0x14 /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts new file mode 100644 index 0000000000..44f283071b --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts @@ -0,0 +1,273 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + #include + +/ { + chosen { + cros,rtc = &mtc; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_lid_open + &int_power_button + >; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_charger: charger { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_CHARGER", + "I2C_PORT_BATTERY", + "I2C_PORT_EEPROM", + "I2C_PORT_KB_DISCRETE", + "I2C_PORT_PORT80"; + }; + typec_aic1: typec-aic1{ + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_TYPEC_AIC_1"; + }; + typec_aic2: typec-aic2{ + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_TYPEC_AIC_2"; + }; + }; + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 3>; + }; + adc_ddr: ddr { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 4>; + }; + adc_skin: skin { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 2>; + }; + adc_vr: vr { + enum-name = "ADC_TEMP_SENSOR_4"; + io-channels = <&adc0 1>; + }; + }; +}; + +/* charger */ +&i2c7_0 { + label = "I2C_CHARGER"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; + + pca95xx: pca95xx@22 { + compatible = "nxp,pca95xx"; + label = "PCA95XX"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + ngpios = <16>; + }; + + rvp_board_id: rvp-board-id { + compatible = "intel,rvp-board-id"; + + /* + * BOM ID [2] : IOEX[0] + * BOM ID [1:0] : IOEX[15:14] + */ + bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>; + + /* + * FAB ID [1:0] : IOEX[2:1] + */ + fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>; + + /* + * BOARD ID[5:0] : IOEX[13:8] + */ + board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>, + <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>; + }; + + kb_discrete: ite-it8801@39 { + compatible = "ite,it8801"; + reg = <0x39>; + }; + + seven_seg_display: max695x-seven-seg-display@38 { + compatible = "maxim,seven-seg-display"; + reg = <0x38>; + label = "MAX695X_SEVEN_SEG_DISPLAY"; + }; + + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; + +/* typec_aic1 */ +&i2c0_0 { + label = "I2C_USB_C0_C1_TCPC"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + + tcpc_port0: nct38xx@73 { + compatible = "nuvoton,nct38xx"; + reg = <0x73>; + gpio-dev = <&nct38xx_c0>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>; + }; + + nct38xx_c0: nct38xx_c0@73 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x73>; + label = "NCT38XX_C0"; + + ioex_c0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT38XX_C0_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xdc>; + pinmux_mask = <0xff>; + }; + }; + + tcpc_port1: nct38xx@77 { + compatible = "nuvoton,nct38xx"; + reg = <0x77>; + gpio-dev = <&nct38xx_c1>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct38xx_c1: nct38xx_c1@77 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x77>; + label = "NCT38XX_C1"; + + ioex_c1: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT38XX_C1_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xdc>; + pinmux_mask = <0xff>; + }; + }; + + nct38xx_alert_0 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpio4 0 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct38xx_c0 &nct38xx_c1>; + label = "NCT38XX_ALERT_1"; + }; + + usb_c0_hb_retimer: jhl8040r-c0@56 { + compatible = "intel,jhl8040r"; + reg = <0x56>; + reset-pin = <&usb_c0_hb_retimer_rst>; + ls-en-pin = <&usb_c0_hb_retimer_ls_en>; + }; + + usb_c1_hb_retimer: jhl8040r-c1@57 { + compatible = "intel,jhl8040r"; + reg = <0x57>; + reset-pin = <&usb_c1_hb_retimer_rst>; + ls-en-pin = <&usb_c1_hb_retimer_ls_en>; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +/* typec_aic2 */ +&i2c1_0 { + label = "I2C_USB_C2_C3_TCPC"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + tcpc_port2: ccgxxf@b { + compatible = "cypress,ccgxxf"; + reg = <0xb>; + }; + + tcpc_port3: ccgxxf@1b { + compatible = "cypress,ccgxxf"; + reg = <0x1b>; + }; + + usb_c2_hb_retimer: jhl8040r-c2@58 { + compatible = "intel,jhl8040r"; + reg = <0x58>; + reset-pin = <&usb_c2_hb_retimer_rst>; + ls-en-pin = <&usb_c2_hb_retimer_ls_en>; + }; + + usb_c3_hb_retimer: jhl8040r-c3@59 { + compatible = "intel,jhl8040r"; + reg = <0x59>; + reset-pin = <&usb_c3_hb_retimer_rst>; + ls-en-pin = <&usb_c3_hb_retimer_ls_en>; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42 + &adc0_chan4_gp41>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts new file mode 100644 index 0000000000..3c270d296f --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts @@ -0,0 +1,125 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <3>; + all-sys-pwrgd-timeout = <20>; + sys-reset-delay = <60>; + }; + + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpioc 4 0>; + output; + }; + pwr-pg-ec-rsmrst-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpio6 6 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioa 4 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpioa 1 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpiod 3 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpiof 5 GPIO_OPEN_DRAIN>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s3 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S3 virtual wire input from PCH"; + enum-name = "PWR_SLP_S3"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S3"; + vw-invert; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + gpios = <&gpio7 0 0>; + interrupt-flags = ; + }; +}; + +/* + * Because the power signals directly reference the GPIOs, + * the correspinding named-gpios need to have no-auto-init set. + */ +&en_pp3300_a { + no-auto-init; +}; +&rsmrst_pwrgd { + no-auto-init; +}; +&ec_pch_rsmrst_l { + no-auto-init; +}; +&pch_slp_s0_n { + no-auto-init; +}; +&ec_pch_pwrok_od { + no-auto-init; +}; +&sys_pwrok_ec { + no-auto-init; +}; +&sys_rst_odl { + no-auto-init; +}; +&all_sys_pwrgd { + no-auto-init; +}; diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf new file mode 100644 index 0000000000..45b101a7ac --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf @@ -0,0 +1,18 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_MTLRVP_NPCX=y +CONFIG_CROS_FLASH_NPCX=y +CONFIG_CROS_SYSTEM_NPCX=y +CONFIG_SYSCON=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# Fan +CONFIG_TACH_NPCX=y + +#RTC +CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf new file mode 100644 index 0000000000..1a521d4c89 --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -0,0 +1,80 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Power Sequencing +CONFIG_AP_X86_INTEL_MTL=y +CONFIG_X86_NON_DSX_PWRSEQ_MTL=y +CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y +CONFIG_PLATFORM_EC_BATTERY_V2=y + +# CBI +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_CBI_EEPROM=y +CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# Disable BC1.2 +CONFIG_PLATFORM_EC_USB_CHARGER=n + +# Charger +CONFIG_PLATFORM_EC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=n +CONFIG_PLATFORM_EC_CHARGER_ISL9241=y +CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y + +# IOEX +CONFIG_PLATFORM_EC_IOEX_CROS_DRV=y +CONFIG_PLATFORM_EC_IOEX_CCGXXF=y +CONFIG_GPIO_PCA95XX=y +CONFIG_GPIO_NCT38XX=y +CONFIG_PLATFORM_EC_IOEX_IT8801=y + +#Keyboard from I/O expander +CONFIG_PLATFORM_EC_KEYBOARD_DISCRETE=y +CONFIG_CROS_KB_RAW_NPCX=n + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y +CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y + +# USB CONFIG +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_MUX_TASK=y +CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y +CONFIG_PLATFORM_EC_USBC_PPC=y +CONFIG_PLATFORM_EC_USB_PD_PPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_CCGXXF=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y +CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y +CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y +CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y +CONFIG_PLATFORM_EC_USBC_VCONN=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y +CONFIG_PLATFORM_EC_USB_PD_USB4=y +CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y +CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y +CONFIG_PLATFORM_EC_USB_PD_PORT_1_SHARED=y + +# 7-Segment Display +CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y diff --git a/zephyr/program/intelrvp/mtlrvp/src/board_power.c b/zephyr/program/intelrvp/mtlrvp/src/board_power.c new file mode 100644 index 0000000000..301402bf0f --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/src/board_power.c @@ -0,0 +1,61 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "gpio_signal.h" +#include "gpio/gpio.h" + +LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); + +#if CONFIG_X86_NON_DSX_PWRSEQ_MTL +#define X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS 50 + +void board_ap_power_force_shutdown(void) +{ + int timeout_ms = X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS; + + /* Turn off PCH_RMSRST to meet tPCH12 */ + power_signal_set(PWR_EC_PCH_RSMRST, 0); + + /* Turn off PRIM load switch. */ + power_signal_set(PWR_EN_PP3300_A, 0); + + /* Wait RSMRST to be off. */ + while (power_signal_get(PWR_RSMRST) && (timeout_ms > 0)) { + k_msleep(1); + timeout_ms--; + }; + + if (power_signal_get(PWR_RSMRST)) + LOG_WRN("RSMRST_ODL didn't go low! Assuming G3."); +} + +void board_ap_power_action_g3_s5(void) +{ + /* Turn on the PP3300_PRIM rail. */ + power_signal_set(PWR_EN_PP3300_A, 1); + + if (!power_wait_signals_timeout( + IN_PGOOD_ALL_CORE, + AP_PWRSEQ_DT_VALUE(wait_signal_timeout))) { + ap_power_ev_send_callbacks(AP_POWER_PRE_INIT); + } +} + +bool board_ap_power_check_power_rails_enabled(void) +{ + return power_signal_get(PWR_EN_PP3300_A); +} +#endif /* CONFIG_X86_NON_DSX_PWRSEQ_MTL */ diff --git a/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c b/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c new file mode 100644 index 0000000000..9d96a08712 --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c @@ -0,0 +1,331 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "battery.h" +#include "battery_fuel_gauge.h" +#include "charger.h" +#include "common.h" +#include "console.h" +#include "driver/retimer/bb_retimer_public.h" +#include "driver/tcpm/ccgxxf.h" +#include "driver/tcpm/nct38xx.h" +#include "driver/tcpm/tcpci.h" +#include "extpower.h" +#include "gpio.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "i2c.h" +#include "intelrvp.h" +#include "intel_rvp_board_id.h" +#include "ioexpander.h" +#include "isl9241.h" +#include "keyboard_raw.h" +#include "power/meteorlake.h" +#include "sn5s330.h" +#include "system.h" +#include "task.h" +#include "tusb1064.h" +#include "usb_mux.h" +#include "usbc_ppc.h" +#include "util.h" + +#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ##args) +#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ##args) + +/*******************************************************************/ +/* USB-C Configuration Start */ + +/* PPC */ +#define I2C_ADDR_SN5S330_P0 0x40 +#define I2C_ADDR_SN5S330_P1 0x41 + +/* IOEX ports */ +enum ioex_port { + IOEX_KBD = 0, +#if defined(HAS_TASK_PD_C2) + IOEX_C2_CCGXXF, +#endif + IOEX_COUNT +}; + +/* USB-C ports */ +enum usbc_port { + USBC_PORT_C0 = 0, + USBC_PORT_C1, +#if defined(HAS_TASK_PD_C2) + USBC_PORT_C2, + USBC_PORT_C3, +#endif + USBC_PORT_COUNT +}; +BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); + +/* USB-C PPC configuration */ +struct ppc_config_t ppc_chips[] = { + [USBC_PORT_C0] = { + .i2c_port = I2C_PORT_TYPEC_AIC_1, + .i2c_addr_flags = I2C_ADDR_SN5S330_P0, + .drv = &sn5s330_drv, + }, + [USBC_PORT_C1] = { + .i2c_port = I2C_PORT_TYPEC_AIC_1, + .i2c_addr_flags = I2C_ADDR_SN5S330_P1, + .drv = &sn5s330_drv, + }, +}; +unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); + +/* TCPC AIC GPIO Configuration */ +const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[] = { + [USBC_PORT_C0] = { + .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)), + .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p0)), + .ppc_intr_handler = sn5s330_interrupt, + }, + [USBC_PORT_C1] = { + .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)), + .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p1)), + .ppc_intr_handler = sn5s330_interrupt, + }, +#if defined(HAS_TASK_PD_C2) + [USBC_PORT_C2] = { + .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p2)), + /* No PPC alert for CCGXXF */ + }, + [USBC_PORT_C3] = { + .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p3)), + /* No PPC alert for CCGXXF */ + }, +#endif +}; +BUILD_ASSERT(ARRAY_SIZE(tcpc_aic_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT); + +static void board_connect_c0_sbu_deferred(void) +{ + enum pd_power_role prole; + + if (gpio_get_level(GPIO_CCD_MODE_ODL)) { + CPRINTS("Default AUX line connected"); + /* Default set the SBU lines to AUX mode */ + ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 0); + ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 1); + } else { + prole = pd_get_power_role(USBC_PORT_C0); + CPRINTS("%s debug device is attached", + prole == PD_ROLE_SINK ? "Servo V4C/SuzyQ" : "Intel"); + + if (prole == PD_ROLE_SINK) { + /* Set the SBU lines to Google CCD mode */ + ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 1); + ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 1); + } else { + /* Set the SBU lines to Intel CCD mode */ + ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 0); + ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 0); + } + } +} +DECLARE_DEFERRED(board_connect_c0_sbu_deferred); + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* + * TODO: Meteorlake PCH does not use Physical GPIO for over current + * error, hence Send 'Over Current Virtual Wire' eSPI signal. + */ +} + +void board_reset_pd_mcu(void) +{ + /* Reset NCT38XX TCPC */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(usb_c0_c1_tcpc_rst_odl), 0); + msleep(NCT38XX_RESET_HOLD_DELAY_MS); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(usb_c0_c1_tcpc_rst_odl), 1); + nct38xx_reset_notify(0); + nct38xx_reset_notify(1); + + if (NCT3807_RESET_POST_DELAY_MS != 0) { + msleep(NCT3807_RESET_POST_DELAY_MS); + } + + /* NCT38XX chip uses gpio ioex */ + gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_c0))); + gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_c1))); + +#if defined(HAS_TASK_PD_C2) + /* Reset the ccgxxf ports only resetting 1 is required */ + ccgxxf_reset(USBC_PORT_C2); + + /* CCGXXF has ioex on port 2 */ + ioex_init(IOEX_C2_CCGXXF); +#endif +} + +void board_connect_c0_sbu(enum gpio_signal signal) +{ + hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0); +} + +/******************************************************************************/ +/* KSO mapping for discrete keyboard */ +__override const uint8_t it8801_kso_mapping[] = { + 0, 1, 20, 3, 4, 5, 6, 11, 12, 13, 14, 15, 16, +}; +BUILD_ASSERT(ARRAY_SIZE(it8801_kso_mapping) == KEYBOARD_COLS_MAX); + +/* PWROK signal configuration */ +/* + * On MTLRVP, SYS_PWROK_EC is an output controlled by EC and uses ALL_SYS_PWRGD + * as input. + */ +const struct intel_x86_pwrok_signal pwrok_signal_assert_list[] = { + { + .gpio = GPIO_PCH_SYS_PWROK, + .delay_ms = 3, + }, +}; +const int pwrok_signal_assert_count = ARRAY_SIZE(pwrok_signal_assert_list); + +const struct intel_x86_pwrok_signal pwrok_signal_deassert_list[] = { + { + .gpio = GPIO_PCH_SYS_PWROK, + }, +}; +const int pwrok_signal_deassert_count = ARRAY_SIZE(pwrok_signal_deassert_list); + +/* + * Returns board information (board id[7:0] and Fab id[15:8]) on success + * -1 on error. + */ +__override int board_get_version(void) +{ + /* Cache the MTLRVP board ID */ + static int mtlrvp_board_id; + + int i; + int rv = EC_ERROR_UNKNOWN; + int fab_id, board_id, bom_id; + + /* Board ID is already read */ + if (mtlrvp_board_id) + return mtlrvp_board_id; + + /* + * IOExpander that has Board ID information is on DSW-VAL rail on + * ADL RVP. On cold boot cycles, DSW-VAL rail is taking time to settle. + * This loop retries to ensure rail is settled and read is successful + */ + for (i = 0; i < RVP_VERSION_READ_RETRY_CNT; i++) { + rv = gpio_pin_get_dt(&bom_id_config[0]); + + if (rv >= 0) + break; + + k_msleep(1); + } + + /* return -1 if failed to read board id */ + if (rv) + return -1; + + /* + * BOM ID [2] : IOEX[0] + * BOM ID [1:0] : IOEX[15:14] + */ + bom_id = gpio_pin_get_dt(&bom_id_config[0]) << 2; + bom_id |= gpio_pin_get_dt(&bom_id_config[1]) << 1; + bom_id |= gpio_pin_get_dt(&bom_id_config[2]); + /* + * FAB ID [1:0] : IOEX[2:1] + 1 + */ + fab_id = gpio_pin_get_dt(&fab_id_config[0]) << 1; + fab_id |= gpio_pin_get_dt(&fab_id_config[1]); + fab_id += 1; + + /* + * BOARD ID[5:0] : IOEX[13:8] + */ + board_id = gpio_pin_get_dt(&board_id_config[0]) << 5; + board_id |= gpio_pin_get_dt(&board_id_config[1]) << 4; + board_id |= gpio_pin_get_dt(&board_id_config[2]) << 3; + board_id |= gpio_pin_get_dt(&board_id_config[3]) << 2; + board_id |= gpio_pin_get_dt(&board_id_config[4]) << 1; + board_id |= gpio_pin_get_dt(&board_id_config[5]); + + CPRINTF("BID:0x%x, FID:0x%x, BOM:0x%x", board_id, fab_id, bom_id); + + mtlrvp_board_id = board_id | (fab_id << 8); + return mtlrvp_board_id; +} + +static void board_int_init(void) +{ + /* Enable PPC interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc)); + + /* Enable TCPC interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_c1_tcpc)); +#if defined(HAS_TASK_PD_C2) + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c2_tcpc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c3_tcpc)); +#endif + + /* Enable CCD Mode interrupt */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode)); +} + +static int board_pre_task_peripheral_init(const struct device *unused) +{ + ARG_UNUSED(unused); + + /* Only reset tcpc/pd if not sysjump */ + if (!system_jumped_late()) { + /* Initialize tcpc and all ioex */ + board_reset_pd_mcu(); + } + + /* Initialize all interrupts */ + board_int_init(); + + /* Make sure SBU are routed to CCD or AUX based on CCD status at init */ + board_connect_c0_sbu_deferred(); + + return 0; +} +SYS_INIT(board_pre_task_peripheral_init, APPLICATION, + CONFIG_APPLICATION_INIT_PRIORITY); + +/* + * Since MTLRVP has both PPC and TCPC ports override to check if the port + * is a PPC or non PPC port + */ +__override bool pd_check_vbus_level(int port, enum vbus_level level) +{ + if (!board_port_has_ppc(port)) { + return tcpm_check_vbus_level(port, level); + } else if (level == VBUS_PRESENT) { + return pd_snk_is_vbus_provided(port); + } else { + return !pd_snk_is_vbus_provided(port); + } +} + +__override bool board_port_has_ppc(int port) +{ + bool ppc_port; + + switch (port) { + case USBC_PORT_C0: + case USBC_PORT_C1: + ppc_port = true; + break; + default: + ppc_port = false; + break; + } + + return ppc_port; +} diff --git a/zephyr/program/intelrvp/mtlrvp/usbc.dts b/zephyr/program/intelrvp/mtlrvp/usbc.dts new file mode 100644 index 0000000000..e4f3bdc465 --- /dev/null +++ b/zephyr/program/intelrvp/mtlrvp/usbc.dts @@ -0,0 +1,76 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + usbc_port0: port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c0_hb_retimer + &virtual_mux_c0>; + }; + }; + port0-muxes { + virtual_mux_c0: virtual-mux-c0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + usbc_port1: port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c1_hb_retimer + &virtual_mux_c1>; + }; + }; + port1-muxes { + virtual_mux_c1: virtual-mux-c1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + usbc_port2: port2@2 { + compatible = "named-usbc-port"; + reg = <2>; + tcpc = <&tcpc_port2>; + usb-mux-chain-2 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c2_hb_retimer + &virtual_mux_c2>; + }; + }; + port2-muxes { + virtual_mux_c2: virtual-mux-c2 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + usbc_port3: port3@3 { + compatible = "named-usbc-port"; + reg = <3>; + tcpc = <&tcpc_port3>; + usb-mux-chain-3 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c3_hb_retimer + &virtual_mux_c3>; + }; + }; + port3-muxes { + virtual_mux_c3: virtual-mux-c3 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; diff --git a/zephyr/program/intelrvp/prj.conf b/zephyr/program/intelrvp/prj.conf new file mode 100644 index 0000000000..df04eca101 --- /dev/null +++ b/zephyr/program/intelrvp/prj.conf @@ -0,0 +1,72 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +CONFIG_CROS_EC=y +CONFIG_LTO=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_SHIMMED_TASKS=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001 + +#Power Sequencing +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y + +# Host command +CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=y +CONFIG_PLATFORM_EC_PORT80=y + +# USB-C and PD +CONFIG_PLATFORM_EC_USB_VID=0x18d1 +CONFIG_PLATFORM_EC_USB_PID=0x8086 +CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y + +# I2C +CONFIG_I2C=y + +# eSPI +CONFIG_ESPI=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_CMD_BUTTON=n + +# Sensors +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n + +# Shell Commands +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y +CONFIG_KERNEL_SHELL=y + +# Logging +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y + +# TODO +# Below conf are disabled to compile successfully +# These will be enabled in upcoming CLs +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n diff --git a/zephyr/program/intelrvp/src/chg_usb_pd.c b/zephyr/program/intelrvp/src/chg_usb_pd.c new file mode 100644 index 0000000000..63a1853b4d --- /dev/null +++ b/zephyr/program/intelrvp/src/chg_usb_pd.c @@ -0,0 +1,129 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Common USB PD charge configuration */ + +#include "charge_manager.h" +#include "charge_state_v2.h" +#include "gpio.h" +#include "hooks.h" +#include "intelrvp.h" +#include "tcpm/tcpci.h" + +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) + +bool is_typec_port(int port) +{ +#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 + return !(port == DEDICATED_CHARGE_PORT || port == CHARGE_PORT_NONE); +#else + return !(port == CHARGE_PORT_NONE); +#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */ +} + +static inline int board_dc_jack_present(void) +{ +#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 + return gpio_get_level(GPIO_DC_JACK_PRESENT); +#else + return 0; +#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */ +} + +static void board_dc_jack_handle(void) +{ +#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 + struct charge_port_info charge_dc_jack; + + /* System is booted from DC Jack */ + if (board_dc_jack_present()) { + charge_dc_jack.current = + (PD_MAX_POWER_MW * 1000) / DC_JACK_MAX_VOLTAGE_MV; + charge_dc_jack.voltage = DC_JACK_MAX_VOLTAGE_MV; + } else { + charge_dc_jack.current = 0; + charge_dc_jack.voltage = USB_CHARGER_VOLTAGE_MV; + } + + charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED, + DEDICATED_CHARGE_PORT, &charge_dc_jack); +#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */ +} + +void board_dc_jack_interrupt(enum gpio_signal signal) +{ + board_dc_jack_handle(); +} + +static void board_charge_init(void) +{ + int port, supplier; + struct charge_port_info charge_init = { + .current = 0, + .voltage = USB_CHARGER_VOLTAGE_MV, + }; + + /* Initialize all charge suppliers to seed the charge manager */ + for (port = 0; port < CHARGE_PORT_COUNT; port++) { + for (supplier = 0; supplier < CHARGE_SUPPLIER_COUNT; + supplier++) { + charge_manager_update_charge(supplier, port, + &charge_init); + } + } + + board_dc_jack_handle(); +} +DECLARE_HOOK(HOOK_INIT, board_charge_init, HOOK_PRIO_DEFAULT); + +int board_set_active_charge_port(int port) +{ + int i; + /* charge port is a realy physical port */ + int is_real_port = (port >= 0 && port < CHARGE_PORT_COUNT); + /* check if we are source vbus on that port */ + int source = board_vbus_source_enabled(port); + + if (is_real_port && source) { + CPRINTS("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + +#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 + /* + * Do not enable Type-C port if the DC Jack is present. + * When the Type-C is active port, hardware circuit will + * block DC jack from enabling +VADP_OUT. + */ + if (port != DEDICATED_CHARGE_PORT && board_dc_jack_present()) { + CPRINTS("DC Jack present, Skip enable p%d", port); + return EC_ERROR_INVAL; + } +#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT */ + + /* Make sure non-charging ports are disabled */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i != port) { + board_charging_enable(i, 0); + } + } + + /* Enable charging port */ + if (is_typec_port(port)) { + board_charging_enable(port, 1); + } + + CPRINTS("New chg p%d", port); + + return EC_SUCCESS; +} + +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) +{ + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} diff --git a/zephyr/program/intelrvp/src/chg_usb_pd_mecc_1_1.c b/zephyr/program/intelrvp/src/chg_usb_pd_mecc_1_1.c new file mode 100644 index 0000000000..45fbbc6f65 --- /dev/null +++ b/zephyr/program/intelrvp/src/chg_usb_pd_mecc_1_1.c @@ -0,0 +1,92 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Intel-RVP family-specific configuration */ + +#include "console.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "include/gpio.h" +#include "intelrvp.h" +#include "ioexpander.h" +#include "system.h" +#include "tcpm/tcpci.h" +#include "usbc_ppc.h" + +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) + +void tcpc_alert_event(enum gpio_signal signal) +{ + int i; + + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + /* No alerts for embedded TCPC */ + if (tcpc_config[i].bus_type == EC_BUS_TYPE_EMBEDDED) { + continue; + } + + if (signal == tcpc_aic_gpios[i].tcpc_alert) { + schedule_deferred_pd_interrupt(i); + break; + } + } +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + int i; + + /* Check which port has the ALERT line set */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + /* No alerts for embdeded TCPC */ + if (tcpc_config[i].bus_type == EC_BUS_TYPE_EMBEDDED) { + continue; + } + + if (!gpio_get_level(tcpc_aic_gpios[i].tcpc_alert)) { + status |= PD_STATUS_TCPC_ALERT_0 << i; + } + } + + return status; +} + +int ppc_get_alert_status(int port) +{ + return tcpc_aic_gpios[port].ppc_intr_handler && + !gpio_get_level(tcpc_aic_gpios[port].ppc_alert); +} + +/* PPC support routines */ +void ppc_interrupt(enum gpio_signal signal) +{ + int i; + + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (tcpc_aic_gpios[i].ppc_intr_handler && + signal == tcpc_aic_gpios[i].ppc_alert) { + tcpc_aic_gpios[i].ppc_intr_handler(i); + break; + } + } +} + +void board_charging_enable(int port, int enable) +{ + int rv; + + if (tcpc_aic_gpios[port].ppc_intr_handler) { + rv = ppc_vbus_sink_enable(port, enable); + } else { + rv = tcpc_config[port].drv->set_snk_ctrl(port, enable); + } + + if (rv) { + CPRINTS("C%d: sink path %s failed", port, + enable ? "en" : "dis"); + } +} diff --git a/zephyr/program/intelrvp/src/intel_rvp_board_id.c b/zephyr/program/intelrvp/src/intel_rvp_board_id.c new file mode 100644 index 0000000000..77d4e93afd --- /dev/null +++ b/zephyr/program/intelrvp/src/intel_rvp_board_id.c @@ -0,0 +1,30 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include "intel_rvp_board_id.h" + +#define DT_DRV_COMPAT intel_rvp_board_id + +BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1, + "Unsupported RVP Board ID instance"); + +#define RVP_ID_GPIO_DT_SPEC_GET(idx, node_id, prop) \ + GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx), + +#define RVP_ID_CONFIG_LIST(node_id, prop) \ + LISTIFY(DT_PROP_LEN(node_id, prop), RVP_ID_GPIO_DT_SPEC_GET, (), \ + node_id, prop) + +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) +const struct gpio_dt_spec bom_id_config[] = { RVP_ID_CONFIG_LIST(DT_DRV_INST(0), + bom_gpios) }; + +const struct gpio_dt_spec fab_id_config[] = { RVP_ID_CONFIG_LIST(DT_DRV_INST(0), + fab_gpios) }; + +const struct gpio_dt_spec board_id_config[] = { RVP_ID_CONFIG_LIST( + DT_DRV_INST(0), board_gpios) }; +#endif /* #if DT_HAS_COMPAT_STATUS_OKAY */ diff --git a/zephyr/program/intelrvp/src/intel_rvp_led.c b/zephyr/program/intelrvp/src/intel_rvp_led.c new file mode 100644 index 0000000000..0e4d872963 --- /dev/null +++ b/zephyr/program/intelrvp/src/intel_rvp_led.c @@ -0,0 +1,168 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "battery.h" +#include "charge_manager.h" +#include "charge_state.h" +#include "chipset.h" +#include "common.h" +#include "console.h" +#include "ec_commands.h" +#include "extpower.h" +#include "hooks.h" +#include "led_common.h" +#include "led_pwm.h" +#include "pwm.h" +#include "timer.h" +#include "util.h" + +/* Battery percentage thresholds to blink at different rates. */ +#define LOW_BATTERY_PERCENTAGE 10 +#define NORMAL_BATTERY_PERCENTAGE 90 + +#define LED_OFF -1 + +#define LED_PULSE_TICK (125 * MSEC) + +#define LED_FAST_PULSE_PERIOD (250 / 125) /* 250 ms */ +#define LED_SLOW_PULSE_PERIOD ((2 * MSEC) / 125) /* 2 sec */ + +struct led_pulse_data { + bool led_is_pulsing; + uint8_t led_pulse_period; + uint8_t led_tick_count; +}; + +static struct led_pulse_data rvp_led[CONFIG_LED_PWM_COUNT]; + +static void pulse_led_deferred(void); +DECLARE_DEFERRED(pulse_led_deferred); + +static void pulse_led_deferred(void) +{ + int i = 0; + bool call_deferred = false; + + for (i = 0; i < CONFIG_LED_PWM_COUNT; i++) { + if (!rvp_led[i].led_is_pulsing) { + rvp_led[i].led_tick_count = 0; + continue; + } + + /* + * LED will be in ON state first half of the pulse period + * and in OFF state in second half of the pulse period. + */ + if (rvp_led[i].led_tick_count < + (rvp_led[i].led_pulse_period >> 1)) + set_pwm_led_color(i, EC_LED_COLOR_GREEN); + else + set_pwm_led_color(i, LED_OFF); + + rvp_led[i].led_tick_count = (rvp_led[i].led_tick_count + 1) % + rvp_led[i].led_pulse_period; + call_deferred = true; + } + + if (call_deferred) + hook_call_deferred(&pulse_led_deferred_data, LED_PULSE_TICK); +} + +static void pulse_leds(enum pwm_led_id id, int period) +{ + rvp_led[id].led_pulse_period = period; + rvp_led[id].led_is_pulsing = true; + + pulse_led_deferred(); +} + +static void update_charger_led(enum pwm_led_id id) +{ + enum charge_state chg_st = charge_get_state(); + + /* + * The colors listed below are the default, but can be overridden. + * + * Fast Flash = Charging error + * Slow Flash = Discharging + * LED on = Charging + * LED off = No Charger connected + */ + if (chg_st == PWR_STATE_CHARGE || + chg_st == PWR_STATE_CHARGE_NEAR_FULL) { + /* Charging: LED ON */ + rvp_led[id].led_is_pulsing = false; + set_pwm_led_color(id, EC_LED_COLOR_GREEN); + } else if (chg_st == PWR_STATE_DISCHARGE || + chg_st == PWR_STATE_DISCHARGE_FULL) { + if (extpower_is_present()) { + /* Discharging: + * Flash slower (2 second period, 100% duty cycle) + */ + pulse_leds(id, LED_SLOW_PULSE_PERIOD); + } else { + /* No Charger connected: LED OFF */ + rvp_led[id].led_is_pulsing = false; + set_pwm_led_color(id, LED_OFF); + } + } else if (chg_st == PWR_STATE_ERROR) { + /* Charging error: + * Flash faster (250 ms period, 100% duty cycle) + */ + pulse_leds(id, LED_FAST_PULSE_PERIOD); + } else { + /* LED OFF */ + rvp_led[id].led_is_pulsing = false; + set_pwm_led_color(id, LED_OFF); + } +} + +static void update_battery_led(enum pwm_led_id id) +{ + /* + * Fast Flash = Low Battery + * Slow Flash = Normal Battery + * LED on = Full Battery + * LED off = No Battery + */ + if (battery_is_present() == BP_YES) { + int batt_percentage = charge_get_percent(); + + if (batt_percentage < LOW_BATTERY_PERCENTAGE) { + /* Low Battery: + * Flash faster (250 ms period, 100% duty cycle) + */ + pulse_leds(id, LED_FAST_PULSE_PERIOD); + } else if (batt_percentage < NORMAL_BATTERY_PERCENTAGE) { + /* Normal Battery: + * Flash slower (2 second period, 100% duty cycle) + */ + pulse_leds(id, LED_SLOW_PULSE_PERIOD); + } else { + /* Full Battery: LED ON */ + rvp_led[id].led_is_pulsing = false; + set_pwm_led_color(id, EC_LED_COLOR_GREEN); + } + } else { + /* No Battery: LED OFF */ + rvp_led[id].led_is_pulsing = false; + set_pwm_led_color(id, LED_OFF); + } +} + +static void init_rvp_leds_off(void) +{ + /* Turn off LEDs such that they are in a known state with zero duty. */ + set_pwm_led_color(PWM_LED0, LED_OFF); + set_pwm_led_color(PWM_LED1, LED_OFF); +} +DECLARE_HOOK(HOOK_INIT, init_rvp_leds_off, HOOK_PRIO_POST_PWM); + +static void update_led(void) +{ + update_battery_led(PWM_LED0); + update_charger_led(PWM_LED1); +} +DECLARE_HOOK(HOOK_SECOND, update_led, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/intelrvp/src/intelrvp.c b/zephyr/program/intelrvp/src/intelrvp.c new file mode 100644 index 0000000000..7098f26cbf --- /dev/null +++ b/zephyr/program/intelrvp/src/intelrvp.c @@ -0,0 +1,25 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* TODO: b/218904113: Convert to using Zephyr GPIOs */ +#include "gpio.h" +#include "hooks.h" + +static void board_init(void) +{ + /* Enable SOC SPI */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_spi_oe_mecc), 1); +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_LAST); + +__override void intel_x86_sys_reset_delay(void) +{ + /* + * From MAX6818 Data sheet, Range of 'Debounce Duaration' is + * Minimum - 20 ms, Typical - 40 ms, Maximum - 80 ms. + * See b/153128296. + */ + udelay(60 * MSEC); +} diff --git a/zephyr/program/intelrvp/src/usb_pd_policy_mecc_1_1.c b/zephyr/program/intelrvp/src/usb_pd_policy_mecc_1_1.c new file mode 100644 index 0000000000..a194b358f1 --- /dev/null +++ b/zephyr/program/intelrvp/src/usb_pd_policy_mecc_1_1.c @@ -0,0 +1,106 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "console.h" +#include "gpio.h" +#include "intelrvp.h" +#include "usb_mux.h" +#include "usbc_ppc.h" + +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) + +static inline void board_pd_set_vbus_discharge(int port, bool enable) +{ + if (tcpc_aic_gpios[port].ppc_intr_handler) { + ppc_discharge_vbus(port, enable); + } else { + tcpc_discharge_vbus(port, enable); + } +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + /* Disable charging. */ + if (tcpc_aic_gpios[port].ppc_intr_handler) { + rv = ppc_vbus_sink_enable(port, 0); + } else { + rv = tcpc_config[port].drv->set_snk_ctrl(port, 0); + } + + if (rv) { + return rv; + } + + board_pd_set_vbus_discharge(port, false); + + /* Provide Vbus. */ + if (tcpc_aic_gpios[port].ppc_intr_handler) { + rv = ppc_vbus_source_enable(port, 1); + } else { + tcpc_config[port].drv->set_src_ctrl(port, 1); + } + + if (rv) { + return rv; + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +void pd_power_supply_reset(int port) +{ + int prev_en; + + prev_en = board_vbus_source_enabled(port); + + /* Disable VBUS. */ + if (tcpc_aic_gpios[port].ppc_intr_handler) { + ppc_vbus_source_enable(port, 0); + } else { + tcpc_config[port].drv->set_src_ctrl(port, 0); + } + + /* Enable discharge if we were previously sourcing 5V */ + if (prev_en) { + board_pd_set_vbus_discharge(port, true); + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_check_vconn_swap(int port) +{ + /* Only allow vconn swap if PP3300 rail is enabled */ + return gpio_get_level(GPIO_EN_PP3300_A); +} + +int pd_snk_is_vbus_provided(int port) +{ + if (tcpc_aic_gpios[port].ppc_intr_handler) { + return ppc_is_vbus_present(port); + } else { + return tcpc_config[port].drv->check_vbus_level(port, + VBUS_PRESENT); + } +} + +int board_vbus_source_enabled(int port) +{ + if (is_typec_port(port)) { + if (tcpc_aic_gpios[port].ppc_intr_handler) { + return ppc_is_sourcing_vbus(port); + } else { + return tcpc_config[port].drv->get_src_ctrl(port); + } + } + return 0; +} diff --git a/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf b/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf new file mode 100644 index 0000000000..1ef365a8fa --- /dev/null +++ b/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf @@ -0,0 +1,9 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Zephyr Inbuilt AP Power Sequencing Config +CONFIG_AP_PWRSEQ=y +CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y +CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y +CONFIG_AP_PWRSEQ_S0IX=y diff --git a/zephyr/program/it8xxx2_evb/BUILD.py b/zephyr/program/it8xxx2_evb/BUILD.py new file mode 100644 index 0000000000..ee89c75390 --- /dev/null +++ b/zephyr/program/it8xxx2_evb/BUILD.py @@ -0,0 +1,18 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for it8xxx2_evb.""" + +register_raw_project( + project_name="it8xxx2_evb", + zephyr_board="it81302bx", + dts_overlays=[ + "adc.dts", + "fan.dts", + "gpio.dts", + "i2c.dts", + "interrupts.dts", + "pwm.dts", + ], +) diff --git a/zephyr/program/it8xxx2_evb/CMakeLists.txt b/zephyr/program/it8xxx2_evb/CMakeLists.txt new file mode 100644 index 0000000000..170606a52d --- /dev/null +++ b/zephyr/program/it8xxx2_evb/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(it8xxx2_evb) + +# Include board specific header files +zephyr_include_directories(include) diff --git a/zephyr/program/it8xxx2_evb/adc.dts b/zephyr/program/it8xxx2_evb/adc.dts new file mode 100644 index 0000000000..509c9b9daf --- /dev/null +++ b/zephyr/program/it8xxx2_evb/adc.dts @@ -0,0 +1,41 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_vbussa: vbussa { + enum-name = "ADC_VBUS"; + io-channels = <&adc0 0>; + }; + adc_vbussb: vbussb { + enum-name = "ADC_PSYS"; + io-channels = <&adc0 1>; + }; + adc_evb_ch_13: evb_ch_13 { + enum-name = "ADC_AMON_BMON"; + io-channels = <&adc0 2>; + }; + adc_evb_ch_14: evb_ch_14 { + enum-name = "ADC_TEMP_SENSOR_FAN"; + io-channels = <&adc0 3>; + }; + adc_evb_ch_15: evb_ch_15 { + enum-name = "ADC_TEMP_SENSOR_DDR_SOC"; + io-channels = <&adc0 4>; + }; + adc_evb_ch_16: evb_ch_16 { + enum-name = "ADC_TEMP_SENSOR_CHARGER"; + io-channels = <&adc0 5>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch3_gpi3_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/it8xxx2_evb/fan.dts b/zephyr/program/it8xxx2_evb/fan.dts new file mode 100644 index 0000000000..2551507ec3 --- /dev/null +++ b/zephyr/program/it8xxx2_evb/fan.dts @@ -0,0 +1,27 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm7 PWM_CHANNEL_7 PWM_KHZ(30) PWM_POLARITY_NORMAL>; + tach = <&tach0>; + rpm_min = <1500>; + rpm_start = <1500>; + rpm_max = <6500>; + }; + }; +}; + +/* fan tachometer sensor */ +&tach0 { + status = "okay"; + channel = ; + pulses-per-round = <2>; + pinctrl-0 = <&tach0a_gpd6_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/it8xxx2_evb/gpio.dts b/zephyr/program/it8xxx2_evb/gpio.dts new file mode 100644 index 0000000000..85bb45d7a0 --- /dev/null +++ b/zephyr/program/it8xxx2_evb/gpio.dts @@ -0,0 +1,169 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-wp = &gpio_wp; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_wp: wp_l { + gpios = <&gpioi 4 (GPIO_INPUT_PULL_UP | + GPIO_ACTIVE_LOW)>; + }; + pch_pltrst_l { + gpios = <&gpioe 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_PCH_RSMRST_L"; + }; + sys_reset_l { + gpios = <&gpiob 6 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_SYS_RESET_L"; + }; + gpio_ec_pch_wake_odl: pch_wake_l { + gpios = <&gpiob 7 GPIO_OUTPUT_HIGH>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* gpioa1 */ + <&gpioa 1 GPIO_INPUT_PULL_DOWN>, + /* gpioa2 */ + <&gpioa 2 GPIO_INPUT_PULL_DOWN>, + /* gpioa3 */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + /* gpioa4 */ + <&gpioa 4 GPIO_INPUT_PULL_DOWN>, + /* gpioa5 */ + <&gpioa 5 GPIO_INPUT_PULL_DOWN>, + + /* gpiob2 */ + <&gpiob 2 GPIO_INPUT_PULL_DOWN>, + /* gpiob5 */ + <&gpiob 5 GPIO_INPUT_PULL_DOWN>, + + /* gpioc0 */ + <&gpioc 0 GPIO_INPUT_PULL_DOWN>, + /* gpioc4 */ + <&gpioc 4 GPIO_INPUT_PULL_DOWN>, + /* gpioc6 */ + <&gpioc 6 GPIO_INPUT_PULL_DOWN>, + /* gpioc7 */ + <&gpioc 7 GPIO_INPUT_PULL_DOWN>, + + /* gpiod0 */ + <&gpiod 0 GPIO_INPUT_PULL_DOWN>, + /* gpiod1 */ + <&gpiod 1 GPIO_INPUT_PULL_DOWN>, + /* gpiod2 */ + <&gpiod 2 GPIO_INPUT_PULL_DOWN>, + /* gpiod3 */ + <&gpiod 3 GPIO_INPUT_PULL_DOWN>, + /* gpiod4 */ + <&gpiod 4 GPIO_INPUT_PULL_DOWN>, + /* gpiod5 */ + <&gpiod 5 GPIO_INPUT_PULL_DOWN>, + /* gpiod7 */ + <&gpiod 7 GPIO_INPUT_PULL_DOWN>, + + /* gpioe1 */ + <&gpioe 1 GPIO_INPUT_PULL_DOWN>, + /* gpioe5 */ + <&gpioe 5 GPIO_INPUT_PULL_DOWN>, + /* gpioe6 */ + <&gpioe 6 GPIO_INPUT_PULL_DOWN>, + + /* gpiof0 */ + <&gpiof 0 GPIO_INPUT_PULL_DOWN>, + /* gpiof1 */ + <&gpiof 1 GPIO_INPUT_PULL_DOWN>, + /* gpiof2 */ + <&gpiof 2 GPIO_INPUT_PULL_DOWN>, + /* gpiof3 */ + <&gpiof 3 GPIO_INPUT_PULL_DOWN>, + /* gpiof4 */ + <&gpiof 4 GPIO_INPUT_PULL_DOWN>, + /* gpiof5 */ + <&gpiof 5 GPIO_INPUT_PULL_DOWN>, + + /* gpiog1 */ + <&gpiog 1 GPIO_INPUT_PULL_DOWN>, + /* gpiog6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + + /* gpioh0 */ + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + /* gpioh3 */ + <&gpioh 3 GPIO_INPUT_PULL_DOWN>, + /* gpioh4 */ + <&gpioh 4 GPIO_INPUT_PULL_DOWN>, + /* gpioh5 */ + <&gpioh 5 GPIO_INPUT_PULL_DOWN>, + /* gpioh6 */ + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + + /* gpioi6 */ + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + /* gpioi7 */ + <&gpioi 7 GPIO_INPUT_PULL_DOWN>, + + /* gpioj0 */ + <&gpioj 0 GPIO_INPUT_PULL_DOWN>, + /* gpioj1 */ + <&gpioj 1 GPIO_INPUT_PULL_DOWN>, + /* gpioj2 */ + <&gpioj 2 GPIO_INPUT_PULL_DOWN>, + /* gpioj3 */ + <&gpioj 3 GPIO_INPUT_PULL_DOWN>, + /* gpioj4 */ + <&gpioj 4 GPIO_INPUT_PULL_DOWN>, + /* gpioj5 */ + <&gpioj 5 GPIO_INPUT_PULL_DOWN>, + /* gpioj6 */ + <&gpioj 6 GPIO_OUTPUT_LOW>, + /* gpioj7 */ + <&gpioj 7 GPIO_OUTPUT_LOW>, + + /* gpiom0 */ + <&gpiom 0 GPIO_INPUT_PULL_DOWN>, + /* gpiom1 */ + <&gpiom 1 GPIO_INPUT_PULL_DOWN>, + /* gpiom2 */ + <&gpiom 2 GPIO_INPUT_PULL_DOWN>, + /* gpiom3 */ + <&gpiom 3 GPIO_INPUT_PULL_DOWN>, + /* gpiom4 */ + <&gpiom 4 GPIO_INPUT_PULL_DOWN>, + /* gpiom6 */ + <&gpiom 6 GPIO_INPUT_PULL_DOWN>; + }; +}; diff --git a/zephyr/program/it8xxx2_evb/i2c.dts b/zephyr/program/it8xxx2_evb/i2c.dts new file mode 100644 index 0000000000..c08c543e44 --- /dev/null +++ b/zephyr/program/it8xxx2_evb/i2c.dts @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + + battery { + i2c-port = <&i2c2>; + enum-names = "I2C_PORT_BATTERY"; + }; + evb-1 { + i2c-port = <&i2c0>; + enum-names = "I2C_PORT_EVB_1"; + }; + evb-2 { + i2c-port = <&i2c1>; + enum-names = "I2C_PORT_EVB_2"; + }; + opt-4 { + i2c-port = <&i2c4>; + enum-names = "I2C_PORT_OPT_4"; + }; + }; +}; + +&i2c0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_clk_gpb3_default + &i2c0_data_gpb4_default>; + pinctrl-names = "default"; +}; + +&i2c1 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_clk_gpc1_default + &i2c1_data_gpc2_default>; + pinctrl-names = "default"; +}; + +&i2c2 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_clk_gpf6_default + &i2c2_data_gpf7_default>; + pinctrl-names = "default"; +}; + +&i2c4 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c4_clk_gpe0_default + &i2c4_data_gpe7_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/it8xxx2_evb/include/i2c_map.h b/zephyr/program/it8xxx2_evb/include/i2c_map.h new file mode 100644 index 0000000000..e83a238d3a --- /dev/null +++ b/zephyr/program/it8xxx2_evb/include/i2c_map.h @@ -0,0 +1,16 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __ZEPHYR_CHROME_I2C_MAP_H +#define __ZEPHYR_CHROME_I2C_MAP_H + +#include + +#include "config.h" + +/* We need registers.h to get the chip specific defines for now */ +#include "i2c/i2c.h" + +#endif /* __ZEPHYR_CHROME_I2C_MAP_H */ diff --git a/zephyr/program/it8xxx2_evb/interrupts.dts b/zephyr/program/it8xxx2_evb/interrupts.dts new file mode 100644 index 0000000000..07fc0ed339 --- /dev/null +++ b/zephyr/program/it8xxx2_evb/interrupts.dts @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = ; + handler = "spi_event"; + }; + }; +}; diff --git a/zephyr/program/it8xxx2_evb/prj.conf b/zephyr/program/it8xxx2_evb/prj.conf new file mode 100644 index 0000000000..d6d422e490 --- /dev/null +++ b/zephyr/program/it8xxx2_evb/prj.conf @@ -0,0 +1,44 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_SHIMMED_TASKS=y + +# SoC configuration +CONFIG_AP=y +CONFIG_AP_ARM_MTK_MT8192=y + +# Lid switch +CONFIG_PLATFORM_EC_LID_SWITCH=y + +# Logging +CONFIG_LOG=y + +# Fan +CONFIG_SENSOR=y + +# I2C +CONFIG_I2C=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# Power Button +CONFIG_PLATFORM_EC_POWER_BUTTON=y + +# TODO(b:185202623): bring these features up +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n +CONFIG_PLATFORM_EC_KEYBOARD=n +CONFIG_CROS_KB_RAW_ITE=n +CONFIG_PLATFORM_EC_SWITCH=n +CONFIG_PLATFORM_EC_VBOOT_EFS2=n +CONFIG_PLATFORM_EC_VBOOT_HASH=n + +# USB-C +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n diff --git a/zephyr/program/it8xxx2_evb/pwm.dts b/zephyr/program/it8xxx2_evb/pwm.dts new file mode 100644 index 0000000000..c566e5c029 --- /dev/null +++ b/zephyr/program/it8xxx2_evb/pwm.dts @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + + /* NOTE: &pwm number needs same with channel number */ + pwm_led_test: pwm_led_test { + pwms = <&pwm0 PWM_CHANNEL_0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + }; + }; +}; + +/* pwm for test */ +&pwm0 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm0_gpa0_default>; + pinctrl-names = "default"; +}; + +/* pwm for fan */ +&pwm7 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm7_gpa7_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/minimal/BUILD.py b/zephyr/program/minimal/BUILD.py new file mode 100644 index 0000000000..5e892aa2d7 --- /dev/null +++ b/zephyr/program/minimal/BUILD.py @@ -0,0 +1,22 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Minimal example project.""" + +register_host_project( + project_name="minimal-posix", + zephyr_board="native_posix", +) + +register_npcx_project( + project_name="minimal-npcx9", + zephyr_board="npcx9m3f", + dts_overlays=[here / "npcx9.dts"], +) + +register_binman_project( + project_name="minimal-it8xxx2", + zephyr_board="it81302bx", + dts_overlays=[here / "it8xxx2.dts"], +) diff --git a/zephyr/program/minimal/CMakeLists.txt b/zephyr/program/minimal/CMakeLists.txt new file mode 100644 index 0000000000..de3bec9428 --- /dev/null +++ b/zephyr/program/minimal/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.20.5) +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(ec) + +zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") diff --git a/zephyr/program/minimal/README.md b/zephyr/program/minimal/README.md new file mode 100644 index 0000000000..72c092dfce --- /dev/null +++ b/zephyr/program/minimal/README.md @@ -0,0 +1,32 @@ +# Minimal Example Zephyr EC Project + +This directory is intended to be an extremely minimal example of a +project. Should you like, you can use it as a bring up a new program, +or as reference as you require. + +If you're bringing up a new variant of a program, you don't need a +whole project directory with a `BUILD.py` and all, and this example is +likely not of use to you. Check out the [project config +documentation] for instructions on adding a new variant. + +[project config documentation]: ../../../docs/zephyr/project_config.md + +# Building + +To build the `native_posix` example, run: + +``` shellsession +(chroot) $ zmake build minimal-posix +``` + +To build the NPCX9 example, run: + +``` shellsession +(chroot) $ zmake build minimal-npcx9 +``` + +For the IT8XXX2 example, run: + +``` shellsession +(chroot) $ zmake build minimal-it8xxx2 +``` diff --git a/zephyr/program/minimal/it8xxx2.dts b/zephyr/program/minimal/it8xxx2.dts new file mode 100644 index 0000000000..3d2028afb2 --- /dev/null +++ b/zephyr/program/minimal/it8xxx2.dts @@ -0,0 +1,22 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &ec_wp_l; + }; + + named-gpios { + compatible = "named-gpios"; + + ec_wp_l: write-protect { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + }; +}; diff --git a/zephyr/program/minimal/npcx9.dts b/zephyr/program/minimal/npcx9.dts new file mode 100644 index 0000000000..3a9f3b26e4 --- /dev/null +++ b/zephyr/program/minimal/npcx9.dts @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &ec_wp_l; + }; + + named-gpios { + compatible = "named-gpios"; + + ec_wp_l: write-protect { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + }; +}; + +&cros_kb_raw { + status = "okay"; + pinctrl-0 = <>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/minimal/prj.conf b/zephyr/program/minimal/prj.conf new file mode 100644 index 0000000000..db7cac0cef --- /dev/null +++ b/zephyr/program/minimal/prj.conf @@ -0,0 +1,18 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_PLATFORM_EC=y +CONFIG_CROS_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_SYSCON=y + +# Disable default features we don't want in a minimal example. +CONFIG_ADC=n +CONFIG_I2C=n +CONFIG_PWM=n +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n +CONFIG_PLATFORM_EC_KEYBOARD=n +CONFIG_PLATFORM_EC_POWER_BUTTON=n +CONFIG_PLATFORM_EC_SWITCH=n +CONFIG_PLATFORM_EC_VBOOT_EFS2=n diff --git a/zephyr/program/nissa/BUILD.py b/zephyr/program/nissa/BUILD.py new file mode 100644 index 0000000000..b1affe7b4c --- /dev/null +++ b/zephyr/program/nissa/BUILD.py @@ -0,0 +1,66 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for nissa.""" + +# Nivviks and Craask, Pujjo, Xivu has NPCX993F, Nereid and Joxer, Yaviks has ITE81302 + + +def register_nissa_project( + project_name, + chip="it81302bx", +): + """Register a variant of nissa.""" + register_func = register_binman_project + if chip.startswith("npcx"): + register_func = register_npcx_project + + chip_kconfig = {"it81302bx": "it8xxx2", "npcx9m3f": "npcx"}[chip] + + return register_func( + project_name=project_name, + zephyr_board=chip, + dts_overlays=[here / project_name / "project.overlay"], + kconfig_files=[ + here / "program.conf", + here / f"{chip_kconfig}_program.conf", + here / project_name / "project.conf", + ], + ) + + +nivviks = register_nissa_project( + project_name="nivviks", + chip="npcx9m3f", +) + +nereid = register_nissa_project( + project_name="nereid", + chip="it81302bx", +) + +craask = register_nissa_project( + project_name="craask", + chip="npcx9m3f", +) + +pujjo = register_nissa_project( + project_name="pujjo", + chip="npcx9m3f", +) + +xivu = register_nissa_project( + project_name="xivu", + chip="npcx9m3f", +) + +joxer = register_nissa_project( + project_name="joxer", + chip="it81302bx", +) + +yaviks = register_nissa_project( + project_name="yaviks", + chip="it81302bx", +) diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt new file mode 100644 index 0000000000..8769af58ba --- /dev/null +++ b/zephyr/program/nissa/CMakeLists.txt @@ -0,0 +1,84 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") + +zephyr_include_directories(include) +zephyr_library_sources("src/common.c") +zephyr_library_sources("src/sub_board.c") +zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ "src/board_power.c") + +if(DEFINED CONFIG_BOARD_NIVVIKS) + project(nivviks) + zephyr_library_sources( + "nivviks/src/led.c" + "nivviks/src/form_factor.c" + "nivviks/src/keyboard.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "nivviks/src/fan.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "nivviks/src/usbc.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "nivviks/src/charger.c") +endif() +if(DEFINED CONFIG_BOARD_NEREID) + project(nereid) + zephyr_library_sources( + "src/led.c" + "nereid/src/keyboard.c" + "nereid/src/hdmi.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "nereid/src/usbc.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "nereid/src/charger.c") +endif() +if(DEFINED CONFIG_BOARD_CRAASK) + zephyr_library_sources( + "craask/src/form_factor.c" + "craask/src/keyboard.c" + "craask/src/led.c" + ) + project(craask) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "craask/src/usbc.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "craask/src/charger.c") +endif() +if(DEFINED CONFIG_BOARD_PUJJO) + project(pujjo) + zephyr_library_sources( + "pujjo/src/led.c" + "pujjo/src/keyboard.c" + "pujjo/src/hdmi.c" + "pujjo/src/form_factor.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "pujjo/src/fan.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "pujjo/src/usbc.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "pujjo/src/charger.c") +endif() +if(DEFINED CONFIG_BOARD_XIVU) + project(xivu) + zephyr_library_sources( + "xivu/src/keyboard.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "xivu/src/usbc.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "xivu/src/charger.c") +endif() +if(DEFINED CONFIG_BOARD_JOXER) + project(joxer) + zephyr_library_sources( + "joxer/src/led.c" + "joxer/src/keyboard.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "joxer/src/usbc.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "joxer/src/charger.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "joxer/src/fan.c") +endif() +if(DEFINED CONFIG_BOARD_YAVIKS) + project(yaviks) + zephyr_library_sources( + "yaviks/src/led.c" + "yaviks/src/keyboard.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "yaviks/src/usbc.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "yaviks/src/charger.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "yaviks/src/fan.c") +endif() \ No newline at end of file diff --git a/zephyr/program/nissa/Kconfig b/zephyr/program/nissa/Kconfig new file mode 100644 index 0000000000..9e9ffc2528 --- /dev/null +++ b/zephyr/program/nissa/Kconfig @@ -0,0 +1,52 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config BOARD_NIVVIKS + bool "Google Nivviks Board" + help + Build Google Nivviks reference board. Nivviks has Intel ADL-N SoC + with NPCX993FA0BX EC. + +config BOARD_NEREID + bool "Google Nereid Board" + help + Build Google Nereid reference board. Nereid has Intel ADL-N SoC + with IT81302 EC. + +config BOARD_CRAASK + bool "Google Craask Board" + help + Build Google Craask board. Craask has Intel ADL-N SoC + with NPCX993FA0BX EC. + +config BOARD_PUJJO + bool "Google Pujjo Board" + help + Build Google Pujjo board. Pujjo has Intel ADL-N SoC + with NPCX993FA0BX EC. + +config BOARD_XIVU + bool "Google Xivu Board" + help + Build Google Xivu board. Xivu has Intel ADL-N SoC + with NPCX993FA0BX EC. + +config BOARD_JOXER + bool "Google Joxer Board" + help + Build Google Joxer reference board. Joxer has Intel ADL-N SoC + with IT81302 EC. + +config BOARD_YAVIKS + bool "Google Yaviks Board" + help + Build Google Yaviks board. Yaviks has Intel ADL-N SoC + with IT81302 EC. + + +module = NISSA +module-str = Nissa board-specific code +source "subsys/logging/Kconfig.template.log_config" + +source "Kconfig.zephyr" diff --git a/zephyr/program/nissa/cbi.dtsi b/zephyr/program/nissa/cbi.dtsi new file mode 100644 index 0000000000..d841be1624 --- /dev/null +++ b/zephyr/program/nissa/cbi.dtsi @@ -0,0 +1,61 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + nissa-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to indicate which sub-board + * is attached. + */ + sub-board { + enum-name = "FW_SUB_BOARD"; + start = <0>; + size = <2>; + + sub-board-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_SUB_BOARD_1"; + value = <1>; + }; + sub-board-2 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_SUB_BOARD_2"; + value = <2>; + }; + sub-board-3 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_SUB_BOARD_3"; + value = <3>; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <2>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + }; +}; diff --git a/zephyr/program/nissa/craask/cbi.dtsi b/zephyr/program/nissa/craask/cbi.dtsi new file mode 100644 index 0000000000..4c2e052f4d --- /dev/null +++ b/zephyr/program/nissa/craask/cbi.dtsi @@ -0,0 +1,107 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* Craask-specific fw_config fields. */ + nissa-fw-config { + /* + * FW_CONFIG field to describe Lid sensor orientation. + */ + lid-inversion { + enum-name = "FW_LID_INVERSION"; + start = <8>; + size = <1>; + + /* + * 0: regular placement of the lid sensor + * 1: rotate 180' of xy plane. + */ + regular { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_LID_REGULAR"; + value = <0>; + default; + }; + xy_rotate_180 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_LID_XY_ROT_180"; + value = <1>; + }; + }; + /* + * FW_CONFIG field to describe Clamshell/Convertible. + */ + form_factor { + enum-name = "FORM_FACTOR"; + start = <9>; + size = <1>; + + /* + * 0: convertible, 1: clamshell + */ + convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CONVERTIBLE"; + value = <0>; + }; + clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CLAMSHELL"; + value = <1>; + }; + }; + }; + /* Craask-specific ssfc fields. */ + cbi-ssfc { + compatible = "named-cbi-ssfc"; + /* + * SSFC bit0-1 was defined for AUDIO CODEC. + * 0: ALC5682I_VS + * 1: NAU8825 + */ + audio_codec { + enum-name = "AUDIO_CODEC"; + size = <2>; + }; + /* + * SSFC field to identify LID motion sensor. + */ + lid-sensor { + enum-name = "LID_SENSOR"; + size = <2>; + + lid_sensor_0: lis2dw12 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <0>; + default; + }; + lid_sensor_1: bma422 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <1>; + }; + }; + /* + * SSFC field to identify BASE motion sensor. + */ + base-sensor { + enum-name = "BASE_SENSOR"; + size = <2>; + + base_sensor_0: lsm6dso { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <0>; + default; + }; + base_sensor_1: bmi323 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <1>; + }; + }; + }; +}; diff --git a/zephyr/program/nissa/craask/generated.dtsi b/zephyr/program/nissa/craask/generated.dtsi new file mode 100644 index 0000000000..4303bbd4c5 --- /dev/null +++ b/zephyr/program/nissa/craask/generated.dtsi @@ -0,0 +1,288 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { + enum-name = "ADC_PP1050_PROC"; + io-channels = <&adc0 4>; + }; + adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { + enum-name = "ADC_PP3300_S5"; + io-channels = <&adc0 6>; + }; + adc_temp_sensor_1: temp_sensor_1 { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 0>; + }; + adc_temp_sensor_2: temp_sensor_2 { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 1>; + }; + adc_temp_sensor_3: temp_sensor_3 { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 10>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_acc_int_l: acc_int_l { + gpios = <&gpio5 0 GPIO_INPUT>; + }; + gpio_all_sys_pwrgd: all_sys_pwrgd { + gpios = <&gpioa 7 GPIO_INPUT>; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_ec_battery_pres_odl: ec_battery_pres_odl { + gpios = <&gpioa 3 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio7 4 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { + gpios = <&gpiod 3 GPIO_ODR_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_entering_rw: ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpio7 5 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_odl { + gpios = <&gpiob 0 GPIO_ODR_LOW>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpiof 1 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { + gpios = <&gpio6 1 GPIO_OUTPUT>; + }; + gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { + gpios = <&gpioe 4 GPIO_OUTPUT>; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpio8 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { + gpios = <&gpio7 2 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpioc 1 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioa 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpio7 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { + gpios = <&gpio3 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { + gpios = <&gpioa 4 GPIO_ODR_HIGH>; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_en_kb_bl: en_kb_bl { + gpios = <&gpioa 0 GPIO_OUTPUT>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_en_pp3300_s5: en_pp3300_s5 { + gpios = <&gpiob 6 GPIO_OUTPUT>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + }; + gpio_en_pp5000_pen_x: en_pp5000_pen_x { + gpios = <&gpioe 2 GPIO_OUTPUT>; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio4 0 GPIO_OUTPUT>; + }; + gpio_en_slp_z: en_slp_z { + gpios = <&gpioe 1 GPIO_OUTPUT>; + }; + gpio_en_usb_a0_vbus: en_usb_a0_vbus { + gpios = <&gpio9 1 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_hdmi_sel: hdmi_sel { + gpios = <&gpioc 6 GPIO_OUTPUT>; + }; + gpio_imu_int_l: imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { + gpios = <&gpio4 3 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_pen_detect_odl: pen_detect_odl { + gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { + gpios = <&gpio4 2 GPIO_INPUT>; + }; + gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { + gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpio9 7 GPIO_INPUT>; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + gpio_slp_s4_l: slp_s4_l { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpio6 2 GPIO_INPUT>; + }; + gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { + gpios = <&gpiod 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB2_ILIM_SEL"; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpioc 5 GPIO_ODR_HIGH>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpio9 5 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { + gpios = <&gpio8 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB1_ILIM_SEL"; + }; + gpio_usb_c0_int_odl: usb_c0_int_odl { + gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; + }; + gpio_vccin_aux_vid0: vccin_aux_vid0 { + gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_vccin_aux_vid1: vccin_aux_vid1 { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_eeprom: ec_i2c_eeprom { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { + i2c-port = <&i2c5_1>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + }; + i2c_ec_i2c_batt: ec_i2c_batt { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_BATTERY"; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan4_gp41 + &adc0_chan6_gp34 + &adc0_chan10_gpe0>; + pinctrl-names = "default"; +}; + +&i2c0_0 { + status = "okay"; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c1_0 { + status = "okay"; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; +}; + +&i2c3_0 { + status = "okay"; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; +}; + +&i2c5_1 { + status = "okay"; + pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>; + pinctrl-names = "default"; +}; + +&i2c7_0 { + status = "okay"; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/craask/keyboard.dtsi b/zephyr/program/nissa/craask/keyboard.dtsi new file mode 100644 index 0000000000..f9e46de1f2 --- /dev/null +++ b/zephyr/program/nissa/craask/keyboard.dtsi @@ -0,0 +1,32 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/craask/motionsense.dtsi b/zephyr/program/nissa/craask/motionsense.dtsi new file mode 100644 index 0000000000..448aed6991 --- /dev/null +++ b/zephyr/program/nissa/craask/motionsense.dtsi @@ -0,0 +1,257 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * Interrupt bindings for sensor devices. + */ + lsm6dso-int = &base_accel; + lis2dw12-int = &lid_accel; + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lis2dw12-mutex { + }; + + lid_mutex_bma422: bma422-mutex { + }; + + base_mutex: base-mutex { + }; + + base_mutex_bmi323: bmi323-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <(-1) 0 0 + 0 1 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + + base_rot_ver1: base-rotation-ver1 { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; + + lid_rot_bma422: lid-rotation-bma { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + + base_rot_bmi323: base-rotation-bmi323 { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lsm6dso_accel_data: lsm6dso-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lsm6dso_gyro_data: lsm6dso-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + bma422_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + * TODO(b/238139272): The first entries of the array must be + * accelerometers,then gyroscope. Fix this dependency in the DTS + * processing which makes the devicetree entries independent. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,lsm6dso-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&lsm6dso_accel_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,lsm6dso-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dso_gyro_data>; + }; + }; + + motionsense-sensor-alt { + alt_lid_accel: alt-lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex_bma422>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_bma422>; + default-range = <2>; + drv-data = <&bma422_data>; + i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; + alternate-for = <&lid_accel>; + alternate-ssfc-indicator = <&lid_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_accel: alt-base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_bmi323>; + drv-data = <&bmi323_data>; + alternate-for = <&base_accel>; + alternate-ssfc-indicator = <&base_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_bmi323>; + drv-data = <&bmi323_data>; + alternate-for = <&base_gyro>; + alternate-ssfc-indicator = <&base_sensor_1>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/nissa/craask/overlay.dtsi b/zephyr/program/nissa/craask/overlay.dtsi new file mode 100644 index 0000000000..257dc299e3 --- /dev/null +++ b/zephyr/program/nissa/craask/overlay.dtsi @@ -0,0 +1,349 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_odl; + int-wp = &int_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; + + batteries { + default_battery: lgc { + compatible = "lgc,ap18c8k", "battery-smart"; + }; + cosmx { + compatible = "cosmx,ap20cbl", "battery-smart"; + }; + cosmx-2 { + compatible = "cosmx,ap20cbl-2", "battery-smart"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_power_button + &int_lid_open + >; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_imu_int_l>; + flags = ; + handler = "motion_interrupt"; + }; + int_vol_down: vol_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_vol_up: vol_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_usb_c0: usb_c0 { + irq-pin = <&gpio_usb_c0_int_odl>; + flags = ; + handler = "usb_interrupt"; + }; + int_usb_c1: usb_c1 { + irq-pin = <&gpio_sb_1>; + flags = ; + handler = "usb_interrupt"; + }; + }; + + named-gpios { + gpio_sb_1: sb-1 { + gpios = <&gpio0 2 GPIO_PULL_UP>; + no-auto-init; + }; + + gpio_sb_2: sb-2 { + gpios = <&gpiod 4 GPIO_OUTPUT>; + no-auto-init; + }; + + /* + * Set I2C pins for type C sub-board to be low voltage (I2C5_1). + * We do this for all boards, since the pins are 3.3V tolerant, + * and the only 2 types of sub-boards used on nivviks both have + * type-C ports on them. + */ + gpio_sb_3: sb-3 { + gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; + no-auto-init; + }; + gpio_sb_4: sb-4 { + gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + no-auto-init; + }; + ec-i2c-sensor-scl { + gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + }; + + /* + * Aliases used for sub-board GPIOs. + */ + aliases { + /* + * Input GPIO when used with type-C port 1 + * Output when used with HDMI sub-board + */ + gpio-usb-c1-int-odl = &gpio_sb_1; + gpio-en-rails-odl = &gpio_sb_1; + /* + * Sub-board with type A USB, enable. + */ + gpio-en-usb-a1-vbus = &gpio_sb_2; + /* + * HPD pins for HDMI sub-board. + */ + gpio-hdmi-en-odl = &gpio_sb_3; + gpio-hpd-odl = &gpio_sb_4; + /* + * Enable S5 rails for LTE sub-board + */ + gpio-en-sub-s5-rails = &gpio_sb_2; + }; + + temp_memory: memory { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_1>; + }; + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_2>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_3>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + memory { + temp_host_high = <75>; + temp_host_halt = <85>; + temp_host_release_high = <70>; + temp_host_release_halt = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_memory>; + }; + charger { + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_charger>; + }; + ambient { + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_ambient>; + }; + }; + + usba { + compatible = "cros-ec,usba-port-enable-pins"; + /* + * sb_2 is only configured as GPIO when USB-A1 is present, + * but it's still safe to control when disabled. + * + * ILIM_SEL pins are referred to by legacy enum name, + * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on + * sub-boards that don't have USB-A so is safe to control + * regardless of system configuration. + */ + enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; + status = "okay"; + }; + + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + chg = <&chg_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + /* + * TODO(b:211693800): port1 may not be present on some + * sub-boards. + */ + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + chg = <&chg_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; + }; + usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; + + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>; + }; +}; + +&thermistor_3V3_51K1_47K_4050B { + status = "okay"; +}; + +&adc_ec_vsense_pp3300_s5 { + /* + * Voltage divider on input has 47k upper and 220k lower legs with + * 2714 mV full-scale reading on the ADC. Apply the largest possible + * multiplier (without overflowing int32) to get the best possible + * approximation of the actual ratio, but derate by a factor of two to + * ensure unexpectedly high values won't overflow. + */ + mul = <(791261 / 2)>; + div = <(651975 / 2)>; +}; + +/* Set bus speeds for I2C */ +&i2c0_0 { + label = "I2C_EEPROM"; + clock-frequency = ; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c1_0 { + label = "I2C_SENSOR"; + clock-frequency = ; +}; + +&i2c3_0 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + /* + * BC1.2 interrupt is shared with TCPC, so + * IRQ is not specified here and handled by + * usb_c0_interrupt. + */ + }; + + chg_port0: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&i2c5_1 { + label = "I2C_SUB_C1_TCPC"; + clock-frequency = ; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port1: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; + + anx7483_mux_1: anx7483-mux-1@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "anx7483_set_default_tuning"; + }; +}; + +&i2c7_0 { + label = "I2C_BATTERY"; + clock-frequency = ; +}; + +&pwm6 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm6_gpc0>; + pinctrl-names = "default"; +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/craask/power_signals.dtsi b/zephyr/program/nissa/craask/power_signals.dtsi new file mode 100644 index 0000000000..1d2b23069d --- /dev/null +++ b/zephyr/program/nissa/craask/power_signals.dtsi @@ -0,0 +1,220 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <10>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpio4 0 0>; + output; + }; + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpiob 6 0>; + output; + }; + pwr-pg-ec-rsmrst-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpio9 4 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioa 6 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpio6 1 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpio4 3 0>; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpio3 7 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + pwr-adc-pp3300 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP3300 PWROK (from ADC)"; + enum-name = "PWR_DSW_PWROK"; + trigger-high = <&cmp_pp3300_s5_high>; + trigger-low = <&cmp_pp3300_s5_low>; + }; + pwr-adc-pp1p05 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP1P05 PWROK (from ADC)"; + enum-name = "PWR_PG_PP1P05"; + trigger-high = <&cmp_pp1p05_high>; + trigger-low = <&cmp_pp1p05_low>; + }; + + adc-cmp { + cmp_pp3300_s5_high: pp3300_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* + * This is 90% of nominal voltage considering voltage + * divider on ADC input. + */ + threshold-mv = <2448>; + }; + cmp_pp3300_s5_low: pp3300_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <2448>; + }; + cmp_pp1p05_high: pp1p05_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* Setting at 90% of nominal voltage */ + threshold-mv = <945>; + }; + cmp_pp1p05_low: pp1p05_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <945>; + }; + }; +}; + +/* + * Because the power signals directly reference the GPIOs, + * the correspinding named-gpios need to have no-auto-init set. + */ +&gpio_ec_soc_dsw_pwrok { + no-auto-init; +}; +&gpio_ec_soc_pch_pwrok_od { + no-auto-init; +}; +&gpio_ec_soc_rsmrst_l { + no-auto-init; +}; +&gpio_ec_soc_sys_pwrok { + no-auto-init; +}; +&gpio_ec_soc_vccst_pwrgd_od { + no-auto-init; +}; +&gpio_en_pp3300_s5 { + no-auto-init; +}; +&gpio_en_pp5000_s5 { + no-auto-init; +}; +&gpio_imvp91_vrrdy_od { + no-auto-init; +}; +&gpio_rsmrst_pwrgd_l { + no-auto-init; +}; +&gpio_slp_s0_l { + no-auto-init; +}; +&gpio_slp_s3_l { + no-auto-init; +}; +&gpio_slp_s4_l { + no-auto-init; +}; +&gpio_slp_sus_l { + no-auto-init; +}; +&gpio_sys_rst_odl { + no-auto-init; +}; diff --git a/zephyr/program/nissa/craask/project.conf b/zephyr/program/nissa/craask/project.conf new file mode 100644 index 0000000000..b7f31cee63 --- /dev/null +++ b/zephyr/program/nissa/craask/project.conf @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_CRAASK=y +CONFIG_PLATFORM_EC_OCPC=y + +# Sensor drivers +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y + +CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y diff --git a/zephyr/program/nissa/craask/project.overlay b/zephyr/program/nissa/craask/project.overlay new file mode 100644 index 0000000000..9ca681d979 --- /dev/null +++ b/zephyr/program/nissa/craask/project.overlay @@ -0,0 +1,14 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../cbi.dtsi" + +#include "cbi.dtsi" +#include "generated.dtsi" +#include "keyboard.dtsi" +#include "motionsense.dtsi" +#include "overlay.dtsi" +#include "power_signals.dtsi" +#include "pwm_leds.dtsi" diff --git a/zephyr/program/nissa/craask/pwm_leds.dtsi b/zephyr/program/nissa/craask/pwm_leds.dtsi new file mode 100644 index 0000000000..e55aa1c9ef --- /dev/null +++ b/zephyr/program/nissa/craask/pwm_leds.dtsi @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm2 2 PWM_HZ(324) PWM_POLARITY_INVERTED>, + <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>, + <&pwm1 1 PWM_HZ(324) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0>; + + /**/ + color-map-red = <100 0 0>; + color-map-green = < 0 100 0>; + color-map-blue = < 0 0 100>; + color-map-yellow = < 0 50 50>; + color-map-white = <100 100 100>; + color-map-amber = < 90 10 0>; + + brightness-range = <100 100 100 0 0 0>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + }; +}; + +/* Enable LEDs to work while CPU suspended */ + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/craask/src/charger.c b/zephyr/program/nissa/craask/src/charger.c new file mode 100644 index 0000000000..d4723e4a0a --- /dev/null +++ b/zephyr/program/nissa/craask/src/charger.c @@ -0,0 +1,56 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charger.h" +#include "charger/isl923x_public.h" +#include "console.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = raa489000_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Craask does not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + if (board_get_usb_pd_port_count() == 2) + raa489000_hibernate(CHARGER_SECONDARY, true); + raa489000_hibernate(CHARGER_PRIMARY, true); + LOG_INF("Charger(s) hibernated"); + cflush(); +} diff --git a/zephyr/program/nissa/craask/src/form_factor.c b/zephyr/program/nissa/craask/src/form_factor.c new file mode 100644 index 0000000000..59869eaa2f --- /dev/null +++ b/zephyr/program/nissa/craask/src/form_factor.c @@ -0,0 +1,121 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "accelgyro.h" +#include "button.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/accelgyro_bmi323.h" +#include "driver/accelgyro_lsm6dso.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "motionsense_sensors.h" +#include "motion_sense.h" +#include "tablet_mode.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define LIS_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_bma422)) +#define BMA_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref)) +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_ver1)) +#define LID_SENSOR SENSOR_ID(DT_NODELABEL(lid_accel)) +#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel)) +#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro)) +#define ALT_LID_S SENSOR_ID(DT_NODELABEL(alt_lid_accel)) + +static bool use_alt_sensor; + +void motion_interrupt(enum gpio_signal signal) +{ + if (use_alt_sensor) + bmi3xx_interrupt(signal); + else + lsm6dso_interrupt(signal); +} + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + enum nissa_sub_board_type sb = nissa_get_sb_type(); + + ret = cbi_get_board_version(&val); + if (ret != EC_SUCCESS) { + LOG_ERR("Error retrieving CBI BOARD_VER."); + return; + } + /* + * The volume up/down button are exchanged on ver3 USB + * sub board. + * + * LTE: + * volup -> gpioa2, voldn -> gpio93 + * USB: + * volup -> gpio93, voldn -> gpioa2 + */ + if (val == 3 && sb == NISSA_SB_C_A) { + LOG_INF("Volume up/down btn exchanged on ver3 USB sku"); + buttons[BUTTON_VOLUME_UP].gpio = GPIO_VOLUME_DOWN_L; + buttons[BUTTON_VOLUME_DOWN].gpio = GPIO_VOLUME_UP_L; + } + + /* + * If the board version is 1 + * use ver1 rotation matrix. + */ + if (val == 1) { + LOG_INF("Switching to ver1 base"); + motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT; + motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT; + } + + /* + * If the firmware config indicates + * an craaskbowl form factor, use the alternative + * rotation matrix. + */ + ret = cros_cbi_get_fw_config(FW_LID_INVERSION, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", + FW_LID_INVERSION); + return; + } + if (val == FW_LID_XY_ROT_180) { + LOG_INF("Lid sensor placement rotate 180 on xy plane"); + motion_sensors[LID_SENSOR].rot_standard_ref = &LIS_ALT_MAT; + motion_sensors_alt[ALT_LID_S].rot_standard_ref = &BMA_ALT_MAT; + } + + /* check which base sensor is used for motion_interrupt */ + use_alt_sensor = cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); + + motion_sensors_check_ssfc(); + + /* Check if it's clamshell or convertible */ + ret = cros_cbi_get_fw_config(FORM_FACTOR, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR); + return; + } + if (val == CLAMSHELL) { + LOG_INF("Clamshell: disable motionsense function."); + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu)); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l), + GPIO_DISCONNECTED); + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/nissa/craask/src/keyboard.c b/zephyr/program/nissa/craask/src/keyboard.c new file mode 100644 index 0000000000..65229eb43f --- /dev/null +++ b/zephyr/program/nissa/craask/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config craask_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &craask_kb; +} diff --git a/zephyr/program/nissa/craask/src/led.c b/zephyr/program/nissa/craask/src/led.c new file mode 100644 index 0000000000..0af0202cf4 --- /dev/null +++ b/zephyr/program/nissa/craask/src/led.c @@ -0,0 +1,56 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery LED control for nissa + */ +#include "common.h" +#include "ec_commands.h" +#include "led_common.h" +#include "led_onoff_states.h" +#include "led_pwm.h" + +__override const int led_charge_lvl_1 = 5; +__override const int led_charge_lvl_2 = 97; +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_BLUE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 3 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_AMBER, + 2 * LED_ONE_SEC }, + { EC_LED_COLOR_BLUE, + 2 * LED_ONE_SEC } }, + }; + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_RED: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_RED); + break; + case EC_LED_COLOR_BLUE: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_BLUE); + break; + case EC_LED_COLOR_AMBER: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); + break; + default: /* LED_OFF and other unsupported colors */ + set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); + break; + } +} diff --git a/zephyr/program/nissa/craask/src/usbc.c b/zephyr/program/nissa/craask/src/usbc.c new file mode 100644 index 0000000000..a15460a212 --- /dev/null +++ b/zephyr/program/nissa/craask/src/usbc.c @@ -0,0 +1,277 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/isl923x_public.h" +#include "driver/retimer/anx7483_public.h" +#include "driver/tcpm/tcpci.h" +#include "driver/tcpm/raa489000.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C0_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, + { /* sub-board */ + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, +}; + +int board_is_sourcing_vbus(int port) +{ + int regval; + + tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); + return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); +} + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + int old_port; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + + LOG_INF("New chg p%d", port); + + /* Disable all ports. */ + if (port == CHARGE_PORT_NONE) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW); + raa489000_enable_asgate(i, false); + } + + return EC_SUCCESS; + } + + /* Check if port is sourcing VBUS. */ + if (board_is_sourcing_vbus(port)) { + LOG_WRN("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i == port) + continue; + + if (tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW)) + LOG_WRN("p%d: sink path disable failed.", i); + raa489000_enable_asgate(i, false); + } + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + if (raa489000_enable_asgate(port, true) || + tcpc_write(port, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { + LOG_WRN("p%d: sink path enable failed.", port); + charger_discharge_on_ac(0); + return EC_ERROR_UNKNOWN; + } + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return EC_SUCCESS; +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + int regval; + + /* + * The interrupt line is shared between the TCPC and BC1.2 detector IC. + * Therefore, go out and actually read the alert registers to report the + * alert status. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { + /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ + if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_0; + } + } + + if (board_get_usb_pd_port_count() == 2 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { + /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ + if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_1; + } + } + + return status; +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS */ + tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return; + + raa489000_set_output_current(port, rp); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return EC_ERROR_INVAL; + + /* Disable charging. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); + if (rv) + return rv; + + /* Our policy is not to source VBUS when the AP is off. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + return EC_ERROR_NOT_POWERED; + + /* Provide Vbus. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); + if (rv) + return rv; + + rv = raa489000_enable_asgate(port, true); + if (rv) + return rv; + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +void board_reset_pd_mcu(void) +{ + /* + * TODO(b:147316511): could send a reset command to the TCPC here + * if needed. + */ +} + +/* + * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible + * for an interrupt to be lost if one asserts the IRQ, the other does the same + * then the first releases it: there will only be one falling edge to trigger + * the interrupt, and the line will be held low. We handle this by running a + * deferred check after a falling edge to see whether the IRQ is still being + * asserted. If it is, we assume an interrupt may have been lost and we need + * to poll each chip for events again. + */ +#define USBC_INT_POLL_DELAY_US 5000 + +static void poll_c0_int(void); +DECLARE_DEFERRED(poll_c0_int); +static void poll_c1_int(void); +DECLARE_DEFERRED(poll_c1_int); + +static void usbc_interrupt_trigger(int port) +{ + schedule_deferred_pd_interrupt(port); + usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); +} + +static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, + const struct deferred_data *ud) +{ + if (!gpio_pin_get_dt(gpio)) { + usbc_interrupt_trigger(port); + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); + } +} + +static void poll_c0_int(void) +{ + poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), + &poll_c0_int_data); +} + +static void poll_c1_int(void) +{ + poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), + &poll_c1_int_data); +} + +void usb_interrupt(enum gpio_signal signal) +{ + int port; + const struct deferred_data *ud; + + if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { + port = 0; + ud = &poll_c0_int_data; + } else { + port = 1; + ud = &poll_c1_int_data; + } + /* + * We've just been called from a falling edge, so there's definitely + * no lost IRQ right now. Cancel any pending check. + */ + hook_call_deferred(ud, -1); + /* Trigger polling of TCPC and BC1.2 in respective tasks */ + usbc_interrupt_trigger(port); + /* Check for lost interrupts in a bit */ + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); +} diff --git a/zephyr/program/nissa/include/nissa_common.h b/zephyr/program/nissa/include/nissa_common.h new file mode 100644 index 0000000000..7cdaba2e50 --- /dev/null +++ b/zephyr/program/nissa/include/nissa_common.h @@ -0,0 +1,23 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Nissa common declarations */ + +#ifndef __CROS_EC_NISSA_NISSA_COMMON_H__ +#define __CROS_EC_NISSA_NISSA_COMMON_H__ + +#include "usb_mux.h" + +enum nissa_sub_board_type { + NISSA_SB_UNKNOWN = -1, /* Uninitialised */ + NISSA_SB_NONE = 0, /* No board defined */ + NISSA_SB_C_A = 1, /* USB type C, USB type A */ + NISSA_SB_C_LTE = 2, /* USB type C, WWAN LTE */ + NISSA_SB_HDMI_A = 3, /* HDMI, USB type A */ +}; + +enum nissa_sub_board_type nissa_get_sb_type(void); + +#endif /* __CROS_EC_NISSA_NISSA_COMMON_H__ */ diff --git a/zephyr/program/nissa/include/nissa_hdmi.h b/zephyr/program/nissa/include/nissa_hdmi.h new file mode 100644 index 0000000000..9f2f533ba7 --- /dev/null +++ b/zephyr/program/nissa/include/nissa_hdmi.h @@ -0,0 +1,55 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Nissa shared HDMI sub-board functionality */ + +#ifndef __CROS_EC_NISSA_NISSA_HDMI_H__ +#define __CROS_EC_NISSA_NISSA_HDMI_H__ + +#include "common.h" + +/** True if the board supports an HDMI sub-board. */ +#define NISSA_BOARD_HAS_HDMI_SUPPORT DT_NODE_EXISTS(DT_NODELABEL(gpio_hdmi_sel)) + +/** + * Configure the GPIO that controls core rails on the HDMI sub-board. + * + * This is the gpio_en_rails_odl pin, which is configured as active-low + * open-drain output to enable power to the HDMI sub-board (typically when the + * AP is in S5 or above). + * + * This function must be called if the pin is connected to the HDMI board and + * power is not enabled by default. + */ +void nissa_configure_hdmi_rails(void); + +/** + * Configure the GPIO that controls the HDMI VCC pin on the HDMI sub-board. + * + * This is the gpio_hdmi_en_odl pin, which is configured as active-low + * open-drain output to enable the VCC pin on the HDMI connector (typically when + * the AP is on, in S0 or S0ix). + * + * This function must be called if the pin is connected to the HDMI board and + * VCC is not enabled by default. + */ +void nissa_configure_hdmi_vcc(void); + +/** + * Configure the GPIOS controlling HDMI sub-board power (core rails and VCC). + * + * This function is called from shared code while configuring sub-boards, and + * used if an HDMI sub-board is present. The default implementation enables the + * core rails control pin (nissa_configure_hdmi_rails) but not VCC + * (nissa_configure_hdmi_vcc), assuming that the pin for VCC is not connected + * connected on most boards (and that VCC will be turned on whenever the core + * rails are turned on). + * + * A board should override this function if it needs to enable more IOs for + * HDMI, or if some pins need to be conditionally enabled. + */ +__override_proto void nissa_configure_hdmi_power_gpios(void); + +#endif /* __CROS_EC_NISSA_NISSA_HDMI_H__ */ diff --git a/zephyr/program/nissa/it8xxx2_program.conf b/zephyr/program/nissa/it8xxx2_program.conf new file mode 100644 index 0000000000..3272c04209 --- /dev/null +++ b/zephyr/program/nissa/it8xxx2_program.conf @@ -0,0 +1,62 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_FLASH_IT8XXX2=y +CONFIG_CROS_SYSTEM_IT8XXX2=y +CONFIG_ESPI_IT8XXX2=y +CONFIG_FPU=y +# rv32iafc/ilp32f is not supported by the toolchain, so use soft-float +CONFIG_FLOAT_HARD=n + +# EC performance is bad; limiting sensor data rate helps keep it from degrading +# so much that it causes problems. b/240485526, b/230818312 +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# Allow more time for the charger to stabilise +CONFIG_PLATFORM_EC_POWER_BUTTON_INIT_TIMEOUT=5 + +# ITE has more space, so don't restrict shell +CONFIG_SHELL_MINIMAL=n + +# RAM savings, since this chip is tight on available RAM. +# It's useful to store a lot of logs for the host to request, but the default 4k +# is pretty large. +CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE=2048 +# Our threads have short names, save 20 bytes per thread +CONFIG_THREAD_MAX_NAME_LEN=12 +# Task stacks, tuned by experiment. Most expanded to prevent overflow, and a few +# shrunk to save RAM. +CONFIG_AP_PWRSEQ_STACK_SIZE=1408 +CONFIG_TASK_HOSTCMD_STACK_SIZE=1280 +CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1280 +CONFIG_TASK_PD_INT_STACK_SIZE=1280 + +# TCPC+PPC: ITE on-chip for C0, PS8745 for optional C1 +CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8745=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_CHARGER=y +# SM5803 controls power path on both ports +CONFIG_PLATFORM_EC_USB_PD_5V_CHARGER_CTRL=y +# SM5803 can discharge VBUS, but not via one of the available options; +# pd_power_supply_reset() does discharge. +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE=n +# The EC is put into programming mode while firmware is running +# (after releasing reset) and PD after being reset will hard-reset +# the port if a contract was already set up. If the system has no +# battery, this will prevent programming because it will brown out +# the system and reset. Inserting a delay gives the programmer more +# time to put the EC into programming mode. +CONFIG_PLATFORM_EC_USB_PD_STARTUP_DELAY_MS=2000 + +# Charger driver and configuration +CONFIG_PLATFORM_EC_OCPC=y +CONFIG_PLATFORM_EC_CHARGER_SM5803=y +CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=21 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=15000 + +# VSENSE: PP3300_S5 & PP1050_PROC +CONFIG_VCMP_IT8XXX2=y +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n diff --git a/zephyr/program/nissa/joxer/cbi.dtsi b/zephyr/program/nissa/joxer/cbi.dtsi new file mode 100644 index 0000000000..afbd125b32 --- /dev/null +++ b/zephyr/program/nissa/joxer/cbi.dtsi @@ -0,0 +1,32 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + nissa-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to indicate which keyboard layout + * should be used. + */ + keyboard { + enum-name = "FW_KB_LAYOUT"; + start = <3>; + size = <2>; + + layout-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_LAYOUT_DEFAULT"; + value = <0>; + default; + }; + layout-2 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_LAYOUT_US2"; + value = <1>; + }; + }; + }; +}; diff --git a/zephyr/program/nissa/joxer/generated.dtsi b/zephyr/program/nissa/joxer/generated.dtsi new file mode 100644 index 0000000000..22214b9726 --- /dev/null +++ b/zephyr/program/nissa/joxer/generated.dtsi @@ -0,0 +1,260 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This file is auto-generated - do not edit! + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { + enum-name = "ADC_PP1050_PROC"; + io-channels = <&adc0 14>; + }; + adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { + enum-name = "ADC_PP3300_S5"; + io-channels = <&adc0 0>; + }; + adc_temp_sensor_1: temp_sensor_1 { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 2>; + }; + adc_temp_sensor_2: temp_sensor_2 { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 3>; + }; + adc_temp_sensor_3: temp_sensor_3 { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 13>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_acc_int_l: acc_int_l { + gpios = <&gpioc 0 GPIO_INPUT>; + }; + gpio_all_sys_pwrgd: all_sys_pwrgd { + gpios = <&gpiob 7 GPIO_INPUT>; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioh 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpiog 1 GPIO_INPUT>; + }; + gpio_ec_battery_pres_odl: ec_battery_pres_odl { + gpios = <&gpioi 4 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioj 5 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { + gpios = <&gpiok 4 GPIO_ODR_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_entering_rw: ec_entering_rw { + gpios = <&gpioc 7 GPIO_OUTPUT>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpioh 1 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_odl { + gpios = <&gpiob 2 GPIO_ODR_LOW>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpioi 1 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { + gpios = <&gpiol 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { + gpios = <&gpiok 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpiod 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { + gpios = <&gpiod 6 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpiob 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioh 0 GPIO_OUTPUT>; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpiok 2 GPIO_OUTPUT>; + }; + gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { + gpios = <&gpiof 2 GPIO_OUTPUT>; + }; + gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { + gpios = <&gpioe 5 GPIO_ODR_HIGH>; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 6 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_en_kb_bl: en_kb_bl { + gpios = <&gpioj 3 GPIO_OUTPUT>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_en_pp3300_s5: en_pp3300_s5 { + gpios = <&gpioc 5 GPIO_OUTPUT>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + }; + gpio_en_pp5000_pen_x: en_pp5000_pen_x { + gpios = <&gpiob 5 GPIO_OUTPUT>; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpiok 5 GPIO_OUTPUT>; + }; + gpio_en_slp_z: en_slp_z { + gpios = <&gpiok 3 GPIO_OUTPUT>; + }; + gpio_en_usb_a0_vbus: en_usb_a0_vbus { + gpios = <&gpiol 6 GPIO_OUTPUT>; + }; + gpio_en_usb_c0_cc1_vconn: en_usb_c0_cc1_vconn { + gpios = <&gpioh 4 GPIO_OUTPUT>; + }; + gpio_en_usb_c0_cc2_vconn: en_usb_c0_cc2_vconn { + gpios = <&gpioh 6 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_hdmi_sel: hdmi_sel { + gpios = <&gpioc 6 GPIO_OUTPUT>; + }; + gpio_imu_int_l: imu_int_l { + gpios = <&gpioj 0 GPIO_INPUT>; + }; + gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiof 3 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_pen_detect_odl: pen_detect_odl { + gpios = <&gpioj 1 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { + gpios = <&gpiod 3 GPIO_INPUT>; + }; + gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { + gpios = <&gpioe 3 GPIO_INPUT>; + }; + gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { + gpios = <&gpioe 1 GPIO_INPUT_PULL_UP>; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioh 3 GPIO_INPUT>; + }; + gpio_slp_s4_l: slp_s4_l { + gpios = <&gpioi 5 GPIO_INPUT>; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpiog 2 GPIO_INPUT>; + }; + gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { + gpios = <&gpiof 1 GPIO_OUTPUT>; + enum-name = "GPIO_USB2_ILIM_SEL"; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpiod 1 GPIO_ODR_HIGH>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { + gpios = <&gpiol 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB1_ILIM_SEL"; + }; + gpio_usb_c0_frs: usb_c0_frs { + gpios = <&gpioc 4 GPIO_OUTPUT>; + }; + gpio_usb_c0_int_odl: usb_c0_int_odl { + gpios = <&gpiok 0 GPIO_INPUT_PULL_UP>; + }; + gpio_vccin_aux_vid0: vccin_aux_vid0 { + gpios = <&gpiod 0 GPIO_INPUT>; + }; + gpio_vccin_aux_vid1: vccin_aux_vid1 { + gpios = <&gpiok 1 GPIO_INPUT>; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpioi 6 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpioi 7 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_eeprom: ec_i2c_eeprom { + i2c-port = <&i2c0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_ec_i2c_batt: ec_i2c_batt { + i2c-port = <&i2c1>; + enum-names = "I2C_PORT_BATTERY"; + }; + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c2>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { + i2c-port = <&i2c4>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + }; + i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { + i2c-port = <&i2c5>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + }; +}; + +&adc0 { + status = "okay"; +}; + +&i2c0 { + status = "okay"; +}; + +&i2c1 { + status = "okay"; +}; + +&i2c2 { + status = "okay"; +}; + +&i2c4 { + status = "okay"; +}; + +&i2c5 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/joxer/joxer_vif.xml b/zephyr/program/nissa/joxer/joxer_vif.xml new file mode 100644 index 0000000000..cfbce5623a --- /dev/null +++ b/zephyr/program/nissa/joxer/joxer_vif.xml @@ -0,0 +1,346 @@ + + + 3.20 + + USB-IF + VIF Editor + 3.3.0.0 + + Google + Joxer + 1 + 0 + Port Product + Reference Platform + + + + + + + + + 0 + Type-C® + + + DRP + DRP + + Both + + + + + + + + + Revision 3 + + + + + + + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 15000 mW + Assured + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + FR_Swap not supported + + + + Over-Current Response + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + 0 msec + 3000 mA + + + + + + 45000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 15000 mV + + + + Variable + 4750 mV + 15000 mV + 3000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505A + 0000 + + + + + + + 1 + Type-C® + + + DRP + DRP + + Both + + + + + + + + + Revision 3 + + + + + + + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 15000 mW + Assured + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + FR_Swap not supported + + + + Over-Current Response + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + 0 msec + 3000 mA + + + + + + 45000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 15000 mV + + + + Variable + 4750 mV + 15000 mV + 3000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505A + 0000 + + \ No newline at end of file diff --git a/zephyr/program/nissa/joxer/keyboard.dtsi b/zephyr/program/nissa/joxer/keyboard.dtsi new file mode 100644 index 0000000000..04a620767a --- /dev/null +++ b/zephyr/program/nissa/joxer/keyboard.dtsi @@ -0,0 +1,22 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + /* + * Use 324 Hz so that 32Khz clock source is used, + * which is not gated in power saving mode. + */ + pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm0 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm0_gpa0_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/joxer/motionsense.dtsi b/zephyr/program/nissa/joxer/motionsense.dtsi new file mode 100644 index 0000000000..537cc34451 --- /dev/null +++ b/zephyr/program/nissa/joxer/motionsense.dtsi @@ -0,0 +1,149 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * Interrupt bindings for sensor devices. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + (-1) 0 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + + bma422_data: bma422-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + * TODO(b/238139272): The first entries of the array must be + * accelerometers,then gyroscope. Fix this dependency in the DTS + * processing which makes the devicetree entries independent. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma422_data>; + i2c-spi-addr-flags = "BMA4_I2C_ADDR_SECONDARY"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi323_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi323_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/nissa/joxer/overlay.dtsi b/zephyr/program/nissa/joxer/overlay.dtsi new file mode 100644 index 0000000000..b587da8fb1 --- /dev/null +++ b/zephyr/program/nissa/joxer/overlay.dtsi @@ -0,0 +1,445 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_odl; + int-wp = &int_wp_l; + /* + * USB-C: interrupt input. + * I2C pins are on i2c_ec_i2c_sub_usb_c1 + */ + gpio-usb-c1-int-odl = &gpio_sb_1; + /* + * USB-A: VBUS enable output + * LTE: power enable output + */ + gpio-en-usb-a1-vbus = &gpio_sb_2; + /* + * HDMI: power enable output, HDMI enable output, + * and HPD input + */ + gpio-en-rails-odl = &gpio_sb_1; + gpio-hdmi-en-odl = &gpio_sb_4; + gpio-hpd-odl = &gpio_sb_3; + /* + * Enable S5 rails for LTE sub-board + */ + gpio-en-sub-s5-rails = &gpio_sb_2; + }; + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; + + batteries { + default_battery: cosmx { + compatible = "cosmx,gh02047xl", "battery-smart"; + }; + dynapack_atl_gh02047xl { + compatible = "dynapack,atl_gh02047xl", "battery-smart"; + }; + dynapack_cosmx_gh02047xl { + compatible = "dynapack,cosmx_gh02047xl", "battery-smart"; + }; + smp_coslight_gh02047xl { + compatible = "smp,coslight_gh02047xl", "battery-smart"; + }; + smp_highpower_gh02047xl { + compatible = "smp,highpower_gh02047xl", "battery-smart"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_power_button + &int_lid_open + >; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_vol_down: vol_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_vol_up: vol_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_imu_int_l>; + flags = ; + handler = "bmi3xx_interrupt"; + }; + int_usb_c0: usb_c0 { + irq-pin = <&gpio_usb_c0_int_odl>; + flags = ; + handler = "usb_c0_interrupt"; + }; + int_usb_c1: usb_c1 { + irq-pin = <&gpio_sb_1>; + flags = ; + handler = "usb_c1_interrupt"; + }; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = <&gpioc 3 0>, + <&gpiod 4 0>, + <&gpioh 2 0>, + <&gpiol 4 0>; + }; + + named-gpios { + /* + * EC doesn't take any specific action on CC/SBU disconnect due to + * fault, but this definition is useful for hardware testing. + */ + gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl { + gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>; + }; + + gpio_sb_1: sb_1 { + gpios = <&gpioe 6 0>; + no-auto-init; + }; + gpio_sb_2: sb_2 { + gpios = <&gpiof 0 0>; + no-auto-init; + }; + + gpio_sb_3: sb_3 { + gpios = <&gpioe 7 0>; + no-auto-init; + }; + gpio_sb_4: sb_4 { + gpios = <&gpioe 0 0>; + no-auto-init; + }; + gpio_fan_enable: fan-enable { + gpios = <&gpiol 4 GPIO_OUTPUT>; + no-auto-init; + }; + gpio_power_led_gate: power_led_gate { + gpios = <&gpiof 1 GPIO_OUTPUT_LOW>; + }; + gpio_led_1_odl: led_1_odl { + gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>; + }; + gpio_led_2_odl: led_2_odl { + gpios = <&gpioa 2 GPIO_OUTPUT_HIGH>; + }; + gpio_led_3_l: led_3_l { + gpios = <&gpiol 2 GPIO_OUTPUT_HIGH>; + }; + gpio_led_4_l: led_4_l { + gpios = <&gpiol 3 GPIO_OUTPUT_HIGH>; + }; + }; + + temp_memory: memory { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_1>; + }; + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_2>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_3>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + memory { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_memory>; + }; + charger { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_charger>; + }; + ambient { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_ambient>; + }; + }; + + usba { + compatible = "cros-ec,usba-port-enable-pins"; + /* + * sb_2 is only configured as GPIO when USB-A1 is present, + * but it's still safe to control when disabled. + * + * ILIM_SEL pins are referred to by legacy enum name, + * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on + * sub-boards that don't have USB-A so is safe to control + * regardless of system configuration. + */ + enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; + status = "okay"; + }; + + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + chg = <&chg_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + chg = <&chg_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; + }; + usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + tcpci_mux_1: tcpci-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; + }; + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm7 PWM_CHANNEL_7 PWM_KHZ(30) PWM_POLARITY_NORMAL>; + tach = <&tach1>; + rpm_min = <1500>; + rpm_start = <1500>; + rpm_max = <6500>; + enable_gpio = <&gpio_fan_enable>; + }; + }; +}; + +&gpio_acc_int_l { + gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; +}; +&gpio_imu_int_l { + gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; +}; +&gpio_vccin_aux_vid0 { + gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; +}; +&gpio_vccin_aux_vid1 { + gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; +}; + +&gpio_ec_prochot_odl { + gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; +}; + +&thermistor_3V3_51K1_47K_4050B { + status = "okay"; +}; + +&adc_ec_vsense_pp3300_s5 { + /* + * Voltage divider on input has 47k upper and 220k lower legs with 3 V + * full-scale reading on the ADC. Apply the largest possible multiplier + * (without overflowing int32) to get the best possible approximation + * of the actual ratio, but derate by a factor of two to ensure + * unexpectedly high values won't overflow. + */ + mul = <(715828 / 2)>; + div = <(589820 / 2)>; +}; + +&adc0 { + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch2_gpi2_default + &adc0_ch3_gpi3_default + &adc0_ch13_gpl0_default + &adc0_ch14_gpl1_default>; + pinctrl-names = "default"; +}; + +&pinctrl { + i2c2_clk_gpf6_default: i2c2_clk_gpf6_default { + gpio-voltage = "1v8"; + }; + i2c2_data_gpf7_default: i2c2_data_gpf7_default { + gpio-voltage = "1v8"; + }; +}; + + +&i2c0 { + label = "I2C_EEPROM"; + clock-frequency = ; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; + pinctrl-0 = <&i2c0_clk_gpb3_default + &i2c0_data_gpb4_default>; + pinctrl-names = "default"; +}; + +&i2c1 { + label = "I2C_BATTERY"; + clock-frequency = <50000>; + pinctrl-0 = <&i2c1_clk_gpc1_default + &i2c1_data_gpc2_default>; + pinctrl-names = "default"; +}; + +&i2c2 { + label = "I2C_SENSOR"; + clock-frequency = ; + pinctrl-0 = <&i2c2_clk_gpf6_default + &i2c2_data_gpf7_default>; + pinctrl-names = "default"; +}; + +&i2c4 { + label = "I2C_SUB_C1_TCPC"; + clock-frequency = ; + pinctrl-0 = <&i2c4_clk_gpe0_default + &i2c4_data_gpe7_default>; + pinctrl-names = "default"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port1: sm5803@32 { + compatible = "siliconmitus,sm5803"; + status = "okay"; + reg = <0x32>; + }; +}; + +&i2c_ec_i2c_sub_usb_c1 { + /* + * Dynamic speed setting is used for AP-controlled firmware update + * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order + * to use more efficient window programming, then sets it back when + * done. + */ + dynamic-speed; +}; + +&i2c5 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + pinctrl-0 = <&i2c5_clk_gpa4_default + &i2c5_data_gpa5_default>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port0: sm5803@32 { + compatible = "siliconmitus,sm5803"; + status = "okay"; + reg = <0x32>; + }; +}; + +/* pwm for fan */ +&pwm7 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm7_gpa7_default>; + pinctrl-names = "default"; +}; + +/* fan tachometer sensor */ +&tach1 { + status = "okay"; + channel = ; + pulses-per-round = <2>; + pinctrl-0 = <&tach1a_gpd7_default>; + pinctrl-names = "default"; +}; + +&usbpd0 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/joxer/power_signals.dtsi b/zephyr/program/nissa/joxer/power_signals.dtsi new file mode 100644 index 0000000000..8affae03b1 --- /dev/null +++ b/zephyr/program/nissa/joxer/power_signals.dtsi @@ -0,0 +1,223 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <10>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpiok 5 0>; + output; + }; + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpioc 5 0>; + output; + }; + pwr-pg-ec-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpioe 1 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioh 0 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpioe 4 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpioh 3 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpiog 2 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpiol 7 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpioe 5 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpioj 4 0>; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpiod 6 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpiof 2 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpiod 1 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + /* + * This is a board level signal, since this + * signal needs some special processing. + */ + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + pwr-adc-pp3300 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP3300_PROC"; + enum-name = "PWR_DSW_PWROK"; + trigger-high = <&vcmp0>; + trigger-low = <&vcmp1>; + }; + pwr-adc-pp1p05 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP1P05_PROC"; + enum-name = "PWR_PG_PP1P05"; + trigger-high = <&vcmp2>; + trigger-low = <&vcmp3>; + }; + +}; + +/* + * Because the power signals directly reference the GPIOs, + * the correspinding named-gpios need to have no-auto-init set. + */ +&gpio_ec_soc_dsw_pwrok { + no-auto-init; +}; +&gpio_ec_soc_pch_pwrok_od { + no-auto-init; +}; +&gpio_ec_soc_rsmrst_l { + no-auto-init; +}; +&gpio_ec_soc_sys_pwrok { + no-auto-init; +}; +&gpio_ec_soc_vccst_pwrgd_od { + no-auto-init; +}; +&gpio_en_pp3300_s5 { + no-auto-init; +}; +&gpio_en_pp5000_s5 { + no-auto-init; +}; +&gpio_imvp91_vrrdy_od { + no-auto-init; +}; +&gpio_rsmrst_pwrgd_l { + no-auto-init; +}; +&gpio_slp_s0_l { + no-auto-init; +}; +&gpio_slp_s3_l { + no-auto-init; +}; +&gpio_slp_sus_l { + no-auto-init; +}; +&gpio_sys_rst_odl { + no-auto-init; +}; +&vcmp0 { + status = "okay"; + scan-period = ; + comparison = ; + /* + * This is 90% of nominal voltage considering voltage + * divider on ADC input. + */ + threshold-mv = <2448>; + io-channels = <&adc0 0>; +}; +&vcmp1 { + status = "okay"; + scan-period = ; + comparison = ; + threshold-mv = <2448>; + io-channels = <&adc0 0>; +}; +&vcmp2 { + status = "okay"; + scan-period = ; + comparison = ; + /* Setting at 90% of nominal voltage */ + threshold-mv = <945>; + io-channels = <&adc0 14>; +}; +&vcmp3 { + status = "okay"; + scan-period = ; + comparison = ; + threshold-mv = <945>; + io-channels = <&adc0 14>; +}; diff --git a/zephyr/program/nissa/joxer/project.conf b/zephyr/program/nissa/joxer/project.conf new file mode 100644 index 0000000000..a0de72294c --- /dev/null +++ b/zephyr/program/nissa/joxer/project.conf @@ -0,0 +1,19 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_JOXER=y + +# Ensure recovery key combination (esc+refresh+power) is reliable: b/236580049 +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y + +# Sensor drivers +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# LED +CONFIG_PLATFORM_EC_LED_PWM=n +CONFIG_PLATFORM_EC_LED_COMMON=y diff --git a/zephyr/program/nissa/joxer/project.overlay b/zephyr/program/nissa/joxer/project.overlay new file mode 100644 index 0000000000..9ca681d979 --- /dev/null +++ b/zephyr/program/nissa/joxer/project.overlay @@ -0,0 +1,14 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../cbi.dtsi" + +#include "cbi.dtsi" +#include "generated.dtsi" +#include "keyboard.dtsi" +#include "motionsense.dtsi" +#include "overlay.dtsi" +#include "power_signals.dtsi" +#include "pwm_leds.dtsi" diff --git a/zephyr/program/nissa/joxer/pwm_leds.dtsi b/zephyr/program/nissa/joxer/pwm_leds.dtsi new file mode 100644 index 0000000000..aa4a76b271 --- /dev/null +++ b/zephyr/program/nissa/joxer/pwm_leds.dtsi @@ -0,0 +1,60 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm1 1 PWM_HZ(1296) PWM_POLARITY_INVERTED>, + <&pwm2 2 PWM_HZ(1296) PWM_POLARITY_INVERTED>, + <&pwm3 3 PWM_HZ(1296) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0>; + + /**/ + color-map-red = <100 0 0>; + color-map-green = < 0 100 0>; + color-map-blue = < 0 0 100>; + color-map-yellow = < 0 50 50>; + color-map-white = <100 100 100>; + color-map-amber = <100 15 0>; + + brightness-range = <100 100 100 0 0 0>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + }; +}; + +&pwm1 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm1_gpa1_default>; + pinctrl-names = "default"; +}; + +&pwm2 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm2_gpa2_default>; + pinctrl-names = "default"; +}; + +&pwm3 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm3_gpa3_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/joxer/src/charger.c b/zephyr/program/nissa/joxer/src/charger.c new file mode 100644 index 0000000000..b9454d8b80 --- /dev/null +++ b/zephyr/program/nissa/joxer/src/charger.c @@ -0,0 +1,56 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charger.h" +#include "console.h" +#include "driver/charger/sm5803.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = sm5803_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Joxer not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + if (board_get_usb_pd_port_count() == 2) + sm5803_hibernate(CHARGER_SECONDARY); + sm5803_hibernate(CHARGER_PRIMARY); + LOG_INF("Charger(s) hibernated"); + cflush(); +} diff --git a/zephyr/program/nissa/joxer/src/fan.c b/zephyr/program/nissa/joxer/src/fan.c new file mode 100644 index 0000000000..6d234b2fc3 --- /dev/null +++ b/zephyr/program/nissa/joxer/src/fan.c @@ -0,0 +1,43 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* + * Joxer fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + if (val != FW_FAN_PRESENT) { + /* Disable the fan */ + fan_set_count(0); + } else { + /* Configure the fan enable GPIO */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), + GPIO_OUTPUT); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/joxer/src/keyboard.c b/zephyr/program/nissa/joxer/src/keyboard.c new file mode 100644 index 0000000000..48db40f53f --- /dev/null +++ b/zephyr/program/nissa/joxer/src/keyboard.c @@ -0,0 +1,68 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "cros_cbi.h" +#include "ec_commands.h" +#include "gpio/gpio.h" +#include "hooks.h" +#include "keyboard_8042_sharedlib.h" +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +static const struct ec_response_keybd_config joxer_kb_legacy = { + .num_top_row_keys = 13, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_KBD_BKLIGHT_TOGGLE, /* T8 */ + TK_PLAY_PAUSE, /* T9 */ + TK_MICMUTE, /* T10 */ + TK_VOL_MUTE, /* T11 */ + TK_VOL_DOWN, /* T12 */ + TK_VOL_UP, /* T13 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &joxer_kb_legacy; +} + +/* + * Keyboard layout decided by FW config. + */ +static void kb_layout_init(void) +{ + int ret; + uint32_t val; + /* + * Retrieve the kb layout config. + */ + ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", + FW_KB_LAYOUT); + return; + } + /* + * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl + * to backslash(\|) key. + */ + if (val == FW_KB_LAYOUT_US2) + set_scancode_set2(4, 0, get_scancode_set2(2, 7)); +} +DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/joxer/src/led.c b/zephyr/program/nissa/joxer/src/led.c new file mode 100644 index 0000000000..d66e5b27a6 --- /dev/null +++ b/zephyr/program/nissa/joxer/src/led.c @@ -0,0 +1,181 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery LED control for nissa + */ +#include + +#include "charge_manager.h" +#include "common.h" +#include "compile_time_macros.h" +#include "ec_commands.h" +#include "gpio.h" +#include "led_common.h" +#include "led_onoff_states.h" +#include "pwm.h" +#include "util.h" + +#define BAT_LED_ON_LVL 0 +#define BAT_LED_OFF_LVL 1 + +#define PWR_LED_ON_LVL 1 +#define PWR_LED_OFF_LVL 0 + +#define LED_SIDESEL_MB_PORT 0 +#define LED_SIDESEL_DB_PORT 1 + +__override const int led_charge_lvl_1 = 5; +__override const int led_charge_lvl_2 = 95; + +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_WHITE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, + 0.5 * LED_ONE_SEC }, + { LED_OFF, 0.5 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_WHITE, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + }; + +__override const struct led_descriptor + led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { + [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, + [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, + 1 * LED_ONE_SEC }, + { LED_OFF, + 1 * LED_ONE_SEC } }, + [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, + }; + +const enum ec_led_id supported_led_ids[] = { + EC_LED_ID_BATTERY_LED, + EC_LED_ID_POWER_LED, +}; + +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +__override void led_set_color_battery(enum ec_led_colors color) +{ + int port; + + /* There are four battery leds, LED1/LED2 are on MB side and + * LED3/LED4 are on DB side. All leds are OFF by default. + */ + int led1, led2, led3, led4; + + led1 = led2 = led3 = led4 = BAT_LED_OFF_LVL; + + /* Check which port is the charging port, + * and turn on the corresponding led. + */ + if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) { + port = charge_manager_get_active_charge_port(); + switch (port) { + case LED_SIDESEL_MB_PORT: + switch (color) { + case EC_LED_COLOR_AMBER: + led1 = BAT_LED_ON_LVL; + break; + case EC_LED_COLOR_WHITE: + led2 = BAT_LED_ON_LVL; + break; + default: /* LED_OFF and other unsupported colors */ + break; + } + break; + case LED_SIDESEL_DB_PORT: + switch (color) { + case EC_LED_COLOR_AMBER: + led3 = BAT_LED_ON_LVL; + break; + case EC_LED_COLOR_WHITE: + led4 = BAT_LED_ON_LVL; + break; + default: /* LED_OFF and other unsupported colors */ + break; + } + break; + default: /* Unknown charging port */ + break; + } + } else { + switch (color) { + case EC_LED_COLOR_AMBER: + led1 = BAT_LED_ON_LVL; + led3 = BAT_LED_ON_LVL; + break; + case EC_LED_COLOR_WHITE: + led2 = BAT_LED_ON_LVL; + led4 = BAT_LED_ON_LVL; + break; + default: /* LED_OFF and other unsupported colors */ + break; + } + } + + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), led1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), led2); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_3_l), led3); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_4_l), led4); +} + +__override void led_set_color_power(enum ec_led_colors color) +{ + if (color == EC_LED_COLOR_WHITE) + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_gate), + PWR_LED_ON_LVL); + else + /* LED_OFF and unsupported colors */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_gate), + PWR_LED_OFF_LVL); +} + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + if (led_id == EC_LED_ID_BATTERY_LED) { + brightness_range[EC_LED_COLOR_AMBER] = 1; + brightness_range[EC_LED_COLOR_WHITE] = 1; + } else if (led_id == EC_LED_ID_POWER_LED) { + brightness_range[EC_LED_COLOR_WHITE] = 1; + } +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + if (led_id == EC_LED_ID_BATTERY_LED) { + led_auto_control(led_id, 0); + if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(EC_LED_COLOR_AMBER); + else if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_battery(EC_LED_COLOR_WHITE); + else if (brightness[LED_OFF] != 0) + led_set_color_battery(LED_OFF); + else { + led_auto_control(led_id, 1); + led_set_color_battery(LED_OFF); + } + } else if (led_id == EC_LED_ID_POWER_LED) { + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_power(EC_LED_COLOR_WHITE); + else + led_set_color_power(LED_OFF); + } + + return EC_SUCCESS; +} diff --git a/zephyr/program/nissa/joxer/src/usbc.c b/zephyr/program/nissa/joxer/src/usbc.c new file mode 100644 index 0000000000..5fec9ab544 --- /dev/null +++ b/zephyr/program/nissa/joxer/src/usbc.c @@ -0,0 +1,392 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/sm5803.h" +#include "driver/tcpm/it83xx_pd.h" +#include "driver/tcpm/ps8xxx_public.h" +#include "driver/tcpm/tcpci.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_EMBEDDED, + /* TCPC is embedded within EC so no i2c config needed */ + .drv = &it8xxx2_tcpm_drv, + /* Alert is active-low, push-pull */ + .flags = 0, + }, + { + /* + * Sub-board: optional PS8745 TCPC+redriver. Behaves the same + * as PS8815. + */ + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1_TCPC, + .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, + }, + .drv = &ps8xxx_tcpm_drv, + /* PS8745 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0, + }, +}; + +/* Vconn control for integrated ITE TCPC */ +void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) +{ + /* Vconn control is only for port 0 */ + if (port) + return; + + if (cc_pin == USBPD_CC_PIN_1) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn), + !!enabled); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn), + !!enabled); +} + +__override bool pd_check_vbus_level(int port, enum vbus_level level) +{ + return sm5803_check_vbus_level(port, level); +} + +/* + * Putting chargers into LPM when in suspend reduces power draw by about 8mW + * per charger, but also seems critical to correct operation in source mode: + * if chargers are not in LPM when a sink is first connected, VBUS sourcing + * works even if the partner is later removed (causing LPM entry) and + * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS + * consistently causes the charger to report (apparently spurious) overcurrent + * failures. + * + * In short, this is important to making things work correctly but we don't + * understand why. + */ +static void board_chargers_suspend(struct ap_power_ev_callback *const cb, + const struct ap_power_ev_data data) +{ + void (*fn)(int chgnum); + + switch (data.event) { + case AP_POWER_SUSPEND: + fn = sm5803_enable_low_power_mode; + break; + case AP_POWER_RESUME: + fn = sm5803_disable_low_power_mode; + break; + default: + LOG_WRN("%s: power event %d is not recognized", __func__, + data.event); + return; + } + + fn(CHARGER_PRIMARY); + if (board_get_charger_chip_count() > 1) + fn(CHARGER_SECONDARY); +} + +static int board_chargers_suspend_init(const struct device *unused) +{ + static struct ap_power_ev_callback cb = { + .handler = board_chargers_suspend, + .events = AP_POWER_SUSPEND | AP_POWER_RESUME, + }; + ap_power_ev_add_callback(&cb); + return 0; +} +SYS_INIT(board_chargers_suspend_init, APPLICATION, 0); + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count()); + int i; + int old_port; + int rv; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + LOG_INF("Charge update: p%d -> p%d", old_port, port); + + /* Check if port is sourcing VBUS. */ + if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) { + LOG_WRN("Skip enable p%d: already sourcing", port); + return EC_ERROR_INVAL; + } + + /* Disable sinking on all ports except the desired one */ + for (i = 0; i < board_get_usb_pd_port_count(); i++) { + if (i == port) + continue; + + if (sm5803_vbus_sink_enable(i, 0)) + /* + * Do not early-return because this can fail during + * power-on which would put us into a loop. + */ + LOG_WRN("p%d: sink path disable failed.", i); + } + + /* Don't enable anything (stop here) if no ports were requested */ + if ((port == CHARGE_PORT_NONE) || (old_port == port)) + return EC_SUCCESS; + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + rv = sm5803_vbus_sink_enable(port, 1); + if (rv) + LOG_WRN("p%d: sink path enable failed: code %d", port, rv); + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return rv; +} + +uint16_t tcpc_get_alert_status(void) +{ + /* + * TCPC 0 is embedded in the EC and processes interrupts in the chip + * code (it83xx/intc.c). This function only needs to poll port C1 if + * present. + */ + uint16_t status = 0; + int regval; + + /* Is the C1 port present and its IRQ line asserted? */ + if (board_get_usb_pd_port_count() == 2 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + /* + * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if + * it asserted the IRQ. + */ + if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { + if (regval) + status = PD_STATUS_TCPC_ALERT_1; + } + } + + return status; +} + +void pd_power_supply_reset(int port) +{ + int prev_en; + + if (port < 0 || port >= board_get_usb_pd_port_count()) + return; + + prev_en = charger_is_sourcing_otg_power(port); + + /* Disable Vbus */ + charger_enable_otg_power(port, 0); + + /* Discharge Vbus if previously enabled */ + if (prev_en) + sm5803_set_vbus_disch(port, 1); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + enum ec_error_list rv; + + if (port < 0 || port > board_get_usb_pd_port_count()) { + LOG_WRN("Port C%d does not exist, cannot enable VBUS", port); + return EC_ERROR_INVAL; + } + + /* Disable sinking */ + rv = sm5803_vbus_sink_enable(port, 0); + if (rv) { + LOG_WRN("C%d failed to disable sinking: %d", port, rv); + return rv; + } + + /* Disable Vbus discharge */ + rv = sm5803_set_vbus_disch(port, 0); + if (rv) { + LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv); + return rv; + } + + /* Provide Vbus */ + rv = charger_enable_otg_power(port, 1); + if (rv) { + LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv); + return rv; + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv; + const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500; + + rv = charger_set_otg_current_voltage(port, current, 5000); + if (rv != EC_SUCCESS) { + LOG_WRN("Failed to set source ilimit on port %d to %d: %d", + port, current, rv); + } +} + +void board_reset_pd_mcu(void) +{ + /* + * Do nothing. The integrated TCPC for C0 lacks a dedicated reset + * command, and C1 (if present) doesn't have a reset pin connected + * to the EC. + */ +} + +#define INT_RECHECK_US 5000 + +/* C0 interrupt line shared by BC 1.2 and charger */ + +static void check_c0_line(void); +DECLARE_DEFERRED(check_c0_line); + +static void notify_c0_chips(void) +{ + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + sm5803_interrupt(0); +} + +static void check_c0_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + notify_c0_chips(); + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); + } +} + +void usb_c0_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c0_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c0_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); +} + +/* C1 interrupt line shared by BC 1.2, TCPC, and charger */ +static void check_c1_line(void); +DECLARE_DEFERRED(check_c1_line); + +static void notify_c1_chips(void) +{ + schedule_deferred_pd_interrupt(1); + usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); + /* Charger is handled in board_process_pd_alert */ +} + +static void check_c1_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + notify_c1_chips(); + hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); + } +} + +void usb_c1_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c1_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c1_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); +} + +/* + * Check state of IRQ lines at startup, ensuring an IRQ that happened before + * the EC started up won't get lost (leaving the IRQ line asserted and blocking + * any further interrupts on the port). + * + * Although the PD task will check for pending TCPC interrupts on startup, + * the charger sharing the IRQ will not be polled automatically. + */ +void board_handle_initial_typec_irq(void) +{ + check_c0_line(); + check_c1_line(); +} +/* + * This must run after sub-board detection (which happens in EC main()), + * but isn't depended on by anything else either. + */ +DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST); + +/* + * Handle charger interrupts in the PD task. Not doing so can lead to a priority + * inversion where we fail to respond to TCPC alerts quickly enough because we + * don't get another edge on a shared IRQ until the charger interrupt is cleared + * (or the IRQ is polled again), which happens in the low-priority charger task: + * the high-priority type-C handler is thus blocked on the lower-priority + * charger. + * + * To avoid that, we run charger interrupts at the same priority. + */ +void board_process_pd_alert(int port) +{ + /* + * Port 0 doesn't use an external TCPC, so its interrupts don't need + * this special handling. + */ + if (port == 1 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + sm5803_handle_interrupt(port); + } +} + +int pd_snk_is_vbus_provided(int port) +{ + int chg_det = 0; + + sm5803_get_chg_det(port, &chg_det); + + return chg_det; +} diff --git a/zephyr/program/nissa/nereid/generated.dtsi b/zephyr/program/nissa/nereid/generated.dtsi new file mode 100644 index 0000000000..bca58c478e --- /dev/null +++ b/zephyr/program/nissa/nereid/generated.dtsi @@ -0,0 +1,260 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This file is auto-generated - do not edit! + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { + enum-name = "ADC_PP1050_PROC"; + io-channels = <&adc0 14>; + }; + adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { + enum-name = "ADC_PP3300_S5"; + io-channels = <&adc0 0>; + }; + adc_temp_sensor_1: temp_sensor_1 { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 2>; + }; + adc_temp_sensor_2: temp_sensor_2 { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 3>; + }; + adc_temp_sensor_3: temp_sensor_3 { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 13>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_acc_int_l: acc_int_l { + gpios = <&gpioc 0 GPIO_INPUT>; + }; + gpio_all_sys_pwrgd: all_sys_pwrgd { + gpios = <&gpiob 7 GPIO_INPUT>; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioh 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpiog 1 GPIO_INPUT>; + }; + gpio_ec_battery_pres_odl: ec_battery_pres_odl { + gpios = <&gpioi 4 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioj 5 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { + gpios = <&gpiok 4 GPIO_ODR_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_entering_rw: ec_entering_rw { + gpios = <&gpioc 7 GPIO_OUTPUT>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpioh 1 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_odl { + gpios = <&gpiob 2 GPIO_ODR_LOW>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpioi 1 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { + gpios = <&gpiol 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { + gpios = <&gpiok 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpiod 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { + gpios = <&gpiod 6 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpiob 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioh 0 GPIO_OUTPUT>; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpiok 2 GPIO_OUTPUT>; + }; + gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { + gpios = <&gpiof 2 GPIO_OUTPUT>; + }; + gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { + gpios = <&gpioe 5 GPIO_ODR_HIGH>; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 6 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_en_kb_bl: en_kb_bl { + gpios = <&gpioj 3 GPIO_OUTPUT>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_en_pp3300_s5: en_pp3300_s5 { + gpios = <&gpioc 5 GPIO_OUTPUT>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + }; + gpio_en_pp5000_pen_x: en_pp5000_pen_x { + gpios = <&gpiob 5 GPIO_OUTPUT>; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpiok 5 GPIO_OUTPUT>; + }; + gpio_en_slp_z: en_slp_z { + gpios = <&gpiok 3 GPIO_OUTPUT>; + }; + gpio_en_usb_a0_vbus: en_usb_a0_vbus { + gpios = <&gpiol 6 GPIO_OUTPUT>; + }; + gpio_en_usb_c0_cc1_vconn: en_usb_c0_cc1_vconn { + gpios = <&gpioh 4 GPIO_OUTPUT>; + }; + gpio_en_usb_c0_cc2_vconn: en_usb_c0_cc2_vconn { + gpios = <&gpioh 6 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_hdmi_sel: hdmi_sel { + gpios = <&gpioc 6 GPIO_OUTPUT>; + }; + gpio_imu_int_l: imu_int_l { + gpios = <&gpioj 0 GPIO_INPUT>; + }; + gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiof 3 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_pen_detect_odl: pen_detect_odl { + gpios = <&gpioj 1 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { + gpios = <&gpiod 3 GPIO_INPUT>; + }; + gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { + gpios = <&gpioe 3 GPIO_INPUT>; + }; + gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { + gpios = <&gpioe 1 GPIO_INPUT_PULL_UP>; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioh 3 GPIO_INPUT>; + }; + gpio_slp_s4_l: slp_s4_l { + gpios = <&gpioi 5 GPIO_INPUT>; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpiog 2 GPIO_INPUT>; + }; + gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { + gpios = <&gpiof 1 GPIO_OUTPUT>; + enum-name = "GPIO_USB2_ILIM_SEL"; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpiod 1 GPIO_ODR_HIGH>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioa 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { + gpios = <&gpiol 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB1_ILIM_SEL"; + }; + gpio_usb_c0_frs: usb_c0_frs { + gpios = <&gpioc 4 GPIO_OUTPUT>; + }; + gpio_usb_c0_int_odl: usb_c0_int_odl { + gpios = <&gpiok 0 GPIO_INPUT_PULL_UP>; + }; + gpio_vccin_aux_vid0: vccin_aux_vid0 { + gpios = <&gpiod 0 GPIO_INPUT>; + }; + gpio_vccin_aux_vid1: vccin_aux_vid1 { + gpios = <&gpiok 1 GPIO_INPUT>; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpioi 6 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpioi 7 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_eeprom: ec_i2c_eeprom { + i2c-port = <&i2c0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_ec_i2c_batt: ec_i2c_batt { + i2c-port = <&i2c1>; + enum-names = "I2C_PORT_BATTERY"; + }; + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c2>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { + i2c-port = <&i2c4>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + }; + i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { + i2c-port = <&i2c5>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + }; +}; + +&adc0 { + status = "okay"; +}; + +&i2c0 { + status = "okay"; +}; + +&i2c1 { + status = "okay"; +}; + +&i2c2 { + status = "okay"; +}; + +&i2c4 { + status = "okay"; +}; + +&i2c5 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/nereid/keyboard.dtsi b/zephyr/program/nissa/nereid/keyboard.dtsi new file mode 100644 index 0000000000..04a620767a --- /dev/null +++ b/zephyr/program/nissa/nereid/keyboard.dtsi @@ -0,0 +1,22 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + /* + * Use 324 Hz so that 32Khz clock source is used, + * which is not gated in power saving mode. + */ + pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm0 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm0_gpa0_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/nereid/motionsense.dtsi b/zephyr/program/nissa/nereid/motionsense.dtsi new file mode 100644 index 0000000000..a65bb48fbd --- /dev/null +++ b/zephyr/program/nissa/nereid/motionsense.dtsi @@ -0,0 +1,147 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * Interrupt bindings for sensor devices. + */ + bmi3xx-int = &base_accel; + bma4xx-int = &lid_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + (-1) 0 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + + bma422_data: bma422-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + * TODO(b/238139272): The first entries of the array must be + * accelerometers,then gyroscope. Fix this dependency in the DTS + * processing which makes the devicetree entries independent. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma422_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi323_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi323_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/program/nissa/nereid/nereid_vif.xml b/zephyr/program/nissa/nereid/nereid_vif.xml new file mode 100644 index 0000000000..91c8dbe68b --- /dev/null +++ b/zephyr/program/nissa/nereid/nereid_vif.xml @@ -0,0 +1,350 @@ + + + 3.19 + + USB-IF + VIF Editor + 3.2.4.0 + + Google + Nereid + 1 + 0 + Port Product + Reference Platform + + + + + + + + + 0 + Type-C® + + + DRP + DRP + + Charging Port + + + + + + + + + Revision 3 + + + + + + + 18D1 + 505A + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 15000 mW + Assured + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + FR_Swap not supported + + + + Over-Current Response + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + 0 msec + 3000 mA + + + + + + 45000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 15000 mV + + + + Variable + 4750 mV + 15000 mV + 3000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505A + 0000 + + + + + + + 1 + Type-C® + + + DRP + DRP + + Charging Port + + + + + + + + + Revision 3 + + + + + + + 18D1 + 505A + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 15000 mW + Assured + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + FR_Swap not supported + + + + Over-Current Response + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + 0 msec + 3000 mA + + + + + + 45000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 15000 mV + + + + Variable + 4750 mV + 15000 mV + 3000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505A + 0000 + + \ No newline at end of file diff --git a/zephyr/program/nissa/nereid/overlay.dtsi b/zephyr/program/nissa/nereid/overlay.dtsi new file mode 100644 index 0000000000..a44a3e01bd --- /dev/null +++ b/zephyr/program/nissa/nereid/overlay.dtsi @@ -0,0 +1,400 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_odl; + int-wp = &int_wp_l; + /* + * USB-C: interrupt input. + * I2C pins are on i2c_ec_i2c_sub_usb_c1 + */ + gpio-usb-c1-int-odl = &gpio_sb_1; + /* + * USB-A: VBUS enable output + * LTE: power enable output + */ + gpio-en-usb-a1-vbus = &gpio_sb_2; + /* + * HDMI: power enable output, HDMI enable output, + * and HPD input + */ + gpio-en-rails-odl = &gpio_sb_1; + gpio-hdmi-en-odl = &gpio_sb_4; + gpio-hpd-odl = &gpio_sb_3; + /* + * Enable S5 rails for LTE sub-board + */ + gpio-en-sub-s5-rails = &gpio_sb_2; + }; + + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; + + batteries { + default_battery: smp { + compatible = "smp,l20m3pg0", "battery-smart"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_power_button + &int_lid_open + >; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_vol_down: vol_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_vol_up: vol_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_imu_int_l>; + flags = ; + handler = "bmi3xx_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&gpio_acc_int_l>; + flags = ; + handler = "bma4xx_interrupt"; + }; + int_usb_c0: usb_c0 { + irq-pin = <&gpio_usb_c0_int_odl>; + flags = ; + handler = "usb_c0_interrupt"; + }; + int_usb_c1: usb_c1 { + irq-pin = <&gpio_sb_1>; + flags = ; + handler = "usb_c1_interrupt"; + }; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = <&gpioc 3 0>, + <&gpiod 4 0>, + <&gpiod 7 0>, + <&gpioh 2 0>, + <&gpioj 7 0>, + <&gpiol 4 0>; + }; + + named-gpios { + /* + * EC doesn't take any specific action on CC/SBU disconnect due to + * fault, but this definition is useful for hardware testing. + */ + gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl { + gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>; + }; + + gpio_sb_1: sb_1 { + gpios = <&gpioe 6 0>; + no-auto-init; + }; + gpio_sb_2: sb_2 { + gpios = <&gpiof 0 0>; + no-auto-init; + }; + + gpio_sb_3: sb_3 { + gpios = <&gpioe 7 0>; + no-auto-init; + }; + gpio_sb_4: sb_4 { + gpios = <&gpioe 0 0>; + no-auto-init; + }; + }; + + temp_memory: memory { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_1>; + }; + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_2>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_3>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + memory { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_memory>; + }; + charger { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_charger>; + }; + ambient { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_ambient>; + }; + }; + + usba { + compatible = "cros-ec,usba-port-enable-pins"; + /* + * sb_2 is only configured as GPIO when USB-A1 is present, + * but it's still safe to control when disabled. + * + * ILIM_SEL pins are referred to by legacy enum name, + * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on + * sub-boards that don't have USB-A so is safe to control + * regardless of system configuration. + */ + enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; + status = "okay"; + }; + + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + chg = <&chg_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + chg = <&chg_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; + }; + usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + tcpci_mux_1: tcpci-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; + }; +}; + +&gpio_acc_int_l { + gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; +}; +&gpio_imu_int_l { + gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; +}; +&gpio_vccin_aux_vid0 { + gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; +}; +&gpio_vccin_aux_vid1 { + gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; +}; + +&gpio_ec_prochot_odl { + gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; +}; + +&thermistor_3V3_51K1_47K_4050B { + status = "okay"; +}; + +&adc_ec_vsense_pp3300_s5 { + /* + * Voltage divider on input has 47k upper and 220k lower legs with 3 V + * full-scale reading on the ADC. Apply the largest possible multiplier + * (without overflowing int32) to get the best possible approximation + * of the actual ratio, but derate by a factor of two to ensure + * unexpectedly high values won't overflow. + */ + mul = <(715828 / 2)>; + div = <(589820 / 2)>; +}; + +&adc0 { + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch2_gpi2_default + &adc0_ch3_gpi3_default + &adc0_ch13_gpl0_default + &adc0_ch14_gpl1_default>; + pinctrl-names = "default"; +}; + +&pinctrl { + i2c4_clk_gpe0_sleep: i2c4_clk_gpe0_sleep { + pinmuxs = <&pinctrle 0 IT8XXX2_ALT_DEFAULT>; + }; + i2c4_data_gpe7_sleep: i2c4_data_gpe7_sleep { + pinmuxs = <&pinctrle 7 IT8XXX2_ALT_DEFAULT>; + }; + i2c2_clk_gpf6_default: i2c2_clk_gpf6_default { + gpio-voltage = "1v8"; + }; + i2c2_data_gpf7_default: i2c2_data_gpf7_default { + gpio-voltage = "1v8"; + }; +}; + +&i2c0 { + label = "I2C_EEPROM"; + clock-frequency = ; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; + pinctrl-0 = <&i2c0_clk_gpb3_default + &i2c0_data_gpb4_default>; + pinctrl-names = "default"; +}; + +&i2c1 { + label = "I2C_BATTERY"; + clock-frequency = <50000>; + pinctrl-0 = <&i2c1_clk_gpc1_default + &i2c1_data_gpc2_default>; + pinctrl-names = "default"; +}; + +&i2c2 { + label = "I2C_SENSOR"; + clock-frequency = ; + pinctrl-0 = <&i2c2_clk_gpf6_default + &i2c2_data_gpf7_default>; + pinctrl-names = "default"; +}; + +&i2c4 { + label = "I2C_SUB_C1_TCPC"; + clock-frequency = ; + pinctrl-0 = <&i2c4_clk_gpe0_default + &i2c4_data_gpe7_default>; + pinctrl-1 = <&i2c4_clk_gpe0_sleep + &i2c4_data_gpe7_sleep>; + pinctrl-names = "default", "sleep"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port1: sm5803@32 { + compatible = "siliconmitus,sm5803"; + status = "okay"; + reg = <0x32>; + }; +}; + +&i2c_ec_i2c_sub_usb_c1 { + /* + * Dynamic speed setting is used for AP-controlled firmware update + * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order + * to use more efficient window programming, then sets it back when + * done. + */ + dynamic-speed; +}; + +&i2c5 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + pinctrl-0 = <&i2c5_clk_gpa4_default + &i2c5_data_gpa5_default>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port0: sm5803@32 { + compatible = "siliconmitus,sm5803"; + status = "okay"; + reg = <0x32>; + }; +}; + +&usbpd0 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/nereid/power_signals.dtsi b/zephyr/program/nissa/nereid/power_signals.dtsi new file mode 100644 index 0000000000..8affae03b1 --- /dev/null +++ b/zephyr/program/nissa/nereid/power_signals.dtsi @@ -0,0 +1,223 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <10>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpiok 5 0>; + output; + }; + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpioc 5 0>; + output; + }; + pwr-pg-ec-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpioe 1 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioh 0 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpioe 4 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpioh 3 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpiog 2 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpiol 7 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpioe 5 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpioj 4 0>; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpiod 6 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpiof 2 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpiod 1 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + /* + * This is a board level signal, since this + * signal needs some special processing. + */ + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + pwr-adc-pp3300 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP3300_PROC"; + enum-name = "PWR_DSW_PWROK"; + trigger-high = <&vcmp0>; + trigger-low = <&vcmp1>; + }; + pwr-adc-pp1p05 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP1P05_PROC"; + enum-name = "PWR_PG_PP1P05"; + trigger-high = <&vcmp2>; + trigger-low = <&vcmp3>; + }; + +}; + +/* + * Because the power signals directly reference the GPIOs, + * the correspinding named-gpios need to have no-auto-init set. + */ +&gpio_ec_soc_dsw_pwrok { + no-auto-init; +}; +&gpio_ec_soc_pch_pwrok_od { + no-auto-init; +}; +&gpio_ec_soc_rsmrst_l { + no-auto-init; +}; +&gpio_ec_soc_sys_pwrok { + no-auto-init; +}; +&gpio_ec_soc_vccst_pwrgd_od { + no-auto-init; +}; +&gpio_en_pp3300_s5 { + no-auto-init; +}; +&gpio_en_pp5000_s5 { + no-auto-init; +}; +&gpio_imvp91_vrrdy_od { + no-auto-init; +}; +&gpio_rsmrst_pwrgd_l { + no-auto-init; +}; +&gpio_slp_s0_l { + no-auto-init; +}; +&gpio_slp_s3_l { + no-auto-init; +}; +&gpio_slp_sus_l { + no-auto-init; +}; +&gpio_sys_rst_odl { + no-auto-init; +}; +&vcmp0 { + status = "okay"; + scan-period = ; + comparison = ; + /* + * This is 90% of nominal voltage considering voltage + * divider on ADC input. + */ + threshold-mv = <2448>; + io-channels = <&adc0 0>; +}; +&vcmp1 { + status = "okay"; + scan-period = ; + comparison = ; + threshold-mv = <2448>; + io-channels = <&adc0 0>; +}; +&vcmp2 { + status = "okay"; + scan-period = ; + comparison = ; + /* Setting at 90% of nominal voltage */ + threshold-mv = <945>; + io-channels = <&adc0 14>; +}; +&vcmp3 { + status = "okay"; + scan-period = ; + comparison = ; + threshold-mv = <945>; + io-channels = <&adc0 14>; +}; diff --git a/zephyr/program/nissa/nereid/project.conf b/zephyr/program/nissa/nereid/project.conf new file mode 100644 index 0000000000..75a5faba5d --- /dev/null +++ b/zephyr/program/nissa/nereid/project.conf @@ -0,0 +1,17 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_NEREID=y + +# Ensure recovery key combination (esc+refresh+power) is reliable: b/236580049 +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y + +# Sensor drivers +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# No fan supported, and tach is default-enabled +CONFIG_TACH_IT8XXX2=n diff --git a/zephyr/program/nissa/nereid/project.overlay b/zephyr/program/nissa/nereid/project.overlay new file mode 100644 index 0000000000..0aceac1c47 --- /dev/null +++ b/zephyr/program/nissa/nereid/project.overlay @@ -0,0 +1,13 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../cbi.dtsi" + +#include "generated.dtsi" +#include "keyboard.dtsi" +#include "motionsense.dtsi" +#include "overlay.dtsi" +#include "power_signals.dtsi" +#include "pwm_leds.dtsi" diff --git a/zephyr/program/nissa/nereid/pwm_leds.dtsi b/zephyr/program/nissa/nereid/pwm_leds.dtsi new file mode 100644 index 0000000000..aa4a76b271 --- /dev/null +++ b/zephyr/program/nissa/nereid/pwm_leds.dtsi @@ -0,0 +1,60 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm1 1 PWM_HZ(1296) PWM_POLARITY_INVERTED>, + <&pwm2 2 PWM_HZ(1296) PWM_POLARITY_INVERTED>, + <&pwm3 3 PWM_HZ(1296) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0>; + + /**/ + color-map-red = <100 0 0>; + color-map-green = < 0 100 0>; + color-map-blue = < 0 0 100>; + color-map-yellow = < 0 50 50>; + color-map-white = <100 100 100>; + color-map-amber = <100 15 0>; + + brightness-range = <100 100 100 0 0 0>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + }; +}; + +&pwm1 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm1_gpa1_default>; + pinctrl-names = "default"; +}; + +&pwm2 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm2_gpa2_default>; + pinctrl-names = "default"; +}; + +&pwm3 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm3_gpa3_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/nereid/src/charger.c b/zephyr/program/nissa/nereid/src/charger.c new file mode 100644 index 0000000000..181e9a61fd --- /dev/null +++ b/zephyr/program/nissa/nereid/src/charger.c @@ -0,0 +1,56 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charger.h" +#include "console.h" +#include "driver/charger/sm5803.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = sm5803_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Nereid does not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + if (board_get_usb_pd_port_count() == 2) + sm5803_hibernate(CHARGER_SECONDARY); + sm5803_hibernate(CHARGER_PRIMARY); + LOG_INF("Charger(s) hibernated"); + cflush(); +} diff --git a/zephyr/program/nissa/nereid/src/hdmi.c b/zephyr/program/nissa/nereid/src/hdmi.c new file mode 100644 index 0000000000..7e5708c6eb --- /dev/null +++ b/zephyr/program/nissa/nereid/src/hdmi.c @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include "nissa_hdmi.h" + +__override void nissa_configure_hdmi_power_gpios(void) +{ + /* + * Nereid versions before 2 need hdmi-en-odl to be + * pulled down to enable VCC on the HDMI port, but later + * versions (and other boards) disconnect this so + * the port's VCC directly follows en-rails-odl. Only + * configure the GPIO if needed, to save power. + */ + uint32_t board_version = 0; + + /* CBI errors ignored, will configure the pin */ + cbi_get_board_version(&board_version); + if (board_version < 2) { + nissa_configure_hdmi_vcc(); + } + + /* Still always need core rails controlled */ + nissa_configure_hdmi_rails(); +} diff --git a/zephyr/program/nissa/nereid/src/keyboard.c b/zephyr/program/nissa/nereid/src/keyboard.c new file mode 100644 index 0000000000..b69bb4da33 --- /dev/null +++ b/zephyr/program/nissa/nereid/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config nereid_kb_legacy = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_FORWARD, /* T2 */ + TK_REFRESH, /* T3 */ + TK_FULLSCREEN, /* T4 */ + TK_OVERVIEW, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &nereid_kb_legacy; +} diff --git a/zephyr/program/nissa/nereid/src/usbc.c b/zephyr/program/nissa/nereid/src/usbc.c new file mode 100644 index 0000000000..48f7cfd9cb --- /dev/null +++ b/zephyr/program/nissa/nereid/src/usbc.c @@ -0,0 +1,393 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/sm5803.h" +#include "driver/tcpm/it83xx_pd.h" +#include "driver/tcpm/ps8xxx_public.h" +#include "driver/tcpm/tcpci.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_EMBEDDED, + /* TCPC is embedded within EC so no i2c config needed */ + .drv = &it8xxx2_tcpm_drv, + /* Alert is active-low, push-pull */ + .flags = 0, + }, + { + /* + * Sub-board: optional PS8745 TCPC+redriver. Behaves the same + * as PS8815. + */ + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1_TCPC, + .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, + }, + .drv = &ps8xxx_tcpm_drv, + /* PS8745 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0, + }, +}; + +/* Vconn control for integrated ITE TCPC */ +void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) +{ + /* Vconn control is only for port 0 */ + if (port) + return; + + if (cc_pin == USBPD_CC_PIN_1) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn), + !!enabled); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn), + !!enabled); +} + +__override bool pd_check_vbus_level(int port, enum vbus_level level) +{ + return sm5803_check_vbus_level(port, level); +} + +/* + * Putting chargers into LPM when in suspend reduces power draw by about 8mW + * per charger, but also seems critical to correct operation in source mode: + * if chargers are not in LPM when a sink is first connected, VBUS sourcing + * works even if the partner is later removed (causing LPM entry) and + * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS + * consistently causes the charger to report (apparently spurious) overcurrent + * failures. + * + * In short, this is important to making things work correctly but we don't + * understand why. + */ +static void board_chargers_suspend(struct ap_power_ev_callback *const cb, + const struct ap_power_ev_data data) +{ + void (*fn)(int chgnum); + + switch (data.event) { + case AP_POWER_SUSPEND: + fn = sm5803_enable_low_power_mode; + break; + case AP_POWER_RESUME: + fn = sm5803_disable_low_power_mode; + break; + default: + LOG_WRN("%s: power event %d is not recognized", __func__, + data.event); + return; + } + + fn(CHARGER_PRIMARY); + if (board_get_charger_chip_count() > 1) + fn(CHARGER_SECONDARY); +} + +static int board_chargers_suspend_init(const struct device *unused) +{ + static struct ap_power_ev_callback cb = { + .handler = board_chargers_suspend, + .events = AP_POWER_SUSPEND | AP_POWER_RESUME, + }; + ap_power_ev_add_callback(&cb); + return 0; +} +SYS_INIT(board_chargers_suspend_init, APPLICATION, 0); + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count()); + int i; + int old_port; + int rv; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + LOG_INF("Charge update: p%d -> p%d", old_port, port); + + /* Check if port is sourcing VBUS. */ + if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) { + LOG_WRN("Skip enable p%d: already sourcing", port); + return EC_ERROR_INVAL; + } + + /* Disable sinking on all ports except the desired one */ + for (i = 0; i < board_get_usb_pd_port_count(); i++) { + if (i == port) + continue; + + if (sm5803_vbus_sink_enable(i, 0)) + /* + * Do not early-return because this can fail during + * power-on which would put us into a loop. + */ + LOG_WRN("p%d: sink path disable failed.", i); + } + + /* Don't enable anything (stop here) if no ports were requested */ + if ((port == CHARGE_PORT_NONE) || (old_port == port)) + return EC_SUCCESS; + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + rv = sm5803_vbus_sink_enable(port, 1); + if (rv) + LOG_WRN("p%d: sink path enable failed: code %d", port, rv); + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return rv; +} + +uint16_t tcpc_get_alert_status(void) +{ + /* + * TCPC 0 is embedded in the EC and processes interrupts in the chip + * code (it83xx/intc.c). This function only needs to poll port C1 if + * present. + */ + uint16_t status = 0; + int regval; + + /* Is the C1 port present and its IRQ line asserted? */ + if (board_get_usb_pd_port_count() == 2 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + /* + * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if + * it asserted the IRQ. + */ + if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { + if (regval) + status = PD_STATUS_TCPC_ALERT_1; + } + } + + return status; +} + +void pd_power_supply_reset(int port) +{ + int prev_en; + + if (port < 0 || port >= board_get_usb_pd_port_count()) + return; + + prev_en = charger_is_sourcing_otg_power(port); + + /* Disable Vbus */ + charger_enable_otg_power(port, 0); + + /* Discharge Vbus if previously enabled */ + if (prev_en) + sm5803_set_vbus_disch(port, 1); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + enum ec_error_list rv; + + if (port < 0 || port > board_get_usb_pd_port_count()) { + LOG_WRN("Port C%d does not exist, cannot enable VBUS", port); + return EC_ERROR_INVAL; + } + + /* Disable sinking */ + rv = sm5803_vbus_sink_enable(port, 0); + if (rv) { + LOG_WRN("C%d failed to disable sinking: %d", port, rv); + return rv; + } + + /* Disable Vbus discharge */ + rv = sm5803_set_vbus_disch(port, 0); + if (rv) { + LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv); + return rv; + } + + /* Provide Vbus */ + rv = charger_enable_otg_power(port, 1); + if (rv) { + LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv); + return rv; + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv; + const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500; + + rv = charger_set_otg_current_voltage(port, current, 5000); + if (rv != EC_SUCCESS) { + LOG_WRN("Failed to set source ilimit on port %d to %d: %d", + port, current, rv); + } +} + +void board_reset_pd_mcu(void) +{ + /* + * Do nothing. The integrated TCPC for C0 lacks a dedicated reset + * command, and C1 (if present) doesn't have a reset pin connected + * to the EC. + */ +} + +#define INT_RECHECK_US 5000 + +/* C0 interrupt line shared by BC 1.2 and charger */ + +static void check_c0_line(void); +DECLARE_DEFERRED(check_c0_line); + +static void notify_c0_chips(void) +{ + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + sm5803_interrupt(0); +} + +static void check_c0_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + notify_c0_chips(); + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); + } +} + +void usb_c0_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c0_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c0_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); +} + +/* C1 interrupt line shared by BC 1.2, TCPC, and charger */ +static void check_c1_line(void); +DECLARE_DEFERRED(check_c1_line); + +static void notify_c1_chips(void) +{ + schedule_deferred_pd_interrupt(1); + usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); + /* Charger is handled in board_process_pd_alert */ +} + +static void check_c1_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + notify_c1_chips(); + hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); + } +} + +void usb_c1_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c1_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c1_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); +} + +/* + * Check state of IRQ lines at startup, ensuring an IRQ that happened before + * the EC started up won't get lost (leaving the IRQ line asserted and blocking + * any further interrupts on the port). + * + * Although the PD task will check for pending TCPC interrupts on startup, + * the charger sharing the IRQ will not be polled automatically. + */ +void board_handle_initial_typec_irq(void) +{ + check_c0_line(); + if (board_get_usb_pd_port_count() == 2) + check_c1_line(); +} +/* + * This must run after sub-board detection (which happens in EC main()), + * but isn't depended on by anything else either. + */ +DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST); + +/* + * Handle charger interrupts in the PD task. Not doing so can lead to a priority + * inversion where we fail to respond to TCPC alerts quickly enough because we + * don't get another edge on a shared IRQ until the charger interrupt is cleared + * (or the IRQ is polled again), which happens in the low-priority charger task: + * the high-priority type-C handler is thus blocked on the lower-priority + * charger. + * + * To avoid that, we run charger interrupts at the same priority. + */ +void board_process_pd_alert(int port) +{ + /* + * Port 0 doesn't use an external TCPC, so its interrupts don't need + * this special handling. + */ + if (port == 1 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + sm5803_handle_interrupt(port); + } +} + +int pd_snk_is_vbus_provided(int port) +{ + int chg_det = 0; + + sm5803_get_chg_det(port, &chg_det); + + return chg_det; +} diff --git a/zephyr/program/nissa/nissa.csv b/zephyr/program/nissa/nissa.csv new file mode 100644 index 0000000000..45b73ea229 --- /dev/null +++ b/zephyr/program/nissa/nissa.csv @@ -0,0 +1,122 @@ +Signal Name,Subsystem,Description,DIR,Int,I/O Type,Internal PU,I/O Voltage,ICs attached,NPCX993 (Nivviks),NPCX993 (Nirwen),IT81302 (Nereid),Type,Enum,SW Notes,HW Notes +ESPI_SOC_CLK,ESPI,ESPI clock,IN,no,--,N,1.80 V,,M1,M1,L1,OTHER,,, +ESPI_SOC_CS_EC_L,ESPI,ESPI chip select,IN,F,--,N,1.80 V,,L2,L2,J2,OTHER,,, +ESPI_SOC_D0_EC,ESPI,ESPI DATA0,I/O,,TTL,N,1.80 V,,H1,H1,L2,OTHER,,, +ESPI_SOC_D1_EC,ESPI,ESPI DATA1,I/O,,TTL,N,1.80 V,,J1,J1,K1,OTHER,,, +ESPI_SOC_D2_EC,ESPI,ESPI DATA2,I/O,,TTL,N,1.80 V,,K1,K1,K2,OTHER,,, +ESPI_SOC_D3_EC,ESPI,ESPI DATA3,I/O,,TTL,N,1.80 V,,L1,L1,J1,OTHER,,, +ESPI_SOC_RST_EC_L,ESPI,ESPI reset,IN,F,,N,1.80 V,,K3,K3,R5,OTHER,,, +ESPI_EC_ALERT_SOC_L,ESPI,ESPI Alert,OUT,,TTL,N,1.80 V,,L3,L3,H1,OTHER,,, +GSC_EC_PWR_BTN_ODL,GSC,Power Button input from GSC,IN,both,--,Y,3.30 V,,E7,E7,B13,INPUT_PU,GPIO_POWER_BUTTON_L,GPIO00, +EC_RST_ODL,GSC,Reset signal for EC from GSC,IN,no,--,N,3.30 V,GSC,K6,K6,M2,OTHER,,, +EC_GSC_PACKET_MODE,GSC,Wakes/interrupts GSC and (maybe) vice-versa,I/O,both,--,N,3.30 V,,J6,J6,F9,OUTPUT,GPIO_PACKET_MODE_EN,, +EC_I2C_EEPROM_SCL,I2C,"I2C clock for CBI, reading INAs, programming EC (ITE only)",I/O,,OD,N,3.30 V,"EEPROMs, INAs",C12,C12,A5,I2C_CLOCK,I2C_PORT_EEPROM,, +EC_I2C_EEPROM_SDA,I2C,"I2C data for CBI, reading INAs, programming EC (ITE only)",I/O,,OD,N,3.30 V,"EEPROMs, INAs",B12,B12,B3,I2C_DATA,,, +EC_I2C_BATT_SDA,I2C,I2C data for battery pack,I/O,,OD,N,3.30 V,Battery Pack,K10,K10,A3,I2C_DATA,,, +EC_I2C_BATT_SCL,I2C,I2C clock for battery pack,I/O,,OD,N,3.30 V,Battery Pack,J10,J10,A4,I2C_CLOCK,I2C_PORT_BATTERY,, +EC_I2C_SENSOR_SCL,I2C,I2C clock for sensors,I/O,,OD,N,3.30 V,"IMU, accel, lid accel, kb bl",K8,K8,C2,I2C_CLOCK,I2C_PORT_SENSOR,, +EC_I2C_SENSOR_SDA,I2C,I2C data for sensors,I/O,,OD,N,3.30 V,"IMU, accel, lid accel, kb bl",K7,K7,D2,I2C_DATA,,, +EC_I2C_USB_C0_SDA,I2C,I2C clock for USB-C C0 and USB-A A0 port ICs,I/O,,OD,N,3.30 V,"TCPC, BC1.2, Charger",F9,F9,K7,I2C_DATA,,, +EC_I2C_USB_C0_SCL,I2C,I2C data for USB-C C0 and USB-A A0 port ICs,I/O,,OD,N,3.30 V,"TCPC, BC1.2, Charger",F8,F8,L7,I2C_CLOCK,I2C_PORT_USB_C0_TCPC,, +EC_I2C_SUB_USB_C1_SDA,I2C,I2C clock for USB-C C1 and USB-A A1 port ICs (HDMI: HDMI_EN_SUB_ODL - enable HDMI retimer/output/active low),I/O,,OD,N,3.30 V,"TCPC, BC1.2, Charger",E9,E9,R4,I2C_DATA,,, +EC_I2C_SUB_USB_C1_SCL,I2C,"I2C data for USB-C C1 and USB-A A1 port ICs (HDMI_HPD_SUB_ODL, hot-plug detection/input (interrupt)/active low)",I/O,,OD,N,3.30 V,"TCPC, BC1.2, Charger",E8,E8,P3,I2C_CLOCK,I2C_PORT_USB_C1_TCPC,, +EC_KSI_00,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,A2,A2,K15,OTHER,,, +KSI_01,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,A3,A3,K14,OTHER,,, +EC_KSI_02,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,A4,A4,K10,OTHER,,, +EC_KSI_03,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,B3,B3,J15,OTHER,,,Vivaldi Support +KSI_04,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,B4,B4,J10,OTHER,,, +KSI_05,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,C3,C3,J11,OTHER,,, +KSI_06,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,C4,C4,J14,OTHER,,, +KSI_07,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,C5,C5,H10,OTHER,,, +KSO_00,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B5,B5,R9,OTHER,,, +KSO_01,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B6,B6,K8,OTHER,,, +EC_KSO_02_INV,Keyboard,Keyboard Output,OUT,,TTL,N,3.30 V,,B7,B7,P10,OUTPUT_L,,KEYBOARD_COL2_INVERTED, +KSO_03,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B8,B8,R10,OTHER,,, +KSO_04,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C7,C7,L9,OTHER,,, +KSO_05,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C6,C6,K9,OTHER,,, +KSO_06,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C8,C8,P11,OTHER,,, +KSO_07,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B9,B9,R11,OTHER,,, +KSO_08,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C9,C9,P12,OTHER,,, +KSO_09,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C10,C10,L10,OTHER,,, +KSO_10,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B11,B11,P13,OTHER,,, +KSO_11,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B10,B10,P14,OTHER,,, +KSO_12,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C11,C11,N14,OTHER,,, +KSO_13,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,D11,D11,M15,OTHER,,,Required only for NUM PAD +KSO_14,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,D6,D6,M14,OTHER,,,Required only for NUM PAD +EN_KB_BL,MISC,Enable Keyboard backlight,OUT,,TTL,N,3.30 V,,G11,G11,D14,OUTPUT,GPIO_EN_KEYBOARD_BACKLIGHT,, +VOLDN_BTN_ODL,MISC,Volume down signal,IN,both,--,Y,3.30 V,Button,F12,E11,G15,INPUT_PU,GPIO_VOLUME_DOWN_L,, +VOLUP_BTN_ODL,MISC,Volume up signal,IN,both,--,Y,3.30 V,Button,E11,F12,F14,INPUT_PU,GPIO_VOLUME_UP_L,, +LID_OPEN,MISC,Indicator from lid switch that lid is open,IN,both,--,N,3.30 V,,G7,G7,A11,INPUT,GPIO_LID_OPEN,, +TABLET_MODE_L,MISC,Indicator from lid switch that lid is flipped all the way around,IN,both,--,N,3.30 V,,M12,M12,L8,INPUT,GPIO_TABLET_MODE_L,,Not required to connect to EC? +IMU_INT_L,MISC,Interrupt from base intertial measurement unit,IN,falling,,N,1.80 V,IMU,M2,M2,F15,INPUT,,, +ACC_INT_L,MISC,Interrupt from lid accel (only in convertibles),IN,falling,,N,1.80 V,ACC,G10,G10,E2,INPUT,,,Not required from Dedede? +EC_WP_ODL,MISC,Write protection status from GSC,IN,no,--,N,3.30 V,GSC,L12,L12,R8,INPUT_L,,, +EC_EDP_BL_EN_OD,MISC,EC override of backlight enable,OUT,,OD,N,3.30 V,,E10,E10,R15,OUTPUT_ODR,GPIO_ENABLE_BACKLIGHT,, +TEMP_SENSOR_1,MISC,NTC 1 - near memory,IN,no,ADC,N,ANA,,F2,F2,H15,ADC,ADC_TEMP_SENSOR_1,, +TEMP_SENSOR_2,MISC,NTC 2 - near chassis hot spot,IN,no,ADC,N,ANA,,E3,E3,G10,ADC,ADC_TEMP_SENSOR_2,, +TEMP_SENSOR_3,MISC,NTC 3 - Ambient/skin temp,IN,no,ADC,N,ANA,,,F4,A13,ADC,ADC_TEMP_SENSOR_3,, +USB_C0_INT_ODL,MISC,Interrupt for all ICs for Type-C port 0,IN,,--,Y,3.30 V,,E6,E6,P1,INPUT_PU,,, +USB_C0_PROT_FAULT_ODL,MISC,Fault out of the USB C0 protection IC,IN,falling,OD,Y,3.30 V,,,#N/A,,,,, +"SUB_USB_C1_INT_ODL +(HDMI: EN_SUB_RAILS_ODL)",MISC,"Interrupt for all ICs for Type-C port 1 or the sub-board +HDMI: Enable 5V power rail/output/active low",IN,,--,Y,3.30 V,,F7,F7,N2,OTHER,,, +HDMI_SEL,MISC,Configures AUX to be HDMI DDC,OUT,,TTL,N,3.30 V,,D10,D10,F2,OUTPUT,,, +CCD_MODE_ODL,MISC,Indicates whether H1 is using SBU lines for debug. Also can trigger CCD if the EC decides to.,I/O,falling,--/OD,N,3.30 V,GSC,A12,A12,B9,INPUT,GPIO_CCD_MODE_ODL,, +EC_BATTERY_PRES_ODL,MISC,or BATT_TEMP - indication of battery presence,IN,,--,N,3.30 V,Battery pack,K12,K12,G14,INPUT,GPIO_BATT_PRES_ODL,, +EC_ENTERING_RW,MISC,Indicate when EC is transitioning to RW code,OUT,,TTL,N,3.30 V,GSC,D9,D9,N1,OUTPUT,GPIO_ENTERING_RW,, +EN_USB_A0_VBUS,MISC,,OUT,,TTL,N,3.30 V,,K9,K9,B1,OUTPUT,,, +USB_A0_ILIMIT_SDP,MISC,,OUT,,TTL,N,3.30 V,,J8,J8,A1,OUTPUT,GPIO_USB1_ILIM_SEL,??, +EN_SUB_USB_A1_VBUS,MISC,,OUT,,TTL,N,3.30 V,,A9,A9,B12,OTHER,,??, +SUB_USB_A1_ILIMIT_SDP,MISC,,OUT,,TTL,N,3.30 V,,A10,A10,A12,OUTPUT,GPIO_USB2_ILIM_SEL,??, +PWM_FAN,MISC,,OUT,,PWM,N,3.30 V,,,J7,,PWM,,, +EC_FAN_TACH,MISC,,IN,,,,5.00 V,,,G5,,TACH,,, +EN_PP5000_FAN_X,MISC,,OUT,,TTL,N,3.30 V,,,J2,,OUTPUT,,, +EC_CBI_WP,MISC,Updated EC WP method,OUT,,TTL,N,3.30 V,,H5,H5,D15,OUTPUT,,cbi_latch_eeprom_wp, +IMVP91_VRRDY_OD,POWER SEQUENCE,,IN,,,,,,E2,E2,C14,INPUT,,, +EC_SOC_SYS_PWROK,POWER SEQUENCE,"Generic power good input to PCH (platform specific), system ready to exit reset.",OUT,,TTL,N,3.30 V,SOC,C1,C1,B11,OUTPUT,,PCH_PWROK, +EN_SLP_Z,POWER SEQUENCE,Enable Sleep State (Active high). For ITE only.,OUT,,TTL,N,3.30 V,,F3,F3,R3,OUTPUT,,, +EN_PP5000_S5,POWER SEQUENCE,"Enable PP5000_S5. Figure 523, states this has to come after 3.3V , why?",OUT,,TTL,N,3.30 V,,E5,E5,R14,OUTPUT,,, +EN_PP3300_S5,POWER SEQUENCE,Enable PP3300_S5.,OUT,,TTL,N,3.30 V,,L9,L9,K11,OUTPUT,GPIO_TEMP_SENSOR_POWER,, +EC_SOC_DSW_PWROK,POWER SEQUENCE,DSW Power is OK to AP (diode logic with PP3300_PG),OUT,,TTL,N,3.30 V,SOC,K4,K4,C1,OUTPUT,,, +EC_SOC_RSMRST_L,POWER SEQUENCE,"Asserted after S5-rails are stable, buffered to SOC from EC",OUT,,TTL,N,3.30 V,SOC,F11,F11,E9,OUTPUT,,, +RSMRST_PWRGD_L,POWER SEQUENCE,,IN,both,--,Y,3.30 V,,M11,M11,B14,INPUT_PU,,, +SLP_SUS_L,POWER SEQUENCE,"If high, EC must keep S5 on, used in both DSx and non-DSx platforms.",IN,both,--,N,3.30 V,,H2,H2,F8,INPUT,,,No virtual wire over eSPI +SLP_S4_L,POWER SEQUENCE,"PCH S4 Sleep control. When low, shut-off power to all non critical systems in S4 and lower.",IN,both,--,N,3.30 V,,J4,J4,G11,INPUT,,,This signal is also virtual wire on the eSPI interface. +SLP_S3_L,POWER SEQUENCE,"PCH S3 Sleep control. When low, shut-off power to all non critical systems in S3 and lower.",IN,both,--,N,3.30 V,,K11,K11,B10,INPUT,,,This signal is also virtual wire on the eSPI interface. +SLP_S0_L,POWER SEQUENCE,"PCH S0 Sleep control, asserted when PCH = idle & CPU = C10",IN,both,--,N,3.30 V,,L10,L10,F1,INPUT,,,No virtual wire over eSPI +CPU_C10_GATE_L,POWER SEQUENCE,Asserted low when going into CPU_C10,IN,both,--,N,3.30 V,"SOC, VRs, LS",J3,J3,B6,INPUT,,??, +EC_VSENSE_PP3300_S5,POWER SEQUENCE,Voltage sense (or PGOOD) for PP3300_S5,IN,no,ADC,N,ANA,,B2,B2,H11,ADC,ADC_PP3300_S5,??,"Nuvoton VREF=2.816V, ITE VREF = AVCC or AVCC/1.1 (3V)" +PG_PP5000_S5_OD,POWER SEQUENCE,PP5000_S5 power good signal.,IN,,--,N,3.30 V,,D3,D3,C15,INPUT,,, +EC_SOC_VCCST_PWRGD_OD,POWER SEQUENCE,,OUT,,OD,N,1.05 V,,H11,H11,P9,OUTPUT_ODR,,, +EC_SOC_PCH_PWROK_OD,POWER SEQUENCE,,OUT,,OD,N,3.30 V,,M4,M4,R12,OUTPUT_ODR,,, +ALL_SYS_PWRGD,POWER SEQUENCE,,IN,both,,N,3.30 V,,J11,J11,B2,INPUT,,,Figure 398 PDG 0.5 +PG_PP1050_MEM_S3_OD,POWER SEQUENCE,,IN,both,--,N,3.30 V,,D2,D2,P5,INPUT,,??, +EC_VSENSE_PP1050_PROC,POWER SEQUENCE,,IN,no,ADC,N,ANA,SOC,C2,C2,A14,ADC,ADC_PP1050_PROC,PP1050_PROC monitoring from FIVR output, +SYS_RST_ODL,POWER SEQUENCE,Reset for SOC,OUT,,OD,N,3.30 V,SOC,H7,H7,P4,OUTPUT_ODR,,, +EC_PCH_WAKE_ODL,POWER SEQUENCE,"Allows EC to wake AP (e.g., keyboard out of S0ix)",OUT,,OD,N,3.30 V,SOC,L11,L11,E1,OUTPUT_ODL,,EC_SOC_WAKE_ODL on schematic; software uses PCH_WAKE name, +EC_SOC_RTCRST,POWER SEQUENCE,Allows EC to reset logic on the AP's RTC well,OUT,,TTL,N,3.30 V,SOC,J5,J5,R2,OUTPUT,,, +VCCIN_AUX_VID0,POWER SEQUENCE,Debug purposes,IN,both,,N,1.80 V,,L8,L8,P2,INPUT,,, +VCCIN_AUX_VID1,POWER SEQUENCE,Debug purposes,IN,both,,N,1.80 V,,L7,L7,R1,INPUT,,, +PWM_KB_BL,PWM,Keyboard backlight PWM control signal,OUT,,PWM,N,3.30 V,,H8,H8,R6,PWM,,, +PWM_LED_1_ODL,PWM,LED 1,OUT,,PWM,N,3.30 V,,G8,G8,P6,PWM_INVERT,,, +PWM_LED_2_ODL,PWM,LED 2,OUT,,PWM,N,3.30 V,,G9,G9,R7,PWM_INVERT,,, +PWM_LED_3_ODL,PWM,LED 3,OUT,,PWM,N,3.30 V,,H10,H10,P7,PWM_INVERT,,, +EC_PSYS,PWM,System power monitoring output,OUT,,PWM,N,ANA,"Charger, IMVP9.1",G6,G6,E15,OTHER,,, +EC_SOC_PWR_BTN_ODL,SOC,Buffered power button signal from EC to SOC,OUT,,OD,N,3.30 V,SOC,H9,H9,J5,OUTPUT_ODR,GPIO_PCH_PWRBTN_L,, +EC_SOC_HDMI_HPD,SOC,HPD buffer output for HDMI,OUT,,TTL,N,3.30 V,,L6,L6,P15,OUTPUT,,, +EC_PROCHOT_ODL,SOC,Allows us to send/read PROCHOT,I/O,both,OD,N,1.05 V,SOC,G3,G3,H14,OUTPUT_ODR,,, +EC_PCHHOT_ODL,SOC,Allows us to send/read PCHHOT,,,,,,,#N/A,#N/A,#N/A,OTHER,,,Intel confirmed that this feature is not used. +EC_SOC_INT_ODL,SOC,EC interrupt to SOC,OUT,,OD,N,,,K5,K5,P8,OUTPUT_ODR,GPIO_EC_INT_L,,Is this needed? +UART_GSC_DBG_RX_EC_TX,UART,UART signal from EC to debugger,OUT,,TTL,N,3.30 V,,H4,H4,B4,OTHER,,, +UART_GSC_DBG_TX_EC_RX,UART,UART signal from debugger to EC,IN,,--,N,3.30 V,,G4,G4,B5,OTHER,,, +EN_PP5000_PEN_X,MISC,Enable signal for 5V PEN charging rail,OUT,,TTL,N,3.30 V,,A11,A11,G2,OUTPUT,,, +PEN_DETECT_ODL,MISC,"PEN detect signal. Internal debouncing, if required.",IN,both,--,Y,3.30 V,,G12,G12,E14,INPUT_PU,,, +USB_C0_CC1,USB-PD,CC1 for IT81302 only,I/O,,CC,PD,ANA,,#N/A,#N/A,E10,OTHER,,, +USB_C0_CC2,USB-PD,CC2 for IT81302 only,I/O,,CC,PD,ANA,,#N/A,#N/A,A10,OTHER,,, +USB_C0_FRS,USB-PD,FRS for IT81302 only,OUT,,TTL,N,3.30 V,,#N/A,#N/A,D1,OUTPUT,,, +EN_USB_C0_CC1_VCONN,USB-PD,CC1 vconn en for IT81302 only,OUT,,TTL,N,3.30 V,,#N/A,#N/A,A9,OUTPUT,,, +EN_USB_C0_CC2_VCONN,USB-PD,CC2 vconn en for IT81302 only,OUT,,TTL,N,3.30 V,,#N/A,#N/A,A8,OUTPUT,,, +EC_TRIS_L,DEBUG,Debug for NPCX993,,,,,,,E4,E4,#N/A,OTHER,,, +EC_TEST_L,DEBUG,Debug for NPCX994,,,,,,,K2,K2,#N/A,OTHER,,, +EC_32KXOUT,DEBUG,Debug for NPCX995,,,,,,,M5,M5,#N/A,OTHER,,, +EC_SHDF_ESPI_L,DEBUG,Debug for NPCX996,,,,,,,H3,H3,#N/A,OTHER,,, \ No newline at end of file diff --git a/zephyr/program/nissa/nivviks/cbi.dtsi b/zephyr/program/nissa/nivviks/cbi.dtsi new file mode 100644 index 0000000000..112a2a885c --- /dev/null +++ b/zephyr/program/nissa/nivviks/cbi.dtsi @@ -0,0 +1,30 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* Nivviks-specific fw_config fields. */ + nissa-fw-config { + /* + * FW_CONFIG field to describe mainboard orientation in chassis. + */ + base-inversion { + enum-name = "FW_BASE_INVERSION"; + start = <3>; + size = <1>; + + inverted { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_INVERTED"; + value = <0>; + }; + regular { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_REGULAR"; + value = <1>; + default; + }; + }; + }; +}; diff --git a/zephyr/program/nissa/nivviks/generated.dtsi b/zephyr/program/nissa/nivviks/generated.dtsi new file mode 100644 index 0000000000..91718302b4 --- /dev/null +++ b/zephyr/program/nissa/nivviks/generated.dtsi @@ -0,0 +1,291 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This file is auto-generated - do not edit! + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { + enum-name = "ADC_PP1050_PROC"; + io-channels = <&adc0 4>; + }; + adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { + enum-name = "ADC_PP3300_S5"; + io-channels = <&adc0 6>; + }; + adc_temp_sensor_1: temp_sensor_1 { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 0>; + }; + adc_temp_sensor_2: temp_sensor_2 { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 1>; + }; + adc_temp_sensor_3: temp_sensor_3 { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 10>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_acc_int_l: acc_int_l { + gpios = <&gpio5 0 GPIO_INPUT>; + }; + gpio_all_sys_pwrgd: all_sys_pwrgd { + gpios = <&gpioa 7 GPIO_INPUT>; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_ec_battery_pres_odl: ec_battery_pres_odl { + gpios = <&gpioa 3 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio7 4 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { + gpios = <&gpiod 3 GPIO_ODR_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_entering_rw: ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpio7 5 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_odl { + gpios = <&gpiob 0 GPIO_ODR_LOW>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpiof 1 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { + gpios = <&gpio6 1 GPIO_OUTPUT>; + }; + gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { + gpios = <&gpioe 4 GPIO_OUTPUT>; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpio8 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { + gpios = <&gpio7 2 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpioc 1 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioa 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpio7 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { + gpios = <&gpio3 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { + gpios = <&gpioa 4 GPIO_ODR_HIGH>; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_en_kb_bl: en_kb_bl { + gpios = <&gpioa 0 GPIO_OUTPUT>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_en_pp3300_s5: en_pp3300_s5 { + gpios = <&gpiob 6 GPIO_OUTPUT>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + }; + gpio_en_pp5000_pen_x: en_pp5000_pen_x { + gpios = <&gpioe 2 GPIO_OUTPUT>; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio4 0 GPIO_OUTPUT>; + }; + gpio_en_slp_z: en_slp_z { + gpios = <&gpioe 1 GPIO_OUTPUT>; + }; + gpio_en_usb_a0_vbus: en_usb_a0_vbus { + gpios = <&gpio9 1 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_hdmi_sel: hdmi_sel { + gpios = <&gpioc 6 GPIO_OUTPUT>; + }; + gpio_imu_int_l: imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { + gpios = <&gpio4 3 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_pen_detect_odl: pen_detect_odl { + gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { + gpios = <&gpio4 2 GPIO_INPUT>; + }; + gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { + gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpio9 7 GPIO_INPUT>; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + gpio_slp_s4_l: slp_s4_l { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpio6 2 GPIO_INPUT>; + }; + gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { + gpios = <&gpiod 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB2_ILIM_SEL"; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpioc 5 GPIO_ODR_HIGH>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpio9 5 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { + gpios = <&gpio8 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB1_ILIM_SEL"; + }; + gpio_usb_c0_int_odl: usb_c0_int_odl { + gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; + }; + gpio_vccin_aux_vid0: vccin_aux_vid0 { + gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_vccin_aux_vid1: vccin_aux_vid1 { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_eeprom: ec_i2c_eeprom { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { + i2c-port = <&i2c5_1>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + }; + i2c_ec_i2c_batt: ec_i2c_batt { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_BATTERY"; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan4_gp41 + &adc0_chan6_gp34 + &adc0_chan10_gpe0>; + pinctrl-names = "default"; +}; + + +&i2c0_0 { + status = "okay"; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c1_0 { + status = "okay"; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; +}; + +&i2c3_0 { + status = "okay"; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; +}; + +&i2c5_1 { + status = "okay"; + pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>; + pinctrl-names = "default"; +}; + +&i2c7_0 { + status = "okay"; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/nivviks/keyboard.dtsi b/zephyr/program/nissa/nivviks/keyboard.dtsi new file mode 100644 index 0000000000..00610e4e18 --- /dev/null +++ b/zephyr/program/nissa/nivviks/keyboard.dtsi @@ -0,0 +1,48 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm6 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm6_gpc0>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/nivviks/motionsense.dtsi b/zephyr/program/nissa/nivviks/motionsense.dtsi new file mode 100644 index 0000000000..6297a07bf5 --- /dev/null +++ b/zephyr/program/nissa/nivviks/motionsense.dtsi @@ -0,0 +1,166 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * Interrupt bindings for sensor devices. + */ + lsm6dso-int = &base_accel; + lis2dw12-int = &lid_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <(-1) 0 0 + 0 1 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rot-ref { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; + + base_rot_inverted: base-rotation-inverted { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lsm6dso_accel_data: lsm6dso-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lsm6dso_gyro_data: lsm6dso-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + * TODO(b/238139272): The first entries of the array must be + * accelerometers,then gyroscope. Fix this dependency in the DTS + * processing which makes the devicetree entries independent. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,lsm6dso-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + /* + * May be replaced by alternate depending + * on board config. + */ + rot-standard-ref = <&base_rot_ref>; + drv-data = <&lsm6dso_accel_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,lsm6dso-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dso_gyro_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/nissa/nivviks/overlay.dtsi b/zephyr/program/nissa/nivviks/overlay.dtsi new file mode 100644 index 0000000000..c2d5e3f24b --- /dev/null +++ b/zephyr/program/nissa/nivviks/overlay.dtsi @@ -0,0 +1,418 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_odl; + int-wp = &int_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; + + batteries { + default_battery: lgc { + compatible = "lgc,ap18c8k", "battery-smart"; + }; + lgc_ap19b8m { + compatible = "lgc,ap19b8m", "battery-smart"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_power_button + &int_lid_open + >; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_imu_int_l>; + flags = ; + handler = "lsm6dso_interrupt"; + }; + int_vol_down: vol_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_vol_up: vol_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_usb_c0: usb_c0 { + irq-pin = <&gpio_usb_c0_int_odl>; + flags = ; + handler = "usb_interrupt"; + }; + int_usb_c1: usb_c1 { + irq-pin = <&gpio_sb_1>; + flags = ; + handler = "usb_interrupt"; + }; + }; + + named-gpios { + gpio_sb_1: sb-1 { + gpios = <&gpio0 2 GPIO_PULL_UP>; + no-auto-init; + }; + + gpio_sb_2: sb-2 { + gpios = <&gpiod 4 GPIO_OUTPUT>; + no-auto-init; + }; + + /* + * Set I2C pins for type C sub-board to be low voltage (I2C5_1). + * We do this for all boards, since the pins are 3.3V tolerant, + * and the only 2 types of sub-boards used on nivviks both have + * type-C ports on them. + */ + gpio_sb_3: sb-3 { + gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; + no-auto-init; + }; + gpio_sb_4: sb-4 { + gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + no-auto-init; + }; + gpio_fan_enable: fan-enable { + gpios = <&gpio6 3 GPIO_OUTPUT>; + no-auto-init; + }; + ec-i2c-sensor-scl { + gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + }; + + /* + * Aliases used for sub-board GPIOs. + */ + aliases { + /* + * Input GPIO when used with type-C port 1 + * Output when used with HDMI sub-board + */ + gpio-usb-c1-int-odl = &gpio_sb_1; + gpio-en-rails-odl = &gpio_sb_1; + /* + * Sub-board with type A USB, enable. + */ + gpio-en-usb-a1-vbus = &gpio_sb_2; + /* + * HPD pins for HDMI sub-board. + */ + gpio-hdmi-en-odl = &gpio_sb_3; + gpio-hpd-odl = &gpio_sb_4; + /* + * Enable S5 rails for LTE sub-board + */ + gpio-en-sub-s5-rails = &gpio_sb_2; + }; + + temp_memory: memory { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_1>; + }; + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_2>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_3>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + memory { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_memory>; + }; + charger { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_charger>; + }; + ambient { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_ambient>; + }; + }; + + usba { + compatible = "cros-ec,usba-port-enable-pins"; + /* + * sb_2 is only configured as GPIO when USB-A1 is present, + * but it's still safe to control when disabled. + * + * ILIM_SEL pins are referred to by legacy enum name, + * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on + * sub-boards that don't have USB-A so is safe to control + * regardless of system configuration. + */ + enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; + status = "okay"; + }; + + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + chg = <&chg_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + /* + * TODO(b:211693800): port1 may not be present on some + * sub-boards. + */ + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + chg = <&chg_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; + }; + usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; + + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm5 5 PWM_KHZ(1) PWM_POLARITY_NORMAL>; + rpm_min = <2200>; + rpm_start = <2200>; + rpm_max = <4200>; + tach = <&tach2>; + enable_gpio = <&gpio_fan_enable>; + }; + }; + + /* + * Declare unused GPIOs so that they are shut down + * and use minimal power + */ + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio3 2 0>, + <&gpio3 3 0>, + <&gpio3 5 0>, + <&gpio3 6 0>, + <&gpio5 7 0>, + <&gpio6 0 0>, + <&gpio6 3 0>, + <&gpio6 6 0>, + <&gpio7 3 0>, + <&gpio8 3 0>, + <&gpio8 6 0>, + <&gpiob 1 0>, + <&gpiob 7 0>, + <&gpioc 7 0>, + <&gpiof 2 0>, + <&gpiof 3 0>; + }; +}; + +&thermistor_3V3_51K1_47K_4050B { + status = "okay"; +}; + +&adc_ec_vsense_pp3300_s5 { + /* + * Voltage divider on input has 47k upper and 220k lower legs with + * 2714 mV full-scale reading on the ADC. Apply the largest possible + * multiplier (without overflowing int32) to get the best possible + * approximation of the actual ratio, but derate by a factor of two to + * ensure unexpectedly high values won't overflow. + */ + mul = <(791261 / 2)>; + div = <(651975 / 2)>; +}; + +/* Set bus speeds for I2C */ +&i2c0_0 { + label = "I2C_EEPROM"; + clock-frequency = ; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c1_0 { + label = "I2C_SENSOR"; + clock-frequency = ; +}; + +&i2c3_0 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + /* + * BC1.2 interrupt is shared with TCPC, so + * IRQ is not specified here and handled by + * usb_c0_interrupt. + */ + }; + + chg_port0: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&i2c5_1 { + label = "I2C_SUB_C1_TCPC"; + clock-frequency = ; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port1: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; + + anx7483_mux_1: anx7483-mux-1@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "anx7483_set_default_tuning"; + }; +}; + +&i2c7_0 { + label = "I2C_BATTERY"; + clock-frequency = ; +}; + +&pwm5_gpb7 { + drive-open-drain; +}; + +&pwm5 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; + +/* Tachometer for fan speed measurement */ +&tach2 { + status = "okay"; + pinctrl-0 = <&ta2_1_in_gp73>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; + +/* + * Declare GPIOs that have leakage current caused by board issues here. NPCX ec + * will disable their input buffers before entering deep sleep and restore them + * after waking up automatically for better power consumption. + */ +&power_leakage_io { + leak-gpios = <&gpioa 4 0 + &gpiof 1 0>; +}; diff --git a/zephyr/program/nissa/nivviks/power_signals.dtsi b/zephyr/program/nissa/nivviks/power_signals.dtsi new file mode 100644 index 0000000000..1d2b23069d --- /dev/null +++ b/zephyr/program/nissa/nivviks/power_signals.dtsi @@ -0,0 +1,220 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <10>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpio4 0 0>; + output; + }; + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpiob 6 0>; + output; + }; + pwr-pg-ec-rsmrst-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpio9 4 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioa 6 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpio6 1 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpio4 3 0>; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpio3 7 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + pwr-adc-pp3300 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP3300 PWROK (from ADC)"; + enum-name = "PWR_DSW_PWROK"; + trigger-high = <&cmp_pp3300_s5_high>; + trigger-low = <&cmp_pp3300_s5_low>; + }; + pwr-adc-pp1p05 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP1P05 PWROK (from ADC)"; + enum-name = "PWR_PG_PP1P05"; + trigger-high = <&cmp_pp1p05_high>; + trigger-low = <&cmp_pp1p05_low>; + }; + + adc-cmp { + cmp_pp3300_s5_high: pp3300_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* + * This is 90% of nominal voltage considering voltage + * divider on ADC input. + */ + threshold-mv = <2448>; + }; + cmp_pp3300_s5_low: pp3300_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <2448>; + }; + cmp_pp1p05_high: pp1p05_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* Setting at 90% of nominal voltage */ + threshold-mv = <945>; + }; + cmp_pp1p05_low: pp1p05_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <945>; + }; + }; +}; + +/* + * Because the power signals directly reference the GPIOs, + * the correspinding named-gpios need to have no-auto-init set. + */ +&gpio_ec_soc_dsw_pwrok { + no-auto-init; +}; +&gpio_ec_soc_pch_pwrok_od { + no-auto-init; +}; +&gpio_ec_soc_rsmrst_l { + no-auto-init; +}; +&gpio_ec_soc_sys_pwrok { + no-auto-init; +}; +&gpio_ec_soc_vccst_pwrgd_od { + no-auto-init; +}; +&gpio_en_pp3300_s5 { + no-auto-init; +}; +&gpio_en_pp5000_s5 { + no-auto-init; +}; +&gpio_imvp91_vrrdy_od { + no-auto-init; +}; +&gpio_rsmrst_pwrgd_l { + no-auto-init; +}; +&gpio_slp_s0_l { + no-auto-init; +}; +&gpio_slp_s3_l { + no-auto-init; +}; +&gpio_slp_s4_l { + no-auto-init; +}; +&gpio_slp_sus_l { + no-auto-init; +}; +&gpio_sys_rst_odl { + no-auto-init; +}; diff --git a/zephyr/program/nissa/nivviks/project.conf b/zephyr/program/nissa/nivviks/project.conf new file mode 100644 index 0000000000..af9e4e2586 --- /dev/null +++ b/zephyr/program/nissa/nivviks/project.conf @@ -0,0 +1,8 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_NIVVIKS=y +CONFIG_PLATFORM_EC_OCPC=y + +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y diff --git a/zephyr/program/nissa/nivviks/project.overlay b/zephyr/program/nissa/nivviks/project.overlay new file mode 100644 index 0000000000..9ca681d979 --- /dev/null +++ b/zephyr/program/nissa/nivviks/project.overlay @@ -0,0 +1,14 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../cbi.dtsi" + +#include "cbi.dtsi" +#include "generated.dtsi" +#include "keyboard.dtsi" +#include "motionsense.dtsi" +#include "overlay.dtsi" +#include "power_signals.dtsi" +#include "pwm_leds.dtsi" diff --git a/zephyr/program/nissa/nivviks/pwm_leds.dtsi b/zephyr/program/nissa/nivviks/pwm_leds.dtsi new file mode 100644 index 0000000000..a265a5929e --- /dev/null +++ b/zephyr/program/nissa/nivviks/pwm_leds.dtsi @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm2 2 PWM_HZ(324) PWM_POLARITY_INVERTED>, + <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>, + <&pwm1 1 PWM_HZ(324) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0>; + + /**/ + color-map-red = <100 0 0>; + color-map-green = < 0 100 0>; + color-map-blue = < 0 0 100>; + color-map-yellow = < 0 50 50>; + color-map-white = <100 100 100>; + color-map-amber = <100 0 0>; + + brightness-range = <0 0 100 0 0 100>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + }; +}; + +/* Enable LEDs to work while CPU suspended */ + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/nivviks/src/charger.c b/zephyr/program/nissa/nivviks/src/charger.c new file mode 100644 index 0000000000..e2f9f966e7 --- /dev/null +++ b/zephyr/program/nissa/nivviks/src/charger.c @@ -0,0 +1,56 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charger.h" +#include "charger/isl923x_public.h" +#include "console.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = raa489000_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Nivviks does not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + if (board_get_usb_pd_port_count() == 2) + raa489000_hibernate(CHARGER_SECONDARY, true); + raa489000_hibernate(CHARGER_PRIMARY, true); + LOG_INF("Charger(s) hibernated"); + cflush(); +} diff --git a/zephyr/program/nissa/nivviks/src/fan.c b/zephyr/program/nissa/nivviks/src/fan.c new file mode 100644 index 0000000000..840049722c --- /dev/null +++ b/zephyr/program/nissa/nivviks/src/fan.c @@ -0,0 +1,43 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* + * Nirwen fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + if (val != FW_FAN_PRESENT) { + /* Disable the fan */ + fan_set_count(0); + } else { + /* Configure the fan enable GPIO */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), + GPIO_OUTPUT); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/nivviks/src/form_factor.c b/zephyr/program/nissa/nivviks/src/form_factor.c new file mode 100644 index 0000000000..602b22baff --- /dev/null +++ b/zephyr/program/nissa/nivviks/src/form_factor.c @@ -0,0 +1,47 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "accelgyro.h" +#include "cros_cbi.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_inverted)) +#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel)) +#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro)) + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + /* + * If the firmware config indicates + * an inverted form factor, use the alternative + * rotation matrix. + */ + ret = cros_cbi_get_fw_config(FW_BASE_INVERSION, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", + FW_BASE_INVERSION); + return; + } + if (val == FW_BASE_INVERTED) { + LOG_INF("Switching to inverted base"); + motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT; + motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/nissa/nivviks/src/keyboard.c b/zephyr/program/nissa/nivviks/src/keyboard.c new file mode 100644 index 0000000000..f13d5bf78c --- /dev/null +++ b/zephyr/program/nissa/nivviks/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config nivviks_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &nivviks_kb; +} diff --git a/zephyr/program/nissa/nivviks/src/led.c b/zephyr/program/nissa/nivviks/src/led.c new file mode 100644 index 0000000000..9087982604 --- /dev/null +++ b/zephyr/program/nissa/nivviks/src/led.c @@ -0,0 +1,51 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery LED control for nissa + */ +#include "common.h" +#include "ec_commands.h" +#include "led_common.h" +#include "led_onoff_states.h" +#include "led_pwm.h" + +__override const int led_charge_lvl_1 = 5; +__override const int led_charge_lvl_2 = 97; +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_BLUE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_AMBER, + 2 * LED_ONE_SEC }, + { EC_LED_COLOR_BLUE, + 2 * LED_ONE_SEC } }, + }; + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_BLUE: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_BLUE); + break; + case EC_LED_COLOR_AMBER: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); + break; + default: /* LED_OFF and other unsupported colors */ + set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); + break; + } +} diff --git a/zephyr/program/nissa/nivviks/src/usbc.c b/zephyr/program/nissa/nivviks/src/usbc.c new file mode 100644 index 0000000000..14fc5a071d --- /dev/null +++ b/zephyr/program/nissa/nivviks/src/usbc.c @@ -0,0 +1,277 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/isl923x_public.h" +#include "driver/retimer/anx7483_public.h" +#include "driver/tcpm/tcpci.h" +#include "driver/tcpm/raa489000.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C0_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, + { /* sub-board */ + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, +}; + +int board_is_sourcing_vbus(int port) +{ + int regval; + + tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); + return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); +} + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + int old_port; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + + LOG_INF("New chg p%d", port); + + /* Disable all ports. */ + if (port == CHARGE_PORT_NONE) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW); + raa489000_enable_asgate(i, false); + } + + return EC_SUCCESS; + } + + /* Check if port is sourcing VBUS. */ + if (board_is_sourcing_vbus(port)) { + LOG_WRN("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i == port) + continue; + + if (tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW)) + LOG_WRN("p%d: sink path disable failed.", i); + raa489000_enable_asgate(i, false); + } + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + if (raa489000_enable_asgate(port, true) || + tcpc_write(port, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { + LOG_WRN("p%d: sink path enable failed.", port); + charger_discharge_on_ac(0); + return EC_ERROR_UNKNOWN; + } + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return EC_SUCCESS; +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + int regval; + + /* + * The interrupt line is shared between the TCPC and BC1.2 detector IC. + * Therefore, go out and actually read the alert registers to report the + * alert status. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { + /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ + if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_0; + } + } + + if (board_get_usb_pd_port_count() == 2 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { + /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ + if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_1; + } + } + + return status; +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS */ + tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return; + + raa489000_set_output_current(port, rp); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return EC_ERROR_INVAL; + + /* Disable charging. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); + if (rv) + return rv; + + /* Our policy is not to source VBUS when the AP is off. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + return EC_ERROR_NOT_POWERED; + + /* Provide Vbus. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); + if (rv) + return rv; + + rv = raa489000_enable_asgate(port, true); + if (rv) + return rv; + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +void board_reset_pd_mcu(void) +{ + /* + * TODO(b:147316511): could send a reset command to the TCPC here + * if needed. + */ +} + +/* + * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible + * for an interrupt to be lost if one asserts the IRQ, the other does the same + * then the first releases it: there will only be one falling edge to trigger + * the interrupt, and the line will be held low. We handle this by running a + * deferred check after a falling edge to see whether the IRQ is still being + * asserted. If it is, we assume an interrupt may have been lost and we need + * to poll each chip for events again. + */ +#define USBC_INT_POLL_DELAY_US 5000 + +static void poll_c0_int(void); +DECLARE_DEFERRED(poll_c0_int); +static void poll_c1_int(void); +DECLARE_DEFERRED(poll_c1_int); + +static void usbc_interrupt_trigger(int port) +{ + schedule_deferred_pd_interrupt(port); + usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); +} + +static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, + const struct deferred_data *ud) +{ + if (!gpio_pin_get_dt(gpio)) { + usbc_interrupt_trigger(port); + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); + } +} + +static void poll_c0_int(void) +{ + poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), + &poll_c0_int_data); +} + +static void poll_c1_int(void) +{ + poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), + &poll_c1_int_data); +} + +void usb_interrupt(enum gpio_signal signal) +{ + int port; + const struct deferred_data *ud; + + if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { + port = 0; + ud = &poll_c0_int_data; + } else { + port = 1; + ud = &poll_c1_int_data; + } + /* + * We've just been called from a falling edge, so there's definitely + * no lost IRQ right now. Cancel any pending check. + */ + hook_call_deferred(ud, -1); + /* Trigger polling of TCPC and BC1.2 in respective tasks */ + usbc_interrupt_trigger(port); + /* Check for lost interrupts in a bit */ + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); +} diff --git a/zephyr/program/nissa/npcx_program.conf b/zephyr/program/nissa/npcx_program.conf new file mode 100644 index 0000000000..ae672cb63a --- /dev/null +++ b/zephyr/program/nissa/npcx_program.conf @@ -0,0 +1,55 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# EC chip configuration: NPCX993 +CONFIG_CROS_FLASH_NPCX=y +CONFIG_CROS_SYSTEM_NPCX=y +CONFIG_SOC_SERIES_NPCX9=y +CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y +CONFIG_SYSCON=y +CONFIG_TACH_NPCX=y +CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=256 + +# Common sensor drivers +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y + +# Keyboard +CONFIG_CROS_KB_RAW_NPCX=y +CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y +# Ensure recovery key combination (esc+refresh+power) is reliable +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y + +# TCPC+PPC: both C0 and C1 (if present) are RAA489000 +CONFIG_PLATFORM_EC_USB_PD_TCPM_RAA489000=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US=100000 +# RAA489000 uses TCPCI but not a separate PPC, so custom function is required +CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y +# type C port 1 redriver +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Save some flash space, but retain some useful features +CONFIG_SHELL_MINIMAL=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y +CONFIG_SHELL_HELP=y +CONFIG_KERNEL_SHELL=y + +# FRS enable +CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y + +# Charger driver and configuration +CONFIG_PLATFORM_EC_CHARGER_RAA489000=y +CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=22 + +# VSENSE: PP3300_S5 & PP1050_PROC +CONFIG_ADC_CMP_NPCX=y +CONFIG_ADC_CMP_NPCX_WORKQUEUE=y +CONFIG_ADC_CMP_NPCX_WORKQUEUE_PRIORITY=12 +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf new file mode 100644 index 0000000000..c23a7f1381 --- /dev/null +++ b/zephyr/program/nissa/program.conf @@ -0,0 +1,156 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Core EC configuration: build the EC application, using ECOS shims +# (which are currently required for a number of features). +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_LTO=y + +# Debug options and features; can be disabled to save memory or once bringup +# is complete. +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y + +# RAM-saving options +# flash shell command is unused, allocated a 4kB buffer for flash test +CONFIG_FLASH_SHELL=n +# EC default 1kB buffer seems unnecessarily large, Zephyr default is 8 bytes +CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=128 + +# Standard shimmed features +CONFIG_PLATFORM_EC_BACKLIGHT_LID=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_VBOOT_EFS2=y +CONFIG_PLATFORM_EC_VBOOT_HASH=y + +# Application processor; communicates with EC via eSPI +CONFIG_AP=y +CONFIG_AP_X86_INTEL_ADL=y +CONFIG_ESPI=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y +CONFIG_PLATFORM_EC_HOSTCMD=y +CONFIG_HCDEBUG_OFF=y +CONFIG_PLATFORM_EC_THROTTLE_AP=y +CONFIG_PLATFORM_EC_PORT80=y +CONFIG_PLATFORM_EC_PORT80_QUIET=y + +# AP Power Sequencing +CONFIG_AP_PWRSEQ=y +CONFIG_X86_NON_DSX_PWRSEQ_ADL=y +CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y +CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y +CONFIG_AP_PWRSEQ_S0IX=y +CONFIG_AP_PWRSEQ_S0IX_ERROR_RECOVERY=y + +# I2C +CONFIG_I2C=y + +# Keyboard support +CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_CMD_BUTTON=n +# Column 2 is driven through the GSC, which inverts the signal going through it +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=y +CONFIG_PLATFORM_EC_LED_PWM=y +CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n + +# MKBP event +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y + +# Temperature sensor support +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y +CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY=y + +# CBI EEPROM support +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_CBI_EEPROM=y +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y + + +# PWM support +CONFIG_PWM=y +CONFIG_PWM_SHELL=y + +# TODO(b/188605676): bring these features up +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n + +# Sensors support +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y + +# USB-C: enable PD on up to two ports +CONFIG_PLATFORM_EC_USBC=y +CONFIG_PLATFORM_EC_USBC_PPC=n +CONFIG_PLATFORM_EC_USB_VID=0x18d1 +CONFIG_PLATFORM_EC_USB_PID=0x505a +# USB4 and TBT are unsupported +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n + +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +# ADL integrated muxes are slow: unblock PD +CONFIG_PLATFORM_EC_USB_MUX_TASK=y +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y + +# USB-C TCPC and PPC standard options +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y + +# USB-A host ports +CONFIG_PLATFORM_EC_USBA=y +CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC=y +# Both ports use a smart switch with CTL1..3 fixed high, for SDP2 or CDP only: +# either SLGC55545 or PI5USB2546. +CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART=y +CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_CDP_SDP_ONLY=y +CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_CDP=y +CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_INVERTED=y + +# Battery support +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y + +# Charger support +CONFIG_PLATFORM_EC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y + +# Dynamically select PD voltage to maximize charger efficiency +CONFIG_PLATFORM_EC_USB_PD_DPS=y +# Reduce logging so that state transitions do not cause protocol issues +# pd dump [1-3] can be used to increase the debugging level +CONFIG_PLATFORM_EC_USB_PD_INITIAL_DEBUG_LEVEL=0 diff --git a/zephyr/program/nissa/pujjo/cbi.dtsi b/zephyr/program/nissa/pujjo/cbi.dtsi new file mode 100644 index 0000000000..b5ba92bd9e --- /dev/null +++ b/zephyr/program/nissa/pujjo/cbi.dtsi @@ -0,0 +1,190 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* Pujjo-specific fw_config fields. */ + nissa-fw-config { + /* + * FW_CONFIG field to enable KB back light or not. + */ + kb-bl { + enum-name = "FW_KB_BL"; + start = <3>; + size = <1>; + + no-kb-bl { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_NOT_PRESENT"; + value = <0>; + }; + kb-bl-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_PRESENT"; + value = <1>; + }; + }; + + /* + * FW_CONFIG field for KB PWB present or not. + */ + kb-pwb { + enum-name = "FW_KB_PWB"; + start = <4>; + size = <1>; + + no-kb-pwb { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_PWB_NOT_PRESENT"; + value = <0>; + }; + kb-pwb-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_PWB_PRESENT"; + value = <1>; + }; + }; + + /* + * FW_CONFIG field for tablet present or not. + */ + tablet { + enum-name = "FW_TABLET"; + start = <5>; + size = <1>; + + no-tablet { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_TABLET_NOT_PRESENT"; + value = <0>; + }; + tablet-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_TABLET_PRESENT"; + value = <1>; + }; + }; + + /* + * FW_CONFIG field for LTE board present or not. + * + * start = <6>; + * size = <1>; + */ + + /* + * FW_CONFIG field for SD card present or not. + * + * start = <7>; + * size = <1>; + */ + + /* + * FW_CONFIG field for pen present or not. + */ + pen { + enum-name = "FW_PEN"; + start = <8>; + size = <1>; + + no-pen { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_PEN_NOT_PRESENT"; + value = <0>; + }; + pen-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_PEN_PRESENT"; + value = <1>; + }; + }; + + /* + * FW_CONFIG field for WF camera present or not. + * + * start = <9>; + * size = <1>; + */ + + /* + * FW_CONFIG field for multiple thermal table. + */ + therm-table { + enum-name = "THERM_TABLE"; + start = <10>; + size = <2>; + + therm-table-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "THERM_TABLE_1"; + value = <1>; + }; + }; + + /* + * FW_CONFIG field for multiple audio module. + * + * start = <12>; + * size = <3>; + */ + + /* + * FW_CONFIG field for EXT_VR. + * + * start = <15>; + * size = <1>; + */ + + /* + * FW_CONFIG field for multiple wi-fi SAR. + * + * start = <16>; + * size = <2>; + */ + }; + + /* Pujjo-specific ssfc fields. */ + cbi-ssfc { + compatible = "named-cbi-ssfc"; + /* + * SSFC field to identify BASE motion sensor. + */ + base-sensor { + enum-name = "BASE_SENSOR"; + size = <2>; + + base_sensor_0: bmi323 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <0>; + default; + }; + base_sensor_1: lsm6dsm { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <1>; + }; + }; + + /* + * SSFC field to identify LID motion sensor. + */ + lid-sensor { + enum-name = "LID_SENSOR"; + size = <2>; + + lid_sensor_0: bma422 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <0>; + default; + }; + lid_sensor_1: lis2dw12 { + compatible = "named-cbi-ssfc-value"; + status = "okay"; + value = <1>; + }; + }; + }; +}; diff --git a/zephyr/program/nissa/pujjo/generated.dtsi b/zephyr/program/nissa/pujjo/generated.dtsi new file mode 100644 index 0000000000..727d2d3d53 --- /dev/null +++ b/zephyr/program/nissa/pujjo/generated.dtsi @@ -0,0 +1,277 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This file is auto-generated - do not edit! + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { + enum-name = "ADC_PP1050_PROC"; + io-channels = <&adc0 4>; + }; + adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { + enum-name = "ADC_PP3300_S5"; + io-channels = <&adc0 6>; + }; + adc_temp_sensor_1: temp_sensor_1 { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 0>; + }; + adc_temp_sensor_2: temp_sensor_2 { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 1>; + }; + adc_temp_sensor_3: temp_sensor_3 { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 10>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_acc_int_l: acc_int_l { + gpios = <&gpio5 0 GPIO_INPUT>; + }; + gpio_all_sys_pwrgd: all_sys_pwrgd { + gpios = <&gpioa 7 GPIO_INPUT>; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_ec_battery_pres_odl: ec_battery_pres_odl { + gpios = <&gpioa 3 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio7 4 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { + gpios = <&gpiod 3 GPIO_ODR_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_entering_rw: ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpio7 5 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_odl { + gpios = <&gpiob 0 GPIO_ODR_LOW>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpiof 1 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { + gpios = <&gpio6 1 GPIO_OUTPUT>; + }; + gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { + gpios = <&gpioe 4 GPIO_OUTPUT>; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpio8 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { + gpios = <&gpio7 2 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpioc 1 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioa 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpio7 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { + gpios = <&gpio3 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { + gpios = <&gpioa 4 GPIO_ODR_HIGH>; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_en_kb_bl: en_kb_bl { + gpios = <&gpioa 0 GPIO_OUTPUT>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_en_pp3300_s5: en_pp3300_s5 { + gpios = <&gpiob 6 GPIO_OUTPUT>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + }; + gpio_en_pp5000_pen_x: en_pp5000_pen_x { + gpios = <&gpioe 2 GPIO_OUTPUT>; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio4 0 GPIO_OUTPUT>; + }; + gpio_en_slp_z: en_slp_z { + gpios = <&gpioe 1 GPIO_OUTPUT>; + }; + gpio_en_usb_a0_vbus: en_usb_a0_vbus { + gpios = <&gpio9 1 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_hdmi_sel: hdmi_sel { + gpios = <&gpioc 6 GPIO_OUTPUT>; + }; + gpio_imu_int_l: imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { + gpios = <&gpio4 3 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_pen_detect_odl: pen_detect_odl { + gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { + gpios = <&gpio4 2 GPIO_INPUT>; + }; + gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { + gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpio9 7 GPIO_INPUT>; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + gpio_slp_s4_l: slp_s4_l { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpio6 2 GPIO_INPUT>; + }; + gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { + gpios = <&gpiod 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB2_ILIM_SEL"; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpioc 5 GPIO_ODR_HIGH>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpio9 5 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { + gpios = <&gpio8 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB1_ILIM_SEL"; + }; + gpio_usb_c0_int_odl: usb_c0_int_odl { + gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; + }; + gpio_vccin_aux_vid0: vccin_aux_vid0 { + gpios = <&gpio9 2 GPIO_INPUT>; + }; + gpio_vccin_aux_vid1: vccin_aux_vid1 { + gpios = <&gpioe 3 GPIO_INPUT>; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_eeprom: ec_i2c_eeprom { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + i2c_ec_i2c_batt: ec_i2c_batt { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_BATTERY"; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan4_gp41 + &adc0_chan6_gp34 + &adc0_chan10_gpe0>; + pinctrl-names = "default"; +}; + + +&i2c0_0 { + status = "okay"; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c1_0 { + status = "okay"; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; +}; + +&i2c3_0 { + status = "okay"; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; +}; + +&i2c7_0 { + status = "okay"; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/pujjo/keyboard.dtsi b/zephyr/program/nissa/pujjo/keyboard.dtsi new file mode 100644 index 0000000000..00610e4e18 --- /dev/null +++ b/zephyr/program/nissa/pujjo/keyboard.dtsi @@ -0,0 +1,48 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm6 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm6_gpc0>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/pujjo/motionsense.dtsi b/zephyr/program/nissa/pujjo/motionsense.dtsi new file mode 100644 index 0000000000..2dfca337c4 --- /dev/null +++ b/zephyr/program/nissa/pujjo/motionsense.dtsi @@ -0,0 +1,245 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * Interrupt bindings for sensor devices. + */ + bmi3xx-int = &base_accel; + lsm6dsm-int = &base_accel; + lis2dw12-int = &lid_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + (-1) 0 0 + 0 0 (-1)>; + }; + + lid_rot_lis2dw12: lid-rotation-lis2dw12 { + mat33 = <0 (-1) 0 + (-1) 0 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_lsm6dsm: base-rotation-lsm6dsm { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + + lsm6dsm_data_accel: lsm6dsm-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dsm"; + status = "okay"; + }; + + lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dsm"; + status = "okay"; + }; + + bma422_data: bma422-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + * TODO(b/238139272): The first entries of the array must be + * accelerometers,then gyroscope. Fix this dependency in the DTS + * processing which makes the devicetree entries independent. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma422_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi323_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi323_data>; + }; + }; + + motionsense-sensor-alt { + alt_lid_accel: alt-lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_lis2dw12>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS"; + alternate-for = <&lid_accel>; + alternate-ssfc-indicator = <&lid_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_accel: alt-base-accel { + compatible = "cros-ec,lsm6dsm-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_lsm6dsm>; + drv-data = <&lsm6dsm_data_accel>; + alternate-for = <&base_accel>; + alternate-ssfc-indicator = <&base_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + ec-rate = <0>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,lsm6dsm-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_lsm6dsm>; + drv-data = <&lsm6dsm_data_gyro>; + alternate-for = <&base_gyro>; + alternate-ssfc-indicator = <&base_sensor_1>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/nissa/pujjo/overlay.dtsi b/zephyr/program/nissa/pujjo/overlay.dtsi new file mode 100644 index 0000000000..60b3b60003 --- /dev/null +++ b/zephyr/program/nissa/pujjo/overlay.dtsi @@ -0,0 +1,350 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_odl; + int-wp = &int_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; + + batteries { + default_battery: smp { + compatible = "smp,l22m3pg0", "battery-smart"; + }; + smp_l22m3pg1 { + compatible = "smp,l22m3pg1", "battery-smart"; + }; + sunwoda_l22d3pg0 { + compatible = "sunwoda,l22d3pg0", "battery-smart"; + }; + sunwoda_l22d3pg1 { + compatible = "sunwoda,l22d3pg1", "battery-smart"; + }; + celxpert_l22c3pg0 { + compatible = "celxpert,l22c3pg0", "battery-smart"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_power_button + &int_lid_open + >; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_imu_int_l>; + flags = ; + handler = "motion_interrupt"; + }; + int_vol_down: vol_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_vol_up: vol_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_usb_c0: usb_c0 { + irq-pin = <&gpio_usb_c0_int_odl>; + flags = ; + handler = "usb_interrupt"; + }; + }; + + named-gpios { + gpio_sb_2: sb_2 { + gpios = <&gpiod 4 GPIO_OUTPUT>; + no-auto-init; + }; + + gpio_sb_3: sb_3 { + gpios = <&gpiof 5 GPIO_OPEN_DRAIN>; + no-auto-init; + }; + gpio_sb_4: sb_4 { + gpios = <&gpiof 4 GPIO_INPUT>; + no-auto-init; + }; + gpio_fan_enable: fan-enable { + gpios = <&gpio6 3 GPIO_OUTPUT>; + no-auto-init; + }; + gpio_power_led: power_led { + gpios = <&gpioc 2 GPIO_OUTPUT_LOW>; + }; + gpio_led_1_odl: led_1_odl { + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + gpio_led_2_odl: led_2_odl { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + }; + + /* + * Aliases used for sub-board GPIOs. + */ + aliases { + /* + * Sub-board with type A USB, enable. + */ + gpio-en-usb-a1-vbus = &gpio_sb_2; + /* + * HPD pins for HDMI sub-board. + */ + gpio-hdmi-en-odl = &gpio_sb_3; + gpio-hpd-odl = &gpio_sb_4; + /* + * Enable S5 rails for LTE sub-board + */ + gpio-en-sub-s5-rails = &gpio_sb_2; + }; + + temp_cpu: cpu { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_1>; + }; + temp_ddr: ddr { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_2>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_3>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + cpu { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <90>; + temp_host_halt = <100>; + temp_host_release_high = <85>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_cpu>; + }; + ddr { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <90>; + temp_host_halt = <100>; + temp_host_release_high = <85>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_ddr>; + }; + ambient { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <90>; + temp_host_halt = <100>; + temp_host_release_high = <85>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_ambient>; + }; + }; + + usba { + compatible = "cros-ec,usba-port-enable-pins"; + /* + * sb_2 is only configured as GPIO when USB-A1 is present, + * but it's still safe to control when disabled. + * + * ILIM_SEL pins are referred to by legacy enum name, + * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on + * sub-boards that don't have USB-A so is safe to control + * regardless of system configuration. + */ + enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; + status = "okay"; + }; + + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + chg = <&chg_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; + + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm5 5 PWM_KHZ(1) PWM_POLARITY_NORMAL>; + rpm_min = <2200>; + rpm_start = <2200>; + rpm_max = <4200>; + tach = <&tach2>; + enable_gpio = <&gpio_fan_enable>; + }; + }; + + /* + * Declare unused GPIOs so that they are shut down + * and use minimal power + */ + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio3 3 0>, + <&gpio3 6 0>, + <&gpiod 7 0>, + <&gpiof 2 0>, + <&gpiof 3 0>; + }; +}; + +&thermistor_3V3_51K1_47K_4050B { + status = "okay"; +}; + +&adc_ec_vsense_pp3300_s5 { + /* + * Voltage divider on input has 47k upper and 220k lower legs with + * 2714 mV full-scale reading on the ADC. Apply the largest possible + * multiplier (without overflowing int32) to get the best possible + * approximation of the actual ratio, but derate by a factor of two to + * ensure unexpectedly high values won't overflow. + */ + mul = <(791261 / 2)>; + div = <(651975 / 2)>; +}; + +/* Set bus speeds for I2C */ +&i2c0_0 { + label = "I2C_EEPROM"; + clock-frequency = ; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c1_0 { + label = "I2C_SENSOR"; + clock-frequency = ; +}; + +&i2c3_0 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + /* + * BC1.2 interrupt is shared with TCPC, so + * IRQ is not specified here and handled by + * usb_c0_interrupt. + */ + }; + + chg_port0: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&i2c7_0 { + label = "I2C_BATTERY"; + clock-frequency = ; +}; + +&pwm5_gpb7 { + drive-open-drain; +}; + +&pwm5 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; + +/* Tachometer for fan speed measurement */ +&tach2 { + status = "okay"; + pinctrl-0 = <&ta2_1_in_gp73>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; + +/* + * Declare GPIOs that have leakage current caused by board issues here. NPCX ec + * will disable their input buffers before entering deep sleep and restore them + * after waking up automatically for better power consumption. + */ +&power_leakage_io { + leak-gpios = <&gpioa 4 0 + &gpiof 1 0>; +}; diff --git a/zephyr/program/nissa/pujjo/power_signals.dtsi b/zephyr/program/nissa/pujjo/power_signals.dtsi new file mode 100644 index 0000000000..1d2b23069d --- /dev/null +++ b/zephyr/program/nissa/pujjo/power_signals.dtsi @@ -0,0 +1,220 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <10>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpio4 0 0>; + output; + }; + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpiob 6 0>; + output; + }; + pwr-pg-ec-rsmrst-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpio9 4 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioa 6 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpio6 1 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpio4 3 0>; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpio3 7 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + pwr-adc-pp3300 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP3300 PWROK (from ADC)"; + enum-name = "PWR_DSW_PWROK"; + trigger-high = <&cmp_pp3300_s5_high>; + trigger-low = <&cmp_pp3300_s5_low>; + }; + pwr-adc-pp1p05 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP1P05 PWROK (from ADC)"; + enum-name = "PWR_PG_PP1P05"; + trigger-high = <&cmp_pp1p05_high>; + trigger-low = <&cmp_pp1p05_low>; + }; + + adc-cmp { + cmp_pp3300_s5_high: pp3300_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* + * This is 90% of nominal voltage considering voltage + * divider on ADC input. + */ + threshold-mv = <2448>; + }; + cmp_pp3300_s5_low: pp3300_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <2448>; + }; + cmp_pp1p05_high: pp1p05_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* Setting at 90% of nominal voltage */ + threshold-mv = <945>; + }; + cmp_pp1p05_low: pp1p05_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <945>; + }; + }; +}; + +/* + * Because the power signals directly reference the GPIOs, + * the correspinding named-gpios need to have no-auto-init set. + */ +&gpio_ec_soc_dsw_pwrok { + no-auto-init; +}; +&gpio_ec_soc_pch_pwrok_od { + no-auto-init; +}; +&gpio_ec_soc_rsmrst_l { + no-auto-init; +}; +&gpio_ec_soc_sys_pwrok { + no-auto-init; +}; +&gpio_ec_soc_vccst_pwrgd_od { + no-auto-init; +}; +&gpio_en_pp3300_s5 { + no-auto-init; +}; +&gpio_en_pp5000_s5 { + no-auto-init; +}; +&gpio_imvp91_vrrdy_od { + no-auto-init; +}; +&gpio_rsmrst_pwrgd_l { + no-auto-init; +}; +&gpio_slp_s0_l { + no-auto-init; +}; +&gpio_slp_s3_l { + no-auto-init; +}; +&gpio_slp_s4_l { + no-auto-init; +}; +&gpio_slp_sus_l { + no-auto-init; +}; +&gpio_sys_rst_odl { + no-auto-init; +}; diff --git a/zephyr/program/nissa/pujjo/project.conf b/zephyr/program/nissa/pujjo/project.conf new file mode 100644 index 0000000000..b9dc28b9cd --- /dev/null +++ b/zephyr/program/nissa/pujjo/project.conf @@ -0,0 +1,33 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_PUJJO=y + +# Sensor drivers +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM=y +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y + +# Increase PD max power from default +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250 + +# LED +CONFIG_PLATFORM_EC_LED_PWM=n +CONFIG_PLATFORM_EC_LED_COMMON=y + +# CBI +CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# DPS +CONFIG_PLATFORM_EC_USB_PD_DPS=n + +# BTN +CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y + +# Charger +CONFIG_PLATFORM_EC_RAA489000_TRICKLE_CHARGE_CURRENT_256MA=y \ No newline at end of file diff --git a/zephyr/program/nissa/pujjo/project.overlay b/zephyr/program/nissa/pujjo/project.overlay new file mode 100644 index 0000000000..e498775714 --- /dev/null +++ b/zephyr/program/nissa/pujjo/project.overlay @@ -0,0 +1,13 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../cbi.dtsi" + +#include "cbi.dtsi" +#include "generated.dtsi" +#include "keyboard.dtsi" +#include "motionsense.dtsi" +#include "overlay.dtsi" +#include "power_signals.dtsi" diff --git a/zephyr/program/nissa/pujjo/pujjo_vif.xml b/zephyr/program/nissa/pujjo/pujjo_vif.xml new file mode 100644 index 0000000000..b7d462584a --- /dev/null +++ b/zephyr/program/nissa/pujjo/pujjo_vif.xml @@ -0,0 +1,350 @@ + + + 3.19 + + USB-IF + VIF Editor + 3.2.4.0 + + Google + Pujjo + 1 + 0 + Port Product + End Product + + + + + + + + + 0 + Type-C® + + + DRP + DRP + + Charging Port + + + + + + + + + Revision 3 + + + + + + + 18D1 + 505A + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 15000 mW + Assured + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + FR_Swap not supported + + + + Over-Current Response + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + 0 msec + 3000 mA + + + + + + 60000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 20000 mV + + + + Variable + 4750 mV + 20000 mV + 3000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505A + 0000 + + + + + + + 1 + Type-C® + + + DRP + DRP + + Charging Port + + + + + + + + + Revision 3 + + + + + + + 18D1 + 505A + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 15000 mW + Assured + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + FR_Swap not supported + + + + Over-Current Response + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + 0 msec + 3000 mA + + + + + + 60000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 20000 mV + + + + Variable + 4750 mV + 20000 mV + 3000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505A + 0000 + + \ No newline at end of file diff --git a/zephyr/program/nissa/pujjo/src/charger.c b/zephyr/program/nissa/pujjo/src/charger.c new file mode 100644 index 0000000000..f1f1d57790 --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/charger.c @@ -0,0 +1,64 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charger.h" +#include "charger/isl923x_public.h" +#include "driver/tcpm/raa489000.h" +#include "driver/charger/isl923x.h" +#include "console.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" +#include "hooks.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = raa489000_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Pujjo does not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + raa489000_hibernate(0, true); + LOG_INF("Charger(s) hibernated"); + cflush(); +} + +static void charger_prochot_init(void) +{ + isl923x_set_ac_prochot(CHARGER_SOLO, 3500); + isl923x_set_dc_prochot(CHARGER_SOLO, 6528); +} +DECLARE_HOOK(HOOK_INIT, charger_prochot_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/pujjo/src/fan.c b/zephyr/program/nissa/pujjo/src/fan.c new file mode 100644 index 0000000000..97323a7edf --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/fan.c @@ -0,0 +1,43 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* + * Pujjo fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + if (val != FW_FAN_PRESENT) { + /* Disable the fan */ + fan_set_count(0); + } else { + /* Configure the fan enable GPIO */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), + GPIO_OUTPUT); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/pujjo/src/form_factor.c b/zephyr/program/nissa/pujjo/src/form_factor.c new file mode 100644 index 0000000000..6b02a258bc --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/form_factor.c @@ -0,0 +1,66 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "accelgyro.h" +#include "button.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/accelgyro_bmi323.h" +#include "driver/accelgyro_lsm6dsm.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "motionsense_sensors.h" +#include "motion_sense.h" +#include "tablet_mode.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +static bool use_alt_sensor; + +void motion_interrupt(enum gpio_signal signal) +{ + if (use_alt_sensor) + lsm6dsm_interrupt(signal); + else + bmi3xx_interrupt(signal); +} + +static void sensor_init(void) +{ + int ret; + uint32_t val; + /* check which base sensor is used for motion_interrupt */ + use_alt_sensor = cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); + + motion_sensors_check_ssfc(); + + /* Check if it's tablet or not */ + ret = cros_cbi_get_fw_config(FW_TABLET, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_TABLET); + return; + } + if (val == FW_TABLET_NOT_PRESENT) { + LOG_INF("Clamshell: disable motionsense function."); + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu)); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l), + GPIO_DISCONNECTED); + + LOG_INF("Clamshell: disable volume button function."); + button_disable_gpio(BUTTON_VOLUME_UP); + button_disable_gpio(BUTTON_VOLUME_DOWN); + } else { + LOG_INF("Tablet: Enable motionsense function."); + } +} +DECLARE_HOOK(HOOK_INIT, sensor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/nissa/pujjo/src/hdmi.c b/zephyr/program/nissa/pujjo/src/hdmi.c new file mode 100644 index 0000000000..9461e7c53e --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/hdmi.c @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "nissa_hdmi.h" + +__override void nissa_configure_hdmi_power_gpios(void) +{ + /* Pujjo needs to drive VCC enable but not core rails */ + nissa_configure_hdmi_vcc(); +} diff --git a/zephyr/program/nissa/pujjo/src/keyboard.c b/zephyr/program/nissa/pujjo/src/keyboard.c new file mode 100644 index 0000000000..1587030080 --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config pujjo_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_BRIGHTNESS_DOWN, /* T5 */ + TK_BRIGHTNESS_UP, /* T6 */ + TK_MICMUTE, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &pujjo_kb; +} diff --git a/zephyr/program/nissa/pujjo/src/led.c b/zephyr/program/nissa/pujjo/src/led.c new file mode 100644 index 0000000000..bd04af5a25 --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/led.c @@ -0,0 +1,134 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Pujjo specific PWM LED settings: there are 2 LEDs on each side of the board, + * each one can be controlled separately. The LED colors are white or amber, + * and the default behavior is tied to the charging process: both sides are + * amber while charging the battery and white when the battery is charged. + */ + +#include "common.h" +#include "led_onoff_states.h" +#include "led_common.h" +#include "gpio.h" + +#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) + +#define LED_OFF_LVL 1 +#define LED_ON_LVL 0 + +__override const int led_charge_lvl_1 = 5; + +__override const int led_charge_lvl_2 = 97; + +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; + +__override const struct led_descriptor + led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { + [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, + [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, 0.5 * LED_ONE_SEC } }, + [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, + 0.5 * LED_ONE_SEC } }, + [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, + }; + +const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED, + EC_LED_ID_POWER_LED }; + +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +__override void led_set_color_power(enum ec_led_colors color) +{ + if (color == EC_LED_COLOR_WHITE) + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led), + LED_ON_LVL); + else + /* LED_OFF and unsupported colors */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led), + LED_OFF_LVL); +} + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_AMBER: + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), + LED_ON_LVL); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), + LED_ON_LVL); + break; + case EC_LED_COLOR_RED: + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), + LED_ON_LVL); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), + LED_OFF_LVL); + break; + case EC_LED_COLOR_GREEN: + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), + LED_OFF_LVL); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), + LED_ON_LVL); + break; + default: /* LED_OFF and other unsupported colors */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), + LED_OFF_LVL); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), + LED_OFF_LVL); + break; + } +} + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + if (led_id == EC_LED_ID_BATTERY_LED) { + brightness_range[EC_LED_COLOR_RED] = 1; + brightness_range[EC_LED_COLOR_AMBER] = 1; + brightness_range[EC_LED_COLOR_GREEN] = 1; + } else if (led_id == EC_LED_ID_POWER_LED) { + brightness_range[EC_LED_COLOR_WHITE] = 1; + } +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + if (led_id == EC_LED_ID_BATTERY_LED) { + if (brightness[EC_LED_COLOR_RED] != 0) + led_set_color_battery(EC_LED_COLOR_RED); + else if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(EC_LED_COLOR_AMBER); + else if (brightness[EC_LED_COLOR_GREEN] != 0) + led_set_color_battery(EC_LED_COLOR_GREEN); + else + led_set_color_battery(LED_OFF); + } else if (led_id == EC_LED_ID_POWER_LED) { + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_power(EC_LED_COLOR_WHITE); + else + led_set_color_power(LED_OFF); + } + + return EC_SUCCESS; +} diff --git a/zephyr/program/nissa/pujjo/src/usbc.c b/zephyr/program/nissa/pujjo/src/usbc.c new file mode 100644 index 0000000000..5d3d94c243 --- /dev/null +++ b/zephyr/program/nissa/pujjo/src/usbc.c @@ -0,0 +1,242 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/isl923x_public.h" +#include "driver/retimer/anx7483_public.h" +#include "driver/tcpm/tcpci.h" +#include "driver/tcpm/raa489000.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C0_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, +}; + +int board_is_sourcing_vbus(int port) +{ + int regval; + + tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); + return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); +} + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + int old_port; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + + LOG_INF("New chg p%d", port); + + /* Disable all ports. */ + if (port == CHARGE_PORT_NONE) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW); + raa489000_enable_asgate(i, false); + } + + return EC_SUCCESS; + } + + /* Check if port is sourcing VBUS. */ + if (board_is_sourcing_vbus(port)) { + LOG_WRN("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i == port) + continue; + + if (tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW)) + LOG_WRN("p%d: sink path disable failed.", i); + raa489000_enable_asgate(i, false); + } + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + if (raa489000_enable_asgate(port, true) || + tcpc_write(port, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { + LOG_WRN("p%d: sink path enable failed.", port); + charger_discharge_on_ac(0); + return EC_ERROR_UNKNOWN; + } + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return EC_SUCCESS; +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + int regval; + + /* + * The interrupt line is shared between the TCPC and BC1.2 detector IC. + * Therefore, go out and actually read the alert registers to report the + * alert status. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { + /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ + if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_0; + } + } + return status; +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS */ + tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return; + + raa489000_set_output_current(port, rp); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return EC_ERROR_INVAL; + + /* Disable charging. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); + if (rv) + return rv; + + /* Our policy is not to source VBUS when the AP is off. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + return EC_ERROR_NOT_POWERED; + + /* Provide Vbus. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); + if (rv) + return rv; + + rv = raa489000_enable_asgate(port, true); + if (rv) + return rv; + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +void board_reset_pd_mcu(void) +{ + /* + * TODO(b:147316511): could send a reset command to the TCPC here + * if needed. + */ +} + +/* + * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible + * for an interrupt to be lost if one asserts the IRQ, the other does the same + * then the first releases it: there will only be one falling edge to trigger + * the interrupt, and the line will be held low. We handle this by running a + * deferred check after a falling edge to see whether the IRQ is still being + * asserted. If it is, we assume an interrupt may have been lost and we need + * to poll each chip for events again. + */ +#define USBC_INT_POLL_DELAY_US 5000 + +static void poll_c0_int(void); +DECLARE_DEFERRED(poll_c0_int); + +static void usbc_interrupt_trigger(int port) +{ + schedule_deferred_pd_interrupt(port); + usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); +} + +static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, + const struct deferred_data *ud) +{ + if (!gpio_pin_get_dt(gpio)) { + usbc_interrupt_trigger(port); + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); + } +} + +static void poll_c0_int(void) +{ + poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), + &poll_c0_int_data); +} + +void usb_interrupt(enum gpio_signal signal) +{ + int port; + const struct deferred_data *ud; + + if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { + port = 0; + ud = &poll_c0_int_data; + } + /* + * We've just been called from a falling edge, so there's definitely + * no lost IRQ right now. Cancel any pending check. + */ + hook_call_deferred(ud, -1); + /* Trigger polling of TCPC and BC1.2 in respective tasks */ + usbc_interrupt_trigger(port); + /* Check for lost interrupts in a bit */ + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); +} diff --git a/zephyr/program/nissa/src/board_power.c b/zephyr/program/nissa/src/board_power.c new file mode 100644 index 0000000000..d7fb4aeffe --- /dev/null +++ b/zephyr/program/nissa/src/board_power.c @@ -0,0 +1,169 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "gpio_signal.h" +#include "gpio/gpio.h" + +LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); + +#define X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS 5 + +static bool s0_stable; + +static void generate_ec_soc_dsw_pwrok_handler(int delay) +{ + int in_sig_val = power_signal_get(PWR_DSW_PWROK); + + if (in_sig_val != power_signal_get(PWR_EC_SOC_DSW_PWROK)) { + if (in_sig_val) + k_msleep(delay); + power_signal_set(PWR_EC_SOC_DSW_PWROK, 1); + } +} + +void board_ap_power_force_shutdown(void) +{ + int timeout_ms = X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS; + + if (s0_stable) { + /* Enable these power signals in case of sudden shutdown */ + power_signal_enable(PWR_DSW_PWROK); + power_signal_enable(PWR_PG_PP1P05); + } + + power_signal_set(PWR_EC_SOC_DSW_PWROK, 0); + power_signal_set(PWR_EC_PCH_RSMRST, 0); + + while (power_signal_get(PWR_RSMRST) == 0 && + power_signal_get(PWR_SLP_SUS) == 0 && timeout_ms > 0) { + k_msleep(1); + timeout_ms--; + } + if (power_signal_get(PWR_SLP_SUS) == 0) { + LOG_WRN("SLP_SUS is not deasserted! Assuming G3"); + } + + if (power_signal_get(PWR_RSMRST) == 1) { + LOG_WRN("RSMRST is not deasserted! Assuming G3"); + } + + power_signal_set(PWR_EN_PP3300_A, 0); + + power_signal_set(PWR_EN_PP5000_A, 0); + + timeout_ms = X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS; + while (power_signal_get(PWR_DSW_PWROK) && timeout_ms > 0) { + k_msleep(1); + timeout_ms--; + }; + + if (power_signal_get(PWR_DSW_PWROK)) + LOG_WRN("DSW_PWROK didn't go low! Assuming G3."); + + power_signal_disable(PWR_DSW_PWROK); + power_signal_disable(PWR_PG_PP1P05); + s0_stable = false; +} + +void board_ap_power_action_g3_s5(void) +{ + power_signal_enable(PWR_DSW_PWROK); + power_signal_enable(PWR_PG_PP1P05); + + LOG_DBG("Turning on PWR_EN_PP5000_A and PWR_EN_PP3300_A"); + power_signal_set(PWR_EN_PP5000_A, 1); + power_signal_set(PWR_EN_PP3300_A, 1); + + power_wait_signals_timeout(IN_PGOOD_ALL_CORE, + AP_PWRSEQ_DT_VALUE(wait_signal_timeout)); + + generate_ec_soc_dsw_pwrok_handler(AP_PWRSEQ_DT_VALUE(dsw_pwrok_delay)); + s0_stable = false; +} + +void board_ap_power_action_s3_s0(void) +{ + s0_stable = false; +} + +void board_ap_power_action_s0_s3(void) +{ + power_signal_enable(PWR_DSW_PWROK); + power_signal_enable(PWR_PG_PP1P05); + s0_stable = false; +} + +void board_ap_power_action_s0(void) +{ + if (s0_stable) { + return; + } + LOG_INF("Reaching S0"); + power_signal_disable(PWR_DSW_PWROK); + power_signal_disable(PWR_PG_PP1P05); + s0_stable = true; +} + +int board_ap_power_assert_pch_power_ok(void) +{ + /* Pass though PCH_PWROK */ + if (power_signal_get(PWR_PCH_PWROK) == 0) { + k_msleep(AP_PWRSEQ_DT_VALUE(pch_pwrok_delay)); + power_signal_set(PWR_PCH_PWROK, 1); + } + + return 0; +} + +bool board_ap_power_check_power_rails_enabled(void) +{ + return power_signal_get(PWR_EN_PP3300_A) && + power_signal_get(PWR_EN_PP5000_A) && + power_signal_get(PWR_EC_SOC_DSW_PWROK); +} + +int board_power_signal_get(enum power_signal signal) +{ + switch (signal) { + default: + LOG_ERR("Unknown signal for board get: %d", signal); + return -EINVAL; + + case PWR_ALL_SYS_PWRGD: + /* + * All system power is good. + * Checks that PWR_SLP_S3 is off, and + * the GPIO signal for all power good is set, + * and that the 1.05 volt line is ready. + */ + if (power_signal_get(PWR_SLP_S3)) { + return 0; + } + if (!gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_all_sys_pwrgd))) { + return 0; + } + if (!power_signal_get(PWR_PG_PP1P05)) { + return 0; + } + return 1; + } +} + +int board_power_signal_set(enum power_signal signal, int value) +{ + return -EINVAL; +} diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c new file mode 100644 index 0000000000..78f703ae49 --- /dev/null +++ b/zephyr/program/nissa/src/common.c @@ -0,0 +1,154 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "battery.h" +#include "charger.h" +#include "charge_state_v2.h" +#include "chipset.h" +#include "cros_cbi.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" + +#include "nissa_common.h" + +#include +LOG_MODULE_REGISTER(nissa, CONFIG_NISSA_LOG_LEVEL); + +static uint8_t cached_usb_pd_port_count; + +__override uint8_t board_get_usb_pd_port_count(void) +{ + __ASSERT(cached_usb_pd_port_count != 0, + "sub-board detection did not run before a port count request"); + if (cached_usb_pd_port_count == 0) + LOG_WRN("USB PD Port count not initialized!"); + return cached_usb_pd_port_count; +} + +static void board_power_change(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + /* + * Enable power to pen garage when system is active (safe even if no + * pen is present). + */ + const struct gpio_dt_spec *const pen_power_gpio = + GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_pen_x); + + switch (data.event) { + case AP_POWER_STARTUP: + gpio_pin_set_dt(pen_power_gpio, 1); + break; + case AP_POWER_SHUTDOWN: + gpio_pin_set_dt(pen_power_gpio, 0); + break; + default: + break; + } +} + +/* + * Initialise the USB PD port count, which + * depends on which sub-board is attached. + */ +static void board_setup_init(void) +{ + static struct ap_power_ev_callback cb; + + ap_power_ev_init_callback(&cb, board_power_change, + AP_POWER_STARTUP | AP_POWER_SHUTDOWN); + ap_power_ev_add_callback(&cb); + + switch (nissa_get_sb_type()) { + default: + cached_usb_pd_port_count = 1; + break; + + case NISSA_SB_C_A: + case NISSA_SB_C_LTE: + cached_usb_pd_port_count = 2; + break; + } +} +/* + * Make sure setup is done after EEPROM is readable. + */ +DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_INIT_I2C); + +__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); + + /* + * Assume charger overdraws by about 4%, keeping the actual draw + * within spec. This adjustment can be changed with characterization + * of actual hardware. + */ + icl = icl * 96 / 100; + charge_set_input_current_limit(icl, charge_mv); +} + +int pd_check_vconn_swap(int port) +{ + /* Allow VCONN swaps if the AP is on. */ + return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON); +} + +/* + * Count of chargers depends on sub board presence. + */ +__override uint8_t board_get_charger_chip_count(void) +{ + return board_get_usb_pd_port_count(); +} + +/* + * Retrieve sub-board type from FW_CONFIG. + */ +enum nissa_sub_board_type nissa_get_sb_type(void) +{ + static enum nissa_sub_board_type sb = NISSA_SB_UNKNOWN; + int ret; + uint32_t val; + + /* + * Return cached value. + */ + if (sb != NISSA_SB_UNKNOWN) + return sb; + + sb = NISSA_SB_NONE; /* Defaults to none */ + ret = cros_cbi_get_fw_config(FW_SUB_BOARD, &val); + if (ret != 0) { + LOG_WRN("Error retrieving CBI FW_CONFIG field %d", + FW_SUB_BOARD); + return sb; + } + switch (val) { + default: + LOG_WRN("No sub-board defined"); + break; + case FW_SUB_BOARD_1: + sb = NISSA_SB_C_A; + LOG_INF("SB: USB type C, USB type A"); + break; + + case FW_SUB_BOARD_2: + sb = NISSA_SB_C_LTE; + LOG_INF("SB: USB type C, WWAN LTE"); + break; + + case FW_SUB_BOARD_3: + sb = NISSA_SB_HDMI_A; + LOG_INF("SB: HDMI, USB type A"); + break; + } + return sb; +} diff --git a/zephyr/program/nissa/src/led.c b/zephyr/program/nissa/src/led.c new file mode 100644 index 0000000000..2617d0092d --- /dev/null +++ b/zephyr/program/nissa/src/led.c @@ -0,0 +1,52 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery LED control for nissa + */ +#include "common.h" +#include "ec_commands.h" +#include "led_common.h" +#include "led_onoff_states.h" +#include "led_pwm.h" + +__override const int led_charge_lvl_1 = 5; +__override const int led_charge_lvl_2 = 97; +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 3 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_RED: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_RED); + break; + case EC_LED_COLOR_GREEN: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_GREEN); + break; + case EC_LED_COLOR_AMBER: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); + break; + default: /* LED_OFF and other unsupported colors */ + set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); + break; + } +} diff --git a/zephyr/program/nissa/src/sub_board.c b/zephyr/program/nissa/src/sub_board.c new file mode 100644 index 0000000000..3ccbcd9325 --- /dev/null +++ b/zephyr/program/nissa/src/sub_board.c @@ -0,0 +1,298 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Nissa sub-board hardware configuration */ + +#include +#include +#include +#include +#include +#include + +#include "cros_board_info.h" +#include "driver/tcpm/tcpci.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "usb_charge.h" +#include "usb_pd.h" +#include "usbc/usb_muxes.h" +#include "task.h" + +#include "nissa_common.h" +#include "nissa_hdmi.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +#if NISSA_BOARD_HAS_HDMI_SUPPORT +static void hdmi_power_handler(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + /* Enable VCC on the HDMI port. */ + const struct gpio_dt_spec *s3_rail = + GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl); + /* Connect AP's DDC to sub-board (default is USB-C aux) */ + const struct gpio_dt_spec *ddc_select = + GPIO_DT_FROM_NODELABEL(gpio_hdmi_sel); + + switch (data.event) { + case AP_POWER_PRE_INIT: + LOG_DBG("Connecting HDMI DDC to sub-board"); + gpio_pin_set_dt(ddc_select, 1); + break; + case AP_POWER_STARTUP: + LOG_DBG("Enabling HDMI VCC"); + gpio_pin_set_dt(s3_rail, 1); + break; + case AP_POWER_SHUTDOWN: + LOG_DBG("Disabling HDMI VCC"); + gpio_pin_set_dt(s3_rail, 0); + break; + case AP_POWER_HARD_OFF: + LOG_DBG("Disconnecting HDMI sub-board DDC"); + gpio_pin_set_dt(ddc_select, 0); + break; + default: + LOG_ERR("Unhandled HDMI power event %d", data.event); + break; + } +} + +static void hdmi_hpd_interrupt(const struct device *device, + struct gpio_callback *callback, + gpio_port_pins_t pins) +{ + int state = gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_hpd_odl)); + + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_hdmi_hpd), state); + LOG_DBG("HDMI HPD changed state to %d", state); +} + +void nissa_configure_hdmi_rails(void) +{ +#if DT_NODE_EXISTS(GPIO_DT_FROM_ALIAS(gpio_en_rails_odl)) + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_rails_odl), + GPIO_OUTPUT_INACTIVE | GPIO_OPEN_DRAIN | + GPIO_PULL_UP | GPIO_ACTIVE_LOW); +#endif +} + +void nissa_configure_hdmi_vcc(void) +{ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl), + GPIO_OUTPUT_INACTIVE | GPIO_OPEN_DRAIN | + GPIO_ACTIVE_LOW); +} + +__overridable void nissa_configure_hdmi_power_gpios(void) +{ + nissa_configure_hdmi_rails(); +} + +#ifdef CONFIG_SOC_IT8XXX2 +/* + * On it8xxx2, the below condition will break the EC to enter deep doze mode + * (b:237717730): + * Enhance i2c (GPE0/E7, GPH1/GPH2 or GPA4/GPA5) is enabled and its clock and + * data pins aren't both at high level. + * + * Since HDMI+type A SKU doesn't use i2c4, disable it for better power number. + */ +#define I2C4_NODE DT_NODELABEL(i2c4) +#if DT_NODE_EXISTS(I2C4_NODE) +PINCTRL_DT_DEFINE(I2C4_NODE); + +/* disable i2c4 alternate function */ +static void soc_it8xxx2_disable_i2c4_alt(void) +{ + const struct pinctrl_dev_config *pcfg = + PINCTRL_DT_DEV_CONFIG_GET(I2C4_NODE); + + pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP); +} +#endif /* DT_NODE_EXISTS(I2C4_NODE) */ +#endif /* CONFIG_SOC_IT8XXX2 */ +#endif /* NISSA_BOARD_HAS_HDMI_SUPPORT */ + +static void lte_power_handler(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + /* Enable rails for S5 */ + const struct gpio_dt_spec *s5_rail = + GPIO_DT_FROM_ALIAS(gpio_en_sub_s5_rails); + switch (data.event) { + case AP_POWER_PRE_INIT: + LOG_DBG("Enabling LTE sub-board power rails"); + gpio_pin_set_dt(s5_rail, 1); + break; + case AP_POWER_HARD_OFF: + LOG_DBG("Disabling LTE sub-board power rails"); + gpio_pin_set_dt(s5_rail, 0); + break; + default: + LOG_ERR("Unhandled LTE power event %d", data.event); + break; + } +} + +/** + * Configure GPIOs (and other pin functions) that vary with present sub-board. + * + * The functions of some pins vary according to which sub-board is present + * (indicated by CBI fw_config); this function configures them according to the + * needs of the present sub-board. + */ +static void nereid_subboard_config(void) +{ + enum nissa_sub_board_type sb = nissa_get_sb_type(); + static struct ap_power_ev_callback power_cb; + + /* + * USB-A port: current limit output is configured by default and unused + * if this port is not present. VBUS enable must be configured if + * needed and is controlled by the usba-port-enable-pins driver. + */ + if (sb == NISSA_SB_C_A || sb == NISSA_SB_HDMI_A || + sb == NISSA_SB_NONE) { + /* + * Configure VBUS enable, default off. + * SB_NONE indicates missing fw_config; it's safe to enable VBUS + * control in this case since all that will happen is we turn + * off power to LTE, and it's useful to allow USB-A to work in + * such a configuration. + */ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus), + GPIO_OUTPUT_LOW); + } else { + /* Turn off unused pins */ + gpio_pin_configure_dt( + GPIO_DT_FROM_NODELABEL(gpio_sub_usb_a1_ilimit_sdp), + GPIO_DISCONNECTED); + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus), + GPIO_DISCONNECTED); + /* Disable second USB-A port enable GPIO */ + __ASSERT(USB_PORT_ENABLE_COUNT == 2, + "USB A port count != 2 (%d)", USB_PORT_ENABLE_COUNT); + usb_port_enable[1] = -1; + } + /* + * USB-C port: the default configuration has I2C on the I2C pins, + * but the interrupt line needs to be configured. + */ +#if CONFIG_USB_PD_PORT_MAX_COUNT > 1 + if (sb == NISSA_SB_C_A || sb == NISSA_SB_C_LTE) { + /* Configure interrupt input */ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), + GPIO_INPUT | GPIO_PULL_UP); + } else { + /* Port doesn't exist, doesn't need muxing */ + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_no_mux); + } +#endif + + switch (sb) { +#if NISSA_BOARD_HAS_HDMI_SUPPORT + case NISSA_SB_HDMI_A: { + /* + * HDMI: two outputs control power which must be configured to + * non-default settings, and HPD must be forwarded to the AP + * on another output pin. + */ + const struct gpio_dt_spec *hpd_gpio = + GPIO_DT_FROM_ALIAS(gpio_hpd_odl); + static struct gpio_callback hdmi_hpd_cb; + int rv, irq_key; + + nissa_configure_hdmi_power_gpios(); + +#if CONFIG_SOC_IT8XXX2 && DT_NODE_EXISTS(I2C4_NODE) + /* disable i2c4 alternate function for better power number */ + soc_it8xxx2_disable_i2c4_alt(); +#endif + + /* + * Control HDMI power according to AP power state. Some events + * won't do anything if the corresponding pin isn't configured, + * but that's okay. + */ + ap_power_ev_init_callback( + &power_cb, hdmi_power_handler, + AP_POWER_PRE_INIT | AP_POWER_HARD_OFF | + AP_POWER_STARTUP | AP_POWER_SHUTDOWN); + ap_power_ev_add_callback(&power_cb); + + /* + * Configure HPD input from sub-board; it's inverted by a buffer + * on the sub-board. + */ + gpio_pin_configure_dt(hpd_gpio, GPIO_INPUT | GPIO_ACTIVE_LOW); + /* Register interrupt handler for HPD changes */ + gpio_init_callback(&hdmi_hpd_cb, hdmi_hpd_interrupt, + BIT(hpd_gpio->pin)); + gpio_add_callback(hpd_gpio->port, &hdmi_hpd_cb); + rv = gpio_pin_interrupt_configure_dt(hpd_gpio, + GPIO_INT_EDGE_BOTH); + __ASSERT(rv == 0, + "HPD interrupt configuration returned error %d", rv); + /* + * Run the HPD handler once to ensure output is in sync. + * Lock interrupts to ensure that we don't cause desync if an + * HPD interrupt comes in between the internal read of the input + * and write to the output. + */ + irq_key = irq_lock(); + hdmi_hpd_interrupt(hpd_gpio->port, &hdmi_hpd_cb, + BIT(hpd_gpio->pin)); + irq_unlock(irq_key); + break; + } +#endif + case NISSA_SB_C_LTE: + /* + * LTE: Set up callbacks for enabling/disabling + * sub-board power on S5 state. + */ + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_sub_s5_rails), + GPIO_OUTPUT_INACTIVE); + /* Control LTE power when CPU entering or + * exiting S5 state. + */ + ap_power_ev_init_callback(&power_cb, lte_power_handler, + AP_POWER_HARD_OFF | + AP_POWER_PRE_INIT); + ap_power_ev_add_callback(&power_cb); + break; + + default: + break; + } +} +DECLARE_HOOK(HOOK_INIT, nereid_subboard_config, HOOK_PRIO_POST_FIRST); + +/* + * Enable interrupts + */ +static void board_init(void) +{ + /* + * Enable USB-C interrupts. + */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0)); +#if CONFIG_USB_PD_PORT_MAX_COUNT > 1 + if (board_get_usb_pd_port_count() == 2) + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1)); +#endif +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); + +/* Trigger shutdown by enabling the Z-sleep circuit */ +__override void board_hibernate_late(void) +{ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_slp_z), 1); + /* + * The system should hibernate, but there may be + * a small delay, so return. + */ +} diff --git a/zephyr/program/nissa/xivu/cbi.dtsi b/zephyr/program/nissa/xivu/cbi.dtsi new file mode 100644 index 0000000000..4149ea291c --- /dev/null +++ b/zephyr/program/nissa/xivu/cbi.dtsi @@ -0,0 +1,77 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* Xivu-specific fw_config fields. */ + nissa-fw-config { + /* + * FW_CONFIG field to enable WFC or not. + */ + wfc { + enum-name = "FW_WFC"; + start = <0>; + size = <1>; + + wfc-mipi { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_WFC_MIPI"; + value = <0>; + }; + wfc-absent { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_WFC_ABSENT"; + value = <1>; + }; + }; + + /* + * FW_CONFIG field to enable stylus or not. + */ + stylus { + enum-name = "FW_STYLUS"; + start = <1>; + size = <1>; + + stylus-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_STYLUS_PRESENT"; + value = <0>; + }; + stylus-absent { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_STYLUS_ABSENT"; + value = <1>; + }; + }; + /* + * FW_CONFIG field to indicate which sub-board + * is attached. + */ + sub-board { + enum-name = "FW_SUB_BOARD"; + start = <2>; + size = <2>; + + sub-board-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_SUB_BOARD_1"; + value = <0>; + }; + sub-board-2 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_SUB_BOARD_2"; + value = <1>; + }; + sub-board-3 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_SUB_BOARD_3"; + value = <2>; + }; + }; + +/delete-node/ fan; + }; + +}; diff --git a/zephyr/program/nissa/xivu/generated.dtsi b/zephyr/program/nissa/xivu/generated.dtsi new file mode 100644 index 0000000000..383054adf8 --- /dev/null +++ b/zephyr/program/nissa/xivu/generated.dtsi @@ -0,0 +1,291 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This file is auto-generated - do not edit! + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { + enum-name = "ADC_PP1050_PROC"; + io-channels = <&adc0 4>; + }; + adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { + enum-name = "ADC_PP3300_S5"; + io-channels = <&adc0 6>; + }; + adc_temp_sensor_1: temp_sensor_1 { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 0>; + }; + adc_temp_sensor_2: temp_sensor_2 { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 1>; + }; + adc_temp_sensor_3: temp_sensor_3 { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 10>; + }; + adc_temp_sensor_4: temp_sensor_4 { + enum-name = "ADC_TEMP_SENSOR_4"; + io-channels = <&adc0 11>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_acc_int_l: acc_int_l { + gpios = <&gpio5 0 GPIO_INPUT>; + }; + gpio_all_sys_pwrgd: all_sys_pwrgd { + gpios = <&gpioa 7 GPIO_INPUT>; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_ec_battery_pres_odl: ec_battery_pres_odl { + gpios = <&gpioa 3 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio7 4 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { + gpios = <&gpiod 3 GPIO_ODR_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_entering_rw: ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpio7 5 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_odl { + gpios = <&gpiob 0 GPIO_ODR_LOW>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpiof 1 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { + gpios = <&gpio6 1 GPIO_OUTPUT>; + }; + gpio_ec_acok_otg_c1: ec_acok_otg_c1 { + gpios = <&gpioe 4 GPIO_OUTPUT>; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpio8 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { + gpios = <&gpio7 2 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpioc 1 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioa 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpio7 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { + gpios = <&gpio3 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { + gpios = <&gpioa 4 GPIO_ODR_HIGH>; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_en_pp3300_s5: en_pp3300_s5 { + gpios = <&gpiob 6 GPIO_OUTPUT>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + }; + gpio_en_pp5000_pen_x: en_pp5000_pen_x { + gpios = <&gpioe 2 GPIO_OUTPUT>; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio4 0 GPIO_OUTPUT>; + }; + gpio_en_slp_z: en_slp_z { + gpios = <&gpioe 1 GPIO_OUTPUT>; + }; + gpio_en_usb_a0_vbus: en_usb_a0_vbus { + gpios = <&gpio9 1 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_acok_otg_c0: ec_acok_otg_c0 { + gpios = <&gpioc 6 GPIO_OUTPUT>; + }; + gpio_imu_int_l: imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { + gpios = <&gpio4 3 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_pen_detect_odl: pen_detect_odl { + gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { + gpios = <&gpio4 2 GPIO_INPUT>; + }; + gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { + gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpio9 7 GPIO_INPUT>; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + gpio_slp_s4_l: slp_s4_l { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpio6 2 GPIO_INPUT>; + }; + gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { + gpios = <&gpiod 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB2_ILIM_SEL"; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpioc 5 GPIO_ODR_HIGH>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpio9 5 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { + gpios = <&gpio3 3 GPIO_OUTPUT>; + enum-name = "GPIO_USB1_ILIM_SEL"; + }; + gpio_usb_c0_int_odl: usb_c0_int_odl { + gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; + }; + gpio_vccin_aux_vid0: vccin_aux_vid0 { + gpios = <&gpio9 2 GPIO_INPUT>; + }; + gpio_vccin_aux_vid1: vccin_aux_vid1 { + gpios = <&gpioe 3 GPIO_INPUT>; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_eeprom: ec_i2c_eeprom { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { + i2c-port = <&i2c5_1>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + }; + i2c_ec_i2c_batt: ec_i2c_batt { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_BATTERY"; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan4_gp41 + &adc0_chan6_gp34 + &adc0_chan10_gpe0 + &adc0_chan11_gpc7>; + pinctrl-names = "default"; +}; + +&i2c0_0 { + status = "okay"; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c1_0 { + status = "okay"; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; +}; + +&i2c3_0 { + status = "okay"; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; +}; + +&i2c5_1 { + status = "okay"; + pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>; + pinctrl-names = "default"; +}; + +&i2c7_0 { + status = "okay"; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/xivu/keyboard.dtsi b/zephyr/program/nissa/xivu/keyboard.dtsi new file mode 100644 index 0000000000..5248c4aaff --- /dev/null +++ b/zephyr/program/nissa/xivu/keyboard.dtsi @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/xivu/led_pins.dtsi b/zephyr/program/nissa/xivu/led_pins.dtsi new file mode 100644 index 0000000000..d85004a0c9 --- /dev/null +++ b/zephyr/program/nissa/xivu/led_pins.dtsi @@ -0,0 +1,94 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwm_pins { + compatible = "cros-ec,pwm-pin-config"; + pwm_led_y_c0: pwm_led_y_c0 { + #led-pin-cells = <1>; + pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; + }; + + pwm_led_w_c0: pwm_led_w_c0 { + #led-pin-cells = <1>; + pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; + }; + + pwm_led_y_c1: pwm_led_y_c1 { + #led-pin-cells = <1>; + pwms = <&pwm6 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; + }; + + pwm_led_w_c1: pwm_led_w_c1 { + #led-pin-cells = <1>; + pwms = <&pwm1 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&pwm_led_y_c0 0>, + <&pwm_led_y_c1 0>, + <&pwm_led_w_c0 0>, + <&pwm_led_w_c1 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&pwm_led_y_c0 1>, + <&pwm_led_y_c1 1>, + <&pwm_led_w_c0 0>, + <&pwm_led_w_c1 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&pwm_led_y_c0 0>, + <&pwm_led_y_c1 0>, + <&pwm_led_w_c0 1>, + <&pwm_led_w_c1 1>; + }; + }; +}; + +/* LED2 */ +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* LED3 */ +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* LED1 */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* LED0 */ +&pwm6 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm6_gpc0>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/xivu/led_policy.dtsi b/zephyr/program/nissa/xivu/led_policy.dtsi new file mode 100644 index 0000000000..562e361ec5 --- /dev/null +++ b/zephyr/program/nissa/xivu/led_policy.dtsi @@ -0,0 +1,122 @@ +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = <0 94>; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-charge-lvl-2 { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Near Full) */ + batt-lvl = <95 97>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <11 100>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= 10%) */ + batt-lvl = <0 10>; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-error-s0 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + /* White 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + }; +}; diff --git a/zephyr/program/nissa/xivu/motionsense.dtsi b/zephyr/program/nissa/xivu/motionsense.dtsi new file mode 100644 index 0000000000..332252c4ef --- /dev/null +++ b/zephyr/program/nissa/xivu/motionsense.dtsi @@ -0,0 +1,156 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * Interrupt bindings for sensor devices. + */ + lsm6dso-int = &base_accel; + lis2dw12-int = &lid_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lsm6dso_accel_data: lsm6dso-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lsm6dso_gyro_data: lsm6dso-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + * TODO(b/238139272): The first entries of the array must be + * accelerometers,then gyroscope. Fix this dependency in the DTS + * processing which makes the devicetree entries independent. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,lsm6dso-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&lsm6dso_accel_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,lsm6dso-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dso_gyro_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/nissa/xivu/overlay.dtsi b/zephyr/program/nissa/xivu/overlay.dtsi new file mode 100644 index 0000000000..de45db75e7 --- /dev/null +++ b/zephyr/program/nissa/xivu/overlay.dtsi @@ -0,0 +1,357 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_odl; + int-wp = &int_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; + + batteries { + default_battery: smp_c31n2005 { + compatible = "smp,c31n2005", "battery-smart"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_power_button + &int_lid_open + >; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_imu_int_l>; + flags = ; + handler = "lsm6dso_interrupt"; + }; + int_vol_down: vol_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_vol_up: vol_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_usb_c0: usb_c0 { + irq-pin = <&gpio_usb_c0_int_odl>; + flags = ; + handler = "usb_interrupt"; + }; + int_usb_c1: usb_c1 { + irq-pin = <&gpio_sb_1>; + flags = ; + handler = "usb_interrupt"; + }; + }; + + named-gpios { + gpio_sb_1: sb-1 { + gpios = <&gpio0 2 GPIO_PULL_UP>; + no-auto-init; + }; + + gpio_sb_2: sb-2 { + gpios = <&gpiod 4 GPIO_OUTPUT>; + no-auto-init; + }; + + /* + * Set I2C pins for type C sub-board to be low voltage (I2C5_1). + * We do this for all boards, since the pins are 3.3V tolerant, + * and the only 2 types of sub-boards used on nivviks both have + * type-C ports on them. + */ + gpio_sb_3: sb-3 { + gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; + no-auto-init; + }; + gpio_sb_4: sb-4 { + gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + no-auto-init; + }; + }; + + /* + * Aliases used for sub-board GPIOs. + */ + aliases { + /* + * Input GPIO when used with type-C port 1 + */ + gpio-usb-c1-int-odl = &gpio_sb_1; + gpio-en-rails-odl = &gpio_sb_1; + /* + * Sub-board with type A USB, enable. + */ + gpio-en-usb-a1-vbus = &gpio_sb_2; + /* + * Enable S5 rails for LTE sub-board + */ + gpio-en-sub-s5-rails = &gpio_sb_2; + }; + + temp_memory: memory { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_1>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_2>; + }; + temp_charger1: charger1 { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_3>; + }; + temp_charger2: charger2 { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_4>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + memory { + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_memory>; + }; + ambient { + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_ambient>; + }; + charger1 { + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_charger1>; + }; + charger2 { + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_charger2>; + }; + }; + + usba { + compatible = "cros-ec,usba-port-enable-pins"; + /* + * sb_2 is only configured as GPIO when USB-A1 is present, + * but it's still safe to control when disabled. + * + * ILIM_SEL pins are referred to by legacy enum name, + * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on + * sub-boards that don't have USB-A so is safe to control + * regardless of system configuration. + */ + enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; + status = "okay"; + }; + + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + chg = <&chg_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + /* + * TODO(b:211693800): port1 may not be present on some + * sub-boards. + */ + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + chg = <&chg_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; + }; + usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio8 5 0>, + <&gpio3 6 0>, + <&gpiod 7 0>, + <&gpio6 0 0>, + <&gpiof 2 0>, + <&gpiof 3 0>; + }; +}; + +&thermistor_3V3_51K1_47K_4050B { + status = "okay"; +}; + +&adc_ec_vsense_pp3300_s5 { + /* + * Voltage divider on input has 47k upper and 220k lower legs with + * 2714 mV full-scale reading on the ADC. Apply the largest possible + * multiplier (without overflowing int32) to get the best possible + * approximation of the actual ratio, but derate by a factor of two to + * ensure unexpectedly high values won't overflow. + */ + mul = <(791261 / 2)>; + div = <(651975 / 2)>; +}; + +/* Set bus speeds for I2C */ +&i2c0_0 { + label = "I2C_EEPROM"; + clock-frequency = ; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c1_0 { + label = "I2C_SENSOR"; + clock-frequency = ; +}; + +&i2c3_0 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + /* + * BC1.2 interrupt is shared with TCPC, so + * IRQ is not specified here and handled by + * usb_c0_interrupt. + */ + }; + + chg_port0: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&i2c5_1 { + label = "I2C_SUB_C1_TCPC"; + clock-frequency = ; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port1: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; + + anx7483_mux_1: anx7483-mux-1@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "anx7483_set_default_tuning"; + }; +}; + +&i2c7_0 { + label = "I2C_BATTERY"; + clock-frequency = ; +}; + +&pwm6 { + status = "okay"; + pinctrl-0 = <&pwm6_gpc0>; + pinctrl-names = "default"; +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/xivu/power_signals.dtsi b/zephyr/program/nissa/xivu/power_signals.dtsi new file mode 100644 index 0000000000..1d2b23069d --- /dev/null +++ b/zephyr/program/nissa/xivu/power_signals.dtsi @@ -0,0 +1,220 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <10>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpio4 0 0>; + output; + }; + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpiob 6 0>; + output; + }; + pwr-pg-ec-rsmrst-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpio9 4 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioa 6 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpio6 1 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpio4 3 0>; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpio3 7 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + pwr-adc-pp3300 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP3300 PWROK (from ADC)"; + enum-name = "PWR_DSW_PWROK"; + trigger-high = <&cmp_pp3300_s5_high>; + trigger-low = <&cmp_pp3300_s5_low>; + }; + pwr-adc-pp1p05 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP1P05 PWROK (from ADC)"; + enum-name = "PWR_PG_PP1P05"; + trigger-high = <&cmp_pp1p05_high>; + trigger-low = <&cmp_pp1p05_low>; + }; + + adc-cmp { + cmp_pp3300_s5_high: pp3300_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* + * This is 90% of nominal voltage considering voltage + * divider on ADC input. + */ + threshold-mv = <2448>; + }; + cmp_pp3300_s5_low: pp3300_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <2448>; + }; + cmp_pp1p05_high: pp1p05_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* Setting at 90% of nominal voltage */ + threshold-mv = <945>; + }; + cmp_pp1p05_low: pp1p05_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <945>; + }; + }; +}; + +/* + * Because the power signals directly reference the GPIOs, + * the correspinding named-gpios need to have no-auto-init set. + */ +&gpio_ec_soc_dsw_pwrok { + no-auto-init; +}; +&gpio_ec_soc_pch_pwrok_od { + no-auto-init; +}; +&gpio_ec_soc_rsmrst_l { + no-auto-init; +}; +&gpio_ec_soc_sys_pwrok { + no-auto-init; +}; +&gpio_ec_soc_vccst_pwrgd_od { + no-auto-init; +}; +&gpio_en_pp3300_s5 { + no-auto-init; +}; +&gpio_en_pp5000_s5 { + no-auto-init; +}; +&gpio_imvp91_vrrdy_od { + no-auto-init; +}; +&gpio_rsmrst_pwrgd_l { + no-auto-init; +}; +&gpio_slp_s0_l { + no-auto-init; +}; +&gpio_slp_s3_l { + no-auto-init; +}; +&gpio_slp_s4_l { + no-auto-init; +}; +&gpio_slp_sus_l { + no-auto-init; +}; +&gpio_sys_rst_odl { + no-auto-init; +}; diff --git a/zephyr/program/nissa/xivu/project.conf b/zephyr/program/nissa/xivu/project.conf new file mode 100644 index 0000000000..fe56a9d562 --- /dev/null +++ b/zephyr/program/nissa/xivu/project.conf @@ -0,0 +1,17 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_XIVU=y +CONFIG_PLATFORM_EC_OCPC=y +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=n +CONFIG_PLATFORM_EC_LED_DT=y + +# USBC +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 + +# Battery +CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/program/nissa/xivu/project.overlay b/zephyr/program/nissa/xivu/project.overlay new file mode 100644 index 0000000000..a7c5b7e9e7 --- /dev/null +++ b/zephyr/program/nissa/xivu/project.overlay @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../cbi.dtsi" + +#include "cbi.dtsi" +#include "generated.dtsi" +#include "keyboard.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" +#include "overlay.dtsi" +#include "power_signals.dtsi" diff --git a/zephyr/program/nissa/xivu/src/charger.c b/zephyr/program/nissa/xivu/src/charger.c new file mode 100644 index 0000000000..5021a55758 --- /dev/null +++ b/zephyr/program/nissa/xivu/src/charger.c @@ -0,0 +1,69 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charger.h" +#include "charger/isl923x_public.h" +#include "console.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = raa489000_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Xivu does not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present_p0 = 0; + int extpower_present_p1 = 0; + + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; + + if (pd_is_connected(0)) + extpower_present_p0 = extpower_is_present(); + else if (pd_is_connected(1)) + extpower_present_p1 = extpower_is_present(); + + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_acok_otg_c0), + extpower_present_p0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_acok_otg_c1), + extpower_present_p1); +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + if (board_get_usb_pd_port_count() == 2) + raa489000_hibernate(CHARGER_SECONDARY, true); + raa489000_hibernate(CHARGER_PRIMARY, true); + LOG_INF("Charger(s) hibernated"); + cflush(); +} diff --git a/zephyr/program/nissa/xivu/src/keyboard.c b/zephyr/program/nissa/xivu/src/keyboard.c new file mode 100644 index 0000000000..ef799fb1d2 --- /dev/null +++ b/zephyr/program/nissa/xivu/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config xivu_kb_legacy = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* 8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &xivu_kb_legacy; +} diff --git a/zephyr/program/nissa/xivu/src/usbc.c b/zephyr/program/nissa/xivu/src/usbc.c new file mode 100644 index 0000000000..c4ba75f741 --- /dev/null +++ b/zephyr/program/nissa/xivu/src/usbc.c @@ -0,0 +1,362 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/isl923x_public.h" +#include "driver/retimer/anx7483_public.h" +#include "driver/tcpm/tcpci.h" +#include "driver/tcpm/raa489000.h" +#include "temp_sensor/temp_sensor.h" +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C0_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, + { /* sub-board */ + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, +}; + +int board_is_sourcing_vbus(int port) +{ + int regval; + + tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); + return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); +} + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + int old_port; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + + LOG_INF("New chg p%d", port); + + /* Disable all ports. */ + if (port == CHARGE_PORT_NONE) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW); + raa489000_enable_asgate(i, false); + } + + return EC_SUCCESS; + } + + /* Check if port is sourcing VBUS. */ + if (board_is_sourcing_vbus(port)) { + LOG_WRN("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i == port) + continue; + + if (tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW)) + LOG_WRN("p%d: sink path disable failed.", i); + raa489000_enable_asgate(i, false); + } + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + if (raa489000_enable_asgate(port, true) || + tcpc_write(port, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { + LOG_WRN("p%d: sink path enable failed.", port); + charger_discharge_on_ac(0); + return EC_ERROR_UNKNOWN; + } + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return EC_SUCCESS; +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + int regval; + + /* + * The interrupt line is shared between the TCPC and BC1.2 detector IC. + * Therefore, go out and actually read the alert registers to report the + * alert status. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { + /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ + if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_0; + } + } + + if (board_get_usb_pd_port_count() == 2 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { + /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ + if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_1; + } + } + + return status; +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS */ + tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return; + + raa489000_set_output_current(port, rp); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return EC_ERROR_INVAL; + + /* Disable charging. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); + if (rv) + return rv; + + /* Our policy is not to source VBUS when the AP is off. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + return EC_ERROR_NOT_POWERED; + + /* Provide Vbus. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); + if (rv) + return rv; + + rv = raa489000_enable_asgate(port, true); + if (rv) + return rv; + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +void board_reset_pd_mcu(void) +{ + /* + * TODO(b:147316511): could send a reset command to the TCPC here + * if needed. + */ +} + +/* + * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible + * for an interrupt to be lost if one asserts the IRQ, the other does the same + * then the first releases it: there will only be one falling edge to trigger + * the interrupt, and the line will be held low. We handle this by running a + * deferred check after a falling edge to see whether the IRQ is still being + * asserted. If it is, we assume an interrupt may have been lost and we need + * to poll each chip for events again. + */ +#define USBC_INT_POLL_DELAY_US 5000 + +static void poll_c0_int(void); +DECLARE_DEFERRED(poll_c0_int); +static void poll_c1_int(void); +DECLARE_DEFERRED(poll_c1_int); + +static void usbc_interrupt_trigger(int port) +{ + schedule_deferred_pd_interrupt(port); + usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); +} + +static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, + const struct deferred_data *ud) +{ + if (!gpio_pin_get_dt(gpio)) { + usbc_interrupt_trigger(port); + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); + } +} + +static void poll_c0_int(void) +{ + poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), + &poll_c0_int_data); +} + +static void poll_c1_int(void) +{ + poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), + &poll_c1_int_data); +} + +void usb_interrupt(enum gpio_signal signal) +{ + int port; + const struct deferred_data *ud; + + if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { + port = 0; + ud = &poll_c0_int_data; + } else { + port = 1; + ud = &poll_c1_int_data; + } + /* + * We've just been called from a falling edge, so there's definitely + * no lost IRQ right now. Cancel any pending check. + */ + hook_call_deferred(ud, -1); + /* Trigger polling of TCPC and BC1.2 in respective tasks */ + usbc_interrupt_trigger(port); + /* Check for lost interrupts in a bit */ + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); +} + +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + charge_ma = (charge_ma * 90) / 100; + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} + +struct chg_curr_step { + int on; + int off; + int curr_ma; +}; + +static const struct chg_curr_step chg_curr_table[] = { + { .on = 0, .off = 36, .curr_ma = 2800 }, + { .on = 46, .off = 36, .curr_ma = 1500 }, + { .on = 48, .off = 38, .curr_ma = 1000 }, +}; + +/* All charge current tables must have the same number of levels */ +#define NUM_CHG_CURRENT_LEVELS ARRAY_SIZE(chg_curr_table) + +int charger_profile_override(struct charge_state_data *curr) +{ + int rv; + int chg_temp_c; + int current; + int thermal_sensor0; + static int current_level; + static int prev_tmp; + + /* + * Precharge must be executed when communication is failed on + * dead battery. + */ + if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE)) + return 0; + + current = curr->requested_current; + + rv = temp_sensor_read( + TEMP_SENSOR_ID_BY_DEV(DT_NODELABEL(temp_charger1)), + &thermal_sensor0); + chg_temp_c = K_TO_C(thermal_sensor0); + + if (rv != EC_SUCCESS) + return 0; + + if (chipset_in_state(CHIPSET_STATE_ON)) { + if (chg_temp_c < prev_tmp) { + if (chg_temp_c <= chg_curr_table[current_level].off) + current_level = current_level - 1; + } else if (chg_temp_c > prev_tmp) { + if (chg_temp_c >= chg_curr_table[current_level + 1].on) + current_level = current_level + 1; + } + /* + * Prevent level always minus 0 or over table steps. + */ + if (current_level < 0) + current_level = 0; + else if (current_level >= NUM_CHG_CURRENT_LEVELS) + current_level = NUM_CHG_CURRENT_LEVELS - 1; + + prev_tmp = chg_temp_c; + current = chg_curr_table[current_level].curr_ma; + + curr->requested_current = MIN(curr->requested_current, current); + } + return 0; +} + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} diff --git a/zephyr/program/nissa/yaviks/cbi.dtsi b/zephyr/program/nissa/yaviks/cbi.dtsi new file mode 100644 index 0000000000..c5716cbd37 --- /dev/null +++ b/zephyr/program/nissa/yaviks/cbi.dtsi @@ -0,0 +1,99 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* Yaviks-specific fw_config fields. */ + nissa-fw-config { + /* + * FW_CONFIG field for multiple wi-fi SAR. + * + * start = <2>; + * size = <2>; + */ + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <4>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + + /* + * FW_CONFIG field to indicate which keyboard layout + * should be used. + */ + keyboard { + enum-name = "FW_KB_LAYOUT"; + start = <5>; + size = <1>; + + layout-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_LAYOUT_DEFAULT"; + value = <0>; + default; + }; + layout-2 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_LAYOUT_US2"; + value = <1>; + }; + }; + + /* + * FW_CONFIG field to indicate which keyboard layout + * should be used. + */ + keyboard-backlight { + enum-name = "FW_KB_BACKLIGHT"; + start = <6>; + size = <1>; + + without-keyboard-backlight { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BACKLIGHT_OFF"; + value = <1>; + }; + with-keyboard-backlight { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BACKLIGHT_ON"; + value = <0>; + default; + }; + }; + + /* + * FW_CONFIG field for multiple touch panel. + * + * start = <7>; + * size = <2>; + */ + + /* + * FW_CONFIG field for multiple storage. + * + * start = <31>; + * size = <1>; + */ + }; +}; diff --git a/zephyr/program/nissa/yaviks/gpio.dtsi b/zephyr/program/nissa/yaviks/gpio.dtsi new file mode 100644 index 0000000000..dae1d641cd --- /dev/null +++ b/zephyr/program/nissa/yaviks/gpio.dtsi @@ -0,0 +1,232 @@ +/* + * Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { + enum-name = "ADC_PP1050_PROC"; + io-channels = <&adc0 14>; + }; + adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { + enum-name = "ADC_PP3300_S5"; + io-channels = <&adc0 0>; + }; + adc_temp_sensor_1: temp_sensor_1 { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 2>; + }; + adc_temp_sensor_2: temp_sensor_2 { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 3>; + }; + adc_temp_sensor_3: temp_sensor_3 { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 13>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_all_sys_pwrgd: all_sys_pwrgd { + gpios = <&gpiob 7 GPIO_INPUT>; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioh 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpiog 1 GPIO_INPUT>; + }; + gpio_ec_battery_pres_odl: ec_battery_pres_odl { + gpios = <&gpioi 4 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioj 5 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { + gpios = <&gpiok 4 GPIO_ODR_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_entering_rw: ec_entering_rw { + gpios = <&gpioc 7 GPIO_OUTPUT>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpioh 1 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_odl { + gpios = <&gpiob 2 GPIO_ODR_LOW>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { + gpios = <&gpiol 7 GPIO_OUTPUT>; + no-auto-init; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpiod 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { + gpios = <&gpiod 6 GPIO_ODR_HIGH>; + no-auto-init; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpiob 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioh 0 GPIO_OUTPUT>; + no-auto-init; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpiok 2 GPIO_OUTPUT>; + }; + gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { + gpios = <&gpiof 2 GPIO_OUTPUT>; + no-auto-init; + }; + gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { + gpios = <&gpioe 5 GPIO_ODR_HIGH>; + no-auto-init; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 6 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_en_pp3300_s5: en_pp3300_s5 { + gpios = <&gpioc 5 GPIO_OUTPUT>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + no-auto-init; + }; + gpio_en_pp5000_pen_x: en_pp5000_pen_x { + gpios = <&gpiob 5 GPIO_OUTPUT>; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpiok 5 GPIO_OUTPUT>; + no-auto-init; + }; + gpio_en_slp_z: en_slp_z { + gpios = <&gpiok 3 GPIO_OUTPUT>; + }; + gpio_en_usb_a0_vbus: en_usb_a0_vbus { + gpios = <&gpiol 6 GPIO_OUTPUT>; + }; + gpio_en_usb_c0_cc1_vconn: en_usb_c0_cc1_vconn { + gpios = <&gpioh 4 GPIO_OUTPUT>; + }; + gpio_en_usb_c0_cc2_vconn: en_usb_c0_cc2_vconn { + gpios = <&gpioh 6 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { + gpios = <&gpioj 4 GPIO_INPUT>; + no-auto-init; + }; + gpio_lid_open: lid_open { + gpios = <&gpiof 3 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_pen_detect_odl: pen_detect_odl { + gpios = <&gpioj 1 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { + gpios = <&gpiod 3 GPIO_INPUT>; + }; + gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { + gpios = <&gpioe 3 GPIO_INPUT>; + }; + gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { + gpios = <&gpioe 1 GPIO_INPUT_PULL_UP>; + no-auto-init; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpioe 4 GPIO_INPUT>; + no-auto-init; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioh 3 GPIO_INPUT>; + no-auto-init; + }; + gpio_slp_s4_l: slp_s4_l { + gpios = <&gpioi 5 GPIO_INPUT>; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpiog 2 GPIO_INPUT>; + no-auto-init; + }; + gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { + gpios = <&gpiof 1 GPIO_OUTPUT>; + enum-name = "GPIO_USB2_ILIM_SEL"; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpiod 1 GPIO_ODR_HIGH>; + no-auto-init; + }; + gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { + gpios = <&gpiol 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB1_ILIM_SEL"; + }; + gpio_usb_c0_frs: usb_c0_frs { + gpios = <&gpioc 4 GPIO_OUTPUT>; + }; + gpio_usb_c0_int_odl: usb_c0_int_odl { + gpios = <&gpiok 0 GPIO_INPUT_PULL_UP>; + }; + gpio_vccin_aux_vid0: vccin_aux_vid0 { + gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_vccin_aux_vid1: vccin_aux_vid1 { + gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_c1_charger_led_white_l: c1_charger_led_white_l { + gpios = <&gpiol 4 GPIO_OUTPUT_HIGH>; + }; + gpio_c1_charger_led_amber_l: c1_charger_led_amber_l { + gpios = <&gpiod 4 GPIO_OUTPUT_HIGH>; + }; + gpio_c0_charger_led_white_l: c0_charger_led_white_l { + gpios = <&gpioc 3 GPIO_OUTPUT_HIGH>; + }; + gpio_c0_charger_led_amber_l: c0_charger_led_amber_l { + gpios = <&gpioj 7 GPIO_OUTPUT_HIGH>; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_eeprom: ec_i2c_eeprom { + i2c-port = <&i2c0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_ec_i2c_batt: ec_i2c_batt { + i2c-port = <&i2c1>; + enum-names = "I2C_PORT_BATTERY"; + }; + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c2>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { + i2c-port = <&i2c4>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + }; + i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { + i2c-port = <&i2c5>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + }; +}; diff --git a/zephyr/program/nissa/yaviks/keyboard.dtsi b/zephyr/program/nissa/yaviks/keyboard.dtsi new file mode 100644 index 0000000000..04a620767a --- /dev/null +++ b/zephyr/program/nissa/yaviks/keyboard.dtsi @@ -0,0 +1,22 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + /* + * Use 324 Hz so that 32Khz clock source is used, + * which is not gated in power saving mode. + */ + pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm0 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm0_gpa0_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/yaviks/overlay.dtsi b/zephyr/program/nissa/yaviks/overlay.dtsi new file mode 100644 index 0000000000..d768116444 --- /dev/null +++ b/zephyr/program/nissa/yaviks/overlay.dtsi @@ -0,0 +1,402 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_odl; + int-wp = &int_wp_l; + /* + * USB-C: interrupt input. + * I2C pins are on i2c_ec_i2c_sub_usb_c1 + */ + gpio-usb-c1-int-odl = &gpio_sb_1; + /* + * USB-A: VBUS enable output + * LTE: power enable output + */ + gpio-en-usb-a1-vbus = &gpio_sb_2; + /* + * Enable S5 rails for LTE sub-board + */ + gpio-en-sub-s5-rails = &gpio_sb_2; + }; + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; + + batteries { + default_battery: cosmx { + compatible = "cosmx,gh02047xl", "battery-smart"; + }; + dynapack_atl_gh02047xl { + compatible = "dynapack,atl_gh02047xl", "battery-smart"; + }; + dynapack_cosmx_gh02047xl { + compatible = "dynapack,cosmx_gh02047xl", "battery-smart"; + }; + smp_coslight_gh02047xl { + compatible = "smp,coslight_gh02047xl", "battery-smart"; + }; + smp_highpower_gh02047xl { + compatible = "smp,highpower_gh02047xl", "battery-smart"; + }; + default_battery_3s:cosmx_si03058xl { + compatible = "cosmx,si03058xl", "battery-smart"; + }; + smp_highpower_si03058xl { + compatible = "smp,highpower_si03058xl", "battery-smart"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_power_button + &int_lid_open + >; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_usb_c0: usb_c0 { + irq-pin = <&gpio_usb_c0_int_odl>; + flags = ; + handler = "usb_c0_interrupt"; + }; + int_usb_c1: usb_c1 { + irq-pin = <&gpio_sb_1>; + flags = ; + handler = "usb_c1_interrupt"; + }; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = <&gpioa 7 0>, + <&gpioc 0 0>, + <&gpioc 6 0>, + <&gpiod 7 0>, + <&gpioh 2 0>, + <&gpioi 6 0>, + <&gpioi 7 0>, + <&gpioj 0 0>, + <&gpioj 3 0>, + <&gpiok 7 GPIO_OUTPUT>; + }; + + named-gpios { + /* + * EC doesn't take any specific action on CC/SBU disconnect due to + * fault, but this definition is useful for hardware testing. + */ + gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl { + gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>; + }; + + gpio_sb_1: sb_1 { + gpios = <&gpioe 6 0>; + no-auto-init; + }; + gpio_sb_2: sb_2 { + gpios = <&gpiof 0 0>; + no-auto-init; + }; + gpio_fan_enable: fan-enable { + gpios = <&gpioa 1 GPIO_OUTPUT>; + no-auto-init; + }; + }; + + temp_cpu: cpu { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_1>; + }; + temp_5v_regulator: 5v_regulator { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_2>; + }; + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_3>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + cpu { + temp_fan_off = <45>; + temp_fan_max = <60>; + temp_host_high = <75>; + temp_host_halt = <85>; + temp_host_release_high = <65>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_cpu>; + }; + 5v_regulator { + temp_fan_off = <50>; + temp_fan_max = <65>; + temp_host_high = <75>; + temp_host_halt = <85>; + temp_host_release_high = <65>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_5v_regulator>; + }; + charger { + temp_fan_off = <50>; + temp_fan_max = <65>; + temp_host_high = <80>; + temp_host_halt = <85>; + temp_host_release_high = <75>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_charger>; + }; + }; + + usba { + compatible = "cros-ec,usba-port-enable-pins"; + /* + * sb_2 is only configured as GPIO when USB-A1 is present, + * but it's still safe to control when disabled. + * + * ILIM_SEL pins are referred to by legacy enum name, + * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on + * sub-boards that don't have USB-A so is safe to control + * regardless of system configuration. + */ + enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; + status = "okay"; + }; + + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + chg = <&chg_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + chg = <&chg_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; + }; + usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + tcpci_mux_1: tcpci-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; + }; + + fans { + compatible = "cros-ec,fans"; + fan_0 { + pwms = <&pwm2 PWM_CHANNEL_2 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + tach = <&tach1>; + rpm_min = <2600>; + rpm_start = <2600>; + rpm_max = <4100>; + enable_gpio = <&gpio_fan_enable>; + }; + }; +}; + +&thermistor_3V3_51K1_47K_4050B { + status = "okay"; +}; + +&adc_ec_vsense_pp3300_s5 { + /* + * Voltage divider on input has 47k upper and 220k lower legs with 3 V + * full-scale reading on the ADC. Apply the largest possible multiplier + * (without overflowing int32) to get the best possible approximation + * of the actual ratio, but derate by a factor of two to ensure + * unexpectedly high values won't overflow. + */ + mul = <(715828 / 2)>; + div = <(589820 / 2)>; +}; + +&adc0 { + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch2_gpi2_default + &adc0_ch3_gpi3_default + &adc0_ch13_gpl0_default + &adc0_ch14_gpl1_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&pinctrl { + i2c4_clk_gpe0_sleep: i2c4_clk_gpe0_sleep { + pinmuxs = <&pinctrle 0 IT8XXX2_ALT_DEFAULT>; + }; + i2c4_data_gpe7_sleep: i2c4_data_gpe7_sleep { + pinmuxs = <&pinctrle 7 IT8XXX2_ALT_DEFAULT>; + }; + i2c2_clk_gpf6_default: i2c2_clk_gpf6_default { + gpio-voltage = "1v8"; + }; + i2c2_data_gpf7_default: i2c2_data_gpf7_default { + gpio-voltage = "1v8"; + }; +}; + +&i2c0 { + label = "I2C_EEPROM"; + clock-frequency = ; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + label = "EEPROM_CBI"; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; + pinctrl-0 = <&i2c0_clk_gpb3_default + &i2c0_data_gpb4_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&i2c1 { + label = "I2C_BATTERY"; + clock-frequency = <50000>; + pinctrl-0 = <&i2c1_clk_gpc1_default + &i2c1_data_gpc2_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&i2c2 { + label = "I2C_SENSOR"; + clock-frequency = ; + pinctrl-0 = <&i2c2_clk_gpf6_default + &i2c2_data_gpf7_default>; + pinctrl-names = "default"; + status = "okay"; +}; + +&i2c4 { + label = "I2C_SUB_C1_TCPC"; + clock-frequency = ; + pinctrl-0 = <&i2c4_clk_gpe0_default + &i2c4_data_gpe7_default>; + pinctrl-1 = <&i2c4_clk_gpe0_sleep + &i2c4_data_gpe7_sleep>; + pinctrl-names = "default", "sleep"; + status = "okay"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port1: sm5803@32 { + compatible = "siliconmitus,sm5803"; + status = "okay"; + reg = <0x32>; + }; +}; + +&i2c_ec_i2c_sub_usb_c1 { + /* + * Dynamic speed setting is used for AP-controlled firmware update + * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order + * to use more efficient window programming, then sets it back when + * done. + */ + dynamic-speed; +}; + +&i2c5 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + pinctrl-0 = <&i2c5_clk_gpa4_default + &i2c5_data_gpa5_default>; + pinctrl-names = "default"; + status = "okay"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port0: sm5803@32 { + compatible = "siliconmitus,sm5803"; + status = "okay"; + reg = <0x32>; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +/* pwm for fan */ +&pwm2 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm2_gpa2_default>; + pinctrl-names = "default"; +}; +/* fan tachometer sensor */ +&tach1 { + status = "okay"; + channel = ; + pulses-per-round = <2>; + pinctrl-0 = <&tach1a_gpd7_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/yaviks/power_signals.dtsi b/zephyr/program/nissa/yaviks/power_signals.dtsi new file mode 100644 index 0000000000..d64ac83150 --- /dev/null +++ b/zephyr/program/nissa/yaviks/power_signals.dtsi @@ -0,0 +1,180 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <10>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpiok 5 0>; + output; + }; + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpioc 5 0>; + output; + }; + pwr-pg-ec-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpioe 1 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioh 0 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpioe 4 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpioh 3 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpiog 2 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpiol 7 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpioe 5 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpioj 4 0>; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpiod 6 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpiof 2 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpiod 1 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + /* + * This is a board level signal, since this + * signal needs some special processing. + */ + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + pwr-adc-pp3300 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP3300_PROC"; + enum-name = "PWR_DSW_PWROK"; + trigger-high = <&vcmp0>; + trigger-low = <&vcmp1>; + }; + pwr-adc-pp1p05 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP1P05_PROC"; + enum-name = "PWR_PG_PP1P05"; + trigger-high = <&vcmp2>; + trigger-low = <&vcmp3>; + }; + +}; + +&vcmp0 { + status = "okay"; + scan-period = ; + comparison = ; + /* + * This is 90% of nominal voltage considering voltage + * divider on ADC input. + */ + threshold-mv = <2448>; + io-channels = <&adc0 0>; +}; +&vcmp1 { + status = "okay"; + scan-period = ; + comparison = ; + threshold-mv = <2448>; + io-channels = <&adc0 0>; +}; +&vcmp2 { + status = "okay"; + scan-period = ; + comparison = ; + /* Setting at 90% of nominal voltage */ + threshold-mv = <945>; + io-channels = <&adc0 14>; +}; +&vcmp3 { + status = "okay"; + scan-period = ; + comparison = ; + threshold-mv = <945>; + io-channels = <&adc0 14>; +}; diff --git a/zephyr/program/nissa/yaviks/project.conf b/zephyr/program/nissa/yaviks/project.conf new file mode 100644 index 0000000000..0e385b843e --- /dev/null +++ b/zephyr/program/nissa/yaviks/project.conf @@ -0,0 +1,33 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_YAVIKS=y + +# Ensure recovery key combination (esc+refresh+power) is reliable: b/236580049 +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y + +# Sensors: disabled; yaviks is clamshell-only +CONFIG_PLATFORM_EC_LID_ANGLE=n +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n +CONFIG_PLATFORM_EC_MOTIONSENSE=n +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n +CONFIG_PLATFORM_EC_ACCEL_FIFO=n +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n +CONFIG_PLATFORM_EC_TABLET_MODE=n +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y +CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=n + +# Fan +CONFIG_PLATFORM_EC_FAN=y + +# LED +CONFIG_PLATFORM_EC_LED_PWM=n diff --git a/zephyr/program/nissa/yaviks/project.overlay b/zephyr/program/nissa/yaviks/project.overlay new file mode 100644 index 0000000000..a7ce97a8b3 --- /dev/null +++ b/zephyr/program/nissa/yaviks/project.overlay @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../cbi.dtsi" + +#include "cbi.dtsi" +#include "gpio.dtsi" +#include "keyboard.dtsi" +#include "overlay.dtsi" +#include "power_signals.dtsi" diff --git a/zephyr/program/nissa/yaviks/src/charger.c b/zephyr/program/nissa/yaviks/src/charger.c new file mode 100644 index 0000000000..9be2e685b0 --- /dev/null +++ b/zephyr/program/nissa/yaviks/src/charger.c @@ -0,0 +1,74 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charger.h" +#include "console.h" +#include "driver/charger/sm5803.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" +#include "battery_fuel_gauge.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = sm5803_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Yaviks does not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + if (board_get_usb_pd_port_count() == 2) + sm5803_hibernate(CHARGER_SECONDARY); + sm5803_hibernate(CHARGER_PRIMARY); + LOG_INF("Charger(s) hibernated"); + cflush(); +} + +__override int board_get_default_battery_type(void) +{ + int type = DEFAULT_BATTERY_TYPE; + int cells; + + if (charger_get_battery_cells(CHARGER_PRIMARY, &cells) == EC_SUCCESS) { + if (cells == 3) + type = DEFAULT_BATTERY_TYPE_3S; + if (cells != 2 && cells != 3) + LOG_ERR("Unexpected number of cells"); + } else { + LOG_ERR("Failed to get default battery type"); + } + + return type; +} diff --git a/zephyr/program/nissa/yaviks/src/fan.c b/zephyr/program/nissa/yaviks/src/fan.c new file mode 100644 index 0000000000..23c3ec1143 --- /dev/null +++ b/zephyr/program/nissa/yaviks/src/fan.c @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include +#include +#include +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" +#include "nissa_common.h" +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +static void fan_init(void) +{ + int ret; + uint32_t val; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + if (val != FW_FAN_PRESENT) { + /* Disable the fan */ + fan_set_count(0); + } else { + /* Configure the fan enable GPIO */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), + GPIO_OUTPUT); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/yaviks/src/keyboard.c b/zephyr/program/nissa/yaviks/src/keyboard.c new file mode 100644 index 0000000000..46d6083dbf --- /dev/null +++ b/zephyr/program/nissa/yaviks/src/keyboard.c @@ -0,0 +1,106 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include + +#include "cros_cbi.h" +#include "ec_commands.h" +#include "hooks.h" +#include "keyboard_8042_sharedlib.h" +#include "keyboard_scan.h" +#include "timer.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* Keyboard scan setting */ +__override struct keyboard_scan_config keyscan_config = { + /* Increase from 50 us, because KSO_02 passes through the H1. */ + .output_settle_us = 80, + /* Other values should be the same as the default configuration. */ + .debounce_down_us = 9 * MSEC, + .debounce_up_us = 30 * MSEC, + .scan_period_us = 3 * MSEC, + .min_post_scan_delay_us = 1000, + .poll_timeout_us = 100 * MSEC, + .actual_key_mask = { + 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xa4, 0xff, 0xf6, 0x55, 0xfe, 0xff, 0xff, 0xff, /* full set */ + }, +}; + +static const struct ec_response_keybd_config yaviks_kb_w_kb_light = { + .num_top_row_keys = 13, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_KBD_BKLIGHT_TOGGLE, /* T8 */ + TK_PLAY_PAUSE, /* T9 */ + TK_MICMUTE, /* T10 */ + TK_VOL_MUTE, /* T11 */ + TK_VOL_DOWN, /* T12 */ + TK_VOL_UP, /* T13 */ + }, + .capabilities = KEYBD_CAP_NUMERIC_KEYPAD, +}; + +static const struct ec_response_keybd_config yaviks_kb_wo_kb_light = { + .num_top_row_keys = 13, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_PLAY_PAUSE, /* T8 */ + TK_MICMUTE, /* T9 */ + TK_VOL_MUTE, /* T10 */ + TK_VOL_DOWN, /* T11 */ + TK_VOL_UP, /* T12 */ + TK_MENU, /* T13 */ + }, + .capabilities = KEYBD_CAP_NUMERIC_KEYPAD, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_KB_BACKLIGHT, &val); + + if (val == FW_KB_BACKLIGHT_OFF) + return &yaviks_kb_wo_kb_light; + else + return &yaviks_kb_w_kb_light; +} + +/* + * Keyboard layout decided by FW config. + */ +static void kb_layout_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", + FW_KB_LAYOUT); + return; + } + /* + * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl + * to backslash(\|) key. + */ + if (val == FW_KB_LAYOUT_US2) + set_scancode_set2(4, 0, get_scancode_set2(2, 7)); +} +DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/yaviks/src/led.c b/zephyr/program/nissa/yaviks/src/led.c new file mode 100644 index 0000000000..88a476f1b0 --- /dev/null +++ b/zephyr/program/nissa/yaviks/src/led.c @@ -0,0 +1,231 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charge_manager.h" +#include "charge_state.h" +#include "chipset.h" +#include "ec_commands.h" +#include "gpio.h" +#include "host_command.h" +#include "led_common.h" +#include "hooks.h" + +#define BAT_LED_ON 0 +#define BAT_LED_OFF 1 + +#define BATT_LOW_BCT 10 + +#define LED_TICKS_PER_CYCLE 4 +#define LED_TICKS_PER_CYCLE_S3 4 +#define LED_ON_TICKS 2 +#define POWER_LED_ON_S3_TICKS 2 + +const enum ec_led_id supported_led_ids[] = { EC_LED_ID_LEFT_LED, + EC_LED_ID_RIGHT_LED }; + +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +enum led_color { + LED_OFF = 0, + LED_AMBER, + LED_WHITE, + LED_COLOR_COUNT /* Number of colors, not a color itself */ +}; + +enum led_port { LEFT_PORT = 0, RIGHT_PORT }; + +static void led_set_color_battery(int port, enum led_color color) +{ + const struct gpio_dt_spec *amber_led, *white_led; + + if (port == LEFT_PORT) { + amber_led = GPIO_DT_FROM_NODELABEL(gpio_c0_charger_led_amber_l); + white_led = GPIO_DT_FROM_NODELABEL(gpio_c0_charger_led_white_l); + } else if (port == RIGHT_PORT) { + amber_led = GPIO_DT_FROM_NODELABEL(gpio_c1_charger_led_amber_l); + white_led = GPIO_DT_FROM_NODELABEL(gpio_c1_charger_led_white_l); + } + + switch (color) { + case LED_WHITE: + gpio_pin_set_dt(white_led, BAT_LED_ON); + gpio_pin_set_dt(amber_led, BAT_LED_OFF); + break; + case LED_AMBER: + gpio_pin_set_dt(white_led, BAT_LED_OFF); + gpio_pin_set_dt(amber_led, BAT_LED_ON); + break; + case LED_OFF: + gpio_pin_set_dt(white_led, BAT_LED_OFF); + gpio_pin_set_dt(amber_led, BAT_LED_OFF); + break; + default: + break; + } +} + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + switch (led_id) { + case EC_LED_ID_LEFT_LED: + brightness_range[EC_LED_COLOR_WHITE] = 1; + brightness_range[EC_LED_COLOR_AMBER] = 1; + break; + case EC_LED_ID_RIGHT_LED: + brightness_range[EC_LED_COLOR_WHITE] = 1; + brightness_range[EC_LED_COLOR_AMBER] = 1; + break; + default: + break; + } +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + switch (led_id) { + case EC_LED_ID_LEFT_LED: + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_battery(LEFT_PORT, LED_WHITE); + else if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(LEFT_PORT, LED_AMBER); + else + led_set_color_battery(LEFT_PORT, LED_OFF); + break; + case EC_LED_ID_RIGHT_LED: + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_battery(RIGHT_PORT, LED_WHITE); + else if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(RIGHT_PORT, LED_AMBER); + else + led_set_color_battery(RIGHT_PORT, LED_OFF); + break; + default: + return EC_ERROR_PARAM1; + } + + return EC_SUCCESS; +} + +/* + * Set active charge port color to the parameter, turn off all others. + * If no port is active (-1), turn off all LEDs. + */ +static void set_active_port_color(enum led_color color) +{ + int port = charge_manager_get_active_charge_port(); + + if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) + led_set_color_battery(RIGHT_PORT, + (port == RIGHT_PORT) ? color : LED_OFF); + if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) + led_set_color_battery(LEFT_PORT, + (port == LEFT_PORT) ? color : LED_OFF); +} + +static void led_set_battery(void) +{ + static unsigned int battery_ticks; + static int suspend_ticks; + + battery_ticks++; + + /* + * Override battery LEDs for Yaviks, Yaviks is non-power LED + * design, blinking both two side battery white LEDs to indicate + * system suspend with non-charging state. + */ + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && + charge_get_state() != PWR_STATE_CHARGE) { + suspend_ticks++; + + led_set_color_battery(RIGHT_PORT, + suspend_ticks % LED_TICKS_PER_CYCLE_S3 < + POWER_LED_ON_S3_TICKS ? + LED_WHITE : + LED_OFF); + led_set_color_battery(LEFT_PORT, + suspend_ticks % LED_TICKS_PER_CYCLE_S3 < + POWER_LED_ON_S3_TICKS ? + LED_WHITE : + LED_OFF); + return; + } + + suspend_ticks = 0; + + switch (charge_get_state()) { + case PWR_STATE_CHARGE: + /* Always indicate when charging, even in suspend. */ + set_active_port_color(LED_AMBER); + break; + case PWR_STATE_DISCHARGE: + /* + * Blinking amber LEDs slowly if battery is lower 10 + * percentage. + */ + if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) { + if (charge_get_percent() < BATT_LOW_BCT) + led_set_color_battery( + RIGHT_PORT, + (battery_ticks % LED_TICKS_PER_CYCLE < + LED_ON_TICKS) ? + LED_AMBER : + LED_OFF); + else + led_set_color_battery(RIGHT_PORT, LED_OFF); + } + + if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) { + if (charge_get_percent() < BATT_LOW_BCT) + led_set_color_battery( + LEFT_PORT, + (battery_ticks % LED_TICKS_PER_CYCLE < + LED_ON_TICKS) ? + LED_AMBER : + LED_OFF); + else + led_set_color_battery(LEFT_PORT, LED_OFF); + } + break; + case PWR_STATE_ERROR: + if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) { + led_set_color_battery( + RIGHT_PORT, + (battery_ticks & 0x1) ? LED_AMBER : LED_OFF); + } + + if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) { + led_set_color_battery(LEFT_PORT, (battery_ticks & 0x1) ? + LED_AMBER : + LED_OFF); + } + break; + case PWR_STATE_CHARGE_NEAR_FULL: + set_active_port_color(LED_WHITE); + break; + case PWR_STATE_IDLE: /* External power connected in IDLE */ + set_active_port_color(LED_WHITE); + break; + case PWR_STATE_FORCED_IDLE: + set_active_port_color( + (battery_ticks % LED_TICKS_PER_CYCLE < LED_ON_TICKS) ? + LED_AMBER : + LED_OFF); + break; + default: + /* Other states don't alter LED behavior */ + break; + } +} + +/* Called by hook task every TICK(IT83xx 500ms) */ +static void led_tick(void) +{ + led_set_battery(); +} +DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/nissa/yaviks/src/usbc.c b/zephyr/program/nissa/yaviks/src/usbc.c new file mode 100644 index 0000000000..48f7cfd9cb --- /dev/null +++ b/zephyr/program/nissa/yaviks/src/usbc.c @@ -0,0 +1,393 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/sm5803.h" +#include "driver/tcpm/it83xx_pd.h" +#include "driver/tcpm/ps8xxx_public.h" +#include "driver/tcpm/tcpci.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_EMBEDDED, + /* TCPC is embedded within EC so no i2c config needed */ + .drv = &it8xxx2_tcpm_drv, + /* Alert is active-low, push-pull */ + .flags = 0, + }, + { + /* + * Sub-board: optional PS8745 TCPC+redriver. Behaves the same + * as PS8815. + */ + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1_TCPC, + .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, + }, + .drv = &ps8xxx_tcpm_drv, + /* PS8745 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0, + }, +}; + +/* Vconn control for integrated ITE TCPC */ +void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) +{ + /* Vconn control is only for port 0 */ + if (port) + return; + + if (cc_pin == USBPD_CC_PIN_1) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn), + !!enabled); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn), + !!enabled); +} + +__override bool pd_check_vbus_level(int port, enum vbus_level level) +{ + return sm5803_check_vbus_level(port, level); +} + +/* + * Putting chargers into LPM when in suspend reduces power draw by about 8mW + * per charger, but also seems critical to correct operation in source mode: + * if chargers are not in LPM when a sink is first connected, VBUS sourcing + * works even if the partner is later removed (causing LPM entry) and + * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS + * consistently causes the charger to report (apparently spurious) overcurrent + * failures. + * + * In short, this is important to making things work correctly but we don't + * understand why. + */ +static void board_chargers_suspend(struct ap_power_ev_callback *const cb, + const struct ap_power_ev_data data) +{ + void (*fn)(int chgnum); + + switch (data.event) { + case AP_POWER_SUSPEND: + fn = sm5803_enable_low_power_mode; + break; + case AP_POWER_RESUME: + fn = sm5803_disable_low_power_mode; + break; + default: + LOG_WRN("%s: power event %d is not recognized", __func__, + data.event); + return; + } + + fn(CHARGER_PRIMARY); + if (board_get_charger_chip_count() > 1) + fn(CHARGER_SECONDARY); +} + +static int board_chargers_suspend_init(const struct device *unused) +{ + static struct ap_power_ev_callback cb = { + .handler = board_chargers_suspend, + .events = AP_POWER_SUSPEND | AP_POWER_RESUME, + }; + ap_power_ev_add_callback(&cb); + return 0; +} +SYS_INIT(board_chargers_suspend_init, APPLICATION, 0); + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count()); + int i; + int old_port; + int rv; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + LOG_INF("Charge update: p%d -> p%d", old_port, port); + + /* Check if port is sourcing VBUS. */ + if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) { + LOG_WRN("Skip enable p%d: already sourcing", port); + return EC_ERROR_INVAL; + } + + /* Disable sinking on all ports except the desired one */ + for (i = 0; i < board_get_usb_pd_port_count(); i++) { + if (i == port) + continue; + + if (sm5803_vbus_sink_enable(i, 0)) + /* + * Do not early-return because this can fail during + * power-on which would put us into a loop. + */ + LOG_WRN("p%d: sink path disable failed.", i); + } + + /* Don't enable anything (stop here) if no ports were requested */ + if ((port == CHARGE_PORT_NONE) || (old_port == port)) + return EC_SUCCESS; + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + rv = sm5803_vbus_sink_enable(port, 1); + if (rv) + LOG_WRN("p%d: sink path enable failed: code %d", port, rv); + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return rv; +} + +uint16_t tcpc_get_alert_status(void) +{ + /* + * TCPC 0 is embedded in the EC and processes interrupts in the chip + * code (it83xx/intc.c). This function only needs to poll port C1 if + * present. + */ + uint16_t status = 0; + int regval; + + /* Is the C1 port present and its IRQ line asserted? */ + if (board_get_usb_pd_port_count() == 2 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + /* + * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if + * it asserted the IRQ. + */ + if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { + if (regval) + status = PD_STATUS_TCPC_ALERT_1; + } + } + + return status; +} + +void pd_power_supply_reset(int port) +{ + int prev_en; + + if (port < 0 || port >= board_get_usb_pd_port_count()) + return; + + prev_en = charger_is_sourcing_otg_power(port); + + /* Disable Vbus */ + charger_enable_otg_power(port, 0); + + /* Discharge Vbus if previously enabled */ + if (prev_en) + sm5803_set_vbus_disch(port, 1); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + enum ec_error_list rv; + + if (port < 0 || port > board_get_usb_pd_port_count()) { + LOG_WRN("Port C%d does not exist, cannot enable VBUS", port); + return EC_ERROR_INVAL; + } + + /* Disable sinking */ + rv = sm5803_vbus_sink_enable(port, 0); + if (rv) { + LOG_WRN("C%d failed to disable sinking: %d", port, rv); + return rv; + } + + /* Disable Vbus discharge */ + rv = sm5803_set_vbus_disch(port, 0); + if (rv) { + LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv); + return rv; + } + + /* Provide Vbus */ + rv = charger_enable_otg_power(port, 1); + if (rv) { + LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv); + return rv; + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv; + const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500; + + rv = charger_set_otg_current_voltage(port, current, 5000); + if (rv != EC_SUCCESS) { + LOG_WRN("Failed to set source ilimit on port %d to %d: %d", + port, current, rv); + } +} + +void board_reset_pd_mcu(void) +{ + /* + * Do nothing. The integrated TCPC for C0 lacks a dedicated reset + * command, and C1 (if present) doesn't have a reset pin connected + * to the EC. + */ +} + +#define INT_RECHECK_US 5000 + +/* C0 interrupt line shared by BC 1.2 and charger */ + +static void check_c0_line(void); +DECLARE_DEFERRED(check_c0_line); + +static void notify_c0_chips(void) +{ + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + sm5803_interrupt(0); +} + +static void check_c0_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + notify_c0_chips(); + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); + } +} + +void usb_c0_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c0_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c0_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); +} + +/* C1 interrupt line shared by BC 1.2, TCPC, and charger */ +static void check_c1_line(void); +DECLARE_DEFERRED(check_c1_line); + +static void notify_c1_chips(void) +{ + schedule_deferred_pd_interrupt(1); + usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); + /* Charger is handled in board_process_pd_alert */ +} + +static void check_c1_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + notify_c1_chips(); + hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); + } +} + +void usb_c1_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c1_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c1_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); +} + +/* + * Check state of IRQ lines at startup, ensuring an IRQ that happened before + * the EC started up won't get lost (leaving the IRQ line asserted and blocking + * any further interrupts on the port). + * + * Although the PD task will check for pending TCPC interrupts on startup, + * the charger sharing the IRQ will not be polled automatically. + */ +void board_handle_initial_typec_irq(void) +{ + check_c0_line(); + if (board_get_usb_pd_port_count() == 2) + check_c1_line(); +} +/* + * This must run after sub-board detection (which happens in EC main()), + * but isn't depended on by anything else either. + */ +DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST); + +/* + * Handle charger interrupts in the PD task. Not doing so can lead to a priority + * inversion where we fail to respond to TCPC alerts quickly enough because we + * don't get another edge on a shared IRQ until the charger interrupt is cleared + * (or the IRQ is polled again), which happens in the low-priority charger task: + * the high-priority type-C handler is thus blocked on the lower-priority + * charger. + * + * To avoid that, we run charger interrupts at the same priority. + */ +void board_process_pd_alert(int port) +{ + /* + * Port 0 doesn't use an external TCPC, so its interrupts don't need + * this special handling. + */ + if (port == 1 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + sm5803_handle_interrupt(port); + } +} + +int pd_snk_is_vbus_provided(int port) +{ + int chg_det = 0; + + sm5803_get_chg_det(port, &chg_det); + + return chg_det; +} diff --git a/zephyr/program/nissa/yaviks/yaviks_vif.xml b/zephyr/program/nissa/yaviks/yaviks_vif.xml new file mode 100644 index 0000000000..edc6299c58 --- /dev/null +++ b/zephyr/program/nissa/yaviks/yaviks_vif.xml @@ -0,0 +1,350 @@ + + + 3.19 + + USB-IF + VIF Editor + 3.2.4.0 + + Google + Yaviks + 1 + 0 + Port Product + Reference Platform + + + + + + + + + 0 + Type-C® + + + DRP + DRP + + Charging Port + + + + + + + + + Revision 3 + + + + + + + 18D1 + 505A + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 15000 mW + Assured + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + FR_Swap not supported + + + + Over-Current Response + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + 0 msec + 3000 mA + + + + + + 45000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 15000 mV + + + + Variable + 4750 mV + 15000 mV + 3000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505A + 0000 + + + + + + + 1 + Type-C® + + + DRP + DRP + + Charging Port + + + + + + + + + Revision 3 + + + + + + + 18D1 + 505A + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 15000 mW + Assured + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + FR_Swap not supported + + + + Over-Current Response + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + 0 msec + 3000 mA + + + + + + 45000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 15000 mV + + + + Variable + 4750 mV + 15000 mV + 3000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505A + 0000 + + \ No newline at end of file diff --git a/zephyr/program/npcx_evb/npcx7/BUILD.py b/zephyr/program/npcx_evb/npcx7/BUILD.py new file mode 100644 index 0000000000..baa6774595 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx7/BUILD.py @@ -0,0 +1,11 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for npcx7_evb.""" + +register_npcx_project( + project_name="npcx7", + zephyr_board="npcx7_evb", + dts_overlays=["gpio.dts", "interrupts.dts", "fan.dts", "keyboard.dts"], +) diff --git a/zephyr/program/npcx_evb/npcx7/CMakeLists.txt b/zephyr/program/npcx_evb/npcx7/CMakeLists.txt new file mode 100644 index 0000000000..64429d586e --- /dev/null +++ b/zephyr/program/npcx_evb/npcx7/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(npcx7) + +zephyr_include_directories(include) diff --git a/zephyr/program/npcx_evb/npcx7/fan.dts b/zephyr/program/npcx_evb/npcx7/fan.dts new file mode 100644 index 0000000000..dc4debdcb9 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx7/fan.dts @@ -0,0 +1,39 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + rpm_min = <1000>; + rpm_start = <1000>; + rpm_max = <5200>; + tach = <&tach1>; + pgood_gpio = <&gpio_pgood_fan>; + }; + }; +}; + +/* Tachometer for fan speed measurement */ +&tach1 { + status = "okay"; + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/npcx_evb/npcx7/gpio.dts b/zephyr/program/npcx_evb/npcx7/gpio.dts new file mode 100644 index 0000000000..d44927609d --- /dev/null +++ b/zephyr/program/npcx_evb/npcx7/gpio.dts @@ -0,0 +1,68 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_wp; + }; + + named-gpios { + compatible = "named-gpios"; + + recovery_l { + gpios = <&gpio0 3 GPIO_INPUT_PULL_UP>; + }; + gpio_wp: wp_l { + gpios = <&gpio9 3 (GPIO_INPUT_PULL_UP | + GPIO_ACTIVE_LOW)>; + }; + gpio_ac_present: ac_present { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_power_button_l: power_button_l { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_lid_open: lid_open { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + entering_rw { + gpios = <&gpio3 6 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_pch_wake_odl: pch_wake_l { + gpios = <&gpio5 0 GPIO_OUTPUT_HIGH>; + }; + gpio_pgood_fan: pgood_fan { + gpios = <&gpioc 7 GPIO_INPUT_PULL_UP>; + }; + spi_cs_l { + gpios = <&gpioa 5 GPIO_OUTPUT_HIGH>; + }; + board_version1 { + gpios = <&gpio6 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + board_version2 { + gpios = <&gpio6 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + board_version3 { + gpios = <&gpio6 6 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_power_button + &int_lid_open + >; + }; +}; diff --git a/zephyr/program/npcx_evb/npcx7/interrupts.dts b/zephyr/program/npcx_evb/npcx7/interrupts.dts new file mode 100644 index 0000000000..3e92428ef4 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx7/interrupts.dts @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_ac_present: ac_present { + irq-pin = <&gpio_ac_present>; + flags = ; + handler = "extpower_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + }; +}; diff --git a/zephyr/program/npcx_evb/npcx7/keyboard.dts b/zephyr/program/npcx_evb/npcx7/keyboard.dts new file mode 100644 index 0000000000..3fb6986f1a --- /dev/null +++ b/zephyr/program/npcx_evb/npcx7/keyboard.dts @@ -0,0 +1,42 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + output-settle = <40>; + debounce-down = <6000>; + scan-period = <1500>; + poll-timeout = <1000000>; + + actual-key-mask = < + 0x14 /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xf6 /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xc8 /* C12 */ + >; + }; + + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm2 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm2 { + status = "okay"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/npcx_evb/npcx7/prj.conf b/zephyr/program/npcx_evb/npcx7/prj.conf new file mode 100644 index 0000000000..5f1fc03f88 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx7/prj.conf @@ -0,0 +1,60 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_BRINGUP=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_SHIMMED_TASKS=y + +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n +CONFIG_PLATFORM_EC_SWITCH=n +CONFIG_PLATFORM_EC_VBOOT_EFS2=n +CONFIG_PLATFORM_EC_VSTORE=n + +# Board version is selected over GPIO board ID pins. +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y + +# PWM +CONFIG_PWM=y + +# Sensors +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n + +# Console command +CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y + +CONFIG_TRACING=y +CONFIG_TRACING_ISR=y +CONFIG_TRACING_USER=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_IRQ=y + +# eSPI +CONFIG_ESPI=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y + +# Keyboard +CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y + +# RTC +CONFIG_PLATFORM_EC_RTC=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y + +# USB-C +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n + +# Zephyr feature +CONFIG_ASSERT=y +CONFIG_SHELL_MINIMAL=n +CONFIG_LOG=y + +# Avoid underflow info from tachometer +CONFIG_SENSOR_LOG_LEVEL_ERR=y + +CONFIG_SYSCON=y diff --git a/zephyr/program/npcx_evb/npcx9/BUILD.py b/zephyr/program/npcx_evb/npcx9/BUILD.py new file mode 100644 index 0000000000..335f410d9b --- /dev/null +++ b/zephyr/program/npcx_evb/npcx9/BUILD.py @@ -0,0 +1,16 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for npcx9_evb.""" + +register_npcx_project( + project_name="npcx9", + zephyr_board="npcx9_evb", + dts_overlays=[ + "gpio.dts", + "interrupts.dts", + "fan.dts", + "keyboard.dts", + ], +) diff --git a/zephyr/program/npcx_evb/npcx9/CMakeLists.txt b/zephyr/program/npcx_evb/npcx9/CMakeLists.txt new file mode 100644 index 0000000000..ef734c06f6 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx9/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(npcx9) + +zephyr_include_directories(include) diff --git a/zephyr/program/npcx_evb/npcx9/fan.dts b/zephyr/program/npcx_evb/npcx9/fan.dts new file mode 100644 index 0000000000..dc4debdcb9 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx9/fan.dts @@ -0,0 +1,39 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + rpm_min = <1000>; + rpm_start = <1000>; + rpm_max = <5200>; + tach = <&tach1>; + pgood_gpio = <&gpio_pgood_fan>; + }; + }; +}; + +/* Tachometer for fan speed measurement */ +&tach1 { + status = "okay"; + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/npcx_evb/npcx9/gpio.dts b/zephyr/program/npcx_evb/npcx9/gpio.dts new file mode 100644 index 0000000000..9a32112471 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx9/gpio.dts @@ -0,0 +1,72 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_wp; + }; + + named-gpios { + compatible = "named-gpios"; + + recovery_l { + gpios = <&gpio0 3 GPIO_INPUT_PULL_UP>; + }; + gpio_wp: wp_l { + gpios = <&gpio9 3 (GPIO_INPUT_PULL_UP | + GPIO_ACTIVE_LOW)>; + }; + gpio_ac_present: ac_present { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_power_button_l: power_button_l { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_lid_open: lid_open { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + entering_rw { + gpios = <&gpio3 6 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_pch_wake_odl: pch_wake_l { + gpios = <&gpio5 0 GPIO_OUTPUT_HIGH>; + }; + gpio_pgood_fan: pgood_fan { + gpios = <&gpioc 7 GPIO_INPUT_PULL_UP>; + }; + spi_cs_l { + gpios = <&gpioa 5 GPIO_OUTPUT_HIGH>; + }; + board_version1 { + gpios = <&gpio6 4 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + board_version2 { + gpios = <&gpio6 5 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + board_version3 { + gpios = <&gpio6 6 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + }; +}; + +/* A falling edge detection type for PSL_IN2 */ +&psl_in2_gp00 { + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in2_gp00>; +}; diff --git a/zephyr/program/npcx_evb/npcx9/interrupts.dts b/zephyr/program/npcx_evb/npcx9/interrupts.dts new file mode 100644 index 0000000000..3e92428ef4 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx9/interrupts.dts @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_ac_present: ac_present { + irq-pin = <&gpio_ac_present>; + flags = ; + handler = "extpower_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + }; +}; diff --git a/zephyr/program/npcx_evb/npcx9/keyboard.dts b/zephyr/program/npcx_evb/npcx9/keyboard.dts new file mode 100644 index 0000000000..3fb6986f1a --- /dev/null +++ b/zephyr/program/npcx_evb/npcx9/keyboard.dts @@ -0,0 +1,42 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + output-settle = <40>; + debounce-down = <6000>; + scan-period = <1500>; + poll-timeout = <1000000>; + + actual-key-mask = < + 0x14 /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xf6 /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xc8 /* C12 */ + >; + }; + + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm2 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm2 { + status = "okay"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/npcx_evb/npcx9/prj.conf b/zephyr/program/npcx_evb/npcx9/prj.conf new file mode 100644 index 0000000000..827b6366c6 --- /dev/null +++ b/zephyr/program/npcx_evb/npcx9/prj.conf @@ -0,0 +1,64 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_BRINGUP=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_SHIMMED_TASKS=y + +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n +CONFIG_PLATFORM_EC_SWITCH=n +CONFIG_PLATFORM_EC_VBOOT_EFS2=n +CONFIG_PLATFORM_EC_VSTORE=n + +# Workaround npcx9 A1 chip's bug for download_from_flash API in th booter. +# This can be removed when A2 chip is available. +CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y + +# Board version is selected over GPIO board ID pins. +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y + +# PWM +CONFIG_PWM=y + +# Sensors +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n + +# Console command +CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y + +CONFIG_TRACING=y +CONFIG_TRACING_ISR=y +CONFIG_TRACING_USER=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_IRQ=y + +# eSPI +CONFIG_ESPI=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y + +# Keyboard +CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y + +# RTC +CONFIG_PLATFORM_EC_RTC=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y + +# USB-C +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n + +# Zephyr feature +CONFIG_ASSERT=y +CONFIG_SHELL_MINIMAL=n +CONFIG_LOG=y + +# Avoid underflow info from tachometer +CONFIG_SENSOR_LOG_LEVEL_ERR=y + +CONFIG_SYSCON=y diff --git a/zephyr/program/rex/BUILD.py b/zephyr/program/rex/BUILD.py new file mode 100644 index 0000000000..2537f61226 --- /dev/null +++ b/zephyr/program/rex/BUILD.py @@ -0,0 +1,45 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Rex Projects.""" + + +def register_variant( + project_name, extra_dts_overlays=(), extra_kconfig_files=() +): + """Register a variant of rex.""" + register_npcx_project( + project_name=project_name, + zephyr_board="npcx9m7f", + dts_overlays=[ + # Common to all projects. + here / "rex.dts", + # Project-specific DTS customization. + *extra_dts_overlays, + ], + kconfig_files=[ + # Common to all projects. + here / "prj.conf", + # Project-specific KConfig customization. + *extra_kconfig_files, + ], + ) + + +register_variant( + project_name="rex", + extra_dts_overlays=[ + here / "generated.dts", + here / "interrupts.dts", + here / "power_signals.dts", + here / "battery.dts", + here / "usbc.dts", + here / "keyboard.dts", + here / "led.dts", + here / "fan.dts", + here / "temp_sensors.dts", + here / "motionsense.dts", + ], + extra_kconfig_files=[here / "prj_rex.conf"], +) diff --git a/zephyr/program/rex/CMakeLists.txt b/zephyr/program/rex/CMakeLists.txt new file mode 100644 index 0000000000..27d7dff068 --- /dev/null +++ b/zephyr/program/rex/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.20.5) +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(rex) + +zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") +zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ "src/board_power.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usbc_config.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy.c") diff --git a/zephyr/program/rex/Kconfig b/zephyr/program/rex/Kconfig new file mode 100644 index 0000000000..7d17c27815 --- /dev/null +++ b/zephyr/program/rex/Kconfig @@ -0,0 +1,11 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config BOARD_REX + bool "Google Rex Baseboard" + help + Build Google Rex reference board. The board uses Nuvoton + NPCX9 chip as the EC. + +source "Kconfig.zephyr" diff --git a/zephyr/program/rex/battery.dts b/zephyr/program/rex/battery.dts new file mode 100644 index 0000000000..e11346f48d --- /dev/null +++ b/zephyr/program/rex/battery.dts @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: batgqa05l22 { + compatible = "powertech,batgqa05l22", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/rex/fan.dts b/zephyr/program/rex/fan.dts new file mode 100644 index 0000000000..aa6dcfde7d --- /dev/null +++ b/zephyr/program/rex/fan.dts @@ -0,0 +1,39 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm5 0 PWM_KHZ(1) PWM_POLARITY_NORMAL>; + rpm_min = <2200>; + rpm_start = <2200>; + rpm_max = <4200>; + tach = <&tach1>; + enable_gpio = <&gpio_en_pp5000_fan>; + }; + }; +}; + +/* Tachemeter for fan speed measurement */ +&tach1 { + status = "okay"; + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm5_gpb7 { + drive-open-drain; +}; + +&pwm5 { + status = "okay"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/rex/generated.dts b/zephyr/program/rex/generated.dts new file mode 100644 index 0000000000..5b6f9cd708 --- /dev/null +++ b/zephyr/program/rex/generated.dts @@ -0,0 +1,363 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This file is auto-generated - do not edit! + * + * TODO(b:/244441996): There are some errors in the main Rex EC GPIO spreadsheet + * which is used as input to create this device tree file. Until that issue is + * resolved, there are some edits required to this file to support EC + * functionality. + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ddr_soc: ddr_soc { + enum-name = "ADC_TEMP_SENSOR_1_DDR_SOC"; + io-channels = <&adc0 0>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 1>; + }; + adc_charger: charger { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 8>; + }; + adc_wwan: wwan { + enum-name = "ADC_TEMP_SENSOR_4"; + io-channels = <&adc0 7>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpioa 7 GPIO_INPUT>; + }; + gpio_ec_accel_int_r_l: ec_accel_int_r_l { + gpios = <&gpio8 1 GPIO_INPUT>; + }; + gpio_ec_als_rgb_int_r_l: ec_als_rgb_int_r_l { + gpios = <&gpiod 4 GPIO_INPUT_PULL_UP>; + }; + gpio_ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioa 3 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio7 3 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en: ec_edp_bl_en { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpio7 5 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_imu_int_r_l: ec_imu_int_r_l { + gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>; + }; + gpio_ec_imvp92_en_smb: ec_imvp92_en_smb { + gpios = <&gpiob 1 GPIO_OUTPUT>; + }; + gpio_ec_kb_bl_en_l: ec_kb_bl_en_l { + gpios = <&gpio8 6 GPIO_OUTPUT>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_ec_prochot_in_l: ec_prochot_in_l { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpio6 3 GPIO_ODR_HIGH>; + }; + gpio_ec_rst_r_odl: ec_rst_r_odl { + gpios = <&gpio7 7 GPIO_INPUT>; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpio7 0 GPIO_ODR_LOW>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpioc 1 GPIO_ODR_LOW>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioa 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpio7 6 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_wake_r_odl: ec_soc_wake_r_odl { + gpios = <&gpioc 0 GPIO_ODR_LOW>; + }; + gpio_ec_spare_gpio42: ec_spare_gpio42 { + gpios = <&gpio4 2 GPIO_OUTPUT>; + }; + gpio_ec_spare_gpio66: ec_spare_gpio66 { + gpios = <&gpio6 6 GPIO_OUTPUT>; + }; + gpio_ec_spare_gpio94: ec_spare_gpio94 { + gpios = <&gpio9 4 GPIO_OUTPUT>; + }; + gpio_ec_spare_gpioa2: ec_spare_gpioa2 { + gpios = <&gpioa 2 GPIO_OUTPUT>; + }; + gpio_ec_spare_gpioa4: ec_spare_gpioa4 { + gpios = <&gpioa 4 GPIO_OUTPUT>; + }; + gpio_ec_spare_gpioc7: ec_spare_gpioc7 { + gpios = <&gpioc 7 GPIO_OUTPUT>; + }; + gpio_ec_spare_gpo32: ec_spare_gpo32 { + gpios = <&gpio3 2 GPIO_OUTPUT>; + }; + gpio_ec_spare_gpo35: ec_spare_gpo35 { + gpios = <&gpio3 5 GPIO_OUTPUT>; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpio9 7 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_l: ec_wp_l { + gpios = <&gpioa 1 GPIO_INPUT>; + }; + gpio_en_pp5000_fan: en_pp5000_fan { + gpios = <&gpio6 1 GPIO_OUTPUT_LOW>; + }; + gpio_en_pp5000_usba_r: en_pp5000_usba_r { + gpios = <&gpiod 7 GPIO_OUTPUT>; + }; + gpio_en_s5_rails: en_s5_rails { + gpios = <&gpiob 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + }; + gpio_en_z1_rails: en_z1_rails { + gpios = <&gpio8 5 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; + }; + gpio_imvp92_vrrdy_od: imvp92_vrrdy_od { + gpios = <&gpio4 3 GPIO_INPUT>; + }; + gpio_led_1_l: led_1_l { + gpios = <&gpioc 4 GPIO_OUTPUT>; + }; + gpio_led_2_l: led_2_l { + gpios = <&gpioc 3 GPIO_OUTPUT>; + }; + gpio_led_3_l: led_3_l { + gpios = <&gpioc 2 GPIO_OUTPUT>; + }; + gpio_led_4_l: led_4_l { + gpios = <&gpio6 0 GPIO_OUTPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_mech_pwr_btn_odl: mech_pwr_btn_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_seq_ec_all_sys_pg: seq_ec_all_sys_pg { + gpios = <&gpiof 4 GPIO_INPUT>; + }; + gpio_seq_ec_rsmrst_odl: seq_ec_rsmrst_odl { + gpios = <&gpioe 2 GPIO_INPUT>; + }; + gpio_slp_s3_ls_l: slp_s3_ls_l { + gpios = <&gpio4 1 GPIO_INPUT>; + }; + gpio_sochot_odl: sochot_odl { + gpios = <&gpio9 6 GPIO_INPUT>; + }; + gpio_soc_pwrok: soc_pwrok { + gpios = <&gpioa 5 GPIO_OUTPUT>; + }; + gpio_sys_pwrok: sys_pwrok { + gpios = <&gpiob 0 GPIO_OUTPUT>; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpioc 5 GPIO_INPUT>; + }; + gpio_sys_slp_s0ix_3v3_l: sys_slp_s0ix_3v3_l { + gpios = <&gpiod 5 GPIO_INPUT>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpio9 5 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio6 2 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + gpio_usb_c0_rt_3p3_sx_en: usb_c0_rt_3p3_sx_en { + gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_rt_int_odl: usb_c0_rt_int_odl { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; + }; + gpio_usb_c0_tcpc_rst_odl: usb_c0_tcpc_rst_odl { + gpios = <&gpio6 7 GPIO_ODR_HIGH>; + }; + gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { + gpios = <&gpio5 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_BC12_INT_ODL"; + }; + gpio_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&gpio8 3 GPIO_ODR_HIGH>; + }; + gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PPC_INT_ODL"; + }; + gpio_usb_c1_rst_odl: usb_c1_rst_odl { + gpios = <&gpio3 7 GPIO_ODR_LOW>; + }; + gpio_usb_c1_rt_int_odl: usb_c1_rt_int_odl { + gpios = <&gpio7 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_rt_rst_r_odl: usb_c1_rt_rst_r_odl { + gpios = <&gpio7 4 GPIO_ODR_HIGH>; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpio3 4 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_usb_c0_tcp: ec_i2c_usb_c0_tcp { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + i2c_ec_i2c_usb_c0_ppc_b: ec_i2c_usb_c0_ppc_b { + i2c-port = <&i2c2_0>; + enum-names = "I2C_PORT_PPC0"; + }; + i2c_ec_i2c_usb_c0_rt: ec_i2c_usb_c0_rt { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_C0_RT"; + }; + i2c_ec_i2c_usb_c1_tcp: ec_i2c_usb_c1_tcp { + i2c-port = <&i2c4_1>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + dynamic-speed; + }; + i2c_ec_i2c_bat: ec_i2c_bat { + i2c-port = <&i2c5_0>; + enum-names = "I2C_PORT_BATTERY"; + }; + i2c_ec_i2c_usb_c1_mix: ec_i2c_usb_c1_mix { + i2c-port = <&i2c6_1>; + enum-names = "I2C_PORT_USB_1_MIX"; + }; + i2c_ec_i2c_mi: ec_i2c_mi { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + }; +}; + +&adc0 { + status = "okay"; +}; + +&i2c0_0 { + status = "okay"; +}; + +&i2c1_0 { + status = "okay"; +}; + +&i2c2_0 { + status = "okay"; +}; + +&i2c3_0 { + status = "okay"; +}; + +&i2c4_1 { + status = "okay"; +}; + +&i2c5_0 { + status = "okay"; +}; + +&i2c6_1 { + status = "okay"; +}; + +&i2c7_0 { + status = "okay"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c_ctrl4 { + status = "okay"; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c_ctrl6 { + status = "okay"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/rex/include/gpio_map.h b/zephyr/program/rex/include/gpio_map.h new file mode 100644 index 0000000000..01cbc44396 --- /dev/null +++ b/zephyr/program/rex/include/gpio_map.h @@ -0,0 +1,9 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __ZEPHYR_GPIO_MAP_H +#define __ZEPHYR_GPIO_MAP_H + +#endif /* __ZEPHYR_GPIO_MAP_H */ diff --git a/zephyr/program/rex/interrupts.dts b/zephyr/program/rex/interrupts.dts new file mode 100644 index 0000000000..7de9141caf --- /dev/null +++ b/zephyr/program/rex/interrupts.dts @@ -0,0 +1,80 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_ac_present: ac_present { + irq-pin = <&gpio_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_mech_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_usb_c0_sbu_fault: c0_sbu_fault { + irq-pin = <&ioex_usb_c0_sbu_fault_odl>; + flags = ; + handler = "sbu_fault_interrupt"; + }; + int_usb_c0_tcpc: usb_c0_tcpc { + irq-pin = <&gpio_usb_c0_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&gpio_usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-pin = <&gpio_usb_c1_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_ppc: usb_c1_ppc { + irq-pin = <&gpio_usb_c1_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_ec_imu_int_r_l>; + flags = ; + handler = "lsm6dso_interrupt"; + }; + int_als_rgb: ec_als_rgb { + irq-pin = <&gpio_ec_als_rgb_int_r_l>; + flags = ; + handler = "tcs3400_interrupt"; + }; + int_accel: ec_accel { + irq-pin = <&gpio_ec_accel_int_r_l>; + flags = ; + handler = "lis2dw12_interrupt"; + }; + }; +}; + +/* Required node label that doesn't is named differently on Rex */ +gpio_ec_pch_wake_odl: &gpio_ec_soc_wake_r_odl {}; + diff --git a/zephyr/program/rex/keyboard.dts b/zephyr/program/rex/keyboard.dts new file mode 100644 index 0000000000..91fad2db92 --- /dev/null +++ b/zephyr/program/rex/keyboard.dts @@ -0,0 +1,47 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm3 0 PWM_HZ(2400) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm3 { + status = "okay"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/rex/led.dts b/zephyr/program/rex/led.dts new file mode 100644 index 0000000000..94acb6da5c --- /dev/null +++ b/zephyr/program/rex/led.dts @@ -0,0 +1,138 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_led_1_l 1>, + <&gpio_led_2_l 1>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&gpio_led_1_l 1>, + <&gpio_led_2_l 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_led_1_l 0>, + <&gpio_led_2_l 1>; + }; + }; + + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* Blue 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Red 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* White 2 sec, Amber 2 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + }; + + power-state-idle-default { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_white>; + }; + }; + }; +}; + +&gpio_led_1_l { + #led-pin-cells = <1>; +}; + +&gpio_led_2_l { + #led-pin-cells = <1>; +}; + +&gpio_led_3_l { + #led-pin-cells = <1>; +}; + +&gpio_led_4_l { + #led-pin-cells = <1>; +}; diff --git a/zephyr/program/rex/motionsense.dts b/zephyr/program/rex/motionsense.dts new file mode 100644 index 0000000000..6af7cd2b12 --- /dev/null +++ b/zephyr/program/rex/motionsense.dts @@ -0,0 +1,257 @@ +/* + * Copyright 2022 The ChromiumOS Authors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + lsm6dso-int = &base_accel; + lis2dw12-int = &lid_accel; + tcs3400-int = &als_clear; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + mutex_lis2dw12: lis2dw12-mutex { + }; + + mutex_lsm6dso: lsm6dso-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + lsm6dso_accel_data: lsm6dso-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lsm6dso_gyro_data: lsm6dso-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + tcs_clear_data: tcs3400-clear-drv-data { + compatible = "cros-ec,drvdata-tcs3400-clear"; + status = "okay"; + + als-drv-data { + compatible = "cros-ec,accelgyro-als-drv-data"; + als-cal { + scale = <1>; + uscale = <0>; + offset = <0>; + als-channel-scale { + compatible = + "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + + tcs_rgb_data: tcs3400-rgb-drv-data { + compatible = "cros-ec,drvdata-tcs3400-rgb"; + status = "okay"; + + /* node for rgb_calibration_t defined in accelgyro.h */ + rgb_calibration { + compatible = + "cros-ec,accelgyro-rgb-calibration"; + + irt = <1>; + + rgb-cal-x { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = + "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-y { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = + "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + rgb-cal-z { + offset = <0>; + coeff = <0 0 0 1>; + als-channel-scale { + compatible = + "cros-ec,accelgyro-als-channel-scale"; + k-channel-scale = <1>; + cover-scale = <1>; + }; + }; + }; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&mutex_lis2dw12>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,lsm6dso-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_lsm6dso>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <4>; + drv-data = <&lsm6dso_accel_data>; + i2c-spi-addr-flags = "LSM6DSO_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,lsm6dso-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_lsm6dso>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dso_gyro_data>; + i2c-spi-addr-flags = "LSM6DSO_ADDR0_FLAGS"; + }; + + als_clear: base-als-clear { + compatible = "cros-ec,tcs3400-clear"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + port = <&i2c_ec_i2c_sensor>; + default-range = <0x10000>; + drv-data = <&tcs_clear_data>; + i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + /* Run ALS sensor in S0 */ + odr = <1000>; + }; + }; + }; + + base-als-rgb { + compatible = "cros-ec,tcs3400-rgb"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_CAMERA"; + default-range = <0x10000>; /* scale = 1x, uscale = 0 */ + drv-data = <&tcs_rgb_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* list of entries for motion_als_sensors */ + als-sensors = <&als_clear>; + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu &int_als_rgb &int_accel>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel &als_clear>; + }; +}; diff --git a/zephyr/program/rex/power_signals.dts b/zephyr/program/rex/power_signals.dts new file mode 100644 index 0000000000..09c84b8558 --- /dev/null +++ b/zephyr/program/rex/power_signals.dts @@ -0,0 +1,152 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <3>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP1800_S5/PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; + output; + }; + pwr-pg-ec-rsmrst-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>; + output; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpioc 5 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpiod 5 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; +/* + * TODO: Initially, use virtual wire for sleep S3 signal instead of + * of the GPIO signal which also exists. + * compatible = "intel,ap-pwrseq-gpio"; + * gpios = <&gpio4 1 GPIO_ACTIVE_LOW>; + * interrupt-flags = ; + */ + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + gpios = <&gpiof 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + interrupt-flags = ; + }; +}; + +/* + * Because the power signals directly reference the GPIOs, + * the corresponding named-gpios need to have no-auto-init set. + */ + /* pwr-en-pp3300-s5 */ +&gpio_en_s5_rails { + no-auto-init; +}; + +/* pwr-pg-ec-rsmrst-od */ +&gpio_seq_ec_rsmrst_odl { + no-auto-init; +}; + +/* pwr-ec-pch-rsmrst-odl */ +&gpio_ec_soc_rsmrst_l { + no-auto-init; +}; + +/* pwr-pch-pwrok */ +&gpio_soc_pwrok { + no-auto-init; +}; + +/* pwr-ec-pch-sys-pwrok */ +&gpio_sys_pwrok { + no-auto-init; +}; + +/* pwr-sys-rst-l */ +&gpio_sys_rst_odl { + no-auto-init; +}; + +/* pwr-slp-s0-l */ +&gpio_sys_slp_s0ix_3v3_l { + no-auto-init; +}; + +/* pwr-slp-s3-l */ +&gpio_slp_s3_ls_l { + no-auto-init; +}; + +/* pwr-all-sys-pwrgd */ +&gpio_seq_ec_all_sys_pg { + no-auto-init; +}; + diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf new file mode 100644 index 0000000000..7dcb2894da --- /dev/null +++ b/zephyr/program/rex/prj.conf @@ -0,0 +1,180 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_PLATFORM_EC=y +CONFIG_CROS_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_SYSCON=y +# Enable during development +CONFIG_LTO=n +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y + +# Shell Commands +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y +CONFIG_KERNEL_SHELL=y + +# Logging +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y + +# Disable default features we don't want in a minimal example. +CONFIG_PLATFORM_EC_BACKLIGHT_LID=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_PLATFORM_EC_VBOOT_EFS2=y + +# Application processor; communicates with EC via eSPI +CONFIG_AP=y +CONFIG_ESPI=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y +CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y +CONFIG_PLATFORM_EC_HOSTCMD=y +# Disabling this until temp sensor support is in +CONFIG_PLATFORM_EC_THROTTLE_AP=n +CONFIG_PLATFORM_EC_PORT80=y + +# Power Sequecing +CONFIG_AP_X86_INTEL_MTL=y +CONFIG_X86_NON_DSX_PWRSEQ_MTL=y +CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y +# TODO (b/240434243): This may be needed, but using eSPI VW for now +CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n + +# Zephyr Inbuilt AP Power Sequencing Config +CONFIG_AP_PWRSEQ=y +CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y +CONFIG_AP_PWRSEQ_S0IX=y + +# ADC +CONFIG_ADC=y + +# I2C +CONFIG_I2C=y +CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y + +# PWM +CONFIG_PWM=y + +# Fan +CONFIG_TACH_NPCX=y + +# Temperature sensors +CONFIG_SENSOR=y +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y +CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y + +# CBI EEPROM support +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_CBI_EEPROM=y +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y +CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y + +# Charger +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512 +CONFIG_PLATFORM_EC_CHARGER_ISL9241=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=30000 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 + +# USB-A +CONFIG_PLATFORM_EC_USBA=y + +# USBC +CONFIG_PLATFORM_EC_USBC_PPC=y +CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X_SMART_DISCHARGE=y +CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y +CONFIG_PLATFORM_EC_USBC_VCONN=y + +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y +CONFIG_PLATFORM_EC_USB_PD_REV30=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y +CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y +CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y +CONFIG_PLATFORM_EC_USB_PD_USB4=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y +CONFIG_PLATFORM_EC_USB_PID=0x504D + +# IOEX +CONFIG_GPIO_NCT38XX=y + +# BC 1.2 +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y + +#USB Mux +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_MUX_TASK=y + +# External power +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y + +# Standard shimmed features +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_LID_SWITCH=y + +# Keyboard support +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y +# Column 2 is driven through the GSC, which inverts the signal going through it +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y + +# MKBP event +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y + +# Sensors console command +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y + +# Sensors +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y +CONFIG_PLATFORM_EC_ALS_TCS3400=y diff --git a/zephyr/program/rex/prj_rex.conf b/zephyr/program/rex/prj_rex.conf new file mode 100644 index 0000000000..0f204b9669 --- /dev/null +++ b/zephyr/program/rex/prj_rex.conf @@ -0,0 +1,9 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Rex reference-board-specific Kconfig settings. +CONFIG_BOARD_REX=y + +# Keyboard +CONFIG_CROS_KB_RAW_NPCX=y diff --git a/zephyr/program/rex/rex.dts b/zephyr/program/rex/rex.dts new file mode 100644 index 0000000000..2d7e1b89ba --- /dev/null +++ b/zephyr/program/rex/rex.dts @@ -0,0 +1,262 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + #include + +/ { + aliases { + gpio-wp = &ec_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + ec_wp_l: write-protect { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + gpio_ec_entering_rw: ec_entering_rw { + enum-name = "GPIO_ENTERING_RW"; + }; + + ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl { + gpios = <&ioex_c0_port1 2 GPIO_INPUT>; + }; + ioex_usb_c0_rt_rst_ls_l: usb_c0_rt_rst_ls_l { + gpios = <&ioex_c0_port0 7 GPIO_OUTPUT>; + }; + + ioex_usb_c0_frs_en: usb_c0_frs_en { + gpios = <&ioex_c0_port0 6 GPIO_OUTPUT_LOW>; + }; + + /* Need to designate 1.8V for I2C buses on the 1800mV rail */ + ec-i2c-sensor-scl { + gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-c0-rt-scl { + gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-c0-rt-sda { + gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_pp5000_usba_r>; + }; +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; + +/* Power switch logic input pads */ +&psl_in1_gpd2 { + /* LID_OPEN */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in2_gp00 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* MECH_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; +}; + +/* ADC and GPIO alt-function specifications */ +&adc0 { + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan8_gpf1 + &adc0_chan7_gpe1>; + pinctrl-names = "default"; +}; + +&i2c0_0 { + label = "I2C_SENSOR"; + clock-frequency = ; + + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c1_0 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + tcpc_port0: nct38xx@70 { + compatible = "nuvoton,nct38xx"; + gpio-dev = <&nct3807_C0>; + reg = <0x70>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct3807_C0: nct3807_C0@70 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x70>; + label = "NCT3807_C0"; + + ioex_c0_port0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3807_C0_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + pinmux_mask = <0xf7>; + }; + ioex_c0_port1: gpio@1 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x1>; + label = "NCT3807_C0_GPIO1"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + }; + }; + + nct3808_alert_0 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct3807_C0>; + label = "NCT3807_ALERT_0"; + }; +}; + +&i2c2_0 { + label = "I2C_PPC0"; + clock-frequency = ; + + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + ppc_port0_syv: ppc_syv@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&ioex_usb_c0_frs_en>; + }; +}; + +&i2c3_0 { + label = "I2C_USB_C0_RT"; + clock-frequency = ; + + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; + + usb_c0_hb_retimer: jhl8040r-c0@56 { + compatible = "intel,jhl8040r"; + reg = <0x56>; + ls-en-pin = <&gpio_usb_c0_rt_3p3_sx_en>; + int-pin = <&gpio_usb_c0_rt_int_odl>; + reset-pin = <&ioex_usb_c0_rt_rst_ls_l>; + }; +}; + +&i2c4_1 { + label = "I2_USB_C1_TCPC"; + clock-frequency = ; + + pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; + pinctrl-names = "default"; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS)>; + }; +}; + +&i2c5_0 { + label = "I2C__BATTERY"; + clock-frequency = ; + + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; +}; + +&i2c6_1 { + label = "I2C_USB_1_MIX"; + clock-frequency = ; + + pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; + pinctrl-names = "default"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c1_bc12>; + }; + + ppc_port1_nxp: nx20p348x@72 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x72>; + }; +}; + +&i2c7_0 { + label = "I2C_CHARGER"; + clock-frequency = ; + + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; + + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x09>; + }; +}; diff --git a/zephyr/program/rex/rex0_gpio.csv b/zephyr/program/rex/rex0_gpio.csv new file mode 100644 index 0000000000..5c20f6fb00 --- /dev/null +++ b/zephyr/program/rex/rex0_gpio.csv @@ -0,0 +1,122 @@ +Signal Name,Pin Number,Type,Enum +USB_C1_BC12_INT_ODL,G10,INPUT,GPIO_USB_C1_BC12_INT_ODL +ESPI_SOC_CS0_L,L2,OTHER, +ESPI_SOC_RESET_L,K3,OTHER, +ESPI_SOC_CLK,M1,OTHER, +EC_IMU_INT_R_L,M2,INPUT_PU, +ESPI_SOC_IO0,H1,OTHER, +ESPI_SOC_IO1,J1,OTHER, +ESPI_SOC_IO2,K1,OTHER, +ESPI_SOC_IO3,L1,OTHER, +ESPI_SOC_ALERT_L_R,L3,OTHER, +EC_VOLDN_BTN_ODL,E11,INPUT_PU,GPIO_VOLUME_DOWN_L +TABLET_MODE_L,M12,INPUT_PU,GPIO_TABLET_MODE_L +SOCHOT_ODL,G12,INPUT, +EC_VOLUP_BTN_ODL,L10,INPUT_PU,GPIO_VOLUME_UP_L +USB_C0_RT_INT_ODL,G11,INPUT, +EC_WP_L,L12,INPUT, +EC_BATT_PRES_ODL,K12,INPUT,GPIO_BATT_PRES_ODL +CPU_C10_GATE_L,J11,INPUT, +SOC_PWROK,K11,OUTPUT, +EC_SOC_RSMRST_L,F11,OUTPUT, +SYS_PWROK,L11,OUTPUT, +EC_SPARE_GPIO94,M11,OUTPUT, +EC_SPARE_GPIOA2,F12,OUTPUT, +EC_SPARE_GPIOA4,H11,OUTPUT, +EC_ACCEL_INT_R_L,M7,INPUT, +SLP_S3_LS_L,C2,INPUT, +IMVP92_VRRDY_OD,E2,INPUT, +EC_PROCHOT_IN_L,D2,INPUT, +EC_SPARE_GPIO42,D3,OUTPUT, +TEMP_SENSOR_2,E3,ADC,ADC_TEMP_SENSOR_2 +TEMP_SENSOR_1,F2,ADC,ADC_TEMP_SENSOR_1 +TEMP_SENSOR_4,F3,ADC,ADC_TEMP_SENSOR_4 +TEMP_SENSOR_3,G3,ADC,ADC_TEMP_SENSOR_3 +SYS_RST_ODL,H7,INPUT, +EC_SOC_WAKE_R_ODL,H8,OUTPUT_ODL, +EC_PROCHOT_ODL,J2,OUTPUT_ODR, +EC_SOC_INT_ODL,J4,OUTPUT_ODL,GPIO_EC_INT_L +EC_SOC_RTCRST,J5,OUTPUT_ODR, +EC_SOC_PWR_BTN_ODL,H9,OUTPUT_ODL,GPIO_PCH_PWRBTN_L +USB_C0_RT_3P3_SX_EN,D9,OUTPUT_ODR, +KSO_13,D11,OTHER, +KSO_12,C11,OTHER, +KSO_11,B10,OTHER, +KSO_10,B11,OTHER, +KSO_09,C10,OTHER, +KSO_08,C9,OTHER, +KSO_05,C6,OTHER, +KSO_04,C7,OTHER, +KSO_03,B8,OTHER, +EC_KSO_02_INV,B7,OUTPUT_L, +KSO_01,B6,OTHER, +KSO_00,B5,OTHER, +KSI_07,C5,OTHER, +KSI_06,C4,OTHER, +KSI_05,C3,OTHER, +KSI_04,B4,OTHER, +EC_KSI_03,B3,OTHER, +EC_KSI_02,A4,OTHER, +KSI_01,A3,OTHER, +EC_KSI_00,A2,OTHER, +EC_I2C_BAT_SCL,D5,I2C_CLOCK,I2C_PORT_BATTERY +USB_C1_TCPC_INT_ODL,B2,INPUT,GPIO_USB_C1_TCPC_INT_ODL +EC_I2C_BAT_SDA,D4,I2C_DATA, +USB_C1_RST_ODL,C1,OUTPUT_ODL, +EC_FAN_TACH,E5,TACH, +LED_4_L,G6,OUTPUT, +EN_PP5000_FAN,K4,OUTPUT_ODR, +USB_C0_PPC_INT_ODL,H2,INPUT,GPIO_USB_C0_PPC_INT_ODL +UART_GSC_DBG_TX_EC_RX_R,G4,OTHER, +EC_SPARE_GPIO66,G2,OUTPUT, +USB_C0_TCPC_RST_ODL,J3,OUTPUT_ODL, +USB_C1_RT_INT_ODL,M4,INPUT_PU, +EC_CBI_WP,G5,OUTPUT, +USB_C1_RT_RST_R_ODL,H5,OUTPUT_ODL, +EC_GSC_PACKET_MODE,J6,OUTPUT_ODR,GPIO_PACKET_MODE_EN +EC_KB_BL_PWM,K5,PWM,GPIO_EN_KEYBOARD_BACKLIGHT +KSO_14,D6,OTHER, +USB_C1_FRS_EN,D7,OUTPUT_ODR, +EC_I2C_USB_C0_TCPC_SDA,K7,I2C_DATA, +EC_I2C_USB_C0_TCPC_SCL,K8,I2C_CLOCK,I2C_PORT_USB_C0_TCPC +EC_I2C_USB_C0_PPC_BC_SDA,K9,I2C_DATA, +EC_I2C_USB_C0_PPC_BC_SCL,L8,I2C_CLOCK,I2C_PORT_PPC0 +EC_IMVP92_EN_SMB,D8,OUTPUT, +EC_I2C_MISC_SDA,K10,I2C_DATA, +EC_I2C_MISC_SCL,J10,I2C_CLOCK,I2C_PORT_EEPROM +EC_I2C_SENSOR_SDA,B12,I2C_DATA, +EC_I2C_SENSOR_SCL,C12,I2C_CLOCK,I2C_PORT_SENSOR +EN_S5_RAILS,L9,OUTPUT_ODR, +FAN_PWM,J7,PWM, +LED_3_L,H10,OUTPUT, +LED_2_L,G9,OUTPUT, +LED_1_L,G8,OUTPUT, +USB_C0_BC12_INT_ODL,D10,INPUT,GPIO_USB_C0_BC12_INT_ODL +EC_SPARE_GPIOC7,F10,OUTPUT, +EC_I2C_USB_C0_RT_SDA,F9,I2C_DATA, +EC_I2C_USB_C0_RT_SCL,F8,I2C_CLOCK,I2C_PORT_USB_C0_RT +EC_EDP_BL_EN,E10,OUTPUT_ODR,GPIO_ENABLE_BACKLIGHT +EC_ALS_RGB_INT_R_L,A9,INPUT_PU, +SYS_SLP_S0IX_3V3_L,A10,INPUT, +USB_C0_TCPC_INT_ODL,F4,INPUT,GPIO_USB_C0_TCPC_INT_ODL +SEQ_EC_RSMRST_ODL,A11,INPUT, +EC_I2C_USB_C1_MIX_SDA,L7,I2C_DATA, +EC_I2C_USB_C1_MIX_SCL,L6,I2C_CLOCK,I2C_PORT_USB_1_MIX +CCD_MODE_ODL,A12,OUTPUT_ODL,GPIO_CCD_MODE_ODL +EC_I2C_USB_C1_TCPC_SDA,F6,I2C_DATA, +EC_I2C_USB_C1_TCPC_SCL,F5,I2C_CLOCK,I2C_PORT_USB_C1_TCPC +SEQ_EC_ALL_SYS_PG,E9,INPUT, +USB_C1_PPC_INT_ODL,E8,INPUT,GPIO_USB_C1_PPC_INT_ODL +EC_KSO_07_JEN_L,B9,OTHER, +EC_KSO_06_GP_SEL_L,C8,OTHER, +EC_SPARE_GPO32,E4,OUTPUT, +EC_SPARE_GPO35,K2,OUTPUT, +UART_GSC_DBG_RX_EC_TX_R,H4,OTHER, +EC_RST_R_ODL,K6,INPUT, +EC_KB_BL_EN_L,J9,OUTPUT, +ACOK_OD,E7,INPUT,GPIO_AC_PRESENT +GSC_EC_PWR_BTN_ODL,E6,INPUT_PU,GPIO_POWER_BUTTON_L +MECH_PWR_BTN_ODL,F7,INPUT, +LID_OPEN,G7,INPUT_PU,GPIO_LID_OPEN +EN_Z1_RAILS,J8,OUTPUT, +EN_PP5000_USBA_R,H6,OUTPUT, diff --git a/zephyr/program/rex/src/board_power.c b/zephyr/program/rex/src/board_power.c new file mode 100644 index 0000000000..c7f12d024e --- /dev/null +++ b/zephyr/program/rex/src/board_power.c @@ -0,0 +1,61 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "gpio_signal.h" +#include "gpio/gpio.h" + +LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); + +#if CONFIG_X86_NON_DSX_PWRSEQ_MTL +#define X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS 50 + +void board_ap_power_force_shutdown(void) +{ + int timeout_ms = X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS; + + /* Turn off PCH_RMSRST to meet tPCH12 */ + power_signal_set(PWR_EC_PCH_RSMRST, 0); + + /* Turn off PRIM load switch. */ + power_signal_set(PWR_EN_PP3300_A, 0); + + /* Wait RSMRST to be off. */ + while (power_signal_get(PWR_RSMRST) && (timeout_ms > 0)) { + k_msleep(1); + timeout_ms--; + }; + + if (power_signal_get(PWR_RSMRST)) { + LOG_WRN("RSMRST_ODL didn't go low! Assuming G3."); + } +} + +void board_ap_power_action_g3_s5(void) +{ + /* Turn on the PP3300_PRIM rail. */ + power_signal_set(PWR_EN_PP3300_A, 1); + + if (!power_wait_signals_timeout( + IN_PGOOD_ALL_CORE, + AP_PWRSEQ_DT_VALUE(wait_signal_timeout))) { + ap_power_ev_send_callbacks(AP_POWER_PRE_INIT); + } +} + +bool board_ap_power_check_power_rails_enabled(void) +{ + return power_signal_get(PWR_EN_PP3300_A); +} +#endif /* CONFIG_X86_NON_DSX_PWRSEQ_MTL */ diff --git a/zephyr/program/rex/src/usb_pd_policy.c b/zephyr/program/rex/src/usb_pd_policy.c new file mode 100644 index 0000000000..7e9876f9c1 --- /dev/null +++ b/zephyr/program/rex/src/usb_pd_policy.c @@ -0,0 +1,77 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Shared USB-C policy for Rex boards */ + +#include + +#include "charge_manager.h" +#include "chipset.h" +#include "common.h" +#include "compile_time_macros.h" +#include "console.h" +#include "ec_commands.h" +#include "ioexpander.h" +#include "system.h" +#include "usb_mux.h" +#include "usb_pd.h" +#include "usbc_ppc.h" +#include "util.h" + +int pd_check_vconn_swap(int port) +{ + /* Allow VCONN swaps if the AP is on. */ + return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON); +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS. */ + ppc_vbus_source_enable(port, 0); + + /* Enable discharge if we were previously sourcing 5V */ + if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) + pd_set_vbus_discharge(port, 1); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + /* Disable charging. */ + rv = ppc_vbus_sink_enable(port, 0); + if (rv) + return rv; + + if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) { + pd_set_vbus_discharge(port, 0); + } + + /* Provide Vbus. */ + rv = ppc_vbus_source_enable(port, 1); + if (rv) { + return rv; + } + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */ +int board_vbus_source_enabled(int port) +{ + return tcpm_get_src_ctrl(port); +} + +/* Used by USB charger task with CONFIG_USB_PD_5V_EN_CUSTOM */ +int board_is_sourcing_vbus(int port) +{ + return board_vbus_source_enabled(port); +} diff --git a/zephyr/program/rex/src/usbc_config.c b/zephyr/program/rex/src/usbc_config.c new file mode 100644 index 0000000000..66f3a1f45d --- /dev/null +++ b/zephyr/program/rex/src/usbc_config.c @@ -0,0 +1,300 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery_fuel_gauge.h" +#include "charger.h" +#include "charge_manager.h" +#include "charge_ramp.h" +#include "charge_state_v2.h" +#include "charge_state.h" +#include "charger.h" +#include "driver/charger/isl9241.h" +#include "driver/retimer/bb_retimer_public.h" +#include "driver/tcpm/nct38xx.h" +#include "driver/tcpm/ps8xxx_public.h" +#include "driver/tcpm/tcpci.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "i2c.h" +#include "ioexpander.h" +#include "driver/ppc/nx20p348x.h" +#include "ppc/syv682x_public.h" +#include "system.h" +#include "task.h" +#include "usb_mux.h" +#include "usbc_ppc.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/*******************************************************************/ +/* USB-C Configuration Start */ + +/* USB-C ports */ +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; +BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); + +static void usbc_interrupt_init(void) +{ + /* Only reset TCPC if not sysjump */ + if (!system_jumped_late()) { + board_reset_pd_mcu(); + } + + /* Enable PPC interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc)); + + /* Enable TCPC interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc)); + + /* Enable BC 1.2 interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12)); + + /* Enable SBU fault interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault)); +} +DECLARE_HOOK(HOOK_INIT, usbc_interrupt_init, HOOK_PRIO_POST_I2C); + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* + * TODO: Meteorlake PCH does not use Physical GPIO for over current + * error, hence Send 'Over Current Virtual Wire' eSPI signal. + */ +} + +void sbu_fault_interrupt(enum gpio_signal signal) +{ + int port = USBC_PORT_C0; + + CPRINTSUSB("C%d: SBU fault", port); + pd_handle_overcurrent(port); +} + +void tcpc_alert_event(enum gpio_signal signal) +{ + int port; + + switch (signal) { + case GPIO_USB_C0_TCPC_INT_ODL: + port = 0; + break; + case GPIO_USB_C1_TCPC_INT_ODL: + port = 1; + break; + default: + return; + } + + schedule_deferred_pd_interrupt(port); +} + +static void reset_nct38xx_port(int port) +{ + const struct gpio_dt_spec *reset_gpio_l; + const struct device *ioex_port0, *ioex_port1; + + /* TODO(b/225189538): Save and restore ioex signals */ + if (port == USBC_PORT_C0) { + reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl); + ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0)); + ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port1)); + } else { + /* Invalid port: do nothing */ + return; + } + + gpio_pin_set_dt(reset_gpio_l, 0); + msleep(NCT38XX_RESET_HOLD_DELAY_MS); + gpio_pin_set_dt(reset_gpio_l, 1); + nct38xx_reset_notify(port); + if (NCT3807_RESET_POST_DELAY_MS != 0) { + msleep(NCT3807_RESET_POST_DELAY_MS); + } + + /* Re-enable the IO expander pins */ + gpio_reset_port(ioex_port0); + gpio_reset_port(ioex_port1); +} + +void board_reset_pd_mcu(void) +{ + /* Reset TCPC0 */ + reset_nct38xx_port(USBC_PORT_C0); + + /* Reset TCPC1 */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 0); + msleep(PS8XXX_RESET_DELAY_MS); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 1); + msleep(PS8815_FW_INIT_DELAY_MS); +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + const struct gpio_dt_spec *tcpc_c0_rst_l; + const struct gpio_dt_spec *tcpc_c0_int_l; + const struct gpio_dt_spec *tcpc_c1_rst_l; + const struct gpio_dt_spec *tcpc_c1_int_l; + + tcpc_c0_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl); + tcpc_c0_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl); + + tcpc_c1_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl); + tcpc_c1_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl); + + /* + * Check which port has the ALERT line set and ignore if that TCPC has + * its reset line active. + */ + if (!gpio_pin_get_dt(tcpc_c0_int_l) && gpio_pin_get_dt(tcpc_c0_rst_l)) { + status |= PD_STATUS_TCPC_ALERT_0; + } + + if (!gpio_pin_get_dt(tcpc_c1_int_l) && gpio_pin_get_dt(tcpc_c1_rst_l)) { + status |= PD_STATUS_TCPC_ALERT_1; + } + + return status; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + syv682x_interrupt(USBC_PORT_C0); + break; + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(USBC_PORT_C1); + break; + default: + break; + } +} + +void bc12_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_BC12_INT_ODL: + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + break; + case GPIO_USB_C1_BC12_INT_ODL: + usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); + break; + default: + break; + } +} + +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) +{ + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} + +static void board_disable_charger_ports(void) +{ + int i; + + CPRINTSUSB("Disabling all charger ports"); + + /* Disable all ports. */ + for (i = 0; i < ppc_cnt; i++) { + /* + * If this port had booted in dead battery mode, go + * ahead and reset it so EN_SNK responds properly. + */ + if (nct38xx_get_boot_type(i) == NCT38XX_BOOT_DEAD_BATTERY) { + reset_nct38xx_port(i); + pd_set_error_recovery(i); + } + + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (ppc_vbus_sink_enable(i, 0)) { + CPRINTSUSB("Disabling C%d as sink failed.", i); + } + } +} + +int board_set_active_charge_port(int port) +{ + int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + int rv; + + if (port == CHARGE_PORT_NONE) { + board_disable_charger_ports(); + return EC_SUCCESS; + } else if (!is_valid_port) { + return EC_ERROR_INVAL; + } + + /* + * Check if we can reset any ports in dead battery mode + * + * The NCT3807 may continue to keep EN_SNK low on the dead battery port + * and allow a dangerous level of voltage to pass through to the initial + * charge port (see b/183660105). We must reset the ports if we have + * sufficient battery to do so, which will bring EN_SNK back under + * normal control. + */ + rv = EC_SUCCESS; + if (port == USBC_PORT_C0 && + nct38xx_get_boot_type(port) == NCT38XX_BOOT_DEAD_BATTERY) { + /* Handle dead battery boot case */ + CPRINTSUSB("Found dead battery on C0"); + /* + * If we have battery, get this port reset ASAP. + * This means temporarily rejecting charge manager + * sets to it. + */ + if (pd_is_battery_capable()) { + reset_nct38xx_port(port); + pd_set_error_recovery(port); + } + } + + if (rv != EC_SUCCESS) { + return rv; + } + + /* Check if the port is sourcing VBUS. */ + if (tcpm_get_src_ctrl(port)) { + CPRINTSUSB("Skip enable C%d", port); + return EC_ERROR_INVAL; + } + + CPRINTSUSB("New charge port: C%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < ppc_cnt; i++) { + if (i == port) { + continue; + } + if (ppc_vbus_sink_enable(i, 0)) { + CPRINTSUSB("C%d: sink path disable failed.", i); + } + } + + /* Enable requested charge port. */ + if (ppc_vbus_sink_enable(port, 1)) { + CPRINTSUSB("C%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} diff --git a/zephyr/program/rex/temp_sensors.dts b/zephyr/program/rex/temp_sensors.dts new file mode 100644 index 0000000000..680ebc8954 --- /dev/null +++ b/zephyr/program/rex/temp_sensors.dts @@ -0,0 +1,69 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + temp_ddr_soc: ddr_soc { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_ddr_soc>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_ambient>; + }; + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_charger>; + }; + temp_wwan: wwan { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_wwan>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ddr_soc { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + sensor = <&temp_ddr_soc>; + }; + ambient { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + sensor = <&temp_ambient>; + }; + charger { + temp_fan_off = <35>; + temp_fan_max = <65>; + temp_host_high = <105>; + temp_host_halt = <120>; + temp_host_release_high = <90>; + sensor = <&temp_charger>; + }; + wwan { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <130>; + temp_host_halt = <130>; + temp_host_release_high = <100>; + sensor = <&temp_wwan>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_4050B { + status = "okay"; +}; diff --git a/zephyr/program/rex/usbc.dts b/zephyr/program/rex/usbc.dts new file mode 100644 index 0000000000..84ae79fae6 --- /dev/null +++ b/zephyr/program/rex/usbc.dts @@ -0,0 +1,51 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + usbc_port0: port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0_syv>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c0_hb_retimer + &virtual_mux_c0>; + }; + }; + port0-muxes { + virtual_mux_c0: virtual-mux-c0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + usbc_port1: port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1_nxp>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_c1 &tcpci_mux_c1>; + }; + }; + port1-muxes { + tcpci_mux_c1: tcpci-mux-c1 { + compatible = "cros-ec,usbc-mux-tcpci"; + hpd-update = "ps8xxx_tcpc_update_hpd_status"; + }; + virtual_mux_c1: virtual-mux-c1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/BUILD.py b/zephyr/program/skyrim/BUILD.py new file mode 100644 index 0000000000..3807150af9 --- /dev/null +++ b/zephyr/program/skyrim/BUILD.py @@ -0,0 +1,86 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for skyrim.""" + + +def register_skyrim_project( + project_name, + extra_dts_overlays=(), + extra_kconfig_files=(), +): + """Register a variant of skyrim.""" + register_npcx_project( + project_name=project_name, + zephyr_board="npcx9m3f", + dts_overlays=[ + # Common to all projects. + here / "adc.dts", + here / "fan.dts", + here / "gpio.dts", + here / "interrupts.dts", + here / "keyboard.dts", + here / "motionsense.dts", + here / "usbc.dts", + # Project-specific DTS customizations. + *extra_dts_overlays, + ], + kconfig_files=[here / "prj.conf", *extra_kconfig_files], + ) + + +register_skyrim_project( + project_name="morthal", + extra_dts_overlays=[ + here / "morthal.dts", + here / "battery_morthal.dts", + here / "led_pins_morthal.dts", + here / "led_policy_morthal.dts", + ], + extra_kconfig_files=[ + here / "prj_morthal.conf", + ], +) + + +register_skyrim_project( + project_name="skyrim", + extra_dts_overlays=[ + here / "skyrim.dts", + here / "battery_skyrim.dts", + here / "led_pins_skyrim.dts", + here / "led_policy_skyrim.dts", + ], + extra_kconfig_files=[ + here / "prj_skyrim.conf", + ], +) + + +register_skyrim_project( + project_name="winterhold", + extra_dts_overlays=[ + here / "winterhold.dts", + here / "battery_winterhold.dts", + here / "led_pins_winterhold.dts", + here / "led_policy_winterhold.dts", + ], + extra_kconfig_files=[ + here / "prj_winterhold.conf", + ], +) + + +register_skyrim_project( + project_name="frostflow", + extra_dts_overlays=[ + here / "frostflow.dts", + here / "battery_frostflow.dts", + here / "led_pins_frostflow.dts", + here / "led_policy_frostflow.dts", + ], + extra_kconfig_files=[ + here / "prj_frostflow.conf", + ], +) diff --git a/zephyr/program/skyrim/CMakeLists.txt b/zephyr/program/skyrim/CMakeLists.txt new file mode 100644 index 0000000000..71b8427aa1 --- /dev/null +++ b/zephyr/program/skyrim/CMakeLists.txt @@ -0,0 +1,62 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") + +zephyr_library_sources("src/common.c") +zephyr_library_sources("src/power_signals.c") + +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/usb_pd_policy.c" + "src/usbc_config.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON + "src/led.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_AMD_STT + "src/stt.c") + +if(DEFINED CONFIG_BOARD_MORTHAL) + project(morthal) + zephyr_library_sources( + "src/morthal/ppc_config.c" + "src/morthal/usb_mux_config.c" +) +endif() + +if(DEFINED CONFIG_BOARD_SKYRIM) + project(skyrim) + cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include) + zephyr_library_sources( + "src/skyrim/usb_mux_config.c" + "src/skyrim/ppc_config.c" + "src/skyrim/form_factor.c" + "src/skyrim/alt_charger.c" + "src/skyrim/keyboard.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/skyrim/fan.c") +endif() + +if(DEFINED CONFIG_BOARD_WINTERHOLD) + project(winterhold) + zephyr_library_sources( + "src/winterhold/usb_mux_config.c" + "src/winterhold/ppc_config.c" + "src/winterhold/kb_backlight.c" + "src/winterhold/keyboard.c" + ) +endif() + +if(DEFINED CONFIG_BOARD_FROSTFLOW) + project(frostflow) + cros_ec_library_include_directories_ifdef(CONFIG_BOARD_FROSTFLOW include) + zephyr_include_directories("include/frostflow") + zephyr_library_sources( + "src/frostflow/usb_mux_config.c" + "src/frostflow/ppc_config.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION + "src/frostflow/keyboard.c" + "src/frostflow/keyboard_customization.c") +endif() diff --git a/zephyr/program/skyrim/Kconfig b/zephyr/program/skyrim/Kconfig new file mode 100644 index 0000000000..fbb797f6fc --- /dev/null +++ b/zephyr/program/skyrim/Kconfig @@ -0,0 +1,46 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config BOARD_MORTHAL + bool "Google Morthal Board" + help + Build Google Morthal reference board. This board uses an AMD SoC + and NPCX9 EC + +config BOARD_SKYRIM + bool "Google Skyrim Board" + help + Build Google Skyrim reference board. This board uses an AMD SoC + and NPCX9 EC + +config BOARD_WINTERHOLD + bool "Google Winterhold Board" + help + Build Google Winterhold reference board. This board uses an AMD SoC + and NPCX9 EC + +config BOARD_FROSTFLOW + bool "Google Frostflow Board" + help + Build Google Frostflow reference board. This board uses an AMD SoC + and NPCX9 EC + +config BOARD_INPUT_CURRENT_SCALE_FACTOR + int "Input current scale factor" + default 100 + help + Limit input current to fraction of negotiated limit. + +config BOARD_USB_HUB_RESET + bool "Support USB hub reset or not" + default y + help + Enable this if your board has a USB hub reset GPIO connect to EC to + reset the USB hub. + +module = SKYRIM +module-str = Skyrim board-specific code +source "subsys/logging/Kconfig.template.log_config" + +source "Kconfig.zephyr" diff --git a/zephyr/program/skyrim/adc.dts b/zephyr/program/skyrim/adc.dts new file mode 100644 index 0000000000..952e5db1d0 --- /dev/null +++ b/zephyr/program/skyrim/adc.dts @@ -0,0 +1,82 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_temp_charger: temp-charger { + enum-name = "ADC_TEMP_SENSOR_CHARGER"; + io-channels = <&adc0 1>; + }; + adc_temp_memory: temp-memory { + enum-name = "ADC_TEMP_SENSOR_MEMORY"; + io-channels = <&adc0 2>; + }; + adc_core_imon1: core-imon1 { + enum-name = "ADC_CORE_IMON1"; + io-channels = <&adc0 3>; + }; + adc_core_imon2: core-imon2 { + enum-name = "ADC_SOC_IMON2"; + io-channels = <&adc0 4>; + }; + }; + + temp_charger_thermistor: charger-thermistor { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_temp_charger>; + }; + + temp_memory_thermistor: memory-thermistor { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_temp_memory>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + temp_sensor_charger: charger-thermistor { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + sensor = <&temp_charger_thermistor>; + }; + + temp_sensor_memory: memory-thermistor { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&temp_memory_thermistor>; + }; + + temp_sensor_cpu: cpu { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_fan_off = <60>; + temp_fan_max = <90>; + power-good-pin = <&gpio_s0_pgood>; + sensor = <&temp_cpu>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42 + &adc0_chan4_gp41>; + pinctrl-names = "default"; +}; + +&thermistor_3V3_30K9_47K_4050B { + status = "okay"; +}; diff --git a/zephyr/program/skyrim/battery_frostflow.dts b/zephyr/program/skyrim/battery_frostflow.dts new file mode 100644 index 0000000000..2d6b28de70 --- /dev/null +++ b/zephyr/program/skyrim/battery_frostflow.dts @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: cdt_c340152 { + compatible = "cdt,c340152", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/battery_morthal.dts b/zephyr/program/skyrim/battery_morthal.dts new file mode 100644 index 0000000000..8c87cef7f9 --- /dev/null +++ b/zephyr/program/skyrim/battery_morthal.dts @@ -0,0 +1,15 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/battery_skyrim.dts b/zephyr/program/skyrim/battery_skyrim.dts new file mode 100644 index 0000000000..8c87cef7f9 --- /dev/null +++ b/zephyr/program/skyrim/battery_skyrim.dts @@ -0,0 +1,15 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/battery_winterhold.dts b/zephyr/program/skyrim/battery_winterhold.dts new file mode 100644 index 0000000000..8e82e0d1f2 --- /dev/null +++ b/zephyr/program/skyrim/battery_winterhold.dts @@ -0,0 +1,33 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: lgc_xphx8 { + compatible = "lgc,xphx8", "battery-smart"; + }; + smp_atlxdy9k { + compatible = "smp,atlxdy9k", "battery-smart"; + }; + smp_cosxdy9k { + compatible = "smp,cosxdy9k", "battery-smart"; + }; + byd_wv3k8 { + compatible = "byd,wv3k8", "battery-smart"; + }; + cosmx_mvk11 { + compatible = "cosmx,mvk11", "battery-smart"; + }; + sunwoda_atlvkyjx { + compatible = "sunwoda,atlvkyjx", "battery-smart"; + }; + sunwoda_cosvkyjx { + compatible = "sunwoda,cosvkyjx", "battery-smart"; + }; + atl_cfd72 { + compatible = "atl,cfd72", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/fan.dts b/zephyr/program/skyrim/fan.dts new file mode 100644 index 0000000000..dff26bcb29 --- /dev/null +++ b/zephyr/program/skyrim/fan.dts @@ -0,0 +1,39 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan0: fan_0 { + pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + rpm_min = <3100>; + rpm_start = <3100>; + rpm_max = <8000>; + tach = <&tach1>; + pgood_gpio = <&gpio_s0_pgood>; + }; + }; +}; + +/* Tachemeter for fan speed measurement */ +&tach1 { + status = "okay"; + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/frostflow.dts b/zephyr/program/skyrim/frostflow.dts new file mode 100644 index 0000000000..1ed0b4cb2b --- /dev/null +++ b/zephyr/program/skyrim/frostflow.dts @@ -0,0 +1,136 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "i2c_common.dtsi" + +/ { + named-gpios { + /* Frostflow-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <35>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; + +&cros_kb_raw { + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; +}; diff --git a/zephyr/program/skyrim/gpio.dts b/zephyr/program/skyrim/gpio.dts new file mode 100644 index 0000000000..57abcc846d --- /dev/null +++ b/zephyr/program/skyrim/gpio.dts @@ -0,0 +1,370 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_wp; + gpio-cbi-wp = &gpio_cbi_wp; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + /* GPIOs shared by all boards */ + named-gpios { + compatible = "named-gpios"; + + ccd_mode_odl { + gpios = <&gpioc 6 GPIO_ODR_HIGH>; + }; + ec_gsc_packet_mode { + gpios = <&gpiob 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_mech_pwr_btn_odl: mech_pwr_btn_odl { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpio6 1 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S3_L"; + alias = "GPIO_PCH_SLP_S0_L"; + }; + gpio_slp_s5_l: slp_s5_l { + gpios = <&gpio7 2 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S5_L"; + }; + gpio_pg_pwr_s5: pg_pwr_s5 { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_S5_PGOOD"; + }; + gpio_s0_pgood: pg_pcore_s0_r_od { + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_S0_PGOOD"; + }; + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_en_pwr_s5: en_pwr_s5 { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PWR_A"; + }; + gpio_en_pwr_s0_r: en_pwr_s0_r { + gpios = <&gpiof 1 GPIO_OUTPUT_LOW>; + }; + gpio_en_pwr_pcore_s0_r: en_pwr_pcore_s0_r { + gpios = <&gpioe 1 GPIO_OUTPUT_LOW>; + }; + ec_sys_rst_l { + gpios = <&gpio7 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_SYS_RESET_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_RSMRST_L"; + }; + gpio_ec_pch_wake_odl: ec_soc_wake_l { + gpios = <&gpio0 3 GPIO_OUTPUT_HIGH>; + }; + prochot_odl { + gpios = <&gpiod 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_CPU_PROCHOT"; + }; + soc_alert_ec_l { + gpios = <&gpioe 2 GPIO_INPUT>; + }; + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpioc 7 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio7 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { + gpios = <&gpiod 4 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PPC_INT_ODL"; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpioa 4 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { + gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_USB_C1_BC12_INT_ODL"; + }; + gpio_usb_c0_tcpc_rst_l: usb_c0_tcpc_rst_l { + gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_USB_C0_TCPC_RST_L"; + }; + gpio_usb_c1_tcpc_rst_l: usb_c1_tcpc_rst_l { + gpios = <&gpio3 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_USB_C1_TCPC_RST_L"; + }; + usb_c0_hpd { + gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_DP_HPD"; + }; + usb_c1_hpd { + gpios = <&gpiof 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_DP_HPD"; + }; + gpio_lid_open: lid_open { + gpios = <&gpio0 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + ec_batt_pres_odl { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_disable_disp_bl: ec_disable_disp_bl { + gpios = <&gpioa 6 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT_L"; + }; + gpio_usb_fault_odl: usb_fault_odl { + gpios = <&gpio5 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + gpio_en_pwr_s3: en_pwr_s3 { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_pg_groupc_s0_od: pg_groupc_s0_od { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_ec_i2c_usbc_pd_int: ec_i2c_usbc_pd_int { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_soc_thermtrip_odl: soc_thermtrip_odl { + gpios = <&gpio9 5 GPIO_INPUT>; + }; + gpio_hub_rst: hub_rst { + gpios = <&gpio6 6 GPIO_OUTPUT_HIGH>; + }; + ec_soc_int_l { + gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pwr_good: ec_soc_pwr_good { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + }; + gpio_pcore_ocp_r_l: pcore_ocp_r_l { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + gpio_usb_hub_fault_q_odl: usb_hub_fault_q_odl { + gpios = <&gpioe 5 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_lpddr5_s3_od: pg_lpddr5_s3_od { + gpios = <&gpio7 3 GPIO_INPUT>; + }; + 3axis_int_l { + gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; + }; + gpio_ec_soc_pwr_btn_l: ec_soc_pwr_btn_l { + gpios = <&gpioa 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpio6 7 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + ec_sc_rst { + gpios = <&gpiob 0 GPIO_OUTPUT_LOW>; + }; + gpio_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 1 GPIO_OUTPUT_LOW>; + }; + gpio_wp: ec_wp_l { + gpios = <&gpiod 7 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_pg_lpddr5_s0_od: pg_lpddr5_s0_od { + gpios = <&gpio6 0 GPIO_INPUT>; + }; + ec_espi_rst_l { + gpios = <&gpio5 4 GPIO_PULL_DOWN>; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + pch-sys-prwok { + enum-name = "GPIO_PCH_SYS_PWROK"; + }; + ec_i2c_usb_a0_c0_scl { + gpios = <&gpiob 5 GPIO_INPUT>; + }; + ec_i2c_usb_a0_c0_sda { + gpios = <&gpiob 4 GPIO_INPUT>; + }; + ec_i2c_usb_a1_c1_scl { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + ec_i2c_usb_a1_c1_sda { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + ec_i2c_batt_scl { + gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_batt_sda { + gpios = <&gpio9 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_usbc_mux_scl { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + ec_i2c_usbc_mux_sda { + gpios = <&gpiod 0 GPIO_INPUT>; + }; + ec_i2c_power_scl { + gpios = <&gpiof 3 GPIO_INPUT>; + }; + ec_i2c_power_sda { + gpios = <&gpiof 2 GPIO_INPUT>; + }; + ec_i2c_cbi_scl { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + ec_i2c_cbi_sda { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + ec_i2c_sensor_scl { + gpios = <&gpioe 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_sensor_sda { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_soc_sic { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_soc_sid { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + en_kb_bl { + gpios = <&gpio9 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + tablet_mode_l { + gpios = <&gpioc 1 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ec_gpio56 { + gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>; + }; + ec_flprg2 { + gpios = <&gpio8 6 GPIO_INPUT_PULL_UP>; + }; + + usb_c0_tcpc_fastsw_ctl_en { + gpios = <&ioex_c0_port0 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN"; + }; + usb_c0_ppc_en_l { + gpios = <&ioex_c0_port1 0 GPIO_OUTPUT_LOW>; + }; + ioex_usb_c0_ilim_3a_en: usb_c0_ppc_ilim_3a_en { + gpios = <&ioex_c0_port1 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_PPC_ILIM_3A_EN"; + }; + ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl { + gpios = <&ioex_c0_port1 2 GPIO_INPUT>; + }; + ioex_en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&ioex_c0_port1 5 GPIO_OUTPUT_LOW>; + }; + ioex_usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&ioex_c0_port1 6 GPIO_INPUT>; + }; + ioex_usb_c0_sbu_flip: usb_c0_sbu_flip { + gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_SBU_FLIP"; + }; + + usb_a1_retimer_en { + gpios = <&ioex_c1_port0 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_A1_RETIMER_EN"; + }; + usb_a1_retimer_rst { + gpios = <&ioex_c1_port0 1 GPIO_OUTPUT_LOW>; + }; + usb_c1_in_hpd { + gpios = <&ioex_c1_port0 3 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_HPD_IN_DB"; + }; + usb_c1_tcpc_fastsw_ctl_en { + gpios = <&ioex_c1_port0 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN"; + }; + usb_c1_ppc_en_l { + gpios = <&ioex_c1_port1 0 GPIO_OUTPUT_LOW>; + }; + usb_c1_ppc_ilim_3a_en { + gpios = <&ioex_c1_port1 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_PPC_ILIM_3A_EN"; + }; + ioex_usb_c1_sbu_fault_odl: usb_c1_sbu_fault_odl { + gpios = <&ioex_c1_port1 2 GPIO_INPUT>; + enum-name = "IOEX_USB_C1_FAULT_ODL"; + }; + ioex_en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus { + gpios = <&ioex_c1_port1 5 GPIO_OUTPUT_LOW>; + }; + ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl { + gpios = <&ioex_c1_port1 6 GPIO_INPUT>; + }; + ioex_usb_c1_sbu_flip: usb_c1_sbu_flip { + gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_SBU_FLIP"; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&ioex_en_pp5000_usb_a0_vbus + &ioex_en_pp5000_usb_a1_vbus>; + }; +}; + +/* PSL input pads*/ +&psl_in1_gpd2 { + /* MECH_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in2_gp00 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* LID_OPEN */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>; +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/i2c_common.dtsi b/zephyr/program/skyrim/i2c_common.dtsi new file mode 100644 index 0000000000..460a6bcfd2 --- /dev/null +++ b/zephyr/program/skyrim/i2c_common.dtsi @@ -0,0 +1,294 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + #include + +/ { + aliases { + i2c-0 = &i2c0_0; + i2c-1 = &i2c1_0; + i2c-2 = &i2c2_0; + i2c-3 = &i2c3_0; + i2c-4 = &i2c4_1; + i2c-5 = &i2c5_0; + i2c-7 = &i2c7_0; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_tcpc0: tcpc0 { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_TCPC0"; + }; + + i2c_tcpc1: tcpc1 { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_TCPC1"; + }; + + battery { + i2c-port = <&i2c2_0>; + remote-port = <0>; + enum-names = "I2C_PORT_BATTERY"; + }; + + usb-mux { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_MUX"; + }; + + i2c_charger: charger { + i2c-port = <&i2c4_1>; + enum-names = "I2C_PORT_CHARGER"; + }; + + eeprom { + i2c-port = <&i2c5_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + + i2c_sensor: sensor { + i2c-port = <&i2c6_1>; + enum-names = "I2C_PORT_SENSOR"; + }; + + i2c_soc_thermal: soc-thermal { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_THERMAL_AP"; + }; + }; + + +}; + +&i2c0_0 { + status = "okay"; + label = "I2C_TCPC0"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + tcpc_port0: nct38xx@70 { + compatible = "nuvoton,nct38xx"; + reg = <0x70>; + gpio-dev = <&nct3807_C0>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct3807_C0: nct3807_C0@70 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x70>; + label = "NCT3807_C0"; + + ioex_c0_port0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3807_C0_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + pinmux_mask = <0xf7>; + }; + ioex_c0_port1: gpio@1 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x1>; + label = "NCT3807_C0_GPIO1"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + }; + }; + + nct3808_alert_0 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct3807_C0>; + label = "NCT3807_ALERT_0"; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + status = "okay"; + label = "I2C_TCPC1"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c1_bc12>; + }; + + tcpc_port1: nct38xx@70 { + compatible = "nuvoton,nct38xx"; + reg = <0x70>; + gpio-dev = <&nct3807_C1>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct3807_C1: nct3807_C1@70 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x70>; + label = "NCT3807_C1"; + + ioex_c1_port0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3807_C1_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + pinmux_mask = <0xf7>; + }; + ioex_c1_port1: gpio@1 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x1>; + label = "NCT3807_C1_GPIO1"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + }; + }; + + nct3808_alert_1 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpioc 7 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct3807_C1>; + label = "NCT3807_ALERT_1"; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + status = "okay"; + label = "I2C_BATTERY"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + status = "okay"; + label = "I2C_USB_MUX"; + clock-frequency = ; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; + + amd_fp6_port0: amd_fp6@5c { + compatible = "amd,usbc-mux-amd-fp6"; + status = "okay"; + reg = <0x5c>; + }; + amd_fp6_port1: amd_fp6@52 { + compatible = "amd,usbc-mux-amd-fp6"; + status = "okay"; + reg = <0x52>; + }; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c4_1 { + status = "okay"; + label = "I2C_CHARGER"; + clock-frequency = ; + pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl4 { + status = "okay"; +}; + +&i2c5_0 { + status = "okay"; + label = "I2C_EEPROM"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c6_1 { + status = "okay"; + label = "I2C_SENSOR"; + clock-frequency = ; + pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; + pinctrl-names = "default"; + + soc_pct2075: soc-pct2075@48 { + compatible = "nxp,pct2075"; + reg = <0x48>; + }; + + amb_pct2075: amb-pct2075@4f { + compatible = "nxp,pct2075"; + reg = <0x4f>; + }; +}; + +&i2c_ctrl6 { + status = "okay"; +}; + +&i2c7_0 { + status = "okay"; + label = "I2C_THERMAL_AP"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; + + temp_cpu: cpu@4c { + compatible = "amd,sb-tsi"; + reg = <0x4c>; + }; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/skyrim/include/frostflow/keyboard_customization.h b/zephyr/program/skyrim/include/frostflow/keyboard_customization.h new file mode 100644 index 0000000000..2d2a997f91 --- /dev/null +++ b/zephyr/program/skyrim/include/frostflow/keyboard_customization.h @@ -0,0 +1,78 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Keyboard configuration */ + +#ifndef __KEYBOARD_CUSTOMIZATION_H +#define __KEYBOARD_CUSTOMIZATION_H + +/* + * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate + * exact spaces for arrays. Actual keyboard scanning is done using + * keyboard_cols, which holds a runtime column size. + */ +#ifdef CONFIG_KEYBOARD_CUSTOMIZATION +#undef KEYBOARD_COLS_MAX +#undef KEYBOARD_ROWS + +#define KEYBOARD_COLS_MAX 15 +#define KEYBOARD_ROWS 8 +#endif + +/* + * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols, + * instead. It checks whether you're eligible or not. + */ +extern uint8_t keyboard_cols; + +#define KEYBOARD_ROW_TO_MASK(r) (1 << (r)) + +/* Columns and masks for keys we particularly care about */ +#define KEYBOARD_COL_DOWN 11 +#define KEYBOARD_ROW_DOWN 5 +#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN) +#define KEYBOARD_COL_ESC 1 +#define KEYBOARD_ROW_ESC 1 +#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC) +#define KEYBOARD_COL_KEY_H 6 +#define KEYBOARD_ROW_KEY_H 1 +#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H) +#define KEYBOARD_COL_KEY_R 3 +#define KEYBOARD_ROW_KEY_R 7 +#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R) +#define KEYBOARD_COL_LEFT_ALT 10 +#define KEYBOARD_ROW_LEFT_ALT 6 +#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT) +#define KEYBOARD_COL_REFRESH 2 +#define KEYBOARD_ROW_REFRESH 3 +#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH) +#define KEYBOARD_COL_RIGHT_ALT 10 +#define KEYBOARD_ROW_RIGHT_ALT 0 +#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT) +#define KEYBOARD_DEFAULT_COL_VOL_UP 4 +#define KEYBOARD_DEFAULT_ROW_VOL_UP 1 +#define KEYBOARD_COL_LEFT_CTRL 0 +#define KEYBOARD_ROW_LEFT_CTRL 2 +#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL) +#define KEYBOARD_COL_RIGHT_CTRL 0 +#define KEYBOARD_ROW_RIGHT_CTRL 4 +#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL) +#define KEYBOARD_COL_SEARCH 0 +#define KEYBOARD_ROW_SEARCH 3 +#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH) +#define KEYBOARD_COL_KEY_0 9 +#define KEYBOARD_ROW_KEY_0 0 +#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) +#define KEYBOARD_COL_KEY_1 1 +#define KEYBOARD_ROW_KEY_1 7 +#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1) +#define KEYBOARD_COL_KEY_2 4 +#define KEYBOARD_ROW_KEY_2 6 +#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) +#define KEYBOARD_COL_LEFT_SHIFT 7 +#define KEYBOARD_ROW_LEFT_SHIFT 1 +#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT) + +#endif /* __KEYBOARD_CUSTOMIZATION_H */ diff --git a/zephyr/program/skyrim/interrupts.dts b/zephyr/program/skyrim/interrupts.dts new file mode 100644 index 0000000000..de4e87986a --- /dev/null +++ b/zephyr/program/skyrim/interrupts.dts @@ -0,0 +1,146 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&gpio_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_mech_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_slp_s3: slp_s3 { + irq-pin = <&gpio_slp_s3_l>; + flags = ; + handler = "baseboard_en_pwr_s0"; + }; + int_slp_s5: slp_s5 { + irq-pin = <&gpio_slp_s5_l>; + flags = ; + handler = "baseboard_set_en_pwr_s3"; + }; + int_s5_pgood: s5_pgood { + irq-pin = <&gpio_pg_pwr_s5>; + flags = ; + handler = "baseboard_s5_pgood"; + }; + int_pg_groupc_s0: pg_groupc_s0 { + irq-pin = <&gpio_pg_groupc_s0_od>; + flags = ; + handler = "baseboard_set_en_pwr_pcore"; + }; + int_pg_lpddr_s3: pg_lpddr_s3 { + irq-pin = <&gpio_pg_lpddr5_s3_od>; + flags = ; + handler = "baseboard_set_en_pwr_pcore"; + }; + int_pg_lpddr_s0: pg_lpddr_s0 { + irq-pin = <&gpio_pg_lpddr5_s0_od>; + flags = ; + handler = "baseboard_set_soc_pwr_pgood"; + }; + int_s0_pgood: s0_pgood { + irq-pin = <&gpio_s0_pgood>; + flags = ; + handler = "baseboard_s0_pgood"; + }; + int_soc_thermtrip: soc_thermtrip { + irq-pin = <&gpio_soc_thermtrip_odl>; + flags = ; + handler = "baseboard_soc_thermtrip"; + }; + int_soc_pcore_ocp: soc_pcore_ocp { + irq-pin = <&gpio_pcore_ocp_r_l>; + flags = ; + handler = "baseboard_soc_pcore_ocp"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_usb_a0_fault: a0_fault { + irq-pin = <&ioex_usb_a0_fault_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_a1_fault: a1_fault { + irq-pin = <&ioex_usb_a1_fault_db_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_c0_sbu_fault: c0_sbu_fault { + irq-pin = <&ioex_usb_c0_sbu_fault_odl>; + flags = ; + handler = "sbu_fault_interrupt"; + }; + int_usb_c1_sbu_fault: c1_sbu_fault { + irq-pin = <&ioex_usb_c1_sbu_fault_odl>; + flags = ; + handler = "sbu_fault_interrupt"; + }; + int_usb_c0_tcpc: usb_c0_tcpc { + irq-pin = <&gpio_usb_c0_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-pin = <&gpio_usb_c1_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&gpio_usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_ppc: usb_c1_ppc { + irq-pin = <&gpio_usb_c1_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_hub_fault: hub_fault { + irq-pin = <&gpio_usb_hub_fault_q_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_pd_soc: usb_pd_soc { + irq-pin = <&gpio_ec_i2c_usbc_pd_int>; + flags = ; + handler = "usb_pd_soc_interrupt"; + }; + int_accel_gyro: accel_gyro { + irq-pin = <&gpio_accel_gyro_int_l>; + flags = ; + handler = "bmi3xx_interrupt"; + }; + }; +}; diff --git a/zephyr/program/skyrim/keyboard.dts b/zephyr/program/skyrim/keyboard.dts new file mode 100644 index 0000000000..df334ba54c --- /dev/null +++ b/zephyr/program/skyrim/keyboard.dts @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/led_pins_frostflow.dts b/zephyr/program/skyrim/led_pins_frostflow.dts new file mode 100644 index 0000000000..d294490208 --- /dev/null +++ b/zephyr/program/skyrim/led_pins_frostflow.dts @@ -0,0 +1,63 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwm_pins { + compatible = "cros-ec,pwm-pin-config"; + + pwm_y: pwm_y { + #led-pin-cells = <1>; + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + + pwm_w: pwm_w { + #led-pin-cells = <1>; + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&pwm_y 0>, + <&pwm_w 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&pwm_y 100>, + <&pwm_w 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&pwm_y 0>, + <&pwm_w 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/led_pins_morthal.dts b/zephyr/program/skyrim/led_pins_morthal.dts new file mode 100644 index 0000000000..d294490208 --- /dev/null +++ b/zephyr/program/skyrim/led_pins_morthal.dts @@ -0,0 +1,63 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwm_pins { + compatible = "cros-ec,pwm-pin-config"; + + pwm_y: pwm_y { + #led-pin-cells = <1>; + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + + pwm_w: pwm_w { + #led-pin-cells = <1>; + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&pwm_y 0>, + <&pwm_w 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&pwm_y 100>, + <&pwm_w 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&pwm_y 0>, + <&pwm_w 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/led_pins_skyrim.dts b/zephyr/program/skyrim/led_pins_skyrim.dts new file mode 100644 index 0000000000..d294490208 --- /dev/null +++ b/zephyr/program/skyrim/led_pins_skyrim.dts @@ -0,0 +1,63 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwm_pins { + compatible = "cros-ec,pwm-pin-config"; + + pwm_y: pwm_y { + #led-pin-cells = <1>; + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + + pwm_w: pwm_w { + #led-pin-cells = <1>; + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&pwm_y 0>, + <&pwm_w 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&pwm_y 100>, + <&pwm_w 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&pwm_y 0>, + <&pwm_w 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/led_pins_winterhold.dts b/zephyr/program/skyrim/led_pins_winterhold.dts new file mode 100644 index 0000000000..d294490208 --- /dev/null +++ b/zephyr/program/skyrim/led_pins_winterhold.dts @@ -0,0 +1,63 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwm_pins { + compatible = "cros-ec,pwm-pin-config"; + + pwm_y: pwm_y { + #led-pin-cells = <1>; + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + + pwm_w: pwm_w { + #led-pin-cells = <1>; + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&pwm_y 0>, + <&pwm_w 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&pwm_y 100>, + <&pwm_w 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&pwm_y 0>, + <&pwm_w 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/led_policy_frostflow.dts b/zephyr/program/skyrim/led_policy_frostflow.dts new file mode 100644 index 0000000000..e5875640fb --- /dev/null +++ b/zephyr/program/skyrim/led_policy_frostflow.dts @@ -0,0 +1,122 @@ +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = <0 94>; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-charge-lvl-2 { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Near Full) */ + batt-lvl = <95 97>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <11 100>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= 10%) */ + batt-lvl = <0 10>; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error-s0 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + /* White 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/led_policy_morthal.dts b/zephyr/program/skyrim/led_policy_morthal.dts new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/led_policy_morthal.dts @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/led_policy_skyrim.dts b/zephyr/program/skyrim/led_policy_skyrim.dts new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/led_policy_skyrim.dts @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/led_policy_winterhold.dts b/zephyr/program/skyrim/led_policy_winterhold.dts new file mode 100644 index 0000000000..f1f8aa31ed --- /dev/null +++ b/zephyr/program/skyrim/led_policy_winterhold.dts @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s3-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/morthal.dts b/zephyr/program/skyrim/morthal.dts new file mode 100644 index 0000000000..508ce23bce --- /dev/null +++ b/zephyr/program/skyrim/morthal.dts @@ -0,0 +1,183 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "i2c_common.dtsi" + +/ { + named-gpios { + /* Morthal-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <0>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + morthal-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/motionsense.dts b/zephyr/program/skyrim/motionsense.dts new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/motionsense.dts @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf new file mode 100644 index 0000000000..a0085258e4 --- /dev/null +++ b/zephyr/program/skyrim/prj.conf @@ -0,0 +1,167 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_ESPI=y + +# Shell features +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y +CONFIG_KERNEL_SHELL=y + +# Power sequencing +CONFIG_AP=y +CONFIG_AP_X86_AMD=y +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM=y +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y +CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y +CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y +CONFIG_PLATFORM_EC_PORT80=y + +# Power button +CONFIG_PLATFORM_EC_POWER_BUTTON=y + +# ADC +CONFIG_ADC=y + +# I2C +CONFIG_I2C=y + +# CBI +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y +CONFIG_PLATFORM_EC_CBI_EEPROM=y + +# Temperature Sensors +CONFIG_PLATFORM_EC_AMD_SB_RMI=y +CONFIG_PLATFORM_EC_AMD_STT=y +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_TEMP_SENSOR_SB_TSI=y +CONFIG_PLATFORM_EC_THERMISTOR=y +CONFIG_PLATFORM_EC_THROTTLE_AP=y + +# External power +CONFIG_PLATFORM_EC_HOSTCMD=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y + +# Sensors +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n + +# Fan +CONFIG_TACH_NPCX=y + +# Lid switch +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_LID_SWITCH=y + +# Keyboard +CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +CONFIG_SYSCON=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y + +# Charger +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512 +CONFIG_PLATFORM_EC_CHARGER_ISL9241=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 + +# USB-A +CONFIG_PLATFORM_EC_USBA=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y +CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y +CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811=y +CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818=y +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_MUX_AMD_FP6=y +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_PID=0x505F +CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y +CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_REV30=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y +# Give ourselves enough task space to use i2ctrace +CONFIG_TASK_PD_STACK_SIZE=1280 + +# IOEX +CONFIG_GPIO_NCT38XX=y + +# Motion sense +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y + +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y + +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y + +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Misc. +CONFIG_PLATFORM_EC_I2C_DEBUG=y +CONFIG_PLATFORM_EC_PORT80_4_BYTE=y + +# These are debug options that happen to be expensive in terms of flash space. +# Turn on as needed based on demand. +CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes +CONFIG_FLASH_SHELL=n # 1852 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes +# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes +CONFIG_THREAD_MONITOR=n # 1548 bytes diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf new file mode 100644 index 0000000000..29931de4d4 --- /dev/null +++ b/zephyr/program/skyrim/prj_frostflow.conf @@ -0,0 +1,30 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Frostflow reference-board-specific Kconfig settings. +CONFIG_BOARD_FROSTFLOW=y +CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR=90 + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Frostflow is capable of sinking 45W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000 +# Only Frostflow has the PCT2075 +CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y + +# Frostflow not have the USB HUB +CONFIG_BOARD_USB_HUB_RESET=n diff --git a/zephyr/program/skyrim/prj_morthal.conf b/zephyr/program/skyrim/prj_morthal.conf new file mode 100644 index 0000000000..3d2b3fddb7 --- /dev/null +++ b/zephyr/program/skyrim/prj_morthal.conf @@ -0,0 +1,23 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Morthal reference-board-specific Kconfig settings. +CONFIG_BOARD_MORTHAL=y + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Morthal is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +# Only Morthal has the PCT2075 +CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y diff --git a/zephyr/program/skyrim/prj_skyrim.conf b/zephyr/program/skyrim/prj_skyrim.conf new file mode 100644 index 0000000000..2752854c8b --- /dev/null +++ b/zephyr/program/skyrim/prj_skyrim.conf @@ -0,0 +1,26 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Skyrim reference-board-specific Kconfig settings. +CONFIG_BOARD_SKYRIM=y + +# CBI WP pin present +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Skyrim is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +# Only Skyrim has the PCT2075 +CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable alternative charger chip +CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y diff --git a/zephyr/program/skyrim/prj_winterhold.conf b/zephyr/program/skyrim/prj_winterhold.conf new file mode 100644 index 0000000000..2ccd195a72 --- /dev/null +++ b/zephyr/program/skyrim/prj_winterhold.conf @@ -0,0 +1,26 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Winterhold reference-board-specific Kconfig settings. +CONFIG_BOARD_WINTERHOLD=y + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Only Winterhold has the PCT2075 +CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable charger chip +CONFIG_PLATFORM_EC_CHARGER_ISL9238=y +CONFIG_PLATFORM_EC_CHARGER_ISL9241=n + +# Get the vbus voltage from TCPC +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y \ No newline at end of file diff --git a/zephyr/program/skyrim/skyrim.dts b/zephyr/program/skyrim/skyrim.dts new file mode 100644 index 0000000000..6a812a55f3 --- /dev/null +++ b/zephyr/program/skyrim/skyrim.dts @@ -0,0 +1,207 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "i2c_common.dtsi" + +/ { + named-gpios { + /* Skyrim-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <35>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + skyrim-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + + charger-option { + enum-name = "FW_CHARGER"; + start = <11>; + size = <2>; + + charger-option-isl9241 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9241"; + value = <0>; + default; + }; + charger-option-isl9538 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9538"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + alt_charger: isl9538@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + chg_alt = <&alt_charger>; + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/src/common.c b/zephyr/program/skyrim/src/common.c new file mode 100644 index 0000000000..af82139c1b --- /dev/null +++ b/zephyr/program/skyrim/src/common.c @@ -0,0 +1,8 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +LOG_MODULE_REGISTER(skyrim, CONFIG_SKYRIM_LOG_LEVEL); diff --git a/zephyr/program/skyrim/src/frostflow/keyboard.c b/zephyr/program/skyrim/src/frostflow/keyboard.c new file mode 100644 index 0000000000..2905f17941 --- /dev/null +++ b/zephyr/program/skyrim/src/frostflow/keyboard.c @@ -0,0 +1,74 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" +#include "keyboard_scan.h" +#include "timer.h" + +/* Keyboard scan setting */ +__override struct keyboard_scan_config keyscan_config = { + /* Increase from 50 us, because KSO_02 passes through the H1. */ + .output_settle_us = 80, + /* Other values should be the same as the default configuration. */ + .debounce_down_us = 9 * MSEC, + .debounce_up_us = 30 * MSEC, + .scan_period_us = 3 * MSEC, + .min_post_scan_delay_us = 1000, + .poll_timeout_us = 100 * MSEC, + .actual_key_mask = { + 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x86, 0xff, 0xff, 0x55, 0xff, 0xff, 0xff, 0xff, /* full set */ + }, +}; + +static const struct ec_response_keybd_config frostflow_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &frostflow_kb; +} + +/* + * Row Column info for Top row keys T1 - T15. + * on frostflow_kb keyboard Row Column is customization + * need define row col to mapping matrix layout. + */ +__override const struct key { + uint8_t row; + uint8_t col; +} vivaldi_keys[] = { + { .row = 4, .col = 2 }, /* T1 */ + { .row = 3, .col = 2 }, /* T2 */ + { .row = 2, .col = 2 }, /* T3 */ + { .row = 1, .col = 2 }, /* T4 */ + { .row = 4, .col = 4 }, /* T5 */ + { .row = 3, .col = 4 }, /* T6 */ + { .row = 2, .col = 4 }, /* T7 */ + { .row = 2, .col = 9 }, /* T8 */ + { .row = 1, .col = 9 }, /* T9 */ + { .row = 1, .col = 4 }, /* T10 */ + { .row = 0, .col = 4 }, /* T11 */ + { .row = 1, .col = 5 }, /* T12 */ + { .row = 3, .col = 5 }, /* T13 */ + { .row = 2, .col = 1 }, /* T14 */ + { .row = 0, .col = 1 }, /* T15 */ +}; +BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS); diff --git a/zephyr/program/skyrim/src/frostflow/keyboard_customization.c b/zephyr/program/skyrim/src/frostflow/keyboard_customization.c new file mode 100644 index 0000000000..d176323d80 --- /dev/null +++ b/zephyr/program/skyrim/src/frostflow/keyboard_customization.c @@ -0,0 +1,85 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "common.h" +#include "gpio.h" +#include "keyboard_customization.h" +#include "keyboard_protocol.h" +#include "keyboard_raw.h" + +static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { + { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 }, + { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 }, + { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a }, + { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d }, + { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d }, + { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 }, + { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c }, + { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 }, + { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d }, + { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a }, + { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 }, + { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 }, + { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d }, + { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 }, + { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 }, +}; + +uint16_t get_scancode_set2(uint8_t row, uint8_t col) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + return scancode_set2[col][row]; + return 0; +} + +void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + scancode_set2[col][row] = val; +} + +#ifdef CONFIG_KEYBOARD_DEBUG +static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { + { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO }, + { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' }, + { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3, + KLLI_UNKNO }, + { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC }, + { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' }, + { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' }, + { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' }, + { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' }, + { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO, + KLLI_LEFT, KLLI_UNKNO }, + { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' }, + { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' }, + { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO }, +}; + +char get_keycap_label(uint8_t row, uint8_t col) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + return keycap_label[col][row]; + return KLLI_UNKNO; +} + +void set_keycap_label(uint8_t row, uint8_t col, char val) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + keycap_label[col][row] = val; +} +#endif diff --git a/zephyr/program/skyrim/src/frostflow/ppc_config.c b/zephyr/program/skyrim/src/frostflow/ppc_config.c new file mode 100644 index 0000000000..6072a788eb --- /dev/null +++ b/zephyr/program/skyrim/src/frostflow/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Frostflow board-specific PPC code */ + +#include + +#include "driver/ppc/nx20p348x.h" +#include "driver/ppc/aoz1380_public.h" +#include "usbc_ppc.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c b/zephyr/program/skyrim/src/frostflow/usb_mux_config.c new file mode 100644 index 0000000000..e641e0d649 --- /dev/null +++ b/zephyr/program/skyrim/src/frostflow/usb_mux_config.c @@ -0,0 +1,123 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Frostflow board-specific USB-C mux configuration */ + +#include + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} diff --git a/zephyr/program/skyrim/src/morthal/ppc_config.c b/zephyr/program/skyrim/src/morthal/ppc_config.c new file mode 100644 index 0000000000..f3ec1d312e --- /dev/null +++ b/zephyr/program/skyrim/src/morthal/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Morthal board-specific PPC code */ + +#include + +#include "driver/ppc/nx20p348x.h" +#include "driver/ppc/aoz1380_public.h" +#include "usbc_ppc.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/src/morthal/usb_mux_config.c b/zephyr/program/skyrim/src/morthal/usb_mux_config.c new file mode 100644 index 0000000000..8fe76233e2 --- /dev/null +++ b/zephyr/program/skyrim/src/morthal/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Morthal board-specific USB-C mux configuration */ + +#include + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/src/power_signals.c b/zephyr/program/skyrim/src/power_signals.c new file mode 100644 index 0000000000..5d372d35ae --- /dev/null +++ b/zephyr/program/skyrim/src/power_signals.c @@ -0,0 +1,245 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ap_power/ap_power.h" +#include "charger.h" +#include "chipset.h" +#include "config.h" +#include "gpio_signal.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "i2c.h" +#include "ioexpander.h" +#include "power.h" +#include "power/amd_x86.h" +#include "timer.h" + +/* Power Signal Input List */ +/* TODO: b/218904113: Convert to using Zephyr GPIOs */ +const struct power_signal_info power_signal_list[] = { + [X86_SLP_S3_N] = { + .gpio = GPIO_PCH_SLP_S3_L, + .flags = POWER_SIGNAL_ACTIVE_HIGH, + .name = "SLP_S3_DEASSERTED", + }, + [X86_SLP_S5_N] = { + .gpio = GPIO_PCH_SLP_S5_L, + .flags = POWER_SIGNAL_ACTIVE_HIGH, + .name = "SLP_S5_DEASSERTED", + }, + [X86_S0_PGOOD] = { + .gpio = GPIO_S0_PGOOD, + .flags = POWER_SIGNAL_ACTIVE_HIGH, + .name = "S0_PGOOD", + }, + [X86_S5_PGOOD] = { + .gpio = GPIO_S5_PGOOD, + .flags = POWER_SIGNAL_ACTIVE_HIGH, + .name = "S5_PGOOD", + }, +}; +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); + +/* Chipset hooks */ +static void baseboard_suspend_change(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + switch (data.event) { + default: + return; + + case AP_POWER_SUSPEND: + /* Disable display backlight and retimer */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl), + 1); + ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0); + break; + + case AP_POWER_RESUME: + /* Enable retimer and display backlight */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl), + 0); + ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1); + /* Any retimer tuning can be done after the retimer turns on */ + break; + } +} + +static void baseboard_init(void) +{ + static struct ap_power_ev_callback cb; + + /* Setup a suspend/resume callback */ + ap_power_ev_init_callback(&cb, baseboard_suspend_change, + AP_POWER_RESUME | AP_POWER_SUSPEND); + ap_power_ev_add_callback(&cb); + /* Enable Power Group interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_groupc_s0)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_lpddr_s0)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_lpddr_s3)); + + /* Enable thermtrip interrupt */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_soc_thermtrip)); +} +DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_POST_I2C); + +/** + * b/227296844: On G3->S5, wait for RSMRST_L to be deasserted before asserting + * PCH_PWRBTN_L. This can be as long as ~65ms after cold boot. Then wait an + * additional delay of T1a defined in the EDS before changing the power button. + */ +#define RSMRST_WAIT_DELAY 70 +#define EDS_PWR_BTN_RSMRST_T1A_DELAY 16 +void board_pwrbtn_to_pch(int level) +{ + timestamp_t start; + + /* Add delay for G3 exit if asserting PWRBTN_L and RSMRST_L is low. */ + if (!level && + !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_rsmrst_l))) { + start = get_time(); + do { + usleep(500); + if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( + gpio_ec_soc_rsmrst_l))) + break; + } while (time_since32(start) < (RSMRST_WAIT_DELAY * MSEC)); + + if (!gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_ec_soc_rsmrst_l))) + ccprints("Error pwrbtn: RSMRST_L still low"); + + msleep(EDS_PWR_BTN_RSMRST_T1A_DELAY); + } + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_pwr_btn_l), level); +} + +/* Note: signal parameter unused */ +void baseboard_set_soc_pwr_pgood(enum gpio_signal unused) +{ + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_ec_soc_pwr_good), + gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_pwr_pcore_s0_r)) && + gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_pg_lpddr5_s0_od)) && + gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood))); +} + +/* TODO(b/248284045): Remove when boards switch to new chip */ +#define MP2845A_I2C_ADDR_FLAGS 0x20 +#define MP2854A_MFR_VOUT_CMPS_MAX_REG 0x69 +#define MP2854A_MFR_LOW_PWR_SEL BIT(12) + +__overridable bool board_supports_pcore_ocp(void) +{ + return true; +} + +static void setup_mp2845(void) +{ + if (i2c_update16(chg_chips[CHARGER_SOLO].i2c_port, + MP2845A_I2C_ADDR_FLAGS, MP2854A_MFR_VOUT_CMPS_MAX_REG, + MP2854A_MFR_LOW_PWR_SEL, MASK_CLR)) + ccprints("Failed to send mp2845 workaround"); + + if (board_supports_pcore_ocp()) + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_soc_pcore_ocp)); +} +DECLARE_DEFERRED(setup_mp2845); + +void baseboard_s0_pgood(enum gpio_signal signal) +{ + baseboard_set_soc_pwr_pgood(signal); + + /* Chain off power signal interrupt handler for PG_PCORE_S0_R_OD */ + power_signal_interrupt(signal); + + /* Set up the MP2845, which is powered in S0 */ + if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood))) + hook_call_deferred(&setup_mp2845_data, 50 * MSEC); + else + gpio_disable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_soc_pcore_ocp)); +} + +/* Note: signal parameter unused */ +void baseboard_set_en_pwr_pcore(enum gpio_signal unused) +{ + /* + * EC must AND signals PG_LPDDR5_S3_OD, PG_GROUPC_S0_OD, and + * EN_PWR_S0_R + */ + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_pwr_pcore_s0_r), + gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_lpddr5_s3_od)) && + gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_pg_groupc_s0_od)) && + gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s0_r))); + + /* Update EC_SOC_PWR_GOOD based on our results */ + baseboard_set_soc_pwr_pgood(unused); +} + +void baseboard_en_pwr_s0(enum gpio_signal signal) +{ + /* EC must AND signals SLP_S3_L and PG_PWR_S5 */ + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s0_r), + gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) && + gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5))); + + /* Change EN_PWR_PCORE_S0_R if needed*/ + baseboard_set_en_pwr_pcore(signal); + + /* Now chain off to the normal power signal interrupt handler. */ + power_signal_interrupt(signal); +} +#ifdef CONFIG_BOARD_USB_HUB_RESET +void baseboard_enable_hub(void) +{ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hub_rst), 0); +} +DECLARE_DEFERRED(baseboard_enable_hub); +#endif /* CONFIG_BOARD_USB_HUB_RESET */ + +void baseboard_s5_pgood(enum gpio_signal signal) +{ +#ifdef CONFIG_BOARD_USB_HUB_RESET + /* We must enable the USB hub at least 30ms after S5 PGOOD */ + if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5))) + hook_call_deferred(&baseboard_enable_hub_data, 30 * MSEC); + else + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hub_rst), 1); +#endif /* CONFIG_BOARD_USB_HUB_RESET */ + + /* Continue to our signal AND-ing and power interrupt */ + baseboard_en_pwr_s0(signal); +} + +void baseboard_set_en_pwr_s3(enum gpio_signal signal) +{ + /* EC must enable PWR_S3 when SLP_S5_L goes high, disable on low */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s3), + gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s5_l))); + + /* Chain off the normal power signal interrupt handler */ + power_signal_interrupt(signal); +} + +void baseboard_soc_thermtrip(enum gpio_signal signal) +{ + ccprints("SoC thermtrip reported, shutting down"); + chipset_force_shutdown(CHIPSET_SHUTDOWN_THERMAL); +} + +void baseboard_soc_pcore_ocp(enum gpio_signal signal) +{ + ccprints("SoC Pcore OCP reported, shutting down"); + chipset_force_shutdown(CHIPSET_SHUTDOWN_BOARD_CUSTOM); +} diff --git a/zephyr/program/skyrim/src/skyrim/alt_charger.c b/zephyr/program/skyrim/src/skyrim/alt_charger.c new file mode 100644 index 0000000000..4b717901cd --- /dev/null +++ b/zephyr/program/skyrim/src/skyrim/alt_charger.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "charger_chips.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "hooks.h" + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +static void alt_charger_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FW_CHARGER, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); + return; + } + + if (val == FW_CHARGER_ISL9538) + CHG_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/src/skyrim/fan.c b/zephyr/program/skyrim/src/skyrim/fan.c new file mode 100644 index 0000000000..0a368ee6f0 --- /dev/null +++ b/zephyr/program/skyrim/src/skyrim/fan.c @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Skyrim fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + uint32_t board_version; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + + ret = cbi_get_board_version(&board_version); + if (ret != EC_SUCCESS) { + LOG_ERR("Error retrieving CBI board version"); + return; + } + + if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { + /* Disable the fan */ + fan_set_count(0); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); + +/* + * Pcore OCP support + * Note: early boards should note enable this interrupt as they are not + * correctly configured for it. + */ +__override bool board_supports_pcore_ocp(void) +{ + uint32_t board_version; + + if (cbi_get_board_version(&board_version) == EC_SUCCESS && + board_version > 3) + return true; + + return false; +} diff --git a/zephyr/program/skyrim/src/skyrim/form_factor.c b/zephyr/program/skyrim/src/skyrim/form_factor.c new file mode 100644 index 0000000000..f137c6db31 --- /dev/null +++ b/zephyr/program/skyrim/src/skyrim/form_factor.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include "common.h" +#include "accelgyro.h" +#include "cros_board_info.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) +#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + /* + * If the board version >=4 + * use ver1 rotation matrix. + */ + ret = cbi_get_board_version(&val); + if (ret == EC_SUCCESS && val >= 4) { + LOG_INF("Switching to ver1 lid"); + motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/src/skyrim/keyboard.c b/zephyr/program/skyrim/src/skyrim/keyboard.c new file mode 100644 index 0000000000..e261321e86 --- /dev/null +++ b/zephyr/program/skyrim/src/skyrim/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config skyrim_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &skyrim_kb; +} diff --git a/zephyr/program/skyrim/src/skyrim/ppc_config.c b/zephyr/program/skyrim/src/skyrim/ppc_config.c new file mode 100644 index 0000000000..bebc8adcc7 --- /dev/null +++ b/zephyr/program/skyrim/src/skyrim/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim board-specific PPC code */ + +#include + +#include "driver/ppc/nx20p348x.h" +#include "driver/ppc/aoz1380_public.h" +#include "usbc_ppc.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/src/skyrim/usb_mux_config.c b/zephyr/program/skyrim/src/skyrim/usb_mux_config.c new file mode 100644 index 0000000000..6c65e56d9e --- /dev/null +++ b/zephyr/program/skyrim/src/skyrim/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim board-specific USB-C mux configuration */ + +#include + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/src/stt.c b/zephyr/program/skyrim/src/stt.c new file mode 100644 index 0000000000..40743fbc68 --- /dev/null +++ b/zephyr/program/skyrim/src/stt.c @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Support code for STT temperature reporting */ + +#include "chipset.h" +#include "temp_sensor/pct2075.h" +#include "temp_sensor/temp_sensor.h" + +int board_get_soc_temp_mk(int *temp_mk) +{ + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) + return EC_ERROR_NOT_POWERED; + + return pct2075_get_val_mk(PCT2075_SENSOR_ID(DT_NODELABEL(soc_pct2075)), + temp_mk); +} + +int board_get_ambient_temp_mk(int *temp_mk) +{ + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) + return EC_ERROR_NOT_POWERED; + + return pct2075_get_val_mk(PCT2075_SENSOR_ID(DT_NODELABEL(amb_pct2075)), + temp_mk); +} diff --git a/zephyr/program/skyrim/src/usb_pd_policy.c b/zephyr/program/skyrim/src/usb_pd_policy.c new file mode 100644 index 0000000000..ec9f873863 --- /dev/null +++ b/zephyr/program/skyrim/src/usb_pd_policy.c @@ -0,0 +1,93 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Shared USB-C policy for Zork boards */ + +#include + +#include "charge_manager.h" +#include "chipset.h" +#include "common.h" +#include "compile_time_macros.h" +#include "console.h" +#include "ec_commands.h" +#include "ioexpander.h" +#include "system.h" +#include "usb_mux.h" +#include "usb_pd.h" +#include "usbc_ppc.h" +#include "util.h" + +int pd_check_vconn_swap(int port) +{ + /* + * Do not allow vconn swap 5V rail is off + * S5_PGOOD depends on PG_PP5000_S5 being asserted, + * so GPIO_S5_PGOOD is a reasonable proxy for PP5000_S5 + */ + return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5)); +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS. */ + ppc_vbus_source_enable(port, 0); + + /* Enable discharge if we were previously sourcing 5V */ + if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) + pd_set_vbus_discharge(port, 1); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + /* Disable charging. */ + rv = ppc_vbus_sink_enable(port, 0); + if (rv) + return rv; + + if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) + pd_set_vbus_discharge(port, 0); + + /* Provide Vbus. */ + rv = ppc_vbus_source_enable(port, 1); + if (rv) + return rv; + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +__override int board_pd_set_frs_enable(int port, int enable) +{ + /* + * Both PPCs require the FRS GPIO to be set as soon as FRS capability + * is established. + */ + if (port == 0) + ioex_set_level(IOEX_USB_C0_TCPC_FASTSW_CTL_EN, enable); + else + ioex_set_level(IOEX_USB_C1_TCPC_FASTSW_CTL_EN, enable); + + return EC_SUCCESS; +} + +/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */ +int board_vbus_source_enabled(int port) +{ + return tcpm_get_src_ctrl(port); +} + +/* Used by USB charger task with CONFIG_USB_PD_5V_EN_CUSTOM */ +int board_is_sourcing_vbus(int port) +{ + return board_vbus_source_enabled(port); +} diff --git a/zephyr/program/skyrim/src/usbc_config.c b/zephyr/program/skyrim/src/usbc_config.c new file mode 100644 index 0000000000..dec9f928b5 --- /dev/null +++ b/zephyr/program/skyrim/src/usbc_config.c @@ -0,0 +1,403 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim family-specific USB-C configuration */ + +#include + +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "battery_fuel_gauge.h" +#include "charge_manager.h" +#include "charge_ramp.h" +#include "charge_state_v2.h" +#include "charge_state.h" +#include "charger.h" +#include "driver/bc12/pi3usb9201.h" +#include "driver/charger/isl9241.h" +#include "driver/ppc/nx20p348x.h" +#include "driver/retimer/anx7483_public.h" +#include "driver/retimer/ps8811.h" +#include "driver/retimer/ps8818_public.h" +#include "driver/tcpm/nct38xx.h" +#include "driver/usb_mux/amd_fp6.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "ioexpander.h" +#include "power.h" +#include "usb_mux.h" +#include "usb_pd_tcpm.h" +#include "usbc_ppc.h" +#include "usbc/usb_muxes.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* USB-A ports */ +enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_A1, USBA_PORT_COUNT }; + +/* USB-C ports */ +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; +BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); + +static void reset_nct38xx_port(int port); + +static void usbc_interrupt_init(void) +{ + /* Enable PPC interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc)); + + /* Enable TCPC interrupts. */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc)); + + /* Enable BC 1.2 interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12)); + + /* Enable SBU fault interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_sbu_fault)); +} +DECLARE_HOOK(HOOK_INIT, usbc_interrupt_init, HOOK_PRIO_POST_I2C); + +static void usb_fault_interrupt_init(void) +{ + /* Enable USB fault interrupts when we hit S5 */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_hub_fault)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_fault)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a1_fault)); +} +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, usb_fault_interrupt_init, HOOK_PRIO_DEFAULT); + +static void usb_fault_interrupt_disable(void) +{ + /* Disable USB fault interrupts leaving S5 */ + gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_hub_fault)); + gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_fault)); + gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a1_fault)); +} +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_fault_interrupt_disable, + HOOK_PRIO_DEFAULT); + +int board_set_active_charge_port(int port) +{ + int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + int rv; + + if (port == CHARGE_PORT_NONE) { + CPRINTSUSB("Disabling all charger ports"); + + /* Disable all ports. */ + for (i = 0; i < ppc_cnt; i++) { + /* + * If this port had booted in dead battery mode, go + * ahead and reset it so EN_SNK responds properly. + */ + if (nct38xx_get_boot_type(i) == + NCT38XX_BOOT_DEAD_BATTERY) { + reset_nct38xx_port(i); + pd_set_error_recovery(i); + } + + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (ppc_vbus_sink_enable(i, 0)) + CPRINTSUSB("Disabling C%d as sink failed.", i); + } + + return EC_SUCCESS; + } else if (!is_valid_port) { + return EC_ERROR_INVAL; + } + + /* + * Check if we can reset any ports in dead battery mode + * + * The NCT3807 may continue to keep EN_SNK low on the dead battery port + * and allow a dangerous level of voltage to pass through to the initial + * charge port (see b/183660105). We must reset the ports if we have + * sufficient battery to do so, which will bring EN_SNK back under + * normal control. + */ + rv = EC_SUCCESS; + for (i = 0; i < board_get_usb_pd_port_count(); i++) { + if (nct38xx_get_boot_type(i) == NCT38XX_BOOT_DEAD_BATTERY) { + CPRINTSUSB("Found dead battery on %d", i); + /* + * If we have battery, get this port reset ASAP. + * This means temporarily rejecting charge manager + * sets to it. + */ + if (pd_is_battery_capable()) { + reset_nct38xx_port(i); + pd_set_error_recovery(i); + + if (port == i) + rv = EC_ERROR_INVAL; + } else if (port != i) { + /* + * If other port is selected and in dead battery + * mode, reset this port. Otherwise, reject + * change because we'll brown out. + */ + if (nct38xx_get_boot_type(port) == + NCT38XX_BOOT_DEAD_BATTERY) { + reset_nct38xx_port(i); + pd_set_error_recovery(i); + } else { + rv = EC_ERROR_INVAL; + } + } + } + } + + if (rv != EC_SUCCESS) + return rv; + + /* Check if the port is sourcing VBUS. */ + if (tcpm_get_src_ctrl(port)) { + CPRINTSUSB("Skip enable C%d", port); + return EC_ERROR_INVAL; + } + + CPRINTSUSB("New charge port: C%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < ppc_cnt; i++) { + if (i == port) + continue; + + if (ppc_vbus_sink_enable(i, 0)) + CPRINTSUSB("C%d: sink path disable failed.", i); + } + + /* Enable requested charge port. */ + if (ppc_vbus_sink_enable(port, 1)) { + CPRINTSUSB("C%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} + +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) +{ + charge_ma = (charge_ma * CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR) / 100; + + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} + +void sbu_fault_interrupt(enum gpio_signal signal) +{ + int port = signal == IOEX_USB_C1_FAULT_ODL ? 1 : 0; + + CPRINTSUSB("C%d: SBU fault", port); + pd_handle_overcurrent(port); +} + +void usb_fault_interrupt(enum gpio_signal signal) +{ + int out; + + CPRINTSUSB("USB fault(%d), alerting the SoC", signal); + out = gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_hub_fault_q_odl)) && + gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_a0_fault_odl)) && + gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_a1_fault_db_odl)); + + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_fault_odl), out); +} + +void usb_pd_soc_interrupt(enum gpio_signal signal) +{ + /* + * This interrupt is unexpected with our use of the SoC mux, so just log + * it as a point of interest. + */ + CPRINTSUSB("SOC PD Interrupt"); +} + +#ifdef CONFIG_CHARGER_ISL9241 +/* Round up 3250 max current to multiple of 128mA for ISL9241 AC prochot. */ +#define SKYRIM_AC_PROCHOT_CURRENT_MA 3328 +static void set_ac_prochot(void) +{ + isl9241_set_ac_prochot(CHARGER_SOLO, SKYRIM_AC_PROCHOT_CURRENT_MA); +} +DECLARE_HOOK(HOOK_INIT, set_ac_prochot, HOOK_PRIO_DEFAULT); +#endif /* CONFIG_CHARGER_ISL9241 */ + +void tcpc_alert_event(enum gpio_signal signal) +{ + int port; + + switch (signal) { + case GPIO_USB_C0_TCPC_INT_ODL: + port = 0; + break; + case GPIO_USB_C1_TCPC_INT_ODL: + port = 1; + break; + default: + return; + } + + schedule_deferred_pd_interrupt(port); +} + +static void reset_nct38xx_port(int port) +{ + const struct gpio_dt_spec *reset_gpio_l; + const struct device *ioex_port0, *ioex_port1; + + /* TODO(b/225189538): Save and restore ioex signals */ + if (port == USBC_PORT_C0) { + reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_l); + ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0)); + ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port1)); + } else if (port == USBC_PORT_C1) { + reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_rst_l); + ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c1_port0)); + ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c1_port1)); + } else { + /* Invalid port: do nothing */ + return; + } + + gpio_pin_set_dt(reset_gpio_l, 0); + msleep(NCT38XX_RESET_HOLD_DELAY_MS); + gpio_pin_set_dt(reset_gpio_l, 1); + nct38xx_reset_notify(port); + if (NCT3807_RESET_POST_DELAY_MS != 0) + msleep(NCT3807_RESET_POST_DELAY_MS); + + /* Re-enable the IO expander pins */ + gpio_reset_port(ioex_port0); + gpio_reset_port(ioex_port1); +} + +void board_reset_pd_mcu(void) +{ + /* Reset TCPC0 */ + reset_nct38xx_port(USBC_PORT_C0); + + /* Reset TCPC1 */ + reset_nct38xx_port(USBC_PORT_C1); +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + + /* + * Check which port has the ALERT line set and ignore if that TCPC has + * its reset line active. + */ + if (!gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) { + if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( + gpio_usb_c0_tcpc_rst_l)) != 0) + status |= PD_STATUS_TCPC_ALERT_0; + } + + if (!gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) { + if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( + gpio_usb_c1_tcpc_rst_l)) != 0) + status |= PD_STATUS_TCPC_ALERT_1; + } + + return status; +} + +void bc12_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_BC12_INT_ODL: + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + break; + + case GPIO_USB_C1_BC12_INT_ODL: + usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); + break; + + default: + break; + } +} + +/** + * Return if VBUS is sagging too low + * + * For legacy BC1.2 charging with CONFIG_CHARGE_RAMP_SW, ramp up input current + * until voltage drops to 4.5V. Don't go lower than this to be kind to the + * charger (see b/67964166). + */ +#define BC12_MIN_VOLTAGE 4500 +int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) +{ + int voltage = 0; + int rv; + + rv = charger_get_vbus_voltage(port, &voltage); + + if (rv) { + CPRINTSUSB("%s rv=%d", __func__, rv); + return 0; + } + + /* + * b/168569046: The ISL9241 sometimes incorrectly reports 0 for unknown + * reason, causing ramp to stop at 0.5A. Workaround this by ignoring 0. + * This partly defeats the point of ramping, but will still catch + * VBUS below 4.5V and above 0V. + */ + if (voltage == 0) { + CPRINTSUSB("%s vbus=0", __func__); + return 0; + } + + if (voltage < BC12_MIN_VOLTAGE) + CPRINTSUSB("%s vbus=%d", __func__, voltage); + + return voltage < BC12_MIN_VOLTAGE; +} + +#define SAFE_RESET_VBUS_DELAY_MS 900 +#define SAFE_RESET_VBUS_MV 5000 +void board_hibernate(void) +{ + int port; + enum ec_error_list ret; + + /* + * If we are charging, then drop the Vbus level down to 5V to ensure + * that we don't get locked out of the 6.8V OVLO for our PPCs in + * dead-battery mode. This is needed when the TCPC/PPC rails go away. + * (b/79218851, b/143778351, b/147007265) + */ + port = charge_manager_get_active_charge_port(); + if (port != CHARGE_PORT_NONE) { + pd_request_source_voltage(port, SAFE_RESET_VBUS_MV); + + /* Give PD task and PPC chip time to get to 5V */ + msleep(SAFE_RESET_VBUS_DELAY_MS); + } + + /* Try to put our battery fuel gauge into sleep mode */ + ret = battery_sleep_fuel_gauge(); + if ((ret != EC_SUCCESS) && (ret != EC_ERROR_UNIMPLEMENTED)) + cprints(CC_SYSTEM, "Failed to send battery sleep command"); +} diff --git a/zephyr/program/skyrim/src/winterhold/kb_backlight.c b/zephyr/program/skyrim/src/winterhold/kb_backlight.c new file mode 100644 index 0000000000..049b99e3a1 --- /dev/null +++ b/zephyr/program/skyrim/src/winterhold/kb_backlight.c @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "board_config.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +__override uint32_t board_override_feature_flags0(uint32_t flags0) +{ + int ret; + uint32_t val; + + /* + * Remove keyboard backlight feature for devices that don't support it. + */ + ret = cros_cbi_get_fw_config(FW_KB_BL, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL); + return flags0; + } + + if (val == FW_KB_BL_NOT_PRESENT) + return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB)); + else + return flags0; +} diff --git a/zephyr/program/skyrim/src/winterhold/keyboard.c b/zephyr/program/skyrim/src/winterhold/keyboard.c new file mode 100644 index 0000000000..d3aebe0f2e --- /dev/null +++ b/zephyr/program/skyrim/src/winterhold/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config winterhold_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &winterhold_kb; +} diff --git a/zephyr/program/skyrim/src/winterhold/ppc_config.c b/zephyr/program/skyrim/src/winterhold/ppc_config.c new file mode 100644 index 0000000000..72ddb6ce6c --- /dev/null +++ b/zephyr/program/skyrim/src/winterhold/ppc_config.c @@ -0,0 +1,27 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Winterhold board-specific PPC code */ + +#include + +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + nx20p348x_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c b/zephyr/program/skyrim/src/winterhold/usb_mux_config.c new file mode 100644 index 0000000000..fdcf37e6b0 --- /dev/null +++ b/zephyr/program/skyrim/src/winterhold/usb_mux_config.c @@ -0,0 +1,107 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Winterhold board-specific USB-C mux configuration */ + +#include + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + /* + * Those registers all need to be set no matter what state the mux is + * in it needs to be set. + */ + RETURN_ERROR( + anx7483_set_eq(me, ANX7483_PIN_URX1, ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR( + anx7483_set_eq(me, ANX7483_PIN_URX2, ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR( + anx7483_set_eq(me, ANX7483_PIN_UTX1, ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR( + anx7483_set_eq(me, ANX7483_PIN_UTX2, ANX7483_EQ_SETTING_8_4DB)); + + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_0_5DB)); + + return EC_SUCCESS; +} diff --git a/zephyr/program/skyrim/usbc.dts b/zephyr/program/skyrim/usbc.dts new file mode 100644 index 0000000000..8486927e8d --- /dev/null +++ b/zephyr/program/skyrim/usbc.dts @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + usbc_port0: port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + }; + + usbc_port1: port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + tcpc = <&tcpc_port1>; + }; + }; +}; diff --git a/zephyr/program/skyrim/winterhold.dts b/zephyr/program/skyrim/winterhold.dts new file mode 100644 index 0000000000..8a182ab835 --- /dev/null +++ b/zephyr/program/skyrim/winterhold.dts @@ -0,0 +1,161 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "i2c_common.dtsi" + +/ { + named-gpios { + /* Winterhold-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <105>; + temp_host_halt = <110>; + temp_host_release_high = <95>; + temp_host_release_halt = <100>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + temp_host_warn = <50>; + temp_host_high = <105>; + temp_host_halt = <110>; + temp_host_release_warn = <45>; + temp_host_release_high = <95>; + temp_host_release_halt = <100>; + temp_fan_off = <35>; + temp_fan_max = <40>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + Winterhold-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to enable KB back light or not. + */ + kb-bl { + enum-name = "FW_KB_BL"; + start = <1>; + size = <1>; + + no-kb-bl { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_NOT_PRESENT"; + value = <0>; + }; + kb-bl-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_PRESENT"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + }; + ppc_port0: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; +}; + +&i2c4_1 { + charger: isl9238@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; +}; + +&fan0 { + pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>; + rpm_min = <2100>; + rpm_start = <2600>; + rpm_max = <4800>; +}; + +&temp_sensor_charger { + temp_host_high = <100>; + temp_host_halt = <110>; + temp_host_release_high = <90>; + temp_host_release_halt = <100>; +}; + +&temp_sensor_memory { + temp_host_high = <91>; + temp_host_halt = <96>; + temp_host_release_high = <81>; + temp_host_release_halt = <86>; +}; + +&temp_sensor_cpu { + /delete-property/ temp_host_high; + /delete-property/ temp_host_halt; + /delete-property/ temp_host_release_high; + /delete-property/ temp_fan_off; + /delete-property/ temp_fan_max; +}; diff --git a/zephyr/program/trogdor/lazor/BUILD.py b/zephyr/program/trogdor/lazor/BUILD.py new file mode 100644 index 0000000000..ca1a26bdcf --- /dev/null +++ b/zephyr/program/trogdor/lazor/BUILD.py @@ -0,0 +1,25 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Define zmake projects for lazor.""" + +register_npcx_project( + project_name="lazor", + zephyr_board="npcx7", + dts_overlays=[ + "adc.dts", + "battery.dts", + "display.dts", + "gpio.dts", + "i2c.dts", + "host_interface_npcx.dts", + "interrupts.dts", + "keyboard.dts", + "led.dts", + "motionsense.dts", + "pwm_led.dts", + "usbc.dts", + "default_gpio_pinctrl.dts", + ], +) diff --git a/zephyr/program/trogdor/lazor/CMakeLists.txt b/zephyr/program/trogdor/lazor/CMakeLists.txt new file mode 100644 index 0000000000..b6d5024707 --- /dev/null +++ b/zephyr/program/trogdor/lazor/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(lazor) + +cros_ec_library_include_directories(include) + +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/power.c" + "src/usb_pd_policy.c" + "src/usbc_config.c") + +zephyr_library_sources( + "src/sku.c" + "src/switchcap.c") + +# Board specific implementation +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C + "src/i2c.c") diff --git a/zephyr/program/trogdor/lazor/adc.dts b/zephyr/program/trogdor/lazor/adc.dts new file mode 100644 index 0000000000..b834001587 --- /dev/null +++ b/zephyr/program/trogdor/lazor/adc.dts @@ -0,0 +1,48 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + vbus { + enum-name = "ADC_VBUS"; + io-channels = <&adc0 1>; + /* Measure VBUS through a 1/10 voltage divider */ + mul = <10>; + }; + amon_bmon { + enum-name = "ADC_AMON_BMON"; + io-channels = <&adc0 2>; + /* + * Adapter current output or battery charging/ + * discharging current (uV) 18x amplification on + * charger side. + */ + mul = <1000>; + div = <18>; + }; + psys { + enum-name = "ADC_PSYS"; + io-channels = <&adc0 3>; + /* + * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor, + * to read 0.8V @ 99 W, i.e. 124000 uW/mV. + */ + mul = <124000>; + }; + }; + +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/trogdor/lazor/battery.dts b/zephyr/program/trogdor/lazor/battery.dts new file mode 100644 index 0000000000..2b17dd4761 --- /dev/null +++ b/zephyr/program/trogdor/lazor/battery.dts @@ -0,0 +1,24 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: ap16l5j { + compatible = "panasonic,ap16l5j", "battery-smart"; + }; + ap16l5j_009 { + compatible = "panasonic,ap16l5j-009", "battery-smart"; + }; + ap16l8j { + compatible = "lgc,ap16l8j", "battery-smart"; + }; + lgc_ap18c8k { + compatible = "lgc,ap18c8k", "battery-smart"; + }; + murata_ap18c4k { + compatible = "murata,ap18c4k", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/trogdor/lazor/default_gpio_pinctrl.dts b/zephyr/program/trogdor/lazor/default_gpio_pinctrl.dts new file mode 100644 index 0000000000..1819bdbc3e --- /dev/null +++ b/zephyr/program/trogdor/lazor/default_gpio_pinctrl.dts @@ -0,0 +1,43 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Adds the &alt1_no_lpc_espi setting over the NPCX7 default setting. */ +&{/def-io-conf-list} { + pinmux = <&alt0_gpio_no_spip + &alt0_gpio_no_fpip + &alt1_no_pwrgd + &alt1_no_lpc_espi + &alta_no_peci_en + &altd_npsl_in1_sl + &altd_npsl_in2_sl + &altd_psl_in3_sl + &altd_psl_in4_sl + &alt7_no_ksi0_sl + &alt7_no_ksi1_sl + &alt7_no_ksi2_sl + &alt7_no_ksi3_sl + &alt7_no_ksi4_sl + &alt7_no_ksi5_sl + &alt7_no_ksi6_sl + &alt7_no_ksi7_sl + &alt8_no_kso00_sl + &alt8_no_kso01_sl + &alt8_no_kso02_sl + &alt8_no_kso03_sl + &alt8_no_kso04_sl + &alt8_no_kso05_sl + &alt8_no_kso06_sl + &alt8_no_kso07_sl + &alt9_no_kso08_sl + &alt9_no_kso09_sl + &alt9_no_kso10_sl + &alt9_no_kso11_sl + &alt9_no_kso12_sl + &alt9_no_kso13_sl + &alt9_no_kso14_sl + &alt9_no_kso15_sl + &alta_no_kso16_sl + &alta_no_kso17_sl >; +}; diff --git a/zephyr/program/trogdor/lazor/display.dts b/zephyr/program/trogdor/lazor/display.dts new file mode 100644 index 0000000000..65d3a2d91b --- /dev/null +++ b/zephyr/program/trogdor/lazor/display.dts @@ -0,0 +1,18 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + displight { + compatible = "cros-ec,displight"; + pwms = <&pwm5 0 PWM_HZ(4800) PWM_POLARITY_NORMAL>; + generic-pwm-channel = <1>; + }; +}; + +&pwm5 { + status = "okay"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/trogdor/lazor/gpio.dts b/zephyr/program/trogdor/lazor/gpio.dts new file mode 100644 index 0000000000..a047d7e2f2 --- /dev/null +++ b/zephyr/program/trogdor/lazor/gpio.dts @@ -0,0 +1,320 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-wp = &gpio_ec_wp_odl; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PD_INT_ODL"; + }; + gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { + gpios = <&gpiof 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PD_INT_ODL"; + }; + gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { + gpios = <&gpio0 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; + }; + gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { + gpios = <&gpio4 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; + }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; + }; + gpio_usb_a0_oc_odl: usb_a0_oc_odl { + gpios = <&gpiod 1 GPIO_INPUT_PULL_UP>; + }; + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 3 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpiof 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_lid_open_ec: lid_open_ec { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ap_rst_l: ap_rst_l { + gpios = <&gpioc 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_AP_RST_L"; + }; + gpio_ps_hold: ps_hold { + gpios = <&gpioa 4 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_PS_HOLD"; + }; + gpio_ap_suspend: ap_suspend { + gpios = <&gpio5 7 GPIO_INPUT>; + enum-name = "GPIO_AP_SUSPEND"; + }; + gpio_deprecated_ap_rst_req: deprecated_ap_rst_req { + gpios = <&gpioc 2 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_DEPRECATED_AP_RST_REQ"; + }; + gpio_power_good: power_good { + gpios = <&gpio5 4 GPIO_INPUT_PULL_DOWN>; + enum-name = "GPIO_POWER_GOOD"; + }; + gpio_warm_reset_l: warm_reset_l { + gpios = <&gpiof 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_WARM_RESET_L"; + }; + ap_ec_spi_cs_l { + gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioc 6 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + gpio_da9313_gpio0: da9313_gpio0 { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_DA9313_GPIO0"; + }; + /* + * Active low input + */ + gpio_switchcap_pg_int_l: switchcap_pg_int_l { + gpios = <&gpioe 2 (GPIO_ACTIVE_LOW | GPIO_INPUT)>; + }; + gpio_ec_rst_odl: ec_rst_odl { + gpios = <&gpio0 2 GPIO_INPUT>; + }; + ec_entering_rw { + gpios = <&gpioe 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + ec_batt_pres_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + pm845_resin_l { + gpios = <&gpio3 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_RESIN_L"; + }; + pmic_kpd_pwr_odl { + gpios = <&gpiod 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_PMIC_KPD_PWR_ODL"; + }; + ec_int_l { + gpios = <&gpioa 2 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + qsip_on { + gpios = <&gpio5 0 GPIO_OUTPUT_LOW>; + }; + gpio_hibernate_l: hibernate_l { + gpios = <&gpio5 2 GPIO_OUTPUT_HIGH>; + }; + gpio_switchcap_on: switchcap_on { + gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_SWITCHCAP_ON"; + }; + gpio_vbob_en: vbob_en { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_VBOB_EN"; + }; + gpio_en_pp3300_a: en_pp3300_a { + gpios = <&gpioa 6 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PP3300_A"; + }; + gpio_en_pp5000_a: en_pp5000_a { + gpios = <&gpio6 7 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PP5000"; + }; + ec_bl_disable_l { + gpios = <&gpiob 6 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_lid_accel_int_l: lid_accel_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + trackpad_int_gate { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { + gpios = <&gpiof 1 GPIO_ODR_HIGH>; + }; + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { + gpios = <&gpioe 4 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_oe_l: dp_mux_oe_l { + gpios = <&gpio9 6 GPIO_ODR_HIGH>; + }; + gpio_dp_mux_sel: dp_mux_sel { + gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; + }; + gpio_dp_hot_plug_det: dp_hot_plug_det { + gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; + }; + gpio_en_usb_a_5v: en_usb_a_5v { + gpios = <&gpio8 6 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_USB_A_5V"; + }; + usb_a_cdp_ilim_en { + gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; + }; + gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { + #led-pin-cells = <1>; + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + gpio_ec_chg_led_b_c1: ec_chg_led_b_c1 { + #led-pin-cells = <1>; + gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; + }; + gpio_brd_id0: brd_id0 { + gpios = <&gpioc 7 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION1"; + }; + gpio_brd_id1: brd_id1 { + gpios = <&gpio9 3 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION2"; + }; + gpio_brd_id2: brd_id2 { + gpios = <&gpio6 3 GPIO_INPUT>; + enum-name = "GPIO_BOARD_VERSION3"; + }; + gpio_sku_id0: sku_id0 { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_sku_id1: sku_id1 { + gpios = <&gpio4 1 GPIO_INPUT>; + }; + gpio_sku_id2: sku_id2 { + gpios = <&gpiod 4 GPIO_INPUT>; + }; + arm_x86 { + gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; + }; + ec-i2c-sensor-scl { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&gpio_en_usb_a_5v>; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_power_button + &int_lid_open + &int_ec_rst + >; + }; + + ec-mkbp-host-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <( + HOST_EVENT_LID_OPEN | + HOST_EVENT_POWER_BUTTON | + HOST_EVENT_AC_CONNECTED | + HOST_EVENT_AC_DISCONNECTED | + HOST_EVENT_HANG_DETECT | + HOST_EVENT_RTC | + HOST_EVENT_MODE_CHANGE | + HOST_EVENT_DEVICE)>; + }; + + ec-mkbp-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | + MKBP_EVENT_HOST_EVENT | + MKBP_EVENT_SENSOR_FIFO)>; + }; + + sku { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_sku_id0 + &gpio_sku_id1 + &gpio_sku_id2 + >; + + system = "binary"; + }; + + board { + compatible = "cros-ec,gpio-id"; + + bits = < + &gpio_brd_id0 + &gpio_brd_id1 + &gpio_brd_id2 + >; + + system = "binary_first_base3"; + }; + + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio5 1 0>, + <&gpiod 0 0>, + <&gpiof 3 0>, + <&gpio0 4 0>, + <&gpioc 0 0>, + <&gpioa 7 0>, + <&gpio8 3 0>, + <&gpio8 1 0>, + <&gpio3 7 0>, + <&gpio7 6 0>, + <&gpio3 4 0>, + <&gpioc 5 0>, + <&gpioa 3 0>, + <&gpio7 3 0>, + <&gpiod 7 0>, + <&gpioa 5 0>, + <&gpiob 0 0>, + <&gpio9 4 0>, + <&gpiob 1 0>, + <&gpio6 2 0>, + <&gpio3 5 0>, + <&gpio9 7 0>, + <&gpio6 0 0>, + <&gpio7 2 0>; + }; +}; diff --git a/zephyr/program/trogdor/lazor/gpio_led.dts b/zephyr/program/trogdor/lazor/gpio_led.dts new file mode 100644 index 0000000000..c8c026506b --- /dev/null +++ b/zephyr/program/trogdor/lazor/gpio_led.dts @@ -0,0 +1,33 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-led-pins { + compatible = "cros-ec,gpio-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&gpio_ec_chg_led_y_c1 0>, + <&gpio_ec_chg_led_b_c1 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&gpio_ec_chg_led_y_c1 1>, + <&gpio_ec_chg_led_b_c1 0>; + }; + + color_blue: color-blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pins = <&gpio_ec_chg_led_y_c1 0>, + <&gpio_ec_chg_led_b_c1 1>; + }; + }; +}; diff --git a/zephyr/program/trogdor/lazor/host_interface_npcx.dts b/zephyr/program/trogdor/lazor/host_interface_npcx.dts new file mode 100644 index 0000000000..14efa3c6b2 --- /dev/null +++ b/zephyr/program/trogdor/lazor/host_interface_npcx.dts @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* host interface */ +&shi { + status = "okay"; + pinctrl-0 = <&shi_gp46_47_53_55>; + pinctrl-1 = <&shi_gpio_gp46_47_53_55>; + pinctrl-names = "default", "sleep"; +}; diff --git a/zephyr/program/trogdor/lazor/i2c.dts b/zephyr/program/trogdor/lazor/i2c.dts new file mode 100644 index 0000000000..e19ad224a9 --- /dev/null +++ b/zephyr/program/trogdor/lazor/i2c.dts @@ -0,0 +1,145 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_power: power { + i2c-port = <&i2c0_0>; + remote-port = <0>; + enum-names = "I2C_PORT_POWER", + "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY", + "I2C_PORT_CHARGER"; + }; + i2c_tcpc0: tcpc0 { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_TCPC0"; + }; + i2c_tcpc1: tcpc1 { + i2c-port = <&i2c2_0>; + enum-names = "I2C_PORT_TCPC1"; + }; + i2c_eeprom: eeprom { + i2c-port = <&i2c5_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_sensor: sensor { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_SENSOR", + "I2C_PORT_ACCEL"; + }; + }; + +}; + +&i2c0_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + charger: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + ppc_port0: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + status = "okay"; + reg = <0xb>; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; + + ppc_port1: sn5s330@40{ + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + status = "okay"; + reg = <0xb>; + }; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + /* Not used as no WLC connected */ + clock-frequency = ; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c5_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c1_bc12>; + }; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c7_0 { + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/trogdor/lazor/include/sku.h b/zephyr/program/trogdor/lazor/include/sku.h new file mode 100644 index 0000000000..76825bbba1 --- /dev/null +++ b/zephyr/program/trogdor/lazor/include/sku.h @@ -0,0 +1,17 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Lazor board-specific SKU configuration */ + +#ifndef __ZEPHYR_LAZOR_SKU_H +#define __ZEPHYR_LAZOR_SKU_H + +int board_get_version(void); +int board_is_clamshell(void); +int board_has_da9313(void); +int board_has_ln9310(void); +int board_has_buck_ic(void); + +#endif /* __ZEPHYR_LAZOR_SKU_H */ diff --git a/zephyr/program/trogdor/lazor/interrupts.dts b/zephyr/program/trogdor/lazor/interrupts.dts new file mode 100644 index 0000000000..5c2ed35e90 --- /dev/null +++ b/zephyr/program/trogdor/lazor/interrupts.dts @@ -0,0 +1,140 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_ac_present: ac_present { + irq-pin = <&gpio_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open_ec>; + flags = ; + handler = "lid_interrupt"; + }; + int_wp: wp { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_ec_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_ec_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + /* + * Note this is an active low input, so + * the direction is from logical low to + * logical high. + */ + int_switchcap_pg: switchcap_pg { + irq-pin = <&gpio_switchcap_pg_int_l>; + flags = ; + handler = "ln9310_interrupt"; + }; + int_ap_rst: ap_rst { + irq-pin = <&gpio_ap_rst_l>; + flags = ; + handler = "chipset_ap_rst_interrupt"; + }; + int_ap_suspend: ap_suspend { + irq-pin = <&gpio_ap_suspend>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_deprecated_ap_rst_req: deprecated_ap_rst_req { + irq-pin = <&gpio_deprecated_ap_rst_req>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_power_good: power_good { + irq-pin = <&gpio_power_good>; + flags = ; + handler = "chipset_power_good_interrupt"; + }; + int_ps_hold: ps_hold { + irq-pin = <&gpio_ps_hold>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_warm_reset: warm_reset { + irq-pin = <&gpio_warm_reset_l>; + flags = ; + handler = "chipset_warm_reset_interrupt"; + }; + int_usb_c0_tcpc: usb_c0_tcpc { + irq-pin = <&gpio_usb_c0_pd_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-pin = <&gpio_usb_c1_pd_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_swctl: usb_c0_swctl { + irq-pin = <&gpio_usb_c0_swctl_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_swctl: usb_c1_swctl { + irq-pin = <&gpio_usb_c1_swctl_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_l>; + flags = ; + handler = "usb0_evt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_l>; + flags = ; + handler = "usb1_evt"; + }; + int_usb_a0_oc: usb_a0_oc { + irq-pin = <&gpio_usb_a0_oc_odl>; + flags = ; + handler = "usba_oc_interrupt"; + }; + int_ccd_mode: ccd_mode { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "board_connect_c0_sbu"; + }; + int_accel: accel { + irq-pin = <&gpio_accel_gyro_int_l>; + flags = ; + handler = "bmi160_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_ec_rst: ec_rst { + irq-pin = <&gpio_ec_rst_odl>; + flags = ; + handler = "wake_isr"; + }; + }; +}; diff --git a/zephyr/program/trogdor/lazor/keyboard.dts b/zephyr/program/trogdor/lazor/keyboard.dts new file mode 100644 index 0000000000..b8689b883c --- /dev/null +++ b/zephyr/program/trogdor/lazor/keyboard.dts @@ -0,0 +1,38 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + actual-key-mask = < + 0x14 /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; + + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm3 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; + generic-pwm-channel = <0>; + }; +}; + +&pwm3 { + status = "okay"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/trogdor/lazor/led.dts b/zephyr/program/trogdor/lazor/led.dts new file mode 100644 index 0000000000..4527afd34c --- /dev/null +++ b/zephyr/program/trogdor/lazor/led.dts @@ -0,0 +1,90 @@ +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Blue 2 sec, Amber 2 sec */ + color-0 { + led-color = <&color_blue>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + }; + + power-state-idle { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_blue>; + }; + }; + }; +}; diff --git a/zephyr/program/trogdor/lazor/motionsense.dts b/zephyr/program/trogdor/lazor/motionsense.dts new file mode 100644 index 0000000000..75fe31b997 --- /dev/null +++ b/zephyr/program/trogdor/lazor/motionsense.dts @@ -0,0 +1,181 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi160-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi160: bmi160-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma255_data: bma255-drv-data { + compatible = "cros-ec,drvdata-bma255"; + status = "okay"; + }; + + bmi160_data: bmi160-drv-data { + compatible = "cros-ec,drvdata-bmi160"; + status = "okay"; + }; + + kx022_data: kx022-drv-data { + compatible = "cros-ec,drvdata-kionix"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma255"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3_S5"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma255_data>; + i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi160-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3_S5"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi160>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi160_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi160-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3_S5"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi160>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi160_data>; + }; + }; + + /* + * List of alternative motion sensors that creates + * motion_sensors_alt array. + */ + motionsense-sensor-alt { + alt_lid_accel { + compatible = "cros-ec,kx022"; + status = "okay"; + active-mask = "SENSOR_ACTIVE_S0_S3_S5"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + drv-data = <&kx022_data>; + alternate-for = <&lid_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf new file mode 100644 index 0000000000..358de69d68 --- /dev/null +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -0,0 +1,164 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +# +# Lazor actually has a NPCX7M6FC, but +# the NPCX7M7FC is actually the same die, without the +# extra RAM being tested. The code size really could +# do with the extra space, so we pretend the EC is the +# part with the larger RAM. YMMV. +# +CONFIG_SOC_NPCX7M7FC=y +CONFIG_SOC_SERIES_NPCX7=y +CONFIG_SHIMMED_TASKS=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_BRINGUP=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y + +# I2C +CONFIG_I2C=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# Application Processor is Qualcomm SC7180 +CONFIG_AP_ARM_QUALCOMM_SC7180=y + +# Board version is selected over GPIO board ID pins. +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y + +# LN9310 Switchcap +CONFIG_PLATFORM_EC_SWITCHCAP_LN9310=y + +# Power Sequencing +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y +CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y +CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y + +# Trogdor family does not use EFS2 +CONFIG_PLATFORM_EC_VBOOT_EFS2=n + +# MKBP event +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_CMD_BUTTON=y +CONFIG_CROS_KB_RAW_NPCX=y + +# ADC +CONFIG_ADC=y +CONFIG_ADC_SHELL=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y +CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238=y +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y +CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y +CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION" +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=10000 +CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y + +# USB-A +CONFIG_PLATFORM_EC_USBA=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n +CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y +CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_REV30=n +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_MULTI_PS8XXX=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8751=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y + +# USB ID +# This is allocated specifically for Trogdor +# http://google3/hardware/standards/usb/ +# TODO(b/183608112): Move to device tree +CONFIG_PLATFORM_EC_USB_PID=0x5043 + +# RTC +CONFIG_PLATFORM_EC_RTC=y +CONFIG_CROS_RTC_NPCX=y +CONFIG_PLATFORM_EC_HOSTCMD_RTC=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y + +# EC software sync +CONFIG_PLATFORM_EC_VBOOT_HASH=y + +# Sensors +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y + +# Sensor Drivers +CONFIG_PLATFORM_EC_ACCEL_BMA255=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI160=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Console history +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_CMDS=y +CONFIG_SHELL_HELP=n +CONFIG_SHELL_MINIMAL=y + +# Taskinfo +CONFIG_THREAD_MONITOR=y +CONFIG_KERNEL_SHELL=y + +CONFIG_SYSCON=y + +# Features should be enabled. But the code RAM is not enough, disable them. +#CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y +#CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y diff --git a/zephyr/program/trogdor/lazor/pwm_led.dts b/zephyr/program/trogdor/lazor/pwm_led.dts new file mode 100644 index 0000000000..0582966d6a --- /dev/null +++ b/zephyr/program/trogdor/lazor/pwm_led.dts @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwm_pins { + compatible = "cros-ec,pwm-pin-config"; + + pwm_y: pwm_y { + #led-pin-cells = <1>; + pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; + }; + + pwm_b: pwm_b { + #led-pin-cells = <1>; + pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&pwm_y 0>, + <&pwm_b 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&pwm_y 100>, + <&pwm_b 0>; + }; + + color_blue: color-blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pins = <&pwm_y 0>, + <&pwm_b 100>; + }; + }; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +&pwm2 { + status = "okay"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/trogdor/lazor/src/hibernate.c b/zephyr/program/trogdor/lazor/src/hibernate.c new file mode 100644 index 0000000000..388ff1b087 --- /dev/null +++ b/zephyr/program/trogdor/lazor/src/hibernate.c @@ -0,0 +1,48 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "sku.h" +#include "system.h" +#include "usbc_ppc.h" + +void board_hibernate(void) +{ + int i; + + if (!board_is_clamshell()) { + /* + * Sensors are unpowered in hibernate. Apply PD to the + * interrupt lines such that they don't float. + */ + gpio_pin_configure_dt( + GPIO_DT_FROM_NODELABEL(gpio_accel_gyro_int_l), + GPIO_DISCONNECTED); + gpio_pin_configure_dt( + GPIO_DT_FROM_NODELABEL(gpio_lid_accel_int_l), + GPIO_DISCONNECTED); + } + + /* + * Board rev 5+ has the hardware fix. Don't need the following + * workaround. + */ + if (system_get_board_version() >= 5) + return; + + /* + * Enable the PPC power sink path before EC enters hibernate; + * otherwise, ACOK won't go High and can't wake EC up. Check the + * bug b/170324206 for details. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) + ppc_vbus_sink_enable(i, 1); +} + +void board_hibernate_late(void) +{ + /* Set the hibernate GPIO to turn off the rails */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hibernate_l), 0); +} diff --git a/zephyr/program/trogdor/lazor/src/i2c.c b/zephyr/program/trogdor/lazor/src/i2c.c new file mode 100644 index 0000000000..6d737b410f --- /dev/null +++ b/zephyr/program/trogdor/lazor/src/i2c.c @@ -0,0 +1,17 @@ +/* Copyright 2021 The ChromiumOS Authors + * 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" + +/* Lazor board specific i2c implementation */ + +#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED +int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) +{ + return (i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY)); +} +#endif diff --git a/zephyr/program/trogdor/lazor/src/power.c b/zephyr/program/trogdor/lazor/src/power.c new file mode 100644 index 0000000000..96f9bc43c5 --- /dev/null +++ b/zephyr/program/trogdor/lazor/src/power.c @@ -0,0 +1,58 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include +#include "power.h" +#include "task.h" +#include "gpio.h" + +static void board_power_change(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) +{ + switch (data.event) { + default: + return; + + case AP_POWER_PRE_INIT: + /* Turn on the 3.3V rail */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 1); + + /* Turn on the 5V rail. */ +#ifdef CONFIG_POWER_PP5000_CONTROL + power_5v_enable(task_get_current(), 1); +#else /* !defined(CONFIG_POWER_PP5000_CONTROL) */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 1); +#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ + break; + + case AP_POWER_SHUTDOWN_COMPLETE: + /* Turn off the 5V rail. */ +#ifdef CONFIG_POWER_PP5000_CONTROL + power_5v_enable(task_get_current(), 0); +#else /* !defined(CONFIG_POWER_PP5000_CONTROL) */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 0); +#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ + + /* Turn off the 3.3V and 5V rails. */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 0); + break; + } +} + +static int board_power_handler_init(const struct device *unused) +{ + static struct ap_power_ev_callback cb; + + /* Setup a suspend/resume callback */ + ap_power_ev_init_callback(&cb, board_power_change, + AP_POWER_PRE_INIT | + AP_POWER_SHUTDOWN_COMPLETE); + ap_power_ev_add_callback(&cb); + return 0; +} +SYS_INIT(board_power_handler_init, APPLICATION, 1); diff --git a/zephyr/program/trogdor/lazor/src/sku.c b/zephyr/program/trogdor/lazor/src/sku.c new file mode 100644 index 0000000000..1d88437031 --- /dev/null +++ b/zephyr/program/trogdor/lazor/src/sku.c @@ -0,0 +1,92 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "config.h" +#include "console.h" +#include "driver/ln9310.h" +#include "tcpm/ps8xxx_public.h" +#include "hooks.h" +#include "sku.h" +#include "system.h" +#include "util.h" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +static uint8_t sku_id; + +enum board_model { + LAZOR, + LIMOZEEN, + UNKNOWN, +}; + +static const char *const model_name[] = { + "LAZOR", + "LIMOZEEN", + "UNKNOWN", +}; + +static enum board_model get_model(void) +{ + if (sku_id == 0 || sku_id == 1 || sku_id == 2 || sku_id == 3) + return LAZOR; + if (sku_id == 4 || sku_id == 5 || sku_id == 6) + return LIMOZEEN; + return UNKNOWN; +} + +/* Read SKU ID from GPIO and initialize variables for board variants */ +static void sku_init(void) +{ + sku_id = system_get_sku_id(); + CPRINTS("SKU: %u (%s)", sku_id, model_name[get_model()]); +} +DECLARE_HOOK(HOOK_INIT, sku_init, HOOK_PRIO_POST_I2C); + +enum battery_cell_type board_get_battery_cell_type(void) +{ + switch (get_model()) { + case LIMOZEEN: + return BATTERY_CELL_TYPE_3S; + default: + return BATTERY_CELL_TYPE_UNKNOWN; + } +} + +int board_is_clamshell(void) +{ + return get_model() == LIMOZEEN; +} + +__override uint16_t board_get_ps8xxx_product_id(int port) +{ + /* + * Lazor (SKU_ID: 0, 1, 2, 3) rev 3+ changes TCPC from PS8751 to + * PS8805. + * + * Limozeen (SKU_ID: 4, 5, 6) all-rev uses PS8805. + */ + if (get_model() == LAZOR && system_get_board_version() < 3) + return PS8751_PRODUCT_ID; + + return PS8805_PRODUCT_ID; +} + +int board_has_da9313(void) +{ + return get_model() == LAZOR; +} + +int board_has_buck_ic(void) +{ + return get_model() == LIMOZEEN && system_get_board_version() >= 8; +} + +int board_has_ln9310(void) +{ + return get_model() == LIMOZEEN && system_get_board_version() < 8; +} diff --git a/zephyr/program/trogdor/lazor/src/switchcap.c b/zephyr/program/trogdor/lazor/src/switchcap.c new file mode 100644 index 0000000000..d8205cbcfc --- /dev/null +++ b/zephyr/program/trogdor/lazor/src/switchcap.c @@ -0,0 +1,128 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "common.h" +#include "config.h" +#include "console.h" +#include "driver/ln9310.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "i2c.h" +#include "power/qcom.h" +#include "system.h" +#include "sku.h" + +#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args) + +/* LN9310 switchcap */ +const struct ln9310_config_t ln9310_config = { + .i2c_port = I2C_PORT_POWER, + .i2c_addr_flags = LN9310_I2C_ADDR_0_FLAGS, +}; + +static void switchcap_init(void) +{ + if (board_has_da9313()) { + CPRINTS("Use switchcap: DA9313"); + + /* + * When the chip in power down mode, it outputs high-Z. + * Set pull-down to avoid floating. + */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0), + GPIO_INPUT | GPIO_PULL_DOWN); + + /* + * Configure DA9313 enable, push-pull output. Don't set the + * level here; otherwise, it will override its value and + * shutdown the switchcap when sysjump to RW. + */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), + GPIO_OUTPUT); + } else if (board_has_ln9310()) { + CPRINTS("Use switchcap: LN9310"); + + /* Enable interrupt for LN9310 */ + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_switchcap_pg)); + + /* + * Configure LN9310 enable, open-drain output. Don't set the + * level here; otherwise, it will override its value and + * shutdown the switchcap when sysjump to RW. + * + * Note that the gpio.inc configures it GPIO_OUT_LOW. When + * sysjump to RW, will output push-pull a short period of + * time. As it outputs LOW, should be fine. + * + * This GPIO changes like: + * (1) EC boots from RO -> high-Z + * (2) GPIO init according to gpio.inc -> push-pull LOW + * (3) This function configures it -> open-drain HIGH + * (4) Power sequence turns on the switchcap -> open-drain LOW + * (5) EC sysjumps to RW + * (6) GPIO init according to gpio.inc -> push-pull LOW + * (7) This function configures it -> open-drain LOW + */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), + GPIO_OUTPUT | GPIO_OPEN_DRAIN); + + /* Only configure the switchcap if not sysjump */ + if (!system_jumped_late()) { + /* + * Deassert the enable pin, so the + * switchcap won't be enabled after the switchcap is + * configured from standby mode to switching mode. + */ + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), 0); + ln9310_init(); + } + } else if (board_has_buck_ic()) { + CPRINTS("Use Buck IC"); + } else { + CPRINTS("ERROR: No switchcap solution"); + } +} +DECLARE_HOOK(HOOK_INIT, switchcap_init, HOOK_PRIO_DEFAULT); + +void board_set_switchcap_power(int enable) +{ + if (board_has_da9313()) { + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), + enable); + } else if (board_has_ln9310()) { + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), + enable); + ln9310_software_enable(enable); + } else if (board_has_buck_ic()) { + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_vbob_en), enable); + } +} + +int board_is_switchcap_enabled(void) +{ + if (board_has_da9313() || board_has_ln9310()) + return gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on)); + + /* Board has buck ic*/ + return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_vbob_en)); +} + +int board_is_switchcap_power_good(void) +{ + if (board_has_da9313()) + return gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0)); + else if (board_has_ln9310()) + return ln9310_power_good(); + + /* Board has buck ic no way to check POWER GOOD */ + return 1; +} diff --git a/zephyr/program/trogdor/lazor/src/usb_pd_policy.c b/zephyr/program/trogdor/lazor/src/usb_pd_policy.c new file mode 100644 index 0000000000..8d046826f9 --- /dev/null +++ b/zephyr/program/trogdor/lazor/src/usb_pd_policy.c @@ -0,0 +1,261 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charge_manager.h" +#include "chipset.h" +#include "console.h" +#include "system.h" +#include "usb_mux.h" +#include "usbc_ppc.h" +#include "util.h" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +int pd_check_vconn_swap(int port) +{ + /* In G3, do not allow vconn swap since PP5000 rail is off */ + return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a)); +} + +static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; +#if CONFIG_USB_PD_PORT_MAX_COUNT == 1 +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5 }; +#else +static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5, + TYPEC_RP_1A5 }; +#endif + +static void board_vbus_update_source_current(int port) +{ + /* Both port are controlled by PPC SN5S330. */ + ppc_set_vbus_source_current_limit(port, vbus_rp[port]); + ppc_vbus_source_enable(port, vbus_en[port]); +} + +void pd_power_supply_reset(int port) +{ + int prev_en; + + prev_en = vbus_en[port]; + + /* Disable VBUS */ + vbus_en[port] = 0; + board_vbus_update_source_current(port); + + /* Enable discharge if we were previously sourcing 5V */ + if (prev_en) + pd_set_vbus_discharge(port, 1); + + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + /* Disable charging */ + board_vbus_sink_enable(port, 0); + + pd_set_vbus_discharge(port, 0); + + /* Provide VBUS */ + vbus_en[port] = 1; + board_vbus_update_source_current(port); + + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; /* we are ready */ +} + +int board_vbus_source_enabled(int port) +{ + return vbus_en[port]; +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + vbus_rp[port] = rp; + board_vbus_update_source_current(port); +} + +int pd_snk_is_vbus_provided(int port) +{ + return tcpm_check_vbus_level(port, VBUS_PRESENT); +} + +/* ----------------- Vendor Defined Messages ------------------ */ +#ifdef CONFIG_USB_PD_ALT_MODE_DFP +__override int svdm_dp_config(int port, uint32_t *payload) +{ + int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); + uint8_t pin_mode = get_dp_pin_mode(port); + + if (!pin_mode) + return 0; + + /* + * Defer setting the usb_mux until HPD goes high, svdm_dp_attention(). + * The AP only supports one DP phy. An external DP mux switches between + * the two ports. Should switch those muxes when it is really used, + * i.e. HPD high; otherwise, the real use case is preempted, like: + * (1) plug a dongle without monitor connected to port-0, + * (2) plug a dongle without monitor connected to port-1, + * (3) plug a monitor to the port-1 dongle. + */ + + payload[0] = + VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); + payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ + 1, /* DPv1.3 signaling */ + 2); /* UFP connected */ + return 2; +}; + +__override void svdm_dp_post_config(int port) +{ + dp_flags[port] |= DP_FLAGS_DP_ON; +} + +/** + * Is the port fine to be muxed its DisplayPort lines? + * + * Only one port can be muxed to DisplayPort at a time. + * + * @param port Port number of TCPC. + * @return 1 is fine; 0 is bad as other port is already muxed; + */ +static int is_dp_muxable(int port) +{ + int i; + + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) + if (i != port) { + if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED) + return 0; + } + + return 1; +} + +__override int svdm_dp_attention(int port, uint32_t *payload) +{ + const struct gpio_dt_spec *hpd = + GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det); + int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); + int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); + int cur_lvl = gpio_pin_get_dt(hpd); + mux_state_t mux_state; + + dp_status[port] = payload[1]; + + if (!is_dp_muxable(port)) { + /* TODO(waihong): Info user? */ + CPRINTS("p%d: The other port is already muxed.", port); + return 0; + } + + /* + * Initial implementation to handle HPD. Only the first-plugged port + * works, i.e. sending HPD signal to AP. The second-plugged port + * will be ignored. + * + * TODO(waihong): Continue the above case, if the first-plugged port + * is then unplugged, switch to the second-plugged port and signal AP? + */ + if (lvl) { + /* + * Enable and switch the DP port selection mux to the + * correct port. + * + * TODO(waihong): Better to move switching DP mux to + * the usb_mux abstraction. + */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), + port == 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0); + + /* Connect the SBU lines in PPC chip. */ + if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) + ppc_set_sbu(port, 1); + + /* + * Connect the USB SS/DP lines in TCPC chip. + * + * When mf_pref not true, still use the dock muxing + * because of the board USB-C topology (limited to 2 + * lanes DP). + */ + usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT, + polarity_rm_dts(pd_get_polarity(port))); + } else { + /* Disconnect the DP port selection mux. */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); + + /* Disconnect the SBU lines in PPC chip. */ + if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) + ppc_set_sbu(port, 0); + + /* Disconnect the DP but keep the USB SS lines in TCPC chip. */ + usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, + polarity_rm_dts(pd_get_polarity(port))); + } + + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) + /* + * Wake up the AP. IRQ or level high indicates a DP sink is now + * present. + */ + pd_notify_dp_alt_mode_entry(port); + + /* Configure TCPC for the HPD event, for proper muxing */ + mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) | + (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED); + usb_mux_hpd_update(port, mux_state); + + /* Signal AP for the HPD event, through GPIO to AP */ + if (irq & cur_lvl) { + uint64_t now = get_time().val; + /* Wait for the minimum spacing between IRQ_HPD if needed */ + if (now < svdm_hpd_deadline[port]) + usleep(svdm_hpd_deadline[port] - now); + + /* Generate IRQ_HPD pulse */ + gpio_pin_set_dt(hpd, 0); + usleep(HPD_DSTREAM_DEBOUNCE_IRQ); + gpio_pin_set_dt(hpd, 1); + + /* Set the minimum time delay (2ms) for the next HPD IRQ */ + svdm_hpd_deadline[port] = + get_time().val + HPD_USTREAM_DEBOUNCE_LVL; + } else if (irq & !lvl) { + CPRINTF("ERR:HPD:IRQ&LOW\n"); + return 0; + } + gpio_pin_set_dt(hpd, lvl); + /* Set the minimum time delay (2ms) for the next HPD IRQ */ + svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; + + return 1; +} + +__override void svdm_exit_dp_mode(int port) +{ + if (is_dp_muxable(port)) { + /* Disconnect the DP port selection mux. */ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); + + /* Signal AP for the HPD low event */ + usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | + USB_PD_MUX_HPD_IRQ_DEASSERTED); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det), + 0); + } +} +#endif /* CONFIG_USB_PD_ALT_MODE_DFP */ diff --git a/zephyr/program/trogdor/lazor/src/usbc_config.c b/zephyr/program/trogdor/lazor/src/usbc_config.c new file mode 100644 index 0000000000..f6bfdfb186 --- /dev/null +++ b/zephyr/program/trogdor/lazor/src/usbc_config.c @@ -0,0 +1,335 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Lazor board-specific USB-C configuration */ + +#include "battery_fuel_gauge.h" +#include "bc12/pi3usb9201_public.h" +#include "charger.h" +#include "charger/isl923x_public.h" +#include "charge_manager.h" +#include "charge_state.h" +#include "common.h" +#include "config.h" +#include "driver/ln9310.h" +#include "gpio_signal.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "ppc/sn5s330_public.h" +#include "system.h" +#include "tcpm/ps8xxx_public.h" +#include "tcpm/tcpci.h" +#include "timer.h" +#include "usb_pd.h" +#include "usb_mux.h" +#include "usbc_ocp.h" +#include "usbc_ppc.h" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +int charger_profile_override(struct charge_state_data *curr) +{ + int usb_mv; + int port; + + if (curr->state != ST_CHARGE) + return 0; + + /* Lower the max requested voltage to 5V when battery is full. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF) && + !(curr->batt.flags & BATT_FLAG_BAD_STATUS) && + !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) && + (curr->batt.status & STATUS_FULLY_CHARGED)) + usb_mv = 5000; + else + usb_mv = PD_MAX_VOLTAGE_MV; + + if (pd_get_max_voltage() != usb_mv) { + CPRINTS("VBUS limited to %dmV", usb_mv); + for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) + pd_set_external_voltage_limit(port, usb_mv); + } + + return 0; +} + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} + +static void usba_oc_deferred(void) +{ + /* Use next number after all USB-C ports to indicate the USB-A port */ + board_overcurrent_event( + CONFIG_USB_PD_PORT_MAX_COUNT, + !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_a0_oc_odl))); +} +DECLARE_DEFERRED(usba_oc_deferred); + +void usba_oc_interrupt(enum gpio_signal signal) +{ + hook_call_deferred(&usba_oc_deferred_data, 0); +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_swctl_int_odl)): + sn5s330_interrupt(0); + break; + case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_swctl_int_odl)): + sn5s330_interrupt(1); + break; + default: + break; + } +} + +static void board_connect_c0_sbu_deferred(void) +{ + /* + * If CCD_MODE_ODL asserts, it means there's a debug accessory connected + * and we should enable the SBU FETs. + */ + ppc_set_sbu(0, 1); +} +DECLARE_DEFERRED(board_connect_c0_sbu_deferred); + +void board_connect_c0_sbu(enum gpio_signal s) +{ + hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0); +} + +/* GPIO Interrupt Handlers */ +void tcpc_alert_event(enum gpio_signal signal) +{ + int port = -1; + + switch (signal) { + case GPIO_USB_C0_PD_INT_ODL: + port = 0; + break; + case GPIO_USB_C1_PD_INT_ODL: + port = 1; + break; + default: + return; + } + + schedule_deferred_pd_interrupt(port); +} + +/* + * Port-0/1 USB mux driver. + * + * The USB mux is handled by TCPC chip and the HPD update is through a GPIO + * to AP. But the TCPC chip is also needed to know the HPD status; otherwise, + * the mux misbehaves. + */ +const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .mux = + &(const struct usb_mux){ + .usb_port = 0, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, + }, + }, + { + .mux = + &(const struct usb_mux){ + .usb_port = 1, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, + }, + } +}; + +__override int board_get_default_battery_type(void) +{ + /* + * A 2S battery is set as default. If the board is configured to use + * a 3S battery, according to its SKU_ID, return a 3S battery as + * default. It helps to configure the charger to output a correct + * voltage in case the battery is not attached. + */ + if (board_get_battery_cell_type() == BATTERY_CELL_TYPE_3S) + return BATTERY_LGC_AP18C8K; + + return DEFAULT_BATTERY_TYPE; +} + +/* Initialize board USC-C things */ +static void board_init_usbc(void) +{ + /* Enable USB-A overcurrent interrupt */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc)); + /* + * The H1 SBU line for CCD are behind PPC chip. The PPC internal FETs + * for SBU may be disconnected after DP alt mode is off. Should enable + * the CCD_MODE_ODL interrupt to make sure the SBU FETs are connected. + */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode)); +} +DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT); + +void board_tcpc_init(void) +{ + /* Only reset TCPC if not sysjump */ + if (!system_jumped_late()) { + /* TODO(crosbug.com/p/61098): How long do we need to wait? */ + board_reset_pd_mcu(); + } + + /* Enable PPC interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl)); + + /* Enable TCPC interrupts */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); + + /* + * Initialize HPD to low; after sysjump SOC needs to see + * HPD pulse to enable video path + */ + for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) + usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | + USB_PD_MUX_HPD_IRQ_DEASSERTED); +} +DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C); + +void board_reset_pd_mcu(void) +{ + cprints(CC_USB, "Resetting TCPCs..."); + cflush(); + + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0); + msleep(PS8XXX_RESET_DELAY_MS); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1); +} + +void board_set_tcpc_power_mode(int port, int mode) +{ + /* Ignore the "mode" to turn the chip on. We can only do a reset. */ + if (mode) + return; + + board_reset_pd_mcu(); +} + +int board_vbus_sink_enable(int port, int enable) +{ + /* Both ports are controlled by PPC SN5S330 */ + return ppc_vbus_sink_enable(port, enable); +} + +int board_is_sourcing_vbus(int port) +{ + /* Both ports are controlled by PPC SN5S330 */ + return ppc_is_sourcing_vbus(port); +} + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* TODO(b/120231371): Notify AP */ + CPRINTS("p%d: overcurrent!", port); +} + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + if (port == CHARGE_PORT_NONE) { + CPRINTS("Disabling all charging port"); + + /* Disable all ports. */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (board_vbus_sink_enable(i, 0)) + CPRINTS("Disabling p%d sink path failed.", i); + } + + return EC_SUCCESS; + } + + /* Check if the port is sourcing VBUS. */ + if (board_is_sourcing_vbus(port)) { + CPRINTS("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + + CPRINTS("New charge port: p%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i == port) + continue; + + if (board_vbus_sink_enable(i, 0)) + CPRINTS("p%d: sink path disable failed.", i); + } + + /* Enable requested charge port. */ + if (board_vbus_sink_enable(port, 1)) { + CPRINTS("p%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} + +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) +{ + /* + * Ignore lower charge ceiling on PD transition if our battery is + * critical, as we may brownout. + */ + if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 && + charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) { + CPRINTS("Using max ilim %d", max_ma); + charge_ma = max_ma; + } + + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) + if (gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l))) + status |= PD_STATUS_TCPC_ALERT_0; + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) + if (gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l))) + status |= PD_STATUS_TCPC_ALERT_1; + + return status; +} diff --git a/zephyr/program/trogdor/lazor/usbc.dts b/zephyr/program/trogdor/lazor/usbc.dts new file mode 100644 index 0000000000..7864c2716b --- /dev/null +++ b/zephyr/program/trogdor/lazor/usbc.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + /* TODO(b/227359762): lazor: move UBC-C configuration into the + * devicetree + */ + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + + bc12 = <&bc12_port0>; + tcpc = <&tcpc_port0>; + + ppc = <&ppc_port0>; + + chg = <&charger>; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + + bc12 = <&bc12_port1>; + tcpc = <&tcpc_port1>; + + ppc = <&ppc_port1>; + }; + }; +}; diff --git a/zephyr/projects/.pylintrc b/zephyr/projects/.pylintrc deleted file mode 100644 index 8bdb6378e4..0000000000 --- a/zephyr/projects/.pylintrc +++ /dev/null @@ -1,28 +0,0 @@ -[BASIC] -additional-builtins= - here, - register_binman_project, - register_host_project, - register_host_test, - register_mchp_project, - register_npcx_project, - register_raw_project, -good-names=BUILD - -# cros lint doesn't inherit the pylintrc from the parent dir. -# These settings are copied from platform/ec/pylintrc -[MESSAGES CONTROL] - -disable= - bad-continuation, - bad-whitespace, - # These have nothing to do with black, they are just annoying - fixme, - too-many-arguments, - too-many-statements, - too-many-branches, - too-many-locals - -[format] - -string-quote=double diff --git a/zephyr/projects/brya/BUILD.py b/zephyr/projects/brya/BUILD.py deleted file mode 100644 index 9991335ca7..0000000000 --- a/zephyr/projects/brya/BUILD.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for brya.""" - - -def register_npcx9_variant( - project_name, extra_dts_overlays=(), extra_kconfig_files=() -): - """Register a variant of a brya, even though this is not named as such.""" - return register_npcx_project( - project_name=project_name, - zephyr_board="npcx9m3f", - dts_overlays=[ - "adc.dts", - "battery.dts", - "fan.dts", - "gpio.dts", - "i2c.dts", - "interrupts.dts", - "keyboard.dts", - "motionsense.dts", - "pwm_leds.dts", - "temp_sensors.dts", - "usbc.dts", - # Project-specific DTS customization. - *extra_dts_overlays, - ], - kconfig_files=[ - # Common to all projects. - here / "prj.conf", - # Project-specific KConfig customization. - *extra_kconfig_files, - ], - ) - - -brya = register_npcx9_variant( - project_name="brya", - extra_dts_overlays=[here / "brya.dts"], - extra_kconfig_files=[here / "prj_brya.conf"], -) diff --git a/zephyr/projects/brya/CMakeLists.txt b/zephyr/projects/brya/CMakeLists.txt deleted file mode 100644 index 11c1a8386f..0000000000 --- a/zephyr/projects/brya/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(brya) - -set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/brya" CACHE PATH - "Path to the platform/ec board directory") -set(PLATFORM_EC_BASEBOARD "${PLATFORM_EC}/baseboard/brya" CACHE PATH - "Path to the platform/ec baseboard directory") - -# Include board specific header files -zephyr_include_directories( - include - "${PLATFORM_EC}/driver/tcpm" - "${PLATFORM_EC_BASEBOARD}" - "${PLATFORM_EC_BOARD}") - -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY - "${PLATFORM_EC_BASEBOARD}/battery_presence.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM - "${PLATFORM_EC_BASEBOARD}/cbi.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_KBLIGHT - "kblight_hooks.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY - "${PLATFORM_EC_BASEBOARD}/battery_presence.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY - "battery_present.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_POWER_DELIVERY - "${PLATFORM_EC_BASEBOARD}/usb_pd_policy.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "${PLATFORM_EC_BOARD}/usbc_config.c" - "${PLATFORM_EC_BOARD}/fw_config.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_MANAGER - "${PLATFORM_EC_BOARD}/charger.c" - "${PLATFORM_EC}/common/math_util.c") diff --git a/zephyr/projects/brya/Kconfig b/zephyr/projects/brya/Kconfig deleted file mode 100644 index 4dd8e23443..0000000000 --- a/zephyr/projects/brya/Kconfig +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -config BOARD_BRYA - bool "Google Brya Baseboard" - help - Build Google Brya reference board. The board uses the Nuvuton NPCX9 - chip as the EC. - -source "Kconfig.zephyr" diff --git a/zephyr/projects/brya/adc.dts b/zephyr/projects/brya/adc.dts deleted file mode 100644 index f3f0d1e064..0000000000 --- a/zephyr/projects/brya/adc.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ddr_soc: ddr_soc { - enum-name = "ADC_TEMP_SENSOR_1_DDR_SOC"; - io-channels = <&adc0 0>; - }; - adc_ambient: ambient { - enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; - io-channels = <&adc0 1>; - }; - adc_charger: charger { - enum-name = "ADC_TEMP_SENSOR_3_CHARGER"; - io-channels = <&adc0 6>; - }; - adc_wwan: wwan { - enum-name = "ADC_TEMP_SENSOR_4_WWAN"; - io-channels = <&adc0 7>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan0_gp45 - &adc0_chan1_gp44 - &adc0_chan6_gp34 - &adc0_chan7_gpe1>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/brya/battery.dts b/zephyr/projects/brya/battery.dts deleted file mode 100644 index 4844d88d92..0000000000 --- a/zephyr/projects/brya/battery.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: batgqa05l22 { - compatible = "powertech,batgqa05l22", "battery-smart"; - }; - lgc_ac17a8m { - compatible = "lgc,ac17a8m", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/brya/battery_present.c b/zephyr/projects/brya/battery_present.c deleted file mode 100644 index c487a01f36..0000000000 --- a/zephyr/projects/brya/battery_present.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include - -#include "battery.h" -#include "cbi.h" - -enum battery_present battery_hw_present(void) -{ - const struct gpio_dt_spec *batt_pres; - - if (get_board_id() == 1) - batt_pres = GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_batt_pres_odl); - else - batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl); - - /* The GPIO is low when the battery is physically present */ - return gpio_pin_get_dt(batt_pres) ? BP_NO : BP_YES; -} diff --git a/zephyr/projects/brya/brya.dts b/zephyr/projects/brya/brya.dts deleted file mode 100644 index 4b0490afa9..0000000000 --- a/zephyr/projects/brya/brya.dts +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - model = "Google Brya Baseboard"; - - chosen { - cros,rtc = &mtc; - }; - - ec-console { - compatible = "ec-console"; - disabled = "events", "lpc", "hostcmd"; - }; -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/brya/fan.dts b/zephyr/projects/brya/fan.dts deleted file mode 100644 index aa6dcfde7d..0000000000 --- a/zephyr/projects/brya/fan.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm5 0 PWM_KHZ(1) PWM_POLARITY_NORMAL>; - rpm_min = <2200>; - rpm_start = <2200>; - rpm_max = <4200>; - tach = <&tach1>; - enable_gpio = <&gpio_en_pp5000_fan>; - }; - }; -}; - -/* Tachemeter for fan speed measurement */ -&tach1 { - status = "okay"; - pinctrl-0 = <&ta1_1_in_gp40>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm5_gpb7 { - drive-open-drain; -}; - -&pwm5 { - status = "okay"; - pinctrl-0 = <&pwm5_gpb7>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/brya/gpio.dts b/zephyr/projects/brya/gpio.dts deleted file mode 100644 index 6c6a2ac054..0000000000 --- a/zephyr/projects/brya/gpio.dts +++ /dev/null @@ -1,341 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_wp_l: ec_wp_odl { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - charger_vap_otg_en { - gpios = <&gpio7 3 GPIO_OUTPUT_LOW>; - }; - gpio_ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpioa 3 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - /* - * Same GPIO as gpio_ec_batt_pres_odl, - * but only enabled for board id 1. - */ - gpio_id_1_ec_kb_bl_en: id_1_ec_kb_bl_en { - gpios = <&gpioa 3 GPIO_OUTPUT_LOW>; - no-auto-init; - }; - gpio_id_1_ec_batt_pres_odl: id_1_ec_batt_pres_odl { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - ec_i2c_bat_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_bat_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - gpio_ec_kb_bl_en_l: ec_kb_bl_en_l { - gpios = <&gpio8 6 GPIO_OUTPUT_HIGH>; - }; - ec_i2c_misc_scl_r { - gpios = <&gpiob 3 GPIO_INPUT>; - }; - ec_i2c_misc_sda_r { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - ec_i2c_sensor_scl { - gpios = <&gpiob 5 GPIO_INPUT>; - }; - ec_i2c_sensor_sda { - gpios = <&gpiob 4 GPIO_INPUT>; - }; - ec_i2c_usb_c0_c2_ppc_bc_scl { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - ec_i2c_usb_c0_c2_ppc_bc_sda { - gpios = <&gpio9 1 GPIO_INPUT>; - }; - ec_i2c_usb_c0_c2_rt_scl { - gpios = <&gpiod 1 GPIO_INPUT>; - }; - ec_i2c_usb_c0_c2_rt_sda { - gpios = <&gpiod 0 GPIO_INPUT>; - }; - ec_i2c_usb_c0_c2_tcpc_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_c0_c2_tcpc_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_usb_c1_mix_scl { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - ec_i2c_usb_c1_mix_sda { - gpios = <&gpioe 3 GPIO_INPUT>; - }; - ec_i2c_usb_c1_tcpc_scl { - gpios = <&gpiof 3 GPIO_INPUT>; - }; - ec_i2c_usb_c1_tcpc_sda { - gpios = <&gpiof 2 GPIO_INPUT>; - }; - ec_chg_led_y_c1 { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - ec_chg_led_b_c1 { - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - ec_gsc_packet_mode { - gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_accel_int_l: ec_accel_int_l { - gpios = <&gpio8 1 GPIO_INPUT>; - }; - gpio_ec_imu_int_l: gpio_ec_imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - gpio_ec_als_rgb_int_l: gpio_ec_als_rgb_int_l { - gpios = <&gpiod 4 GPIO_INPUT>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpio9 5 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - gpio_ec_pch_wake_odl: ec_pch_wake_r_odl { - gpios = <&gpioc 0 GPIO_ODR_HIGH>; - }; - ec_pch_int_odl { - gpios = <&gpiob 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_pg_ec_dsw_pwrok: pg_ec_dsw_pwrok { - gpios = <&gpioc 7 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_DSW_PWROK"; - alias = "GPIO_SEQ_EC_DSW_PWROK"; - }; - en_s5_rails { - gpios = <&gpiob 6 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_S5_RAILS"; - alias = "GPIO_TEMP_SENSOR_POWER"; - }; - sys_rst_odl { - gpios = <&gpioc 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_SYS_RESET_L"; - }; - gpio_pg_ec_rsmrst_odl: pg_ec_rsmrst_odl { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_RSMRST_ODL"; - }; - ec_pch_rsmrst_odl { - gpios = <&gpioa 6 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_RSMRST_L"; - }; - gpio_pg_ec_all_sys_pwrgd: pg_ec_all_sys_pwrgd { - gpios = <&gpiof 4 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD"; - }; - gpio_slp_s0_l: slp_s0_l { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S0_L"; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S3_L"; - }; - vccst_pwrgd_od { - gpios = <&gpioa 4 GPIO_ODR_LOW>; - enum-name = "GPIO_VCCST_PWRGD_OD"; - }; - ec_prochot_odl { - gpios = <&gpio6 3 GPIO_ODR_HIGH>; - enum-name = "GPIO_CPU_PROCHOT"; - }; - ec_pch_pwr_btn_odl { - gpios = <&gpioc 1 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_slp_sus_l: slp_sus_l { - gpios = <&gpiof 1 GPIO_INPUT>; - enum-name = "GPIO_SLP_SUS_L"; - }; - pch_pwrok { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_PWROK"; - }; - ec_pch_sys_pwrok { - gpios = <&gpio3 7 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EC_PCH_SYS_PWROK"; - }; - imvp9_vrrdy_od { - gpios = <&gpio4 3 GPIO_INPUT>; - enum-name = "GPIO_IMVP9_VRRDY_OD"; - }; - ec_edp_bl_en { - gpios = <&gpiod 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_prochot_in_l: ec_prochot_in_l { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_en_pp5000_fan: en_pp5000_fan { - gpios = <&gpio6 1 GPIO_OUTPUT_HIGH>; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpio9 7 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_usb_c0_c2_tcpc_int_odl: usb_c0_c2_tcpc_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_C2_TCPC_INT_ODL"; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioa 2 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio6 2 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PPC_INT_ODL"; - }; - gpio_usb_c2_ppc_int_odl: usb_c2_ppc_int_odl { - gpios = <&gpio7 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C2_PPC_INT_ODL"; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { - gpios = <&gpio5 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_BC12_INT_ODL"; - }; - gpio_usb_c2_bc12_int_odl: usb_c2_bc12_int_odl { - gpios = <&gpio8 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C2_BC12_INT_ODL"; - }; - gpio_en_pp5000_usba_r: en_pp5000_usba_r { - gpios = <&gpiod 7 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP5000_USBA_R"; - }; - usb_c1_rt_rst_r_odl { - gpios = <&gpio0 2 GPIO_ODR_LOW>; - enum-name = "GPIO_USB_C1_RT_RST_R_ODL"; - }; - usb_c1_rst_odl { - gpios = <&gpio9 6 GPIO_ODR_LOW>; - enum-name = "GPIO_USB_C1_RST_ODL"; - }; - usb_c0_c2_tcpc_rst_odl { - gpios = <&gpioa 7 GPIO_ODR_HIGH>; - enum-name = "GPIO_USB_C0_C2_TCPC_RST_ODL"; - }; - id_1_usb_c0_c2_tcpc_rst_odl { - gpios = <&gpio3 4 GPIO_ODR_LOW>; - }; - usb_c0_int_odl { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - usb_c2_int_odl { - gpios = <&gpio4 1 GPIO_INPUT>; - }; - usb_c0_rt_int_odl: usb_c0_rt_int_odl { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - usb_c2_rt_int_odl: usb_c2_rt_int_odl { - gpios = <&gpio4 1 GPIO_INPUT>; - }; - usb_c0_oc_odl { - gpios = <&ioex_port1 4 GPIO_ODR_HIGH>; - no-auto-init; - }; - usb_c0_frs_en: usb_c0_frs_en { - gpios = <&ioex_port1 6 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_FRS_EN"; - no-auto-init; - }; - usb_c0_rt_rst_odl: usb_c0_rt_rst_odl { - gpios = <&ioex_port1 7 GPIO_ODR_LOW>; - no-auto-init; - }; - usb_c2_rt_rst_odl: usb_c2_rt_rst_odl { - gpios = <&ioex_port2 2 GPIO_ODR_LOW>; - no-auto-init; - }; - usb_c1_oc_odl { - gpios = <&ioex_port2 3 GPIO_ODR_HIGH>; - no-auto-init; - }; - usb_c2_oc_odl { - gpios = <&ioex_port2 4 GPIO_ODR_HIGH>; - no-auto-init; - }; - usb_c2_frs_en: usb_c2_frs_en { - gpios = <&ioex_port2 6 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C2_FRS_EN"; - no-auto-init; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_pp5000_usba_r>; - }; -}; - -/* Power switch logic input pads */ -/* LID_OPEN_OD */ -&psl_in1_gpd2 { - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -/* ACOK_EC_OD */ -&psl_in2_gp00 { - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -/* GSC_EC_PWR_BTN_ODL */ -&psl_in3_gp01 { - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01>; -}; diff --git a/zephyr/projects/brya/i2c.dts b/zephyr/projects/brya/i2c.dts deleted file mode 100644 index 7284d80870..0000000000 --- a/zephyr/projects/brya/i2c.dts +++ /dev/null @@ -1,285 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #include - -/ { - named-i2c-ports { - compatible = "named-i2c-ports"; - i2c_sensor: sensor { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_SENSOR"; - }; - tcpc0_2: tcpc0_2 { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_USB_C0_C2_TCPC"; - }; - tcpc1: tcpc1 { - i2c-port = <&i2c4_1>; - enum-names = "I2C_PORT_USB_C1_TCPC"; - dynamic-speed; - }; - c0_c2_bc12: c0_c2_bc12 { - i2c-port = <&i2c2_0>; - enum-names = "I2C_PORT_USB_C0_C2_PPC", - "I2C_PORT_USB_C0_C2_BC12"; - }; - c1_bc12: c1_bc12 { - i2c-port = <&i2c6_1>; - enum-names = "I2C_PORT_USB_C1_PPC", - "I2C_PORT_USB_C1_BC12"; - dynamic-speed; - }; - retimer0_2: retimer0_2 { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_C0_C2_MUX"; - }; - battery { - i2c-port = <&i2c5_0>; - enum-names = "I2C_PORT_BATTERY"; - }; - i2c_charger: charger { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_CHARGER", - "I2C_PORT_EEPROM", - "I2C_PORT_MP2964"; - }; - }; -}; - -&i2c0_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - tcpc_port0: nct38xx@70 { - compatible = "nuvoton,nct38xx"; - reg = <0x70>; - gpio-dev = <&nct3808_0_P1>; - tcpc-flags = <( - TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>; - }; - - nct3808_0_P1: nct3808_0_P1@70 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x70>; - label = "NCT3808_0_P1"; - - ioex_port1: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3808_0_P1_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xdc>; - pinmux_mask = <0xff>; - }; - }; - - tcpc_port2: nct38xx@74 { - compatible = "nuvoton,nct38xx"; - reg = <0x74>; - gpio-dev = <&nct3808_0_P2>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct3808_0_P2: nct3808_0_P2@74 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x74>; - label = "NCT3808_0_P2"; - - ioex_port2: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3808_0_P2_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xdc>; - pinmux_mask = <0xff>; - }; - }; - - nct3808_alert_1 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpioe 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; - nct38xx-dev = <&nct3808_0_P1 &nct3808_0_P2>; - label = "NCT3808_ALERT_1"; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; - - ppc_port0: syv682x@40 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x40>; - frs_en_gpio = <&usb_c0_frs_en>; - }; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - ppc_port2: syv682x@42 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x42>; - frs_en_gpio = <&usb_c2_frs_en>; - }; - - bc12_port2: pi3usb9201@5d { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5d>; - irq = <&int_usb_c2_bc12>; - }; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; - - usb_c0_bb_retimer: jhl8040r-c0@56 { - compatible = "intel,jhl8040r"; - reg = <0x56>; - int-pin = <&usb_c0_rt_int_odl>; - reset-pin = <&usb_c0_rt_rst_odl>; - }; - - usb_c2_bb_retimer: jhl8040r-c2@57 { - compatible = "intel,jhl8040r"; - reg = <0x57>; - int-pin = <&usb_c2_rt_int_odl>; - reset-pin = <&usb_c2_rt_rst_odl>; - }; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c4_1 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; - pinctrl-names = "default"; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - tcpc-flags = <( - TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V | - TCPC_FLAGS_CONTROL_VCONN | - TCPC_FLAGS_CONTROL_FRS)>; - }; -}; - -&i2c_ctrl4 { - status = "okay"; -}; - -&i2c5_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c6_1 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; - pinctrl-names = "default"; - - ppc_port1: nx20p348x@72 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x72>; - }; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c1_bc12>; - }; -}; - -&i2c_ctrl6 { - status = "okay"; -}; - -&i2c7_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; - - pmic_mp2964: pmic_mp2964@20 { - compatible = "mps,mp2964"; - reg = <0x20>; - label = "I2C_ADDR_MP2964_FLAGS"; - }; - - charger: bq25710@9 { - compatible = "ti,bq25710"; - status = "okay"; - reg = <0x9>; - }; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/brya/interrupts.dts b/zephyr/projects/brya/interrupts.dts deleted file mode 100644 index 1adca3e035..0000000000 --- a/zephyr/projects/brya/interrupts.dts +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_lid_open: lid_open { - irq-pin = <&lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_wp: wp { - irq-pin = <&gpio_ec_wp_l>; - flags = ; - handler = "switch_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_ec_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_ec_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_accel: accel { - irq-pin = <&gpio_ec_accel_int_l>; - flags = ; - handler = "lis2dw12_interrupt"; - }; - int_imu: imu { - irq-pin = <&gpio_ec_imu_int_l>; - flags = ; - handler = "lsm6dso_interrupt"; - }; - int_slp_s0: slp_s0 { - irq-pin = <&gpio_slp_s0_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_slp_s3: slp_s3 { - irq-pin = <&gpio_slp_s3_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_slp_sus: slp_sus { - irq-pin = <&gpio_slp_sus_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_pg_dsw_pwrok: pg_dsw_pwrok { - irq-pin = <&gpio_pg_ec_dsw_pwrok>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_pg_rsmrst_odl: pg_rsmrst_odl { - irq-pin = <&gpio_pg_ec_rsmrst_odl>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_pg_all_sys_pwrgd: pg_all_sys_pwrgd { - irq-pin = <&gpio_pg_ec_all_sys_pwrgd>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_als_rgb: als_rgb { - irq-pin = <&gpio_ec_als_rgb_int_l>; - flags = ; - handler = "tcs3400_interrupt"; - }; - int_prochot: prochot { - irq-pin = <&gpio_ec_prochot_in_l>; - flags = ; - handler = "throttle_ap_prochot_input_interrupt"; - }; - int_usb_c0_c2_tcpc: usb_c0_c2_tcpc { - irq-pin = <&gpio_usb_c0_c2_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_tcpc: usb_c1_tcpc { - irq-pin = <&gpio_usb_c1_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&gpio_usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_ppc: usb_c1_ppc { - irq-pin = <&gpio_usb_c1_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c2_ppc: usb_c2_ppc { - irq-pin = <&gpio_usb_c2_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c1_bc12: usb_c1_bc12 { - irq-pin = <&gpio_usb_c1_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c2_bc12: usb_c2_bc12 { - irq-pin = <&gpio_usb_c2_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c0_rt: usb_c0_rt { - irq-pin = <&usb_c0_rt_int_odl>; - flags = ; - handler = "retimer_interrupt"; - }; - int_usb_c2_rt: usb_c2_rt { - irq-pin = <&usb_c2_rt_int_odl>; - flags = ; - handler = "retimer_interrupt"; - }; - }; -}; diff --git a/zephyr/projects/brya/kblight_hooks.c b/zephyr/projects/brya/kblight_hooks.c deleted file mode 100644 index d6d795f28e..0000000000 --- a/zephyr/projects/brya/kblight_hooks.c +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include -#include "cbi.h" -#include "hooks.h" - -/* Enable/Disable keyboard backlight gpio */ -static inline void kbd_backlight_enable(bool enable) -{ - if (get_board_id() == 1) - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_kb_bl_en), - enable); - else - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_kb_bl_en_l), - !enable); -} - -static void board_backlight_handler(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - bool enable; - - switch (data.event) { - default: - return; - - case AP_POWER_RESUME: - /* Called on AP S3 -> S0 transition */ - enable = true; - break; - - case AP_POWER_SUSPEND: - /* Called on AP S0 -> S3 transition */ - enable = false; - break; - } - kbd_backlight_enable(enable); -} - -/* - * Explicitly apply the board ID 1 *gpio.inc settings to pins that - * were reassigned on current boards. - */ -static void set_board_id_1_gpios(void) -{ - static struct ap_power_ev_callback cb; - - /* - * Add a callback for suspend/resume to - * control the keyboard backlight. - */ - ap_power_ev_init_callback(&cb, board_backlight_handler, - AP_POWER_RESUME | AP_POWER_SUSPEND); - ap_power_ev_add_callback(&cb); - - if (get_board_id() != 1) - return; - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_kb_bl_en), - GPIO_OUTPUT_LOW); -} -DECLARE_HOOK(HOOK_INIT, set_board_id_1_gpios, HOOK_PRIO_FIRST); diff --git a/zephyr/projects/brya/keyboard.dts b/zephyr/projects/brya/keyboard.dts deleted file mode 100644 index 91fad2db92..0000000000 --- a/zephyr/projects/brya/keyboard.dts +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm3 0 PWM_HZ(2400) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm3 { - status = "okay"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/brya/motionsense.dts b/zephyr/projects/brya/motionsense.dts deleted file mode 100644 index 08994e30cc..0000000000 --- a/zephyr/projects/brya/motionsense.dts +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2022 The ChromiumOS Authors - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - lsm6dso-int = &base_accel; - lis2dw12-int = &lid_accel; - tcs3400-int = &als_clear; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - mutex_lis2dw12: lis2dw12-mutex { - }; - - mutex_lsm6dso: lsm6dso-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - - lsm6dso_accel_data: lsm6dso-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - lsm6dso_gyro_data: lsm6dso-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - tcs_clear_data: tcs3400-clear-drv-data { - compatible = "cros-ec,drvdata-tcs3400-clear"; - status = "okay"; - - als-drv-data { - compatible = "cros-ec,accelgyro-als-drv-data"; - als-cal { - scale = <1>; - uscale = <0>; - offset = <0>; - als-channel-scale { - compatible = - "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - - tcs_rgb_data: tcs3400-rgb-drv-data { - compatible = "cros-ec,drvdata-tcs3400-rgb"; - status = "okay"; - - /* node for rgb_calibration_t defined in accelgyro.h */ - rgb_calibration { - compatible = - "cros-ec,accelgyro-rgb-calibration"; - - irt = <1>; - - rgb-cal-x { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = - "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-y { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = - "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-z { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = - "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&mutex_lis2dw12>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,lsm6dso-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_lsm6dso>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <4>; - drv-data = <&lsm6dso_accel_data>; - i2c-spi-addr-flags = "LSM6DSO_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(13000 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,lsm6dso-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_lsm6dso>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ - drv-data = <&lsm6dso_gyro_data>; - i2c-spi-addr-flags = "LSM6DSO_ADDR0_FLAGS"; - }; - - als_clear: base-als-clear { - compatible = "cros-ec,tcs3400-clear"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - port = <&i2c_sensor>; - default-range = <0x10000>; - drv-data = <&tcs_clear_data>; - i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - /* Run ALS sensor in S0 */ - odr = <1000>; - }; - }; - }; - - base-als-rgb { - compatible = "cros-ec,tcs3400-rgb"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - default-range = <0x10000>; /* scale = 1x, uscale = 0 */ - drv-data = <&tcs_rgb_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* list of entries for motion_als_sensors */ - als-sensors = <&als_clear>; - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_imu &int_als_rgb &int_accel>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel &als_clear>; - }; -}; diff --git a/zephyr/projects/brya/prj.conf b/zephyr/projects/brya/prj.conf deleted file mode 100644 index 422f862809..0000000000 --- a/zephyr/projects/brya/prj.conf +++ /dev/null @@ -1,200 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_LTO=y -CONFIG_CROS_FLASH_NPCX=y -CONFIG_CROS_SYSTEM_NPCX=y -CONFIG_PLATFORM_EC_VBOOT_EFS2=y -CONFIG_PLATFORM_EC_VBOOT_HASH=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y - -CONFIG_PLATFORM_EC_ADC_CHANNELS_RUNTIME_CONFIG=y - -CONFIG_KERNEL_SHELL=y - -# SoC configuration -CONFIG_AP=y -CONFIG_AP_X86_INTEL_ADL=y -CONFIG_FPU=y -CONFIG_ARM_MPU=y - -# CBI -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y - -# eSPI -CONFIG_ESPI=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150 - -# I2C -CONFIG_I2C=y - -# Power Sequencing -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=y -CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y -CONFIG_PLATFORM_EC_POWERSEQ_S4=y -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -CONFIG_PLATFORM_EC_THROTTLE_AP=y - -# Host command -CONFIG_PLATFORM_EC_HOSTCMD=y -CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=y - -# Console command -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y - -# Sensors -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_ALS=y -CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y -CONFIG_PLATFORM_EC_ALS_TCS3400=y - -# Fan -CONFIG_TACH_NPCX=y - -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y - -# MKBP event -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y - -# PMIC -CONFIG_PLATFORM_EC_PMIC=y -CONFIG_PLATFORM_EC_MP2964=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_CMD_BUTTON=n -CONFIG_CROS_KB_RAW_NPCX=y - -CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y - -# USB-C and charging -CONFIG_PLATFORM_EC_CHARGER_BQ25720=y -CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y -CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70 -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=3 -CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC=1 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 -CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USB_PID=0x504F -CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y -CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y -CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_MUX_TASK=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2 -CONFIG_PLATFORM_EC_USB_PD_ALT_MODE_UFP=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_PPC=y -CONFIG_PLATFORM_EC_USB_PD_REV30=y -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y -CONFIG_PLATFORM_EC_USB_PD_USB4=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1715=n -CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=n -CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y -CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT=y -CONFIG_PLATFORM_EC_USBA=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP=n -CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n -CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y -CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y -CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y -CONFIG_PLATFORM_EC_USB_PD_PORT_2_SHARED=y - -CONFIG_SYSCON=y - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_PWM=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n -CONFIG_PLATFORM_EC_LED_PWM_NEAR_FULL_COLOR=4 -CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR=4 -CONFIG_PLATFORM_EC_LED_PWM_SOC_SUSPEND_COLOR=4 -CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR=5 - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -#IOEX -CONFIG_GPIO_NCT38XX=y - -# TODO(b/188605676): bring these features up -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n - -# Power Sequencing -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n -CONFIG_CHIPSET_ALDERLAKE_SLG4BD44540=y -CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=n -CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -# Treat 2nd reset from H1 as Power-On -CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y -CONFIG_PLATFORM_EC_THROTTLE_AP=y - -# RTC -CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/projects/brya/prj_brya.conf b/zephyr/projects/brya/prj_brya.conf deleted file mode 100644 index 5aaf86a8c9..0000000000 --- a/zephyr/projects/brya/prj_brya.conf +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# BRYA-NPCX9 reference-board-specific Kconfig settings. -CONFIG_BOARD_BRYA=y diff --git a/zephyr/projects/brya/pwm_leds.dts b/zephyr/projects/brya/pwm_leds.dts deleted file mode 100644 index 4321b4bd34..0000000000 --- a/zephyr/projects/brya/pwm_leds.dts +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm2 0 PWM_HZ(4800) PWM_POLARITY_INVERTED - &pwm0 0 PWM_HZ(4800) PWM_POLARITY_INVERTED>; - }; - pwm_led1: pwm_led_1 { - pwms = <&pwm1 0 PWM_HZ(4800) PWM_POLARITY_INVERTED - &pwm7 0 PWM_HZ(4800) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0 &pwm_led1>; - - /**/ - color-map-red = <0 0>; - color-map-green = <0 0>; - color-map-blue = <0 0>; - color-map-yellow = <0 0>; - color-map-white = <0 50>; - color-map-amber = <50 0>; - - brightness-range = <0 0 0 0 100 100>; - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_LEFT_LED"; - }; - - pwm_led_1@1 { - reg = <1>; - ec-led-name = "EC_LED_ID_RIGHT_LED"; - }; - }; -}; - -/* LED2 */ -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -/* LED3 */ -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -/* LED1 */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* LED4 */ -&pwm7 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm7_gp60>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/brya/temp_sensors.dts b/zephyr/projects/brya/temp_sensors.dts deleted file mode 100644 index ae436a2c6b..0000000000 --- a/zephyr/projects/brya/temp_sensors.dts +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - temp_ddr_soc: ddr_soc { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_ddr_soc>; - }; - - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_ambient>; - }; - - temp_charger: charger { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_charger>; - }; - - temp_wwan: wwan { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_wwan>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - ddr_soc { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - sensor = <&temp_ddr_soc>; - }; - - ambient { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - sensor = <&temp_ambient>; - }; - - charger { - temp_fan_off = <35>; - temp_fan_max = <65>; - temp_host_high = <105>; - temp_host_halt = <120>; - temp_host_release_high = <90>; - sensor = <&temp_charger>; - }; - - wwan { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <130>; - temp_host_halt = <130>; - temp_host_release_high = <100>; - sensor = <&temp_wwan>; - }; - }; -}; - -&thermistor_3V3_30K9_47K_4050B { - status = "okay"; -}; diff --git a/zephyr/projects/brya/usbc.dts b/zephyr/projects/brya/usbc.dts deleted file mode 100644 index 1be9ac94ac..0000000000 --- a/zephyr/projects/brya/usbc.dts +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c0_bb_retimer - &virtual_mux_c0>; - }; - ppc = <&ppc_port0>; - }; - port0-muxes { - virtual_mux_c0: virtual-mux-c0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_c1 &tcpci_mux_c1>; - }; - ppc = <&ppc_port1>; - }; - port1-muxes { - tcpci_mux_c1: tcpci-mux-c1 { - compatible = "cros-ec,usbc-mux-tcpci"; - hpd-update = "ps8xxx_tcpc_update_hpd_status"; - }; - virtual_mux_c1: virtual-mux-c1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port2@2 { - compatible = "named-usbc-port"; - reg = <2>; - bc12 = <&bc12_port2>; - tcpc = <&tcpc_port2>; - usb-mux-chain-2 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c2_bb_retimer - &virtual_mux_c2>; - }; - ppc = <&ppc_port2>; - }; - port2-muxes { - virtual_mux_c2: virtual-mux-c2 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; diff --git a/zephyr/projects/corsola/BUILD.py b/zephyr/projects/corsola/BUILD.py deleted file mode 100644 index 91bd8ab062..0000000000 --- a/zephyr/projects/corsola/BUILD.py +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for corsola.""" - -# Default chip is it81202bx, some variants will use NPCX9X. - - -def register_corsola_project( - project_name, - chip="it81202bx", - extra_dts_overlays=(), - extra_kconfig_files=(), -): - """Register a variant of corsola.""" - register_func = register_binman_project - if chip.startswith("npcx"): - register_func = register_npcx_project - - register_func( - project_name=project_name, - zephyr_board=chip, - dts_overlays=[ - here / "common.dts", - here / "power_signal.dts", - here / "usba.dts", - *extra_dts_overlays, - ], - kconfig_files=[here / "prj.conf", *extra_kconfig_files], - ) - - -register_corsola_project( - "krabby", - extra_dts_overlays=[ - here / "adc_krabby.dts", - here / "battery_krabby.dts", - here / "gpio_krabby.dts", - here / "keyboard_krabby.dts", - here / "i2c_krabby.dts", - here / "interrupts_krabby.dts", - here / "led_krabby.dts", - here / "motionsense_krabby.dts", - here / "usbc_krabby.dts", - ], - extra_kconfig_files=[ - here / "prj_it81202_base.conf", - here / "prj_krabby.conf", - ], -) - -register_corsola_project( - project_name="kingler", - chip="npcx9m3f", - extra_dts_overlays=[ - here / "adc_kingler.dts", - here / "battery_kingler.dts", - here / "host_interface_npcx.dts", - here / "i2c_kingler.dts", - here / "interrupts_kingler.dts", - here / "gpio_kingler.dts", - here / "npcx_keyboard.dts", - here / "led_kingler.dts", - here / "motionsense_kingler.dts", - here / "usbc_kingler.dts", - here / "default_gpio_pinctrl_kingler.dts", - ], - extra_kconfig_files=[ - here / "prj_npcx993_base.conf", - here / "prj_kingler.conf", - ], -) - -register_corsola_project( - project_name="steelix", - chip="npcx9m3f", - extra_dts_overlays=[ - here / "adc_kingler.dts", - here / "battery_steelix.dts", - here / "host_interface_npcx.dts", - here / "i2c_kingler.dts", - here / "interrupts_kingler.dts", - here / "interrupts_steelix.dts", - here / "cbi_steelix.dts", - here / "gpio_steelix.dts", - here / "npcx_keyboard.dts", - here / "keyboard_steelix.dts", - here / "led_steelix.dts", - here / "motionsense_kingler.dts", - here / "motionsense_steelix.dts", - here / "usba_steelix.dts", - here / "usbc_kingler.dts", - here / "default_gpio_pinctrl_kingler.dts", - ], - extra_kconfig_files=[ - here / "prj_npcx993_base.conf", - here / "prj_steelix.conf", - ], -) - - -register_corsola_project( - "tentacruel", - extra_dts_overlays=[ - here / "adc_tentacruel.dts", - here / "battery_tentacruel.dts", - here / "cbi_tentacruel.dts", - here / "gpio_tentacruel.dts", - here / "keyboard_krabby.dts", - here / "i2c_tentacruel.dts", - here / "interrupts_tentacruel.dts", - here / "led_tentacruel.dts", - here / "motionsense_tentacruel.dts", - here / "usbc_tentacruel.dts", - here / "thermistor_tentacruel.dts", - ], - extra_kconfig_files=[ - here / "prj_it81202_base.conf", - here / "prj_tentacruel.conf", - ], -) - -register_corsola_project( - "magikarp", - extra_dts_overlays=[ - here / "adc_magikarp.dts", - here / "battery_magikarp.dts", - here / "cbi_magikarp.dts", - here / "gpio_magikarp.dts", - here / "keyboard_krabby.dts", - here / "i2c_magikarp.dts", - here / "interrupts_magikarp.dts", - here / "led_magikarp.dts", - here / "motionsense_magikarp.dts", - here / "usbc_magikarp.dts", - ], - extra_kconfig_files=[ - here / "prj_it81202_base.conf", - here / "prj_magikarp.conf", - ], -) diff --git a/zephyr/projects/corsola/CMakeLists.txt b/zephyr/projects/corsola/CMakeLists.txt deleted file mode 100644 index fa899a0e77..0000000000 --- a/zephyr/projects/corsola/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") - -cros_ec_library_include_directories(include) - -# Include selected EC source from the baseboard -zephyr_library_sources( - "src/board.c" - "src/board_chipset.c" - "src/hibernate.c" -) - -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usbc_config.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy.c") -zephyr_library_sources_ifdef(CONFIG_VARIANT_CORSOLA_DB_DETECTION - "src/variant_db_detection.c") - -if(DEFINED CONFIG_BOARD_KRABBY) - project(krabby) - zephyr_library_sources("src/krabby/hooks.c" - "src/krabby/charger_workaround.c" - "src/krabby/ppc_krabby.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/krabby/usb_pd_policy.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "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_LED_COMMON - "src/kingler/led.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/kingler/usb_pd_policy.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/kingler/usbc_config.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG - "src/kingler/button.c") -elseif(DEFINED CONFIG_BOARD_STEELIX) - project(steelix) - zephyr_library_sources("src/kingler/board_steelix.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON - "src/kingler/led_steelix.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/kingler/usb_pd_policy.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/kingler/usbc_config.c") - -elseif(DEFINED CONFIG_BOARD_TENTACRUEL) - project(tentacruel) - zephyr_library_sources("src/krabby/hooks.c" - "src/krabby/charger_workaround.c" - "src/krabby/sensor_tentacruel.c" - "src/krabby/temp_tentacruel.c" - "src/krabby/ppc_tentacruel.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/krabby/usb_pd_policy.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/krabby/usbc_config.c") - -elseif(DEFINED CONFIG_BOARD_MAGIKARP) - project(magikarp) - zephyr_library_sources("src/krabby/hooks.c" - "src/krabby/sensor_magikarp.c" - "src/krabby/ppc_magikarp.c" - "src/krabby/keyboard_magikarp.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/krabby/usb_pd_policy.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/krabby/usbc_config.c") - -endif() - diff --git a/zephyr/projects/corsola/Kconfig b/zephyr/projects/corsola/Kconfig deleted file mode 100644 index 4f66601c20..0000000000 --- a/zephyr/projects/corsola/Kconfig +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -config BOARD_KRABBY - bool "Google Krabby Board" - help - Build Google Krabby reference board. Krabby has MediaTek MT8186 SoC - with ITE it81202-bx EC. - -config BOARD_KINGLER - bool "Google Kingler Board" - help - Build Google Kingler reference board. Krabby has MediaTek MT8186 SoC - with NPCX993FA0BX EC. - -config BOARD_STEELIX - bool "Google Steelix Board" - help - Build Google Steelix variant board. Steelix is a variant of Kingler - and has MediaTek MT8186 SoC with NPCX993FA0BX EC. - -config BOARD_TENTACRUEL - bool "Google Tentacruel Board" - help - Build Google Tentacruel variant board. Tentacruel is a variant of Krabby - and has MediaTek MT8186 SoC with ITE it81202-bx EC. - -config BOARD_MAGIKARP - bool "Google Magikarp Board" - help - Build Google Magikarp variant board. Magikarp is a variant of Krabby - and has MediaTek MT8186 SoC with ITE it81202-bx EC. - -config VARIANT_CORSOLA_DB_DETECTION - bool "Corsola Platform Runtime Daughter Board Detection" - depends on PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG - depends on PLATFORM_EC_USB_MUX_RUNTIME_CONFIG - help - Daughter board detection for Type-C subboard or HDMI subboard. This - includes pin configuration and driver loading. - default y - -config VARIANT_CORSOLA_USBA - bool "Corsola Platform USB-A support" - help - Support Corsola USB-A related functions. Enable this function if - it has USB-A ports. - depends on PLATFORM_EC_USBC - default y - -source "Kconfig.zephyr" diff --git a/zephyr/projects/corsola/adc_kingler.dts b/zephyr/projects/corsola/adc_kingler.dts deleted file mode 100644 index 7b69abe48a..0000000000 --- a/zephyr/projects/corsola/adc_kingler.dts +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * Kingler and Steelix use the same dts, take care of this when modify it. - */ - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_charger_pmon_r { - enum-name = "ADC_PSYS"; - io-channels = <&adc0 0>; - /* - * ISL9238C PSYS output is 1.44 uA/W over 33K resistor. - */ - mul = <21043>; - }; - adc_ec_id0 { - enum-name = "ADC_ID_0"; - io-channels = <&adc0 1>; - }; - adc_ec_id1 { - enum-name = "ADC_ID_1"; - io-channels = <&adc0 2>; - }; - adc_charger_amon_r { - enum-name = "ADC_AMON_BMON"; - io-channels = <&adc0 3>; - mul = <1000>; - div = <18>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan0_gp45 - &adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/corsola/adc_krabby.dts b/zephyr/projects/corsola/adc_krabby.dts deleted file mode 100644 index be65e9eea7..0000000000 --- a/zephyr/projects/corsola/adc_krabby.dts +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_vbus_c0 { - enum-name = "ADC_VBUS_C0"; - io-channels = <&adc0 0>; - mul = <10>; - }; - adc_board_id0 { - enum-name = "ADC_BOARD_ID_0"; - io-channels = <&adc0 1>; - }; - adc_board_id1 { - enum-name = "ADC_BOARD_ID_1"; - io-channels = <&adc0 2>; - }; - adc_vbus_c1 { - enum-name = "ADC_VBUS_C1"; - io-channels = <&adc0 7>; - mul = <10>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch1_gpi1_default - &adc0_ch2_gpi2_default - &adc0_ch7_gpi7_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/corsola/adc_magikarp.dts b/zephyr/projects/corsola/adc_magikarp.dts deleted file mode 100644 index 358af6f0f4..0000000000 --- a/zephyr/projects/corsola/adc_magikarp.dts +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - adc_vbus_c0 { - enum-name = "ADC_VBUS_C0"; - io-channels = <&adc0 0>; - mul = <10>; - }; - adc_board_id0 { - enum-name = "ADC_BOARD_ID_0"; - io-channels = <&adc0 1>; - }; - adc_board_id1 { - enum-name = "ADC_BOARD_ID_1"; - io-channels = <&adc0 2>; - }; - adc_vbus_c1 { - enum-name = "ADC_VBUS_C1"; - io-channels = <&adc0 7>; - mul = <10>; - }; - adc_ambient: ambient { - enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; - io-channels = <&adc0 5>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch1_gpi1_default - &adc0_ch2_gpi2_default - &adc0_ch5_gpi5_default - &adc0_ch7_gpi7_default>; - pinctrl-names = "default"; -}; - -/ { - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; - adc = <&adc_ambient>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - ambient { - sensor = <&temp_ambient>; - }; - }; -}; - -&thermistor_3V3_30K9_47K_NCP15WB { - status = "okay"; -}; diff --git a/zephyr/projects/corsola/adc_tentacruel.dts b/zephyr/projects/corsola/adc_tentacruel.dts deleted file mode 100644 index 7ab6f8817b..0000000000 --- a/zephyr/projects/corsola/adc_tentacruel.dts +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - adc_vbus_c0 { - enum-name = "ADC_VBUS_C0"; - io-channels = <&adc0 0>; - mul = <10>; - }; - adc_board_id0 { - enum-name = "ADC_BOARD_ID_0"; - io-channels = <&adc0 1>; - }; - adc_board_id1 { - enum-name = "ADC_BOARD_ID_1"; - io-channels = <&adc0 2>; - }; - adc_vbus_c1 { - enum-name = "ADC_VBUS_C1"; - io-channels = <&adc0 7>; - mul = <10>; - }; - adc_ambient: ambient { - enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; - io-channels = <&adc0 5>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch1_gpi1_default - &adc0_ch2_gpi2_default - &adc0_ch5_gpi5_default - &adc0_ch7_gpi7_default>; - pinctrl-names = "default"; -}; - -/ { - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; - adc = <&adc_ambient>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - ambient { - temp_host_high = <56>; - temp_host_halt = <80>; - temp_host_release_high = <42>; - sensor = <&temp_ambient>; - }; - temp_charger: charger { - temp_host_high = <68>; - temp_host_halt = <90>; - temp_host_release_high = <59>; - sensor = <&charger>; - }; - }; -}; - -&thermistor_3V3_30K9_47K_NCP15WB { - status = "okay"; -}; diff --git a/zephyr/projects/corsola/battery_kingler.dts b/zephyr/projects/corsola/battery_kingler.dts deleted file mode 100644 index b01fb8a46d..0000000000 --- a/zephyr/projects/corsola/battery_kingler.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: smp_l20m3pg2 { - compatible = "smp,l20m3pg2", "battery-smart"; - }; - lgc_l20l3pg2 { - compatible = "lgc,l20l3pg2", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/corsola/battery_krabby.dts b/zephyr/projects/corsola/battery_krabby.dts deleted file mode 100644 index ce41859182..0000000000 --- a/zephyr/projects/corsola/battery_krabby.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: c235 { - compatible = "celxpert,c235-41", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/corsola/battery_magikarp.dts b/zephyr/projects/corsola/battery_magikarp.dts deleted file mode 100644 index bbdd6ac0c5..0000000000 --- a/zephyr/projects/corsola/battery_magikarp.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: smp_c31n1915 { - compatible = "smp,c31n1915", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/corsola/battery_steelix.dts b/zephyr/projects/corsola/battery_steelix.dts deleted file mode 100644 index 594c83478c..0000000000 --- a/zephyr/projects/corsola/battery_steelix.dts +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: byd_l22b3pg0 { - compatible = "byd,l22b3pg0", "battery-smart"; - }; - celxpert_l22c3pg0 { - compatible = "celxpert,l22c3pg0", "battery-smart"; - }; - cosmx_l22x3pg0 { - compatible = "cosmx,l22x3pg0", "battery-smart"; - }; - smp_l22m3pg0 { - compatible = "smp,l22m3pg0", "battery-smart"; - }; - sunwoda_l22d3pg0 { - compatible = "sunwoda,l22d3pg0", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/corsola/battery_tentacruel.dts b/zephyr/projects/corsola/battery_tentacruel.dts deleted file mode 100644 index f116c20a51..0000000000 --- a/zephyr/projects/corsola/battery_tentacruel.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: dynapack_c140254 { - compatible = "dynapack,c140254", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/corsola/cbi_magikarp.dts b/zephyr/projects/corsola/cbi_magikarp.dts deleted file mode 100644 index 5eac6b82c6..0000000000 --- a/zephyr/projects/corsola/cbi_magikarp.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* magikarp-specific fw_config fields. */ - magikarp-fw-config { - compatible = "cros-ec,cbi-fw-config"; - /* - * FW_CONFIG field to describe mainboard orientation in chassis. - */ - base-gyro { - enum-name = "FW_BASE_GYRO"; - start = <0>; - size = <2>; - - None { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_NONE"; - value = <0>; - }; - icm42607 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_ICM42607"; - value = <1>; - default; - }; - bmi323 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_BMI323"; - value = <2>; - }; - }; - }; -}; diff --git a/zephyr/projects/corsola/cbi_steelix.dts b/zephyr/projects/corsola/cbi_steelix.dts deleted file mode 100644 index f4918b1577..0000000000 --- a/zephyr/projects/corsola/cbi_steelix.dts +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - steelix-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - /* - * FW_CONFIG field to indicate the device is clamshell - * or convertible. - */ - form_factor { - enum-name = "FORM_FACTOR"; - start = <13>; - size = <3>; - - convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "CONVERTIBLE"; - value = <1>; - }; - clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "CLAMSHELL"; - value = <0>; - }; - }; - - /* FW_CONFIG field to indicate which DB is attached. */ - db_config: db { - enum-name = "DB"; - start = <0>; - size = <4>; - - sub-board-1 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_NONE"; - value = <0>; - }; - sub-board-2 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_USBA_HDMI"; - value = <1>; - }; - sub-board-3 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_USBA_HDMI_LTE"; - value = <2>; - }; - }; - }; - - /* Steelix-specific ssfc fields. */ - steelix-ssfc { - compatible = "named-cbi-ssfc"; - - /* SSFC field to identify BASE motion sensor. */ - base-sensor { - enum-name = "BASE_SENSOR"; - size = <3>; - - base_sensor_0: bmi323 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <1>; - default; - }; - base_sensor_1: lsm6dsm { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <2>; - }; - }; - - /* SSFC field to identify LID motion sensor. */ - lid-sensor { - enum-name = "LID_SENSOR"; - size = <3>; - - lid_sensor_0: bma422 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <1>; - default; - }; - lid_sensor_1: lis2dw12 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <2>; - }; - }; - }; -}; diff --git a/zephyr/projects/corsola/cbi_tentacruel.dts b/zephyr/projects/corsola/cbi_tentacruel.dts deleted file mode 100644 index 2cd4594417..0000000000 --- a/zephyr/projects/corsola/cbi_tentacruel.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* tentacruel-specific fw_config fields. */ - tentacruel-fw-config { - compatible = "cros-ec,cbi-fw-config"; - /* - * FW_CONFIG field to describe mainboard orientation in chassis. - */ - base-gyro { - enum-name = "FW_BASE_GYRO"; - start = <8>; - size = <2>; - - None { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_NONE"; - value = <0>; - }; - icm42607 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_ICM42607"; - value = <1>; - default; - }; - bmi323 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_BMI323"; - value = <2>; - }; - }; - }; -}; diff --git a/zephyr/projects/corsola/common.dts b/zephyr/projects/corsola/common.dts deleted file mode 100644 index 001dcc7ce3..0000000000 --- a/zephyr/projects/corsola/common.dts +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - ec-mkbp-host-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <( - HOST_EVENT_AC_CONNECTED | - HOST_EVENT_AC_DISCONNECTED | - HOST_EVENT_LID_OPEN | - HOST_EVENT_POWER_BUTTON | - HOST_EVENT_HANG_DETECT | - HOST_EVENT_MODE_CHANGE)>; - }; - - ec-mkbp-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | - MKBP_EVENT_HOST_EVENT)>; - }; -}; diff --git a/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts b/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts deleted file mode 100644 index 604658a145..0000000000 --- a/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ -&{/def-io-conf-list} { - pinmux = <&alt0_gpio_no_spip - &alt0_gpio_no_fpip - &alt1_no_pwrgd - &alt1_no_lpc_espi - &alta_no_peci_en - &altd_npsl_in1_sl - &altd_npsl_in2_sl - &altd_psl_in3_sl - &altd_psl_in4_sl - &alt7_no_ksi0_sl - &alt7_no_ksi1_sl - &alt7_no_ksi2_sl - &alt7_no_ksi3_sl - &alt7_no_ksi4_sl - &alt7_no_ksi5_sl - &alt7_no_ksi6_sl - &alt7_no_ksi7_sl - &alt8_no_kso00_sl - &alt8_no_kso01_sl - &alt8_no_kso02_sl - &alt8_no_kso03_sl - &alt8_no_kso04_sl - &alt8_no_kso05_sl - &alt8_no_kso06_sl - &alt8_no_kso07_sl - &alt9_no_kso08_sl - &alt9_no_kso09_sl - &alt9_no_kso10_sl - &alt9_no_kso11_sl - &alt9_no_kso12_sl - &alt9_no_kso13_sl - &alt9_no_kso14_sl - &alt9_no_kso15_sl - &alta_no_kso16_sl - &alta_no_kso17_sl - &altg_psl_gpo_sl>; -}; diff --git a/zephyr/projects/corsola/gpio_kingler.dts b/zephyr/projects/corsola/gpio_kingler.dts deleted file mode 100644 index 9a827a06dd..0000000000 --- a/zephyr/projects/corsola/gpio_kingler.dts +++ /dev/null @@ -1,249 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - /* - * In npcx9 series, gpio46, gpio47, and the whole gpio5 port - * belong to VHIF power well. On kingler, it is connencted to - * 1.8V. - */ - base_imu_int_l: base_imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - spi_ap_clk_ec { - gpios = <&gpio5 5 GPIO_INPUT>; - }; - spi_ap_cs_ec_l { - gpios = <&gpio5 3 GPIO_INPUT>; - }; - spi_ap_do_ec_di { - gpios = <&gpio4 6 GPIO_INPUT>; - }; - spi_ap_di_ec_do { - gpios = <&gpio4 7 GPIO_INPUT>; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; - }; - en_ec_id_odl { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - }; - sys_rst_odl { - gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - ec_i2c_sensor_scl { - gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_sensor_sda { - gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_usb_c0_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_c0_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_usb_c1_scl { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - ec_i2c_usb_c1_sda { - gpios = <&gpio9 1 GPIO_INPUT>; - }; - ec_i2c_pwr_cbi_scl { - gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_pwr_cbi_sda { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_batt_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_batt_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - ec_pen_chg_dis_odl { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_wp_l: ec_wp_odl { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | - GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpiob 2 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ec_ap_int_odl { - gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpio8 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; - }; - charger_prochot_odl { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - ec_rst_odl { - gpios = <&gpio7 7 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; - }; - packet_mode_en { - gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiod 4 GPIO_INPUT>; - }; - /* - * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 - * belong to VSPI power rail. On kingler, it is connencted to - * 1.8V. - */ - ap_sysrst_odl_r: ap_sysrst_odl_r { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio6 7 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - pg_pp5000_z2_od { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpio7 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpio3 7 GPIO_INPUT>; - }; - en_pp5000_z2 { - gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - ec_batt_pres_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - usb_a0_fault_odl { - gpios = <&gpioc 7 GPIO_INPUT>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpio6 1 GPIO_ODR_HIGH>; - }; - ec_pmic_en_odl { - gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; - - /* - * aliases for sub-board GPIOs - */ - aliases { - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_power_button - &int_lid_open - >; - }; -}; diff --git a/zephyr/projects/corsola/gpio_krabby.dts b/zephyr/projects/corsola/gpio_krabby.dts deleted file mode 100644 index 5f06609f43..0000000000 --- a/zephyr/projects/corsola/gpio_krabby.dts +++ /dev/null @@ -1,231 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &ec_flash_wp_odl; - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - named-gpios { - compatible = "named-gpios"; - - power_button_l: power_button_l { - gpios = <&gpioe 4 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - lid_open: lid_open { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - tablet_mode_l: tablet_mode_l { - gpios = <&gpioj 7 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - base_imu_int_l: base_imu_int_l { - gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l: lid_accel_int_l { - gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - volume_down_l: volume_down_l { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - volume_up_l: volume_up_l { - gpios = <&gpiod 6 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ac_present: ac_present { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - ec_flash_wp_odl: ec_flash_wp_odl { - gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - }; - spi0_cs: spi0_cs { - gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - usb_c0_ppc_bc12_int_odl: usb_c0_ppc_bc12_int_odl { - gpios = <&gpiod 1 GPIO_INPUT>; - }; - usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { - gpios = <&gpioj 4 GPIO_INPUT>; - }; - ec_pmic_en_odl: ec_pmic_en_odl { - gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - en_pp5000_z2: en_pp5000_z2 { - gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; - }; - sys_rst_odl: sys_rst_odl { - gpios = <&gpiog 1 GPIO_ODR_LOW>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - ap_sysrst_odl_r: ap_ec_sysrst_odl { - gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ec_int_l: ec_int_l { - gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - }; - usb_c0_ppc_frsinfo: usb_c0_ppc_frsinfo { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - en_ec_id_odl: en_ec_id_odl { - gpios = <&gpioh 5 GPIO_ODR_HIGH>; - }; - entering_rw: entering_rw { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; - }; - usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&gpioj 6 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpioj 3 GPIO_INPUT>; - }; - gpio_packet_mode_en: packet_mode_en { - gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioc 4 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = <&int_ac_present - &int_power_button - &int_lid_open>; - }; - - unused-pins { - compatible = "unused-gpios"; - - unused-gpios = - /* pg_pp5000_z2_od */ - <&gpiod 2 GPIO_INPUT>, - /* pg_mt6315_proc_b_odl */ - <&gpioe 1 GPIO_INPUT>, - /* ec_pen_chg_dis_odl */ - <&gpioh 3 GPIO_ODR_HIGH>, - /* unnamed nc pins */ - <&gpioa 3 GPIO_INPUT_PULL_DOWN>, - <&gpioa 6 GPIO_INPUT_PULL_DOWN>, - <&gpioa 7 GPIO_INPUT_PULL_DOWN>, - <&gpiod 7 GPIO_INPUT_PULL_DOWN>, - <&gpiof 1 GPIO_INPUT_PULL_DOWN>, - <&gpioh 0 GPIO_INPUT_PULL_DOWN>, - <&gpioh 6 GPIO_INPUT_PULL_DOWN>, - <&gpioi 3 GPIO_INPUT_PULL_DOWN>, - <&gpioi 5 GPIO_INPUT_PULL_DOWN>, - <&gpioi 6 GPIO_INPUT_PULL_DOWN>, - <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, - /* spi_clk_gpg6 */ - <&gpiog 6 GPIO_INPUT_PULL_UP>, - /* spi_mosi_gpg4 */ - <&gpiog 4 GPIO_OUTPUT_LOW>, - /* spi_miso_gpg5 */ - <&gpiog 5 GPIO_OUTPUT_LOW>, - /* spi_cs_gpg7 */ - <&gpiog 7 GPIO_OUTPUT_LOW>; - }; -}; - -&pinctrl { - /* I2C property setting */ - i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { - gpio-voltage = "1v8"; - }; - i2c0_data_gpb4_default: i2c0_data_gpb4_default { - gpio-voltage = "1v8"; - }; - i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { - gpio-voltage = "1v8"; - }; - i2c3_data_gpf3_default: i2c3_data_gpf3_default { - gpio-voltage = "1v8"; - }; - /* SHI property setting */ - shi_mosi_gpm0_default: shi_mosi_gpm0_default { - gpio-voltage = "1v8"; - }; - shi_miso_gpm1_default: shi_miso_gpm1_default { - gpio-voltage = "1v8"; - }; - shi_clk_gpm4_default: shi_clk_gpm4_default { - gpio-voltage = "1v8"; - }; - shi_cs_gpm5_default: shi_cs_gpm5_default { - gpio-voltage = "1v8"; - }; -}; diff --git a/zephyr/projects/corsola/gpio_magikarp.dts b/zephyr/projects/corsola/gpio_magikarp.dts deleted file mode 100644 index cb9f6f1a0a..0000000000 --- a/zephyr/projects/corsola/gpio_magikarp.dts +++ /dev/null @@ -1,237 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &ec_flash_wp_odl; - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - named-gpios { - compatible = "named-gpios"; - - power_button_l: power_button_l { - gpios = <&gpioe 4 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - lid_open: lid_open { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - tablet_mode_l: tablet_mode_l { - gpios = <&gpioj 7 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - base_imu_int_l: base_imu_int_l { - gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l: lid_accel_int_l { - gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - volume_down_l: volume_down_l { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - volume_up_l: volume_up_l { - gpios = <&gpiod 6 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ac_present: ac_present { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - ec_flash_wp_odl: ec_flash_wp_odl { - gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - }; - spi0_cs: spi0_cs { - gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpiod 1 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpiof 1 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { - gpios = <&gpioj 4 GPIO_INPUT>; - }; - ec_pmic_en_odl: ec_pmic_en_odl { - gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - en_pp5000_z2: en_pp5000_z2 { - gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; - }; - sys_rst_odl: sys_rst_odl { - gpios = <&gpiog 1 GPIO_ODR_LOW>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - ap_sysrst_odl_r: ap_ec_sysrst_odl { - gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ec_int_l: ec_int_l { - gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - }; - usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - en_ec_id_odl: en_ec_id_odl { - gpios = <&gpioh 5 GPIO_ODR_HIGH>; - }; - entering_rw: entering_rw { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; - }; - usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&gpioj 6 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpioj 3 GPIO_INPUT>; - }; - gpio_packet_mode_en: packet_mode_en { - gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioc 4 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = <&int_ac_present - &int_power_button - &int_lid_open>; - }; - - unused-pins { - compatible = "unused-gpios"; - - unused-gpios = - /* pg_pp5000_z2_od */ - <&gpiod 2 GPIO_INPUT>, - /* pg_mt6315_proc_b_odl */ - <&gpioe 1 GPIO_INPUT>, - /* ec_pen_chg_dis_odl */ - <&gpioh 3 GPIO_ODR_HIGH>, - /* unnamed nc pins */ - <&gpioa 3 GPIO_INPUT_PULL_DOWN>, - <&gpioa 6 GPIO_INPUT_PULL_DOWN>, - <&gpioa 7 GPIO_INPUT_PULL_DOWN>, - /* reserved for b:241345809 */ - <&gpiod 7 GPIO_OUTPUT_LOW>, - <&gpiog 2 GPIO_INPUT_PULL_DOWN>, - <&gpioh 0 GPIO_INPUT_PULL_DOWN>, - <&gpioh 6 GPIO_INPUT_PULL_DOWN>, - <&gpioi 3 GPIO_INPUT_PULL_DOWN>, - <&gpioi 6 GPIO_INPUT_PULL_DOWN>, - <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, - /* spi_clk_gpg6 */ - <&gpiog 6 GPIO_INPUT_PULL_UP>, - /* spi_mosi_gpg4 */ - <&gpiog 4 GPIO_OUTPUT_LOW>, - /* spi_miso_gpg5 */ - <&gpiog 5 GPIO_OUTPUT_LOW>, - /* spi_cs_gpg7 */ - <&gpiog 7 GPIO_OUTPUT_LOW>; - }; -}; - -&pinctrl { - /* I2C property setting */ - i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { - gpio-voltage = "1v8"; - }; - i2c0_data_gpb4_default: i2c0_data_gpb4_default { - gpio-voltage = "1v8"; - }; - i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { - gpio-voltage = "1v8"; - }; - i2c3_data_gpf3_default: i2c3_data_gpf3_default { - gpio-voltage = "1v8"; - }; - /* SHI property setting */ - shi_mosi_gpm0_default: shi_mosi_gpm0_default { - gpio-voltage = "1v8"; - }; - shi_miso_gpm1_default: shi_miso_gpm1_default { - gpio-voltage = "1v8"; - }; - shi_clk_gpm4_default: shi_clk_gpm4_default { - gpio-voltage = "1v8"; - }; - shi_cs_gpm5_default: shi_cs_gpm5_default { - gpio-voltage = "1v8"; - }; -}; diff --git a/zephyr/projects/corsola/gpio_steelix.dts b/zephyr/projects/corsola/gpio_steelix.dts deleted file mode 100644 index 14120e6d7d..0000000000 --- a/zephyr/projects/corsola/gpio_steelix.dts +++ /dev/null @@ -1,255 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - /* - * In npcx9 series, gpio46, gpio47, and the whole gpio5 port - * belong to VHIF power well. On steelix, it is connencted to - * 1.8V. - */ - base_imu_int_l: base_imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - spi_ap_clk_ec { - gpios = <&gpio5 5 GPIO_INPUT>; - }; - spi_ap_cs_ec_l { - gpios = <&gpio5 3 GPIO_INPUT>; - }; - spi_ap_do_ec_di { - gpios = <&gpio4 6 GPIO_INPUT>; - }; - spi_ap_di_ec_do { - gpios = <&gpio4 7 GPIO_INPUT>; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; - }; - en_ec_id_odl { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - }; - sys_rst_odl { - gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - ec_i2c_sensor_scl { - gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_sensor_sda { - gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_usb_c0_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_c0_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_usb_c1_scl { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - ec_i2c_usb_c1_sda { - gpios = <&gpio9 1 GPIO_INPUT>; - }; - ec_i2c_pwr_cbi_scl { - gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_pwr_cbi_sda { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_batt_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_batt_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x { - gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; - }; - usb_a1_fault_odl { - gpios = <&gpiof 4 GPIO_INPUT>; - }; - ec_pen_chg_dis_odl { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_wp_l: ec_wp_odl { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | - GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpiob 2 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ec_ap_int_odl { - gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpio8 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; - }; - charger_prochot_odl { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - ec_rst_odl { - gpios = <&gpio7 7 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; - }; - packet_mode_en { - gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiod 4 GPIO_INPUT>; - }; - /* - * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 - * belong to VSPI power well. On steelix, it is connencted to - * 1.8V. - */ - ap_sysrst_odl_r: ap_sysrst_odl_r { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio6 7 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - pg_pp5000_z2_od { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpio7 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpio3 7 GPIO_INPUT>; - }; - en_pp5000_z2 { - gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - ec_batt_pres_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - usb_a0_fault_odl { - gpios = <&gpioc 7 GPIO_INPUT>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpio6 1 GPIO_ODR_HIGH>; - }; - ec_pmic_en_odl { - gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; - - /* - * aliases for sub-board GPIOs - */ - aliases { - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_power_button - &int_lid_open - >; - }; -}; diff --git a/zephyr/projects/corsola/gpio_tentacruel.dts b/zephyr/projects/corsola/gpio_tentacruel.dts deleted file mode 100644 index a9ac9e8eac..0000000000 --- a/zephyr/projects/corsola/gpio_tentacruel.dts +++ /dev/null @@ -1,235 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &ec_flash_wp_odl; - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - named-gpios { - compatible = "named-gpios"; - - power_button_l: power_button_l { - gpios = <&gpioe 4 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - lid_open: lid_open { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - tablet_mode_l: tablet_mode_l { - gpios = <&gpioj 7 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - base_imu_int_l: base_imu_int_l { - gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l: lid_accel_int_l { - gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - volume_down_l: volume_down_l { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - volume_up_l: volume_up_l { - gpios = <&gpiod 6 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ac_present: ac_present { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - ec_flash_wp_odl: ec_flash_wp_odl { - gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - }; - spi0_cs: spi0_cs { - gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpiod 1 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpiof 1 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { - gpios = <&gpioj 4 GPIO_INPUT>; - }; - ec_pmic_en_odl: ec_pmic_en_odl { - gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - en_pp5000_z2: en_pp5000_z2 { - gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; - }; - sys_rst_odl: sys_rst_odl { - gpios = <&gpiog 1 GPIO_ODR_LOW>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - ap_sysrst_odl_r: ap_ec_sysrst_odl { - gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ec_int_l: ec_int_l { - gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - }; - usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - en_ec_id_odl: en_ec_id_odl { - gpios = <&gpioh 5 GPIO_ODR_HIGH>; - }; - entering_rw: entering_rw { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; - }; - usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&gpioj 6 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpioj 3 GPIO_INPUT>; - }; - gpio_packet_mode_en: packet_mode_en { - gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioc 4 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = <&int_ac_present - &int_power_button - &int_lid_open>; - }; - - unused-pins { - compatible = "unused-gpios"; - - unused-gpios = - /* pg_pp5000_z2_od */ - <&gpiod 2 GPIO_INPUT>, - /* pg_mt6315_proc_b_odl */ - <&gpioe 1 GPIO_INPUT>, - /* ec_pen_chg_dis_odl */ - <&gpioh 3 GPIO_ODR_HIGH>, - /* unnamed nc pins */ - <&gpioa 3 GPIO_INPUT_PULL_DOWN>, - <&gpioa 6 GPIO_INPUT_PULL_DOWN>, - <&gpioa 7 GPIO_INPUT_PULL_DOWN>, - <&gpiod 7 GPIO_INPUT_PULL_DOWN>, - <&gpioh 0 GPIO_INPUT_PULL_DOWN>, - <&gpioh 6 GPIO_INPUT_PULL_DOWN>, - <&gpioi 3 GPIO_INPUT_PULL_DOWN>, - <&gpioi 6 GPIO_INPUT_PULL_DOWN>, - <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, - /* spi_clk_gpg6 */ - <&gpiog 6 GPIO_INPUT_PULL_UP>, - /* spi_mosi_gpg4 */ - <&gpiog 4 GPIO_OUTPUT_LOW>, - /* spi_miso_gpg5 */ - <&gpiog 5 GPIO_OUTPUT_LOW>, - /* spi_cs_gpg7 */ - <&gpiog 7 GPIO_OUTPUT_LOW>; - }; -}; - -&pinctrl { - /* I2C property setting */ - i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { - gpio-voltage = "1v8"; - }; - i2c0_data_gpb4_default: i2c0_data_gpb4_default { - gpio-voltage = "1v8"; - }; - i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { - gpio-voltage = "1v8"; - }; - i2c3_data_gpf3_default: i2c3_data_gpf3_default { - gpio-voltage = "1v8"; - }; - /* SHI property setting */ - shi_mosi_gpm0_default: shi_mosi_gpm0_default { - gpio-voltage = "1v8"; - }; - shi_miso_gpm1_default: shi_miso_gpm1_default { - gpio-voltage = "1v8"; - }; - shi_clk_gpm4_default: shi_clk_gpm4_default { - gpio-voltage = "1v8"; - }; - shi_cs_gpm5_default: shi_cs_gpm5_default { - gpio-voltage = "1v8"; - }; -}; diff --git a/zephyr/projects/corsola/host_interface_npcx.dts b/zephyr/projects/corsola/host_interface_npcx.dts deleted file mode 100644 index 14efa3c6b2..0000000000 --- a/zephyr/projects/corsola/host_interface_npcx.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* host interface */ -&shi { - status = "okay"; - pinctrl-0 = <&shi_gp46_47_53_55>; - pinctrl-1 = <&shi_gpio_gp46_47_53_55>; - pinctrl-names = "default", "sleep"; -}; diff --git a/zephyr/projects/corsola/i2c_kingler.dts b/zephyr/projects/corsola/i2c_kingler.dts deleted file mode 100644 index 90390ab8a0..0000000000 --- a/zephyr/projects/corsola/i2c_kingler.dts +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/* - * Kingler and Steelix use the same dts, take care of this when modify it. - */ - -/ { - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_sensor: sensor { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_usb_c0: usb-c0 { - i2c-port = <&i2c1_0>; - remote-port = <7>; - enum-names = "I2C_PORT_USB_C0"; - }; - i2c_usb_c1: usb-c1 { - i2c-port = <&i2c2_0>; - enum-names = "I2C_PORT_USB_C1", - "I2C_PORT_USB_C1_TCPC", - "I2C_PORT_USB_C1_PPC"; - }; - i2c_charger: charger { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_POWER", - "I2C_PORT_EEPROM"; - }; - battery { - i2c-port = <&i2c5_0>; - remote-port = <1>; - enum-names = "I2C_PORT_BATTERY", - "I2C_PORT_VIRTUAL_BATTERY"; - }; - }; -}; - -&i2c0_0 { - label = "I2C_SENSOR"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - label = "I2C_USB_C0"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - tcpc_port0: anx7447-tcpc@2c { - compatible = "analogix,anx7447-tcpc"; - status = "okay"; - reg = <0x2c>; - tcpc-flags = <( - TCPC_FLAGS_VBUS_MONITOR | - TCPC_FLAGS_ALERT_OD | - TCPC_FLAGS_CONTROL_VCONN | - TCPC_FLAGS_CONTROL_FRS)>; - }; - - ppc_port0: nx20p348x@72 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x72>; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - label = "I2C_USB_C1"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; - - bc12_port1: rt1718s-bc12@40 { - compatible = "richtek,rt1718s-bc12"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: rt1718s-tcpc@40 { - compatible = "richtek,rt1718s-tcpc"; - reg = <0x40>; - tcpc-flags = <( - TCPC_FLAGS_ALERT_OD | - TCPC_FLAGS_CONTROL_VCONN | - TCPC_FLAGS_CONTROL_FRS)>; - }; - - ppc_port1: nx20p348x@72 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x72>; - }; - - ps8743_mux_1: ps8743-mux-1@10 { - compatible = "parade,ps8743"; - reg = <0x10>; - board-init = "ps8743_mux_1_board_init"; - }; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - label = "I2C_PWR_CBI"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; - - charger: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c5_0 { - label = "I2C_BATTERY"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; -}; - -&i2c_ctrl5 { - status = "okay"; -}; diff --git a/zephyr/projects/corsola/i2c_krabby.dts b/zephyr/projects/corsola/i2c_krabby.dts deleted file mode 100644 index a5dc03b655..0000000000 --- a/zephyr/projects/corsola/i2c_krabby.dts +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "i2c_krabby_tentacruel.dtsi" - -&i2c0 { - charger: rt9490@53 { - compatible = "richtek,rt9490"; - status = "okay"; - reg = <0x53>; - }; -}; - -&i2c4 { - tusb1064_mux_1: tusb1064-mux-1@44 { - compatible = "ti,tusb1064"; - reg = <0x44>; - board-init = "tusb1064_mux_1_board_init"; - }; -}; diff --git a/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi b/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi deleted file mode 100644 index 6fd153e1fa..0000000000 --- a/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - named-i2c-ports { - compatible = "named-i2c-ports"; - - battery { - i2c-port = <&i2c1>; - remote-port = <1>; - enum-names = "I2C_PORT_BATTERY", - "I2C_PORT_VIRTUAL_BATTERY"; - }; - i2c_charger: charger { - i2c-port = <&i2c0>; - enum-names = "I2C_PORT_CHARGER", - "I2C_PORT_EEPROM"; - }; - i2c_sensor: sensor { - i2c-port = <&i2c3>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_usb_c0: usb-c0 { - i2c-port = <&i2c2>; - enum-names = "I2C_PORT_USB_C0", - "I2C_PORT_USB_MUX0"; - }; - i2c_usb_c1: usb-c1 { - i2c-port = <&i2c4>; - enum-names = "I2C_PORT_USB_C1", - "I2C_PORT_USB_MUX1"; - }; - }; - -}; - -&pinctrl { - i2c3_clk_gpf2_sleep: i2c3_clk_gpf2_sleep { - pinmuxs = <&pinctrlf 2 IT8XXX2_ALT_DEFAULT>; - }; - i2c3_data_gpf3_sleep: i2c3_data_gpf3_sleep { - pinmuxs = <&pinctrlf 3 IT8XXX2_ALT_DEFAULT>; - }; -}; - -&i2c0 { - /* EC_I2C_PWR_CBI */ - label = "I2C_PWR_CBI"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_clk_gpb3_default - &i2c0_data_gpb4_default>; - pinctrl-names = "default"; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; - - bc12_port1: rt9490-bc12@53 { - compatible = "richtek,rt9490-bc12"; - status = "okay"; - reg = <0x53>; - irq = <&int_usb_c1_bc12_charger>; - }; -}; - -&i2c1 { - /* EC_I2C_BATTERY */ - label = "I2C_BATTERY"; - status = "okay"; - clock-frequency = <50000>; - pinctrl-0 = <&i2c1_clk_gpc1_default - &i2c1_data_gpc2_default>; - pinctrl-names = "default"; - fifo-enable; -}; - -&i2c2 { - /* EC_I2C_USB_C0 */ - label = "I2C_USB_C0"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_clk_gpf6_default - &i2c2_data_gpf7_default>; - pinctrl-names = "default"; - /delete-property/ fifo-enable; - - bc12_ppc_port0: rt1739@70 { - compatible = "richtek,rt1739"; - status = "okay"; - reg = <0x70>; - }; - - it5205_mux_0: it5205-mux-0@48 { - compatible = "ite,it5205"; - reg = <0x48>; - }; -}; - -&i2c3 { - /* EC_I2C_SENSOR */ - label = "I2C_SENSOR"; - status = "okay"; - clock-frequency = ; - scl-gpios = <&gpiof 2 0>; - sda-gpios = <&gpiof 3 0>; - pinctrl-0 = <&i2c3_clk_gpf2_default - &i2c3_data_gpf3_default>; - pinctrl-1 = <&i2c3_clk_gpf2_sleep - &i2c3_data_gpf3_sleep>; - pinctrl-names = "default", "sleep"; - prescale-scl-low = <1>; -}; - -&i2c4 { - /* EC_I2C_USB_C1 */ - label = "I2C_USB_C1"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c4_clk_gpe0_default - &i2c4_data_gpe7_default>; - pinctrl-names = "default"; - prescale-scl-low = <1>; - - ppc_port1: syv682x@40 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x40>; - frs_en_gpio = <&gpio_ec_x_gpio1>; - }; -}; diff --git a/zephyr/projects/corsola/i2c_magikarp.dts b/zephyr/projects/corsola/i2c_magikarp.dts deleted file mode 100644 index fbf5ed6337..0000000000 --- a/zephyr/projects/corsola/i2c_magikarp.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "i2c_krabby_tentacruel.dtsi" - -&i2c0 { - charger: rt9490@53 { - compatible = "richtek,rt9490"; - status = "okay"; - reg = <0x53>; - }; -}; - -&i2c2 { - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - ppc_port0: syv682x@40 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x40>; - frs_en_gpio = <&usb_c0_frs_en>; - }; -}; - -&i2c4 { - ps8743_mux_1: ps8743-mux-1@10 { - compatible = "parade,ps8743"; - reg = <0x10>; - }; -}; diff --git a/zephyr/projects/corsola/i2c_tentacruel.dts b/zephyr/projects/corsola/i2c_tentacruel.dts deleted file mode 100644 index a635adcf5c..0000000000 --- a/zephyr/projects/corsola/i2c_tentacruel.dts +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "i2c_krabby_tentacruel.dtsi" - -&i2c0 { - charger: rt9490@53 { - compatible = "richtek,rt9490"; - status = "okay"; - reg = <0x53>; - thermistor = <&thermistor_rt9490>; - }; -}; - -&i2c2 { - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - ppc_port0: syv682x@40 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x40>; - frs_en_gpio = <&usb_c0_frs_en>; - }; -}; - -&i2c4 { - ps8743_mux_1: ps8743-mux-1@10 { - compatible = "parade,ps8743"; - reg = <0x10>; - board-init = "ps8743_eq_c1_setting"; - }; -}; diff --git a/zephyr/projects/corsola/include/baseboard_usbc_config.h b/zephyr/projects/corsola/include/baseboard_usbc_config.h deleted file mode 100644 index a80aa10446..0000000000 --- a/zephyr/projects/corsola/include/baseboard_usbc_config.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Corsola daughter board detection */ - -#ifndef __CROS_EC_BASEBOARD_USBC_CONFIG_H -#define __CROS_EC_BASEBOARD_USBC_CONFIG_H - -#include "gpio.h" - -#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S -#define GPIO_EN_USB_C1_SINK RT1718S_GPIO1 -#define GPIO_EN_USB_C1_SOURCE RT1718S_GPIO2 -#define GPIO_EN_USB_C1_FRS RT1718S_GPIO3 -#endif - -void ppc_interrupt(enum gpio_signal signal); -void ccd_interrupt(enum gpio_signal signal); -void hdmi_hpd_interrupt(enum gpio_signal signal); -void ps185_hdmi_hpd_mux_set(void); -int corsola_is_dp_muxable(int port); - -/* USB-A ports */ -enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_COUNT }; - -/* USB-C ports */ -enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; -BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); - -/** - * Is the port fine to be muxed its DisplayPort lines? - * - * Only one port can be muxed to DisplayPort at a time. - * - * @param port Port number of TCPC. - * @return 1 is fine; 0 is bad as other port is already muxed; - */ -int corsola_is_dp_muxable(int port); - -#endif /* __CROS_EC_BASEBOARD_USBC_CONFIG_H */ diff --git a/zephyr/projects/corsola/include/variant_db_detection.h b/zephyr/projects/corsola/include/variant_db_detection.h deleted file mode 100644 index e98ba3067d..0000000000 --- a/zephyr/projects/corsola/include/variant_db_detection.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Corsola daughter board detection */ - -#ifndef __CROS_EC_CORSOLA_DB_DETECTION_H -#define __CROS_EC_CORSOLA_DB_DETECTION_H - -enum corsola_db_type { - CORSOLA_DB_UNINIT = -1, - CORSOLA_DB_NONE, - CORSOLA_DB_TYPEC, - CORSOLA_DB_HDMI, - CORSOLA_DB_COUNT, -}; - -#ifdef CONFIG_VARIANT_CORSOLA_DB_DETECTION -/* - * Get the connected daughterboard type. - * - * @return The daughterboard type. - */ -enum corsola_db_type corsola_get_db_type(void); -#else -inline enum corsola_db_type corsola_get_db_type(void) -{ - return CORSOLA_DB_NONE; -}; -#endif /* CONFIG_VARIANT_CORSOLA_DB_DETECTION */ - -/* return the adjusted port count for board overridden usbc/charger functions. - */ -uint8_t board_get_adjusted_usb_pd_port_count(void); - -#endif /* __CROS_EC_CORSOLA_DB_DETECTION_H */ diff --git a/zephyr/projects/corsola/interrupts_kingler.dts b/zephyr/projects/corsola/interrupts_kingler.dts deleted file mode 100644 index f3da785a60..0000000000 --- a/zephyr/projects/corsola/interrupts_kingler.dts +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * Kingler and Steelix use the same dts, take care of this when modify it. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_ec_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_ec_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_warm_rst: warm_rst { - irq-pin = <&ap_ec_warm_rst_req>; - flags = ; - handler = "chipset_reset_request_interrupt"; - }; - int_ap_in_sleep: ap_in_sleep { - irq-pin = <&ap_in_sleep_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_in_rst: ap_in_rst { - irq-pin = <&ap_sysrst_odl_r>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_wdtrst: ap_wdtrst { - irq-pin = <&ap_ec_wdtrst_l>; - flags = ; - handler = "chipset_watchdog_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&gpio_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_usba: usba { - irq-pin = <&gpio_ap_xhci_init_done>; - flags = ; - handler = "usb_a0_interrupt"; - }; - int_wp: wp { - irq-pin = <&gpio_ec_wp_l>; - flags = ; - handler = "switch_interrupt"; - }; - int_usb_c0_tcpc: usb_c0_tcpc { - irq-pin = <&gpio_usb_c0_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_tcpc: usb_c1_tcpc { - irq-pin = <&gpio_usb_c1_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&gpio_usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_x_ec_gpio2: x_ec_gpio2 { - irq-pin = <&gpio_x_ec_gpio2>; - flags = ; - handler = "x_ec_interrupt"; - }; - int_base_imu: base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "bmi3xx_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "ccd_interrupt"; - }; - }; -}; diff --git a/zephyr/projects/corsola/interrupts_krabby.dts b/zephyr/projects/corsola/interrupts_krabby.dts deleted file mode 100644 index 3caf4660ae..0000000000 --- a/zephyr/projects/corsola/interrupts_krabby.dts +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&volume_up_l>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&volume_down_l>; - flags = ; - handler = "button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_warm_rst: warm_rst { - irq-pin = <&ap_ec_warm_rst_req>; - flags = ; - handler = "chipset_reset_request_interrupt"; - }; - int_ap_in_sleep: ap_in_sleep { - irq-pin = <&ap_in_sleep_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_in_rst: ap_in_rst { - irq-pin = <&ap_sysrst_odl_r>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_wdtrst: ap_wdtrst { - irq-pin = <&ap_ec_wdtrst_l>; - flags = ; - handler = "chipset_watchdog_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_base_imu: base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "icm42607_interrupt"; - }; - int_lid_imu: lid_imu { - irq-pin = <&lid_accel_int_l>; - flags = ; - handler = "lis2dw12_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&ac_present>; - flags = ; - handler = "extpower_interrupt"; - }; - int_usba: usba { - irq-pin = <&gpio_ap_xhci_init_done>; - flags = ; - handler = "usb_a0_interrupt"; - }; - int_wp: wp { - irq-pin = <&ec_flash_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_spi0_cs: spi0_cs { - irq-pin = <&spi0_cs>; - flags = ; - handler = "spi_event"; - }; - int_x_ec_gpio2: x_ec_gpio2 { - irq-pin = <&gpio_x_ec_gpio2>; - flags = ; - handler = "x_ec_interrupt"; - }; - int_usb_c0_ppc_bc12: usb_c0_ppc_bc12 { - irq-pin = <&usb_c0_ppc_bc12_int_odl>; - flags = ; - handler = "c0_bc12_interrupt"; - }; - int_usb_c1_bc12_charger: usb_c1_bc12_charger { - irq-pin = <&usb_c1_bc12_charger_int_odl>; - flags = ; - handler = "rt9490_bc12_dt_interrupt"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "ccd_interrupt"; - }; - }; -}; diff --git a/zephyr/projects/corsola/interrupts_magikarp.dts b/zephyr/projects/corsola/interrupts_magikarp.dts deleted file mode 100644 index 4f4e0ba100..0000000000 --- a/zephyr/projects/corsola/interrupts_magikarp.dts +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&volume_up_l>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&volume_down_l>; - flags = ; - handler = "button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_warm_rst: warm_rst { - irq-pin = <&ap_ec_warm_rst_req>; - flags = ; - handler = "chipset_reset_request_interrupt"; - }; - int_ap_in_sleep: ap_in_sleep { - irq-pin = <&ap_in_sleep_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_in_rst: ap_in_rst { - irq-pin = <&ap_sysrst_odl_r>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_wdtrst: ap_wdtrst { - irq-pin = <&ap_ec_wdtrst_l>; - flags = ; - handler = "chipset_watchdog_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_base_imu: base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "motion_interrupt"; - }; - int_lid_imu: lid_imu { - irq-pin = <&lid_accel_int_l>; - flags = ; - handler = "lis2dw12_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&ac_present>; - flags = ; - handler = "extpower_interrupt"; - }; - int_usba: usba { - irq-pin = <&gpio_ap_xhci_init_done>; - flags = ; - handler = "usb_a0_interrupt"; - }; - int_wp: wp { - irq-pin = <&ec_flash_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_spi0_cs: spi0_cs { - irq-pin = <&spi0_cs>; - flags = ; - handler = "spi_event"; - }; - int_x_ec_gpio2: x_ec_gpio2 { - irq-pin = <&gpio_x_ec_gpio2>; - flags = ; - handler = "x_ec_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_bc12_charger: usb_c1_bc12_charger { - irq-pin = <&usb_c1_bc12_charger_int_odl>; - flags = ; - handler = "rt9490_bc12_dt_interrupt"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "ccd_interrupt"; - }; - }; -}; diff --git a/zephyr/projects/corsola/interrupts_steelix.dts b/zephyr/projects/corsola/interrupts_steelix.dts deleted file mode 100644 index 816beb95f4..0000000000 --- a/zephyr/projects/corsola/interrupts_steelix.dts +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -&int_base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "motion_interrupt"; -}; diff --git a/zephyr/projects/corsola/interrupts_tentacruel.dts b/zephyr/projects/corsola/interrupts_tentacruel.dts deleted file mode 100644 index 11229daf36..0000000000 --- a/zephyr/projects/corsola/interrupts_tentacruel.dts +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&volume_up_l>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&volume_down_l>; - flags = ; - handler = "button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_warm_rst: warm_rst { - irq-pin = <&ap_ec_warm_rst_req>; - flags = ; - handler = "chipset_reset_request_interrupt"; - }; - int_ap_in_sleep: ap_in_sleep { - irq-pin = <&ap_in_sleep_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_in_rst: ap_in_rst { - irq-pin = <&ap_sysrst_odl_r>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_wdtrst: ap_wdtrst { - irq-pin = <&ap_ec_wdtrst_l>; - flags = ; - handler = "chipset_watchdog_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_base_imu: base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "motion_interrupt"; - }; - int_lid_imu: lid_imu { - irq-pin = <&lid_accel_int_l>; - flags = ; - handler = "lis2dw12_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&ac_present>; - flags = ; - handler = "extpower_interrupt"; - }; - int_usba: usba { - irq-pin = <&gpio_ap_xhci_init_done>; - flags = ; - handler = "usb_a0_interrupt"; - }; - int_wp: wp { - irq-pin = <&ec_flash_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_spi0_cs: spi0_cs { - irq-pin = <&spi0_cs>; - flags = ; - handler = "spi_event"; - }; - int_x_ec_gpio2: x_ec_gpio2 { - irq-pin = <&gpio_x_ec_gpio2>; - flags = ; - handler = "x_ec_interrupt"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c1_bc12_charger: usb_c1_bc12_charger { - irq-pin = <&usb_c1_bc12_charger_int_odl>; - flags = ; - handler = "rt9490_bc12_dt_interrupt"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "ccd_interrupt"; - }; - }; -}; diff --git a/zephyr/projects/corsola/keyboard_krabby.dts b/zephyr/projects/corsola/keyboard_krabby.dts deleted file mode 100644 index b1a9af6330..0000000000 --- a/zephyr/projects/corsola/keyboard_krabby.dts +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - scan-period = <10000>; - - actual-key-mask = < - 0x1c /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; -}; diff --git a/zephyr/projects/corsola/keyboard_steelix.dts b/zephyr/projects/corsola/keyboard_steelix.dts deleted file mode 100644 index 9a0dca3e05..0000000000 --- a/zephyr/projects/corsola/keyboard_steelix.dts +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - debounce-down = <15000>; - debounce-up = <15000>; - - actual-key-mask = < - 0x1c /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; -}; diff --git a/zephyr/projects/corsola/led_it81202_base.dtsi b/zephyr/projects/corsola/led_it81202_base.dtsi deleted file mode 100644 index dce7bb4f95..0000000000 --- a/zephyr/projects/corsola/led_it81202_base.dtsi +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include - -/ { - led_colors: led-colors { - compatible = "cros-ec,led-policy"; - - bat-power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_battery_amber>; - }; - }; - - bat-power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_battery_white>; - }; - }; - - bat-power-state-discharge { - charge-state = "PWR_STATE_DISCHARGE"; - - color-0 { - led-color = <&color_battery_off>; - }; - }; - - bat-power-state-discharge-s0-bat-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - batt-lvl = ; - - color-0 { - led-color = <&color_battery_amber>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-error { - charge-state = "PWR_STATE_ERROR"; - - color-0 { - led-color = <&color_battery_amber>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <1000>; - }; - }; - - pwr-power-state-off { - color-0 { - led-color = <&color_power_off>; - }; - }; - - pwr-power-state-on { - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_power_white>; - }; - }; - - pwr-power-state-s3 { - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_power_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_power_off>; - period-ms = <3000>; - }; - }; - }; - - pwmleds { - compatible = "cros-ec,pwm-pin-config"; - - /* NOTE: &pwm number needs same with channel number */ - led_power_white: ec_led1_odl { - #led-pin-cells = <1>; - pwms = <&pwm0 - PWM_CHANNEL_0 - PWM_HZ(324) - PWM_POLARITY_INVERTED>; - }; - led_battery_amber: ec_led2_odl { - #led-pin-cells = <1>; - pwms = <&pwm1 - PWM_CHANNEL_1 - PWM_HZ(324) - PWM_POLARITY_INVERTED>; - }; - led_battery_white: ec_led3_odl { - #led-pin-cells = <1>; - pwms = <&pwm2 - PWM_CHANNEL_2 - PWM_HZ(324) - PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_power_off: color-power-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 0>; - }; - - color_power_white: color-power-white { - led-color = "LED_WHITE"; - br-color = "EC_LED_COLOR_WHITE"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 100>; - }; - - color_battery_off: color-battery-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&led_battery_amber 0>, - <&led_battery_white 0>; - }; - - color_battery_amber: color-battery-amber { - led-color = "LED_AMBER"; - br-color = "EC_LED_COLOR_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&led_battery_amber 100>, - <&led_battery_white 0>; - }; - - color_battery_white: color-battery-white { - led-color = "LED_WHITE"; - br-color = "EC_LED_COLOR_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&led_battery_amber 0>, - <&led_battery_white 100>; - }; - }; -}; - -/* LED1 */ -&pwm0 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm0_gpa0_default>; - pinctrl-names = "default"; -}; - -/* LED2 */ -&pwm1 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm1_gpa1_default>; - pinctrl-names = "default"; -}; - -/* LED3 */ -&pwm2 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm2_gpa2_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/corsola/led_kingler.dts b/zephyr/projects/corsola/led_kingler.dts deleted file mode 100644 index 92f6c4d4fe..0000000000 --- a/zephyr/projects/corsola/led_kingler.dts +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED - &pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED - &pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0>; - - color-map-red = <100 0 0>; - color-map-green = < 0 100 0>; - color-map-amber = <100 20 0>; - - brightness-range = <255 255 0 0 0 255>; - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_BATTERY_LED"; - }; - }; -}; - -/* Red LED */ -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -/* Green LED */ -&pwm1_gpc2 { - drive-open-drain; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -/* Blue LED */ -&pwm2_gpc4 { - drive-open-drain; -}; - -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/corsola/led_krabby.dts b/zephyr/projects/corsola/led_krabby.dts deleted file mode 100644 index b16bff3cac..0000000000 --- a/zephyr/projects/corsola/led_krabby.dts +++ /dev/null @@ -1,5 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "led_it81202_base.dtsi" diff --git a/zephyr/projects/corsola/led_magikarp.dts b/zephyr/projects/corsola/led_magikarp.dts deleted file mode 100644 index 0e2b0aca52..0000000000 --- a/zephyr/projects/corsola/led_magikarp.dts +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "led_it81202_base.dtsi" - -/ { - led_colors: led-colors { - compatible = "cros-ec,led-policy"; - - /* Magikarp LED bat charge */ - bat-power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = ; - color-0 { - led-color = <&color_battery_amber>; - }; - }; - - bat-power-state-charge-near-full { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) - BATTERY_LEVEL_FULL>; - color-0 { - led-color = <&color_battery_white>; - }; - }; - - /* Magikarp LED bat discharge */ - bat-power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= 11%, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_battery_white>; - }; - }; - - - bat-power-state-discharge-s0-bat-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= 10%) */ - batt-lvl = ; - - color-0 { - led-color = <&color_battery_amber>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - color-0 { - led-color = <&color_battery_off>; - }; - }; - - /* Magikarp LED bat error */ - bat-power-state-error { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_battery_amber>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <1000>; - }; - }; - - bat-power-state-error-s3 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-error-s5 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_battery_off>; - }; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - /* Overwrite Power LED white to off */ - color_power_white: color-power-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 0>; - }; - }; -}; diff --git a/zephyr/projects/corsola/led_steelix.dts b/zephyr/projects/corsola/led_steelix.dts deleted file mode 100644 index 6a25929327..0000000000 --- a/zephyr/projects/corsola/led_steelix.dts +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - led_battery_red: ec_led1_odl { - pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - led_battery_green: ec_led2_odl { - pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - led_power_white: ec_led3_odl { - pwms = <&pwm4 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; -}; - -/* Red LED */ -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -/* Green LED */ -&pwm1_gpc2 { - drive-open-drain; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -/* White LED */ -&pwm4_gpb6 { - drive-open-drain; -}; - -&pwm4 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm4_gpb6>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/corsola/led_tentacruel.dts b/zephyr/projects/corsola/led_tentacruel.dts deleted file mode 100644 index 5569a956f6..0000000000 --- a/zephyr/projects/corsola/led_tentacruel.dts +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "led_it81202_base.dtsi" - -/ { - led_colors: led-colors { - compatible = "cros-ec,led-policy"; - - /* Tentacruel LED bat charge */ - bat-power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = ; - color-0 { - led-color = <&color_battery_amber>; - }; - }; - - bat-power-state-charge-near-full { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) - BATTERY_LEVEL_FULL>; - color-0 { - led-color = <&color_battery_white>; - }; - }; - - /* Tentacruel LED bat discharge */ - bat-power-state-discharge { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= 11%, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_battery_white>; - }; - }; - - bat-power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - color-0 { - led-color = <&color_battery_off>; - }; - }; - - /* Tentacruel LED bat error */ - bat-power-state-error { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_battery_amber>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <1000>; - }; - }; - - bat-power-state-error-s3 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-error-s5 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_battery_off>; - }; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - /* Overwrite Power LED white to off */ - color_power_white: color-power-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 0>; - }; - }; -}; diff --git a/zephyr/projects/corsola/motionsense_kingler.dts b/zephyr/projects/corsola/motionsense_kingler.dts deleted file mode 100644 index a7f674e01f..0000000000 --- a/zephyr/projects/corsola/motionsense_kingler.dts +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * Kingler and Steelix use the same dts, take care of this when modify it. - */ - -#include - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - base_mutex: base-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - (-1) 0 0 - 0 0 (-1)>; - }; - base_rot_ref: base-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma4xx_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <0>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_base_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/corsola/motionsense_krabby.dts b/zephyr/projects/corsola/motionsense_krabby.dts deleted file mode 100644 index 1c7d5b2df4..0000000000 --- a/zephyr/projects/corsola/motionsense_krabby.dts +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - icm42607-int = &base_accel; - lis2dw12-int = &lid_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: icm42607-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - icm42607_data: icm42607-drv-data { - compatible = "cros-ec,drvdata-icm42607"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,icm42607-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,icm42607-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_base_imu &int_lid_imu>; - }; -}; diff --git a/zephyr/projects/corsola/motionsense_magikarp.dts b/zephyr/projects/corsola/motionsense_magikarp.dts deleted file mode 100644 index 92e73bd2c6..0000000000 --- a/zephyr/projects/corsola/motionsense_magikarp.dts +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - icm42607-int = &base_accel; - lis2dw12-int = &lid_accel; - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: icm42607-mutex { - }; - - base_mutex_bmi323: bmi323-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref_bmi: base-rotation-ref-bmi { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - icm42607_data: icm42607-drv-data { - compatible = "cros-ec,drvdata-icm42607"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - - bmi323_data: bmi323-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,icm42607-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,icm42607-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - }; - }; - - motionsense-sensor-alt { - alt_base_accel: alt-base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_bmi>; - drv-data = <&bmi323_data>; - alternate-for = <&base_accel>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_bmi>; - drv-data = <&bmi323_data>; - alternate-for = <&base_gyro>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_base_imu &int_lid_imu>; - }; -}; diff --git a/zephyr/projects/corsola/motionsense_steelix.dts b/zephyr/projects/corsola/motionsense_steelix.dts deleted file mode 100644 index df96fc2e42..0000000000 --- a/zephyr/projects/corsola/motionsense_steelix.dts +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/* inherit the rot_ref from Kingler and overwrite it */ -&lid_rot_ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; -}; - -&base_rot_ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; -}; - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - lsm6dsm-int = &base_accel; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - base_rot_ref_lsm6dsm: base-rotation-ref-lsm6dsm { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - lsm6dsm_data_accel: lsm6dsm-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dsm"; - status = "okay"; - }; - lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dsm"; - status = "okay"; - }; - }; - - motionsense-sensor-alt { - alt_lid_accel: alt-lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; - alternate-for = <&lid_accel>; - alternate-ssfc-indicator = <&lid_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_accel: alt-base-accel { - compatible = "cros-ec,lsm6dsm-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_lsm6dsm>; - drv-data = <&lsm6dsm_data_accel>; - alternate-for = <&base_accel>; - alternate-ssfc-indicator = <&base_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <0>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,lsm6dsm-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_lsm6dsm>; - default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ - drv-data = <&lsm6dsm_data_gyro>; - alternate-for = <&base_gyro>; - alternate-ssfc-indicator = <&base_sensor_1>; - }; - }; -}; diff --git a/zephyr/projects/corsola/motionsense_tentacruel.dts b/zephyr/projects/corsola/motionsense_tentacruel.dts deleted file mode 100644 index 68b2c023df..0000000000 --- a/zephyr/projects/corsola/motionsense_tentacruel.dts +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - icm42607-int = &base_accel; - lis2dw12-int = &lid_accel; - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: icm42607-mutex { - }; - - base_mutex_bmi323: bmi323-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref_bmi: base-rotation-ref-bmi { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - icm42607_data: icm42607-drv-data { - compatible = "cros-ec,drvdata-icm42607"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - - bmi323_data: bmi323-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,icm42607-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,icm42607-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - }; - }; - - motionsense-sensor-alt { - alt_base_accel: alt-base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_bmi>; - drv-data = <&bmi323_data>; - alternate-for = <&base_accel>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_bmi>; - drv-data = <&bmi323_data>; - alternate-for = <&base_gyro>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_base_imu &int_lid_imu>; - }; -}; diff --git a/zephyr/projects/corsola/npcx_keyboard.dts b/zephyr/projects/corsola/npcx_keyboard.dts deleted file mode 100644 index f9e46de1f2..0000000000 --- a/zephyr/projects/corsola/npcx_keyboard.dts +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/corsola/power_signal.dts b/zephyr/projects/corsola/power_signal.dts deleted file mode 100644 index 181d7cf96e..0000000000 --- a/zephyr/projects/corsola/power_signal.dts +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - power_signal_list: power-signal-list { - compatible = "mt8186,power-signal-list"; - ap_in_rst { - power-enum-name = "AP_IN_RST"; - power-gpio-pin = <&ap_sysrst_odl_r>; - }; - ap_in_s3 { - power-enum-name = "AP_IN_S3"; - power-gpio-pin = <&ap_in_sleep_l>; - }; - ap_wdt_asserted { - power-enum-name = "AP_WDT_ASSERTED"; - power-gpio-pin = <&ap_ec_wdtrst_l>; - }; - ap_warm_rst_req { - power-enum-name = "AP_WARM_RST_REQ"; - power-gpio-pin = <&ap_ec_warm_rst_req>; - }; - }; -}; diff --git a/zephyr/projects/corsola/prj.conf b/zephyr/projects/corsola/prj.conf deleted file mode 100644 index 110b91bbbb..0000000000 --- a/zephyr/projects/corsola/prj.conf +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# - -# http://google3/hardware/standards/usb/ -CONFIG_PLATFORM_EC_USB_PID=0x505C - -# CROS EC -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_SHIMMED_TASKS=y - -# AP SoC configuration -CONFIG_AP=y -CONFIG_AP_ARM_MTK_MT8186=y - -# Variant config -CONFIG_VARIANT_CORSOLA_DB_DETECTION=y - -# Shell features -CONFIG_KERNEL_SHELL=y -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y - -# CBI -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y -CONFIG_PLATFORM_EC_CBI_EEPROM=y - -# I2C -CONFIG_I2C=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y - -# MKBP -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - -# EFS2 -CONFIG_PLATFORM_EC_VBOOT_EFS2=y - -# USB -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK=y - -# USB-C -CONFIG_PLATFORM_EC_USBC=y -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_PD_DPS=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_FRS=y - -# Power Seq -CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y - -# Optional features -CONFIG_FLASH_SHELL=n - -# EEPROM -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y - -# Host Commands -CONFIG_PLATFORM_EC_HOSTCMD=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=9000 -CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y -CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y - -# Charger -CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y -CONFIG_PLATFORM_EC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGE_MANAGER=y - -# Button -CONFIG_PLATFORM_EC_CMD_BUTTON=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y diff --git a/zephyr/projects/corsola/prj_it81202_base.conf b/zephyr/projects/corsola/prj_it81202_base.conf deleted file mode 100644 index 04283bcf5c..0000000000 --- a/zephyr/projects/corsola/prj_it81202_base.conf +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Bring up options -CONFIG_SHELL_HISTORY_BUFFER=256 -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y -CONFIG_PLATFORM_EC_BRINGUP=y - -# Power Sequencing -CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y - -# Lid Switch -CONFIG_PLATFORM_EC_LID_SWITCH=y - -# Charger -CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_RT9490=y -CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -# BOARD_RS2 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -# BOARD_RS1 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y - -# Host Commands -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y -CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# Sensors -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 - -# Sensor Drivers -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y -CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=y -CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=y - -# Tasks -CONFIG_TASK_CHARGER_STACK_SIZE=1024 -CONFIG_TASK_CHIPSET_STACK_SIZE=1440 -CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024 -CONFIG_TASK_PD_STACK_SIZE=1280 - -# USB-A -CONFIG_PLATFORM_EC_USBA=y - -# USB-C -CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n -CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y -CONFIG_PLATFORM_EC_USB_MUX_IT5205=y -CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y -CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n -CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0 -CONFIG_PLATFORM_EC_USB_PD_PULLUP=1 - -CONFIG_PLATFORM_EC_SHA256_UNROLLED=y - -# TODO(b/180980668): bring these features up -CONFIG_LTO=n -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n diff --git a/zephyr/projects/corsola/prj_kingler.conf b/zephyr/projects/corsola/prj_kingler.conf deleted file mode 100644 index d7de991e93..0000000000 --- a/zephyr/projects/corsola/prj_kingler.conf +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_KINGLER=y - -# LED -CONFIG_PLATFORM_EC_LED_PWM=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/projects/corsola/prj_krabby.conf b/zephyr/projects/corsola/prj_krabby.conf deleted file mode 100644 index c4cde05c16..0000000000 --- a/zephyr/projects/corsola/prj_krabby.conf +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_KRABBY=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/projects/corsola/prj_magikarp.conf b/zephyr/projects/corsola/prj_magikarp.conf deleted file mode 100644 index a5ec9ede3b..0000000000 --- a/zephyr/projects/corsola/prj_magikarp.conf +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_MAGIKARP=y - -# USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n -CONFIG_PLATFORM_EC_USB_MUX_PS8743=y -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y - -# Sensor -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y diff --git a/zephyr/projects/corsola/prj_npcx993_base.conf b/zephyr/projects/corsola/prj_npcx993_base.conf deleted file mode 100644 index 0642bcd331..0000000000 --- a/zephyr/projects/corsola/prj_npcx993_base.conf +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - - -# Bring up options -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# Debug options and features; can be disabled to save memory or once bringup -# is complete. -CONFIG_SHELL_MINIMAL=n -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y - -# ADC -CONFIG_ADC=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y - -# Math -CONFIG_PLATFORM_EC_MATH_UTIL=y - -# Power sequencing -CONFIG_PLATFORM_EC_POWERSEQ_MT8186=y -CONFIG_PLATFORM_EC_POWERSEQ_S4=n - -# Button -CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y - -# Sensors -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y - -# USBA -CONFIG_PLATFORM_EC_USBA=y - -# USBC -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n -CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY=15000 -CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY=15000 -CONFIG_PLATFORM_EC_USBC_PPC=y -CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y -CONFIG_PLATFORM_EC_USBC_PPC_RT1718S=y -CONFIG_PLATFORM_EC_USB_MUX_PS8743=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2 -CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447_AUX_PU_PD=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y - -# External power -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n - -# Keyboard -CONFIG_CROS_KB_RAW_NPCX=y -CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y - -CONFIG_SYSCON=y - -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n diff --git a/zephyr/projects/corsola/prj_steelix.conf b/zephyr/projects/corsola/prj_steelix.conf deleted file mode 100644 index 16f622989f..0000000000 --- a/zephyr/projects/corsola/prj_steelix.conf +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_STEELIX=y - -# steelix only use D2, drop the workaround config for H1 -CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n - -# Motion sensor -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM=y -CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y - -# USBC -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250 -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 - -# Remove bring up options for FW QUAL -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n - -# Remove debug options and features for FW QUAL -CONFIG_LOG=n -CONFIG_LOG_MODE_MINIMAL=n -CONFIG_SHELL_MINIMAL=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=0 - -# AC_OK debounce time -CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 diff --git a/zephyr/projects/corsola/prj_tentacruel.conf b/zephyr/projects/corsola/prj_tentacruel.conf deleted file mode 100644 index 71cc9d9694..0000000000 --- a/zephyr/projects/corsola/prj_tentacruel.conf +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_TENTACRUEL=y - -# USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n -CONFIG_PLATFORM_EC_USB_MUX_PS8743=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y - -# Sensor -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y - -# Battery -CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/projects/corsola/src/board.c b/zephyr/projects/corsola/src/board.c deleted file mode 100644 index 93a2443191..0000000000 --- a/zephyr/projects/corsola/src/board.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "console.h" -#include "hooks.h" -#include "typec_control.h" -#include "usb_dp_alt_mode.h" -#include "usb_mux.h" -#include "usb_pd.h" -#include "usbc_ppc.h" - -#include "baseboard_usbc_config.h" - -#define CPRINTS(format, args...) cprints(CC_USB, format, ##args) - -static void ccd_interrupt_deferred(void) -{ - /* - * If CCD_MODE_ODL asserts, it means there's a debug accessory connected - * and we should enable the SBU FETs. - */ - typec_set_sbu(CONFIG_CCD_USBC_PORT_NUMBER, 1); - - /* Mux DP AUX away when CCD enabled to prevent the AUX channel - * interferes the SBU pins. - */ - CPRINTS("CCD Enabled, mux DP_AUX_PATH_SEL to 1"); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), 1); -} -DECLARE_DEFERRED(ccd_interrupt_deferred); - -void ccd_interrupt(enum gpio_signal signal) -{ - hook_call_deferred(&ccd_interrupt_deferred_data, 0); -} diff --git a/zephyr/projects/corsola/src/board_chipset.c b/zephyr/projects/corsola/src/board_chipset.c deleted file mode 100644 index 54e96bc631..0000000000 --- a/zephyr/projects/corsola/src/board_chipset.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Corsola baseboard-chipset specific configuration */ - -#include -#include -#include -#include "gpio.h" - -static void board_backlight_handler(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - int value; - - switch (data.event) { - default: - return; - - case AP_POWER_RESUME: - /* Called on AP S3 -> S0 transition */ - value = 1; - break; - - case AP_POWER_SUSPEND: - /* Called on AP S0 -> S3 transition */ - value = 0; - break; - } - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_bl_en_od), value); -} - -static int install_backlight_handler(const struct device *unused) -{ - static struct ap_power_ev_callback cb; - - /* - * Add a callback for suspend/resume to - * control the keyboard backlight. - */ - ap_power_ev_init_callback(&cb, board_backlight_handler, - AP_POWER_RESUME | AP_POWER_SUSPEND); - ap_power_ev_add_callback(&cb); - return 0; -} - -SYS_INIT(install_backlight_handler, APPLICATION, 1); diff --git a/zephyr/projects/corsola/src/hibernate.c b/zephyr/projects/corsola/src/hibernate.c deleted file mode 100644 index 56c085e077..0000000000 --- a/zephyr/projects/corsola/src/hibernate.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include - -#include "charger.h" -#include "driver/charger/isl923x_public.h" -#include "system.h" - -/* Corsola board specific hibernate implementation */ -__override void board_hibernate(void) -{ -#ifdef CONFIG_CHARGER_ISL9238C - isl9238c_hibernate(CHARGER_SOLO); -#endif -} - -__override void board_hibernate_late(void) -{ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_ulp), 1); -} diff --git a/zephyr/projects/corsola/src/kingler/board_steelix.c b/zephyr/projects/corsola/src/kingler/board_steelix.c deleted file mode 100644 index 8b88a6d7c7..0000000000 --- a/zephyr/projects/corsola/src/kingler/board_steelix.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Board re-init for Rusty board - * Rusty shares the firmware with Steelix. - * Steelix is convertible but Rusty is clamshell - * so some functions should be disabled for clamshell. - */ -#include -#include - -#include "accelgyro.h" -#include "common.h" -#include "cros_cbi.h" -#include "driver/accelgyro_bmi3xx.h" -#include "driver/accelgyro_lsm6dsm.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "motion_sense.h" -#include "motionsense_sensors.h" -#include "tablet_mode.h" - -LOG_MODULE_REGISTER(board_init, LOG_LEVEL_ERR); - -static bool board_is_clamshell; - -static void board_setup_init(void) -{ - int ret; - uint32_t val; - - ret = cros_cbi_get_fw_config(FORM_FACTOR, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR); - return; - } - if (val == CLAMSHELL) { - board_is_clamshell = true; - motion_sensor_count = 0; - gmr_tablet_switch_disable(); - } -} -DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_PRE_DEFAULT); - -static void disable_base_imu_irq(void) -{ - if (board_is_clamshell) { - gpio_disable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_base_imu)); - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(base_imu_int_l), - GPIO_INPUT | GPIO_PULL_UP); - } -} -DECLARE_HOOK(HOOK_INIT, disable_base_imu_irq, HOOK_PRIO_POST_DEFAULT); - -static bool base_use_alt_sensor; - -void motion_interrupt(enum gpio_signal signal) -{ - if (base_use_alt_sensor) { - lsm6dsm_interrupt(signal); - } else { - bmi3xx_interrupt(signal); - } -} - -static void alt_sensor_init(void) -{ - base_use_alt_sensor = cros_cbi_ssfc_check_match( - CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); - - motion_sensors_check_ssfc(); -} -DECLARE_HOOK(HOOK_INIT, alt_sensor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/projects/corsola/src/kingler/button.c b/zephyr/projects/corsola/src/kingler/button.c deleted file mode 100644 index 920069bef6..0000000000 --- a/zephyr/projects/corsola/src/kingler/button.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* kingler button */ - -#include "button.h" -#include "cros_board_info.h" -#include "gpio.h" -#include "hooks.h" - -static void buttons_hook(void) -{ - int version; - - if (cbi_get_board_version(&version)) { - return; - } - - /* b:219891339: drop this workaround when we deprecate rev0 */ - if (version == 0) { - /* swap VOLUP/VOLDN */ - button_reassign_gpio(BUTTON_VOLUME_DOWN, GPIO_VOLUME_UP_L); - button_reassign_gpio(BUTTON_VOLUME_UP, GPIO_VOLUME_DOWN_L); - /* - * button_reassign_gpio will disable the old button interrupt - * and then enable the new button interrupt which cause the - * GPIO_VOLUME_UP_L interrupt disabled after we reassign - * BUTTON_VOLUME_UP, so we need to re-enable it here. - */ - gpio_enable_interrupt(GPIO_VOLUME_UP_L); - } -} -DECLARE_HOOK(HOOK_INIT, buttons_hook, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/corsola/src/kingler/i2c.c b/zephyr/projects/corsola/src/kingler/i2c.c deleted file mode 100644 index f2bbff3749..0000000000 --- a/zephyr/projects/corsola/src/kingler/i2c.c +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * 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 and Steelix board specific i2c implementation */ - -#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED -int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) -{ - return (i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) || - i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_EEPROM) || - i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_USB_C0)); -} -#endif diff --git a/zephyr/projects/corsola/src/kingler/led.c b/zephyr/projects/corsola/src/kingler/led.c deleted file mode 100644 index 4e2c5b12fb..0000000000 --- a/zephyr/projects/corsola/src/kingler/led.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery LED control for Kingler - */ -#include "common.h" -#include "ec_commands.h" -#include "led_common.h" -#include "led_onoff_states.h" -#include "led_pwm.h" - -__override const int led_charge_lvl_1 = 5; -__override const int led_charge_lvl_2 = 97; -__override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, - LED_INDEFINITE } }, - [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, - 1 * LED_ONE_SEC }, - { LED_OFF, 3 * LED_ONE_SEC } }, - [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, - { EC_LED_COLOR_GREEN, - 2 * LED_ONE_SEC } }, - }; - -__override void led_set_color_battery(enum ec_led_colors color) -{ - switch (color) { - case EC_LED_COLOR_RED: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_RED); - break; - case EC_LED_COLOR_GREEN: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_GREEN); - break; - case EC_LED_COLOR_AMBER: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); - break; - default: /* LED_OFF and other unsupported colors */ - set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); - break; - } -} diff --git a/zephyr/projects/corsola/src/kingler/led_steelix.c b/zephyr/projects/corsola/src/kingler/led_steelix.c deleted file mode 100644 index 87b76128e8..0000000000 --- a/zephyr/projects/corsola/src/kingler/led_steelix.c +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery LED control for Steelix - */ - -#include -#include - -#include "board_led.h" -#include "common.h" -#include "cros_cbi.h" -#include "led_common.h" -#include "led_onoff_states.h" -#include "util.h" - -LOG_MODULE_REGISTER(board_led, LOG_LEVEL_ERR); - -#define BOARD_LED_PWM_PERIOD_NS BOARD_LED_HZ_TO_PERIOD_NS(100) - -static const struct board_led_pwm_dt_channel board_led_battery_red = - BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_red)); -static const struct board_led_pwm_dt_channel board_led_battery_green = - BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_green)); -static const struct board_led_pwm_dt_channel board_led_power_white = - BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_power_white)); - -__override const int led_charge_lvl_1 = 5; -__override const int led_charge_lvl_2 = 97; -__override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, - LED_INDEFINITE } }, - [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S0_BAT_LOW] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, - { EC_LED_COLOR_GREEN, - 2 * LED_ONE_SEC } }, - }; - -__override const struct led_descriptor - led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { - [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, - [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, - 3 * LED_ONE_SEC }, - { LED_OFF, 0.5 * LED_ONE_SEC } }, - [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, - 3 * LED_ONE_SEC }, - { LED_OFF, - 0.5 * LED_ONE_SEC } }, - [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, - }; - -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_BATTERY_LED, - EC_LED_ID_POWER_LED, -}; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -static void board_led_pwm_set_duty(const struct board_led_pwm_dt_channel *ch, - int percent) -{ - uint32_t pulse_ns; - int rv; - - if (!device_is_ready(ch->dev)) { - LOG_ERR("PWM device %s not ready", ch->dev->name); - return; - } - - pulse_ns = DIV_ROUND_NEAREST(BOARD_LED_PWM_PERIOD_NS * percent, 100); - - LOG_DBG("Board LED PWM %s set percent (%d), pulse %d", ch->dev->name, - percent, pulse_ns); - - rv = pwm_set(ch->dev, ch->channel, BOARD_LED_PWM_PERIOD_NS, pulse_ns, - ch->flags); - if (rv) { - LOG_ERR("pwm_set() failed %s (%d)", ch->dev->name, rv); - } -} - -static bool device_is_clamshell(void) -{ - int ret; - uint32_t val; - - ret = cros_cbi_get_fw_config(FORM_FACTOR, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR); - return false; - } - - return val == CLAMSHELL; -} - -__override void led_set_color_battery(enum ec_led_colors color) -{ - switch (color) { - case EC_LED_COLOR_RED: - board_led_pwm_set_duty(&board_led_battery_red, 100); - board_led_pwm_set_duty(&board_led_battery_green, 0); - break; - case EC_LED_COLOR_GREEN: - board_led_pwm_set_duty(&board_led_battery_red, 0); - board_led_pwm_set_duty(&board_led_battery_green, 100); - break; - case EC_LED_COLOR_AMBER: - board_led_pwm_set_duty(&board_led_battery_red, 100); - board_led_pwm_set_duty(&board_led_battery_green, 20); - break; - default: /* LED_OFF and other unsupported colors */ - board_led_pwm_set_duty(&board_led_battery_red, 0); - board_led_pwm_set_duty(&board_led_battery_green, 0); - break; - } -} - -__override void led_set_color_power(enum ec_led_colors color) -{ - if (device_is_clamshell()) { - board_led_pwm_set_duty(&board_led_power_white, 0); - } else { - switch (color) { - case EC_LED_COLOR_WHITE: - board_led_pwm_set_duty(&board_led_power_white, 100); - break; - default: - board_led_pwm_set_duty(&board_led_power_white, 0); - break; - } - } -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - if (led_id == EC_LED_ID_BATTERY_LED) { - brightness_range[EC_LED_COLOR_RED] = 1; - brightness_range[EC_LED_COLOR_GREEN] = 1; - brightness_range[EC_LED_COLOR_AMBER] = 1; - } else if (led_id == EC_LED_ID_POWER_LED) { - if (device_is_clamshell()) { - brightness_range[EC_LED_COLOR_WHITE] = 0; - } else { - brightness_range[EC_LED_COLOR_WHITE] = 1; - } - } -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - if (led_id == EC_LED_ID_BATTERY_LED) { - if (brightness[EC_LED_COLOR_RED] != 0) { - led_set_color_battery(EC_LED_COLOR_RED); - } else if (brightness[EC_LED_COLOR_GREEN] != 0) { - led_set_color_battery(EC_LED_COLOR_GREEN); - } else if (brightness[EC_LED_COLOR_AMBER] != 0) { - led_set_color_battery(EC_LED_COLOR_AMBER); - } else { - led_set_color_battery(LED_OFF); - } - } else if (led_id == EC_LED_ID_POWER_LED) { - if (brightness[EC_LED_COLOR_WHITE] != 0) { - led_set_color_power(EC_LED_COLOR_WHITE); - } else { - led_set_color_power(LED_OFF); - } - } - - return EC_SUCCESS; -} diff --git a/zephyr/projects/corsola/src/kingler/usb_pd_policy.c b/zephyr/projects/corsola/src/kingler/usb_pd_policy.c deleted file mode 100644 index 3de2857ad1..0000000000 --- a/zephyr/projects/corsola/src/kingler/usb_pd_policy.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "charge_manager.h" -#include "console.h" -#include "driver/ppc/rt1718s.h" -#include "system.h" -#include "usb_mux.h" -#include "usb_pd.h" -#include "usbc_ppc.h" -#include "util.h" - -#include "baseboard_usbc_config.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -void pd_power_supply_reset(int port) -{ - int prev_en; - - prev_en = ppc_is_sourcing_vbus(port); - - if (port == USBC_PORT_C1) { - rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 0); - } - - /* Disable VBUS. */ - ppc_vbus_source_enable(port, 0); - - /* Enable discharge if we were previously sourcing 5V */ - if (prev_en) { - pd_set_vbus_discharge(port, 1); - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - /* Disable charging. */ - rv = ppc_vbus_sink_enable(port, 0); - if (rv) { - return rv; - } - - pd_set_vbus_discharge(port, 0); - - /* Provide Vbus. */ - if (port == USBC_PORT_C1) { - rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 1); - } - - rv = ppc_vbus_source_enable(port, 1); - if (rv) { - return rv; - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -int pd_snk_is_vbus_provided(int port) -{ - /* TODO: use ADC? */ - return tcpm_check_vbus_level(port, VBUS_PRESENT); -} diff --git a/zephyr/projects/corsola/src/kingler/usbc_config.c b/zephyr/projects/corsola/src/kingler/usbc_config.c deleted file mode 100644 index 7531904c4a..0000000000 --- a/zephyr/projects/corsola/src/kingler/usbc_config.c +++ /dev/null @@ -1,318 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Kingler board-specific USB-C configuration */ - -#include "charger.h" -#include "console.h" -#include "driver/bc12/pi3usb9201_public.h" -#include "driver/charger/isl923x_public.h" -#include "driver/ppc/nx20p348x.h" -#include "driver/ppc/rt1718s.h" -#include "driver/tcpm/anx7447.h" -#include "driver/tcpm/rt1718s.h" -#include "driver/usb_mux/ps8743.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "timer.h" -#include "usb_charge.h" -#include "usb_mux.h" -#include "usb_pd_tcpm.h" -#include "usbc_ppc.h" - -#include "baseboard_usbc_config.h" -#include "variant_db_detection.h" - -/* TODO(b/220196310): Create GPIO driver for RT17181S TCPC */ -#ifdef __REQUIRE_ZEPHYR_GPIOS__ -#undef __REQUIRE_ZEPHYR_GPIOS__ -#endif -#include "gpio.h" - -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) - -/* USB Mux */ - -/* USB Mux C1 : board_init of PS8743 */ -int ps8743_mux_1_board_init(const struct usb_mux *me) -{ - ps8743_tune_usb_eq(me, PS8743_USB_EQ_TX_3_6_DB, - PS8743_USB_EQ_RX_16_0_DB); - - return EC_SUCCESS; -} - -void board_usb_mux_init(void) -{ - if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { - /* Disable DCI function. This is not needed for ARM. */ - ps8743_field_update(usb_muxes[1].mux, PS8743_REG_DCI_CONFIG_2, - PS8743_AUTO_DCI_MODE_MASK, - PS8743_AUTO_DCI_MODE_FORCE_USB); - } -} -DECLARE_HOOK(HOOK_INIT, board_usb_mux_init, HOOK_PRIO_INIT_I2C + 1); - -void board_tcpc_init(void) -{ - /* Only reset TCPC if not sysjump */ - if (!system_jumped_late()) { - /* TODO(crosbug.com/p/61098): How long do we need to wait? */ - board_reset_pd_mcu(); - } - - /* Enable TCPC interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); - if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { - gpio_enable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc)); - } - - /* Enable BC1.2 interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); - - /* - * Initialize HPD to low; after sysjump SOC needs to see - * HPD pulse to enable video path - */ - for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) { - usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); - } -} -DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C); - -__override int board_rt1718s_init(int port) -{ - static bool gpio_initialized; - - if (!system_jumped_late() && !gpio_initialized) { - /* set GPIO 1~3 as push pull, as output, output low. */ - rt1718s_gpio_set_flags(port, RT1718S_GPIO1, GPIO_OUT_LOW); - rt1718s_gpio_set_flags(port, RT1718S_GPIO2, GPIO_OUT_LOW); - rt1718s_gpio_set_flags(port, RT1718S_GPIO3, GPIO_OUT_LOW); - gpio_initialized = true; - } - - /* gpio1 low, gpio2 output high when receiving frs signal */ - RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO1_VBUS_CTRL, - RT1718S_GPIO1_VBUS_CTRL_FRS_RX_VBUS, - 0)); - RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO2_VBUS_CTRL, - RT1718S_GPIO2_VBUS_CTRL_FRS_RX_VBUS, - 0xFF)); - - /* Trigger GPIO 1/2 change when FRS signal received */ - RETURN_ERROR(rt1718s_update_bits8( - port, RT1718S_FRS_CTRL3, - RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 | - RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1, - RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 | - RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1)); - /* Set FRS signal detect time to 46.875us */ - RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_FRS_CTRL1, - RT1718S_FRS_CTRL1_FRSWAPRX_MASK, - 0xFF)); - - /* Disable BC1.2 SRC mode */ - RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_RT2_BC12_SRC_FUNC, - RT1718S_RT2_BC12_SRC_FUNC_BC12_SRC_EN, - 0)); - - return EC_SUCCESS; -} - -__override int board_rt1718s_set_frs_enable(int port, int enable) -{ - if (port == USBC_PORT_C1) - /* - * Use set_flags (implemented by a single i2c write) instead - * of set_level (= i2c_update) to save one read operation in - * FRS path. - */ - rt1718s_gpio_set_flags(port, GPIO_EN_USB_C1_FRS, - enable ? GPIO_OUT_HIGH : GPIO_OUT_LOW); - return EC_SUCCESS; -} - -void board_reset_pd_mcu(void) -{ - CPRINTS("Resetting TCPCs..."); - /* reset C0 ANX3447 */ - /* Assert reset */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst), 1); - msleep(1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst), 0); - /* After TEST_R release, anx7447/3447 needs 2ms to finish eFuse - * loading. - */ - msleep(2); - - /* reset C1 RT1718s */ - rt1718s_sw_reset(USBC_PORT_C1); -} - -/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */ -int board_vbus_source_enabled(int port) -{ - return ppc_is_sourcing_vbus(port); -} - -__override int board_rt1718s_set_snk_enable(int port, int enable) -{ - if (port == USBC_PORT_C1) { - rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SINK, enable); - } - - return EC_SUCCESS; -} - -int board_set_active_charge_port(int port) -{ - int i; - bool is_valid_port = - (port >= 0 && port < board_get_adjusted_usb_pd_port_count()); - /* adjust the actual port count when not the type-c db connected. */ - - if (!is_valid_port && port != CHARGE_PORT_NONE) { - return EC_ERROR_INVAL; - } - - if (port == CHARGE_PORT_NONE) { - CPRINTS("Disabling all charger ports"); - - /* Disable all ports. */ - for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { - /* - * Do not return early if one fails otherwise we can - * get into a boot loop assertion failure. - */ - if (ppc_vbus_sink_enable(i, 0)) { - CPRINTS("Disabling C%d as sink failed.", i); - } - } - - return EC_SUCCESS; - } - - /* Check if the port is sourcing VBUS. */ - if (ppc_is_sourcing_vbus(port)) { - CPRINTS("Skip enable C%d", port); - return EC_ERROR_INVAL; - } - - CPRINTS("New charge port: C%d", port); - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { - if (i == port) { - continue; - } - - if (ppc_vbus_sink_enable(i, 0)) { - CPRINTS("C%d: sink path disable failed.", i); - } - } - - /* Enable requested charge port. */ - if (ppc_vbus_sink_enable(port, 1)) { - CPRINTS("C%d: sink path enable failed.", port); - return EC_ERROR_UNKNOWN; - } - - return EC_SUCCESS; -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - - if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) { - if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst))) { - status |= PD_STATUS_TCPC_ALERT_0; - } - } - - if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) { - return status |= PD_STATUS_TCPC_ALERT_1; - } - return status; -} - -void tcpc_alert_event(enum gpio_signal signal) -{ - int port; - - switch (signal) { - case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_tcpc_int_odl)): - port = 0; - break; - case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_tcpc_int_odl)): - port = 1; - break; - default: - return; - } - - schedule_deferred_pd_interrupt(port); -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_ppc_int_odl)): - ppc_chips[0].drv->interrupt(0); - break; - case GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl)): - ppc_chips[1].drv->interrupt(1); - break; - default: - break; - } -} - -void bc12_interrupt(enum gpio_signal signal) -{ - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); -} - -__override int board_get_vbus_voltage(int port) -{ - int voltage = 0; - int rv; - - switch (port) { - case USBC_PORT_C0: - rv = tcpc_config[USBC_PORT_C0].drv->get_vbus_voltage(port, - &voltage); - if (rv) - return 0; - break; - case USBC_PORT_C1: - rt1718s_get_adc(port, RT1718S_ADC_VBUS1, &voltage); - break; - default: - return 0; - } - return voltage; -} - -__override int board_nx20p348x_init(int port) -{ - int rv; - - rv = i2c_update8(ppc_chips[port].i2c_port, - ppc_chips[port].i2c_addr_flags, - NX20P348X_DEVICE_CONTROL_REG, NX20P348X_CTRL_LDO_SD, - MASK_SET); - return rv; -} diff --git a/zephyr/projects/corsola/src/krabby/charger_workaround.c b/zephyr/projects/corsola/src/krabby/charger_workaround.c deleted file mode 100644 index d7fd05cc00..0000000000 --- a/zephyr/projects/corsola/src/krabby/charger_workaround.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "charger.h" -#include "driver/charger/rt9490.h" -#include "hooks.h" -#include "i2c.h" -#include "system.h" - -/* - * This workaround and the board id checks only apply to krabby and early - * tentacruel devices. - * Newer project should have all of these fixed. - */ -BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_KRABBY) || - IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST)); - -/* b/194967754#comment5: work around for IBUS ADC unstable issue */ -static void ibus_adc_workaround(void) -{ - if (system_get_board_version() != 0) { - return; - } - - i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_SET); - - rt9490_enable_hidden_mode(CHARGER_SOLO, true); - /* undocumented registers... */ - i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x52, 0xC4); - - i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_CLR); - rt9490_enable_hidden_mode(CHARGER_SOLO, false); -} - -/* b/214880220#comment44: lock i2c at 400khz */ -static void i2c_speed_workaround(void) -{ - if (system_get_board_version() >= 3) { - return; - } - - rt9490_enable_hidden_mode(CHARGER_SOLO, true); - /* Set to Auto mode, default run at 400kHz */ - i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x71, 0x22); - /* Manually select for 400kHz, valid only when 0x71[7] == 1 */ - i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, 0xF7, 0x14); - rt9490_enable_hidden_mode(CHARGER_SOLO, false); -} - -static void eoc_deglitch_workaround(void) -{ - if (system_get_board_version() != 1) { - return; - } - - /* set end-of-charge deglitch time to 2ms */ - i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - RT9490_REG_ADD_CTRL0, RT9490_TD_EOC, MASK_CLR); -} - -static void disable_safety_timer(void) -{ - if (system_get_board_version() >= 2) { - return; - } - /* Disable charge timer */ - i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - RT9490_REG_SAFETY_TMR_CTRL, - RT9490_EN_TRICHG_TMR | RT9490_EN_PRECHG_TMR | - RT9490_EN_FASTCHG_TMR); -} - -static void board_rt9490_workaround(void) -{ - ibus_adc_workaround(); - i2c_speed_workaround(); - eoc_deglitch_workaround(); - disable_safety_timer(); -} -DECLARE_HOOK(HOOK_INIT, board_rt9490_workaround, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/corsola/src/krabby/hooks.c b/zephyr/projects/corsola/src/krabby/hooks.c deleted file mode 100644 index 1eb4f600f2..0000000000 --- a/zephyr/projects/corsola/src/krabby/hooks.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include -#include "charger.h" -#include "driver/charger/rt9490.h" -#include "extpower.h" -#include "gpio.h" -#include "hooks.h" - -#define I2C3_NODE DT_NODELABEL(i2c3) -PINCTRL_DT_DEFINE(I2C3_NODE); - -static void board_i2c3_ctrl(bool enable) -{ - if (DEVICE_DT_GET( - DT_GPIO_CTLR_BY_IDX(DT_NODELABEL(i2c3), scl_gpios, 0)) == - DEVICE_DT_GET(DT_NODELABEL(gpiof))) { - const struct pinctrl_dev_config *pcfg = - PINCTRL_DT_DEV_CONFIG_GET(I2C3_NODE); - - if (enable) { - pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT); - } else { - pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP); - } - } -} - -static void board_enable_i2c3(void) -{ - board_i2c3_ctrl(1); -} -DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_enable_i2c3, HOOK_PRIO_FIRST); - -static void board_disable_i2c3(void) -{ - board_i2c3_ctrl(0); -} -DECLARE_HOOK(HOOK_CHIPSET_HARD_OFF, board_disable_i2c3, HOOK_PRIO_LAST); - -static void board_suspend_handler(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - int value; - - switch (data.event) { - default: - return; - - case AP_POWER_RESUME: - value = 1; - break; - - case AP_POWER_SUSPEND: - value = 0; - break; - } - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_5v_usm), value); -} - -static int install_suspend_handler(const struct device *unused) -{ - static struct ap_power_ev_callback cb; - - /* - * Add a callback for suspend/resume. - */ - ap_power_ev_init_callback(&cb, board_suspend_handler, - AP_POWER_RESUME | AP_POWER_SUSPEND); - ap_power_ev_add_callback(&cb); - return 0; -} - -SYS_INIT(install_suspend_handler, APPLICATION, 1); - -static void board_hook_ac_change(void) -{ - if (system_get_board_version() >= 1) { - rt9490_enable_adc(CHARGER_SOLO, extpower_is_present()); - } -} -DECLARE_HOOK(HOOK_AC_CHANGE, board_hook_ac_change, HOOK_PRIO_DEFAULT); -DECLARE_HOOK(HOOK_INIT, board_hook_ac_change, HOOK_PRIO_LAST); diff --git a/zephyr/projects/corsola/src/krabby/i2c.c b/zephyr/projects/corsola/src/krabby/i2c.c deleted file mode 100644 index a83af77dbd..0000000000 --- a/zephyr/projects/corsola/src/krabby/i2c.c +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * 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" - -/* Krabby board specific i2c implementation */ - -#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED -int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) -{ - return (i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) || - i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_EEPROM)); -} -#endif diff --git a/zephyr/projects/corsola/src/krabby/keyboard_magikarp.c b/zephyr/projects/corsola/src/krabby/keyboard_magikarp.c deleted file mode 100644 index bcb706bba3..0000000000 --- a/zephyr/projects/corsola/src/krabby/keyboard_magikarp.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config magikarp_kb_legacy = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &magikarp_kb_legacy; -} diff --git a/zephyr/projects/corsola/src/krabby/ppc_krabby.c b/zephyr/projects/corsola/src/krabby/ppc_krabby.c deleted file mode 100644 index d4f574a725..0000000000 --- a/zephyr/projects/corsola/src/krabby/ppc_krabby.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Krabby PPC/BC12 (RT1739) configuration */ - -#include "baseboard_usbc_config.h" -#include "gpio/gpio_int.h" -#include "driver/ppc/rt1739.h" -#include "driver/ppc/syv682x.h" -#include "hooks.h" -#include "variant_db_detection.h" - -void c0_bc12_interrupt(enum gpio_signal signal) -{ - rt1739_interrupt(0); -} - -static void board_usbc_init(void) -{ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc_bc12)); -} -DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT); - -void ppc_interrupt(enum gpio_signal signal) -{ - if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) { - syv682x_interrupt(1); - } -} diff --git a/zephyr/projects/corsola/src/krabby/ppc_magikarp.c b/zephyr/projects/corsola/src/krabby/ppc_magikarp.c deleted file mode 100644 index 41cce3f73d..0000000000 --- a/zephyr/projects/corsola/src/krabby/ppc_magikarp.c +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Tentacruel PPC/BC12 (mixed RT1739 or PI3USB9201+SYV682X) configuration */ - -#include "baseboard_usbc_config.h" -#include "console.h" -#include "cros_board_info.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "usbc/ppc.h" -#include "variant_db_detection.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) - -void bc12_interrupt(enum gpio_signal signal) -{ - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); -} - -static void board_usbc_init(void) -{ - /* Enable PPC interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); - - /* Enable BC1.2 interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); -} -DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT); - -void ppc_interrupt(enum gpio_signal signal) -{ - if (signal == GPIO_SIGNAL(DT_NODELABEL(usb_c0_ppc_int_odl))) { - syv682x_interrupt(0); - } else if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) { - syv682x_interrupt(1); - } -} diff --git a/zephyr/projects/corsola/src/krabby/ppc_tentacruel.c b/zephyr/projects/corsola/src/krabby/ppc_tentacruel.c deleted file mode 100644 index 877b9940b4..0000000000 --- a/zephyr/projects/corsola/src/krabby/ppc_tentacruel.c +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Tentacruel PPC/BC12 (mixed RT1739 or PI3USB9201+SYV682X) configuration */ - -#include "baseboard_usbc_config.h" -#include "console.h" -#include "cros_board_info.h" -#include "driver/usb_mux/ps8743.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "usb_mux.h" -#include "usbc/ppc.h" -#include "variant_db_detection.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) - -LOG_MODULE_REGISTER(alt_dev_replacement); - -#define BOARD_VERSION_UNKNOWN 0xffffffff - -/* Check board version to decide which ppc/bc12 is used. */ -static bool board_has_syv_ppc(void) -{ - static uint32_t board_version = BOARD_VERSION_UNKNOWN; - - if (board_version == BOARD_VERSION_UNKNOWN) { - if (cbi_get_board_version(&board_version) != EC_SUCCESS) { - LOG_ERR("Failed to get board version."); - board_version = 0; - } - } - - return (board_version >= 3); -} - -static void check_alternate_devices(void) -{ - /* Configure the PPC driver */ - if (board_has_syv_ppc()) - /* Arg is the USB port number */ - PPC_ENABLE_ALTERNATE(0); -} -DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT); - -void bc12_interrupt(enum gpio_signal signal) -{ - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); -} - -/* USB Mux C1 : board_init of PS8743 */ -int ps8743_eq_c1_setting(void) -{ - ps8743_write(usb_muxes[1].mux, PS8743_REG_USB_EQ_RX, 0x90); - return EC_SUCCESS; -} - -static void board_usbc_init(void) -{ - if (board_has_syv_ppc()) { - /* Enable PPC interrupts. */ - gpio_enable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); - - /* Enable BC1.2 interrupts. */ - gpio_enable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); - } else { - gpio_enable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); - } -} -DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT); - -void ppc_interrupt(enum gpio_signal signal) -{ - if (signal == GPIO_SIGNAL(DT_NODELABEL(usb_c0_ppc_int_odl))) { - ppc_chips[0].drv->interrupt(0); - } - if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) { - ppc_chips[1].drv->interrupt(1); - } -} diff --git a/zephyr/projects/corsola/src/krabby/sensor_magikarp.c b/zephyr/projects/corsola/src/krabby/sensor_magikarp.c deleted file mode 100644 index 269bc26fae..0000000000 --- a/zephyr/projects/corsola/src/krabby/sensor_magikarp.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "accelgyro.h" -#include "cros_cbi.h" -#include "driver/accelgyro_bmi323.h" -#include "driver/accelgyro_icm42607.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -void motion_interrupt(enum gpio_signal signal) -{ - uint32_t val; - - cros_cbi_get_fw_config(FW_BASE_GYRO, &val); - if (val == FW_BASE_ICM42607) { - icm42607_interrupt(signal); - } else if (val == FW_BASE_BMI323) { - bmi3xx_interrupt(signal); - } -} - -static void motionsense_init(void) -{ - uint32_t val; - - cros_cbi_get_fw_config(FW_BASE_GYRO, &val); - if (val == FW_BASE_ICM42607) { - ccprints("BASE ACCEL is ICM42607"); - } else if (val == FW_BASE_BMI323) { - MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); - MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro); - ccprints("BASE ACCEL IS BMI323"); - } else { - ccprints("no motionsense"); - } -} -DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c b/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c deleted file mode 100644 index 269bc26fae..0000000000 --- a/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "accelgyro.h" -#include "cros_cbi.h" -#include "driver/accelgyro_bmi323.h" -#include "driver/accelgyro_icm42607.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -void motion_interrupt(enum gpio_signal signal) -{ - uint32_t val; - - cros_cbi_get_fw_config(FW_BASE_GYRO, &val); - if (val == FW_BASE_ICM42607) { - icm42607_interrupt(signal); - } else if (val == FW_BASE_BMI323) { - bmi3xx_interrupt(signal); - } -} - -static void motionsense_init(void) -{ - uint32_t val; - - cros_cbi_get_fw_config(FW_BASE_GYRO, &val); - if (val == FW_BASE_ICM42607) { - ccprints("BASE ACCEL is ICM42607"); - } else if (val == FW_BASE_BMI323) { - MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); - MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro); - ccprints("BASE ACCEL IS BMI323"); - } else { - ccprints("no motionsense"); - } -} -DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/corsola/src/krabby/temp_tentacruel.c b/zephyr/projects/corsola/src/krabby/temp_tentacruel.c deleted file mode 100644 index 5d2c304f76..0000000000 --- a/zephyr/projects/corsola/src/krabby/temp_tentacruel.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "charger.h" -#include "charge_state.h" -#include "common.h" -#include "config.h" -#include "console.h" -#include "driver/charger/rt9490.h" -#include "hooks.h" -#include "temp_sensor/temp_sensor.h" -#include "thermal.h" -#include "util.h" - -#define NUM_CURRENT_LEVELS ARRAY_SIZE(current_table) -#define TEMP_THRESHOLD 50 -#define TEMP_BUFF_SIZE 60 -#define KEEP_TIME 5 - -BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST)); -/* calculate current average temperature */ -static int average_tempature(void) -{ - static int temp_history_buffer[TEMP_BUFF_SIZE]; - static int buff_ptr; - static int temp_sum; - static int past_temp; - static int avg_temp; - int cur_temp, t; - - temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)), &t); - cur_temp = K_TO_C(t); - past_temp = temp_history_buffer[buff_ptr]; - temp_history_buffer[buff_ptr] = cur_temp; - temp_sum = temp_sum + temp_history_buffer[buff_ptr] - past_temp; - buff_ptr++; - if (buff_ptr >= TEMP_BUFF_SIZE) { - buff_ptr = 0; - } - /* Calculate per minute temperature. - * It's expected low temperature when the first 60 seconds. - */ - avg_temp = temp_sum / TEMP_BUFF_SIZE; - return avg_temp; -} - -static int current_level; - -/* Limit charging current table : 3600/3000/2400/1800 - * note this should be in descending order. - */ -static uint16_t current_table[] = { - 3600, - 3000, - 2400, - 1600, -}; - -/* Called by hook task every hook second (1 sec) */ -static void current_update(void) -{ - int temp; - static uint8_t uptime; - static uint8_t dntime; - - temp = average_tempature(); -#ifndef CONFIG_TEST - if (charge_get_state() == PWR_STATE_DISCHARGE) { - current_level = 0; - uptime = 0; - dntime = 0; - return; - } -#endif - if (temp >= TEMP_THRESHOLD) { - dntime = 0; - if (uptime < KEEP_TIME) { - uptime++; - } else { - uptime = 0; - current_level++; - } - } else if (current_level != 0 && temp < TEMP_THRESHOLD) { - uptime = 0; - if (dntime < KEEP_TIME) { - dntime++; - } else { - dntime = 0; - current_level--; - } - } else { - uptime = 0; - dntime = 0; - } - if (current_level > NUM_CURRENT_LEVELS) { - current_level = NUM_CURRENT_LEVELS; - } -} -DECLARE_HOOK(HOOK_SECOND, current_update, HOOK_PRIO_DEFAULT); - -int charger_profile_override(struct charge_state_data *curr) -{ - /* - * Precharge must be executed when communication is failed on - * dead battery. - */ - if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE)) - return 0; - if (current_level != 0) { - if (curr->requested_current > current_table[current_level - 1]) - curr->requested_current = - current_table[current_level - 1]; - } - return 0; -} - -enum ec_status charger_profile_override_get_param(uint32_t param, - uint32_t *value) -{ - return EC_RES_INVALID_PARAM; -} - -enum ec_status charger_profile_override_set_param(uint32_t param, - uint32_t value) -{ - return EC_RES_INVALID_PARAM; -} diff --git a/zephyr/projects/corsola/src/krabby/usb_pd_policy.c b/zephyr/projects/corsola/src/krabby/usb_pd_policy.c deleted file mode 100644 index 8f2a2c3515..0000000000 --- a/zephyr/projects/corsola/src/krabby/usb_pd_policy.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "adc.h" -#include "charge_manager.h" -#include "chipset.h" -#include "usb_charge.h" -#include "usb_pd.h" -#include "usbc_ppc.h" - -int pd_snk_is_vbus_provided(int port) -{ - static atomic_t vbus_prev[CONFIG_USB_PD_PORT_MAX_COUNT]; - int vbus; - - /* - * (b:181203590#comment20) TODO(yllin): use - * PD_VSINK_DISCONNECT_PD for non-5V case. - */ - vbus = adc_read_channel(board_get_vbus_adc(port)) >= - PD_V_SINK_DISCONNECT_MAX; - -#ifdef CONFIG_USB_CHARGER - /* - * There's no PPC to inform VBUS change for usb_charger, so inform - * the usb_charger now. - */ - if (!!(vbus_prev[port] != vbus)) { - usb_charger_vbus_change(port, vbus); - } - - if (vbus) { - atomic_or(&vbus_prev[port], 1); - } else { - atomic_clear(&vbus_prev[port]); - } -#endif - return vbus; -} - -void pd_power_supply_reset(int port) -{ - int prev_en; - - prev_en = ppc_is_sourcing_vbus(port); - - /* Disable VBUS. */ - ppc_vbus_source_enable(port, 0); - - /* Enable discharge if we were previously sourcing 5V */ - if (prev_en) { - pd_set_vbus_discharge(port, 1); - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - /* Disable charging. */ - rv = ppc_vbus_sink_enable(port, 0); - if (rv) { - return rv; - } - - pd_set_vbus_discharge(port, 0); - - /* Provide Vbus. */ - rv = ppc_vbus_source_enable(port, 1); - if (rv) { - return rv; - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -int board_vbus_source_enabled(int port) -{ - return ppc_is_sourcing_vbus(port); -} diff --git a/zephyr/projects/corsola/src/krabby/usbc_config.c b/zephyr/projects/corsola/src/krabby/usbc_config.c deleted file mode 100644 index 8e03e8dbad..0000000000 --- a/zephyr/projects/corsola/src/krabby/usbc_config.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Krabby board-specific USB-C configuration */ - -#include "adc.h" -#include "baseboard_usbc_config.h" -#include "charge_manager.h" -#include "console.h" -#include "driver/tcpm/it83xx_pd.h" -#include "driver/usb_mux/tusb1064.h" -#include "i2c.h" -#include "usb_pd.h" -#include "usbc_ppc.h" - -#include "variant_db_detection.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) - -int tusb1064_mux_1_board_init(const struct usb_mux *me) -{ - int rv; - - rv = i2c_write8(me->i2c_port, me->i2c_addr_flags, - TUSB1064_REG_DP1DP3EQ_SEL, - TUSB1064_DP1EQ(TUSB1064_DP_EQ_RX_8_9_DB) | - TUSB1064_DP3EQ(TUSB1064_DP_EQ_RX_5_4_DB)); - if (rv) - return rv; - - /* Enable EQ_OVERRIDE so the gain registers are used */ - return i2c_update8(me->i2c_port, me->i2c_addr_flags, - TUSB1064_REG_GENERAL, REG_GENERAL_EQ_OVERRIDE, - MASK_SET); -} - -#ifdef CONFIG_USB_PD_TCPM_ITE_ON_CHIP -const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port) -{ - const static struct cc_para_t - cc_parameter[CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT] = { - { - .rising_time = - IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, - .falling_time = - IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, - }, - { - .rising_time = - IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, - .falling_time = - IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, - }, - }; - - return &cc_parameter[port]; -} -#endif - -void board_reset_pd_mcu(void) -{ - /* - * C0 & C1: TCPC is embedded in the EC and processes interrupts in the - * chip code (it83xx/intc.c) - */ -} - -#ifndef CONFIG_TEST -int board_set_active_charge_port(int port) -{ - int i; - int is_valid_port = - (port >= 0 && port < board_get_adjusted_usb_pd_port_count()); - /* adjust the actual port count when not the type-c db connected. */ - - if (!is_valid_port && port != CHARGE_PORT_NONE) { - return EC_ERROR_INVAL; - } - - if (port == CHARGE_PORT_NONE) { - CPRINTS("Disabling all charger ports"); - - /* Disable all ports. */ - for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { - /* - * Do not return early if one fails otherwise we can - * get into a boot loop assertion failure. - */ - if (ppc_vbus_sink_enable(i, 0)) { - CPRINTS("Disabling C%d as sink failed.", i); - } - } - - return EC_SUCCESS; - } - - /* Check if the port is sourcing VBUS. */ - if (ppc_is_sourcing_vbus(port)) { - CPRINTS("Skip enable C%d", port); - return EC_ERROR_INVAL; - } - - CPRINTS("New charge port: C%d", port); - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) { - if (i == port) { - continue; - } - - if (ppc_vbus_sink_enable(i, 0)) { - CPRINTS("C%d: sink path disable failed.", i); - } - } - - /* Enable requested charge port. */ - if (ppc_vbus_sink_enable(port, 1)) { - CPRINTS("C%d: sink path enable failed.", port); - return EC_ERROR_UNKNOWN; - } - - return EC_SUCCESS; -} -#endif - -#ifdef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT -enum adc_channel board_get_vbus_adc(int port) -{ - if (port == 0) { - return ADC_VBUS_C0; - } - if (port == 1) { - return ADC_VBUS_C1; - } - CPRINTSUSB("Unknown vbus adc port id: %d", port); - return ADC_VBUS_C0; -} -#endif /* CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT */ diff --git a/zephyr/projects/corsola/src/usb_pd_policy.c b/zephyr/projects/corsola/src/usb_pd_policy.c deleted file mode 100644 index a885362c61..0000000000 --- a/zephyr/projects/corsola/src/usb_pd_policy.c +++ /dev/null @@ -1,226 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "atomic.h" -#include "console.h" -#include "chipset.h" -#include "hooks.h" -#include "timer.h" -#include "typec_control.h" -#include "usb_dp_alt_mode.h" -#include "usb_mux.h" -#include "usb_pd.h" -#include "usbc_ppc.h" - -#include "baseboard_usbc_config.h" - -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) - -static int active_aux_port = -1; - -int pd_check_vconn_swap(int port) -{ - /* Allow Vconn swap if AP is on. */ - return chipset_in_state(CHIPSET_STATE_SUSPEND | CHIPSET_STATE_ON); -} - -static void set_dp_aux_path_sel(int port) -{ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), port); - CPRINTS("Set DP_AUX_PATH_SEL: %d", port); -} - -int svdm_get_hpd_gpio(int port) -{ - /* HPD is low active, inverse the result */ - return !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl)); -} - -static void reset_aux_deferred(void) -{ - if (active_aux_port == -1) - /* reset to 1 for lower power consumption. */ - set_dp_aux_path_sel(1); -} -DECLARE_DEFERRED(reset_aux_deferred); - -void svdm_set_hpd_gpio(int port, int en) -{ - /* - * HPD is low active, inverse the en. - * - * Implement FCFS policy: - * 1) Enable hpd if no active port. - * 2) Disable hpd if active port is the given port. - */ - if (en && active_aux_port < 0) { - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), 0); - active_aux_port = port; - hook_call_deferred(&reset_aux_deferred_data, -1); - } - - if (!en && active_aux_port == port) { - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), 1); - active_aux_port = -1; - /* - * This might be a HPD debounce to send a HPD IRQ (500us), so - * do not reset the aux path immediately. Defer this call and - * re-check if this is a real disable. - */ - hook_call_deferred(&reset_aux_deferred_data, 1 * MSEC); - } -} - -__override int svdm_dp_config(int port, uint32_t *payload) -{ - int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); - uint8_t pin_mode = get_dp_pin_mode(port); - mux_state_t mux_mode = svdm_dp_get_mux_mode(port); - int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]); - - if (!pin_mode) { - return 0; - } - - CPRINTS("pin_mode: %x, mf: %d, mux: %d", pin_mode, mf_pref, mux_mode); - /* - * Defer setting the usb_mux until HPD goes high, svdm_dp_attention(). - * The AP only supports one DP phy. An external DP mux switches between - * the two ports. Should switch those muxes when it is really used, - * i.e. HPD high; otherwise, the real use case is preempted, like: - * (1) plug a dongle without monitor connected to port-0, - * (2) plug a dongle without monitor connected to port-1, - * (3) plug a monitor to the port-1 dongle. - */ - - payload[0] = - VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); - payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ - 1, /* DPv1.3 signaling */ - 2); /* UFP connected */ - return 2; -}; - -__override void svdm_dp_post_config(int port) -{ - mux_state_t mux_mode = svdm_dp_get_mux_mode(port); - - typec_set_sbu(port, true); - - /* - * Prior to post-config, the mux will be reset to safe mode, and this - * will break mux config and aux path config we did in the first DP - * status command. Only enable this if the port is the current aux-port. - */ - if (port == active_aux_port) { - usb_mux_set(port, mux_mode, USB_SWITCH_CONNECT, - polarity_rm_dts(pd_get_polarity(port))); - usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL | - USB_PD_MUX_HPD_IRQ_DEASSERTED); - } - - dp_flags[port] |= DP_FLAGS_DP_ON; -} - -int corsola_is_dp_muxable(int port) -{ - int i; - - for (i = 0; i < board_get_usb_pd_port_count(); i++) { - if (i != port) { - if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED) { - return 0; - } - } - } - - return 1; -} - -__override int svdm_dp_attention(int port, uint32_t *payload) -{ - int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); - int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); -#ifdef CONFIG_USB_PD_DP_HPD_GPIO - int cur_lvl = svdm_get_hpd_gpio(port); -#endif /* CONFIG_USB_PD_DP_HPD_GPIO */ - mux_state_t mux_state; - - dp_status[port] = payload[1]; - - if (!corsola_is_dp_muxable(port)) { - /* TODO(waihong): Info user? */ - CPRINTS("p%d: The other port is already muxed.", port); - return 0; /* nak */ - } - - if (lvl) { - set_dp_aux_path_sel(port); - - usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT, - polarity_rm_dts(pd_get_polarity(port))); - } else { - usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, - polarity_rm_dts(pd_get_polarity(port))); - } - - if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) { - /* - * Wake up the AP. IRQ or level high indicates a DP sink is now - * present. - */ - if (IS_ENABLED(CONFIG_MKBP_EVENT)) { - pd_notify_dp_alt_mode_entry(port); - } - } - -#ifdef CONFIG_USB_PD_DP_HPD_GPIO - if (irq && !lvl) { - /* - * IRQ can only be generated when the level is high, because - * the IRQ is signaled by a short low pulse from the high level. - */ - CPRINTF("ERR:HPD:IRQ&LOW\n"); - return 0; /* nak */ - } - - if (irq && cur_lvl) { - uint64_t now = get_time().val; - /* wait for the minimum spacing between IRQ_HPD if needed */ - if (now < svdm_hpd_deadline[port]) { - usleep(svdm_hpd_deadline[port] - now); - } - - /* generate IRQ_HPD pulse */ - svdm_set_hpd_gpio(port, 0); - /* - * b/171172053#comment14: since the HPD_DSTREAM_DEBOUNCE_IRQ is - * very short (500us), we can use udelay instead of usleep for - * more stable pulse period. - */ - udelay(HPD_DSTREAM_DEBOUNCE_IRQ); - svdm_set_hpd_gpio(port, 1); - } else { - svdm_set_hpd_gpio(port, lvl); - } - - /* set the minimum time delay (2ms) for the next HPD IRQ */ - svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; -#endif /* CONFIG_USB_PD_DP_HPD_GPIO */ - - mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) | - (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED); - usb_mux_hpd_update(port, mux_state); - -#ifdef USB_PD_PORT_TCPC_MST - if (port == USB_PD_PORT_TCPC_MST) { - baseboard_mst_enable_control(port, lvl); - } -#endif - - /* ack */ - return 1; -} diff --git a/zephyr/projects/corsola/src/usbc_config.c b/zephyr/projects/corsola/src/usbc_config.c deleted file mode 100644 index b776bc1ca9..0000000000 --- a/zephyr/projects/corsola/src/usbc_config.c +++ /dev/null @@ -1,258 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Corsola baseboard-specific USB-C configuration */ - -#include -#include - -#include "adc.h" -#include "baseboard_usbc_config.h" -#include "button.h" -#include "charger.h" -#include "charge_state_v2.h" -#include "console.h" -#include "ec_commands.h" -#include "extpower.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "i2c.h" -#include "lid_switch.h" -#include "task.h" -#include "ppc/syv682x_public.h" -#include "power.h" -#include "power_button.h" -#include "spi.h" -#include "switch.h" -#include "tablet_mode.h" -#include "uart.h" -#include "usb_charge.h" -#include "usb_mux.h" -#include "usb_pd_tcpm.h" -#include "usb_tc_sm.h" -#include "usbc/usb_muxes.h" -#include "usbc_ppc.h" - -#include "variant_db_detection.h" - -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) - -/* a flag for indicating the tasks are inited. */ -static bool tasks_inited; - -/* Baseboard */ -static void baseboard_init(void) -{ -#ifdef CONFIG_VARIANT_CORSOLA_USBA - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usba)); -#endif - /* If CCD mode has enabled before init, force the ccd_interrupt. */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ccd_mode_odl))) { - ccd_interrupt(GPIO_CCD_MODE_ODL); - } - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode_odl)); -} -DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_PRE_DEFAULT); - -__override uint8_t board_get_usb_pd_port_count(void) -{ - /* This function returns the PORT_COUNT+1 when HDMI db is connected. - * This is a trick to ensure the usb_mux_set being set properley. - * HDMI display functions using the USB virtual mux to * communicate - * with the DP bridge. - */ - if (corsola_get_db_type() == CORSOLA_DB_HDMI) { - if (tasks_inited) { - return CONFIG_USB_PD_PORT_MAX_COUNT; - } else { - return CONFIG_USB_PD_PORT_MAX_COUNT - 1; - } - } else if (corsola_get_db_type() == CORSOLA_DB_NONE) { - return CONFIG_USB_PD_PORT_MAX_COUNT - 1; - } - - return CONFIG_USB_PD_PORT_MAX_COUNT; -} - -uint8_t board_get_adjusted_usb_pd_port_count(void) -{ - if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { - return CONFIG_USB_PD_PORT_MAX_COUNT; - } else { - return CONFIG_USB_PD_PORT_MAX_COUNT - 1; - } -} - -/* USB-A */ -void usb_a0_interrupt(enum gpio_signal signal) -{ - enum usb_charge_mode mode = gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( - gpio_ap_xhci_init_done)) ? - USB_CHARGE_MODE_ENABLED : - USB_CHARGE_MODE_DISABLED; - - const int xhci_stat = gpio_get_level(signal); - - for (int i = 0; i < USB_PORT_COUNT; i++) { - usb_charge_set_mode(i, mode, USB_ALLOW_SUSPEND_CHARGE); - } - - for (int i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - /* - * Enable DRP toggle after XHCI inited. This is used to follow - * USB 3.2 spec 10.3.1.1. - */ - if (xhci_stat) { - pd_set_dual_role(i, PD_DRP_TOGGLE_ON); - } else if (tc_is_attached_src(i)) { - /* - * This is a AP reset S0->S0 transition. - * We should set the role back to sink. - */ - pd_set_dual_role(i, PD_DRP_FORCE_SINK); - } - } -} - -__override enum pd_dual_role_states pd_get_drp_state_in_s0(void) -{ - if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ap_xhci_init_done))) { - return PD_DRP_TOGGLE_ON; - } else { - return PD_DRP_FORCE_SINK; - } -} - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - int icl = charge_ma * 97 / 100; - /* - * b:257167723: Adapter output current exceeds the spec on heavy-load. - * Preserve a margin in case of charger overdraw. - */ - charge_set_input_current_limit(icl, charge_mv); -} - -void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) -{ - /* - * We ignore the cc_pin and PPC vconn because polarity and PPC vconn - * should already be set correctly in the PPC driver via the pd - * state machine. - */ -} - -/* HDMI/TYPE-C function shared subboard interrupt */ -void x_ec_interrupt(enum gpio_signal signal) -{ - int sub = corsola_get_db_type(); - - if (sub == CORSOLA_DB_TYPEC) { - /* C1: PPC interrupt */ - ppc_interrupt(signal); - } else if (sub == CORSOLA_DB_HDMI) { - hdmi_hpd_interrupt(signal); - } else { - CPRINTS("Undetected subboard interrupt."); - } -} - -static void board_hdmi_handler(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - int value; - - switch (data.event) { - default: - return; - - case AP_POWER_RESUME: - value = 1; - break; - - case AP_POWER_SUSPEND: - value = 0; - break; - } - gpio_pin_set_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr), value); - gpio_pin_set_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl), value); -} - -static void tasks_init_deferred(void) -{ - tasks_inited = true; - if (corsola_get_db_type() == CORSOLA_DB_HDMI) { - /* If the HDMI port is plugged on-boot, and the usb_mux won't - * be configured before the task inited. Re-invoke the - * HPD configuration after task inited. - */ - ps185_hdmi_hpd_mux_set(); - } -} -DECLARE_DEFERRED(tasks_init_deferred); - -static void baseboard_x_ec_gpio2_init(void) -{ - static struct ppc_drv virtual_ppc_drv = { 0 }; - static struct tcpm_drv virtual_tcpc_drv = { 0 }; - static struct bc12_drv virtual_bc12_drv = { 0 }; - - /* no sub board */ - if (corsola_get_db_type() == CORSOLA_DB_NONE) { - return; - } - - /* type-c: USB_C1_PPC_INT_ODL / hdmi: PS185_EC_DP_HPD */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); - - if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { - gpio_pin_interrupt_configure_dt( - GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl), - GPIO_INT_EDGE_FALLING); - return; - } - if (corsola_get_db_type() == CORSOLA_DB_HDMI) { - static struct ap_power_ev_callback cb; - - ap_power_ev_init_callback(&cb, board_hdmi_handler, - AP_POWER_RESUME | AP_POWER_SUSPEND); - ap_power_ev_add_callback(&cb); - } - - /* drop related C1 port drivers when it's a HDMI DB. */ - ppc_chips[USBC_PORT_C1] = - (const struct ppc_config_t){ .drv = &virtual_ppc_drv }; - tcpc_config[USBC_PORT_C1] = - (const struct tcpc_config_t){ .drv = &virtual_tcpc_drv }; - bc12_ports[USBC_PORT_C1] = - (const struct bc12_config){ .drv = &virtual_bc12_drv }; - /* Use virtual mux to notify AP the mainlink direction. */ - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_hdmi_db); - - /* - * If a HDMI DB is attached, C1 port tasks will be exiting in that - * the port number is larger than board_get_usb_pd_port_count(). - * After C1 port tasks finished, we intentionally increase the port - * count by 1 for usb_mux to access the C1 virtual mux for notifying - * mainlink direction. - */ - hook_call_deferred(&tasks_init_deferred_data, 2 * SECOND); -} -DECLARE_HOOK(HOOK_INIT, baseboard_x_ec_gpio2_init, HOOK_PRIO_DEFAULT); - -__override uint8_t get_dp_pin_mode(int port) -{ - if (corsola_get_db_type() == CORSOLA_DB_HDMI && port == USBC_PORT_C1) { - if (usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED) { - return MODE_DP_PIN_E; - } else { - return 0; - } - } - - return pd_dfp_dp_get_pin_mode(port, dp_status[port]); -} diff --git a/zephyr/projects/corsola/src/variant_db_detection.c b/zephyr/projects/corsola/src/variant_db_detection.c deleted file mode 100644 index f68d9c8fad..0000000000 --- a/zephyr/projects/corsola/src/variant_db_detection.c +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Corsola daughter board detection */ -#include - -#include "baseboard_usbc_config.h" -#include "console.h" -#include "cros_cbi.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "usb_mux.h" - -#include "variant_db_detection.h" - -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) - -#ifdef TEST_BUILD -uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT]; -#endif - -static void corsola_db_config(enum corsola_db_type type) -{ - switch (type) { - case CORSOLA_DB_HDMI: - /* EC_X_GPIO1 */ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr), - GPIO_OUTPUT_HIGH); - /* X_EC_GPIO2 */ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd), - GPIO_INPUT); - gpio_enable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); - /* EC_X_GPIO3 */ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl), - GPIO_OUTPUT_HIGH | GPIO_OPEN_DRAIN); - return; - case CORSOLA_DB_TYPEC: - /* EC_X_GPIO1 */ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_frs_en), - GPIO_OUTPUT_LOW); - /* X_EC_GPIO2 */ - gpio_pin_configure_dt( - GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl), - GPIO_INPUT | GPIO_PULL_UP); - gpio_enable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); - /* EC_X_GPIO3 */ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_dp_in_hpd), - GPIO_OUTPUT_LOW); - return; - case CORSOLA_DB_NONE: - /* Set floating pins as input with PU to prevent leakage */ - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio1), - GPIO_INPUT | GPIO_PULL_UP); - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_x_ec_gpio2), - GPIO_INPUT | GPIO_PULL_UP); - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio3), - GPIO_INPUT | GPIO_PULL_UP); - return; - default: - break; - } -} - -enum corsola_db_type corsola_get_db_type(void) -{ -#if DT_NODE_EXISTS(DT_NODELABEL(db_config)) - int ret; - uint32_t val; -#endif - static enum corsola_db_type db = CORSOLA_DB_UNINIT; - - if (db != CORSOLA_DB_UNINIT) { - return db; - } - - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_hdmi_prsnt_odl))) { - db = CORSOLA_DB_HDMI; - } else { - db = CORSOLA_DB_TYPEC; - } - -/* Detect for no sub board case by FW_CONFIG */ -#if DT_NODE_EXISTS(DT_NODELABEL(db_config)) - ret = cros_cbi_get_fw_config(DB, &val); - if (ret != 0) { - CPRINTS("Error retrieving CBI FW_CONFIG field %d", DB); - } else if (val == DB_NONE) { - db = CORSOLA_DB_NONE; - } -#endif - - corsola_db_config(db); - - switch (db) { - case CORSOLA_DB_NONE: - CPRINTS("Detect %s DB", "NONE"); - break; - case CORSOLA_DB_TYPEC: - CPRINTS("Detect %s DB", "TYPEC"); - break; - case CORSOLA_DB_HDMI: - CPRINTS("Detect %s DB", "HDMI"); - break; - default: - CPRINTS("DB UNINIT"); - break; - } - - return db; -} - -static void corsola_db_init(void) -{ - corsola_get_db_type(); -} -DECLARE_HOOK(HOOK_INIT, corsola_db_init, HOOK_PRIO_PRE_I2C); - -/** - * Handle PS185 HPD changing state. - */ -void ps185_hdmi_hpd_mux_set(void) -{ - const int hpd = - gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); - - if (!corsola_is_dp_muxable(USBC_PORT_C1)) { - return; - } - - if (hpd && !(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { - dp_status[USBC_PORT_C1] = - VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ - 0, /* HPD level ... not applicable */ - 0, /* exit DP? ... no */ - 0, /* usb mode? ... no */ - 0, /* multi-function ... no */ - 1, /* DP enabled ... yes */ - 0, /* power low? ... no */ - (!!DP_FLAGS_DP_ON)); - /* update C1 virtual mux */ - usb_mux_set(USBC_PORT_C1, USB_PD_MUX_DP_ENABLED, - USB_SWITCH_DISCONNECT, - 0 /* polarity, don't care */); - CPRINTS("HDMI plug"); - } -} - -static void ps185_hdmi_hpd_deferred(void) -{ - const int hpd = - gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); - - if (!hpd && (usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { - dp_status[USBC_PORT_C1] = - VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ - 0, /* HPD level ... not applicable */ - 0, /* exit DP? ... no */ - 0, /* usb mode? ... no */ - 0, /* multi-function ... no */ - 0, /* DP enabled ... no */ - 0, /* power low? ... no */ - (!DP_FLAGS_DP_ON)); - usb_mux_set(USBC_PORT_C1, USB_PD_MUX_NONE, - USB_SWITCH_DISCONNECT, - 0 /* polarity, don't care */); - CPRINTS("HDMI unplug"); - - return; - } - - ps185_hdmi_hpd_mux_set(); -} -DECLARE_DEFERRED(ps185_hdmi_hpd_deferred); - -#define HPD_SINK_ABSENCE_DEBOUNCE (2 * MSEC) - -void hdmi_hpd_interrupt(enum gpio_signal signal) -{ - const int hpd = - gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); - - if (!hpd) { - hook_call_deferred(&ps185_hdmi_hpd_deferred_data, - HPD_SINK_ABSENCE_DEBOUNCE); - } else { - hook_call_deferred(&ps185_hdmi_hpd_deferred_data, -1); - } - - /* C0 DP is muxed, we should not send HPD to the AP */ - if (!corsola_is_dp_muxable(USBC_PORT_C1)) { - if (hpd) { - CPRINTS("C0 port is already muxed."); - } - return; - } - - if (hpd && !(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) { - /* set dp_aux_path_sel first, and configure the usb_mux in the - * deferred hook to prevent from dead locking. - */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), hpd); - hook_call_deferred(&ps185_hdmi_hpd_deferred_data, 0); - } - - svdm_set_hpd_gpio(USBC_PORT_C1, hpd); -} diff --git a/zephyr/projects/corsola/thermistor_tentacruel.dts b/zephyr/projects/corsola/thermistor_tentacruel.dts deleted file mode 100644 index f9e5306f24..0000000000 --- a/zephyr/projects/corsola/thermistor_tentacruel.dts +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - thermistor_rt9490: thermistor-rt9490 { - status = "okay"; - compatible = "cros-ec,thermistor"; - scaling-factor = <3>; - num-pairs = <21>; - steinhart-reference-mv = <4900>; - steinhart-reference-res = <10000>; - - sample-datum-0 { - milivolt = <(731 / 3)>; - temp = <0>; - sample-index = <0>; - }; - - sample-datum-1 { - milivolt = <(708 / 3)>; - temp = <5>; - sample-index = <1>; - }; - - sample-datum-2 { - milivolt = <(682 / 3)>; - temp = <10>; - sample-index = <2>; - }; - - sample-datum-3 { - milivolt = <(653 / 3)>; - temp = <15>; - sample-index = <3>; - }; - - sample-datum-4 { - milivolt = <(622 / 3)>; - temp = <20>; - sample-index = <4>; - }; - - sample-datum-5 { - milivolt = <(589 / 3)>; - temp = <25>; - sample-index = <5>; - }; - - sample-datum-6 { - milivolt = <(554 / 3)>; - temp = <30>; - sample-index = <6>; - }; - - sample-datum-7 { - milivolt = <(519 / 3)>; - temp = <35>; - sample-index = <7>; - }; - - sample-datum-8 { - milivolt = <(483 / 3)>; - temp = <40>; - sample-index = <8>; - }; - - sample-datum-9 { - milivolt = <(446 / 3)>; - temp = <45>; - sample-index = <9>; - }; - - sample-datum-10 { - milivolt = <(411 / 3)>; - temp = <50>; - sample-index = <10>; - }; - sample-datum-11 { - milivolt = <(376 / 3)>; - temp = <55>; - sample-index = <11>; - }; - - sample-datum-12 { - milivolt = <(343 / 3)>; - temp = <60>; - sample-index = <12>; - }; - - sample-datum-13 { - milivolt = <(312 / 3)>; - temp = <65>; - sample-index = <13>; - }; - - sample-datum-14 { - milivolt = <(284 / 3)>; - temp = <70>; - sample-index = <14>; - }; - - sample-datum-15 { - milivolt = <(257 / 3)>; - temp = <75>; - sample-index = <15>; - }; - - sample-datum-16 { - milivolt = <(232 / 3)>; - temp = <80>; - sample-index = <16>; - }; - - sample-datum-17 { - milivolt = <(209 / 3)>; - temp = <85>; - sample-index = <17>; - }; - - sample-datum-18 { - milivolt = <(188 / 3)>; - temp = <90>; - sample-index = <18>; - }; - - sample-datum-19 { - milivolt = <(169 / 3)>; - temp = <95>; - sample-index = <19>; - }; - - sample-datum-20 { - milivolt = <(152 / 3)>; - temp = <100>; - sample-index = <20>; - }; - }; -}; diff --git a/zephyr/projects/corsola/usba.dts b/zephyr/projects/corsola/usba.dts deleted file mode 100644 index 2ecb3b7d5a..0000000000 --- a/zephyr/projects/corsola/usba.dts +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usba_port_enable_list: usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&en_pp5000_usb_a0_vbus>; - }; -}; diff --git a/zephyr/projects/corsola/usba_steelix.dts b/zephyr/projects/corsola/usba_steelix.dts deleted file mode 100644 index 0ddd67f664..0000000000 --- a/zephyr/projects/corsola/usba_steelix.dts +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* steelix usba port enable config */ -&usba_port_enable_list { - enable-pins = <&en_pp5000_usb_a0_vbus - &en_pp5000_usb_a1_vbus>; -}; diff --git a/zephyr/projects/corsola/usbc_kingler.dts b/zephyr/projects/corsola/usbc_kingler.dts deleted file mode 100644 index 18bc6ce303..0000000000 --- a/zephyr/projects/corsola/usbc_kingler.dts +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - tcpc = <&tcpc_port0>; - ppc = <&ppc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&anx7447_mux_0 &virtual_mux_0>; - }; - }; - - port0-muxes { - anx7447_mux_0: anx7447-mux-0 { - compatible = "analogix,usbc-mux-anx7447"; - }; - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - tcpc = <&tcpc_port1>; - ppc = <&ppc_port1>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; - }; - usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; diff --git a/zephyr/projects/corsola/usbc_krabby.dts b/zephyr/projects/corsola/usbc_krabby.dts deleted file mode 100644 index a72864da35..0000000000 --- a/zephyr/projects/corsola/usbc_krabby.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_ppc_port0>; - ppc = <&bc12_ppc_port0>; - tcpc = <&usbpd0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&it5205_mux_0 &virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&usbpd1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>; - }; - usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; - -&usbpd0 { - status = "okay"; -}; - -&usbpd1 { - status = "okay"; -}; diff --git a/zephyr/projects/corsola/usbc_magikarp.dts b/zephyr/projects/corsola/usbc_magikarp.dts deleted file mode 100644 index c94db15b3a..0000000000 --- a/zephyr/projects/corsola/usbc_magikarp.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&usbpd0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&it5205_mux_0 &virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&usbpd1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; - }; - usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; - -&usbpd0 { - status = "okay"; -}; - -&usbpd1 { - status = "okay"; -}; diff --git a/zephyr/projects/corsola/usbc_tentacruel.dts b/zephyr/projects/corsola/usbc_tentacruel.dts deleted file mode 100644 index bb105a8e08..0000000000 --- a/zephyr/projects/corsola/usbc_tentacruel.dts +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&bc12_ppc_port0>; - ppc_alt = <&ppc_port0>; - tcpc = <&usbpd0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&it5205_mux_0 &virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&usbpd1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; - }; - usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; - -&usbpd0 { - status = "okay"; -}; - -&usbpd1 { - status = "okay"; -}; diff --git a/zephyr/projects/herobrine/BUILD.py b/zephyr/projects/herobrine/BUILD.py deleted file mode 100644 index 0bee6ffe2a..0000000000 --- a/zephyr/projects/herobrine/BUILD.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for herobrine.""" - - -def register_variant( - project_name, -): - """Register a variant of herobrine.""" - register_npcx_project( - project_name=project_name, - zephyr_board="npcx9m3f", - dts_overlays=[ - here / project_name / "project.overlay", - ], - kconfig_files=[ - # Common to all projects. - here / "program.conf", - # Project-specific KConfig customization. - here / project_name / "project.conf", - ], - ) - - -register_variant( - project_name="evoker", -) - -register_variant( - project_name="herobrine", -) - -register_variant( - project_name="hoglin", -) - -register_variant( - project_name="villager", -) - -register_variant( - project_name="zoglin", -) - -register_variant( - project_name="zombie", -) diff --git a/zephyr/projects/herobrine/CMakeLists.txt b/zephyr/projects/herobrine/CMakeLists.txt deleted file mode 100644 index 90a49a053e..0000000000 --- a/zephyr/projects/herobrine/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") - -cros_ec_library_include_directories(include) - -# Common Herobrine implementation -zephyr_library_sources( - "src/board_chipset.c" -) - -# Board specific implementation -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/usbc_config.c" - "src/usb_pd_policy.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C - "src/i2c.c") - -if(DEFINED CONFIG_BOARD_EVOKER) - project(evoker) -elseif(DEFINED CONFIG_BOARD_HEROBRINE) - project(herobrine) - add_subdirectory(herobrine) -elseif(DEFINED CONFIG_BOARD_HOGLIN) - project(hoglin) -elseif(DEFINED CONFIG_BOARD_VILLAGER) - project(villager) -elseif(DEFINED CONFIG_BOARD_ZOGLIN) - project(zoglin) -elseif(DEFINED CONFIG_BOARD_ZOMBIE) - project(zombie) -endif() diff --git a/zephyr/projects/herobrine/Kconfig b/zephyr/projects/herobrine/Kconfig deleted file mode 100644 index d0056288d5..0000000000 --- a/zephyr/projects/herobrine/Kconfig +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -config BOARD_EVOKER - bool "Evoker Board" - help - Build the Evoker board. The board is based on the Herobrine - reference design. - -config BOARD_HEROBRINE - bool "Google Herobrine Baseboard" - help - Build Google Herobrine reference board. The board uses Nuvoton - NPCX9 chip as the EC. - -config BOARD_HOGLIN - bool "Qualcomm Hoglin Baseboard" - help - Build Qualcomm Hoglin reference board. The board uses Nuvoton - NPCX9 chip as the EC. - -config BOARD_VILLAGER - bool "Villager Board" - help - Build the Villager board. The board is based on the Herobrine - reference design. - -config BOARD_ZOGLIN - bool "Qualcomm Zoglin Baseboard" - help - Build Qualcomm Zoglin reference board. The board uses Nuvoton - NPCX9 chip as the EC. - -config BOARD_ZOMBIE - bool "Zombie Board" - help - Build the Zombie board. The board is based on the Herobrine - reference design. - -source "Kconfig.zephyr" diff --git a/zephyr/projects/herobrine/adc.dtsi b/zephyr/projects/herobrine/adc.dtsi deleted file mode 100644 index 16a5434e9d..0000000000 --- a/zephyr/projects/herobrine/adc.dtsi +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - vbus { - enum-name = "ADC_VBUS"; - io-channels = <&adc0 1>; - /* Measure VBUS through a 1/10 voltage divider */ - mul = <10>; - }; - amon_bmon { - enum-name = "ADC_AMON_BMON"; - io-channels = <&adc0 2>; - /* - * Adapter current output or battery charging/ - * discharging current (uV) 18x amplification on - * charger side. - */ - mul = <1000>; - div = <18>; - }; - psys { - enum-name = "ADC_PSYS"; - io-channels = <&adc0 3>; - /* - * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor, - * to read 0.8V @ 99 W, i.e. 124000 uW/mV. - */ - mul = <124000>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/herobrine/common.dtsi b/zephyr/projects/herobrine/common.dtsi deleted file mode 100644 index a722f1dfa2..0000000000 --- a/zephyr/projects/herobrine/common.dtsi +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - chosen { - cros,rtc = &pcf85063a; - }; - - ec-console { - compatible = "ec-console"; - disabled = "hostcmd"; - }; - - ec-mkbp-host-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <( - HOST_EVENT_LID_OPEN | - HOST_EVENT_POWER_BUTTON | - HOST_EVENT_AC_CONNECTED | - HOST_EVENT_AC_DISCONNECTED | - HOST_EVENT_HANG_DETECT | - HOST_EVENT_RTC | - HOST_EVENT_MODE_CHANGE | - HOST_EVENT_DEVICE)>; - }; - - ec-mkbp-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \ - MKBP_EVENT_HOST_EVENT | \ - MKBP_EVENT_SENSOR_FIFO)>; - }; -}; - -&shi { - status = "okay"; - pinctrl-0 = <&shi_gp46_47_53_55>; - pinctrl-1 = <&shi_gpio_gp46_47_53_55>; - pinctrl-names = "default", "sleep"; -}; diff --git a/zephyr/projects/herobrine/default_gpio_pinctrl.dtsi b/zephyr/projects/herobrine/default_gpio_pinctrl.dtsi deleted file mode 100644 index 604658a145..0000000000 --- a/zephyr/projects/herobrine/default_gpio_pinctrl.dtsi +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ -&{/def-io-conf-list} { - pinmux = <&alt0_gpio_no_spip - &alt0_gpio_no_fpip - &alt1_no_pwrgd - &alt1_no_lpc_espi - &alta_no_peci_en - &altd_npsl_in1_sl - &altd_npsl_in2_sl - &altd_psl_in3_sl - &altd_psl_in4_sl - &alt7_no_ksi0_sl - &alt7_no_ksi1_sl - &alt7_no_ksi2_sl - &alt7_no_ksi3_sl - &alt7_no_ksi4_sl - &alt7_no_ksi5_sl - &alt7_no_ksi6_sl - &alt7_no_ksi7_sl - &alt8_no_kso00_sl - &alt8_no_kso01_sl - &alt8_no_kso02_sl - &alt8_no_kso03_sl - &alt8_no_kso04_sl - &alt8_no_kso05_sl - &alt8_no_kso06_sl - &alt8_no_kso07_sl - &alt9_no_kso08_sl - &alt9_no_kso09_sl - &alt9_no_kso10_sl - &alt9_no_kso11_sl - &alt9_no_kso12_sl - &alt9_no_kso13_sl - &alt9_no_kso14_sl - &alt9_no_kso15_sl - &alta_no_kso16_sl - &alta_no_kso17_sl - &altg_psl_gpo_sl>; -}; diff --git a/zephyr/projects/herobrine/display.dtsi b/zephyr/projects/herobrine/display.dtsi deleted file mode 100644 index 65d3a2d91b..0000000000 --- a/zephyr/projects/herobrine/display.dtsi +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - displight { - compatible = "cros-ec,displight"; - pwms = <&pwm5 0 PWM_HZ(4800) PWM_POLARITY_NORMAL>; - generic-pwm-channel = <1>; - }; -}; - -&pwm5 { - status = "okay"; - pinctrl-0 = <&pwm5_gpb7>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/herobrine/evoker/battery.dtsi b/zephyr/projects/herobrine/evoker/battery.dtsi deleted file mode 100644 index 0e09616c1d..0000000000 --- a/zephyr/projects/herobrine/evoker/battery.dtsi +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: pc_vp_bp153 { - compatible = "smp,pc-vp-bp153", "battery-smart"; - }; - ap16l5j { - compatible = "panasonic,ap16l5j", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/evoker/gpio.dtsi b/zephyr/projects/herobrine/evoker/gpio.dtsi deleted file mode 100644 index d60fdf93c7..0000000000 --- a/zephyr/projects/herobrine/evoker/gpio.dtsi +++ /dev/null @@ -1,329 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { - #led-pin-cells = <1>; - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpio5 0 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; diff --git a/zephyr/projects/herobrine/evoker/i2c.dtsi b/zephyr/projects/herobrine/evoker/i2c.dtsi deleted file mode 100644 index 6de6863f60..0000000000 --- a/zephyr/projects/herobrine/evoker/i2c.dtsi +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - ppc_port0_alt: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - ppc_port1_alt: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/projects/herobrine/evoker/led_pins.dtsi b/zephyr/projects/herobrine/evoker/led_pins.dtsi deleted file mode 100644 index ff2dc0e36c..0000000000 --- a/zephyr/projects/herobrine/evoker/led_pins.dtsi +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_power_off: color-power-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&gpio_ec_chg_led_w_c1 0>; - }; - - color_power_white: color-power-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&gpio_ec_chg_led_w_c1 1>; - }; - - color_battery_off: color-battery-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_battery_amber: color-battery-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_battery_white: color-battery-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 1>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_battery_red: color-battery-red { - led-color = "LED_RED"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/evoker/led_policy.dtsi b/zephyr/projects/herobrine/evoker/led_policy.dtsi deleted file mode 100644 index fc17755ede..0000000000 --- a/zephyr/projects/herobrine/evoker/led_policy.dtsi +++ /dev/null @@ -1,86 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - battery-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_battery_amber>; - }; - }; - - battery-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_battery_white>; - }; - }; - - battery-state-discharge { - charge-state = "PWR_STATE_DISCHARGE"; - - color-0 { - led-color = <&color_battery_off>; - }; - }; - - battery-state-error { - charge-state = "PWR_STATE_ERROR"; - - color-0 { - led-color = <&color_battery_red>; - }; - }; - - /* force idle mode */ - battery-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Red 1 sec, White 1 sec */ - color-0 { - led-color = <&color_battery_red>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - }; - - pwr-power-state-s0 { - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_power_white>; - }; - }; - - power-state-s3 { - chipset-state = "POWER_S3"; - - /* white LED - on 1 sec, off 1 sec */ - color-0 { - led-color = <&color_power_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_power_off>; - period-ms = <1000>; - }; - }; - - power-state-s5 { - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_power_off>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/evoker/motionsense.dtsi b/zephyr/projects/herobrine/evoker/motionsense.dtsi deleted file mode 100644 index aa7646e0b3..0000000000 --- a/zephyr/projects/herobrine/evoker/motionsense.dtsi +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <(-1) 0 0 - 0 (-1) 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma4xx_data>; - i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/herobrine/evoker/project.conf b/zephyr/projects/herobrine/evoker/project.conf deleted file mode 100644 index b4a5fce160..0000000000 --- a/zephyr/projects/herobrine/evoker/project.conf +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Evoker board-specific Kconfig settings. -CONFIG_BOARD_EVOKER=y - -# Disable type-c port sourcing 3A -CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0 - -CONFIG_PLATFORM_EC_ACCEL_BMA255=n -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y - -# ISL9238C disable the CMOUT latch function. -CONFIG_PLATFORM_EC_ISL9238C_DISABLE_CMOUT_LATCH=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y \ No newline at end of file diff --git a/zephyr/projects/herobrine/evoker/project.overlay b/zephyr/projects/herobrine/evoker/project.overlay deleted file mode 100644 index 5731bf3312..0000000000 --- a/zephyr/projects/herobrine/evoker/project.overlay +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Herobrine program common DTS includes */ -#include "../adc.dtsi" -#include "../common.dtsi" -#include "../interrupts.dtsi" -#include "../keyboard.dtsi" -#include "../default_gpio_pinctrl.dtsi" -#include "../display.dtsi" -#include "../switchcap.dtsi" - -/* Evoker project DTS includes*/ -#include "battery.dtsi" -#include "gpio.dtsi" -#include "i2c.dtsi" -#include "led_pins.dtsi" -#include "led_policy.dtsi" -#include "motionsense.dtsi" -#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/evoker/usbc.dtsi b/zephyr/projects/herobrine/evoker/usbc.dtsi deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/projects/herobrine/evoker/usbc.dtsi +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/gpio.dtsi b/zephyr/projects/herobrine/gpio.dtsi deleted file mode 100644 index a355aaf099..0000000000 --- a/zephyr/projects/herobrine/gpio.dtsi +++ /dev/null @@ -1,329 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { - #led-pin-cells = <1>; - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { - #led-pin-cells = <1>; - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpio5 0 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; \ No newline at end of file diff --git a/zephyr/projects/herobrine/herobrine/CMakeLists.txt b/zephyr/projects/herobrine/herobrine/CMakeLists.txt deleted file mode 100644 index 5524db7215..0000000000 --- a/zephyr/projects/herobrine/herobrine/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/alt_dev_replacement.c") diff --git a/zephyr/projects/herobrine/herobrine/battery.dtsi b/zephyr/projects/herobrine/herobrine/battery.dtsi deleted file mode 100644 index b347ec4c3c..0000000000 --- a/zephyr/projects/herobrine/herobrine/battery.dtsi +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap16l5j { - compatible = "panasonic,ap16l5j", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/herobrine/i2c.dtsi b/zephyr/projects/herobrine/herobrine/i2c.dtsi deleted file mode 100644 index 6f2d89aa71..0000000000 --- a/zephyr/projects/herobrine/herobrine/i2c.dtsi +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - ppc_port0_alt: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/projects/herobrine/herobrine/led_pins.dtsi b/zephyr/projects/herobrine/herobrine/led_pins.dtsi deleted file mode 100644 index c509ab1a64..0000000000 --- a/zephyr/projects/herobrine/herobrine/led_pins.dtsi +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off_left: color-off-left { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_LEFT_LED"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_w_c1 0>; - }; - - color_off_right: color-off-right { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_RIGHT_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>; - }; - - color_amber_left: color-amber-left { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_LEFT_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_w_c1 0>; - }; - - color_amber_right: color-amber-right { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_RIGHT_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_w_c0 0>; - }; - - color_white_left: color-white-left { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_LEFT_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_w_c1 1>; - }; - - color_white_right: color-white-right { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_RIGHT_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/herobrine/led_policy.dtsi b/zephyr/projects/herobrine/herobrine/led_policy.dtsi deleted file mode 100644 index 13e5306deb..0000000000 --- a/zephyr/projects/herobrine/herobrine/led_policy.dtsi +++ /dev/null @@ -1,202 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge-left { - charge-state = "PWR_STATE_CHARGE"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED to Amber */ - color-1 { - led-color = <&color_amber_left>; - }; - }; - - power-state-charge-right { - charge-state = "PWR_STATE_CHARGE"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED to Amber */ - color-1 { - led-color = <&color_amber_right>; - }; - }; - - power-state-discharge-right-low { - charge-state = "PWR_STATE_DISCHARGE"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED - White 1 sec, off 3 sec */ - color-1 { - led-color = <&color_white_right>; - period-ms = <1000>; - }; - color-2 { - led-color = <&color_off_right>; - period-ms = <3000>; - }; - }; - - power-state-discharge-right { - charge-state = "PWR_STATE_DISCHARGE"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Turn off the right LED */ - color-1 { - led-color = <&color_off_right>; - }; - }; - - power-state-error-left { - charge-state = "PWR_STATE_ERROR"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED - White 2 sec, off 2 sec */ - color-1 { - led-color = <&color_white_left>; - period-ms = <2000>; - }; - color-2 { - led-color = <&color_off_right>; - period-ms = <2000>; - }; - }; - - power-state-error-right { - charge-state = "PWR_STATE_ERROR"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED - White 2 sec, off 2 sec */ - color-1 { - led-color = <&color_white_right>; - period-ms = <2000>; - }; - color-2 { - led-color = <&color_off_right>; - period-ms = <2000>; - }; - }; - - power-state-near-full-left { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED to White */ - color-1 { - led-color = <&color_white_left>; - }; - }; - - power-state-near-full-right { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED to White */ - color-1 { - led-color = <&color_white_right>; - }; - }; - - power-state-forced-idle-left { - charge-state = "PWR_STATE_FORCED_IDLE"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED - Amber 3 sec, Off 1 sec */ - color-1 { - led-color = <&color_amber_left>; - period-ms = <3000>; - }; - color-2 { - led-color = <&color_off_left>; - period-ms = <1000>; - }; - }; - - power-state-forced-idle-right { - charge-state = "PWR_STATE_FORCED_IDLE"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED - Amber 3 sec, Off 1 sec */ - color-1 { - led-color = <&color_amber_right>; - period-ms = <3000>; - }; - color-2 { - led-color = <&color_off_right>; - period-ms = <1000>; - }; - }; - - power-state-idle-left { - charge-state = "PWR_STATE_IDLE"; - charge-port = <1>; /* Left port */ - - /* Turn off the right LED */ - color-0 { - led-color = <&color_off_right>; - }; - /* Left LED to White */ - color-1 { - led-color = <&color_white_left>; - }; - }; - - power-state-idle-right { - charge-state = "PWR_STATE_IDLE"; - charge-port = <0>; /* Right port */ - - /* Turn off the left LED */ - color-0 { - led-color = <&color_off_left>; - }; - /* Right LED to White */ - color-1 { - led-color = <&color_white_right>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/herobrine/project.conf b/zephyr/projects/herobrine/herobrine/project.conf deleted file mode 100644 index bf39f65692..0000000000 --- a/zephyr/projects/herobrine/herobrine/project.conf +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Herobrine-NPCX9 reference-board-specific Kconfig settings. -CONFIG_BOARD_HEROBRINE=y - -# Sensors -CONFIG_PLATFORM_EC_ALS=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ALS_TCS3400=y -CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/herobrine/project.overlay b/zephyr/projects/herobrine/herobrine/project.overlay deleted file mode 100644 index a74db66815..0000000000 --- a/zephyr/projects/herobrine/herobrine/project.overlay +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Herobrine program common DTS includes */ -#include "../adc.dtsi" -#include "../common.dtsi" -#include "../interrupts.dtsi" -#include "../keyboard.dtsi" -#include "../default_gpio_pinctrl.dtsi" -#include "../display.dtsi" -#include "../gpio.dtsi" -#include "../motionsense.dtsi" -#include "../switchcap.dtsi" - -/* Herobrine project DTS includes*/ -#include "battery.dtsi" -#include "i2c.dtsi" -#include "led_pins.dtsi" -#include "led_policy.dtsi" -#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/herobrine/src/alt_dev_replacement.c b/zephyr/projects/herobrine/herobrine/src/alt_dev_replacement.c deleted file mode 100644 index 00acd509f4..0000000000 --- a/zephyr/projects/herobrine/herobrine/src/alt_dev_replacement.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include -#include "usbc/ppc.h" -#include "hooks.h" -#include "cros_board_info.h" - -LOG_MODULE_REGISTER(alt_dev_replacement); - -#define BOARD_VERSION_UNKNOWN 0xffffffff - -/* Check board version to decide which ppc is used. */ -static bool board_has_alt_ppc(void) -{ - static uint32_t board_version = BOARD_VERSION_UNKNOWN; - - if (board_version == BOARD_VERSION_UNKNOWN) { - if (cbi_get_board_version(&board_version) != EC_SUCCESS) { - LOG_ERR("Failed to get board version."); - board_version = 0; - } - } - - return (board_version >= 1); -} - -static void check_alternate_devices(void) -{ - /* Configure the PPC driver */ - if (board_has_alt_ppc()) - /* Arg is the USB port number */ - PPC_ENABLE_ALTERNATE(0); -} -DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/herobrine/herobrine/usbc.dtsi b/zephyr/projects/herobrine/herobrine/usbc.dtsi deleted file mode 100644 index 675286ecd7..0000000000 --- a/zephyr/projects/herobrine/herobrine/usbc.dtsi +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - ppc_alt = <&ppc_port0_alt>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/hoglin/battery.dtsi b/zephyr/projects/herobrine/hoglin/battery.dtsi deleted file mode 100644 index 11180c3988..0000000000 --- a/zephyr/projects/herobrine/hoglin/battery.dtsi +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: 7c01 { - compatible = "ganfeng,7c01", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/hoglin/gpio.dtsi b/zephyr/projects/herobrine/hoglin/gpio.dtsi deleted file mode 100644 index cb7babc9cf..0000000000 --- a/zephyr/projects/herobrine/hoglin/gpio.dtsi +++ /dev/null @@ -1,327 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpio5 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_y_c1: ec_chg_led_b_c1 { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_w_c1: ec_chg_led_r_c1 { - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpiod 5 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; diff --git a/zephyr/projects/herobrine/hoglin/i2c.dtsi b/zephyr/projects/herobrine/hoglin/i2c.dtsi deleted file mode 100644 index ca2529cbaa..0000000000 --- a/zephyr/projects/herobrine/hoglin/i2c.dtsi +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@1b { - compatible = "parade,ps8xxx"; - reg = <0x1b>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@1b { - compatible = "parade,ps8xxx"; - reg = <0x1b>; - }; -}; diff --git a/zephyr/projects/herobrine/hoglin/led_pins.dtsi b/zephyr/projects/herobrine/hoglin/led_pins.dtsi deleted file mode 100644 index 7b125c5cac..0000000000 --- a/zephyr/projects/herobrine/hoglin/led_pins.dtsi +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_b_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_b_c0 1>, - <&gpio_ec_chg_led_r_c0 0>; - }; - - color_red: color-red { - led-color = "LED_RED"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_RED"; - led-pins = <&gpio_ec_chg_led_b_c0 0>, - <&gpio_ec_chg_led_r_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/hoglin/led_policy.dtsi b/zephyr/projects/herobrine/hoglin/led_policy.dtsi deleted file mode 100644 index 043dfbcaa5..0000000000 --- a/zephyr/projects/herobrine/hoglin/led_policy.dtsi +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* Blue 1 sec, off 3 sec */ - color-0 { - led-color = <&color_blue>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Red 1 sec, off 1 sec */ - color-0 { - led-color = <&color_red>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_red>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Red 2 sec, Blue 2 sec */ - color-0 { - led-color = <&color_red>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_blue>; - period-ms = <2000>; - }; - }; - - power-state-idle-default { - charge-state = "PWR_STATE_IDLE"; - - color-0 { - led-color = <&color_red>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/hoglin/motionsense.dtsi b/zephyr/projects/herobrine/hoglin/motionsense.dtsi deleted file mode 100644 index c3935178ff..0000000000 --- a/zephyr/projects/herobrine/hoglin/motionsense.dtsi +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - tcs3400-int = &als_clear; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <(-1) 0 0 - 0 (-1) 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - - tcs_clear_data: tcs3400-clear-drv-data { - compatible = "cros-ec,drvdata-tcs3400-clear"; - status = "okay"; - - als-drv-data { - compatible = "cros-ec,accelgyro-als-drv-data"; - als-cal { - scale = <1>; - uscale = <0>; - offset = <0>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - - tcs_rgb_data: tcs3400-rgb-drv-data { - compatible = "cros-ec,drvdata-tcs3400-rgb"; - status = "okay"; - - /* node for rgb_calibration_t defined in accelgyro.h */ - rgb_calibration { - compatible = - "cros-ec,accelgyro-rgb-calibration"; - - irt = <1>; - - rgb-cal-x { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-y { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-z { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma4xx_data>; - i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - - als_clear: base-als-clear { - compatible = "cros-ec,tcs3400-clear"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - port = <&i2c_sensor>; - default-range = <0x10000>; - drv-data = <&tcs_clear_data>; - i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - /* Run ALS sensor in S0 */ - odr = <1000>; - }; - }; - }; - - base-als-rgb { - compatible = "cros-ec,tcs3400-rgb"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - default-range = <0x10000>; /* scale = 1x, uscale = 0 */ - drv-data = <&tcs_rgb_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* list of entries for motion_als_sensors */ - als-sensors = <&als_clear>; - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel &als_clear>; - }; -}; diff --git a/zephyr/projects/herobrine/hoglin/project.conf b/zephyr/projects/herobrine/hoglin/project.conf deleted file mode 100644 index c6e20937c0..0000000000 --- a/zephyr/projects/herobrine/hoglin/project.conf +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Hoglin reference-board-specific Kconfig settings. -CONFIG_BOARD_HOGLIN=y -CONFIG_PLATFORM_EC_ACCEL_BMA255=n -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y - -# Sensors -CONFIG_PLATFORM_EC_ALS=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ALS_TCS3400=y -CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/hoglin/project.overlay b/zephyr/projects/herobrine/hoglin/project.overlay deleted file mode 100644 index d68a5a80d1..0000000000 --- a/zephyr/projects/herobrine/hoglin/project.overlay +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Herobrine program common DTS includes */ -#include "../adc.dtsi" -#include "../common.dtsi" -#include "../interrupts.dtsi" -#include "../keyboard.dtsi" -#include "../default_gpio_pinctrl.dtsi" - -/* Hoglin project DTS includes*/ -#include "battery.dtsi" -#include "gpio.dtsi" -#include "i2c.dtsi" -#include "led_pins.dtsi" -#include "led_policy.dtsi" -#include "motionsense.dtsi" -#include "switchcap.dtsi" -#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/hoglin/switchcap.dtsi b/zephyr/projects/herobrine/hoglin/switchcap.dtsi deleted file mode 100644 index 7c083667a1..0000000000 --- a/zephyr/projects/herobrine/hoglin/switchcap.dtsi +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - switchcap { - compatible = "switchcap-gpio"; - enable-pin = <&gpio_switchcap_on>; - poff-delay-ms = <550>; - }; -}; diff --git a/zephyr/projects/herobrine/hoglin/usbc.dtsi b/zephyr/projects/herobrine/hoglin/usbc.dtsi deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/projects/herobrine/hoglin/usbc.dtsi +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/i2c.dtsi b/zephyr/projects/herobrine/i2c.dtsi deleted file mode 100644 index b1ed0242c0..0000000000 --- a/zephyr/projects/herobrine/i2c.dtsi +++ /dev/null @@ -1,157 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - i2c-0 = &i2c0_0; - i2c-1 = &i2c1_0; - i2c-2 = &i2c2_0; - i2c-3 = &i2c3_0; - i2c-4 = &i2c4_1; - i2c-5 = &i2c5_0; - i2c-7 = &i2c7_0; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_power: power { - i2c-port = <&i2c0_0>; - remote-port = <0>; - enum-names = "I2C_PORT_POWER", - "I2C_PORT_BATTERY", - "I2C_PORT_VIRTUAL_BATTERY", - "I2C_PORT_CHARGER"; - }; - i2c_tcpc0: tcpc0 { - i2c-port = <&i2c1_0>; - dynamic-speed; - enum-names = "I2C_PORT_TCPC0"; - }; - i2c_tcpc1: tcpc1 { - i2c-port = <&i2c2_0>; - dynamic-speed; - enum-names = "I2C_PORT_TCPC1"; - }; - rtc { - i2c-port = <&i2c4_1>; - enum-names = "I2C_PORT_RTC"; - }; - i2c_eeprom: eeprom { - i2c-port = <&i2c5_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_sensor: sensor { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_SENSOR", - "I2C_PORT_ACCEL"; - }; - }; - - -}; - -&i2c0_0 { - label = "I2C_POWER"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - charger: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - label = "I2C_USB_C0_PD"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - label = "I2C_USB_C1_PD"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - /* Not used as no WLC connected */ - clock-frequency = ; -}; - -&i2c4_1 { - label = "I2C_RTC"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; - pinctrl-names = "default"; - - pcf85063a: pcf85063a@51 { - compatible = "nxp,rtc-pcf85063a"; - reg = <0x51>; - int-pin = <&gpio_rtc_ec_wake_odl>; - }; -}; - -&i2c_ctrl4 { - status = "okay"; -}; - -&i2c5_0 { - label = "I2C_EEPROM"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c1_bc12>; - }; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c7_0 { - label = "I2C_SENSOR"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/herobrine/include/board_chipset.h b/zephyr/projects/herobrine/include/board_chipset.h deleted file mode 100644 index 81c0dd1a40..0000000000 --- a/zephyr/projects/herobrine/include/board_chipset.h +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __CROS_EC_HEROBRINE_BOARD_CHIPSET_H -#define __CROS_EC_HEROBRINE_BOARD_CHIPSET_H - -__test_only void reset_pp5000_inited(void); - -#endif /* __CROS_EC_HEROBRINE_BOARD_CHIPSET_H */ diff --git a/zephyr/projects/herobrine/interrupts.dtsi b/zephyr/projects/herobrine/interrupts.dtsi deleted file mode 100644 index 82650bfc51..0000000000 --- a/zephyr/projects/herobrine/interrupts.dtsi +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp_l; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_ac_present: ac_present { - irq-pin = <&gpio_chg_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open_ec>; - flags = ; - handler = "lid_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_ec_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_ec_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_ap_rst: ap_rst { - irq-pin = <&gpio_ap_rst_l>; - flags = ; - handler = "chipset_ap_rst_interrupt"; - }; - int_ap_suspend: ap_suspend { - irq-pin = <&gpio_ap_suspend>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_power_good: power_good { - irq-pin = <&gpio_mb_power_good>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ps_hold: ps_hold { - irq-pin = <&gpio_ps_hold>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_warm_reset: warm_reset { - irq-pin = <&gpio_warm_reset_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_usb_c0_pd: usb_c0_pd { - irq-pin = <&gpio_usb_c0_pd_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_pd: usb_c1_pd { - irq-pin = <&gpio_usb_c1_pd_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_swctl: usb_c0_swctl { - irq-pin = <&gpio_usb_c0_swctl_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_swctl: usb_c1_swctl { - irq-pin = <&gpio_usb_c1_swctl_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_l>; - flags = ; - handler = "usb0_evt"; - }; - int_usb_c1_bc12: usb_c1_bc12 { - irq-pin = <&gpio_usb_c1_bc12_int_l>; - flags = ; - handler = "usb1_evt"; - }; - int_usb_a0_oc: usb_a0_oc { - irq-pin = <&gpio_usb_a0_oc_odl>; - flags = ; - handler = "usba_oc_interrupt"; - }; - int_accel_gyro: accel_gyro { - irq-pin = <&gpio_accel_gyro_int_l>; - flags = ; - handler = "bmi260_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/keyboard.dtsi b/zephyr/projects/herobrine/keyboard.dtsi deleted file mode 100644 index 3b7e830f2f..0000000000 --- a/zephyr/projects/herobrine/keyboard.dtsi +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm3 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; - generic-pwm-channel = <0>; - }; -}; - -&pwm3 { - status = "okay"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/herobrine/motionsense.dtsi b/zephyr/projects/herobrine/motionsense.dtsi deleted file mode 100644 index 1955f43284..0000000000 --- a/zephyr/projects/herobrine/motionsense.dtsi +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - tcs3400-int = &als_clear; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma255_data: bma255-drv-data { - compatible = "cros-ec,drvdata-bma255"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - - tcs_clear_data: tcs3400-clear-drv-data { - compatible = "cros-ec,drvdata-tcs3400-clear"; - status = "okay"; - - als-drv-data { - compatible = "cros-ec,accelgyro-als-drv-data"; - als-cal { - scale = <1>; - uscale = <0>; - offset = <0>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - - tcs_rgb_data: tcs3400-rgb-drv-data { - compatible = "cros-ec,drvdata-tcs3400-rgb"; - status = "okay"; - - /* node for rgb_calibration_t defined in accelgyro.h */ - rgb_calibration { - compatible = - "cros-ec,accelgyro-rgb-calibration"; - - irt = <1>; - - rgb-cal-x { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-y { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-z { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma255"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma255_data>; - i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - - als_clear: base-als-clear { - compatible = "cros-ec,tcs3400-clear"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - port = <&i2c_sensor>; - default-range = <0x10000>; - drv-data = <&tcs_clear_data>; - i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - /* Run ALS sensor in S0 */ - odr = <1000>; - }; - }; - }; - - base-als-rgb { - compatible = "cros-ec,tcs3400-rgb"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - default-range = <0x10000>; /* scale = 1x, uscale = 0 */ - drv-data = <&tcs_rgb_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* list of entries for motion_als_sensors */ - als-sensors = <&als_clear>; - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel &als_clear>; - }; -}; diff --git a/zephyr/projects/herobrine/program.conf b/zephyr/projects/herobrine/program.conf deleted file mode 100644 index 3391e60dce..0000000000 --- a/zephyr/projects/herobrine/program.conf +++ /dev/null @@ -1,160 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_BRINGUP=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_CBI_GPIO=y -CONFIG_KERNEL_SHELL=y -CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y - -# I2C options -CONFIG_I2C=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y -CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y - -# Shell history and tab autocompletion (for convenience) -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=n -CONFIG_PLATFORM_EC_LED_DT=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# Application Processor is Qualcomm SC7280 -CONFIG_AP_ARM_QUALCOMM_SC7280=y - -# GPIO Switchcap -CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y - -# Board version is selected over GPIO board ID pins. -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y - -# Power Sequencing -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y -CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y - -# MKBP event -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_CMD_BUTTON=y -CONFIG_CROS_KB_RAW_NPCX=y - -# ADC -CONFIG_ADC=y -CONFIG_ADC_SHELL=n - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y -CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y -CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y -CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y -CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION" -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=12500 -CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y - -# USB-A -CONFIG_PLATFORM_EC_USBA=y - -# USB-C -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n -CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y -CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y -CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_DPS=y -CONFIG_PLATFORM_EC_USB_PD_REV30=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=2 - -# USB ID -# This is allocated specifically for Herobrine -# http://google3/hardware/standards/usb/ -# TODO(b/183608112): Move to device tree -CONFIG_PLATFORM_EC_USB_PID=0x5055 - -# RTC -CONFIG_PLATFORM_EC_RTC=y -CONFIG_CROS_RTC_NXP_PCF85063A=y -CONFIG_PLATFORM_EC_HOSTCMD_RTC=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM=y - -# EC software sync -CONFIG_PLATFORM_EC_VBOOT_HASH=y - -# Sensors -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 - -# Sensor Drivers -CONFIG_PLATFORM_EC_ACCEL_BMA255=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -CONFIG_SYSCON=y -CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y diff --git a/zephyr/projects/herobrine/src/board_chipset.c b/zephyr/projects/herobrine/src/board_chipset.c deleted file mode 100644 index 2312bdb1c4..0000000000 --- a/zephyr/projects/herobrine/src/board_chipset.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Herobrine chipset-specific configuration */ - -#include "charger.h" -#include "common.h" -#include "console.h" -#include "battery.h" -#include "gpio.h" -#include "hooks.h" -#include "timer.h" -#include "usb_pd.h" - -#include "board_chipset.h" - -#define CPRINTS(format, args...) cprints(CC_HOOK, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_HOOK, format, ##args) - -/* - * A window of PD negotiation. It starts from the Type-C state reaching - * Attached.SNK, and ends when the PD contract is created. The VBUS may be - * raised anytime in this window. - * - * The current implementation is the worst case scenario: every message the PD - * negotiation is received at the last moment before timeout. More extra time - * is added to compensate the delay internally, like the decision of the DPM. - * - * TODO(waihong): Cancel this timer when the PD contract is negotiated. - */ -#define PD_READY_TIMEOUT \ - (PD_T_SINK_WAIT_CAP + PD_T_SENDER_RESPONSE + PD_T_SINK_TRANSITION + \ - 20 * MSEC) - -#define PD_READY_POLL_DELAY (10 * MSEC) - -static timestamp_t pd_ready_timeout; - -static bool pp5000_inited; - -__test_only void reset_pp5000_inited(void) -{ - pp5000_inited = false; -} - -/* Called on USB PD connected */ -static void board_usb_pd_connect(void) -{ - int soc = -1; - - /* First boot, battery unattached or low SOC */ - if (!pp5000_inited && - ((battery_state_of_charge_abs(&soc) != EC_SUCCESS || - soc < charger_get_min_bat_pct_for_power_on()))) { - pd_ready_timeout = get_time(); - pd_ready_timeout.val += PD_READY_TIMEOUT; - } -} -DECLARE_HOOK(HOOK_USB_PD_CONNECT, board_usb_pd_connect, HOOK_PRIO_DEFAULT); - -static void wait_pd_ready(void) -{ - CPRINTS("Wait PD negotiated VBUS transition %u", - pd_ready_timeout.le.lo); - while (pd_ready_timeout.val && get_time().val < pd_ready_timeout.val) - usleep(PD_READY_POLL_DELAY); -} - -/* Called on AP S5 -> S3 transition */ -static void board_chipset_pre_init(void) -{ - if (!pp5000_inited) { - if (pd_ready_timeout.val) { - wait_pd_ready(); - } - CPRINTS("Enable 5V rail"); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_s5), 1); - pp5000_inited = true; - } -} -DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/herobrine/src/i2c.c b/zephyr/projects/herobrine/src/i2c.c deleted file mode 100644 index 88b722c42d..0000000000 --- a/zephyr/projects/herobrine/src/i2c.c +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * 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" - -/* Herobrine-NPCX9 board specific i2c implementation */ - -#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED -int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) -{ - return (i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY)); -} -#endif diff --git a/zephyr/projects/herobrine/src/usb_pd_policy.c b/zephyr/projects/herobrine/src/usb_pd_policy.c deleted file mode 100644 index adc517d3cb..0000000000 --- a/zephyr/projects/herobrine/src/usb_pd_policy.c +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "charge_manager.h" -#include "chipset.h" -#include "console.h" -#include "system.h" -#include "usb_mux.h" -#include "usbc_ppc.h" -#include "util.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -int pd_check_vconn_swap(int port) -{ - /* In G3, do not allow vconn swap since PP5000 rail is off */ - return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_s5)); -} - -static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; - -static void board_vbus_update_source_current(int port) -{ - ppc_vbus_source_enable(port, vbus_en[port]); -} - -void pd_power_supply_reset(int port) -{ - int prev_en; - - prev_en = vbus_en[port]; - - /* Disable VBUS */ - vbus_en[port] = 0; - board_vbus_update_source_current(port); - - /* Enable discharge if we were previously sourcing 5V */ - if (prev_en) - pd_set_vbus_discharge(port, 1); - - /* notify host of power info change */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - /* Disable charging */ - board_vbus_sink_enable(port, 0); - - pd_set_vbus_discharge(port, 0); - - /* Provide VBUS */ - vbus_en[port] = 1; - board_vbus_update_source_current(port); - - /* notify host of power info change */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; /* we are ready */ -} - -int board_vbus_source_enabled(int port) -{ - return vbus_en[port]; -} - -int pd_snk_is_vbus_provided(int port) -{ - return tcpm_check_vbus_level(port, VBUS_PRESENT); -} - -/* ----------------- Vendor Defined Messages ------------------ */ -#ifdef CONFIG_USB_PD_ALT_MODE_DFP -__override int svdm_dp_config(int port, uint32_t *payload) -{ - int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); - uint8_t pin_mode = get_dp_pin_mode(port); - - if (!pin_mode) - return 0; - - /* - * Defer setting the usb_mux until HPD goes high, svdm_dp_attention(). - * The AP only supports one DP phy. An external DP mux switches between - * the two ports. Should switch those muxes when it is really used, - * i.e. HPD high; otherwise, the real use case is preempted, like: - * (1) plug a dongle without monitor connected to port-0, - * (2) plug a dongle without monitor connected to port-1, - * (3) plug a monitor to the port-1 dongle. - */ - - payload[0] = - VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); - payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ - 1, /* DPv1.3 signaling */ - 2); /* UFP connected */ - return 2; -}; - -__override void svdm_dp_post_config(int port) -{ - dp_flags[port] |= DP_FLAGS_DP_ON; -} - -/** - * Is the port fine to be muxed its DisplayPort lines? - * - * Only one port can be muxed to DisplayPort at a time. - * - * @param port Port number of TCPC. - * @return 1 is fine; 0 is bad as other port is already muxed; - */ -static int is_dp_muxable(int port) -{ - int i; - - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) - if (i != port) { - if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED) - return 0; - } - - return 1; -} - -__override int svdm_dp_attention(int port, uint32_t *payload) -{ - const struct gpio_dt_spec *hpd = - GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det_r); - int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); - int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); - int cur_lvl = gpio_pin_get_dt(hpd); - mux_state_t mux_state; - - dp_status[port] = payload[1]; - - if (!is_dp_muxable(port)) { - /* TODO(waihong): Info user? */ - CPRINTS("p%d: The other port is already muxed.", port); - return 0; - } - - /* - * Initial implementation to handle HPD. Only the first-plugged port - * works, i.e. sending HPD signal to AP. The second-plugged port - * will be ignored. - * - * TODO(waihong): Continue the above case, if the first-plugged port - * is then unplugged, switch to the second-plugged port and signal AP? - */ - if (lvl) { - /* - * Enable and switch the DP port selection mux to the - * correct port. - * - * TODO(waihong): Better to move switching DP mux to - * the usb_mux abstraction. - */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), - port == 1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0); - - /* Connect the SBU lines in PPC chip. */ - if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) - ppc_set_sbu(port, 1); - - /* - * Connect the USB SS/DP lines in TCPC chip. - * - * When mf_pref not true, still use the dock muxing - * because of the board USB-C topology (limited to 2 - * lanes DP). - */ - usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT, - polarity_rm_dts(pd_get_polarity(port))); - } else { - /* Disconnect the DP port selection mux. */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); - - /* Disconnect the SBU lines in PPC chip. */ - if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) - ppc_set_sbu(port, 0); - - /* Disconnect the DP but keep the USB SS lines in TCPC chip. */ - usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, - polarity_rm_dts(pd_get_polarity(port))); - } - - if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) - /* - * Wake up the AP. IRQ or level high indicates a DP sink is now - * present. - */ - pd_notify_dp_alt_mode_entry(port); - - /* Configure TCPC for the HPD event, for proper muxing */ - mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) | - (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED); - usb_mux_hpd_update(port, mux_state); - - /* Signal AP for the HPD event, through GPIO to AP */ - if (irq & cur_lvl) { - uint64_t now = get_time().val; - /* Wait for the minimum spacing between IRQ_HPD if needed */ - if (now < svdm_hpd_deadline[port]) - usleep(svdm_hpd_deadline[port] - now); - - /* Generate IRQ_HPD pulse */ - CPRINTS("C%d: Recv IRQ. HPD->0", port); - gpio_pin_set_dt(hpd, 0); - usleep(HPD_DSTREAM_DEBOUNCE_IRQ); - gpio_pin_set_dt(hpd, 1); - CPRINTS("C%d: Recv IRQ. HPD->1", port); - - /* Set the minimum time delay (2ms) for the next HPD IRQ */ - svdm_hpd_deadline[port] = - get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - } else if (irq & !lvl) { - CPRINTF("ERR:HPD:IRQ&LOW\n"); - return 0; - } else { - CPRINTS("C%d: Recv lvl. HPD->%d", port, lvl); - gpio_pin_set_dt(hpd, lvl); - /* Set the minimum time delay (2ms) for the next HPD IRQ */ - svdm_hpd_deadline[port] = - get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - } - - return 1; -} - -__override void svdm_exit_dp_mode(int port) -{ - CPRINTS("%s(%d)", __func__, port); - if (is_dp_muxable(port)) { - /* Disconnect the DP port selection mux. */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); - - /* Signal AP for the HPD low event */ - usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); - CPRINTS("C%d: DP exit. HPD->0", port); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det_r), - 0); - } -} -#endif /* CONFIG_USB_PD_ALT_MODE_DFP */ diff --git a/zephyr/projects/herobrine/src/usbc_config.c b/zephyr/projects/herobrine/src/usbc_config.c deleted file mode 100644 index f040ab12cb..0000000000 --- a/zephyr/projects/herobrine/src/usbc_config.c +++ /dev/null @@ -1,278 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Herobrine board-specific USB-C configuration */ - -#include - -#include "charger.h" -#include "charger/isl923x_public.h" -#include "charge_manager.h" -#include "charge_state.h" -#include "common.h" -#include "config.h" -#include "cros_board_info.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "ppc/sn5s330_public.h" -#include "ppc/syv682x_public.h" -#include "system.h" -#include "tcpm/ps8xxx_public.h" -#include "tcpm/tcpci.h" -#include "timer.h" -#include "usb_pd.h" -#include "usb_mux.h" -#include "usbc_ocp.h" -#include "usbc_ppc.h" -#include "usbc/ppc.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* GPIO Interrupt Handlers */ -void tcpc_alert_event(enum gpio_signal signal) -{ - int port = -1; - - switch (signal) { - case GPIO_USB_C0_PD_INT_ODL: - port = 0; - break; - case GPIO_USB_C1_PD_INT_ODL: - port = 1; - break; - default: - return; - } - - schedule_deferred_pd_interrupt(port); -} - -static void usba_oc_deferred(void) -{ - /* Use next number after all USB-C ports to indicate the USB-A port */ - board_overcurrent_event( - CONFIG_USB_PD_PORT_MAX_COUNT, - !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_a0_oc_odl))); -} -DECLARE_DEFERRED(usba_oc_deferred); - -void usba_oc_interrupt(enum gpio_signal signal) -{ - hook_call_deferred(&usba_oc_deferred_data, 0); -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_SWCTL_INT_ODL: - ppc_chips[0].drv->interrupt(0); - break; - - case GPIO_USB_C1_SWCTL_INT_ODL: - ppc_chips[1].drv->interrupt(1); - break; - - default: - break; - } -} - -int charger_profile_override(struct charge_state_data *curr) -{ - int usb_mv; - int port; - - if (curr->state != ST_CHARGE) - return 0; - - /* Lower the max requested voltage to 5V when battery is full. */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF) && - !(curr->batt.flags & BATT_FLAG_BAD_STATUS) && - !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) && - (curr->batt.status & STATUS_FULLY_CHARGED)) - usb_mv = 5000; - else - usb_mv = PD_MAX_VOLTAGE_MV; - - if (pd_get_max_voltage() != usb_mv) { - CPRINTS("VBUS limited to %dmV", usb_mv); - for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) - pd_set_external_voltage_limit(port, usb_mv); - } - - return 0; -} - -enum ec_status charger_profile_override_get_param(uint32_t param, - uint32_t *value) -{ - return EC_RES_INVALID_PARAM; -} - -enum ec_status charger_profile_override_set_param(uint32_t param, - uint32_t value) -{ - return EC_RES_INVALID_PARAM; -} - -/* Initialize board USC-C things */ -static void board_init_usbc(void) -{ - /* Enable USB-A overcurrent interrupt */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc)); -} -DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT); - -void board_tcpc_init(void) -{ - /* Only reset TCPC if not sysjump */ - if (!system_jumped_late()) { - /* TODO(crosbug.com/p/61098): How long do we need to wait? */ - board_reset_pd_mcu(); - } - - /* Enable PPC interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl)); - - /* Enable TCPC interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_pd)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_pd)); - - /* - * Initialize HPD to low; after sysjump SOC needs to see - * HPD pulse to enable video path - */ - for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) - usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); -} -DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C); - -void board_reset_pd_mcu(void) -{ - cprints(CC_USB, "Resetting TCPCs..."); - cflush(); - - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0); - msleep(PS8XXX_RESET_DELAY_MS); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1); - msleep(PS8805_FW_INIT_DELAY_MS); -} - -void board_set_tcpc_power_mode(int port, int mode) -{ - /* Ignore the "mode" to turn the chip on. We can only do a reset. */ - if (mode) - return; - - board_reset_pd_mcu(); -} - -int board_vbus_sink_enable(int port, int enable) -{ - /* Both ports are controlled by PPC SN5S330 */ - return ppc_vbus_sink_enable(port, enable); -} - -int board_is_sourcing_vbus(int port) -{ - /* Both ports are controlled by PPC SN5S330 */ - return ppc_is_sourcing_vbus(port); -} - -void board_overcurrent_event(int port, int is_overcurrented) -{ - /* TODO(b/120231371): Notify AP */ - CPRINTS("p%d: overcurrent!", port); -} - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - if (port == CHARGE_PORT_NONE) { - CPRINTS("Disabling all charging port"); - - /* Disable all ports. */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - /* - * Do not return early if one fails otherwise we can - * get into a boot loop assertion failure. - */ - if (board_vbus_sink_enable(i, 0)) - CPRINTS("Disabling p%d sink path failed.", i); - } - - return EC_SUCCESS; - } - - /* Check if the port is sourcing VBUS. */ - if (board_is_sourcing_vbus(port)) { - CPRINTS("Skip enable p%d", port); - return EC_ERROR_INVAL; - } - - CPRINTS("New charge port: p%d", port); - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (i == port) - continue; - - if (board_vbus_sink_enable(i, 0)) - CPRINTS("p%d: sink path disable failed.", i); - } - - /* Enable requested charge port. */ - if (board_vbus_sink_enable(port, 1)) { - CPRINTS("p%d: sink path enable failed.", port); - return EC_ERROR_UNKNOWN; - } - - return EC_SUCCESS; -} - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * Ignore lower charge ceiling on PD transition if our battery is - * critical, as we may brownout. - */ - if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 && - charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) { - CPRINTS("Using max ilim %d", max_ma); - charge_ma = max_ma; - } - - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) - if (gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l))) - status |= PD_STATUS_TCPC_ALERT_0; - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_int_odl))) - if (gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l))) - status |= PD_STATUS_TCPC_ALERT_1; - - return status; -} diff --git a/zephyr/projects/herobrine/switchcap.dtsi b/zephyr/projects/herobrine/switchcap.dtsi deleted file mode 100644 index ed200a0c6f..0000000000 --- a/zephyr/projects/herobrine/switchcap.dtsi +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - switchcap { - compatible = "switchcap-gpio"; - enable-pin = <&gpio_switchcap_on>; - power-good-pin = <&gpio_switchcap_pg>; - }; -}; diff --git a/zephyr/projects/herobrine/villager/battery.dtsi b/zephyr/projects/herobrine/villager/battery.dtsi deleted file mode 100644 index dafd473a6e..0000000000 --- a/zephyr/projects/herobrine/villager/battery.dtsi +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap19a5k { - compatible = "panasonic,ap19a5k", "battery-smart"; - }; - ap19a8k { - compatible = "lgc,ap19a8k", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/villager/gpio.dtsi b/zephyr/projects/herobrine/villager/gpio.dtsi deleted file mode 100644 index 1e7625ff6a..0000000000 --- a/zephyr/projects/herobrine/villager/gpio.dtsi +++ /dev/null @@ -1,323 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 3 0>, - <&gpioc 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpio5 0 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; diff --git a/zephyr/projects/herobrine/villager/i2c.dtsi b/zephyr/projects/herobrine/villager/i2c.dtsi deleted file mode 100644 index 02d1729dd1..0000000000 --- a/zephyr/projects/herobrine/villager/i2c.dtsi +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/projects/herobrine/villager/led_pins.dtsi b/zephyr/projects/herobrine/villager/led_pins.dtsi deleted file mode 100644 index b0913cdbce..0000000000 --- a/zephyr/projects/herobrine/villager/led_pins.dtsi +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_b_c0 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/villager/led_policy.dtsi b/zephyr/projects/herobrine/villager/led_policy.dtsi deleted file mode 100644 index f8996a3f4b..0000000000 --- a/zephyr/projects/herobrine/villager/led_policy.dtsi +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Blue 2 sec, Amber 2 sec */ - color-0 { - led-color = <&color_blue>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - }; - - power-state-idle { - charge-state = "PWR_STATE_IDLE"; - - color-0 { - led-color = <&color_blue>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/villager/motionsense.dtsi b/zephyr/projects/herobrine/villager/motionsense.dtsi deleted file mode 100644 index 31d00e04a5..0000000000 --- a/zephyr/projects/herobrine/villager/motionsense.dtsi +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - kx022_data: kx022-drv-data { - compatible = "cros-ec,drvdata-kionix"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,kx022"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&kx022_data>; - i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/herobrine/villager/project.conf b/zephyr/projects/herobrine/villager/project.conf deleted file mode 100644 index 35eebe6d99..0000000000 --- a/zephyr/projects/herobrine/villager/project.conf +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Villager board-specific Kconfig settings. -CONFIG_BOARD_VILLAGER=y - -CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/projects/herobrine/villager/project.overlay b/zephyr/projects/herobrine/villager/project.overlay deleted file mode 100644 index a18d6416dd..0000000000 --- a/zephyr/projects/herobrine/villager/project.overlay +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Herobrine program common DTS includes */ -#include "../adc.dtsi" -#include "../common.dtsi" -#include "../interrupts.dtsi" -#include "../keyboard.dtsi" -#include "../default_gpio_pinctrl.dtsi" -#include "../switchcap.dtsi" - -/* Villager project DTS includes*/ -#include "battery.dtsi" -#include "gpio.dtsi" -#include "i2c.dtsi" -#include "led_pins.dtsi" -#include "led_policy.dtsi" -#include "motionsense.dtsi" -#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/villager/usbc.dtsi b/zephyr/projects/herobrine/villager/usbc.dtsi deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/projects/herobrine/villager/usbc.dtsi +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/zoglin/project.conf b/zephyr/projects/herobrine/zoglin/project.conf deleted file mode 100644 index 7f96cf6c79..0000000000 --- a/zephyr/projects/herobrine/zoglin/project.conf +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Zoglin reference-board-specific Kconfig settings. -CONFIG_BOARD_ZOGLIN=y -CONFIG_PLATFORM_EC_ACCEL_BMA255=n -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y - -# Sensors -CONFIG_PLATFORM_EC_ALS=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ALS_TCS3400=y -CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y diff --git a/zephyr/projects/herobrine/zoglin/project.overlay b/zephyr/projects/herobrine/zoglin/project.overlay deleted file mode 100644 index 55f7dd73fc..0000000000 --- a/zephyr/projects/herobrine/zoglin/project.overlay +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Herobrine program common DTS includes */ -#include "../adc.dtsi" -#include "../common.dtsi" -#include "../interrupts.dtsi" -#include "../keyboard.dtsi" -#include "../default_gpio_pinctrl.dtsi" - -/* Zoglin project DTS includes*/ -#include "../hoglin/battery.dtsi" -#include "../hoglin/gpio.dtsi" -#include "../hoglin/i2c.dtsi" -#include "../hoglin/led_pins.dtsi" -#include "../hoglin/led_policy.dtsi" -#include "../hoglin/motionsense.dtsi" -#include "../hoglin/switchcap.dtsi" -#include "../hoglin/usbc.dtsi" diff --git a/zephyr/projects/herobrine/zombie/battery.dtsi b/zephyr/projects/herobrine/zombie/battery.dtsi deleted file mode 100644 index dafd473a6e..0000000000 --- a/zephyr/projects/herobrine/zombie/battery.dtsi +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap19a5k { - compatible = "panasonic,ap19a5k", "battery-smart"; - }; - ap19a8k { - compatible = "lgc,ap19a8k", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/herobrine/zombie/gpio.dtsi b/zephyr/projects/herobrine/zombie/gpio.dtsi deleted file mode 100644 index 14ed1f54d6..0000000000 --- a/zephyr/projects/herobrine/zombie/gpio.dtsi +++ /dev/null @@ -1,323 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; - gpio_chg_acok_od: chg_acok_od { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpio5 1 GPIO_INPUT>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_mb_power_good: mb_power_good { - gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_rtc_ec_wake_odl: rtc_ec_wake_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpio7 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - ec_gsc_packet_mode { - gpios = <&gpio8 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - pmic_resin_l { - gpios = <&gpioa 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ap_ec_int_l { - gpios = <&gpio5 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - /* The PMIC controls backlight enable and this pin must - * be HiZ for normal operation. But the backlight can - * be enabled by setting this pin low and configuring it - * as an output. - */ - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - lid_accel_int_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - tp_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpiob 1 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpioc 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_FRS_EN"; - }; - gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - ap_ec_spi_mosi { - gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_miso { - gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>; - }; - ap_ec_spi_clk { - gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpioa 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - gpio_switchcap_pg: src_vph_pwr_pg { - gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_SWITCHCAP_PG"; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "ternary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "ternary"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 2 0>, - <&gpio5 4 0>, - <&gpio7 6 0>, - <&gpiod 1 0>, - <&gpiod 0 0>, - <&gpioe 3 0>, - <&gpio0 4 0>, - <&gpiod 6 0>, - <&gpio3 2 0>, - <&gpio3 5 0>, - <&gpiod 7 0>, - <&gpio8 6 0>, - <&gpiod 4 0>, - <&gpio4 1 0>, - <&gpio3 4 0>, - <&gpioc 3 0>, - <&gpioc 4 0>, - <&gpioc 7 0>, - <&gpioa 4 0>, - <&gpio9 6 0>, - <&gpio9 3 0>, - <&gpioa 7 0>, - <&gpio5 0 0>, - <&gpio8 1 0>, - <&gpiob 7 0>; - }; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* EC_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in3_gp01 { - /* LID_OPEN_EC */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* RTC_EC_WAKE_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; diff --git a/zephyr/projects/herobrine/zombie/i2c.dtsi b/zephyr/projects/herobrine/zombie/i2c.dtsi deleted file mode 100644 index 02d1729dd1..0000000000 --- a/zephyr/projects/herobrine/zombie/i2c.dtsi +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/projects/herobrine/zombie/led_pins.dtsi b/zephyr/projects/herobrine/zombie/led_pins.dtsi deleted file mode 100644 index b0913cdbce..0000000000 --- a/zephyr/projects/herobrine/zombie/led_pins.dtsi +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_b_c0 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 1>; - }; - }; -}; diff --git a/zephyr/projects/herobrine/zombie/led_policy.dtsi b/zephyr/projects/herobrine/zombie/led_policy.dtsi deleted file mode 100644 index f8996a3f4b..0000000000 --- a/zephyr/projects/herobrine/zombie/led_policy.dtsi +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Blue 2 sec, Amber 2 sec */ - color-0 { - led-color = <&color_blue>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - }; - - power-state-idle { - charge-state = "PWR_STATE_IDLE"; - - color-0 { - led-color = <&color_blue>; - }; - }; - }; -}; diff --git a/zephyr/projects/herobrine/zombie/motionsense.dtsi b/zephyr/projects/herobrine/zombie/motionsense.dtsi deleted file mode 100644 index e069564b35..0000000000 --- a/zephyr/projects/herobrine/zombie/motionsense.dtsi +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi260-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi260: bmi260-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - kx022_data: kx022-drv-data { - compatible = "cros-ec,drvdata-kionix"; - status = "okay"; - }; - - bmi260_data: bmi260-drv-data { - compatible = "cros-ec,drvdata-bmi260"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,kx022"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&kx022_data>; - i2c-spi-addr-flags = "KX022_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi260-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi260-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi260>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi260_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/herobrine/zombie/project.conf b/zephyr/projects/herobrine/zombie/project.conf deleted file mode 100644 index 037ab5cc05..0000000000 --- a/zephyr/projects/herobrine/zombie/project.conf +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Zombie board-specific Kconfig settings. -CONFIG_BOARD_ZOMBIE=y - -CONFIG_PLATFORM_EC_ACCEL_KX022=y diff --git a/zephyr/projects/herobrine/zombie/project.overlay b/zephyr/projects/herobrine/zombie/project.overlay deleted file mode 100644 index 7b44350e5a..0000000000 --- a/zephyr/projects/herobrine/zombie/project.overlay +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Herobrine program common DTS includes */ -#include "../adc.dtsi" -#include "../common.dtsi" -#include "../interrupts.dtsi" -#include "../keyboard.dtsi" -#include "../default_gpio_pinctrl.dtsi" -#include "../switchcap.dtsi" - -/* Zombie project DTS includes*/ -#include "battery.dtsi" -#include "gpio.dtsi" -#include "i2c.dtsi" -#include "led_pins.dtsi" -#include "led_policy.dtsi" -#include "motionsense.dtsi" -#include "usbc.dtsi" diff --git a/zephyr/projects/herobrine/zombie/usbc.dtsi b/zephyr/projects/herobrine/zombie/usbc.dtsi deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/projects/herobrine/zombie/usbc.dtsi +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/BUILD.py b/zephyr/projects/intelrvp/BUILD.py deleted file mode 100644 index f129b3d2d2..0000000000 --- a/zephyr/projects/intelrvp/BUILD.py +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for intelrvp.""" - -# intelrvp has adlrvp_npcx, adlrvpp_ite, adlrvpp_mchp etc - - -def register_intelrvp_project( - project_name, - chip="npcx9m3f", - extra_dts_overlays=(), - extra_kconfig_files=(), -): - """Register a variant of intelrvp.""" - register_func = register_binman_project - if chip.startswith("mec1727"): - register_func = register_mchp_project - elif chip.startswith("npcx"): - register_func = register_npcx_project - - kconfig_files = [here / "prj.conf"] - dts_overlays = [] - if project_name.startswith("adlrvp"): - kconfig_files.append(here / "adlrvp/prj.conf") - dts_overlays.append(here / "adlrvp/battery.dts") - dts_overlays.append(here / "adlrvp/ioex.dts") - if project_name.startswith("mtlrvp"): - kconfig_files.append(here / "mtlrvp/prj.conf") - dts_overlays.append(here / "adlrvp/battery.dts") - kconfig_files.extend(extra_kconfig_files) - dts_overlays.extend(extra_dts_overlays) - - register_func( - project_name=project_name, - zephyr_board=chip, - dts_overlays=dts_overlays, - kconfig_files=kconfig_files, - ) - - -register_intelrvp_project( - project_name="adlrvp_mchp", - chip="mec1727", - extra_dts_overlays=[ - here / "adlrvp/adlrvp_mchp/adlrvp_mchp.dts", - here / "adlrvp/adlrvp_mchp/gpio.dts", - here / "adlrvp/adlrvp_mchp/interrupts.dts", - here / "adlrvp/adlrvp_mchp/keyboard.dts", - here / "adlrvp/adlrvp_mchp/usbc.dts", - ], - extra_kconfig_files=[ - here / "legacy_ec_pwrseq.conf", - here / "adlrvp/adlrvp_mchp/prj.conf", - ], -) - - -register_intelrvp_project( - project_name="adlrvp_npcx", - chip="npcx9m7f", - extra_dts_overlays=[ - here / "adlrvp/adlrvp_npcx/adlrvp_npcx.dts", - here / "adlrvp/adlrvp_npcx/fan.dts", - here / "adlrvp/adlrvp_npcx/gpio.dts", - here / "adlrvp/adlrvp_npcx/interrupts.dts", - here / "adlrvp/adlrvp_npcx/keyboard.dts", - here / "adlrvp/adlrvp_npcx/temp_sensor.dts", - here / "adlrvp/adlrvp_npcx/usbc.dts", - here / "adlrvp/adlrvp_npcx/pwm_leds.dts", - ], - extra_kconfig_files=[ - here / "legacy_ec_pwrseq.conf", - here / "adlrvp/adlrvp_npcx/prj.conf", - ], -) - - -register_intelrvp_project( - project_name="mtlrvpp_npcx", - chip="npcx9m3f", - extra_dts_overlays=[ - here / "mtlrvp/mtlrvpp_npcx/fan.dts", - here / "mtlrvp/mtlrvpp_npcx/gpio.dts", - here / "mtlrvp/mtlrvpp_npcx/keyboard.dts", - here / "mtlrvp/mtlrvpp_npcx/interrupts.dts", - here / "mtlrvp/ioex.dts", - here / "mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts", - here / "mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts", - here / "adlrvp/adlrvp_npcx/temp_sensor.dts", - here / "mtlrvp/usbc.dts", - ], - extra_kconfig_files=[ - here / "zephyr_ap_pwrseq.conf", - here / "mtlrvp/mtlrvpp_npcx/prj.conf", - ], -) diff --git a/zephyr/projects/intelrvp/CMakeLists.txt b/zephyr/projects/intelrvp/CMakeLists.txt deleted file mode 100644 index 039627dec6..0000000000 --- a/zephyr/projects/intelrvp/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(intelrvp) - -cros_ec_library_include_directories(include) -cros_ec_library_include_directories("${PLATFORM_EC}/driver/charger") -cros_ec_library_include_directories("${PLATFORM_EC}/driver/ppc") -cros_ec_library_include_directories("${PLATFORM_EC}/driver/tcpm") -cros_ec_library_include_directories("${PLATFORM_EC}/driver/usb_mux") -zephyr_library_sources("src/intel_rvp_board_id.c") - -if((DEFINED CONFIG_BOARD_ADLRVP_MCHP) OR (DEFINED CONFIG_BOARD_ADLRVP_NPCX)) - add_subdirectory(adlrvp) - zephyr_library_sources("src/intelrvp.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "${PLATFORM_EC}/baseboard/intelrvp/usb_pd_policy_mecc_1_0.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "${PLATFORM_EC}/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "${PLATFORM_EC}/baseboard/intelrvp/chg_usb_pd.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM "src/intel_rvp_led.c") -endif() - -if(DEFINED CONFIG_BOARD_MTLRVP_NPCX) - add_subdirectory(mtlrvp) - zephyr_library_sources("src/intelrvp.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy_mecc_1_1.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/chg_usb_pd_mecc_1_1.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/chg_usb_pd.c") -endif() diff --git a/zephyr/projects/intelrvp/Kconfig b/zephyr/projects/intelrvp/Kconfig deleted file mode 100644 index 605f57c054..0000000000 --- a/zephyr/projects/intelrvp/Kconfig +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -config BOARD_ADLRVP_MCHP - bool "Intel ADLRVP_MCHP board" - depends on SOC_MEC172X_NSZ - help - Build Intel ADLRVP_MCHP reference board. This board has Intel ADL RVP - SoC with MEC1727 EC. - -config BOARD_ADLRVP_NPCX - bool "Intel ADLRVP_NPCX board" - depends on SOC_NPCX9M7F - help - Build Intel ADLRVP_NPCX reference board. This board has Intel ADL RVP - SoC with NPCX9M37F EC. - -config BOARD_MTLRVP_NPCX - bool "Intel MTLRVP_NPCX board" - depends on SOC_NPCX9M3F - help - Build Intel MTLRVP_NPCX reference board. This board is Intel MTL RVP - SOC with NPCX_NPCX9M3F - -source "Kconfig.zephyr" diff --git a/zephyr/projects/intelrvp/adlrvp/CMakeLists.txt b/zephyr/projects/intelrvp/adlrvp/CMakeLists.txt deleted file mode 100644 index 71dee29552..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cros_ec_library_include_directories("include") -zephyr_library_sources("src/adlrvp.c") diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts deleted file mode 100644 index 527a62e776..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts +++ /dev/null @@ -1,201 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_lid_open - &int_power_button - >; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_charger: charger { - i2c-port = <&i2c_smb_0>; - enum-names = "I2C_PORT_BATTERY", - "I2C_PORT_CHARGER", - "I2C_PORT_EEPROM", - "I2C_PORT_PORT80"; - }; - typec_0: typec-0 { - i2c-port = <&i2c_smb_1>; - enum-names = "I2C_PORT_TYPEC_0"; - }; - typec_1: typec-1 { - i2c-port = <&i2c_smb_2>; - enum-names = "I2C_PORT_TYPEC_1"; - }; - typec_2: typec-2 { - i2c-port = <&i2c_smb_3>; - enum-names = "I2C_PORT_TYPEC_2"; - }; - typec_3: typec-3 { - i2c-port = <&i2c_smb_4>; - enum-names = "I2C_PORT_TYPEC_3"; - }; - }; -}; - -/* charger */ -&i2c_smb_0 { - status = "okay"; - clock-frequency = ; - port_sel = <0>; - pinctrl-0 = <&i2c00_scl_gpio004 &i2c00_sda_gpio003>; - pinctrl-names = "default"; - - pca95xx: pca95xx@22 { - compatible = "nxp,pca95xx"; - label = "PCA95XX"; - reg = <0x22>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <16>; - }; - - rvp_board_id: rvp-board-id { - compatible = "intel,rvp-board-id"; - - /* - * BOM ID [2] : IOEX[0] - * BOM ID [1:0] : IOEX[15:14] - */ - bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>; - - /* - * FAB ID [1:0] : IOEX[2:1] - */ - fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>; - - /* - * BOARD ID[5:0] : IOEX[13:8] - */ - board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>, - <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>; - }; - - seven_seg_display: max695x-seven-seg-display@38 { - compatible = "maxim,seven-seg-display"; - reg = <0x38>; - label = "MAX695X_SEVEN_SEG_DISPLAY"; - }; - - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -/* typec_0 */ -&i2c_smb_1 { - status = "okay"; - clock-frequency = ; - port_sel = <6>; - pinctrl-0 = <&i2c06_scl_gpio140 &i2c06_sda_gpio132>; - pinctrl-names = "default"; - - tcpc_port0: fusb302@22 { - compatible = "fairchild,fusb302"; - reg = <0x22>; - }; - - usb_c0_soc_side_bb_retimer: jhl8040r-c0-soc-side@54 { - compatible = "intel,jhl8040r"; - reg = <0x54>; - reset-pin = <&usb_c0_bb_retimer_rst>; - ls-en-pin = <&usb_c0_bb_retimer_ls_en>; - }; - - usb_c0_bb_retimer: jhl8040r-c0@56 { - compatible = "intel,jhl8040r"; - reg = <0x56>; - reset-pin = <&usb_c0_bb_retimer_rst>; - ls-en-pin = <&usb_c0_bb_retimer_ls_en>; - }; -}; - -/* typec_1 */ -&i2c_smb_2 { - status = "okay"; - clock-frequency = ; - port_sel = <3>; - pinctrl-0 = <&i2c03_scl_gpio010 &i2c03_sda_gpio007>; - pinctrl-names = "default"; - - tcpc_port1: fusb302@22 { - compatible = "fairchild,fusb302"; - reg = <0x22>; - }; - - usb_c1_soc_side_bb_retimer: jhl8040r-c1-soc-side@55 { - compatible = "intel,jhl8040r"; - reg = <0x55>; - reset-pin = <&usb_c1_bb_retimer_rst>; - ls-en-pin = <&usb_c1_bb_retimer_ls_en>; - }; - - usb_c1_bb_retimer: jhl8040r-c1@57 { - compatible = "intel,jhl8040r"; - reg = <0x57>; - reset-pin = <&usb_c1_bb_retimer_rst>; - ls-en-pin = <&usb_c1_bb_retimer_ls_en>; - }; -}; - -/* typec_2 */ -&i2c_smb_3 { - status = "okay"; - clock-frequency = ; - port_sel = <7>; - pinctrl-0 = <&i2c07_scl_gpio013 &i2c07_sda_gpio012>; - pinctrl-names = "default"; - - tcpc_port2: fusb302@22 { - compatible = "fairchild,fusb302"; - reg = <0x22>; - }; - - usb_c2_bb_retimer: jhl8040r-c2@58 { - compatible = "intel,jhl8040r"; - reg = <0x58>; - reset-pin = <&usb_c2_bb_retimer_rst>; - ls-en-pin = <&usb_c2_bb_retimer_ls_en>; - }; -}; - -/* typec_3 */ -&i2c_smb_4 { - status = "okay"; - clock-frequency = ; - port_sel = <2>; - pinctrl-0 = <&i2c02_scl_gpio155 &i2c02_sda_gpio154>; - pinctrl-names = "default"; - - tcpc_port3: fusb302@22 { - compatible = "fairchild,fusb302"; - reg = <0x22>; - }; - - usb_c3_bb_retimer: jhl8040r-c3@59 { - compatible = "intel,jhl8040r"; - reg = <0x59>; - reset-pin = <&usb_c3_bb_retimer_rst>; - ls-en-pin = <&usb_c3_bb_retimer_ls_en>; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts deleted file mode 100644 index 1c760120f1..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -&i2c_smb_1 { - status = "okay"; - clock-frequency = ; - - usb_c0_bb_retimer: jhl8040r@56 { - compatible = "intel,jhl8040r"; - reg = <0x56>; - label = "USB_C0_BB_RETIMER"; - reset-pin = <&usb_c0_bb_retimer_rst>; - }; -}; - -&i2c_smb_2 { - status = "okay"; - clock-frequency = ; - - usb_c1_bb_retimer: jhl8040r@57 { - compatible = "intel,jhl8040r"; - reg = <0x57>; - label = "USB_C1_BB_RETIMER"; - reset-pin = <&usb_c1_bb_retimer_rst>; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/gpio.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/gpio.dts deleted file mode 100644 index d526fdcb3b..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/gpio.dts +++ /dev/null @@ -1,299 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_wp; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - all_sys_pwrgd: all-sys-pwrgd { - gpios = <&gpio_040_076 15 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD"; - }; /* GPIO057 */ - rsmrst_pwrgd: rsmrst-pwrgd { - gpios = <&gpio_200_236 17 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_RSMRST_ODL"; - }; /* GPIO221 */ - pch_slp_s0_n: pch-slp-s0-n { - gpios = <&gpio_240_276 3 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S0_L"; - }; /* GPIO243 */ - vccpdsw_3p3: vccpdsw-3p3 { - gpios = <&gpio_200_236 1 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_DSW_PWROK"; - }; /* GPIO201 */ - pm_slp_sus_ec_n: pm-slp-sus-ec-n { - gpios = <&gpio_200_236 23 GPIO_INPUT>; - enum-name = "GPIO_SLP_SUS_L"; - }; /* GPIO227 */ - pm_slp_s3_n: pm-slp-s3-n { - gpios = <&gpio_140_176 17 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S3_L"; - }; /* GPIO161 */ - pm_slp_s4_n: pm-slp-s4-n { - gpios = <&gpio_140_176 18 GPIO_INPUT>; - }; /* GPIO162 */ - volume_up { - gpios = <&gpio_000_036 30 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; /* GPIO036 */ - vol_dn_ec { - gpios = <&gpio_240_276 12 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; /* GPIO254 */ - smc_lid: smc-lid { - gpios = <&gpio_200_236 22 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_LID_OPEN"; - }; /* GPIO226 */ - mech_pwr_btn_odl: mech-pwr-btn-odl { - gpios = <&gpio_100_136 13 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; /* GPIO115 */ - std_adp_prsnt: std-adp-prsnt { - gpios = <&gpio_040_076 3 GPIO_INPUT>; - enum-name= "GPIO_DC_JACK_PRESENT"; - }; /* GPIO043 */ - bc_acok: bc-acok { - gpios = <&gpio_140_176 14 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; /* GPIO156 */ - usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { - gpios = <&gpio_140_176 3 GPIO_INPUT>; - }; /* GPIO143 */ - usbc_tcpc_alrt_p1: usbc-tcpc-alrt-p1 { - gpios = <&gpio_240_276 1 GPIO_INPUT>; - }; /* GPIO241 */ - usbc_tcpc_alrt_p2: usbc-tcpc-alrt-p2 { - gpios = <&gpio_100_136 24 GPIO_INPUT>; - }; /* GPIO130 */ - usbc_tcpc_alrt_p3: usbc-tcpc-alrt-p3 { - gpios = <&gpio_240_276 2 GPIO_INPUT>; - }; /* GPIO242 */ - usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { - gpios = <&gpio_240_276 0 GPIO_INPUT>; - }; /* GPIO240 */ - usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { - gpios = <&gpio_100_136 1 GPIO_INPUT>; - }; /* GPIO101 */ - usbc_tcpc_ppc_alrt_p2: usbc-tcpc-ppc-alrt-p2 { - gpios = <&gpio_140_176 4 GPIO_INPUT>; - }; /* GPIO144 */ - usbc_tcpc_ppc_alrt_p3: usbc-tcpc-ppc-alrt-p3 { - gpios = <&gpio_140_176 2 GPIO_INPUT>; - }; /* GPIO142 */ - gpio_ec_pch_wake_odl: smc-wake-sci-n-mecc { - gpios = <&gpio_040_076 9 GPIO_ODR_HIGH>; - }; /* GPIO051 */ - ec_pch_mkbp_int_odl { - gpios = <&gpio_100_136 23 GPIO_ODR_HIGH>; - }; /* GPIO127 */ - lpc_espi_rst_n { - gpios = <&gpio_040_076 17 GPIO_INPUT>; - }; /* GPIO061 NANA */ - plt_rst_l { - gpios = <&gpio_040_076 10 GPIO_INPUT>; - }; /* GPIO052 NANA */ - slate_mode_indication { - gpios = <&gpio_200_236 18 GPIO_INPUT>; - }; /* GPIO222 */ - prochot_ec_n { - gpios = <&gpio_000_036 2 GPIO_INPUT>; - enum-name = "GPIO_CPU_PROCHOT"; - }; /* GPIO002 ???? */ - sys_rst_odl { - gpios = <&gpio_040_076 16 GPIO_ODR_HIGH>; - enum-name = "GPIO_SYS_RESET_L"; - }; /* GPIO060 */ - pm_rsmrst_n { - gpios = <&gpio_040_076 12 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_RSMRST_L"; - }; /* GPIO054 */ - pm_pwrbtn_n { - gpios = <&gpio_000_036 14 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; /* GPIO016 */ - ec_spi_oe_mecc: ec-spi-oe-mecc { - gpios = <&gpio_040_076 2 GPIO_OUTPUT_LOW>; - }; /* GPIO042 */ - ec_ds3 { - gpios = <&gpio_000_036 21 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP3300_A"; - }; /* GPIO025 */ - pch_pwrok_ec { - gpios = <&gpio_100_136 6 GPIO_INPUT>; - enum-name = "GPIO_PCH_PWROK"; - }; /* GPIO106 */ - sys_pwrok { - gpios = <&gpio_200_236 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_SYS_PWROK"; - }; /* GPIO202 */ - ec_dsw_pwrok { - gpios = <&gpio_000_036 28 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_DSW_PWROK"; - }; /* GPIO034 */ - gpio_wp: ec-flash-wp-odl { - gpios = <&gpio_000_036 12 GPIO_INPUT>; - }; /* GPIO014 */ - ec_h1_packet_mode { - gpios = <&gpio_000_036 29 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; /* GPIO035 */ - ec_entering_rw { - gpios = <&gpio_100_136 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; /* GPIO102 */ - ccd_mode_odl: ccd-mode-odl { - gpios = <&gpio_140_176 29 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; /* GPIO175 */ - bat_det { - gpios = <&gpio_200_236 6 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; /* GPIO206 */ - edp_bklt_en_mecc { - gpios = <&gpio_000_036 18 GPIO_OUTPUT_HIGH>; - }; /* GPIO022 */ - led_1_l { - gpios = <&gpio_140_176 15 GPIO_OUTPUT_HIGH>; - }; /* GPIO157 */ - led_2_l { - gpios = <&gpio_140_176 11 GPIO_OUTPUT_HIGH>; - }; /* GPIO153 */ - therm_sen_mecc { - gpios = <&gpio_140_176 1 GPIO_OUTPUT_LOW>; - }; /* GPIO141 */ - smb_bs_clk { - gpios = <&gpio_000_036 4 GPIO_INPUT>; - }; /* GPIO004 */ - smb_bs_data { - gpios = <&gpio_000_036 3 GPIO_INPUT>; - }; /* GPIO003 */ - usbc_tcpc_i2c_clk_p0 { - gpios = <&gpio_140_176 0 GPIO_INPUT>; - }; /* GPIO140 */ - usbc_tcpc_i2c_data_p0 { - gpios = <&gpio_100_136 26 GPIO_INPUT>; - }; /* GPIO132 */ - usbc_tcpc_i2c_clk_p2 { - gpios = <&gpio_000_036 8 GPIO_INPUT>; - }; /* GPIO010 */ - usbc_tcpc_i2c_data_p2 { - gpios = <&gpio_000_036 7 GPIO_INPUT>; - }; /* GPIO007 */ - usbc_tcpc_i2c_clk_p1 { - gpios = <&gpio_000_036 11 GPIO_INPUT>; - }; /* GPIO013 */ - usbc_tcpc_i2c_data_p1 { - gpios = <&gpio_000_036 10 GPIO_INPUT>; - }; /* GPIO012 */ - usbc_tcpc_i2c_clk_p3 { - gpios = <&gpio_140_176 13 GPIO_INPUT>; - }; /* GPIO155 */ - usbc_tcpc_i2c_data_p3 { - gpios = <&gpio_140_176 12 GPIO_INPUT>; - }; /* GPIO154 */ - sml1_clk_mecc { - gpios = <&gpio_100_136 25 GPIO_INPUT>; - }; /* GPIO131 */ - cpu_cat_err_mecc { - gpios = <&gpio_000_036 0 GPIO_INPUT>; - }; /* GPIO000 */ - espi_alert0_n { - gpios = <&gpio_040_076 19 GPIO_INPUT>; - }; /* GPIO063 NANA */ - batt_disable_ec { - gpios = <&gpio_040_076 23 GPIO_INPUT>; - }; /* GPIO067 */ - cpu_c10_gate_mecc { - gpios = <&gpio_000_036 19 GPIO_INPUT>; - }; /* GPIO023 */ - smc_sdown_mecc { - gpios = <&gpio_240_276 13 GPIO_INPUT>; - }; /* GPIO255 */ - std_adpt_cntrl_gpio { - gpios = <&gpio_240_276 4 GPIO_INPUT>; - }; /* GPIO244 */ - smc_onoff_n { - gpios = <&gpio_100_136 12 GPIO_INPUT>; - }; /* GPIO114 */ - suswarn { - gpios = <&gpio_000_036 20 GPIO_INPUT>; - }; /* GPIO024 */ - me_g3_to_m3_ec { - gpios = <&gpio_000_036 27 GPIO_INPUT>; - }; /* GPIO033 */ - gpio_ec_kso_02_inv: ec-kso-02-inv { - gpios = <&gpio_040_076 6 (GPIO_OUTPUT_LOW - | GPIO_ACTIVE_LOW)>; - }; /* GPIO046 */ - - usb_c0_bb_retimer_rst: usb-c0-bb-retimer-rst { - gpios = <&ioex_c0_port 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_BB_RETIMER_RST"; - }; - usb_c0_bb_retimer_ls_en: usb-c0-bb-retimer-ls-en { - gpios = <&ioex_c0_port 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_BB_RETIMER_LS_EN"; - }; - usb-c0-usb-mux-cntrl-1 { - gpios = <&ioex_c0_port 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_USB_MUX_CNTRL_1"; - }; - usb-c0-usb-mux-cntrl-0 { - gpios = <&ioex_c0_port 5 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_USB_MUX_CNTRL_0"; - }; - usb_c1_bb_retimer_rst: usb-c1-bb-retimer-rst { - gpios = <&ioex_c1_port 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_BB_RETIMER_RST"; - }; - usb_c1_bb_retimer_ls_en: usb-c1-bb-retimer-ls-en { - gpios = <&ioex_c1_port 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_BB_RETIMER_LS_EN"; - }; - usb-c1-hpd { - gpios = <&ioex_c1_port 2 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_HPD"; - }; - usb-c0-c1-oc { - gpios = <&ioex_c1_port 8 GPIO_OUTPUT_HIGH>; - enum-name = "IOEX_USB_C0_C1_OC"; - }; - usb_c2_bb_retimer_rst: usb-c2-bb-retimer-rst { - gpios = <&ioex_c2_port 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C2_BB_RETIMER_RST"; - }; - usb_c2_bb_retimer_ls_en: usb-c2-bb-retimer-ls-en { - gpios = <&ioex_c2_port 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C2_BB_RETIMER_LS_EN"; - }; - usb-c2-usb-mux-cntrl-1 { - gpios = <&ioex_c2_port 4 GPIO_OUTPUT_LOW>; - }; - usb-c2-usb-mux-cntrl-0 { - gpios = <&ioex_c2_port 5 GPIO_OUTPUT_LOW>; - }; - usb_c3_bb_retimer_rst: usb-c3-bb-retimer-rst { - gpios = <&ioex_c3_port 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C3_BB_RETIMER_RST"; - }; - usb_c3_bb_retimer_ls_en: usb-c3-bb-retimer-ls-en { - gpios = <&ioex_c3_port 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C3_BB_RETIMER_LS_EN"; - }; - usb-c2-c3-oc { - gpios = <&ioex_c3_port 8 GPIO_OUTPUT_HIGH>; - enum-name = "IOEX_USB_C2_C3_OC"; - }; - /* unimplemented GPIOs */ - en-pp5000 { - enum-name = "GPIO_EN_PP5000"; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts deleted file mode 100644 index 17986fe2c7..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_lid_open: lid-open { - irq-pin = <&smc_lid>; - flags = ; - handler = "lid_interrupt"; - }; - int_power_button: power-button { - irq-pin = <&mech_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_ac_present: ac-present { - irq-pin = <&bc_acok>; - flags = ; - handler = "extpower_interrupt"; - }; - int_slp_s0: slp-s0 { - irq-pin = <&pch_slp_s0_n>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_slp_sus: slp-sus { - irq-pin = <&pm_slp_sus_ec_n>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_pg_dsw_pwrok: pg-dsw-pwrok { - irq-pin = <&vccpdsw_3p3>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_rsmrst_pwrgd: rsmrst-pwrgd { - irq-pin = <&rsmrst_pwrgd>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_all_sys_pwrgd: all-sys-pwrgd { - irq-pin = <&all_sys_pwrgd>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { - irq-pin = <&usbc_tcpc_alrt_p0>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usbc_tcpc_alrt_p1: usbc-tcpc-alrt-p1 { - irq-pin = <&usbc_tcpc_alrt_p1>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { - irq-pin = <&usbc_tcpc_ppc_alrt_p0>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { - irq-pin = <&usbc_tcpc_ppc_alrt_p1>; - flags = ; - handler = "ppc_interrupt"; - }; - int_std_adp_prsnt: std-adp-prsnt { - irq-pin = <&std_adp_prsnt>; - flags = ; - handler = "board_dc_jack_interrupt"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&ccd_mode_odl>; - flags = ; - handler = "board_connect_c0_sbu"; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts deleted file mode 100644 index b3577e6afd..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - output-settle = <80>; - debounce-down = <9000>; - debounce-up = <30000>; - poll-timeout = <100000>; - - actual-key-mask = < - 0x14 /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf deleted file mode 100644 index 083530c858..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_ADLRVP_MCHP=y -CONFIG_CROS_FLASH_XEC=y -CONFIG_CROS_SYSTEM_XEC=y -CONFIG_CROS_KB_RAW_XEC=y - -# For MCHP ESPI Drivers -CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y -CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION=y -CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE=y -CONFIG_ESPI_PERIPHERAL_XEC_EMI0=y -CONFIG_ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA=y -CONFIG_ESPI_PERIPHERAL_KBC_OBE_CBK=y -CONFIG_ESPI_PERIPHERAL_KBC_IBF_EVT_DATA=y - -# Invoke SoC Python script to create zephyr.mchp.bin which -# is zephyr.bin processed for Boot-ROM loading. -CONFIG_MCHP_MEC_UNSIGNED_HEADER=y -CONFIG_MCHP_MEC_HEADER_FLASH_SIZE_256K=y - -# Support Zephyr SPI NOR driver to work with MCHP SPI driver -CONFIG_SPI_NOR=y -CONFIG_SPI_XEC_QMSPI_FULL_DUPLEX=y - -# Sensors - MCHP TACH driver under sensor -CONFIG_SENSOR=n -CONFIG_SENSOR_SHELL=n - -# Debug option -# Enable flash console commands -CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y - - -## TODO - support following features next -# Fan -CONFIG_PLATFORM_EC_FAN=n - -# RTC -CONFIG_PLATFORM_EC_RTC=n - -# PWM -CONFIG_PWM=n -CONFIG_PWM_SHELL=n - -## INTEL RVP -# Host command -CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=n - -# Power Sequencing -CONFIG_PLATFORM_EC_THROTTLE_AP=n - -## ADL RVP -# CBI -CONFIG_EEPROM=n -CONFIG_EEPROM_AT24=n -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=n - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=n -CONFIG_PLATFORM_EC_LED_PWM=n -CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=n - -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=n -CONFIG_PLATFORM_EC_THERMISTOR=n -CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=n - -# Charger -CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y - -# H1 issues second reset -CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n - -# 7-Segment Display -CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=n - -# Debug options -# Enable flash console commands -CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y -CONFIG_WDT_DISABLE_AT_BOOT=y diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/usbc.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/usbc.dts deleted file mode 100644 index 471a1f52e9..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/usbc.dts +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - usbc_port0: port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb_mux_chain_0: usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c0_bb_retimer - &virtual_mux_c0>; - }; - usb_mux_alt_chain_0: usb-mux-alt-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&usb_c0_bb_retimer - &usb_c0_soc_side_bb_retimer - &virtual_mux_c0>; - }; - }; - port0-muxes { - virtual_mux_c0: virtual-mux-c0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - usbc_port1: port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - tcpc = <&tcpc_port1>; - usb_mux_chain_1: usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c1_bb_retimer - &virtual_mux_c1>; - }; - usb_mux_alt_chain_1: usb-mux-alt-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&usb_c1_bb_retimer - &usb_c1_soc_side_bb_retimer - &virtual_mux_c1>; - }; - }; - port1-muxes { - virtual_mux_c1: virtual-mux-c1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port2@2 { - compatible = "named-usbc-port"; - reg = <2>; - tcpc = <&tcpc_port2>; - usb_mux_chain_2: usb-mux-chain-2 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c2_bb_retimer - &virtual_mux_c2>; - }; - }; - port2-muxes { - virtual_mux_c2: virtual-mux-c2 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port3@3 { - compatible = "named-usbc-port"; - reg = <3>; - tcpc = <&tcpc_port3>; - usb_mux_chain_3: usb-mux-chain-3 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c3_bb_retimer - &virtual_mux_c3>; - }; - }; - port3-muxes { - virtual_mux_c3: virtual-mux-c3 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts deleted file mode 100644 index 79723beabd..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts +++ /dev/null @@ -1,258 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - cros,rtc = &mtc; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_lid_open - &int_power_button - >; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_charger: charger { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_BATTERY", - "I2C_PORT_CHARGER", - "I2C_PORT_EEPROM", - "I2C_PORT_PORT80"; - }; - typec_0: typec-0 { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_TYPEC_0"; - }; - typec_1: typec-1 { - i2c-port = <&i2c2_0>; - enum-names = "I2C_PORT_TYPEC_1"; - }; - typec_2: typec-2 { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_TYPEC_2"; - }; - typec_3: typec-3 { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_TYPEC_3"; - }; - }; - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ambient: ambient { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 3>; - }; - adc_ddr: ddr { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 4>; - }; - adc_skin: skin { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 2>; - }; - adc_vr: vr { - enum-name = "ADC_TEMP_SENSOR_4"; - io-channels = <&adc0 1>; - }; - }; - -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; - -/* charger */ -&i2c7_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; - - pca95xx: pca95xx@22 { - compatible = "nxp,pca95xx"; - label = "PCA95XX"; - reg = <0x22>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <16>; - }; - - rvp_board_id: rvp-board-id { - compatible = "intel,rvp-board-id"; - - /* - * BOM ID [2] : IOEX[0] - * BOM ID [1:0] : IOEX[15:14] - */ - bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>; - - /* - * FAB ID [1:0] : IOEX[2:1] - */ - fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>; - - /* - * BOARD ID[5:0] : IOEX[13:8] - */ - board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>, - <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>; - }; - - seven_seg_display: max695x-seven-seg-display@38 { - compatible = "maxim,seven-seg-display"; - reg = <0x38>; - label = "MAX695X_SEVEN_SEG_DISPLAY"; - }; - - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c_ctrl7 { - status = "okay"; -}; - -/* typec_0 */ -&i2c0_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; - - tcpc_port0: fusb302@22 { - compatible = "fairchild,fusb302"; - reg = <0x22>; - }; - - usb_c0_soc_side_bb_retimer: jhl8040r-c0-soc-side@54 { - compatible = "intel,jhl8040r"; - reg = <0x54>; - reset-pin = <&usb_c0_bb_retimer_rst>; - ls-en-pin = <&usb_c0_bb_retimer_ls_en>; - }; - - usb_c0_bb_retimer: jhl8040r-c0@56 { - compatible = "intel,jhl8040r"; - reg = <0x56>; - reset-pin = <&usb_c0_bb_retimer_rst>; - ls-en-pin = <&usb_c0_bb_retimer_ls_en>; - }; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -/* typec_1 */ -&i2c2_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; - - tcpc_port1: fusb302@22 { - compatible = "fairchild,fusb302"; - reg = <0x22>; - }; - - usb_c1_soc_side_bb_retimer: jhl8040r-c1-soc-side@55 { - compatible = "intel,jhl8040r"; - reg = <0x55>; - reset-pin = <&usb_c1_bb_retimer_rst>; - ls-en-pin = <&usb_c1_bb_retimer_ls_en>; - }; - - usb_c1_bb_retimer: jhl8040r-c1@57 { - compatible = "intel,jhl8040r"; - reg = <0x57>; - reset-pin = <&usb_c1_bb_retimer_rst>; - ls-en-pin = <&usb_c1_bb_retimer_ls_en>; - }; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -/* typec_2 */ -&i2c1_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - tcpc_port2: fusb302@22 { - compatible = "fairchild,fusb302"; - reg = <0x22>; - }; - - usb_c2_bb_retimer: jhl8040r-c2@58 { - compatible = "intel,jhl8040r"; - reg = <0x58>; - reset-pin = <&usb_c2_bb_retimer_rst>; - ls-en-pin = <&usb_c2_bb_retimer_ls_en>; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -/* typec_3 */ -&i2c3_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; - - tcpc_port3: fusb302@22 { - compatible = "fairchild,fusb302"; - reg = <0x22>; - }; - - usb_c3_bb_retimer: jhl8040r-c3@59 { - compatible = "intel,jhl8040r"; - reg = <0x59>; - reset-pin = <&usb_c3_bb_retimer_rst>; - ls-en-pin = <&usb_c3_bb_retimer_ls_en>; - }; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42 - &adc0_chan4_gp41>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/fan.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/fan.dts deleted file mode 100644 index 8babe53903..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/fan.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm3 0 PWM_KHZ(30) PWM_POLARITY_NORMAL>; - rpm_min = <3000>; - rpm_start = <3000>; - rpm_max = <10000>; - tach = <&tach2>; - pgood_gpio = <&all_sys_pwrgd>; - enable_gpio = <&gpio_fan_control>; - }; - }; -}; - -/* Tachemeter for fan speed measurement */ -&tach2 { - status = "okay"; - pinctrl-0 = <&ta2_2_in_gpa6>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm3 { - status = "okay"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/gpio.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/gpio.dts deleted file mode 100644 index 1d38fc877c..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/gpio.dts +++ /dev/null @@ -1,344 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_wp; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - all_sys_pwrgd: all-sys-pwrgd { - gpios = <&gpio7 0 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD"; - }; - rsmrst_pwrgd: rsmrst-pwrgd { - gpios = <&gpio3 7 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_RSMRST_ODL"; - }; - pch_slp_s0_n: pch-slp-s0-n { - gpios = <&gpioa 1 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S0_L"; - }; - vccpdsw_3p3: vccpdsw-3p3 { - gpios = <&gpio4 5 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_DSW_PWROK"; - }; - pm_slp_sus_ec_n: pm-slp-sus-ec-n { - gpios = <&gpio8 6 GPIO_INPUT>; - enum-name = "GPIO_SLP_SUS_L"; - }; - pm-slp-s3-n { - gpios = <&gpiob 0 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S3_L"; - }; - pm-slp-s4-n { - gpios = <&gpioa 5 GPIO_INPUT>; - }; - volume-up { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - vol-dn-ec { - gpios = <&gpio0 3 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - smc_lid: smc-lid { - gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_LID_OPEN"; - }; - mech_pwr_btn_odl: mech-pwr-btn-odl { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - std_adp_prsnt: std-adp-prsnt { - gpios = <&gpio0 2 GPIO_INPUT>; - enum-name= "GPIO_DC_JACK_PRESENT"; - }; - bc_acok: bc-acok { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { - gpios = <&gpio4 0 GPIO_INPUT>; - }; - usbc_tcpc_alrt_p1: usbc-tcpc-alrt-p1 { - gpios = <&gpio6 2 GPIO_INPUT>; - }; - usbc_tcpc_alrt_p2: usbc-tcpc-alrt-p2 { - gpios = <&gpio6 3 GPIO_INPUT>; - }; - usbc_tcpc_alrt_p3: usbc-tcpc-alrt-p3 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { - gpios = <&gpiof 1 GPIO_INPUT>; - }; - usbc_tcpc_ppc_alrt_p2: usbc-tcpc-ppc-alrt-p2 { - gpios = <&gpiof 2 GPIO_INPUT>; - }; - usbc_tcpc_ppc_alrt_p3: usbc-tcpc-ppc-alrt-p3 { - gpios = <&gpiof 3 GPIO_INPUT>; - }; - gpio_ec_pch_wake_odl: smc-wake-sci-n-mecc { - gpios = <&gpioa 4 GPIO_ODR_HIGH>; - }; - ec-pch-mkbp-int-odl { - gpios = <&gpiof 5 GPIO_ODR_HIGH>; - }; - lpc-espi-rst-n { - gpios = <&gpio5 4 GPIO_INPUT>; - }; - plt-rst-l { - gpios = <&gpioa 2 GPIO_INPUT>; - }; - slate-mode-indication { - gpios = <&gpioe 5 GPIO_INPUT>; - }; - prochot-ec-n { - gpios = <&gpioa 7 GPIO_INPUT>; - enum-name = "GPIO_CPU_PROCHOT"; - }; - sys-rst-odl { - gpios = <&gpioc 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_SYS_RESET_L"; - }; - pm-rsmrst-n { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_RSMRST_L"; - }; - pm-pwrbtn-n { - gpios = <&gpio9 7 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - ec_spi_oe_mecc: ec-spi-oe-mecc { - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - ec-ds3 { - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP3300_A"; - alias = "GPIO_TEMP_SENSOR_POWER"; - }; - pch-pwrok-ec { - gpios = <&gpioa 0 GPIO_INPUT>; - enum-name = "GPIO_PCH_PWROK"; - }; - sys-pwrok { - gpios = <&gpio9 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_SYS_PWROK"; - }; - ec-dsw-pwrok { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_DSW_PWROK"; - }; - gpio_wp: ec-flash-wp-odl { - gpios = <&gpio9 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - ec-h1-packet-mode { - gpios = <&gpioe 2 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - ec-entering-rw { - gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ccd_mode_odl: ccd-mode-odl { - gpios = <&gpiof 4 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - bat-det { - gpios = <&gpio7 6 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - edp-bklt-en-mecc { - gpios = <&gpioe 1 GPIO_OUTPUT_HIGH>; - }; - led_red_l: led-1-l { - gpios = <&gpiob 6 GPIO_OUTPUT_HIGH>; - }; - led_white_l: led-2-l { - gpios = <&gpiob 7 GPIO_OUTPUT_HIGH>; - }; - gpio_fan_control: therm-sen-mecc { - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - smb-bs-clk { - gpios = <&gpiob 3 GPIO_INPUT>; - }; - smb-bs-data { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - usbc-tcpc-i2c-clk-p0 { - gpios = <&gpiob 5 GPIO_INPUT>; - }; - usbc-tcpc-i2c-data-p0 { - gpios = <&gpiob 4 GPIO_INPUT>; - }; - usbc-tcpc-i2c-clk-p2 { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - usbc-tcpc-i2c-data-p2 { - gpios = <&gpio9 1 GPIO_INPUT>; - }; - usbc-tcpc-i2c-clk-p1 { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - usbc-tcpc-i2c-data-p1 { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - usbc-tcpc-i2c-clk-p3 { - gpios = <&gpiod 1 GPIO_INPUT>; - }; - usbc-tcpc-i2c-data-p3 { - gpios = <&gpiod 0 GPIO_INPUT>; - }; - sml1-clk-mecc { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - sml1-data-mecc { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - smb-pch-clk { - gpios = <&gpioc 2 GPIO_INPUT>; - }; - smb-pch-data { - gpios = <&gpioc 1 GPIO_INPUT>; - }; - i3c-0-scl { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - i3c-0-sda { - gpios = <&gpioe 3 GPIO_INPUT>; - }; - cpu-cat-err-mecc { - gpios = <&gpio3 4 GPIO_INPUT>; - }; - tp29 { - gpios = <&gpio5 0 GPIO_INPUT>; - }; - tp28 { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - espi-alert0-n { - gpios = <&gpio5 7 GPIO_INPUT>; - }; - batt-disable-ec { - gpios = <&gpio6 6 GPIO_INPUT>; - }; - tp33 { - gpios = <&gpio7 2 GPIO_INPUT>; - }; - tp26 { - gpios = <&gpio7 3 GPIO_INPUT>; - }; - slp-s0-cs-n { - gpios = <&gpio7 4 GPIO_INPUT>; - }; - ec-peci { - gpios = <&gpio8 1 GPIO_INPUT>; - }; - cpu-c10-gate-mecc { - gpios = <&gpio9 6 GPIO_INPUT>; - }; - smb-pch-alrt { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - smc-sdown-mecc { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - std-adpt-cntrl-gpio { - gpios = <&gpioc 3 GPIO_INPUT>; - }; - sml1-alert { - gpios = <&gpioc 7 GPIO_INPUT>; - }; - smc-onoff-n { - gpios = <&gpiod 2 GPIO_INPUT>; - }; - suswarn { - gpios = <&gpiod 5 GPIO_INPUT>; - }; - tp-gpiod6-ec { - gpios = <&gpiod 6 GPIO_INPUT>; - }; - tp-gpiod7-ec { - gpios = <&gpiod 7 GPIO_INPUT>; - }; - me-g3-to-m3-ec { - gpios = <&gpioe 0 GPIO_INPUT>; - }; - gpio_ec_kso_02_inv: ec-kso-02-inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - - usb_c0_bb_retimer_rst: usb-c0-bb-retimer-rst { - gpios = <&ioex_c0_port 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_BB_RETIMER_RST"; - }; - usb_c0_bb_retimer_ls_en: usb-c0-bb-retimer-ls-en { - gpios = <&ioex_c0_port 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_BB_RETIMER_LS_EN"; - }; - usb-c0-usb-mux-cntrl-1 { - gpios = <&ioex_c0_port 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_USB_MUX_CNTRL_1"; - }; - usb-c0-usb-mux-cntrl-0 { - gpios = <&ioex_c0_port 5 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_USB_MUX_CNTRL_0"; - }; - usb_c1_bb_retimer_rst: usb-c1-bb-retimer-rst { - gpios = <&ioex_c1_port 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_BB_RETIMER_RST"; - }; - usb_c1_bb_retimer_ls_en: usb-c1-bb-retimer-ls-en { - gpios = <&ioex_c1_port 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_BB_RETIMER_LS_EN"; - }; - usb-c1-hpd { - gpios = <&ioex_c1_port 2 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_HPD"; - }; - usb-c0-c1-oc { - gpios = <&ioex_c1_port 8 GPIO_OUTPUT_HIGH>; - enum-name = "IOEX_USB_C0_C1_OC"; - }; - usb_c2_bb_retimer_rst: usb-c2-bb-retimer-rst { - gpios = <&ioex_c2_port 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C2_BB_RETIMER_RST"; - }; - usb_c2_bb_retimer_ls_en: usb-c2-bb-retimer-ls-en { - gpios = <&ioex_c2_port 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C2_BB_RETIMER_LS_EN"; - }; - usb-c2-usb-mux-cntrl-1 { - gpios = <&ioex_c2_port 4 GPIO_OUTPUT_LOW>; - }; - usb-c2-usb-mux-cntrl-0 { - gpios = <&ioex_c2_port 5 GPIO_OUTPUT_LOW>; - }; - usb_c3_bb_retimer_rst: usb-c3-bb-retimer-rst { - gpios = <&ioex_c3_port 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C3_BB_RETIMER_RST"; - }; - usb_c3_bb_retimer_ls_en: usb-c3-bb-retimer-ls-en { - gpios = <&ioex_c3_port 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C3_BB_RETIMER_LS_EN"; - }; - usb-c2-c3-oc { - gpios = <&ioex_c3_port 8 GPIO_OUTPUT_HIGH>; - enum-name = "IOEX_USB_C2_C3_OC"; - }; - /* unimplemented GPIOs */ - en-pp5000 { - enum-name = "GPIO_EN_PP5000"; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts deleted file mode 100644 index d7bb40fad2..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_lid_open: lid-open { - irq-pin = <&smc_lid>; - flags = ; - handler = "lid_interrupt"; - }; - int_power_button: power-button { - irq-pin = <&mech_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_ac_present: ac-present { - irq-pin = <&bc_acok>; - flags = ; - handler = "extpower_interrupt"; - }; - int_slp_s0: slp-s0 { - irq-pin = <&pch_slp_s0_n>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_slp_sus: slp-sus { - irq-pin = <&pm_slp_sus_ec_n>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_pg_dsw_pwrok: pg-dsw-pwrok { - irq-pin = <&vccpdsw_3p3>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_rsmrst_pwrgd: rsmrst-pwrgd { - irq-pin = <&rsmrst_pwrgd>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_all_sys_pwrgd: all-sys-pwrgd { - irq-pin = <&all_sys_pwrgd>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { - irq-pin = <&usbc_tcpc_alrt_p0>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usbc_tcpc_alrt_p1: usbc-tcpc-alrt-p1 { - irq-pin = <&usbc_tcpc_alrt_p1>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usbc_tcpc_alrt_p2: usbc-tcpc-alrt-p2 { - irq-pin = <&usbc_tcpc_alrt_p2>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usbc_tcpc_alrt_p3: usbc-tcpc-alrt-p3 { - irq-pin = <&usbc_tcpc_alrt_p3>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { - irq-pin = <&usbc_tcpc_ppc_alrt_p0>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { - irq-pin = <&usbc_tcpc_ppc_alrt_p1>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usbc_tcpc_ppc_alrt_p2: usbc-tcpc-ppc-alrt-p2 { - irq-pin = <&usbc_tcpc_ppc_alrt_p2>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usbc_tcpc_ppc_alrt_p3: usbc-tcpc-ppc-alrt-p3 { - irq-pin = <&usbc_tcpc_ppc_alrt_p3>; - flags = ; - handler = "ppc_interrupt"; - }; - int_std_adp_prsnt: std-adp-prsnt { - irq-pin = <&std_adp_prsnt>; - flags = ; - handler = "board_dc_jack_interrupt"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&ccd_mode_odl>; - flags = ; - handler = "board_connect_c0_sbu"; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts deleted file mode 100644 index 81d6e82f48..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - output-settle = <35>; - debounce-down = <5000>; - debounce-up = <40000>; - poll-timeout = <100000>; - - actual-key-mask = < - 0x14 /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf deleted file mode 100644 index 2c98fd9330..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_ADLRVP_NPCX=y -CONFIG_CROS_FLASH_NPCX=y -CONFIG_CROS_SYSTEM_NPCX=y -CONFIG_SYSCON=y - -# Charger -CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y - -# FAN -CONFIG_TACH_NPCX=y - -# Keyboard -CONFIG_CROS_KB_RAW_NPCX=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# RTC -CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts deleted file mode 100644 index eb1576dbff..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm4 0 PWM_HZ(4800) PWM_POLARITY_INVERTED>; - }; - pwm_led1: pwm_led_1 { - pwms = <&pwm5 0 PWM_HZ(4800) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0 &pwm_led1>; - - color-map-green = <100>; - - /* brightness-range = */ - brightness-range = <0 100 0 0 0 0>; - - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_BATTERY_LED"; - }; - - pwm_led_1@1 { - reg = <1>; - ec-led-name = "EC_LED_ID_POWER_LED"; - }; - }; -}; - -/* LED1 */ -&pwm4 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm4_gpb6>; - pinctrl-names = "default"; -}; - -/* LED2 */ -&pwm5 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm5_gpb7>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts deleted file mode 100644 index 93ecaa02f6..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V0_22K6_47K_4050B>; - adc = <&adc_ambient>; - }; - temp_ddr: ddr { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V0_22K6_47K_4050B>; - adc = <&adc_ddr>; - }; - temp_skin: skin { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V0_22K6_47K_4050B>; - adc = <&adc_skin>; - }; - temp_vr: vr { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V0_22K6_47K_4050B>; - adc = <&adc_vr>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - ambient { - temp_fan_off = <15>; - temp_fan_max = <50>; - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - sensor = <&temp_ambient>; - }; - - /* - * TDB: battery temp read api is not using thermistor and - * zephyr shim layer doesn't support to configure custom read - * function. - * - * battery { - * compatible = "cros-ec,temp-sensor-thermistor", - * "cros-ec,temp-sensor"; - * thermistor = < >; - * enum-name = ""; - * temp_fan_off = <15>; - * temp_fan_max = <50>; - * temp_host_high = <75>; - * temp_host_halt = <80>; - * temp_host_release_high = <65>; - * adc = <&adc_battery>; - * }; - */ - - ddr { - temp_fan_off = <15>; - temp_fan_max = <50>; - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - sensor = <&temp_ddr>; - }; - skin { - temp_fan_off = <15>; - temp_fan_max = <50>; - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - sensor = <&temp_skin>; - }; - vr { - temp_fan_off = <15>; - temp_fan_max = <50>; - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - sensor = <&temp_vr>; - }; - }; -}; - -&thermistor_3V0_22K6_47K_4050B { - status = "okay"; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts deleted file mode 100644 index 471a1f52e9..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - usbc_port0: port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb_mux_chain_0: usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c0_bb_retimer - &virtual_mux_c0>; - }; - usb_mux_alt_chain_0: usb-mux-alt-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&usb_c0_bb_retimer - &usb_c0_soc_side_bb_retimer - &virtual_mux_c0>; - }; - }; - port0-muxes { - virtual_mux_c0: virtual-mux-c0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - usbc_port1: port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - tcpc = <&tcpc_port1>; - usb_mux_chain_1: usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c1_bb_retimer - &virtual_mux_c1>; - }; - usb_mux_alt_chain_1: usb-mux-alt-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&usb_c1_bb_retimer - &usb_c1_soc_side_bb_retimer - &virtual_mux_c1>; - }; - }; - port1-muxes { - virtual_mux_c1: virtual-mux-c1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port2@2 { - compatible = "named-usbc-port"; - reg = <2>; - tcpc = <&tcpc_port2>; - usb_mux_chain_2: usb-mux-chain-2 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c2_bb_retimer - &virtual_mux_c2>; - }; - }; - port2-muxes { - virtual_mux_c2: virtual-mux-c2 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port3@3 { - compatible = "named-usbc-port"; - reg = <3>; - tcpc = <&tcpc_port3>; - usb_mux_chain_3: usb-mux-chain-3 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c3_bb_retimer - &virtual_mux_c3>; - }; - }; - port3-muxes { - virtual_mux_c3: virtual-mux-c3 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/battery.dts b/zephyr/projects/intelrvp/adlrvp/battery.dts deleted file mode 100644 index 1de4111791..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/battery.dts +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - getac-3s = &default_battery; - getac-2s = &getac_smp_hhp_408_2s; - }; - - batteries { - default_battery: getac-smp-hhp-408-3s { - compatible = "getac,bq40z50-R3-S3", "battery-smart"; - }; - getac_smp_hhp_408_2s: getac-smp-hhp-408-2s { - compatible = "getac,bq40z50-R3-S2", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/include/adlrvp_zephyr.h b/zephyr/projects/intelrvp/adlrvp/include/adlrvp_zephyr.h deleted file mode 100644 index 135fd4ef4f..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/include/adlrvp_zephyr.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Intel ADL-RVP specific configuration */ - -#ifndef __ADLRVP_BOARD_H -#define __ADLRVP_BOARD_H - -#include "config.h" - -#define I2C_ADDR_FUSB302_TCPC_AIC 0x22 -#define I2C_ADDR_SN5S330_TCPC_AIC_PPC 0x40 - -#define I2C_ADDR_PCA9675_TCPC_AIC_IOEX 0x21 - -/* SOC side BB retimers (dual retimer config) */ -#define I2C_PORT0_BB_RETIMER_SOC_ADDR 0x54 -#if defined(HAS_TASK_PD_C1) -#define I2C_PORT1_BB_RETIMER_SOC_ADDR 0x55 -#endif - -#define ADLM_LP4_RVP1_SKU_BOARD_ID 0x01 -#define ADLM_LP5_RVP2_SKU_BOARD_ID 0x02 -#define ADLM_LP5_RVP3_SKU_BOARD_ID 0x03 -#define ADLN_LP5_ERB_SKU_BOARD_ID 0x06 -#define ADLN_LP5_RVP_SKU_BOARD_ID 0x07 -#define ADLP_DDR5_RVP_SKU_BOARD_ID 0x12 -#define ADLP_LP5_T4_RVP_SKU_BOARD_ID 0x13 -#define ADL_RVP_BOARD_ID(id) ((id)&0x3F) - -#define CONFIG_BATTERY_TYPE_NO_AUTO_DETECT - -enum adlrvp_charge_ports { - TYPE_C_PORT_0, -#if defined(HAS_TASK_PD_C1) - TYPE_C_PORT_1, -#endif -#if defined(HAS_TASK_PD_C2) - TYPE_C_PORT_2, -#endif -#if defined(HAS_TASK_PD_C3) - TYPE_C_PORT_3, -#endif -}; - -enum ioex_port { - IOEX_C0_PCA9675, - IOEX_C1_PCA9675, -#if defined(HAS_TASK_PD_C2) - IOEX_C2_PCA9675, - IOEX_C3_PCA9675, -#endif - IOEX_PORT_COUNT -}; - -#endif /* __ADLRVP_BOARD_H */ diff --git a/zephyr/projects/intelrvp/adlrvp/ioex.dts b/zephyr/projects/intelrvp/adlrvp/ioex.dts deleted file mode 100644 index 3e2227dacb..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/ioex.dts +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* IOEX_C0_PCA9675 */ - ioex-c0 { - compatible = "cros,ioex-chip"; - i2c-port = <&typec_0>; - i2c-addr = <0x21>; - drv = "pca9675_ioexpander_drv"; - flags = <0x00>; - #address-cells = <1>; - #size-cells = <0>; - ioex_c0_port: ioex-c0-port@0 { - compatible = "cros,ioex-port"; - reg = <0>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <16>; - }; - }; - - /* IOEX_C1_PCA9675 */ - ioex-c1 { - compatible = "cros,ioex-chip"; - i2c-port = <&typec_1>; - i2c-addr = <0x21>; - drv = "pca9675_ioexpander_drv"; - flags = <0x00>; - #address-cells = <1>; - #size-cells = <0>; - ioex_c1_port: ioex-c1-port@0 { - compatible = "cros,ioex-port"; - reg = <0>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <16>; - }; - }; - - /* IOEX_C2_PCA9675 */ - ioex-c2 { - compatible = "cros,ioex-chip"; - i2c-port = <&typec_2>; - i2c-addr = <0x21>; - drv = "pca9675_ioexpander_drv"; - flags = <0x00>; - #address-cells = <1>; - #size-cells = <0>; - ioex_c2_port: ioex-c2-port@0 { - compatible = "cros,ioex-port"; - reg = <0>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <16>; - }; - }; - - /* IOEX_C3_PCA9675 */ - ioex-c3 { - compatible = "cros,ioex-chip"; - i2c-port = <&typec_3>; - i2c-addr = <0x21>; - drv = "pca9675_ioexpander_drv"; - flags = <0x00>; - #address-cells = <1>; - #size-cells = <0>; - ioex_c3_port: ioex-c3-port@0 { - compatible = "cros,ioex-port"; - reg = <0>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <16>; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/adlrvp/prj.conf b/zephyr/projects/intelrvp/adlrvp/prj.conf deleted file mode 100644 index 4bcee4a953..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/prj.conf +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Power Sequencing -CONFIG_AP_X86_INTEL_TGL=y -CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n -CONFIG_PLATFORM_EC_POWERSEQ_ICELAKE=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y -CONFIG_PLATFORM_EC_BATTERY_V2=y - -# BC1.2 -CONFIG_PLATFORM_EC_USB_CHARGER=n - -# CBI -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 -CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=n -CONFIG_PLATFORM_EC_CHARGER_BQ25720=y -CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y -CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70 -CONFIG_PLATFORM_EC_CHARGER_ISL9241=y -CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_PWM=y -CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=y - -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y - -# USB-C and PD -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_MUX_TUSB1044=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_REV30=y -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y -CONFIG_PLATFORM_EC_USB_PD_USB4=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_FUSB302=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y -CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y -CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y - -# IOEX -CONFIG_PLATFORM_EC_IOEX_CROS_DRV=y -CONFIG_PLATFORM_EC_IOEX_PCA9675=y -CONFIG_GPIO_PCA95XX=y - -# 7-Segment Display -CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y - -# eSPI -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150 diff --git a/zephyr/projects/intelrvp/adlrvp/src/adlrvp.c b/zephyr/projects/intelrvp/adlrvp/src/adlrvp.c deleted file mode 100644 index ce5196c60d..0000000000 --- a/zephyr/projects/intelrvp/adlrvp/src/adlrvp.c +++ /dev/null @@ -1,430 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* TODO: b/218904113: Convert to using Zephyr GPIOs */ -#include "gpio_signal.h" -#include "adlrvp_zephyr.h" -#include "common.h" -#include "console.h" -#include "intelrvp.h" -#include "intel_rvp_board_id.h" -#include "battery_fuel_gauge.h" -#include "charger.h" -#include "battery.h" -#include "bq25710.h" -#include "driver/retimer/bb_retimer_public.h" -#include "extpower.h" -#include "hooks.h" -#include "ioexpander.h" -#include "isl9241.h" -#include "power/icelake.h" -#include "sn5s330.h" -#include "system.h" -#include "task.h" -#include "tusb1064.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" -#include "usbc_ppc.h" -#include "util.h" - -#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ##args) -#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ##args) - -/* TCPC AIC GPIO Configuration */ -const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[] = { - [TYPE_C_PORT_0] = { - .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)), - .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p0)), - .ppc_intr_handler = sn5s330_interrupt, - }, -#if defined(HAS_TASK_PD_C1) - [TYPE_C_PORT_1] = { - .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p1)), - .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p1)), - .ppc_intr_handler = sn5s330_interrupt, - }, -#endif -#if defined(HAS_TASK_PD_C2) - [TYPE_C_PORT_2] = { - .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p2)), - .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p2)), - .ppc_intr_handler = sn5s330_interrupt, - }, -#endif -#if defined(HAS_TASK_PD_C3) - [TYPE_C_PORT_3] = { - .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p3)), - .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p3)), - .ppc_intr_handler = sn5s330_interrupt, - }, -#endif -}; -BUILD_ASSERT(ARRAY_SIZE(tcpc_aic_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT); - -/* USB-C PPC configuration */ -struct ppc_config_t ppc_chips[] = { - [TYPE_C_PORT_0] = { - .i2c_port = I2C_PORT_TYPEC_0, - .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC, - .drv = &sn5s330_drv, - }, -#if defined(HAS_TASK_PD_C1) - [TYPE_C_PORT_1] = { - .i2c_port = I2C_PORT_TYPEC_1, - .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC, - .drv = &sn5s330_drv - }, -#endif -#if defined(HAS_TASK_PD_C2) - [TYPE_C_PORT_2] = { - .i2c_port = I2C_PORT_TYPEC_2, - .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC, - .drv = &sn5s330_drv, - }, -#endif -#if defined(HAS_TASK_PD_C3) - [TYPE_C_PORT_3] = { - .i2c_port = I2C_PORT_TYPEC_3, - .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC, - .drv = &sn5s330_drv, - }, -#endif -}; -BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == CONFIG_USB_PD_PORT_MAX_COUNT); -unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); - -/* Cache BB retimer power state */ -static bool cache_bb_enable[CONFIG_USB_PD_PORT_MAX_COUNT]; - -void board_overcurrent_event(int port, int is_overcurrented) -{ - /* Port 0 & 1 and 2 & 3 share same line for over current indication */ -#if defined(HAS_TASK_PD_C2) - enum ioex_signal oc_signal = port < TYPE_C_PORT_2 ? IOEX_USB_C0_C1_OC : - IOEX_USB_C2_C3_OC; -#else - enum ioex_signal oc_signal = IOEX_USB_C0_C1_OC; -#endif - - /* Overcurrent indication is active low signal */ - ioex_set_level(oc_signal, is_overcurrented ? 0 : 1); -} - -__override int bb_retimer_power_enable(const struct usb_mux *me, bool enable) -{ - /* - * ADL-P-DDR5 RVP SKU has cascaded retimer topology. - * Ports with cascaded retimers share common load switch and reset pin - * hence no need to set the power state again if the 1st retimer's power - * status has already changed. - */ - if (cache_bb_enable[me->usb_port] == enable) - return EC_SUCCESS; - - cache_bb_enable[me->usb_port] = enable; - - /* Handle retimer's power domain.*/ - if (enable) { - ioex_set_level(bb_controls[me->usb_port].usb_ls_en_gpio, 1); - - /* - * minimum time from VCC to RESET_N de-assertion is 100us - * For boards that don't provide a load switch control, the - * retimer_init() function ensures power is up before calling - * this function. - */ - msleep(1); - ioex_set_level(bb_controls[me->usb_port].retimer_rst_gpio, 1); - - /* - * Allow 1ms time for the retimer to power up lc_domain - * which powers I2C controller within retimer - */ - msleep(1); - - } else { - ioex_set_level(bb_controls[me->usb_port].retimer_rst_gpio, 0); - msleep(1); - ioex_set_level(bb_controls[me->usb_port].usb_ls_en_gpio, 0); - } - return EC_SUCCESS; -} - -static void board_connect_c0_sbu_deferred(void) -{ - int ccd_intr_level = gpio_get_level(GPIO_CCD_MODE_ODL); - - if (ccd_intr_level) { - /* Default set the SBU lines to AUX mode on TCPC-AIC */ - ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_1, 0); - ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_0, 0); - } else { - /* Set the SBU lines to CCD mode on TCPC-AIC */ - ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_1, 1); - ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_0, 0); - } -} -DECLARE_DEFERRED(board_connect_c0_sbu_deferred); - -void board_connect_c0_sbu(enum gpio_signal s) -{ - hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0); -} - -static void enable_h1_irq(void) -{ - gpio_enable_interrupt(GPIO_CCD_MODE_ODL); -} -DECLARE_HOOK(HOOK_INIT, enable_h1_irq, HOOK_PRIO_LAST); - -void set_charger_system_voltage(void) -{ - switch (ADL_RVP_BOARD_ID(board_get_version())) { - case ADLN_LP5_ERB_SKU_BOARD_ID: - case ADLN_LP5_RVP_SKU_BOARD_ID: - /* - * As per b:196184163 configure the PPVAR_SYS depend - * on AC or AC+battery - */ - if (extpower_is_present() && battery_is_present()) { - bq25710_set_min_system_voltage( - CHARGER_SOLO, battery_get_info()->voltage_min); - } else { - bq25710_set_min_system_voltage( - CHARGER_SOLO, battery_get_info()->voltage_max); - } - break; - - /* Add additional board SKUs */ - default: - break; - } -} -DECLARE_HOOK(HOOK_AC_CHANGE, set_charger_system_voltage, HOOK_PRIO_DEFAULT); - -static void configure_charger(void) -{ - switch (ADL_RVP_BOARD_ID(board_get_version())) { - case ADLN_LP5_ERB_SKU_BOARD_ID: - case ADLN_LP5_RVP_SKU_BOARD_ID: - /* charger chip BQ25720 support */ - chg_chips[0].i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS; - chg_chips[0].drv = &bq25710_drv; - set_charger_system_voltage(); - break; - - /* Add additional board SKUs */ - default: - break; - } -} - -static void configure_retimer_usbmux(void) -{ - struct usb_mux *mux; - - switch (ADL_RVP_BOARD_ID(board_get_version())) { - case ADLN_LP5_ERB_SKU_BOARD_ID: - case ADLN_LP5_RVP_SKU_BOARD_ID: - /* enable TUSB1044RNQR redriver on Port0 */ - mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_0), 0); - mux->i2c_addr_flags = TUSB1064_I2C_ADDR14_FLAGS; - mux->driver = &tusb1064_usb_mux_driver; - mux->hpd_update = tusb1044_hpd_update; - -#if defined(HAS_TASK_PD_C1) - mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_1), 0); - mux->driver = NULL; - mux->hpd_update = NULL; -#endif - break; - - case ADLP_LP5_T4_RVP_SKU_BOARD_ID: - /* No retimer on Port-2 */ -#if defined(HAS_TASK_PD_C2) - mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_2), 0); - mux->driver = NULL; -#endif - break; - - case ADLP_DDR5_RVP_SKU_BOARD_ID: - /* - * ADL-P-DDR5 RVP has dual BB-retimers for port0 & port1. - * Change the default usb mux config on runtime to support - * dual retimer topology. - */ - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_alt_chain_0); -#if defined(HAS_TASK_PD_C1) - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_alt_chain_1); -#endif - break; - - /* Add additional board SKUs */ - - default: - break; - } -} - -static void configure_battery_type(void) -{ - int bat_cell_type; - - switch (ADL_RVP_BOARD_ID(board_get_version())) { - case ADLM_LP4_RVP1_SKU_BOARD_ID: - case ADLM_LP5_RVP2_SKU_BOARD_ID: - case ADLM_LP5_RVP3_SKU_BOARD_ID: - case ADLN_LP5_ERB_SKU_BOARD_ID: - case ADLN_LP5_RVP_SKU_BOARD_ID: - /* configure Battery to 2S based */ - bat_cell_type = BATTERY_TYPE(DT_ALIAS(getac_2s)); - break; - default: - /* configure Battery to 3S based */ - bat_cell_type = BATTERY_TYPE(DT_ALIAS(getac_3s)); - break; - } - - /* Set the fixed battery type */ - battery_set_fixed_battery_type(bat_cell_type); -} -/******************************************************************************/ -/* PWROK signal configuration */ -/* - * On ADLRVP, SYS_PWROK_EC is an output controlled by EC and uses ALL_SYS_PWRGD - * as input. - */ -const struct intel_x86_pwrok_signal pwrok_signal_assert_list[] = { - { - .gpio = GPIO_PCH_SYS_PWROK, - .delay_ms = 3, - }, -}; -const int pwrok_signal_assert_count = ARRAY_SIZE(pwrok_signal_assert_list); - -const struct intel_x86_pwrok_signal pwrok_signal_deassert_list[] = { - { - .gpio = GPIO_PCH_SYS_PWROK, - }, -}; -const int pwrok_signal_deassert_count = ARRAY_SIZE(pwrok_signal_deassert_list); - -/* - * Returns board information (board id[7:0] and Fab id[15:8]) on success - * -1 on error. - */ -__override int board_get_version(void) -{ - /* Cache the board ID */ - static int adlrvp_board_id; - - int i; - int rv = EC_ERROR_UNKNOWN; - - int fab_id, board_id, bom_id; - - /* Board ID is already read */ - if (adlrvp_board_id) - return adlrvp_board_id; - - /* - * IOExpander that has Board ID information is on DSW-VAL rail on - * ADL RVP. On cold boot cycles, DSW-VAL rail is taking time to settle. - * This loop retries to ensure rail is settled and read is successful - */ - for (i = 0; i < RVP_VERSION_READ_RETRY_CNT; i++) { - rv = gpio_pin_get_dt(&bom_id_config[0]); - - if (rv >= 0) - break; - - k_msleep(1); - } - - /* retrun -1 if failed to read board id */ - if (rv < 0) - return -1; - - /* - * BOM ID [2] : IOEX[0] - * BOM ID [1:0] : IOEX[15:14] - */ - bom_id = gpio_pin_get_dt(&bom_id_config[0]) << 2; - bom_id |= gpio_pin_get_dt(&bom_id_config[1]) << 1; - bom_id |= gpio_pin_get_dt(&bom_id_config[2]); - - /* - * FAB ID [1:0] : IOEX[2:1] + 1 - */ - fab_id = gpio_pin_get_dt(&fab_id_config[0]) << 1; - fab_id |= gpio_pin_get_dt(&fab_id_config[1]); - fab_id += 1; - - /* - * BOARD ID[5:0] : IOEX[13:8] - */ - board_id = gpio_pin_get_dt(&board_id_config[0]) << 5; - board_id |= gpio_pin_get_dt(&board_id_config[1]) << 4; - board_id |= gpio_pin_get_dt(&board_id_config[2]) << 3; - board_id |= gpio_pin_get_dt(&board_id_config[3]) << 2; - board_id |= gpio_pin_get_dt(&board_id_config[4]) << 1; - board_id |= gpio_pin_get_dt(&board_id_config[5]); - - CPRINTF("BID:0x%x, FID:0x%x, BOM:0x%x", board_id, fab_id, bom_id); - - adlrvp_board_id = board_id | (fab_id << 8); - return adlrvp_board_id; -} - -__override bool board_is_tbt_usb4_port(int port) -{ - bool tbt_usb4 = true; - - switch (ADL_RVP_BOARD_ID(board_get_version())) { - case ADLN_LP5_ERB_SKU_BOARD_ID: - case ADLN_LP5_RVP_SKU_BOARD_ID: - /* No retimer on both ports */ - tbt_usb4 = false; - break; - - case ADLP_LP5_T4_RVP_SKU_BOARD_ID: - /* No retimer on Port-2 hence no platform level AUX & LSx mux */ -#if defined(HAS_TASK_PD_C2) - if (port == TYPE_C_PORT_2) - tbt_usb4 = false; -#endif - break; - - /* Add additional board SKUs */ - default: - break; - } - - return tbt_usb4; -} - -static int board_pre_task_peripheral_init(const struct device *unused) -{ - ARG_UNUSED(unused); - - /* Initialized IOEX-0 to access IOEX-GPIOs needed pre-task */ - ioex_init(IOEX_C0_PCA9675); - - /* Make sure SBU are routed to CCD or AUX based on CCD status at init */ - board_connect_c0_sbu_deferred(); - - /* Configure battery type */ - configure_battery_type(); - - /* Reconfigure board specific charger drivers */ - configure_charger(); - - /* Configure board specific retimer & mux */ - configure_retimer_usbmux(); - - return 0; -} -SYS_INIT(board_pre_task_peripheral_init, APPLICATION, - CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/zephyr/projects/intelrvp/include/intel_rvp_board_id.h b/zephyr/projects/intelrvp/include/intel_rvp_board_id.h deleted file mode 100644 index 7825b272e3..0000000000 --- a/zephyr/projects/intelrvp/include/intel_rvp_board_id.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __INTEL_RVP_BOARD_ID_H -#define __INTEL_RVP_BOARD_ID_H - -#include - -extern const struct gpio_dt_spec bom_id_config[]; - -extern const struct gpio_dt_spec fab_id_config[]; - -extern const struct gpio_dt_spec board_id_config[]; - -#endif /* __INTEL_RVP_BOARD_ID_H */ diff --git a/zephyr/projects/intelrvp/include/intelrvp.h b/zephyr/projects/intelrvp/include/intelrvp.h deleted file mode 100644 index 9b6dc98485..0000000000 --- a/zephyr/projects/intelrvp/include/intelrvp.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef __INTELRVP_BOARD_H -#define __INTELRVP_BOARD_H - -#include "compiler.h" -#include "gpio_signal.h" -#include "stdbool.h" - -/* RVP ID read retry count */ -#define RVP_VERSION_READ_RETRY_CNT 2 - -#define DC_JACK_MAX_VOLTAGE_MV 19000 - -FORWARD_DECLARE_ENUM(tcpc_rp_value); - -struct tcpc_aic_gpio_config_t { - /* TCPC interrupt */ - enum gpio_signal tcpc_alert; - /* PPC interrupt */ - enum gpio_signal ppc_alert; - /* PPC interrupt handler */ - void (*ppc_intr_handler)(int port); -}; -extern const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[]; - -void board_charging_enable(int port, int enable); -void board_vbus_enable(int port, int enable); -void board_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp); -void board_dc_jack_interrupt(enum gpio_signal signal); -void tcpc_alert_event(enum gpio_signal signal); -bool is_typec_port(int port); -#endif /* __INTELRVP_BOARD_H */ diff --git a/zephyr/projects/intelrvp/led.md b/zephyr/projects/intelrvp/led.md deleted file mode 100644 index c36bc6b36c..0000000000 --- a/zephyr/projects/intelrvp/led.md +++ /dev/null @@ -1,44 +0,0 @@ -## LED behavior on Intel RVP - -There are two LEDs on RVP, they represent battery and charger status -respectively. - -LED | Description -------------|------------------------ -CHARGER_LED | Represent charger state -BATTERY_LED | Represent battery state - -LEDs on RVP emit a single color (green). Rather than just using the on and off -state of the LED, PWM is used to blink the LED to represent multiple states and -the below table represents the multiple LED states. - -LED State | Description ----------------|------------------------------ -LED_ON | Switch On using gpio/pwmduty -LED_OFF | Switch Off using gpio/pwmduty -LED_FLASH_SLOW | Flashing with 2 sec period -LED_FLASH_FAST | Flashing with 250ms period - -### LED Behavior : Charger - -CHARGER_LED is dedicated to represent Charger status and the below table -represents the LED states for the Charger. - -Charger Status | LED States ----------------------|--------------- -Charging | LED_ON -Discharging | LED_FLASH_SLOW -Charging error | LED_FLASH_FAST -No Charger Connected | LED_OFF - -### LED Behavior : Battery - -BATTERY_LED is dedicated to represent Battery status and the below table -represents the LED states for the Battery. - -Battery Status | LED States -----------------------------|--------------- -Battery Low (<10%) | LED_FLASH_FAST -Battery Normal (10% to 90%) | LED_FLASH_SLOW -Battery Full (>90%) | LED_ON -Battery Not Present | LED_OFF diff --git a/zephyr/projects/intelrvp/legacy_ec_pwrseq.conf b/zephyr/projects/intelrvp/legacy_ec_pwrseq.conf deleted file mode 100644 index 331afb637d..0000000000 --- a/zephyr/projects/intelrvp/legacy_ec_pwrseq.conf +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Legacy EC Power Sequencing Common Config -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y -CONFIG_PLATFORM_EC_POWERSEQ_INTEL=y -CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y -CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y -CONFIG_PLATFORM_EC_POWERSEQ_S4=y -CONFIG_PLATFORM_EC_THROTTLE_AP=y diff --git a/zephyr/projects/intelrvp/mtlrvp/CMakeLists.txt b/zephyr/projects/intelrvp/mtlrvp/CMakeLists.txt deleted file mode 100644 index c6729af776..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -zephyr_library_sources("src/mtlrvp.c") -zephyr_library_sources("src/board_power.c") diff --git a/zephyr/projects/intelrvp/mtlrvp/ioex.dts b/zephyr/projects/intelrvp/mtlrvp/ioex.dts deleted file mode 100644 index 7d2f4b5820..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/ioex.dts +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* IOEX_KBD_GPIO IT8801 */ - ioex-kbd-gpio { - compatible = "cros,ioex-chip"; - i2c-port = <&i2c_charger>; - i2c-addr = <0x39>; - drv = "it8801_ioexpander_drv"; - flags = <0x00>; - #address-cells = <1>; - #size-cells = <0>; - - ioex_it8801_port0: it8801_port@0 { - compatible = "cros,ioex-port"; - reg = <0>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - }; - - ioex_it8801_port1: it8801_port@1 { - compatible = "cros,ioex-port"; - reg = <1>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - }; - }; - /* IOEX_C2_CCGXXF */ - ioex-c2 { - compatible = "cros,ioex-chip"; - i2c-port = <&typec_aic2>; - i2c-addr = <0x0B>; - drv = "ccgxxf_ioexpander_drv"; - flags = <0x00>; - #address-cells = <1>; - #size-cells = <0>; - ioex_c2_port0: ioex-c2-port@0 { - compatible = "cros,ioex-port"; - reg = <0>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - }; - ioex_c2_port1: ioex-c2-port@1 { - compatible = "cros,ioex-port"; - reg = <1>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - }; - ioex_c2_port2: ioex-c2-port@2 { - compatible = "cros,ioex-port"; - reg = <2>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - }; - ioex_c2_port3: ioex-c2-port@3 { - compatible = "cros,ioex-port"; - reg = <3>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts deleted file mode 100644 index cf85dd3413..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm3 0 PWM_KHZ(30) PWM_POLARITY_NORMAL>; - rpm_min = <3200>; - rpm_start = <2200>; - rpm_max = <6600>; - tach = <&tach2>; - pgood_gpio = <&all_sys_pwrgd>; - enable_gpio = <&gpio_fan_control>; - }; - }; -}; - -/* Tachemeter for fan speed measurement */ -&tach2 { - status = "okay"; - pinctrl-0 = <&ta2_1_in_gp73>; /* TA2 input on GPIO73 */ - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm3 { - status = "okay"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts deleted file mode 100644 index 77b4cf0573..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts +++ /dev/null @@ -1,366 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_wp; - }; - - named-gpios { - compatible = "named-gpios"; - - ioex_kbd_intr_n: ioex-kbd-intr-n { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_KB_DISCRETE_INT"; - }; - all_sys_pwrgd: all-sys-pwrgd { - gpios = <&gpio7 0 GPIO_INPUT>; - enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD"; - }; - rsmrst_pwrgd: rsmrst-pwrgd { - gpios = <&gpio6 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_PG_EC_RSMRST_ODL"; - }; - pch_slp_s0_n: pch-slp-s0-n-ec { - gpios = <&gpioa 1 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S0_L"; /* 1.8V */ - }; - pm-slp-s3-n-ec { - gpios = <&gpiob 0 GPIO_INPUT>; /* 1.8V */ - enum-name = "GPIO_PCH_SLP_S3_L"; - }; - pm-slp-s4-n-ec { - gpios = <&gpioa 5 GPIO_INPUT>; /* 1.8V */ - }; - volume-up { - gpios = <&gpio6 1 (GPIO_INPUT | GPIO_PULL_UP)>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - vol-dn-ec-r { - gpios = <&gpio0 3 (GPIO_INPUT | GPIO_PULL_UP)>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - smc_lid: smc-lid { - gpios = <&gpio0 1 (GPIO_INPUT | GPIO_PULL_UP)>; - enum-name = "GPIO_LID_OPEN"; - }; - smc_onoff_n: smc-onoff-n { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_wp: wp-l { - gpios = <&gpiod 5 GPIO_INPUT>; - }; - std_adp_prsnt: std-adp-prsnt { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_DC_JACK_PRESENT"; - }; - bc_acok: bc-acok-ec { - gpios = <&gpio0 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - usbc_tcpc_alrt_p0: usbc-tcpc-alrt-p0 { - gpios = <&gpio4 0 GPIO_INPUT>; - }; - /* NOTE: Netname is USBC_TCPC_PPC_ALRT_P0 */ - usb_c0_c1_tcpc_rst_odl: usb-c0-c1-tcpc-rst-odl { - gpios = <&gpiod 0 GPIO_ODR_HIGH>; - }; - /* NOTE: Netname is USBC_TCPC_ALRT_P1 */ - usbc_tcpc_ppc_alrt_p0: usbc-tcpc-ppc-alrt-p0 { - gpios = <&gpiod 1 GPIO_INPUT>; - }; - usbc_tcpc_ppc_alrt_p1: usbc-tcpc-ppc-alrt-p1 { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - usbc_tcpc_alrt_p2: usbc-tcpc-alrt-p2 { - gpios = <&gpio9 1 GPIO_INPUT>; - }; - /* NOTE: Netname is USBC_TCPC_PPC_ALRT_P3 */ - usbc_tcpc_alrt_p3: usbc-tcpc-alrt-p3 { - gpios = <&gpiof 3 GPIO_INPUT>; - }; - gpio_ec_pch_wake_odl: pch-wake-n { - gpios = <&gpio7 4 GPIO_ODR_HIGH>; - }; - espi-rst-n { - gpios = <&gpio5 4 GPIO_INPUT>; /* 1.8V */ - }; - plt-rst-l { - gpios = <&gpioa 2 GPIO_INPUT>; /* 1.8V */ - }; - slate-mode-indication { - gpios = <&gpio9 4 GPIO_INPUT>; /* 1.8V */ - }; - prochot-ec { - gpios = <&gpio6 0 GPIO_INPUT>; - enum-name = "GPIO_CPU_PROCHOT"; - }; - sys_rst_odl: sys-rst-odl-ec { - gpios = <&gpioc 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_SYS_RESET_L"; - }; - ec_pch_rsmrst_l: pm-rsmrst-r-n { - gpios = <&gpioa 4 GPIO_OUTPUT_LOW>; /* 1.8V */ - enum-name = "GPIO_PCH_RSMRST_L"; - }; - pm-pwrbtn-n-ec { - gpios = <&gpiod 4 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - ec_spi_oe_mecc: ec-spi-oe-mecc-r { - gpios = <&gpioa 7 GPIO_OUTPUT_LOW>; /* 1.8V */ - }; - en_pp3300_a: ec-ds3-r { - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP3300_A"; - alias = "GPIO_TEMP_SENSOR_POWER"; - }; - ec_pch_pwrok_od: pch-pwrok-ec-r { - gpios = <&gpiod 3 GPIO_ODR_LOW>; - enum-name = "GPIO_PCH_PWROK"; - }; - sys_pwrok_ec: sys-pwrok-ec { - gpios = <&gpiof 5 GPIO_ODR_LOW>; - enum-name = "GPIO_PCH_SYS_PWROK"; - }; - bat-det-ec { - gpios = <&gpio7 6 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - edp-bklt-en { - gpios = <&gpioe 1 GPIO_OUTPUT_HIGH>; - }; - /* TODO: move both LEDs to PWM */ - led-1-l-ec { - gpios = <&gpiob 6 GPIO_OUTPUT_HIGH>; - }; - led-2-l-ec { - gpios = <&gpiob 7 GPIO_OUTPUT_HIGH>; - }; - gpio_fan_control: therm-sen-mecc-r { - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - /* NOTE: Netname is USBC_TCPC_ALRT_P3 */ - ccd_mode_odl: ccd-mode-odl { - gpios = <&gpio9 2 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - smb-bs-clk { - gpios = <&gpiob 3 GPIO_INPUT>; - }; - smb-bs-data { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - usbc-tcpc-i2c-clk-aic1 { - gpios = <&gpiob 5 GPIO_INPUT>; - }; - usbc-tcpc-i2c-data-aic1 { - gpios = <&gpiob 4 GPIO_INPUT>; - }; - usbc-tcpc-i2c-clk-aic2 { - gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - usbc-tcpc-i2c-data-aic2 { - gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - /* Unused 1.8V pins */ - i3c-1-sda-r { - gpios = <&gpio5 0 GPIO_INPUT>; - }; - i3c-1-scl-r { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - espi-alert0-n-r { - gpios = <&gpio5 7 GPIO_INPUT>; - }; - tp-gpio95 { - gpios = <&gpio9 5 GPIO_INPUT>; - }; - cpu-c10-gate { - gpios = <&gpio9 6 GPIO_INPUT>; - }; - slp-s0-cs-n-ec { - gpios = <&gpio9 7 GPIO_INPUT>; - }; - rtc-rst-n-r { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - tp-gpioa6 { - gpios = <&gpioa 6 GPIO_INPUT>; - }; - sml1-clk-mecc { - gpios = <&gpio3 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - sml1-data-mecc { - gpios = <&gpio3 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - sml1-alert { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - smb-pch-alrt { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - smb-pch-data { - gpios = <&gpioc 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - smb-pch-clk { - gpios = <&gpioc 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - /* Unused 3.3V pins */ - cpu-cat-err-mecc { - gpios = <&gpio3 4 GPIO_INPUT>; - }; - tp-gpio37 { - gpios = <&gpio3 7 GPIO_INPUT>; - }; - tp-vccpdsw-3p3-ec { - gpios = <&gpio4 5 GPIO_INPUT>; - }; - mech-pwr-btn-in-odl { - gpios = <&gpio6 2 GPIO_INPUT>; - }; - tp-gpio63 { - gpios = <&gpio6 3 GPIO_INPUT>; - }; - tp-gpio67 { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - tp-gpio72 { - gpios = <&gpio7 2 GPIO_INPUT>; - }; - tp-gpio75 { - gpios = <&gpio7 5 GPIO_INPUT>; - }; - ec-peci-ec { - gpios = <&gpio8 1 GPIO_INPUT>; - }; - tp-gpiob1 { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - std-adpt-cntrl-GPIO_r { - gpios = <&gpioc 3 GPIO_INPUT>; - }; - ec-packet-mode-ec { - gpios = <&gpioe 2 GPIO_INPUT>; - }; - tp-gpioe3 { - gpios = <&gpioe 3 GPIO_INPUT>; - }; - boot-stall-r { - gpios = <&gpioe 5 GPIO_INPUT>; - }; - tp-gpiof0 { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - tp-gpiof1 { - gpios = <&gpiof 1 GPIO_INPUT>; - }; - usbc_tcpc_ppc_alrt_p2: usbc-tcpc-ppc-alrt-p2 { - gpios = <&gpiof 2 GPIO_INPUT>; - }; - tp-gpiof4 { - gpios = <&gpiof 4 GPIO_INPUT>; - }; - - /* KBD IOEX configuration */ - srtc-rst { - gpios = <&ioex_it8801_port0 3 GPIO_OUTPUT_LOW>; - }; - ec-h1-packet-mode { - gpios = <&ioex_it8801_port0 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - rtc-rst { - gpios = <&ioex_it8801_port0 6 GPIO_OUTPUT_LOW>; - }; - ec-entering-rw { - gpios = <&ioex_it8801_port0 7 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ioex-sys-rst-odl-ec { - gpios = <&ioex_it8801_port1 0 GPIO_INPUT>; - }; - ioex-slate-mode-indication { - gpios = <&ioex_it8801_port1 2 GPIO_INPUT>; - }; - - /* USB C IOEX configuration */ - usb_c0_hb_retimer_ls_en: usb-c0-hbr-ls-en { - gpios = <&ioex_c0 2 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_HBR_LS_EN"; - no-auto-init; - }; - usb_c0_hb_retimer_rst: usb-c0-hbr-rst { - gpios = <&ioex_c0 3 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_HBR_RST"; - no-auto-init; - }; - usb_c1_hb_retimer_ls_en: usb-c1-hbr-ls-en { - gpios = <&ioex_c1 2 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_HBR_LS_EN"; - no-auto-init; - }; - usb_c1_hb_retimer_rst: usb-c1-hbr-rst { - gpios = <&ioex_c1 3 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_HBR_RST"; - no-auto-init; - }; - usb-c0-mux-oe-n { - gpios = <&ioex_c0 4 GPIO_OUTPUT_LOW>; - no-auto-init; - }; - usb-c0-mux-sbu-sel-0 { - gpios = <&ioex_c0 6 GPIO_OUTPUT_HIGH>; - enum-name = "IOEX_USB_C0_MUX_SBU_SEL_0"; - no-auto-init; - }; - usb-c0-mux-sbu-sel-1 { - gpios = <&ioex_c1 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_MUX_SBU_SEL_1"; - no-auto-init; - }; - usb-c0-c1-prochot-n { - gpios = <&ioex_c1 6 GPIO_INPUT>; - no-auto-init; - }; - dg-bssb-sbu-sel { - gpios = <&ioex_c2_port1 4 GPIO_INPUT>; - no-auto-init; - }; - usb_c2_hb_retimer_rst: usb-c2-hbr-rst { - gpios = <&ioex_c2_port1 1 (GPIO_ODR_LOW | \ - GPIO_VOLTAGE_1P8)>; - enum-name = "IOEX_USB_C2_HBR_RST"; - no-auto-init; - }; - usb_c2_hb_retimer_ls_en: usb-c2-hbr-ls-en { - gpios = <&ioex_c2_port2 0 (GPIO_ODR_LOW | \ - GPIO_VOLTAGE_1P8)>; - enum-name = "IOEX_USB_C2_HBR_LS_EN"; - no-auto-init; - }; - usb_c3_hb_retimer_rst: usb-c3-hbr-rst { - gpios = <&ioex_c2_port1 3 (GPIO_ODR_LOW | \ - GPIO_VOLTAGE_1P8)>; - enum-name = "IOEX_USB_C3_HBR_RST"; - no-auto-init; - }; - usb_c3_hb_retimer_ls_en: usb-c3-hbr-ls-en { - gpios = <&ioex_c2_port3 3 (GPIO_ODR_LOW | \ - GPIO_VOLTAGE_1P8)>; - enum-name = "IOEX_USB_C3_HBR_LS_EN"; - no-auto-init; - }; - usb-c2-c3-prochot-n { - gpios = <&ioex_c2_port0 0 GPIO_INPUT>; - no-auto-init; - }; - /* unimplemented GPIOs */ - en-pp5000 { - enum-name = "GPIO_EN_PP5000"; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts deleted file mode 100644 index b120f6c05e..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_lid_open: lid_open { - irq-pin = <&smc_lid>; - flags = ; - handler = "lid_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&smc_onoff_n>; - flags = ; - handler = "power_button_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&bc_acok>; - flags = ; - handler = "extpower_interrupt"; - }; - int_ioex_kbd_intr_n: ioex_kbd_intr_n { - irq-pin = <&ioex_kbd_intr_n>; - flags = ; - handler = "io_expander_it8801_interrupt"; - }; - int_usb_c0_c1_tcpc: usb_c0_tcpc { - irq-pin = <&usbc_tcpc_alrt_p0>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&usbc_tcpc_ppc_alrt_p0>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_ppc: usb_c1_ppc { - irq-pin = <&usbc_tcpc_ppc_alrt_p1>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c2_tcpc: usb_c2_tcpc { - irq-pin = <&usbc_tcpc_alrt_p2>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c3_tcpc: usb_c3_tcpc { - irq-pin = <&usbc_tcpc_alrt_p3>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_ccd_mode: ccd_mode { - irq-pin = <&ccd_mode_odl>; - flags = ; - handler = "board_connect_c0_sbu"; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts deleted file mode 100644 index 81d6e82f48..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - output-settle = <35>; - debounce-down = <5000>; - debounce-up = <40000>; - poll-timeout = <100000>; - - actual-key-mask = < - 0x14 /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts deleted file mode 100644 index 44f283071b..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts +++ /dev/null @@ -1,273 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #include - -/ { - chosen { - cros,rtc = &mtc; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_lid_open - &int_power_button - >; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_charger: charger { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_CHARGER", - "I2C_PORT_BATTERY", - "I2C_PORT_EEPROM", - "I2C_PORT_KB_DISCRETE", - "I2C_PORT_PORT80"; - }; - typec_aic1: typec-aic1{ - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_TYPEC_AIC_1"; - }; - typec_aic2: typec-aic2{ - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_TYPEC_AIC_2"; - }; - }; - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ambient: ambient { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 3>; - }; - adc_ddr: ddr { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 4>; - }; - adc_skin: skin { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 2>; - }; - adc_vr: vr { - enum-name = "ADC_TEMP_SENSOR_4"; - io-channels = <&adc0 1>; - }; - }; -}; - -/* charger */ -&i2c7_0 { - label = "I2C_CHARGER"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; - - pca95xx: pca95xx@22 { - compatible = "nxp,pca95xx"; - label = "PCA95XX"; - reg = <0x22>; - gpio-controller; - #gpio-cells = <2>; - ngpios = <16>; - }; - - rvp_board_id: rvp-board-id { - compatible = "intel,rvp-board-id"; - - /* - * BOM ID [2] : IOEX[0] - * BOM ID [1:0] : IOEX[15:14] - */ - bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>; - - /* - * FAB ID [1:0] : IOEX[2:1] - */ - fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>; - - /* - * BOARD ID[5:0] : IOEX[13:8] - */ - board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>, - <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>; - }; - - kb_discrete: ite-it8801@39 { - compatible = "ite,it8801"; - reg = <0x39>; - }; - - seven_seg_display: max695x-seven-seg-display@38 { - compatible = "maxim,seven-seg-display"; - reg = <0x38>; - label = "MAX695X_SEVEN_SEG_DISPLAY"; - }; - - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; - -/* typec_aic1 */ -&i2c0_0 { - label = "I2C_USB_C0_C1_TCPC"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; - - tcpc_port0: nct38xx@73 { - compatible = "nuvoton,nct38xx"; - reg = <0x73>; - gpio-dev = <&nct38xx_c0>; - tcpc-flags = <( - TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>; - }; - - nct38xx_c0: nct38xx_c0@73 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x73>; - label = "NCT38XX_C0"; - - ioex_c0: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT38XX_C0_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xdc>; - pinmux_mask = <0xff>; - }; - }; - - tcpc_port1: nct38xx@77 { - compatible = "nuvoton,nct38xx"; - reg = <0x77>; - gpio-dev = <&nct38xx_c1>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct38xx_c1: nct38xx_c1@77 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x77>; - label = "NCT38XX_C1"; - - ioex_c1: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT38XX_C1_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xdc>; - pinmux_mask = <0xff>; - }; - }; - - nct38xx_alert_0 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpio4 0 GPIO_ACTIVE_LOW>; - nct38xx-dev = <&nct38xx_c0 &nct38xx_c1>; - label = "NCT38XX_ALERT_1"; - }; - - usb_c0_hb_retimer: jhl8040r-c0@56 { - compatible = "intel,jhl8040r"; - reg = <0x56>; - reset-pin = <&usb_c0_hb_retimer_rst>; - ls-en-pin = <&usb_c0_hb_retimer_ls_en>; - }; - - usb_c1_hb_retimer: jhl8040r-c1@57 { - compatible = "intel,jhl8040r"; - reg = <0x57>; - reset-pin = <&usb_c1_hb_retimer_rst>; - ls-en-pin = <&usb_c1_hb_retimer_ls_en>; - }; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -/* typec_aic2 */ -&i2c1_0 { - label = "I2C_USB_C2_C3_TCPC"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - tcpc_port2: ccgxxf@b { - compatible = "cypress,ccgxxf"; - reg = <0xb>; - }; - - tcpc_port3: ccgxxf@1b { - compatible = "cypress,ccgxxf"; - reg = <0x1b>; - }; - - usb_c2_hb_retimer: jhl8040r-c2@58 { - compatible = "intel,jhl8040r"; - reg = <0x58>; - reset-pin = <&usb_c2_hb_retimer_rst>; - ls-en-pin = <&usb_c2_hb_retimer_ls_en>; - }; - - usb_c3_hb_retimer: jhl8040r-c3@59 { - compatible = "intel,jhl8040r"; - reg = <0x59>; - reset-pin = <&usb_c3_hb_retimer_rst>; - ls-en-pin = <&usb_c3_hb_retimer_ls_en>; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42 - &adc0_chan4_gp41>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts deleted file mode 100644 index 3c270d296f..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <3>; - all-sys-pwrgd-timeout = <20>; - sys-reset-delay = <60>; - }; - - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpioc 4 0>; - output; - }; - pwr-pg-ec-rsmrst-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpio6 6 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioa 4 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpioa 1 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpiod 3 GPIO_OPEN_DRAIN>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpiof 5 GPIO_OPEN_DRAIN>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s3 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S3 virtual wire input from PCH"; - enum-name = "PWR_SLP_S3"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S3"; - vw-invert; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - gpios = <&gpio7 0 0>; - interrupt-flags = ; - }; -}; - -/* - * Because the power signals directly reference the GPIOs, - * the correspinding named-gpios need to have no-auto-init set. - */ -&en_pp3300_a { - no-auto-init; -}; -&rsmrst_pwrgd { - no-auto-init; -}; -&ec_pch_rsmrst_l { - no-auto-init; -}; -&pch_slp_s0_n { - no-auto-init; -}; -&ec_pch_pwrok_od { - no-auto-init; -}; -&sys_pwrok_ec { - no-auto-init; -}; -&sys_rst_odl { - no-auto-init; -}; -&all_sys_pwrgd { - no-auto-init; -}; diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf deleted file mode 100644 index 45b101a7ac..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_MTLRVP_NPCX=y -CONFIG_CROS_FLASH_NPCX=y -CONFIG_CROS_SYSTEM_NPCX=y -CONFIG_SYSCON=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# Fan -CONFIG_TACH_NPCX=y - -#RTC -CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/projects/intelrvp/mtlrvp/prj.conf b/zephyr/projects/intelrvp/mtlrvp/prj.conf deleted file mode 100644 index 1a521d4c89..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/prj.conf +++ /dev/null @@ -1,80 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Power Sequencing -CONFIG_AP_X86_INTEL_MTL=y -CONFIG_X86_NON_DSX_PWRSEQ_MTL=y -CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n - -# Battery -CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y -CONFIG_PLATFORM_EC_BATTERY_V2=y - -# CBI -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y -CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# Disable BC1.2 -CONFIG_PLATFORM_EC_USB_CHARGER=n - -# Charger -CONFIG_PLATFORM_EC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 -CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=n -CONFIG_PLATFORM_EC_CHARGER_ISL9241=y -CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y - -# IOEX -CONFIG_PLATFORM_EC_IOEX_CROS_DRV=y -CONFIG_PLATFORM_EC_IOEX_CCGXXF=y -CONFIG_GPIO_PCA95XX=y -CONFIG_GPIO_NCT38XX=y -CONFIG_PLATFORM_EC_IOEX_IT8801=y - -#Keyboard from I/O expander -CONFIG_PLATFORM_EC_KEYBOARD_DISCRETE=y -CONFIG_CROS_KB_RAW_NPCX=n - -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y - -# USB CONFIG -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_MUX_TASK=y -CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y -CONFIG_PLATFORM_EC_USBC_PPC=y -CONFIG_PLATFORM_EC_USB_PD_PPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_CCGXXF=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y -CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y -CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y -CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y -CONFIG_PLATFORM_EC_USBC_VCONN=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y -CONFIG_PLATFORM_EC_USB_PD_USB4=y -CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y -CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y -CONFIG_PLATFORM_EC_USB_PD_PORT_1_SHARED=y - -# 7-Segment Display -CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y diff --git a/zephyr/projects/intelrvp/mtlrvp/src/board_power.c b/zephyr/projects/intelrvp/mtlrvp/src/board_power.c deleted file mode 100644 index 301402bf0f..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/src/board_power.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "gpio_signal.h" -#include "gpio/gpio.h" - -LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); - -#if CONFIG_X86_NON_DSX_PWRSEQ_MTL -#define X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS 50 - -void board_ap_power_force_shutdown(void) -{ - int timeout_ms = X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS; - - /* Turn off PCH_RMSRST to meet tPCH12 */ - power_signal_set(PWR_EC_PCH_RSMRST, 0); - - /* Turn off PRIM load switch. */ - power_signal_set(PWR_EN_PP3300_A, 0); - - /* Wait RSMRST to be off. */ - while (power_signal_get(PWR_RSMRST) && (timeout_ms > 0)) { - k_msleep(1); - timeout_ms--; - }; - - if (power_signal_get(PWR_RSMRST)) - LOG_WRN("RSMRST_ODL didn't go low! Assuming G3."); -} - -void board_ap_power_action_g3_s5(void) -{ - /* Turn on the PP3300_PRIM rail. */ - power_signal_set(PWR_EN_PP3300_A, 1); - - if (!power_wait_signals_timeout( - IN_PGOOD_ALL_CORE, - AP_PWRSEQ_DT_VALUE(wait_signal_timeout))) { - ap_power_ev_send_callbacks(AP_POWER_PRE_INIT); - } -} - -bool board_ap_power_check_power_rails_enabled(void) -{ - return power_signal_get(PWR_EN_PP3300_A); -} -#endif /* CONFIG_X86_NON_DSX_PWRSEQ_MTL */ diff --git a/zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c b/zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c deleted file mode 100644 index 9d96a08712..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c +++ /dev/null @@ -1,331 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "battery.h" -#include "battery_fuel_gauge.h" -#include "charger.h" -#include "common.h" -#include "console.h" -#include "driver/retimer/bb_retimer_public.h" -#include "driver/tcpm/ccgxxf.h" -#include "driver/tcpm/nct38xx.h" -#include "driver/tcpm/tcpci.h" -#include "extpower.h" -#include "gpio.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "i2c.h" -#include "intelrvp.h" -#include "intel_rvp_board_id.h" -#include "ioexpander.h" -#include "isl9241.h" -#include "keyboard_raw.h" -#include "power/meteorlake.h" -#include "sn5s330.h" -#include "system.h" -#include "task.h" -#include "tusb1064.h" -#include "usb_mux.h" -#include "usbc_ppc.h" -#include "util.h" - -#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ##args) -#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ##args) - -/*******************************************************************/ -/* USB-C Configuration Start */ - -/* PPC */ -#define I2C_ADDR_SN5S330_P0 0x40 -#define I2C_ADDR_SN5S330_P1 0x41 - -/* IOEX ports */ -enum ioex_port { - IOEX_KBD = 0, -#if defined(HAS_TASK_PD_C2) - IOEX_C2_CCGXXF, -#endif - IOEX_COUNT -}; - -/* USB-C ports */ -enum usbc_port { - USBC_PORT_C0 = 0, - USBC_PORT_C1, -#if defined(HAS_TASK_PD_C2) - USBC_PORT_C2, - USBC_PORT_C3, -#endif - USBC_PORT_COUNT -}; -BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); - -/* USB-C PPC configuration */ -struct ppc_config_t ppc_chips[] = { - [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_TYPEC_AIC_1, - .i2c_addr_flags = I2C_ADDR_SN5S330_P0, - .drv = &sn5s330_drv, - }, - [USBC_PORT_C1] = { - .i2c_port = I2C_PORT_TYPEC_AIC_1, - .i2c_addr_flags = I2C_ADDR_SN5S330_P1, - .drv = &sn5s330_drv, - }, -}; -unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); - -/* TCPC AIC GPIO Configuration */ -const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[] = { - [USBC_PORT_C0] = { - .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)), - .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p0)), - .ppc_intr_handler = sn5s330_interrupt, - }, - [USBC_PORT_C1] = { - .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)), - .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p1)), - .ppc_intr_handler = sn5s330_interrupt, - }, -#if defined(HAS_TASK_PD_C2) - [USBC_PORT_C2] = { - .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p2)), - /* No PPC alert for CCGXXF */ - }, - [USBC_PORT_C3] = { - .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p3)), - /* No PPC alert for CCGXXF */ - }, -#endif -}; -BUILD_ASSERT(ARRAY_SIZE(tcpc_aic_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT); - -static void board_connect_c0_sbu_deferred(void) -{ - enum pd_power_role prole; - - if (gpio_get_level(GPIO_CCD_MODE_ODL)) { - CPRINTS("Default AUX line connected"); - /* Default set the SBU lines to AUX mode */ - ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 0); - ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 1); - } else { - prole = pd_get_power_role(USBC_PORT_C0); - CPRINTS("%s debug device is attached", - prole == PD_ROLE_SINK ? "Servo V4C/SuzyQ" : "Intel"); - - if (prole == PD_ROLE_SINK) { - /* Set the SBU lines to Google CCD mode */ - ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 1); - ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 1); - } else { - /* Set the SBU lines to Intel CCD mode */ - ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 0); - ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 0); - } - } -} -DECLARE_DEFERRED(board_connect_c0_sbu_deferred); - -void board_overcurrent_event(int port, int is_overcurrented) -{ - /* - * TODO: Meteorlake PCH does not use Physical GPIO for over current - * error, hence Send 'Over Current Virtual Wire' eSPI signal. - */ -} - -void board_reset_pd_mcu(void) -{ - /* Reset NCT38XX TCPC */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(usb_c0_c1_tcpc_rst_odl), 0); - msleep(NCT38XX_RESET_HOLD_DELAY_MS); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(usb_c0_c1_tcpc_rst_odl), 1); - nct38xx_reset_notify(0); - nct38xx_reset_notify(1); - - if (NCT3807_RESET_POST_DELAY_MS != 0) { - msleep(NCT3807_RESET_POST_DELAY_MS); - } - - /* NCT38XX chip uses gpio ioex */ - gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_c0))); - gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_c1))); - -#if defined(HAS_TASK_PD_C2) - /* Reset the ccgxxf ports only resetting 1 is required */ - ccgxxf_reset(USBC_PORT_C2); - - /* CCGXXF has ioex on port 2 */ - ioex_init(IOEX_C2_CCGXXF); -#endif -} - -void board_connect_c0_sbu(enum gpio_signal signal) -{ - hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0); -} - -/******************************************************************************/ -/* KSO mapping for discrete keyboard */ -__override const uint8_t it8801_kso_mapping[] = { - 0, 1, 20, 3, 4, 5, 6, 11, 12, 13, 14, 15, 16, -}; -BUILD_ASSERT(ARRAY_SIZE(it8801_kso_mapping) == KEYBOARD_COLS_MAX); - -/* PWROK signal configuration */ -/* - * On MTLRVP, SYS_PWROK_EC is an output controlled by EC and uses ALL_SYS_PWRGD - * as input. - */ -const struct intel_x86_pwrok_signal pwrok_signal_assert_list[] = { - { - .gpio = GPIO_PCH_SYS_PWROK, - .delay_ms = 3, - }, -}; -const int pwrok_signal_assert_count = ARRAY_SIZE(pwrok_signal_assert_list); - -const struct intel_x86_pwrok_signal pwrok_signal_deassert_list[] = { - { - .gpio = GPIO_PCH_SYS_PWROK, - }, -}; -const int pwrok_signal_deassert_count = ARRAY_SIZE(pwrok_signal_deassert_list); - -/* - * Returns board information (board id[7:0] and Fab id[15:8]) on success - * -1 on error. - */ -__override int board_get_version(void) -{ - /* Cache the MTLRVP board ID */ - static int mtlrvp_board_id; - - int i; - int rv = EC_ERROR_UNKNOWN; - int fab_id, board_id, bom_id; - - /* Board ID is already read */ - if (mtlrvp_board_id) - return mtlrvp_board_id; - - /* - * IOExpander that has Board ID information is on DSW-VAL rail on - * ADL RVP. On cold boot cycles, DSW-VAL rail is taking time to settle. - * This loop retries to ensure rail is settled and read is successful - */ - for (i = 0; i < RVP_VERSION_READ_RETRY_CNT; i++) { - rv = gpio_pin_get_dt(&bom_id_config[0]); - - if (rv >= 0) - break; - - k_msleep(1); - } - - /* return -1 if failed to read board id */ - if (rv) - return -1; - - /* - * BOM ID [2] : IOEX[0] - * BOM ID [1:0] : IOEX[15:14] - */ - bom_id = gpio_pin_get_dt(&bom_id_config[0]) << 2; - bom_id |= gpio_pin_get_dt(&bom_id_config[1]) << 1; - bom_id |= gpio_pin_get_dt(&bom_id_config[2]); - /* - * FAB ID [1:0] : IOEX[2:1] + 1 - */ - fab_id = gpio_pin_get_dt(&fab_id_config[0]) << 1; - fab_id |= gpio_pin_get_dt(&fab_id_config[1]); - fab_id += 1; - - /* - * BOARD ID[5:0] : IOEX[13:8] - */ - board_id = gpio_pin_get_dt(&board_id_config[0]) << 5; - board_id |= gpio_pin_get_dt(&board_id_config[1]) << 4; - board_id |= gpio_pin_get_dt(&board_id_config[2]) << 3; - board_id |= gpio_pin_get_dt(&board_id_config[3]) << 2; - board_id |= gpio_pin_get_dt(&board_id_config[4]) << 1; - board_id |= gpio_pin_get_dt(&board_id_config[5]); - - CPRINTF("BID:0x%x, FID:0x%x, BOM:0x%x", board_id, fab_id, bom_id); - - mtlrvp_board_id = board_id | (fab_id << 8); - return mtlrvp_board_id; -} - -static void board_int_init(void) -{ - /* Enable PPC interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc)); - - /* Enable TCPC interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_c1_tcpc)); -#if defined(HAS_TASK_PD_C2) - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c2_tcpc)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c3_tcpc)); -#endif - - /* Enable CCD Mode interrupt */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode)); -} - -static int board_pre_task_peripheral_init(const struct device *unused) -{ - ARG_UNUSED(unused); - - /* Only reset tcpc/pd if not sysjump */ - if (!system_jumped_late()) { - /* Initialize tcpc and all ioex */ - board_reset_pd_mcu(); - } - - /* Initialize all interrupts */ - board_int_init(); - - /* Make sure SBU are routed to CCD or AUX based on CCD status at init */ - board_connect_c0_sbu_deferred(); - - return 0; -} -SYS_INIT(board_pre_task_peripheral_init, APPLICATION, - CONFIG_APPLICATION_INIT_PRIORITY); - -/* - * Since MTLRVP has both PPC and TCPC ports override to check if the port - * is a PPC or non PPC port - */ -__override bool pd_check_vbus_level(int port, enum vbus_level level) -{ - if (!board_port_has_ppc(port)) { - return tcpm_check_vbus_level(port, level); - } else if (level == VBUS_PRESENT) { - return pd_snk_is_vbus_provided(port); - } else { - return !pd_snk_is_vbus_provided(port); - } -} - -__override bool board_port_has_ppc(int port) -{ - bool ppc_port; - - switch (port) { - case USBC_PORT_C0: - case USBC_PORT_C1: - ppc_port = true; - break; - default: - ppc_port = false; - break; - } - - return ppc_port; -} diff --git a/zephyr/projects/intelrvp/mtlrvp/usbc.dts b/zephyr/projects/intelrvp/mtlrvp/usbc.dts deleted file mode 100644 index e4f3bdc465..0000000000 --- a/zephyr/projects/intelrvp/mtlrvp/usbc.dts +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - usbc_port0: port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c0_hb_retimer - &virtual_mux_c0>; - }; - }; - port0-muxes { - virtual_mux_c0: virtual-mux-c0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - usbc_port1: port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c1_hb_retimer - &virtual_mux_c1>; - }; - }; - port1-muxes { - virtual_mux_c1: virtual-mux-c1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - usbc_port2: port2@2 { - compatible = "named-usbc-port"; - reg = <2>; - tcpc = <&tcpc_port2>; - usb-mux-chain-2 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c2_hb_retimer - &virtual_mux_c2>; - }; - }; - port2-muxes { - virtual_mux_c2: virtual-mux-c2 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - usbc_port3: port3@3 { - compatible = "named-usbc-port"; - reg = <3>; - tcpc = <&tcpc_port3>; - usb-mux-chain-3 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c3_hb_retimer - &virtual_mux_c3>; - }; - }; - port3-muxes { - virtual_mux_c3: virtual-mux-c3 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; diff --git a/zephyr/projects/intelrvp/prj.conf b/zephyr/projects/intelrvp/prj.conf deleted file mode 100644 index df04eca101..0000000000 --- a/zephyr/projects/intelrvp/prj.conf +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - - -CONFIG_CROS_EC=y -CONFIG_LTO=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_SHIMMED_TASKS=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001 - -#Power Sequencing -CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y - -# Host command -CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=y -CONFIG_PLATFORM_EC_PORT80=y - -# USB-C and PD -CONFIG_PLATFORM_EC_USB_VID=0x18d1 -CONFIG_PLATFORM_EC_USB_PID=0x8086 -CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y - -# I2C -CONFIG_I2C=y - -# eSPI -CONFIG_ESPI=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_CMD_BUTTON=n - -# Sensors -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n - -# Shell Commands -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y -CONFIG_KERNEL_SHELL=y - -# Logging -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y - -# TODO -# Below conf are disabled to compile successfully -# These will be enabled in upcoming CLs -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n diff --git a/zephyr/projects/intelrvp/src/chg_usb_pd.c b/zephyr/projects/intelrvp/src/chg_usb_pd.c deleted file mode 100644 index 63a1853b4d..0000000000 --- a/zephyr/projects/intelrvp/src/chg_usb_pd.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Common USB PD charge configuration */ - -#include "charge_manager.h" -#include "charge_state_v2.h" -#include "gpio.h" -#include "hooks.h" -#include "intelrvp.h" -#include "tcpm/tcpci.h" - -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) - -bool is_typec_port(int port) -{ -#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 - return !(port == DEDICATED_CHARGE_PORT || port == CHARGE_PORT_NONE); -#else - return !(port == CHARGE_PORT_NONE); -#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */ -} - -static inline int board_dc_jack_present(void) -{ -#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 - return gpio_get_level(GPIO_DC_JACK_PRESENT); -#else - return 0; -#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */ -} - -static void board_dc_jack_handle(void) -{ -#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 - struct charge_port_info charge_dc_jack; - - /* System is booted from DC Jack */ - if (board_dc_jack_present()) { - charge_dc_jack.current = - (PD_MAX_POWER_MW * 1000) / DC_JACK_MAX_VOLTAGE_MV; - charge_dc_jack.voltage = DC_JACK_MAX_VOLTAGE_MV; - } else { - charge_dc_jack.current = 0; - charge_dc_jack.voltage = USB_CHARGER_VOLTAGE_MV; - } - - charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED, - DEDICATED_CHARGE_PORT, &charge_dc_jack); -#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */ -} - -void board_dc_jack_interrupt(enum gpio_signal signal) -{ - board_dc_jack_handle(); -} - -static void board_charge_init(void) -{ - int port, supplier; - struct charge_port_info charge_init = { - .current = 0, - .voltage = USB_CHARGER_VOLTAGE_MV, - }; - - /* Initialize all charge suppliers to seed the charge manager */ - for (port = 0; port < CHARGE_PORT_COUNT; port++) { - for (supplier = 0; supplier < CHARGE_SUPPLIER_COUNT; - supplier++) { - charge_manager_update_charge(supplier, port, - &charge_init); - } - } - - board_dc_jack_handle(); -} -DECLARE_HOOK(HOOK_INIT, board_charge_init, HOOK_PRIO_DEFAULT); - -int board_set_active_charge_port(int port) -{ - int i; - /* charge port is a realy physical port */ - int is_real_port = (port >= 0 && port < CHARGE_PORT_COUNT); - /* check if we are source vbus on that port */ - int source = board_vbus_source_enabled(port); - - if (is_real_port && source) { - CPRINTS("Skip enable p%d", port); - return EC_ERROR_INVAL; - } - -#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 - /* - * Do not enable Type-C port if the DC Jack is present. - * When the Type-C is active port, hardware circuit will - * block DC jack from enabling +VADP_OUT. - */ - if (port != DEDICATED_CHARGE_PORT && board_dc_jack_present()) { - CPRINTS("DC Jack present, Skip enable p%d", port); - return EC_ERROR_INVAL; - } -#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT */ - - /* Make sure non-charging ports are disabled */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (i != port) { - board_charging_enable(i, 0); - } - } - - /* Enable charging port */ - if (is_typec_port(port)) { - board_charging_enable(port, 1); - } - - CPRINTS("New chg p%d", port); - - return EC_SUCCESS; -} - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} diff --git a/zephyr/projects/intelrvp/src/chg_usb_pd_mecc_1_1.c b/zephyr/projects/intelrvp/src/chg_usb_pd_mecc_1_1.c deleted file mode 100644 index 45fbbc6f65..0000000000 --- a/zephyr/projects/intelrvp/src/chg_usb_pd_mecc_1_1.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Intel-RVP family-specific configuration */ - -#include "console.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "include/gpio.h" -#include "intelrvp.h" -#include "ioexpander.h" -#include "system.h" -#include "tcpm/tcpci.h" -#include "usbc_ppc.h" - -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) - -void tcpc_alert_event(enum gpio_signal signal) -{ - int i; - - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - /* No alerts for embedded TCPC */ - if (tcpc_config[i].bus_type == EC_BUS_TYPE_EMBEDDED) { - continue; - } - - if (signal == tcpc_aic_gpios[i].tcpc_alert) { - schedule_deferred_pd_interrupt(i); - break; - } - } -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - int i; - - /* Check which port has the ALERT line set */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - /* No alerts for embdeded TCPC */ - if (tcpc_config[i].bus_type == EC_BUS_TYPE_EMBEDDED) { - continue; - } - - if (!gpio_get_level(tcpc_aic_gpios[i].tcpc_alert)) { - status |= PD_STATUS_TCPC_ALERT_0 << i; - } - } - - return status; -} - -int ppc_get_alert_status(int port) -{ - return tcpc_aic_gpios[port].ppc_intr_handler && - !gpio_get_level(tcpc_aic_gpios[port].ppc_alert); -} - -/* PPC support routines */ -void ppc_interrupt(enum gpio_signal signal) -{ - int i; - - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (tcpc_aic_gpios[i].ppc_intr_handler && - signal == tcpc_aic_gpios[i].ppc_alert) { - tcpc_aic_gpios[i].ppc_intr_handler(i); - break; - } - } -} - -void board_charging_enable(int port, int enable) -{ - int rv; - - if (tcpc_aic_gpios[port].ppc_intr_handler) { - rv = ppc_vbus_sink_enable(port, enable); - } else { - rv = tcpc_config[port].drv->set_snk_ctrl(port, enable); - } - - if (rv) { - CPRINTS("C%d: sink path %s failed", port, - enable ? "en" : "dis"); - } -} diff --git a/zephyr/projects/intelrvp/src/intel_rvp_board_id.c b/zephyr/projects/intelrvp/src/intel_rvp_board_id.c deleted file mode 100644 index 77d4e93afd..0000000000 --- a/zephyr/projects/intelrvp/src/intel_rvp_board_id.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include "intel_rvp_board_id.h" - -#define DT_DRV_COMPAT intel_rvp_board_id - -BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1, - "Unsupported RVP Board ID instance"); - -#define RVP_ID_GPIO_DT_SPEC_GET(idx, node_id, prop) \ - GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx), - -#define RVP_ID_CONFIG_LIST(node_id, prop) \ - LISTIFY(DT_PROP_LEN(node_id, prop), RVP_ID_GPIO_DT_SPEC_GET, (), \ - node_id, prop) - -#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -const struct gpio_dt_spec bom_id_config[] = { RVP_ID_CONFIG_LIST(DT_DRV_INST(0), - bom_gpios) }; - -const struct gpio_dt_spec fab_id_config[] = { RVP_ID_CONFIG_LIST(DT_DRV_INST(0), - fab_gpios) }; - -const struct gpio_dt_spec board_id_config[] = { RVP_ID_CONFIG_LIST( - DT_DRV_INST(0), board_gpios) }; -#endif /* #if DT_HAS_COMPAT_STATUS_OKAY */ diff --git a/zephyr/projects/intelrvp/src/intel_rvp_led.c b/zephyr/projects/intelrvp/src/intel_rvp_led.c deleted file mode 100644 index 0e4d872963..0000000000 --- a/zephyr/projects/intelrvp/src/intel_rvp_led.c +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "battery.h" -#include "charge_manager.h" -#include "charge_state.h" -#include "chipset.h" -#include "common.h" -#include "console.h" -#include "ec_commands.h" -#include "extpower.h" -#include "hooks.h" -#include "led_common.h" -#include "led_pwm.h" -#include "pwm.h" -#include "timer.h" -#include "util.h" - -/* Battery percentage thresholds to blink at different rates. */ -#define LOW_BATTERY_PERCENTAGE 10 -#define NORMAL_BATTERY_PERCENTAGE 90 - -#define LED_OFF -1 - -#define LED_PULSE_TICK (125 * MSEC) - -#define LED_FAST_PULSE_PERIOD (250 / 125) /* 250 ms */ -#define LED_SLOW_PULSE_PERIOD ((2 * MSEC) / 125) /* 2 sec */ - -struct led_pulse_data { - bool led_is_pulsing; - uint8_t led_pulse_period; - uint8_t led_tick_count; -}; - -static struct led_pulse_data rvp_led[CONFIG_LED_PWM_COUNT]; - -static void pulse_led_deferred(void); -DECLARE_DEFERRED(pulse_led_deferred); - -static void pulse_led_deferred(void) -{ - int i = 0; - bool call_deferred = false; - - for (i = 0; i < CONFIG_LED_PWM_COUNT; i++) { - if (!rvp_led[i].led_is_pulsing) { - rvp_led[i].led_tick_count = 0; - continue; - } - - /* - * LED will be in ON state first half of the pulse period - * and in OFF state in second half of the pulse period. - */ - if (rvp_led[i].led_tick_count < - (rvp_led[i].led_pulse_period >> 1)) - set_pwm_led_color(i, EC_LED_COLOR_GREEN); - else - set_pwm_led_color(i, LED_OFF); - - rvp_led[i].led_tick_count = (rvp_led[i].led_tick_count + 1) % - rvp_led[i].led_pulse_period; - call_deferred = true; - } - - if (call_deferred) - hook_call_deferred(&pulse_led_deferred_data, LED_PULSE_TICK); -} - -static void pulse_leds(enum pwm_led_id id, int period) -{ - rvp_led[id].led_pulse_period = period; - rvp_led[id].led_is_pulsing = true; - - pulse_led_deferred(); -} - -static void update_charger_led(enum pwm_led_id id) -{ - enum charge_state chg_st = charge_get_state(); - - /* - * The colors listed below are the default, but can be overridden. - * - * Fast Flash = Charging error - * Slow Flash = Discharging - * LED on = Charging - * LED off = No Charger connected - */ - if (chg_st == PWR_STATE_CHARGE || - chg_st == PWR_STATE_CHARGE_NEAR_FULL) { - /* Charging: LED ON */ - rvp_led[id].led_is_pulsing = false; - set_pwm_led_color(id, EC_LED_COLOR_GREEN); - } else if (chg_st == PWR_STATE_DISCHARGE || - chg_st == PWR_STATE_DISCHARGE_FULL) { - if (extpower_is_present()) { - /* Discharging: - * Flash slower (2 second period, 100% duty cycle) - */ - pulse_leds(id, LED_SLOW_PULSE_PERIOD); - } else { - /* No Charger connected: LED OFF */ - rvp_led[id].led_is_pulsing = false; - set_pwm_led_color(id, LED_OFF); - } - } else if (chg_st == PWR_STATE_ERROR) { - /* Charging error: - * Flash faster (250 ms period, 100% duty cycle) - */ - pulse_leds(id, LED_FAST_PULSE_PERIOD); - } else { - /* LED OFF */ - rvp_led[id].led_is_pulsing = false; - set_pwm_led_color(id, LED_OFF); - } -} - -static void update_battery_led(enum pwm_led_id id) -{ - /* - * Fast Flash = Low Battery - * Slow Flash = Normal Battery - * LED on = Full Battery - * LED off = No Battery - */ - if (battery_is_present() == BP_YES) { - int batt_percentage = charge_get_percent(); - - if (batt_percentage < LOW_BATTERY_PERCENTAGE) { - /* Low Battery: - * Flash faster (250 ms period, 100% duty cycle) - */ - pulse_leds(id, LED_FAST_PULSE_PERIOD); - } else if (batt_percentage < NORMAL_BATTERY_PERCENTAGE) { - /* Normal Battery: - * Flash slower (2 second period, 100% duty cycle) - */ - pulse_leds(id, LED_SLOW_PULSE_PERIOD); - } else { - /* Full Battery: LED ON */ - rvp_led[id].led_is_pulsing = false; - set_pwm_led_color(id, EC_LED_COLOR_GREEN); - } - } else { - /* No Battery: LED OFF */ - rvp_led[id].led_is_pulsing = false; - set_pwm_led_color(id, LED_OFF); - } -} - -static void init_rvp_leds_off(void) -{ - /* Turn off LEDs such that they are in a known state with zero duty. */ - set_pwm_led_color(PWM_LED0, LED_OFF); - set_pwm_led_color(PWM_LED1, LED_OFF); -} -DECLARE_HOOK(HOOK_INIT, init_rvp_leds_off, HOOK_PRIO_POST_PWM); - -static void update_led(void) -{ - update_battery_led(PWM_LED0); - update_charger_led(PWM_LED1); -} -DECLARE_HOOK(HOOK_SECOND, update_led, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/intelrvp/src/intelrvp.c b/zephyr/projects/intelrvp/src/intelrvp.c deleted file mode 100644 index 7098f26cbf..0000000000 --- a/zephyr/projects/intelrvp/src/intelrvp.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* TODO: b/218904113: Convert to using Zephyr GPIOs */ -#include "gpio.h" -#include "hooks.h" - -static void board_init(void) -{ - /* Enable SOC SPI */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_spi_oe_mecc), 1); -} -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_LAST); - -__override void intel_x86_sys_reset_delay(void) -{ - /* - * From MAX6818 Data sheet, Range of 'Debounce Duaration' is - * Minimum - 20 ms, Typical - 40 ms, Maximum - 80 ms. - * See b/153128296. - */ - udelay(60 * MSEC); -} diff --git a/zephyr/projects/intelrvp/src/usb_pd_policy_mecc_1_1.c b/zephyr/projects/intelrvp/src/usb_pd_policy_mecc_1_1.c deleted file mode 100644 index a194b358f1..0000000000 --- a/zephyr/projects/intelrvp/src/usb_pd_policy_mecc_1_1.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "console.h" -#include "gpio.h" -#include "intelrvp.h" -#include "usb_mux.h" -#include "usbc_ppc.h" - -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) - -static inline void board_pd_set_vbus_discharge(int port, bool enable) -{ - if (tcpc_aic_gpios[port].ppc_intr_handler) { - ppc_discharge_vbus(port, enable); - } else { - tcpc_discharge_vbus(port, enable); - } -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - /* Disable charging. */ - if (tcpc_aic_gpios[port].ppc_intr_handler) { - rv = ppc_vbus_sink_enable(port, 0); - } else { - rv = tcpc_config[port].drv->set_snk_ctrl(port, 0); - } - - if (rv) { - return rv; - } - - board_pd_set_vbus_discharge(port, false); - - /* Provide Vbus. */ - if (tcpc_aic_gpios[port].ppc_intr_handler) { - rv = ppc_vbus_source_enable(port, 1); - } else { - tcpc_config[port].drv->set_src_ctrl(port, 1); - } - - if (rv) { - return rv; - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -void pd_power_supply_reset(int port) -{ - int prev_en; - - prev_en = board_vbus_source_enabled(port); - - /* Disable VBUS. */ - if (tcpc_aic_gpios[port].ppc_intr_handler) { - ppc_vbus_source_enable(port, 0); - } else { - tcpc_config[port].drv->set_src_ctrl(port, 0); - } - - /* Enable discharge if we were previously sourcing 5V */ - if (prev_en) { - board_pd_set_vbus_discharge(port, true); - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_check_vconn_swap(int port) -{ - /* Only allow vconn swap if PP3300 rail is enabled */ - return gpio_get_level(GPIO_EN_PP3300_A); -} - -int pd_snk_is_vbus_provided(int port) -{ - if (tcpc_aic_gpios[port].ppc_intr_handler) { - return ppc_is_vbus_present(port); - } else { - return tcpc_config[port].drv->check_vbus_level(port, - VBUS_PRESENT); - } -} - -int board_vbus_source_enabled(int port) -{ - if (is_typec_port(port)) { - if (tcpc_aic_gpios[port].ppc_intr_handler) { - return ppc_is_sourcing_vbus(port); - } else { - return tcpc_config[port].drv->get_src_ctrl(port); - } - } - return 0; -} diff --git a/zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf b/zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf deleted file mode 100644 index 1ef365a8fa..0000000000 --- a/zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Zephyr Inbuilt AP Power Sequencing Config -CONFIG_AP_PWRSEQ=y -CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y -CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y -CONFIG_AP_PWRSEQ_S0IX=y diff --git a/zephyr/projects/it8xxx2_evb/BUILD.py b/zephyr/projects/it8xxx2_evb/BUILD.py deleted file mode 100644 index ee89c75390..0000000000 --- a/zephyr/projects/it8xxx2_evb/BUILD.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for it8xxx2_evb.""" - -register_raw_project( - project_name="it8xxx2_evb", - zephyr_board="it81302bx", - dts_overlays=[ - "adc.dts", - "fan.dts", - "gpio.dts", - "i2c.dts", - "interrupts.dts", - "pwm.dts", - ], -) diff --git a/zephyr/projects/it8xxx2_evb/CMakeLists.txt b/zephyr/projects/it8xxx2_evb/CMakeLists.txt deleted file mode 100644 index 170606a52d..0000000000 --- a/zephyr/projects/it8xxx2_evb/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(it8xxx2_evb) - -# Include board specific header files -zephyr_include_directories(include) diff --git a/zephyr/projects/it8xxx2_evb/adc.dts b/zephyr/projects/it8xxx2_evb/adc.dts deleted file mode 100644 index 509c9b9daf..0000000000 --- a/zephyr/projects/it8xxx2_evb/adc.dts +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_vbussa: vbussa { - enum-name = "ADC_VBUS"; - io-channels = <&adc0 0>; - }; - adc_vbussb: vbussb { - enum-name = "ADC_PSYS"; - io-channels = <&adc0 1>; - }; - adc_evb_ch_13: evb_ch_13 { - enum-name = "ADC_AMON_BMON"; - io-channels = <&adc0 2>; - }; - adc_evb_ch_14: evb_ch_14 { - enum-name = "ADC_TEMP_SENSOR_FAN"; - io-channels = <&adc0 3>; - }; - adc_evb_ch_15: evb_ch_15 { - enum-name = "ADC_TEMP_SENSOR_DDR_SOC"; - io-channels = <&adc0 4>; - }; - adc_evb_ch_16: evb_ch_16 { - enum-name = "ADC_TEMP_SENSOR_CHARGER"; - io-channels = <&adc0 5>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_ch3_gpi3_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/it8xxx2_evb/fan.dts b/zephyr/projects/it8xxx2_evb/fan.dts deleted file mode 100644 index 2551507ec3..0000000000 --- a/zephyr/projects/it8xxx2_evb/fan.dts +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm7 PWM_CHANNEL_7 PWM_KHZ(30) PWM_POLARITY_NORMAL>; - tach = <&tach0>; - rpm_min = <1500>; - rpm_start = <1500>; - rpm_max = <6500>; - }; - }; -}; - -/* fan tachometer sensor */ -&tach0 { - status = "okay"; - channel = ; - pulses-per-round = <2>; - pinctrl-0 = <&tach0a_gpd6_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/it8xxx2_evb/gpio.dts b/zephyr/projects/it8xxx2_evb/gpio.dts deleted file mode 100644 index 85bb45d7a0..0000000000 --- a/zephyr/projects/it8xxx2_evb/gpio.dts +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-wp = &gpio_wp; - }; - - named-gpios { - compatible = "named-gpios"; - - power_button_l: power_button_l { - gpios = <&gpioe 4 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - lid_open: lid_open { - gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_wp: wp_l { - gpios = <&gpioi 4 (GPIO_INPUT_PULL_UP | - GPIO_ACTIVE_LOW)>; - }; - pch_pltrst_l { - gpios = <&gpioe 3 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_PCH_RSMRST_L"; - }; - sys_reset_l { - gpios = <&gpiob 6 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_SYS_RESET_L"; - }; - gpio_ec_pch_wake_odl: pch_wake_l { - gpios = <&gpiob 7 GPIO_OUTPUT_HIGH>; - }; - spi0_cs: spi0_cs { - gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = <&int_power_button - &int_lid_open>; - }; - - unused-pins { - compatible = "unused-gpios"; - - unused-gpios = - /* gpioa1 */ - <&gpioa 1 GPIO_INPUT_PULL_DOWN>, - /* gpioa2 */ - <&gpioa 2 GPIO_INPUT_PULL_DOWN>, - /* gpioa3 */ - <&gpioa 3 GPIO_INPUT_PULL_DOWN>, - /* gpioa4 */ - <&gpioa 4 GPIO_INPUT_PULL_DOWN>, - /* gpioa5 */ - <&gpioa 5 GPIO_INPUT_PULL_DOWN>, - - /* gpiob2 */ - <&gpiob 2 GPIO_INPUT_PULL_DOWN>, - /* gpiob5 */ - <&gpiob 5 GPIO_INPUT_PULL_DOWN>, - - /* gpioc0 */ - <&gpioc 0 GPIO_INPUT_PULL_DOWN>, - /* gpioc4 */ - <&gpioc 4 GPIO_INPUT_PULL_DOWN>, - /* gpioc6 */ - <&gpioc 6 GPIO_INPUT_PULL_DOWN>, - /* gpioc7 */ - <&gpioc 7 GPIO_INPUT_PULL_DOWN>, - - /* gpiod0 */ - <&gpiod 0 GPIO_INPUT_PULL_DOWN>, - /* gpiod1 */ - <&gpiod 1 GPIO_INPUT_PULL_DOWN>, - /* gpiod2 */ - <&gpiod 2 GPIO_INPUT_PULL_DOWN>, - /* gpiod3 */ - <&gpiod 3 GPIO_INPUT_PULL_DOWN>, - /* gpiod4 */ - <&gpiod 4 GPIO_INPUT_PULL_DOWN>, - /* gpiod5 */ - <&gpiod 5 GPIO_INPUT_PULL_DOWN>, - /* gpiod7 */ - <&gpiod 7 GPIO_INPUT_PULL_DOWN>, - - /* gpioe1 */ - <&gpioe 1 GPIO_INPUT_PULL_DOWN>, - /* gpioe5 */ - <&gpioe 5 GPIO_INPUT_PULL_DOWN>, - /* gpioe6 */ - <&gpioe 6 GPIO_INPUT_PULL_DOWN>, - - /* gpiof0 */ - <&gpiof 0 GPIO_INPUT_PULL_DOWN>, - /* gpiof1 */ - <&gpiof 1 GPIO_INPUT_PULL_DOWN>, - /* gpiof2 */ - <&gpiof 2 GPIO_INPUT_PULL_DOWN>, - /* gpiof3 */ - <&gpiof 3 GPIO_INPUT_PULL_DOWN>, - /* gpiof4 */ - <&gpiof 4 GPIO_INPUT_PULL_DOWN>, - /* gpiof5 */ - <&gpiof 5 GPIO_INPUT_PULL_DOWN>, - - /* gpiog1 */ - <&gpiog 1 GPIO_INPUT_PULL_DOWN>, - /* gpiog6 */ - <&gpiog 6 GPIO_INPUT_PULL_UP>, - - /* gpioh0 */ - <&gpioh 0 GPIO_INPUT_PULL_DOWN>, - /* gpioh3 */ - <&gpioh 3 GPIO_INPUT_PULL_DOWN>, - /* gpioh4 */ - <&gpioh 4 GPIO_INPUT_PULL_DOWN>, - /* gpioh5 */ - <&gpioh 5 GPIO_INPUT_PULL_DOWN>, - /* gpioh6 */ - <&gpioh 6 GPIO_INPUT_PULL_DOWN>, - - /* gpioi6 */ - <&gpioi 6 GPIO_INPUT_PULL_DOWN>, - /* gpioi7 */ - <&gpioi 7 GPIO_INPUT_PULL_DOWN>, - - /* gpioj0 */ - <&gpioj 0 GPIO_INPUT_PULL_DOWN>, - /* gpioj1 */ - <&gpioj 1 GPIO_INPUT_PULL_DOWN>, - /* gpioj2 */ - <&gpioj 2 GPIO_INPUT_PULL_DOWN>, - /* gpioj3 */ - <&gpioj 3 GPIO_INPUT_PULL_DOWN>, - /* gpioj4 */ - <&gpioj 4 GPIO_INPUT_PULL_DOWN>, - /* gpioj5 */ - <&gpioj 5 GPIO_INPUT_PULL_DOWN>, - /* gpioj6 */ - <&gpioj 6 GPIO_OUTPUT_LOW>, - /* gpioj7 */ - <&gpioj 7 GPIO_OUTPUT_LOW>, - - /* gpiom0 */ - <&gpiom 0 GPIO_INPUT_PULL_DOWN>, - /* gpiom1 */ - <&gpiom 1 GPIO_INPUT_PULL_DOWN>, - /* gpiom2 */ - <&gpiom 2 GPIO_INPUT_PULL_DOWN>, - /* gpiom3 */ - <&gpiom 3 GPIO_INPUT_PULL_DOWN>, - /* gpiom4 */ - <&gpiom 4 GPIO_INPUT_PULL_DOWN>, - /* gpiom6 */ - <&gpiom 6 GPIO_INPUT_PULL_DOWN>; - }; -}; diff --git a/zephyr/projects/it8xxx2_evb/i2c.dts b/zephyr/projects/it8xxx2_evb/i2c.dts deleted file mode 100644 index c08c543e44..0000000000 --- a/zephyr/projects/it8xxx2_evb/i2c.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - named-i2c-ports { - compatible = "named-i2c-ports"; - - battery { - i2c-port = <&i2c2>; - enum-names = "I2C_PORT_BATTERY"; - }; - evb-1 { - i2c-port = <&i2c0>; - enum-names = "I2C_PORT_EVB_1"; - }; - evb-2 { - i2c-port = <&i2c1>; - enum-names = "I2C_PORT_EVB_2"; - }; - opt-4 { - i2c-port = <&i2c4>; - enum-names = "I2C_PORT_OPT_4"; - }; - }; -}; - -&i2c0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_clk_gpb3_default - &i2c0_data_gpb4_default>; - pinctrl-names = "default"; -}; - -&i2c1 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_clk_gpc1_default - &i2c1_data_gpc2_default>; - pinctrl-names = "default"; -}; - -&i2c2 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_clk_gpf6_default - &i2c2_data_gpf7_default>; - pinctrl-names = "default"; -}; - -&i2c4 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c4_clk_gpe0_default - &i2c4_data_gpe7_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/it8xxx2_evb/include/i2c_map.h b/zephyr/projects/it8xxx2_evb/include/i2c_map.h deleted file mode 100644 index e83a238d3a..0000000000 --- a/zephyr/projects/it8xxx2_evb/include/i2c_map.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __ZEPHYR_CHROME_I2C_MAP_H -#define __ZEPHYR_CHROME_I2C_MAP_H - -#include - -#include "config.h" - -/* We need registers.h to get the chip specific defines for now */ -#include "i2c/i2c.h" - -#endif /* __ZEPHYR_CHROME_I2C_MAP_H */ diff --git a/zephyr/projects/it8xxx2_evb/interrupts.dts b/zephyr/projects/it8xxx2_evb/interrupts.dts deleted file mode 100644 index 07fc0ed339..0000000000 --- a/zephyr/projects/it8xxx2_evb/interrupts.dts +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_spi0_cs: spi0_cs { - irq-pin = <&spi0_cs>; - flags = ; - handler = "spi_event"; - }; - }; -}; diff --git a/zephyr/projects/it8xxx2_evb/prj.conf b/zephyr/projects/it8xxx2_evb/prj.conf deleted file mode 100644 index d6d422e490..0000000000 --- a/zephyr/projects/it8xxx2_evb/prj.conf +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_SHIMMED_TASKS=y - -# SoC configuration -CONFIG_AP=y -CONFIG_AP_ARM_MTK_MT8192=y - -# Lid switch -CONFIG_PLATFORM_EC_LID_SWITCH=y - -# Logging -CONFIG_LOG=y - -# Fan -CONFIG_SENSOR=y - -# I2C -CONFIG_I2C=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# Power Button -CONFIG_PLATFORM_EC_POWER_BUTTON=y - -# TODO(b:185202623): bring these features up -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n -CONFIG_PLATFORM_EC_KEYBOARD=n -CONFIG_CROS_KB_RAW_ITE=n -CONFIG_PLATFORM_EC_SWITCH=n -CONFIG_PLATFORM_EC_VBOOT_EFS2=n -CONFIG_PLATFORM_EC_VBOOT_HASH=n - -# USB-C -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n diff --git a/zephyr/projects/it8xxx2_evb/pwm.dts b/zephyr/projects/it8xxx2_evb/pwm.dts deleted file mode 100644 index c566e5c029..0000000000 --- a/zephyr/projects/it8xxx2_evb/pwm.dts +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - - /* NOTE: &pwm number needs same with channel number */ - pwm_led_test: pwm_led_test { - pwms = <&pwm0 PWM_CHANNEL_0 PWM_MSEC(20) PWM_POLARITY_NORMAL>; - }; - }; -}; - -/* pwm for test */ -&pwm0 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm0_gpa0_default>; - pinctrl-names = "default"; -}; - -/* pwm for fan */ -&pwm7 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm7_gpa7_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/minimal/BUILD.py b/zephyr/projects/minimal/BUILD.py deleted file mode 100644 index 5e892aa2d7..0000000000 --- a/zephyr/projects/minimal/BUILD.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Minimal example project.""" - -register_host_project( - project_name="minimal-posix", - zephyr_board="native_posix", -) - -register_npcx_project( - project_name="minimal-npcx9", - zephyr_board="npcx9m3f", - dts_overlays=[here / "npcx9.dts"], -) - -register_binman_project( - project_name="minimal-it8xxx2", - zephyr_board="it81302bx", - dts_overlays=[here / "it8xxx2.dts"], -) diff --git a/zephyr/projects/minimal/CMakeLists.txt b/zephyr/projects/minimal/CMakeLists.txt deleted file mode 100644 index de3bec9428..0000000000 --- a/zephyr/projects/minimal/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.20.5) -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(ec) - -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") diff --git a/zephyr/projects/minimal/README.md b/zephyr/projects/minimal/README.md deleted file mode 100644 index 72c092dfce..0000000000 --- a/zephyr/projects/minimal/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Minimal Example Zephyr EC Project - -This directory is intended to be an extremely minimal example of a -project. Should you like, you can use it as a bring up a new program, -or as reference as you require. - -If you're bringing up a new variant of a program, you don't need a -whole project directory with a `BUILD.py` and all, and this example is -likely not of use to you. Check out the [project config -documentation] for instructions on adding a new variant. - -[project config documentation]: ../../../docs/zephyr/project_config.md - -# Building - -To build the `native_posix` example, run: - -``` shellsession -(chroot) $ zmake build minimal-posix -``` - -To build the NPCX9 example, run: - -``` shellsession -(chroot) $ zmake build minimal-npcx9 -``` - -For the IT8XXX2 example, run: - -``` shellsession -(chroot) $ zmake build minimal-it8xxx2 -``` diff --git a/zephyr/projects/minimal/it8xxx2.dts b/zephyr/projects/minimal/it8xxx2.dts deleted file mode 100644 index 3d2028afb2..0000000000 --- a/zephyr/projects/minimal/it8xxx2.dts +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &ec_wp_l; - }; - - named-gpios { - compatible = "named-gpios"; - - ec_wp_l: write-protect { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; -}; diff --git a/zephyr/projects/minimal/npcx9.dts b/zephyr/projects/minimal/npcx9.dts deleted file mode 100644 index 3a9f3b26e4..0000000000 --- a/zephyr/projects/minimal/npcx9.dts +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &ec_wp_l; - }; - - named-gpios { - compatible = "named-gpios"; - - ec_wp_l: write-protect { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; -}; - -&cros_kb_raw { - status = "okay"; - pinctrl-0 = <>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/minimal/prj.conf b/zephyr/projects/minimal/prj.conf deleted file mode 100644 index db7cac0cef..0000000000 --- a/zephyr/projects/minimal/prj.conf +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_PLATFORM_EC=y -CONFIG_CROS_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_SYSCON=y - -# Disable default features we don't want in a minimal example. -CONFIG_ADC=n -CONFIG_I2C=n -CONFIG_PWM=n -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -CONFIG_PLATFORM_EC_KEYBOARD=n -CONFIG_PLATFORM_EC_POWER_BUTTON=n -CONFIG_PLATFORM_EC_SWITCH=n -CONFIG_PLATFORM_EC_VBOOT_EFS2=n diff --git a/zephyr/projects/nissa/BUILD.py b/zephyr/projects/nissa/BUILD.py deleted file mode 100644 index b1affe7b4c..0000000000 --- a/zephyr/projects/nissa/BUILD.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for nissa.""" - -# Nivviks and Craask, Pujjo, Xivu has NPCX993F, Nereid and Joxer, Yaviks has ITE81302 - - -def register_nissa_project( - project_name, - chip="it81302bx", -): - """Register a variant of nissa.""" - register_func = register_binman_project - if chip.startswith("npcx"): - register_func = register_npcx_project - - chip_kconfig = {"it81302bx": "it8xxx2", "npcx9m3f": "npcx"}[chip] - - return register_func( - project_name=project_name, - zephyr_board=chip, - dts_overlays=[here / project_name / "project.overlay"], - kconfig_files=[ - here / "program.conf", - here / f"{chip_kconfig}_program.conf", - here / project_name / "project.conf", - ], - ) - - -nivviks = register_nissa_project( - project_name="nivviks", - chip="npcx9m3f", -) - -nereid = register_nissa_project( - project_name="nereid", - chip="it81302bx", -) - -craask = register_nissa_project( - project_name="craask", - chip="npcx9m3f", -) - -pujjo = register_nissa_project( - project_name="pujjo", - chip="npcx9m3f", -) - -xivu = register_nissa_project( - project_name="xivu", - chip="npcx9m3f", -) - -joxer = register_nissa_project( - project_name="joxer", - chip="it81302bx", -) - -yaviks = register_nissa_project( - project_name="yaviks", - chip="it81302bx", -) diff --git a/zephyr/projects/nissa/CMakeLists.txt b/zephyr/projects/nissa/CMakeLists.txt deleted file mode 100644 index 8769af58ba..0000000000 --- a/zephyr/projects/nissa/CMakeLists.txt +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") - -zephyr_include_directories(include) -zephyr_library_sources("src/common.c") -zephyr_library_sources("src/sub_board.c") -zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ "src/board_power.c") - -if(DEFINED CONFIG_BOARD_NIVVIKS) - project(nivviks) - zephyr_library_sources( - "nivviks/src/led.c" - "nivviks/src/form_factor.c" - "nivviks/src/keyboard.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "nivviks/src/fan.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "nivviks/src/usbc.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "nivviks/src/charger.c") -endif() -if(DEFINED CONFIG_BOARD_NEREID) - project(nereid) - zephyr_library_sources( - "src/led.c" - "nereid/src/keyboard.c" - "nereid/src/hdmi.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "nereid/src/usbc.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "nereid/src/charger.c") -endif() -if(DEFINED CONFIG_BOARD_CRAASK) - zephyr_library_sources( - "craask/src/form_factor.c" - "craask/src/keyboard.c" - "craask/src/led.c" - ) - project(craask) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "craask/src/usbc.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "craask/src/charger.c") -endif() -if(DEFINED CONFIG_BOARD_PUJJO) - project(pujjo) - zephyr_library_sources( - "pujjo/src/led.c" - "pujjo/src/keyboard.c" - "pujjo/src/hdmi.c" - "pujjo/src/form_factor.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "pujjo/src/fan.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "pujjo/src/usbc.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "pujjo/src/charger.c") -endif() -if(DEFINED CONFIG_BOARD_XIVU) - project(xivu) - zephyr_library_sources( - "xivu/src/keyboard.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "xivu/src/usbc.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "xivu/src/charger.c") -endif() -if(DEFINED CONFIG_BOARD_JOXER) - project(joxer) - zephyr_library_sources( - "joxer/src/led.c" - "joxer/src/keyboard.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "joxer/src/usbc.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "joxer/src/charger.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "joxer/src/fan.c") -endif() -if(DEFINED CONFIG_BOARD_YAVIKS) - project(yaviks) - zephyr_library_sources( - "yaviks/src/led.c" - "yaviks/src/keyboard.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "yaviks/src/usbc.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "yaviks/src/charger.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "yaviks/src/fan.c") -endif() \ No newline at end of file diff --git a/zephyr/projects/nissa/Kconfig b/zephyr/projects/nissa/Kconfig deleted file mode 100644 index 9e9ffc2528..0000000000 --- a/zephyr/projects/nissa/Kconfig +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -config BOARD_NIVVIKS - bool "Google Nivviks Board" - help - Build Google Nivviks reference board. Nivviks has Intel ADL-N SoC - with NPCX993FA0BX EC. - -config BOARD_NEREID - bool "Google Nereid Board" - help - Build Google Nereid reference board. Nereid has Intel ADL-N SoC - with IT81302 EC. - -config BOARD_CRAASK - bool "Google Craask Board" - help - Build Google Craask board. Craask has Intel ADL-N SoC - with NPCX993FA0BX EC. - -config BOARD_PUJJO - bool "Google Pujjo Board" - help - Build Google Pujjo board. Pujjo has Intel ADL-N SoC - with NPCX993FA0BX EC. - -config BOARD_XIVU - bool "Google Xivu Board" - help - Build Google Xivu board. Xivu has Intel ADL-N SoC - with NPCX993FA0BX EC. - -config BOARD_JOXER - bool "Google Joxer Board" - help - Build Google Joxer reference board. Joxer has Intel ADL-N SoC - with IT81302 EC. - -config BOARD_YAVIKS - bool "Google Yaviks Board" - help - Build Google Yaviks board. Yaviks has Intel ADL-N SoC - with IT81302 EC. - - -module = NISSA -module-str = Nissa board-specific code -source "subsys/logging/Kconfig.template.log_config" - -source "Kconfig.zephyr" diff --git a/zephyr/projects/nissa/cbi.dtsi b/zephyr/projects/nissa/cbi.dtsi deleted file mode 100644 index d841be1624..0000000000 --- a/zephyr/projects/nissa/cbi.dtsi +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - nissa-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - /* - * FW_CONFIG field to indicate which sub-board - * is attached. - */ - sub-board { - enum-name = "FW_SUB_BOARD"; - start = <0>; - size = <2>; - - sub-board-1 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_SUB_BOARD_1"; - value = <1>; - }; - sub-board-2 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_SUB_BOARD_2"; - value = <2>; - }; - sub-board-3 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_SUB_BOARD_3"; - value = <3>; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <2>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - }; -}; diff --git a/zephyr/projects/nissa/craask/cbi.dtsi b/zephyr/projects/nissa/craask/cbi.dtsi deleted file mode 100644 index 4c2e052f4d..0000000000 --- a/zephyr/projects/nissa/craask/cbi.dtsi +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* Craask-specific fw_config fields. */ - nissa-fw-config { - /* - * FW_CONFIG field to describe Lid sensor orientation. - */ - lid-inversion { - enum-name = "FW_LID_INVERSION"; - start = <8>; - size = <1>; - - /* - * 0: regular placement of the lid sensor - * 1: rotate 180' of xy plane. - */ - regular { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_LID_REGULAR"; - value = <0>; - default; - }; - xy_rotate_180 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_LID_XY_ROT_180"; - value = <1>; - }; - }; - /* - * FW_CONFIG field to describe Clamshell/Convertible. - */ - form_factor { - enum-name = "FORM_FACTOR"; - start = <9>; - size = <1>; - - /* - * 0: convertible, 1: clamshell - */ - convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "CONVERTIBLE"; - value = <0>; - }; - clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "CLAMSHELL"; - value = <1>; - }; - }; - }; - /* Craask-specific ssfc fields. */ - cbi-ssfc { - compatible = "named-cbi-ssfc"; - /* - * SSFC bit0-1 was defined for AUDIO CODEC. - * 0: ALC5682I_VS - * 1: NAU8825 - */ - audio_codec { - enum-name = "AUDIO_CODEC"; - size = <2>; - }; - /* - * SSFC field to identify LID motion sensor. - */ - lid-sensor { - enum-name = "LID_SENSOR"; - size = <2>; - - lid_sensor_0: lis2dw12 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <0>; - default; - }; - lid_sensor_1: bma422 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <1>; - }; - }; - /* - * SSFC field to identify BASE motion sensor. - */ - base-sensor { - enum-name = "BASE_SENSOR"; - size = <2>; - - base_sensor_0: lsm6dso { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <0>; - default; - }; - base_sensor_1: bmi323 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <1>; - }; - }; - }; -}; diff --git a/zephyr/projects/nissa/craask/generated.dtsi b/zephyr/projects/nissa/craask/generated.dtsi deleted file mode 100644 index 4303bbd4c5..0000000000 --- a/zephyr/projects/nissa/craask/generated.dtsi +++ /dev/null @@ -1,288 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { - enum-name = "ADC_PP1050_PROC"; - io-channels = <&adc0 4>; - }; - adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { - enum-name = "ADC_PP3300_S5"; - io-channels = <&adc0 6>; - }; - adc_temp_sensor_1: temp_sensor_1 { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 0>; - }; - adc_temp_sensor_2: temp_sensor_2 { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 1>; - }; - adc_temp_sensor_3: temp_sensor_3 { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 10>; - }; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_acc_int_l: acc_int_l { - gpios = <&gpio5 0 GPIO_INPUT>; - }; - gpio_all_sys_pwrgd: all_sys_pwrgd { - gpios = <&gpioa 7 GPIO_INPUT>; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_cpu_c10_gate_l: cpu_c10_gate_l { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_ec_battery_pres_odl: ec_battery_pres_odl { - gpios = <&gpioa 3 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio7 4 GPIO_OUTPUT>; - }; - gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { - gpios = <&gpiod 3 GPIO_ODR_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_entering_rw: ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { - gpios = <&gpio7 5 GPIO_OUTPUT>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_ec_pch_wake_odl: ec_pch_wake_odl { - gpios = <&gpiob 0 GPIO_ODR_LOW>; - }; - gpio_ec_prochot_odl: ec_prochot_odl { - gpios = <&gpiof 1 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { - gpios = <&gpio6 1 GPIO_OUTPUT>; - }; - gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { - gpios = <&gpioe 4 GPIO_OUTPUT>; - }; - gpio_ec_soc_int_odl: ec_soc_int_odl { - gpios = <&gpio8 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { - gpios = <&gpio7 2 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { - gpios = <&gpioc 1 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioa 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_rtcrst: ec_soc_rtcrst { - gpios = <&gpio7 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { - gpios = <&gpio3 7 GPIO_OUTPUT>; - }; - gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { - gpios = <&gpioa 4 GPIO_ODR_HIGH>; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_en_kb_bl: en_kb_bl { - gpios = <&gpioa 0 GPIO_OUTPUT>; - enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; - }; - gpio_en_pp3300_s5: en_pp3300_s5 { - gpios = <&gpiob 6 GPIO_OUTPUT>; - enum-name = "GPIO_TEMP_SENSOR_POWER"; - }; - gpio_en_pp5000_pen_x: en_pp5000_pen_x { - gpios = <&gpioe 2 GPIO_OUTPUT>; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio4 0 GPIO_OUTPUT>; - }; - gpio_en_slp_z: en_slp_z { - gpios = <&gpioe 1 GPIO_OUTPUT>; - }; - gpio_en_usb_a0_vbus: en_usb_a0_vbus { - gpios = <&gpio9 1 GPIO_OUTPUT>; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_hdmi_sel: hdmi_sel { - gpios = <&gpioc 6 GPIO_OUTPUT>; - }; - gpio_imu_int_l: imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { - gpios = <&gpio4 3 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_pen_detect_odl: pen_detect_odl { - gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { - gpios = <&gpio4 2 GPIO_INPUT>; - }; - gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { - gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; - }; - gpio_slp_s0_l: slp_s0_l { - gpios = <&gpio9 7 GPIO_INPUT>; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpioa 5 GPIO_INPUT>; - }; - gpio_slp_s4_l: slp_s4_l { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_slp_sus_l: slp_sus_l { - gpios = <&gpio6 2 GPIO_INPUT>; - }; - gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { - gpios = <&gpiod 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB2_ILIM_SEL"; - }; - gpio_sys_rst_odl: sys_rst_odl { - gpios = <&gpioc 5 GPIO_ODR_HIGH>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpio9 5 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { - gpios = <&gpio8 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB1_ILIM_SEL"; - }; - gpio_usb_c0_int_odl: usb_c0_int_odl { - gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; - }; - gpio_vccin_aux_vid0: vccin_aux_vid0 { - gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_vccin_aux_vid1: vccin_aux_vid1 { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_ec_i2c_eeprom: ec_i2c_eeprom { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_ec_i2c_sensor: ec_i2c_sensor { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_C0_TCPC"; - }; - i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { - i2c-port = <&i2c5_1>; - enum-names = "I2C_PORT_USB_C1_TCPC"; - }; - i2c_ec_i2c_batt: ec_i2c_batt { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_BATTERY"; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan0_gp45 - &adc0_chan1_gp44 - &adc0_chan4_gp41 - &adc0_chan6_gp34 - &adc0_chan10_gpe0>; - pinctrl-names = "default"; -}; - -&i2c0_0 { - status = "okay"; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; -}; - -&i2c1_0 { - status = "okay"; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; -}; - -&i2c3_0 { - status = "okay"; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; -}; - -&i2c5_1 { - status = "okay"; - pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>; - pinctrl-names = "default"; -}; - -&i2c7_0 { - status = "okay"; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/nissa/craask/keyboard.dtsi b/zephyr/projects/nissa/craask/keyboard.dtsi deleted file mode 100644 index f9e46de1f2..0000000000 --- a/zephyr/projects/nissa/craask/keyboard.dtsi +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/craask/motionsense.dtsi b/zephyr/projects/nissa/craask/motionsense.dtsi deleted file mode 100644 index 448aed6991..0000000000 --- a/zephyr/projects/nissa/craask/motionsense.dtsi +++ /dev/null @@ -1,257 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * Interrupt bindings for sensor devices. - */ - lsm6dso-int = &base_accel; - lis2dw12-int = &lid_accel; - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lis2dw12-mutex { - }; - - lid_mutex_bma422: bma422-mutex { - }; - - base_mutex: base-mutex { - }; - - base_mutex_bmi323: bmi323-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <(-1) 0 0 - 0 1 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - - base_rot_ver1: base-rotation-ver1 { - mat33 = <(-1) 0 0 - 0 (-1) 0 - 0 0 1>; - }; - - lid_rot_bma422: lid-rotation-bma { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - - base_rot_bmi323: base-rotation-bmi323 { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - lsm6dso_accel_data: lsm6dso-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - lsm6dso_gyro_data: lsm6dso-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - - bma422_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi323_data: bmi323-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - * TODO(b/238139272): The first entries of the array must be - * accelerometers,then gyroscope. Fix this dependency in the DTS - * processing which makes the devicetree entries independent. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,lsm6dso-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&lsm6dso_accel_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,lsm6dso-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ - drv-data = <&lsm6dso_gyro_data>; - }; - }; - - motionsense-sensor-alt { - alt_lid_accel: alt-lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex_bma422>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_bma422>; - default-range = <2>; - drv-data = <&bma422_data>; - i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; - alternate-for = <&lid_accel>; - alternate-ssfc-indicator = <&lid_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_accel: alt-base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_bmi323>; - drv-data = <&bmi323_data>; - alternate-for = <&base_accel>; - alternate-ssfc-indicator = <&base_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_bmi323>; - drv-data = <&bmi323_data>; - alternate-for = <&base_gyro>; - alternate-ssfc-indicator = <&base_sensor_1>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/nissa/craask/overlay.dtsi b/zephyr/projects/nissa/craask/overlay.dtsi deleted file mode 100644 index 257dc299e3..0000000000 --- a/zephyr/projects/nissa/craask/overlay.dtsi +++ /dev/null @@ -1,349 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_odl; - int-wp = &int_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - ec-console { - compatible = "ec-console"; - disabled = "events", "lpc", "hostcmd"; - }; - - batteries { - default_battery: lgc { - compatible = "lgc,ap18c8k", "battery-smart"; - }; - cosmx { - compatible = "cosmx,ap20cbl", "battery-smart"; - }; - cosmx-2 { - compatible = "cosmx,ap20cbl-2", "battery-smart"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_power_button - &int_lid_open - >; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_imu: ec_imu { - irq-pin = <&gpio_imu_int_l>; - flags = ; - handler = "motion_interrupt"; - }; - int_vol_down: vol_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_vol_up: vol_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_usb_c0: usb_c0 { - irq-pin = <&gpio_usb_c0_int_odl>; - flags = ; - handler = "usb_interrupt"; - }; - int_usb_c1: usb_c1 { - irq-pin = <&gpio_sb_1>; - flags = ; - handler = "usb_interrupt"; - }; - }; - - named-gpios { - gpio_sb_1: sb-1 { - gpios = <&gpio0 2 GPIO_PULL_UP>; - no-auto-init; - }; - - gpio_sb_2: sb-2 { - gpios = <&gpiod 4 GPIO_OUTPUT>; - no-auto-init; - }; - - /* - * Set I2C pins for type C sub-board to be low voltage (I2C5_1). - * We do this for all boards, since the pins are 3.3V tolerant, - * and the only 2 types of sub-boards used on nivviks both have - * type-C ports on them. - */ - gpio_sb_3: sb-3 { - gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; - no-auto-init; - }; - gpio_sb_4: sb-4 { - gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - no-auto-init; - }; - ec-i2c-sensor-scl { - gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - }; - - /* - * Aliases used for sub-board GPIOs. - */ - aliases { - /* - * Input GPIO when used with type-C port 1 - * Output when used with HDMI sub-board - */ - gpio-usb-c1-int-odl = &gpio_sb_1; - gpio-en-rails-odl = &gpio_sb_1; - /* - * Sub-board with type A USB, enable. - */ - gpio-en-usb-a1-vbus = &gpio_sb_2; - /* - * HPD pins for HDMI sub-board. - */ - gpio-hdmi-en-odl = &gpio_sb_3; - gpio-hpd-odl = &gpio_sb_4; - /* - * Enable S5 rails for LTE sub-board - */ - gpio-en-sub-s5-rails = &gpio_sb_2; - }; - - temp_memory: memory { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_1>; - }; - temp_charger: charger { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_2>; - }; - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_3>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - memory { - temp_host_high = <75>; - temp_host_halt = <85>; - temp_host_release_high = <70>; - temp_host_release_halt = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_memory>; - }; - charger { - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_charger>; - }; - ambient { - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_ambient>; - }; - }; - - usba { - compatible = "cros-ec,usba-port-enable-pins"; - /* - * sb_2 is only configured as GPIO when USB-A1 is present, - * but it's still safe to control when disabled. - * - * ILIM_SEL pins are referred to by legacy enum name, - * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on - * sub-boards that don't have USB-A so is safe to control - * regardless of system configuration. - */ - enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; - status = "okay"; - }; - - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - chg = <&chg_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - /* - * TODO(b:211693800): port1 may not be present on some - * sub-boards. - */ - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - chg = <&chg_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; - }; - usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; - - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>; - }; -}; - -&thermistor_3V3_51K1_47K_4050B { - status = "okay"; -}; - -&adc_ec_vsense_pp3300_s5 { - /* - * Voltage divider on input has 47k upper and 220k lower legs with - * 2714 mV full-scale reading on the ADC. Apply the largest possible - * multiplier (without overflowing int32) to get the best possible - * approximation of the actual ratio, but derate by a factor of two to - * ensure unexpectedly high values won't overflow. - */ - mul = <(791261 / 2)>; - div = <(651975 / 2)>; -}; - -/* Set bus speeds for I2C */ -&i2c0_0 { - label = "I2C_EEPROM"; - clock-frequency = ; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c1_0 { - label = "I2C_SENSOR"; - clock-frequency = ; -}; - -&i2c3_0 { - label = "I2C_USB_C0_TCPC"; - clock-frequency = ; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - /* - * BC1.2 interrupt is shared with TCPC, so - * IRQ is not specified here and handled by - * usb_c0_interrupt. - */ - }; - - chg_port0: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&i2c5_1 { - label = "I2C_SUB_C1_TCPC"; - clock-frequency = ; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port1: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; - - anx7483_mux_1: anx7483-mux-1@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "anx7483_set_default_tuning"; - }; -}; - -&i2c7_0 { - label = "I2C_BATTERY"; - clock-frequency = ; -}; - -&pwm6 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm6_gpc0>; - pinctrl-names = "default"; -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/craask/power_signals.dtsi b/zephyr/projects/nissa/craask/power_signals.dtsi deleted file mode 100644 index 1d2b23069d..0000000000 --- a/zephyr/projects/nissa/craask/power_signals.dtsi +++ /dev/null @@ -1,220 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <10>; - all-sys-pwrgd-timeout = <20>; - }; - - pwr-en-pp5000-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP5000_S5 enable output to regulator"; - enum-name = "PWR_EN_PP5000_A"; - gpios = <&gpio4 0 0>; - output; - }; - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpiob 6 0>; - output; - }; - pwr-pg-ec-rsmrst-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpio9 4 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioa 6 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-sus-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_SUS_L input from PCH"; - enum-name = "PWR_SLP_SUS"; - gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-ec-soc-dsw-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "DSW_PWROK output to PCH"; - enum-name = "PWR_EC_SOC_DSW_PWROK"; - gpios = <&gpio6 1 0>; - output; - }; - pwr-vccst-pwrgd-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VCCST_PWRGD output to PCH"; - enum-name = "PWR_VCCST_PWRGD"; - gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; - output; - }; - pwr-imvp9-vrrdy-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VRRDY input from IMVP9"; - enum-name = "PWR_IMVP9_VRRDY"; - gpios = <&gpio4 3 0>; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpio3 7 0>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - compatible = "intel,ap-pwrseq-external"; - dbg-label = "Combined all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - }; - pwr-adc-pp3300 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP3300 PWROK (from ADC)"; - enum-name = "PWR_DSW_PWROK"; - trigger-high = <&cmp_pp3300_s5_high>; - trigger-low = <&cmp_pp3300_s5_low>; - }; - pwr-adc-pp1p05 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP1P05 PWROK (from ADC)"; - enum-name = "PWR_PG_PP1P05"; - trigger-high = <&cmp_pp1p05_high>; - trigger-low = <&cmp_pp1p05_low>; - }; - - adc-cmp { - cmp_pp3300_s5_high: pp3300_high { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 6>; - comparison = "ADC_CMP_NPCX_GREATER"; - /* - * This is 90% of nominal voltage considering voltage - * divider on ADC input. - */ - threshold-mv = <2448>; - }; - cmp_pp3300_s5_low: pp3300_low { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 6>; - comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; - threshold-mv = <2448>; - }; - cmp_pp1p05_high: pp1p05_high { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 4>; - comparison = "ADC_CMP_NPCX_GREATER"; - /* Setting at 90% of nominal voltage */ - threshold-mv = <945>; - }; - cmp_pp1p05_low: pp1p05_low { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 4>; - comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; - threshold-mv = <945>; - }; - }; -}; - -/* - * Because the power signals directly reference the GPIOs, - * the correspinding named-gpios need to have no-auto-init set. - */ -&gpio_ec_soc_dsw_pwrok { - no-auto-init; -}; -&gpio_ec_soc_pch_pwrok_od { - no-auto-init; -}; -&gpio_ec_soc_rsmrst_l { - no-auto-init; -}; -&gpio_ec_soc_sys_pwrok { - no-auto-init; -}; -&gpio_ec_soc_vccst_pwrgd_od { - no-auto-init; -}; -&gpio_en_pp3300_s5 { - no-auto-init; -}; -&gpio_en_pp5000_s5 { - no-auto-init; -}; -&gpio_imvp91_vrrdy_od { - no-auto-init; -}; -&gpio_rsmrst_pwrgd_l { - no-auto-init; -}; -&gpio_slp_s0_l { - no-auto-init; -}; -&gpio_slp_s3_l { - no-auto-init; -}; -&gpio_slp_s4_l { - no-auto-init; -}; -&gpio_slp_sus_l { - no-auto-init; -}; -&gpio_sys_rst_odl { - no-auto-init; -}; diff --git a/zephyr/projects/nissa/craask/project.conf b/zephyr/projects/nissa/craask/project.conf deleted file mode 100644 index b7f31cee63..0000000000 --- a/zephyr/projects/nissa/craask/project.conf +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_CRAASK=y -CONFIG_PLATFORM_EC_OCPC=y - -# Sensor drivers -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y - -CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y diff --git a/zephyr/projects/nissa/craask/project.overlay b/zephyr/projects/nissa/craask/project.overlay deleted file mode 100644 index 9ca681d979..0000000000 --- a/zephyr/projects/nissa/craask/project.overlay +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../cbi.dtsi" - -#include "cbi.dtsi" -#include "generated.dtsi" -#include "keyboard.dtsi" -#include "motionsense.dtsi" -#include "overlay.dtsi" -#include "power_signals.dtsi" -#include "pwm_leds.dtsi" diff --git a/zephyr/projects/nissa/craask/pwm_leds.dtsi b/zephyr/projects/nissa/craask/pwm_leds.dtsi deleted file mode 100644 index e55aa1c9ef..0000000000 --- a/zephyr/projects/nissa/craask/pwm_leds.dtsi +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm2 2 PWM_HZ(324) PWM_POLARITY_INVERTED>, - <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>, - <&pwm1 1 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0>; - - /**/ - color-map-red = <100 0 0>; - color-map-green = < 0 100 0>; - color-map-blue = < 0 0 100>; - color-map-yellow = < 0 50 50>; - color-map-white = <100 100 100>; - color-map-amber = < 90 10 0>; - - brightness-range = <100 100 100 0 0 0>; - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_BATTERY_LED"; - }; - }; -}; - -/* Enable LEDs to work while CPU suspended */ - -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/craask/src/charger.c b/zephyr/projects/nissa/craask/src/charger.c deleted file mode 100644 index d4723e4a0a..0000000000 --- a/zephyr/projects/nissa/craask/src/charger.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery.h" -#include "charger.h" -#include "charger/isl923x_public.h" -#include "console.h" -#include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -int extpower_is_present(void) -{ - int port; - int rv; - bool acok; - - for (port = 0; port < board_get_usb_pd_port_count(); port++) { - rv = raa489000_is_acok(port, &acok); - if ((rv == EC_SUCCESS) && acok) - return 1; - } - - return 0; -} - -/* - * Craask does not have a GPIO indicating whether extpower is present, - * so detect using the charger(s). - */ -__override void board_check_extpower(void) -{ - static int last_extpower_present; - int extpower_present = extpower_is_present(); - - if (last_extpower_present ^ extpower_present) - extpower_handle_update(extpower_present); - - last_extpower_present = extpower_present; -} - -__override void board_hibernate(void) -{ - /* Shut down the chargers */ - if (board_get_usb_pd_port_count() == 2) - raa489000_hibernate(CHARGER_SECONDARY, true); - raa489000_hibernate(CHARGER_PRIMARY, true); - LOG_INF("Charger(s) hibernated"); - cflush(); -} diff --git a/zephyr/projects/nissa/craask/src/form_factor.c b/zephyr/projects/nissa/craask/src/form_factor.c deleted file mode 100644 index 59869eaa2f..0000000000 --- a/zephyr/projects/nissa/craask/src/form_factor.c +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "accelgyro.h" -#include "button.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/accelgyro_bmi323.h" -#include "driver/accelgyro_lsm6dso.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "motionsense_sensors.h" -#include "motion_sense.h" -#include "tablet_mode.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -/* - * Mainboard orientation support. - */ - -#define LIS_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_bma422)) -#define BMA_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref)) -#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_ver1)) -#define LID_SENSOR SENSOR_ID(DT_NODELABEL(lid_accel)) -#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel)) -#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro)) -#define ALT_LID_S SENSOR_ID(DT_NODELABEL(alt_lid_accel)) - -static bool use_alt_sensor; - -void motion_interrupt(enum gpio_signal signal) -{ - if (use_alt_sensor) - bmi3xx_interrupt(signal); - else - lsm6dso_interrupt(signal); -} - -static void form_factor_init(void) -{ - int ret; - uint32_t val; - enum nissa_sub_board_type sb = nissa_get_sb_type(); - - ret = cbi_get_board_version(&val); - if (ret != EC_SUCCESS) { - LOG_ERR("Error retrieving CBI BOARD_VER."); - return; - } - /* - * The volume up/down button are exchanged on ver3 USB - * sub board. - * - * LTE: - * volup -> gpioa2, voldn -> gpio93 - * USB: - * volup -> gpio93, voldn -> gpioa2 - */ - if (val == 3 && sb == NISSA_SB_C_A) { - LOG_INF("Volume up/down btn exchanged on ver3 USB sku"); - buttons[BUTTON_VOLUME_UP].gpio = GPIO_VOLUME_DOWN_L; - buttons[BUTTON_VOLUME_DOWN].gpio = GPIO_VOLUME_UP_L; - } - - /* - * If the board version is 1 - * use ver1 rotation matrix. - */ - if (val == 1) { - LOG_INF("Switching to ver1 base"); - motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT; - motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT; - } - - /* - * If the firmware config indicates - * an craaskbowl form factor, use the alternative - * rotation matrix. - */ - ret = cros_cbi_get_fw_config(FW_LID_INVERSION, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", - FW_LID_INVERSION); - return; - } - if (val == FW_LID_XY_ROT_180) { - LOG_INF("Lid sensor placement rotate 180 on xy plane"); - motion_sensors[LID_SENSOR].rot_standard_ref = &LIS_ALT_MAT; - motion_sensors_alt[ALT_LID_S].rot_standard_ref = &BMA_ALT_MAT; - } - - /* check which base sensor is used for motion_interrupt */ - use_alt_sensor = cros_cbi_ssfc_check_match( - CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); - - motion_sensors_check_ssfc(); - - /* Check if it's clamshell or convertible */ - ret = cros_cbi_get_fw_config(FORM_FACTOR, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR); - return; - } - if (val == CLAMSHELL) { - LOG_INF("Clamshell: disable motionsense function."); - motion_sensor_count = 0; - gmr_tablet_switch_disable(); - gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu)); - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l), - GPIO_DISCONNECTED); - } -} -DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/projects/nissa/craask/src/keyboard.c b/zephyr/projects/nissa/craask/src/keyboard.c deleted file mode 100644 index 65229eb43f..0000000000 --- a/zephyr/projects/nissa/craask/src/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config craask_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &craask_kb; -} diff --git a/zephyr/projects/nissa/craask/src/led.c b/zephyr/projects/nissa/craask/src/led.c deleted file mode 100644 index 0af0202cf4..0000000000 --- a/zephyr/projects/nissa/craask/src/led.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery LED control for nissa - */ -#include "common.h" -#include "ec_commands.h" -#include "led_common.h" -#include "led_onoff_states.h" -#include "led_pwm.h" - -__override const int led_charge_lvl_1 = 5; -__override const int led_charge_lvl_2 = 97; -__override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_BLUE, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S3] = { { EC_LED_COLOR_AMBER, - 1 * LED_ONE_SEC }, - { LED_OFF, 3 * LED_ONE_SEC } }, - [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, - 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - [STATE_FACTORY_TEST] = { { EC_LED_COLOR_AMBER, - 2 * LED_ONE_SEC }, - { EC_LED_COLOR_BLUE, - 2 * LED_ONE_SEC } }, - }; - -__override void led_set_color_battery(enum ec_led_colors color) -{ - switch (color) { - case EC_LED_COLOR_RED: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_RED); - break; - case EC_LED_COLOR_BLUE: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_BLUE); - break; - case EC_LED_COLOR_AMBER: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); - break; - default: /* LED_OFF and other unsupported colors */ - set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); - break; - } -} diff --git a/zephyr/projects/nissa/craask/src/usbc.c b/zephyr/projects/nissa/craask/src/usbc.c deleted file mode 100644 index a15460a212..0000000000 --- a/zephyr/projects/nissa/craask/src/usbc.c +++ /dev/null @@ -1,277 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "charge_state_v2.h" -#include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" -#include "driver/charger/isl923x_public.h" -#include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" -#include "driver/tcpm/raa489000.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, - { /* sub-board */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - -int board_is_sourcing_vbus(int port) -{ - int regval; - - tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); - return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); -} - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; - int old_port; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - old_port = charge_manager_get_active_charge_port(); - - LOG_INF("New chg p%d", port); - - /* Disable all ports. */ - if (port == CHARGE_PORT_NONE) { - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - tcpc_write(i, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_LOW); - raa489000_enable_asgate(i, false); - } - - return EC_SUCCESS; - } - - /* Check if port is sourcing VBUS. */ - if (board_is_sourcing_vbus(port)) { - LOG_WRN("Skip enable p%d", port); - return EC_ERROR_INVAL; - } - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (i == port) - continue; - - if (tcpc_write(i, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_LOW)) - LOG_WRN("p%d: sink path disable failed.", i); - raa489000_enable_asgate(i, false); - } - - /* - * Stop the charger IC from switching while changing ports. Otherwise, - * we can overcurrent the adapter we're switching to. (crbug.com/926056) - */ - if (old_port != CHARGE_PORT_NONE) - charger_discharge_on_ac(1); - - /* Enable requested charge port. */ - if (raa489000_enable_asgate(port, true) || - tcpc_write(port, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { - LOG_WRN("p%d: sink path enable failed.", port); - charger_discharge_on_ac(0); - return EC_ERROR_UNKNOWN; - } - - /* Allow the charger IC to begin/continue switching. */ - charger_discharge_on_ac(0); - - return EC_SUCCESS; -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - int regval; - - /* - * The interrupt line is shared between the TCPC and BC1.2 detector IC. - * Therefore, go out and actually read the alert registers to report the - * alert status. - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { - if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { - /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ - if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_0; - } - } - - if (board_get_usb_pd_port_count() == 2 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { - /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ - if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_1; - } - } - - return status; -} - -void pd_power_supply_reset(int port) -{ - /* Disable VBUS */ - tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) -{ - if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) - return; - - raa489000_set_output_current(port, rp); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) - return EC_ERROR_INVAL; - - /* Disable charging. */ - rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); - if (rv) - return rv; - - /* Our policy is not to source VBUS when the AP is off. */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - return EC_ERROR_NOT_POWERED; - - /* Provide Vbus. */ - rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); - if (rv) - return rv; - - rv = raa489000_enable_asgate(port, true); - if (rv) - return rv; - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -void board_reset_pd_mcu(void) -{ - /* - * TODO(b:147316511): could send a reset command to the TCPC here - * if needed. - */ -} - -/* - * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible - * for an interrupt to be lost if one asserts the IRQ, the other does the same - * then the first releases it: there will only be one falling edge to trigger - * the interrupt, and the line will be held low. We handle this by running a - * deferred check after a falling edge to see whether the IRQ is still being - * asserted. If it is, we assume an interrupt may have been lost and we need - * to poll each chip for events again. - */ -#define USBC_INT_POLL_DELAY_US 5000 - -static void poll_c0_int(void); -DECLARE_DEFERRED(poll_c0_int); -static void poll_c1_int(void); -DECLARE_DEFERRED(poll_c1_int); - -static void usbc_interrupt_trigger(int port) -{ - schedule_deferred_pd_interrupt(port); - usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); -} - -static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, - const struct deferred_data *ud) -{ - if (!gpio_pin_get_dt(gpio)) { - usbc_interrupt_trigger(port); - hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); - } -} - -static void poll_c0_int(void) -{ - poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), - &poll_c0_int_data); -} - -static void poll_c1_int(void) -{ - poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), - &poll_c1_int_data); -} - -void usb_interrupt(enum gpio_signal signal) -{ - int port; - const struct deferred_data *ud; - - if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { - port = 0; - ud = &poll_c0_int_data; - } else { - port = 1; - ud = &poll_c1_int_data; - } - /* - * We've just been called from a falling edge, so there's definitely - * no lost IRQ right now. Cancel any pending check. - */ - hook_call_deferred(ud, -1); - /* Trigger polling of TCPC and BC1.2 in respective tasks */ - usbc_interrupt_trigger(port); - /* Check for lost interrupts in a bit */ - hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); -} diff --git a/zephyr/projects/nissa/include/nissa_common.h b/zephyr/projects/nissa/include/nissa_common.h deleted file mode 100644 index 7cdaba2e50..0000000000 --- a/zephyr/projects/nissa/include/nissa_common.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Nissa common declarations */ - -#ifndef __CROS_EC_NISSA_NISSA_COMMON_H__ -#define __CROS_EC_NISSA_NISSA_COMMON_H__ - -#include "usb_mux.h" - -enum nissa_sub_board_type { - NISSA_SB_UNKNOWN = -1, /* Uninitialised */ - NISSA_SB_NONE = 0, /* No board defined */ - NISSA_SB_C_A = 1, /* USB type C, USB type A */ - NISSA_SB_C_LTE = 2, /* USB type C, WWAN LTE */ - NISSA_SB_HDMI_A = 3, /* HDMI, USB type A */ -}; - -enum nissa_sub_board_type nissa_get_sb_type(void); - -#endif /* __CROS_EC_NISSA_NISSA_COMMON_H__ */ diff --git a/zephyr/projects/nissa/include/nissa_hdmi.h b/zephyr/projects/nissa/include/nissa_hdmi.h deleted file mode 100644 index 9f2f533ba7..0000000000 --- a/zephyr/projects/nissa/include/nissa_hdmi.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Nissa shared HDMI sub-board functionality */ - -#ifndef __CROS_EC_NISSA_NISSA_HDMI_H__ -#define __CROS_EC_NISSA_NISSA_HDMI_H__ - -#include "common.h" - -/** True if the board supports an HDMI sub-board. */ -#define NISSA_BOARD_HAS_HDMI_SUPPORT DT_NODE_EXISTS(DT_NODELABEL(gpio_hdmi_sel)) - -/** - * Configure the GPIO that controls core rails on the HDMI sub-board. - * - * This is the gpio_en_rails_odl pin, which is configured as active-low - * open-drain output to enable power to the HDMI sub-board (typically when the - * AP is in S5 or above). - * - * This function must be called if the pin is connected to the HDMI board and - * power is not enabled by default. - */ -void nissa_configure_hdmi_rails(void); - -/** - * Configure the GPIO that controls the HDMI VCC pin on the HDMI sub-board. - * - * This is the gpio_hdmi_en_odl pin, which is configured as active-low - * open-drain output to enable the VCC pin on the HDMI connector (typically when - * the AP is on, in S0 or S0ix). - * - * This function must be called if the pin is connected to the HDMI board and - * VCC is not enabled by default. - */ -void nissa_configure_hdmi_vcc(void); - -/** - * Configure the GPIOS controlling HDMI sub-board power (core rails and VCC). - * - * This function is called from shared code while configuring sub-boards, and - * used if an HDMI sub-board is present. The default implementation enables the - * core rails control pin (nissa_configure_hdmi_rails) but not VCC - * (nissa_configure_hdmi_vcc), assuming that the pin for VCC is not connected - * connected on most boards (and that VCC will be turned on whenever the core - * rails are turned on). - * - * A board should override this function if it needs to enable more IOs for - * HDMI, or if some pins need to be conditionally enabled. - */ -__override_proto void nissa_configure_hdmi_power_gpios(void); - -#endif /* __CROS_EC_NISSA_NISSA_HDMI_H__ */ diff --git a/zephyr/projects/nissa/it8xxx2_program.conf b/zephyr/projects/nissa/it8xxx2_program.conf deleted file mode 100644 index 3272c04209..0000000000 --- a/zephyr/projects/nissa/it8xxx2_program.conf +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_FLASH_IT8XXX2=y -CONFIG_CROS_SYSTEM_IT8XXX2=y -CONFIG_ESPI_IT8XXX2=y -CONFIG_FPU=y -# rv32iafc/ilp32f is not supported by the toolchain, so use soft-float -CONFIG_FLOAT_HARD=n - -# EC performance is bad; limiting sensor data rate helps keep it from degrading -# so much that it causes problems. b/240485526, b/230818312 -CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 - -# Allow more time for the charger to stabilise -CONFIG_PLATFORM_EC_POWER_BUTTON_INIT_TIMEOUT=5 - -# ITE has more space, so don't restrict shell -CONFIG_SHELL_MINIMAL=n - -# RAM savings, since this chip is tight on available RAM. -# It's useful to store a lot of logs for the host to request, but the default 4k -# is pretty large. -CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE=2048 -# Our threads have short names, save 20 bytes per thread -CONFIG_THREAD_MAX_NAME_LEN=12 -# Task stacks, tuned by experiment. Most expanded to prevent overflow, and a few -# shrunk to save RAM. -CONFIG_AP_PWRSEQ_STACK_SIZE=1408 -CONFIG_TASK_HOSTCMD_STACK_SIZE=1280 -CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1280 -CONFIG_TASK_PD_INT_STACK_SIZE=1280 - -# TCPC+PPC: ITE on-chip for C0, PS8745 for optional C1 -CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8745=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_CHARGER=y -# SM5803 controls power path on both ports -CONFIG_PLATFORM_EC_USB_PD_5V_CHARGER_CTRL=y -# SM5803 can discharge VBUS, but not via one of the available options; -# pd_power_supply_reset() does discharge. -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE=n -# The EC is put into programming mode while firmware is running -# (after releasing reset) and PD after being reset will hard-reset -# the port if a contract was already set up. If the system has no -# battery, this will prevent programming because it will brown out -# the system and reset. Inserting a delay gives the programmer more -# time to put the EC into programming mode. -CONFIG_PLATFORM_EC_USB_PD_STARTUP_DELAY_MS=2000 - -# Charger driver and configuration -CONFIG_PLATFORM_EC_OCPC=y -CONFIG_PLATFORM_EC_CHARGER_SM5803=y -CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=21 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=15000 - -# VSENSE: PP3300_S5 & PP1050_PROC -CONFIG_VCMP_IT8XXX2=y -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n diff --git a/zephyr/projects/nissa/joxer/cbi.dtsi b/zephyr/projects/nissa/joxer/cbi.dtsi deleted file mode 100644 index afbd125b32..0000000000 --- a/zephyr/projects/nissa/joxer/cbi.dtsi +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - nissa-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - /* - * FW_CONFIG field to indicate which keyboard layout - * should be used. - */ - keyboard { - enum-name = "FW_KB_LAYOUT"; - start = <3>; - size = <2>; - - layout-1 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_LAYOUT_DEFAULT"; - value = <0>; - default; - }; - layout-2 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_LAYOUT_US2"; - value = <1>; - }; - }; - }; -}; diff --git a/zephyr/projects/nissa/joxer/generated.dtsi b/zephyr/projects/nissa/joxer/generated.dtsi deleted file mode 100644 index 22214b9726..0000000000 --- a/zephyr/projects/nissa/joxer/generated.dtsi +++ /dev/null @@ -1,260 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * This file is auto-generated - do not edit! - */ - -/ { - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { - enum-name = "ADC_PP1050_PROC"; - io-channels = <&adc0 14>; - }; - adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { - enum-name = "ADC_PP3300_S5"; - io-channels = <&adc0 0>; - }; - adc_temp_sensor_1: temp_sensor_1 { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 2>; - }; - adc_temp_sensor_2: temp_sensor_2 { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 3>; - }; - adc_temp_sensor_3: temp_sensor_3 { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 13>; - }; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_acc_int_l: acc_int_l { - gpios = <&gpioc 0 GPIO_INPUT>; - }; - gpio_all_sys_pwrgd: all_sys_pwrgd { - gpios = <&gpiob 7 GPIO_INPUT>; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioh 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_cpu_c10_gate_l: cpu_c10_gate_l { - gpios = <&gpiog 1 GPIO_INPUT>; - }; - gpio_ec_battery_pres_odl: ec_battery_pres_odl { - gpios = <&gpioi 4 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioj 5 GPIO_OUTPUT>; - }; - gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { - gpios = <&gpiok 4 GPIO_ODR_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_entering_rw: ec_entering_rw { - gpios = <&gpioc 7 GPIO_OUTPUT>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { - gpios = <&gpioh 1 GPIO_OUTPUT>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_pch_wake_odl: ec_pch_wake_odl { - gpios = <&gpiob 2 GPIO_ODR_LOW>; - }; - gpio_ec_prochot_odl: ec_prochot_odl { - gpios = <&gpioi 1 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { - gpios = <&gpiol 7 GPIO_OUTPUT>; - }; - gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { - gpios = <&gpiok 7 GPIO_OUTPUT>; - }; - gpio_ec_soc_int_odl: ec_soc_int_odl { - gpios = <&gpiod 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { - gpios = <&gpiod 6 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { - gpios = <&gpiob 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioh 0 GPIO_OUTPUT>; - }; - gpio_ec_soc_rtcrst: ec_soc_rtcrst { - gpios = <&gpiok 2 GPIO_OUTPUT>; - }; - gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { - gpios = <&gpiof 2 GPIO_OUTPUT>; - }; - gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { - gpios = <&gpioe 5 GPIO_ODR_HIGH>; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpioa 6 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_en_kb_bl: en_kb_bl { - gpios = <&gpioj 3 GPIO_OUTPUT>; - enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; - }; - gpio_en_pp3300_s5: en_pp3300_s5 { - gpios = <&gpioc 5 GPIO_OUTPUT>; - enum-name = "GPIO_TEMP_SENSOR_POWER"; - }; - gpio_en_pp5000_pen_x: en_pp5000_pen_x { - gpios = <&gpiob 5 GPIO_OUTPUT>; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpiok 5 GPIO_OUTPUT>; - }; - gpio_en_slp_z: en_slp_z { - gpios = <&gpiok 3 GPIO_OUTPUT>; - }; - gpio_en_usb_a0_vbus: en_usb_a0_vbus { - gpios = <&gpiol 6 GPIO_OUTPUT>; - }; - gpio_en_usb_c0_cc1_vconn: en_usb_c0_cc1_vconn { - gpios = <&gpioh 4 GPIO_OUTPUT>; - }; - gpio_en_usb_c0_cc2_vconn: en_usb_c0_cc2_vconn { - gpios = <&gpioh 6 GPIO_OUTPUT>; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_hdmi_sel: hdmi_sel { - gpios = <&gpioc 6 GPIO_OUTPUT>; - }; - gpio_imu_int_l: imu_int_l { - gpios = <&gpioj 0 GPIO_INPUT>; - }; - gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { - gpios = <&gpioj 4 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiof 3 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_pen_detect_odl: pen_detect_odl { - gpios = <&gpioj 1 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { - gpios = <&gpiod 3 GPIO_INPUT>; - }; - gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { - gpios = <&gpioe 3 GPIO_INPUT>; - }; - gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { - gpios = <&gpioe 1 GPIO_INPUT_PULL_UP>; - }; - gpio_slp_s0_l: slp_s0_l { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpioh 3 GPIO_INPUT>; - }; - gpio_slp_s4_l: slp_s4_l { - gpios = <&gpioi 5 GPIO_INPUT>; - }; - gpio_slp_sus_l: slp_sus_l { - gpios = <&gpiog 2 GPIO_INPUT>; - }; - gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { - gpios = <&gpiof 1 GPIO_OUTPUT>; - enum-name = "GPIO_USB2_ILIM_SEL"; - }; - gpio_sys_rst_odl: sys_rst_odl { - gpios = <&gpiod 1 GPIO_ODR_HIGH>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioj 7 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { - gpios = <&gpiol 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB1_ILIM_SEL"; - }; - gpio_usb_c0_frs: usb_c0_frs { - gpios = <&gpioc 4 GPIO_OUTPUT>; - }; - gpio_usb_c0_int_odl: usb_c0_int_odl { - gpios = <&gpiok 0 GPIO_INPUT_PULL_UP>; - }; - gpio_vccin_aux_vid0: vccin_aux_vid0 { - gpios = <&gpiod 0 GPIO_INPUT>; - }; - gpio_vccin_aux_vid1: vccin_aux_vid1 { - gpios = <&gpiok 1 GPIO_INPUT>; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpioi 6 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpioi 7 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_ec_i2c_eeprom: ec_i2c_eeprom { - i2c-port = <&i2c0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_ec_i2c_batt: ec_i2c_batt { - i2c-port = <&i2c1>; - enum-names = "I2C_PORT_BATTERY"; - }; - i2c_ec_i2c_sensor: ec_i2c_sensor { - i2c-port = <&i2c2>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { - i2c-port = <&i2c4>; - enum-names = "I2C_PORT_USB_C1_TCPC"; - }; - i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { - i2c-port = <&i2c5>; - enum-names = "I2C_PORT_USB_C0_TCPC"; - }; - }; -}; - -&adc0 { - status = "okay"; -}; - -&i2c0 { - status = "okay"; -}; - -&i2c1 { - status = "okay"; -}; - -&i2c2 { - status = "okay"; -}; - -&i2c4 { - status = "okay"; -}; - -&i2c5 { - status = "okay"; -}; diff --git a/zephyr/projects/nissa/joxer/joxer_vif.xml b/zephyr/projects/nissa/joxer/joxer_vif.xml deleted file mode 100644 index cfbce5623a..0000000000 --- a/zephyr/projects/nissa/joxer/joxer_vif.xml +++ /dev/null @@ -1,346 +0,0 @@ - - - 3.20 - - USB-IF - VIF Editor - 3.3.0.0 - - Google - Joxer - 1 - 0 - Port Product - Reference Platform - - - - - - - - - 0 - Type-C® - - - DRP - DRP - - Both - - - - - - - - - Revision 3 - - - - - - - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 15000 mW - Assured - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - FR_Swap not supported - - - - Over-Current Response - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - 0 msec - 3000 mA - - - - - - 45000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 15000 mV - - - - Variable - 4750 mV - 15000 mV - 3000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505A - 0000 - - - - - - - 1 - Type-C® - - - DRP - DRP - - Both - - - - - - - - - Revision 3 - - - - - - - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 15000 mW - Assured - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - FR_Swap not supported - - - - Over-Current Response - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - 0 msec - 3000 mA - - - - - - 45000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 15000 mV - - - - Variable - 4750 mV - 15000 mV - 3000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505A - 0000 - - \ No newline at end of file diff --git a/zephyr/projects/nissa/joxer/keyboard.dtsi b/zephyr/projects/nissa/joxer/keyboard.dtsi deleted file mode 100644 index 04a620767a..0000000000 --- a/zephyr/projects/nissa/joxer/keyboard.dtsi +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - /* - * Use 324 Hz so that 32Khz clock source is used, - * which is not gated in power saving mode. - */ - pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm0 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm0_gpa0_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/joxer/motionsense.dtsi b/zephyr/projects/nissa/joxer/motionsense.dtsi deleted file mode 100644 index 537cc34451..0000000000 --- a/zephyr/projects/nissa/joxer/motionsense.dtsi +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * Interrupt bindings for sensor devices. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: base-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - (-1) 0 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bmi323_data: bmi323-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - - bma422_data: bma422-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - * TODO(b/238139272): The first entries of the array must be - * accelerometers,then gyroscope. Fix this dependency in the DTS - * processing which makes the devicetree entries independent. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma422_data>; - i2c-spi-addr-flags = "BMA4_I2C_ADDR_SECONDARY"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi323_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi323_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/nissa/joxer/overlay.dtsi b/zephyr/projects/nissa/joxer/overlay.dtsi deleted file mode 100644 index b587da8fb1..0000000000 --- a/zephyr/projects/nissa/joxer/overlay.dtsi +++ /dev/null @@ -1,445 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_odl; - int-wp = &int_wp_l; - /* - * USB-C: interrupt input. - * I2C pins are on i2c_ec_i2c_sub_usb_c1 - */ - gpio-usb-c1-int-odl = &gpio_sb_1; - /* - * USB-A: VBUS enable output - * LTE: power enable output - */ - gpio-en-usb-a1-vbus = &gpio_sb_2; - /* - * HDMI: power enable output, HDMI enable output, - * and HPD input - */ - gpio-en-rails-odl = &gpio_sb_1; - gpio-hdmi-en-odl = &gpio_sb_4; - gpio-hpd-odl = &gpio_sb_3; - /* - * Enable S5 rails for LTE sub-board - */ - gpio-en-sub-s5-rails = &gpio_sb_2; - }; - - ec-console { - compatible = "ec-console"; - disabled = "events", "lpc", "hostcmd"; - }; - - batteries { - default_battery: cosmx { - compatible = "cosmx,gh02047xl", "battery-smart"; - }; - dynapack_atl_gh02047xl { - compatible = "dynapack,atl_gh02047xl", "battery-smart"; - }; - dynapack_cosmx_gh02047xl { - compatible = "dynapack,cosmx_gh02047xl", "battery-smart"; - }; - smp_coslight_gh02047xl { - compatible = "smp,coslight_gh02047xl", "battery-smart"; - }; - smp_highpower_gh02047xl { - compatible = "smp,highpower_gh02047xl", "battery-smart"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_power_button - &int_lid_open - >; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_vol_down: vol_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_vol_up: vol_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_imu: ec_imu { - irq-pin = <&gpio_imu_int_l>; - flags = ; - handler = "bmi3xx_interrupt"; - }; - int_usb_c0: usb_c0 { - irq-pin = <&gpio_usb_c0_int_odl>; - flags = ; - handler = "usb_c0_interrupt"; - }; - int_usb_c1: usb_c1 { - irq-pin = <&gpio_sb_1>; - flags = ; - handler = "usb_c1_interrupt"; - }; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = <&gpioc 3 0>, - <&gpiod 4 0>, - <&gpioh 2 0>, - <&gpiol 4 0>; - }; - - named-gpios { - /* - * EC doesn't take any specific action on CC/SBU disconnect due to - * fault, but this definition is useful for hardware testing. - */ - gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl { - gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>; - }; - - gpio_sb_1: sb_1 { - gpios = <&gpioe 6 0>; - no-auto-init; - }; - gpio_sb_2: sb_2 { - gpios = <&gpiof 0 0>; - no-auto-init; - }; - - gpio_sb_3: sb_3 { - gpios = <&gpioe 7 0>; - no-auto-init; - }; - gpio_sb_4: sb_4 { - gpios = <&gpioe 0 0>; - no-auto-init; - }; - gpio_fan_enable: fan-enable { - gpios = <&gpiol 4 GPIO_OUTPUT>; - no-auto-init; - }; - gpio_power_led_gate: power_led_gate { - gpios = <&gpiof 1 GPIO_OUTPUT_LOW>; - }; - gpio_led_1_odl: led_1_odl { - gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>; - }; - gpio_led_2_odl: led_2_odl { - gpios = <&gpioa 2 GPIO_OUTPUT_HIGH>; - }; - gpio_led_3_l: led_3_l { - gpios = <&gpiol 2 GPIO_OUTPUT_HIGH>; - }; - gpio_led_4_l: led_4_l { - gpios = <&gpiol 3 GPIO_OUTPUT_HIGH>; - }; - }; - - temp_memory: memory { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_1>; - }; - temp_charger: charger { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_2>; - }; - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_3>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - memory { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_memory>; - }; - charger { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_charger>; - }; - ambient { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_ambient>; - }; - }; - - usba { - compatible = "cros-ec,usba-port-enable-pins"; - /* - * sb_2 is only configured as GPIO when USB-A1 is present, - * but it's still safe to control when disabled. - * - * ILIM_SEL pins are referred to by legacy enum name, - * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on - * sub-boards that don't have USB-A so is safe to control - * regardless of system configuration. - */ - enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; - status = "okay"; - }; - - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - chg = <&chg_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - chg = <&chg_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; - }; - usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - tcpci_mux_1: tcpci-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; - }; - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm7 PWM_CHANNEL_7 PWM_KHZ(30) PWM_POLARITY_NORMAL>; - tach = <&tach1>; - rpm_min = <1500>; - rpm_start = <1500>; - rpm_max = <6500>; - enable_gpio = <&gpio_fan_enable>; - }; - }; -}; - -&gpio_acc_int_l { - gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; -}; -&gpio_imu_int_l { - gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; -}; -&gpio_vccin_aux_vid0 { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; -}; -&gpio_vccin_aux_vid1 { - gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; -}; - -&gpio_ec_prochot_odl { - gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; -}; - -&thermistor_3V3_51K1_47K_4050B { - status = "okay"; -}; - -&adc_ec_vsense_pp3300_s5 { - /* - * Voltage divider on input has 47k upper and 220k lower legs with 3 V - * full-scale reading on the ADC. Apply the largest possible multiplier - * (without overflowing int32) to get the best possible approximation - * of the actual ratio, but derate by a factor of two to ensure - * unexpectedly high values won't overflow. - */ - mul = <(715828 / 2)>; - div = <(589820 / 2)>; -}; - -&adc0 { - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch2_gpi2_default - &adc0_ch3_gpi3_default - &adc0_ch13_gpl0_default - &adc0_ch14_gpl1_default>; - pinctrl-names = "default"; -}; - -&pinctrl { - i2c2_clk_gpf6_default: i2c2_clk_gpf6_default { - gpio-voltage = "1v8"; - }; - i2c2_data_gpf7_default: i2c2_data_gpf7_default { - gpio-voltage = "1v8"; - }; -}; - - -&i2c0 { - label = "I2C_EEPROM"; - clock-frequency = ; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; - pinctrl-0 = <&i2c0_clk_gpb3_default - &i2c0_data_gpb4_default>; - pinctrl-names = "default"; -}; - -&i2c1 { - label = "I2C_BATTERY"; - clock-frequency = <50000>; - pinctrl-0 = <&i2c1_clk_gpc1_default - &i2c1_data_gpc2_default>; - pinctrl-names = "default"; -}; - -&i2c2 { - label = "I2C_SENSOR"; - clock-frequency = ; - pinctrl-0 = <&i2c2_clk_gpf6_default - &i2c2_data_gpf7_default>; - pinctrl-names = "default"; -}; - -&i2c4 { - label = "I2C_SUB_C1_TCPC"; - clock-frequency = ; - pinctrl-0 = <&i2c4_clk_gpe0_default - &i2c4_data_gpe7_default>; - pinctrl-names = "default"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port1: sm5803@32 { - compatible = "siliconmitus,sm5803"; - status = "okay"; - reg = <0x32>; - }; -}; - -&i2c_ec_i2c_sub_usb_c1 { - /* - * Dynamic speed setting is used for AP-controlled firmware update - * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order - * to use more efficient window programming, then sets it back when - * done. - */ - dynamic-speed; -}; - -&i2c5 { - label = "I2C_USB_C0_TCPC"; - clock-frequency = ; - pinctrl-0 = <&i2c5_clk_gpa4_default - &i2c5_data_gpa5_default>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port0: sm5803@32 { - compatible = "siliconmitus,sm5803"; - status = "okay"; - reg = <0x32>; - }; -}; - -/* pwm for fan */ -&pwm7 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm7_gpa7_default>; - pinctrl-names = "default"; -}; - -/* fan tachometer sensor */ -&tach1 { - status = "okay"; - channel = ; - pulses-per-round = <2>; - pinctrl-0 = <&tach1a_gpd7_default>; - pinctrl-names = "default"; -}; - -&usbpd0 { - status = "okay"; -}; diff --git a/zephyr/projects/nissa/joxer/power_signals.dtsi b/zephyr/projects/nissa/joxer/power_signals.dtsi deleted file mode 100644 index 8affae03b1..0000000000 --- a/zephyr/projects/nissa/joxer/power_signals.dtsi +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <10>; - all-sys-pwrgd-timeout = <20>; - }; - - pwr-en-pp5000-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP5000_S5 enable output to regulator"; - enum-name = "PWR_EN_PP5000_A"; - gpios = <&gpiok 5 0>; - output; - }; - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpioc 5 0>; - output; - }; - pwr-pg-ec-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpioe 1 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioh 0 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpioe 4 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - gpios = <&gpioh 3 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-sus-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_SUS_L input from PCH"; - enum-name = "PWR_SLP_SUS"; - gpios = <&gpiog 2 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-ec-soc-dsw-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "DSW_PWROK output to PCH"; - enum-name = "PWR_EC_SOC_DSW_PWROK"; - gpios = <&gpiol 7 0>; - output; - }; - pwr-vccst-pwrgd-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VCCST_PWRGD output to PCH"; - enum-name = "PWR_VCCST_PWRGD"; - gpios = <&gpioe 5 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; - output; - }; - pwr-imvp9-vrrdy-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VRRDY input from IMVP9"; - enum-name = "PWR_IMVP9_VRRDY"; - gpios = <&gpioj 4 0>; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpiod 6 GPIO_OPEN_DRAIN>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpiof 2 0>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpiod 1 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - /* - * This is a board level signal, since this - * signal needs some special processing. - */ - compatible = "intel,ap-pwrseq-external"; - dbg-label = "Combined all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - }; - pwr-adc-pp3300 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP3300_PROC"; - enum-name = "PWR_DSW_PWROK"; - trigger-high = <&vcmp0>; - trigger-low = <&vcmp1>; - }; - pwr-adc-pp1p05 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP1P05_PROC"; - enum-name = "PWR_PG_PP1P05"; - trigger-high = <&vcmp2>; - trigger-low = <&vcmp3>; - }; - -}; - -/* - * Because the power signals directly reference the GPIOs, - * the correspinding named-gpios need to have no-auto-init set. - */ -&gpio_ec_soc_dsw_pwrok { - no-auto-init; -}; -&gpio_ec_soc_pch_pwrok_od { - no-auto-init; -}; -&gpio_ec_soc_rsmrst_l { - no-auto-init; -}; -&gpio_ec_soc_sys_pwrok { - no-auto-init; -}; -&gpio_ec_soc_vccst_pwrgd_od { - no-auto-init; -}; -&gpio_en_pp3300_s5 { - no-auto-init; -}; -&gpio_en_pp5000_s5 { - no-auto-init; -}; -&gpio_imvp91_vrrdy_od { - no-auto-init; -}; -&gpio_rsmrst_pwrgd_l { - no-auto-init; -}; -&gpio_slp_s0_l { - no-auto-init; -}; -&gpio_slp_s3_l { - no-auto-init; -}; -&gpio_slp_sus_l { - no-auto-init; -}; -&gpio_sys_rst_odl { - no-auto-init; -}; -&vcmp0 { - status = "okay"; - scan-period = ; - comparison = ; - /* - * This is 90% of nominal voltage considering voltage - * divider on ADC input. - */ - threshold-mv = <2448>; - io-channels = <&adc0 0>; -}; -&vcmp1 { - status = "okay"; - scan-period = ; - comparison = ; - threshold-mv = <2448>; - io-channels = <&adc0 0>; -}; -&vcmp2 { - status = "okay"; - scan-period = ; - comparison = ; - /* Setting at 90% of nominal voltage */ - threshold-mv = <945>; - io-channels = <&adc0 14>; -}; -&vcmp3 { - status = "okay"; - scan-period = ; - comparison = ; - threshold-mv = <945>; - io-channels = <&adc0 14>; -}; diff --git a/zephyr/projects/nissa/joxer/project.conf b/zephyr/projects/nissa/joxer/project.conf deleted file mode 100644 index a0de72294c..0000000000 --- a/zephyr/projects/nissa/joxer/project.conf +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_JOXER=y - -# Ensure recovery key combination (esc+refresh+power) is reliable: b/236580049 -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y - -# Sensor drivers -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 - -# LED -CONFIG_PLATFORM_EC_LED_PWM=n -CONFIG_PLATFORM_EC_LED_COMMON=y diff --git a/zephyr/projects/nissa/joxer/project.overlay b/zephyr/projects/nissa/joxer/project.overlay deleted file mode 100644 index 9ca681d979..0000000000 --- a/zephyr/projects/nissa/joxer/project.overlay +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../cbi.dtsi" - -#include "cbi.dtsi" -#include "generated.dtsi" -#include "keyboard.dtsi" -#include "motionsense.dtsi" -#include "overlay.dtsi" -#include "power_signals.dtsi" -#include "pwm_leds.dtsi" diff --git a/zephyr/projects/nissa/joxer/pwm_leds.dtsi b/zephyr/projects/nissa/joxer/pwm_leds.dtsi deleted file mode 100644 index aa4a76b271..0000000000 --- a/zephyr/projects/nissa/joxer/pwm_leds.dtsi +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm1 1 PWM_HZ(1296) PWM_POLARITY_INVERTED>, - <&pwm2 2 PWM_HZ(1296) PWM_POLARITY_INVERTED>, - <&pwm3 3 PWM_HZ(1296) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0>; - - /**/ - color-map-red = <100 0 0>; - color-map-green = < 0 100 0>; - color-map-blue = < 0 0 100>; - color-map-yellow = < 0 50 50>; - color-map-white = <100 100 100>; - color-map-amber = <100 15 0>; - - brightness-range = <100 100 100 0 0 0>; - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_BATTERY_LED"; - }; - }; -}; - -&pwm1 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm1_gpa1_default>; - pinctrl-names = "default"; -}; - -&pwm2 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm2_gpa2_default>; - pinctrl-names = "default"; -}; - -&pwm3 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm3_gpa3_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/joxer/src/charger.c b/zephyr/projects/nissa/joxer/src/charger.c deleted file mode 100644 index b9454d8b80..0000000000 --- a/zephyr/projects/nissa/joxer/src/charger.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery.h" -#include "charger.h" -#include "console.h" -#include "driver/charger/sm5803.h" -#include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -int extpower_is_present(void) -{ - int port; - int rv; - bool acok; - - for (port = 0; port < board_get_usb_pd_port_count(); port++) { - rv = sm5803_is_acok(port, &acok); - if ((rv == EC_SUCCESS) && acok) - return 1; - } - - return 0; -} - -/* - * Joxer not have a GPIO indicating whether extpower is present, - * so detect using the charger(s). - */ -__override void board_check_extpower(void) -{ - static int last_extpower_present; - int extpower_present = extpower_is_present(); - - if (last_extpower_present ^ extpower_present) - extpower_handle_update(extpower_present); - - last_extpower_present = extpower_present; -} - -__override void board_hibernate(void) -{ - /* Shut down the chargers */ - if (board_get_usb_pd_port_count() == 2) - sm5803_hibernate(CHARGER_SECONDARY); - sm5803_hibernate(CHARGER_PRIMARY); - LOG_INF("Charger(s) hibernated"); - cflush(); -} diff --git a/zephyr/projects/nissa/joxer/src/fan.c b/zephyr/projects/nissa/joxer/src/fan.c deleted file mode 100644 index 6d234b2fc3..0000000000 --- a/zephyr/projects/nissa/joxer/src/fan.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -/* - * Joxer fan support - */ -static void fan_init(void) -{ - int ret; - uint32_t val; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - if (val != FW_FAN_PRESENT) { - /* Disable the fan */ - fan_set_count(0); - } else { - /* Configure the fan enable GPIO */ - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), - GPIO_OUTPUT); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/nissa/joxer/src/keyboard.c b/zephyr/projects/nissa/joxer/src/keyboard.c deleted file mode 100644 index 48db40f53f..0000000000 --- a/zephyr/projects/nissa/joxer/src/keyboard.c +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include "cros_cbi.h" -#include "ec_commands.h" -#include "gpio/gpio.h" -#include "hooks.h" -#include "keyboard_8042_sharedlib.h" -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -static const struct ec_response_keybd_config joxer_kb_legacy = { - .num_top_row_keys = 13, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_KBD_BKLIGHT_TOGGLE, /* T8 */ - TK_PLAY_PAUSE, /* T9 */ - TK_MICMUTE, /* T10 */ - TK_VOL_MUTE, /* T11 */ - TK_VOL_DOWN, /* T12 */ - TK_VOL_UP, /* T13 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &joxer_kb_legacy; -} - -/* - * Keyboard layout decided by FW config. - */ -static void kb_layout_init(void) -{ - int ret; - uint32_t val; - /* - * Retrieve the kb layout config. - */ - ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", - FW_KB_LAYOUT); - return; - } - /* - * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl - * to backslash(\|) key. - */ - if (val == FW_KB_LAYOUT_US2) - set_scancode_set2(4, 0, get_scancode_set2(2, 7)); -} -DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/nissa/joxer/src/led.c b/zephyr/projects/nissa/joxer/src/led.c deleted file mode 100644 index d66e5b27a6..0000000000 --- a/zephyr/projects/nissa/joxer/src/led.c +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery LED control for nissa - */ -#include - -#include "charge_manager.h" -#include "common.h" -#include "compile_time_macros.h" -#include "ec_commands.h" -#include "gpio.h" -#include "led_common.h" -#include "led_onoff_states.h" -#include "pwm.h" -#include "util.h" - -#define BAT_LED_ON_LVL 0 -#define BAT_LED_OFF_LVL 1 - -#define PWR_LED_ON_LVL 1 -#define PWR_LED_OFF_LVL 0 - -#define LED_SIDESEL_MB_PORT 0 -#define LED_SIDESEL_DB_PORT 1 - -__override const int led_charge_lvl_1 = 5; -__override const int led_charge_lvl_2 = 95; - -__override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_WHITE, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, - 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, - 0.5 * LED_ONE_SEC }, - { LED_OFF, 0.5 * LED_ONE_SEC } }, - [STATE_FACTORY_TEST] = { { EC_LED_COLOR_WHITE, - 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - }; - -__override const struct led_descriptor - led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { - [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, - [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, - 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, - 1 * LED_ONE_SEC }, - { LED_OFF, - 1 * LED_ONE_SEC } }, - [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, - }; - -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_BATTERY_LED, - EC_LED_ID_POWER_LED, -}; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -__override void led_set_color_battery(enum ec_led_colors color) -{ - int port; - - /* There are four battery leds, LED1/LED2 are on MB side and - * LED3/LED4 are on DB side. All leds are OFF by default. - */ - int led1, led2, led3, led4; - - led1 = led2 = led3 = led4 = BAT_LED_OFF_LVL; - - /* Check which port is the charging port, - * and turn on the corresponding led. - */ - if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) { - port = charge_manager_get_active_charge_port(); - switch (port) { - case LED_SIDESEL_MB_PORT: - switch (color) { - case EC_LED_COLOR_AMBER: - led1 = BAT_LED_ON_LVL; - break; - case EC_LED_COLOR_WHITE: - led2 = BAT_LED_ON_LVL; - break; - default: /* LED_OFF and other unsupported colors */ - break; - } - break; - case LED_SIDESEL_DB_PORT: - switch (color) { - case EC_LED_COLOR_AMBER: - led3 = BAT_LED_ON_LVL; - break; - case EC_LED_COLOR_WHITE: - led4 = BAT_LED_ON_LVL; - break; - default: /* LED_OFF and other unsupported colors */ - break; - } - break; - default: /* Unknown charging port */ - break; - } - } else { - switch (color) { - case EC_LED_COLOR_AMBER: - led1 = BAT_LED_ON_LVL; - led3 = BAT_LED_ON_LVL; - break; - case EC_LED_COLOR_WHITE: - led2 = BAT_LED_ON_LVL; - led4 = BAT_LED_ON_LVL; - break; - default: /* LED_OFF and other unsupported colors */ - break; - } - } - - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), led1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), led2); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_3_l), led3); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_4_l), led4); -} - -__override void led_set_color_power(enum ec_led_colors color) -{ - if (color == EC_LED_COLOR_WHITE) - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_gate), - PWR_LED_ON_LVL); - else - /* LED_OFF and unsupported colors */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_gate), - PWR_LED_OFF_LVL); -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - if (led_id == EC_LED_ID_BATTERY_LED) { - brightness_range[EC_LED_COLOR_AMBER] = 1; - brightness_range[EC_LED_COLOR_WHITE] = 1; - } else if (led_id == EC_LED_ID_POWER_LED) { - brightness_range[EC_LED_COLOR_WHITE] = 1; - } -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - if (led_id == EC_LED_ID_BATTERY_LED) { - led_auto_control(led_id, 0); - if (brightness[EC_LED_COLOR_AMBER] != 0) - led_set_color_battery(EC_LED_COLOR_AMBER); - else if (brightness[EC_LED_COLOR_WHITE] != 0) - led_set_color_battery(EC_LED_COLOR_WHITE); - else if (brightness[LED_OFF] != 0) - led_set_color_battery(LED_OFF); - else { - led_auto_control(led_id, 1); - led_set_color_battery(LED_OFF); - } - } else if (led_id == EC_LED_ID_POWER_LED) { - if (brightness[EC_LED_COLOR_WHITE] != 0) - led_set_color_power(EC_LED_COLOR_WHITE); - else - led_set_color_power(LED_OFF); - } - - return EC_SUCCESS; -} diff --git a/zephyr/projects/nissa/joxer/src/usbc.c b/zephyr/projects/nissa/joxer/src/usbc.c deleted file mode 100644 index 5fec9ab544..0000000000 --- a/zephyr/projects/nissa/joxer/src/usbc.c +++ /dev/null @@ -1,392 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "charge_state_v2.h" -#include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" -#include "driver/charger/sm5803.h" -#include "driver/tcpm/it83xx_pd.h" -#include "driver/tcpm/ps8xxx_public.h" -#include "driver/tcpm/tcpci.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_EMBEDDED, - /* TCPC is embedded within EC so no i2c config needed */ - .drv = &it8xxx2_tcpm_drv, - /* Alert is active-low, push-pull */ - .flags = 0, - }, - { - /* - * Sub-board: optional PS8745 TCPC+redriver. Behaves the same - * as PS8815. - */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, - }, - .drv = &ps8xxx_tcpm_drv, - /* PS8745 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0, - }, -}; - -/* Vconn control for integrated ITE TCPC */ -void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) -{ - /* Vconn control is only for port 0 */ - if (port) - return; - - if (cc_pin == USBPD_CC_PIN_1) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn), - !!enabled); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn), - !!enabled); -} - -__override bool pd_check_vbus_level(int port, enum vbus_level level) -{ - return sm5803_check_vbus_level(port, level); -} - -/* - * Putting chargers into LPM when in suspend reduces power draw by about 8mW - * per charger, but also seems critical to correct operation in source mode: - * if chargers are not in LPM when a sink is first connected, VBUS sourcing - * works even if the partner is later removed (causing LPM entry) and - * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS - * consistently causes the charger to report (apparently spurious) overcurrent - * failures. - * - * In short, this is important to making things work correctly but we don't - * understand why. - */ -static void board_chargers_suspend(struct ap_power_ev_callback *const cb, - const struct ap_power_ev_data data) -{ - void (*fn)(int chgnum); - - switch (data.event) { - case AP_POWER_SUSPEND: - fn = sm5803_enable_low_power_mode; - break; - case AP_POWER_RESUME: - fn = sm5803_disable_low_power_mode; - break; - default: - LOG_WRN("%s: power event %d is not recognized", __func__, - data.event); - return; - } - - fn(CHARGER_PRIMARY); - if (board_get_charger_chip_count() > 1) - fn(CHARGER_SECONDARY); -} - -static int board_chargers_suspend_init(const struct device *unused) -{ - static struct ap_power_ev_callback cb = { - .handler = board_chargers_suspend, - .events = AP_POWER_SUSPEND | AP_POWER_RESUME, - }; - ap_power_ev_add_callback(&cb); - return 0; -} -SYS_INIT(board_chargers_suspend_init, APPLICATION, 0); - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count()); - int i; - int old_port; - int rv; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - old_port = charge_manager_get_active_charge_port(); - LOG_INF("Charge update: p%d -> p%d", old_port, port); - - /* Check if port is sourcing VBUS. */ - if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) { - LOG_WRN("Skip enable p%d: already sourcing", port); - return EC_ERROR_INVAL; - } - - /* Disable sinking on all ports except the desired one */ - for (i = 0; i < board_get_usb_pd_port_count(); i++) { - if (i == port) - continue; - - if (sm5803_vbus_sink_enable(i, 0)) - /* - * Do not early-return because this can fail during - * power-on which would put us into a loop. - */ - LOG_WRN("p%d: sink path disable failed.", i); - } - - /* Don't enable anything (stop here) if no ports were requested */ - if ((port == CHARGE_PORT_NONE) || (old_port == port)) - return EC_SUCCESS; - - /* - * Stop the charger IC from switching while changing ports. Otherwise, - * we can overcurrent the adapter we're switching to. (crbug.com/926056) - */ - if (old_port != CHARGE_PORT_NONE) - charger_discharge_on_ac(1); - - /* Enable requested charge port. */ - rv = sm5803_vbus_sink_enable(port, 1); - if (rv) - LOG_WRN("p%d: sink path enable failed: code %d", port, rv); - - /* Allow the charger IC to begin/continue switching. */ - charger_discharge_on_ac(0); - - return rv; -} - -uint16_t tcpc_get_alert_status(void) -{ - /* - * TCPC 0 is embedded in the EC and processes interrupts in the chip - * code (it83xx/intc.c). This function only needs to poll port C1 if - * present. - */ - uint16_t status = 0; - int regval; - - /* Is the C1 port present and its IRQ line asserted? */ - if (board_get_usb_pd_port_count() == 2 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - /* - * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if - * it asserted the IRQ. - */ - if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { - if (regval) - status = PD_STATUS_TCPC_ALERT_1; - } - } - - return status; -} - -void pd_power_supply_reset(int port) -{ - int prev_en; - - if (port < 0 || port >= board_get_usb_pd_port_count()) - return; - - prev_en = charger_is_sourcing_otg_power(port); - - /* Disable Vbus */ - charger_enable_otg_power(port, 0); - - /* Discharge Vbus if previously enabled */ - if (prev_en) - sm5803_set_vbus_disch(port, 1); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - enum ec_error_list rv; - - if (port < 0 || port > board_get_usb_pd_port_count()) { - LOG_WRN("Port C%d does not exist, cannot enable VBUS", port); - return EC_ERROR_INVAL; - } - - /* Disable sinking */ - rv = sm5803_vbus_sink_enable(port, 0); - if (rv) { - LOG_WRN("C%d failed to disable sinking: %d", port, rv); - return rv; - } - - /* Disable Vbus discharge */ - rv = sm5803_set_vbus_disch(port, 0); - if (rv) { - LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv); - return rv; - } - - /* Provide Vbus */ - rv = charger_enable_otg_power(port, 1); - if (rv) { - LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv); - return rv; - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv; - const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500; - - rv = charger_set_otg_current_voltage(port, current, 5000); - if (rv != EC_SUCCESS) { - LOG_WRN("Failed to set source ilimit on port %d to %d: %d", - port, current, rv); - } -} - -void board_reset_pd_mcu(void) -{ - /* - * Do nothing. The integrated TCPC for C0 lacks a dedicated reset - * command, and C1 (if present) doesn't have a reset pin connected - * to the EC. - */ -} - -#define INT_RECHECK_US 5000 - -/* C0 interrupt line shared by BC 1.2 and charger */ - -static void check_c0_line(void); -DECLARE_DEFERRED(check_c0_line); - -static void notify_c0_chips(void) -{ - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - sm5803_interrupt(0); -} - -static void check_c0_line(void) -{ - /* - * If line is still being held low, see if there's more to process from - * one of the chips - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { - notify_c0_chips(); - hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); - } -} - -void usb_c0_interrupt(enum gpio_signal s) -{ - /* Cancel any previous calls to check the interrupt line */ - hook_call_deferred(&check_c0_line_data, -1); - - /* Notify all chips using this line that an interrupt came in */ - notify_c0_chips(); - - /* Check the line again in 5ms */ - hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); -} - -/* C1 interrupt line shared by BC 1.2, TCPC, and charger */ -static void check_c1_line(void); -DECLARE_DEFERRED(check_c1_line); - -static void notify_c1_chips(void) -{ - schedule_deferred_pd_interrupt(1); - usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); - /* Charger is handled in board_process_pd_alert */ -} - -static void check_c1_line(void) -{ - /* - * If line is still being held low, see if there's more to process from - * one of the chips. - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - notify_c1_chips(); - hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); - } -} - -void usb_c1_interrupt(enum gpio_signal s) -{ - /* Cancel any previous calls to check the interrupt line */ - hook_call_deferred(&check_c1_line_data, -1); - - /* Notify all chips using this line that an interrupt came in */ - notify_c1_chips(); - - /* Check the line again in 5ms */ - hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); -} - -/* - * Check state of IRQ lines at startup, ensuring an IRQ that happened before - * the EC started up won't get lost (leaving the IRQ line asserted and blocking - * any further interrupts on the port). - * - * Although the PD task will check for pending TCPC interrupts on startup, - * the charger sharing the IRQ will not be polled automatically. - */ -void board_handle_initial_typec_irq(void) -{ - check_c0_line(); - check_c1_line(); -} -/* - * This must run after sub-board detection (which happens in EC main()), - * but isn't depended on by anything else either. - */ -DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST); - -/* - * Handle charger interrupts in the PD task. Not doing so can lead to a priority - * inversion where we fail to respond to TCPC alerts quickly enough because we - * don't get another edge on a shared IRQ until the charger interrupt is cleared - * (or the IRQ is polled again), which happens in the low-priority charger task: - * the high-priority type-C handler is thus blocked on the lower-priority - * charger. - * - * To avoid that, we run charger interrupts at the same priority. - */ -void board_process_pd_alert(int port) -{ - /* - * Port 0 doesn't use an external TCPC, so its interrupts don't need - * this special handling. - */ - if (port == 1 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - sm5803_handle_interrupt(port); - } -} - -int pd_snk_is_vbus_provided(int port) -{ - int chg_det = 0; - - sm5803_get_chg_det(port, &chg_det); - - return chg_det; -} diff --git a/zephyr/projects/nissa/nereid/generated.dtsi b/zephyr/projects/nissa/nereid/generated.dtsi deleted file mode 100644 index bca58c478e..0000000000 --- a/zephyr/projects/nissa/nereid/generated.dtsi +++ /dev/null @@ -1,260 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * This file is auto-generated - do not edit! - */ - -/ { - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { - enum-name = "ADC_PP1050_PROC"; - io-channels = <&adc0 14>; - }; - adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { - enum-name = "ADC_PP3300_S5"; - io-channels = <&adc0 0>; - }; - adc_temp_sensor_1: temp_sensor_1 { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 2>; - }; - adc_temp_sensor_2: temp_sensor_2 { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 3>; - }; - adc_temp_sensor_3: temp_sensor_3 { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 13>; - }; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_acc_int_l: acc_int_l { - gpios = <&gpioc 0 GPIO_INPUT>; - }; - gpio_all_sys_pwrgd: all_sys_pwrgd { - gpios = <&gpiob 7 GPIO_INPUT>; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioh 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_cpu_c10_gate_l: cpu_c10_gate_l { - gpios = <&gpiog 1 GPIO_INPUT>; - }; - gpio_ec_battery_pres_odl: ec_battery_pres_odl { - gpios = <&gpioi 4 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioj 5 GPIO_OUTPUT>; - }; - gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { - gpios = <&gpiok 4 GPIO_ODR_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_entering_rw: ec_entering_rw { - gpios = <&gpioc 7 GPIO_OUTPUT>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { - gpios = <&gpioh 1 GPIO_OUTPUT>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_pch_wake_odl: ec_pch_wake_odl { - gpios = <&gpiob 2 GPIO_ODR_LOW>; - }; - gpio_ec_prochot_odl: ec_prochot_odl { - gpios = <&gpioi 1 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { - gpios = <&gpiol 7 GPIO_OUTPUT>; - }; - gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { - gpios = <&gpiok 7 GPIO_OUTPUT>; - }; - gpio_ec_soc_int_odl: ec_soc_int_odl { - gpios = <&gpiod 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { - gpios = <&gpiod 6 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { - gpios = <&gpiob 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioh 0 GPIO_OUTPUT>; - }; - gpio_ec_soc_rtcrst: ec_soc_rtcrst { - gpios = <&gpiok 2 GPIO_OUTPUT>; - }; - gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { - gpios = <&gpiof 2 GPIO_OUTPUT>; - }; - gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { - gpios = <&gpioe 5 GPIO_ODR_HIGH>; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpioa 6 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_en_kb_bl: en_kb_bl { - gpios = <&gpioj 3 GPIO_OUTPUT>; - enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; - }; - gpio_en_pp3300_s5: en_pp3300_s5 { - gpios = <&gpioc 5 GPIO_OUTPUT>; - enum-name = "GPIO_TEMP_SENSOR_POWER"; - }; - gpio_en_pp5000_pen_x: en_pp5000_pen_x { - gpios = <&gpiob 5 GPIO_OUTPUT>; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpiok 5 GPIO_OUTPUT>; - }; - gpio_en_slp_z: en_slp_z { - gpios = <&gpiok 3 GPIO_OUTPUT>; - }; - gpio_en_usb_a0_vbus: en_usb_a0_vbus { - gpios = <&gpiol 6 GPIO_OUTPUT>; - }; - gpio_en_usb_c0_cc1_vconn: en_usb_c0_cc1_vconn { - gpios = <&gpioh 4 GPIO_OUTPUT>; - }; - gpio_en_usb_c0_cc2_vconn: en_usb_c0_cc2_vconn { - gpios = <&gpioh 6 GPIO_OUTPUT>; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_hdmi_sel: hdmi_sel { - gpios = <&gpioc 6 GPIO_OUTPUT>; - }; - gpio_imu_int_l: imu_int_l { - gpios = <&gpioj 0 GPIO_INPUT>; - }; - gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { - gpios = <&gpioj 4 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiof 3 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_pen_detect_odl: pen_detect_odl { - gpios = <&gpioj 1 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { - gpios = <&gpiod 3 GPIO_INPUT>; - }; - gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { - gpios = <&gpioe 3 GPIO_INPUT>; - }; - gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { - gpios = <&gpioe 1 GPIO_INPUT_PULL_UP>; - }; - gpio_slp_s0_l: slp_s0_l { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpioh 3 GPIO_INPUT>; - }; - gpio_slp_s4_l: slp_s4_l { - gpios = <&gpioi 5 GPIO_INPUT>; - }; - gpio_slp_sus_l: slp_sus_l { - gpios = <&gpiog 2 GPIO_INPUT>; - }; - gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { - gpios = <&gpiof 1 GPIO_OUTPUT>; - enum-name = "GPIO_USB2_ILIM_SEL"; - }; - gpio_sys_rst_odl: sys_rst_odl { - gpios = <&gpiod 1 GPIO_ODR_HIGH>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioa 7 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { - gpios = <&gpiol 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB1_ILIM_SEL"; - }; - gpio_usb_c0_frs: usb_c0_frs { - gpios = <&gpioc 4 GPIO_OUTPUT>; - }; - gpio_usb_c0_int_odl: usb_c0_int_odl { - gpios = <&gpiok 0 GPIO_INPUT_PULL_UP>; - }; - gpio_vccin_aux_vid0: vccin_aux_vid0 { - gpios = <&gpiod 0 GPIO_INPUT>; - }; - gpio_vccin_aux_vid1: vccin_aux_vid1 { - gpios = <&gpiok 1 GPIO_INPUT>; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpioi 6 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpioi 7 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_ec_i2c_eeprom: ec_i2c_eeprom { - i2c-port = <&i2c0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_ec_i2c_batt: ec_i2c_batt { - i2c-port = <&i2c1>; - enum-names = "I2C_PORT_BATTERY"; - }; - i2c_ec_i2c_sensor: ec_i2c_sensor { - i2c-port = <&i2c2>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { - i2c-port = <&i2c4>; - enum-names = "I2C_PORT_USB_C1_TCPC"; - }; - i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { - i2c-port = <&i2c5>; - enum-names = "I2C_PORT_USB_C0_TCPC"; - }; - }; -}; - -&adc0 { - status = "okay"; -}; - -&i2c0 { - status = "okay"; -}; - -&i2c1 { - status = "okay"; -}; - -&i2c2 { - status = "okay"; -}; - -&i2c4 { - status = "okay"; -}; - -&i2c5 { - status = "okay"; -}; diff --git a/zephyr/projects/nissa/nereid/keyboard.dtsi b/zephyr/projects/nissa/nereid/keyboard.dtsi deleted file mode 100644 index 04a620767a..0000000000 --- a/zephyr/projects/nissa/nereid/keyboard.dtsi +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - /* - * Use 324 Hz so that 32Khz clock source is used, - * which is not gated in power saving mode. - */ - pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm0 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm0_gpa0_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/nereid/motionsense.dtsi b/zephyr/projects/nissa/nereid/motionsense.dtsi deleted file mode 100644 index a65bb48fbd..0000000000 --- a/zephyr/projects/nissa/nereid/motionsense.dtsi +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * Interrupt bindings for sensor devices. - */ - bmi3xx-int = &base_accel; - bma4xx-int = &lid_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: base-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - (-1) 0 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bmi323_data: bmi323-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - - bma422_data: bma422-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - * TODO(b/238139272): The first entries of the array must be - * accelerometers,then gyroscope. Fix this dependency in the DTS - * processing which makes the devicetree entries independent. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma422_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi323_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi323_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_imu &int_lid_imu>; - }; -}; diff --git a/zephyr/projects/nissa/nereid/nereid_vif.xml b/zephyr/projects/nissa/nereid/nereid_vif.xml deleted file mode 100644 index 91c8dbe68b..0000000000 --- a/zephyr/projects/nissa/nereid/nereid_vif.xml +++ /dev/null @@ -1,350 +0,0 @@ - - - 3.19 - - USB-IF - VIF Editor - 3.2.4.0 - - Google - Nereid - 1 - 0 - Port Product - Reference Platform - - - - - - - - - 0 - Type-C® - - - DRP - DRP - - Charging Port - - - - - - - - - Revision 3 - - - - - - - 18D1 - 505A - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 15000 mW - Assured - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - FR_Swap not supported - - - - Over-Current Response - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - 0 msec - 3000 mA - - - - - - 45000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 15000 mV - - - - Variable - 4750 mV - 15000 mV - 3000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505A - 0000 - - - - - - - 1 - Type-C® - - - DRP - DRP - - Charging Port - - - - - - - - - Revision 3 - - - - - - - 18D1 - 505A - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 15000 mW - Assured - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - FR_Swap not supported - - - - Over-Current Response - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - 0 msec - 3000 mA - - - - - - 45000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 15000 mV - - - - Variable - 4750 mV - 15000 mV - 3000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505A - 0000 - - \ No newline at end of file diff --git a/zephyr/projects/nissa/nereid/overlay.dtsi b/zephyr/projects/nissa/nereid/overlay.dtsi deleted file mode 100644 index a44a3e01bd..0000000000 --- a/zephyr/projects/nissa/nereid/overlay.dtsi +++ /dev/null @@ -1,400 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_odl; - int-wp = &int_wp_l; - /* - * USB-C: interrupt input. - * I2C pins are on i2c_ec_i2c_sub_usb_c1 - */ - gpio-usb-c1-int-odl = &gpio_sb_1; - /* - * USB-A: VBUS enable output - * LTE: power enable output - */ - gpio-en-usb-a1-vbus = &gpio_sb_2; - /* - * HDMI: power enable output, HDMI enable output, - * and HPD input - */ - gpio-en-rails-odl = &gpio_sb_1; - gpio-hdmi-en-odl = &gpio_sb_4; - gpio-hpd-odl = &gpio_sb_3; - /* - * Enable S5 rails for LTE sub-board - */ - gpio-en-sub-s5-rails = &gpio_sb_2; - }; - - - ec-console { - compatible = "ec-console"; - disabled = "events", "lpc", "hostcmd"; - }; - - batteries { - default_battery: smp { - compatible = "smp,l20m3pg0", "battery-smart"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_power_button - &int_lid_open - >; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_vol_down: vol_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_vol_up: vol_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_imu: ec_imu { - irq-pin = <&gpio_imu_int_l>; - flags = ; - handler = "bmi3xx_interrupt"; - }; - int_lid_imu: lid_imu { - irq-pin = <&gpio_acc_int_l>; - flags = ; - handler = "bma4xx_interrupt"; - }; - int_usb_c0: usb_c0 { - irq-pin = <&gpio_usb_c0_int_odl>; - flags = ; - handler = "usb_c0_interrupt"; - }; - int_usb_c1: usb_c1 { - irq-pin = <&gpio_sb_1>; - flags = ; - handler = "usb_c1_interrupt"; - }; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = <&gpioc 3 0>, - <&gpiod 4 0>, - <&gpiod 7 0>, - <&gpioh 2 0>, - <&gpioj 7 0>, - <&gpiol 4 0>; - }; - - named-gpios { - /* - * EC doesn't take any specific action on CC/SBU disconnect due to - * fault, but this definition is useful for hardware testing. - */ - gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl { - gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>; - }; - - gpio_sb_1: sb_1 { - gpios = <&gpioe 6 0>; - no-auto-init; - }; - gpio_sb_2: sb_2 { - gpios = <&gpiof 0 0>; - no-auto-init; - }; - - gpio_sb_3: sb_3 { - gpios = <&gpioe 7 0>; - no-auto-init; - }; - gpio_sb_4: sb_4 { - gpios = <&gpioe 0 0>; - no-auto-init; - }; - }; - - temp_memory: memory { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_1>; - }; - temp_charger: charger { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_2>; - }; - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_3>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - memory { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_memory>; - }; - charger { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_charger>; - }; - ambient { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_ambient>; - }; - }; - - usba { - compatible = "cros-ec,usba-port-enable-pins"; - /* - * sb_2 is only configured as GPIO when USB-A1 is present, - * but it's still safe to control when disabled. - * - * ILIM_SEL pins are referred to by legacy enum name, - * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on - * sub-boards that don't have USB-A so is safe to control - * regardless of system configuration. - */ - enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; - status = "okay"; - }; - - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - chg = <&chg_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - chg = <&chg_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; - }; - usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - tcpci_mux_1: tcpci-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; - }; -}; - -&gpio_acc_int_l { - gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; -}; -&gpio_imu_int_l { - gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; -}; -&gpio_vccin_aux_vid0 { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; -}; -&gpio_vccin_aux_vid1 { - gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; -}; - -&gpio_ec_prochot_odl { - gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; -}; - -&thermistor_3V3_51K1_47K_4050B { - status = "okay"; -}; - -&adc_ec_vsense_pp3300_s5 { - /* - * Voltage divider on input has 47k upper and 220k lower legs with 3 V - * full-scale reading on the ADC. Apply the largest possible multiplier - * (without overflowing int32) to get the best possible approximation - * of the actual ratio, but derate by a factor of two to ensure - * unexpectedly high values won't overflow. - */ - mul = <(715828 / 2)>; - div = <(589820 / 2)>; -}; - -&adc0 { - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch2_gpi2_default - &adc0_ch3_gpi3_default - &adc0_ch13_gpl0_default - &adc0_ch14_gpl1_default>; - pinctrl-names = "default"; -}; - -&pinctrl { - i2c4_clk_gpe0_sleep: i2c4_clk_gpe0_sleep { - pinmuxs = <&pinctrle 0 IT8XXX2_ALT_DEFAULT>; - }; - i2c4_data_gpe7_sleep: i2c4_data_gpe7_sleep { - pinmuxs = <&pinctrle 7 IT8XXX2_ALT_DEFAULT>; - }; - i2c2_clk_gpf6_default: i2c2_clk_gpf6_default { - gpio-voltage = "1v8"; - }; - i2c2_data_gpf7_default: i2c2_data_gpf7_default { - gpio-voltage = "1v8"; - }; -}; - -&i2c0 { - label = "I2C_EEPROM"; - clock-frequency = ; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; - pinctrl-0 = <&i2c0_clk_gpb3_default - &i2c0_data_gpb4_default>; - pinctrl-names = "default"; -}; - -&i2c1 { - label = "I2C_BATTERY"; - clock-frequency = <50000>; - pinctrl-0 = <&i2c1_clk_gpc1_default - &i2c1_data_gpc2_default>; - pinctrl-names = "default"; -}; - -&i2c2 { - label = "I2C_SENSOR"; - clock-frequency = ; - pinctrl-0 = <&i2c2_clk_gpf6_default - &i2c2_data_gpf7_default>; - pinctrl-names = "default"; -}; - -&i2c4 { - label = "I2C_SUB_C1_TCPC"; - clock-frequency = ; - pinctrl-0 = <&i2c4_clk_gpe0_default - &i2c4_data_gpe7_default>; - pinctrl-1 = <&i2c4_clk_gpe0_sleep - &i2c4_data_gpe7_sleep>; - pinctrl-names = "default", "sleep"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port1: sm5803@32 { - compatible = "siliconmitus,sm5803"; - status = "okay"; - reg = <0x32>; - }; -}; - -&i2c_ec_i2c_sub_usb_c1 { - /* - * Dynamic speed setting is used for AP-controlled firmware update - * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order - * to use more efficient window programming, then sets it back when - * done. - */ - dynamic-speed; -}; - -&i2c5 { - label = "I2C_USB_C0_TCPC"; - clock-frequency = ; - pinctrl-0 = <&i2c5_clk_gpa4_default - &i2c5_data_gpa5_default>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port0: sm5803@32 { - compatible = "siliconmitus,sm5803"; - status = "okay"; - reg = <0x32>; - }; -}; - -&usbpd0 { - status = "okay"; -}; diff --git a/zephyr/projects/nissa/nereid/power_signals.dtsi b/zephyr/projects/nissa/nereid/power_signals.dtsi deleted file mode 100644 index 8affae03b1..0000000000 --- a/zephyr/projects/nissa/nereid/power_signals.dtsi +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <10>; - all-sys-pwrgd-timeout = <20>; - }; - - pwr-en-pp5000-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP5000_S5 enable output to regulator"; - enum-name = "PWR_EN_PP5000_A"; - gpios = <&gpiok 5 0>; - output; - }; - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpioc 5 0>; - output; - }; - pwr-pg-ec-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpioe 1 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioh 0 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpioe 4 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - gpios = <&gpioh 3 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-sus-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_SUS_L input from PCH"; - enum-name = "PWR_SLP_SUS"; - gpios = <&gpiog 2 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-ec-soc-dsw-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "DSW_PWROK output to PCH"; - enum-name = "PWR_EC_SOC_DSW_PWROK"; - gpios = <&gpiol 7 0>; - output; - }; - pwr-vccst-pwrgd-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VCCST_PWRGD output to PCH"; - enum-name = "PWR_VCCST_PWRGD"; - gpios = <&gpioe 5 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; - output; - }; - pwr-imvp9-vrrdy-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VRRDY input from IMVP9"; - enum-name = "PWR_IMVP9_VRRDY"; - gpios = <&gpioj 4 0>; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpiod 6 GPIO_OPEN_DRAIN>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpiof 2 0>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpiod 1 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - /* - * This is a board level signal, since this - * signal needs some special processing. - */ - compatible = "intel,ap-pwrseq-external"; - dbg-label = "Combined all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - }; - pwr-adc-pp3300 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP3300_PROC"; - enum-name = "PWR_DSW_PWROK"; - trigger-high = <&vcmp0>; - trigger-low = <&vcmp1>; - }; - pwr-adc-pp1p05 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP1P05_PROC"; - enum-name = "PWR_PG_PP1P05"; - trigger-high = <&vcmp2>; - trigger-low = <&vcmp3>; - }; - -}; - -/* - * Because the power signals directly reference the GPIOs, - * the correspinding named-gpios need to have no-auto-init set. - */ -&gpio_ec_soc_dsw_pwrok { - no-auto-init; -}; -&gpio_ec_soc_pch_pwrok_od { - no-auto-init; -}; -&gpio_ec_soc_rsmrst_l { - no-auto-init; -}; -&gpio_ec_soc_sys_pwrok { - no-auto-init; -}; -&gpio_ec_soc_vccst_pwrgd_od { - no-auto-init; -}; -&gpio_en_pp3300_s5 { - no-auto-init; -}; -&gpio_en_pp5000_s5 { - no-auto-init; -}; -&gpio_imvp91_vrrdy_od { - no-auto-init; -}; -&gpio_rsmrst_pwrgd_l { - no-auto-init; -}; -&gpio_slp_s0_l { - no-auto-init; -}; -&gpio_slp_s3_l { - no-auto-init; -}; -&gpio_slp_sus_l { - no-auto-init; -}; -&gpio_sys_rst_odl { - no-auto-init; -}; -&vcmp0 { - status = "okay"; - scan-period = ; - comparison = ; - /* - * This is 90% of nominal voltage considering voltage - * divider on ADC input. - */ - threshold-mv = <2448>; - io-channels = <&adc0 0>; -}; -&vcmp1 { - status = "okay"; - scan-period = ; - comparison = ; - threshold-mv = <2448>; - io-channels = <&adc0 0>; -}; -&vcmp2 { - status = "okay"; - scan-period = ; - comparison = ; - /* Setting at 90% of nominal voltage */ - threshold-mv = <945>; - io-channels = <&adc0 14>; -}; -&vcmp3 { - status = "okay"; - scan-period = ; - comparison = ; - threshold-mv = <945>; - io-channels = <&adc0 14>; -}; diff --git a/zephyr/projects/nissa/nereid/project.conf b/zephyr/projects/nissa/nereid/project.conf deleted file mode 100644 index 75a5faba5d..0000000000 --- a/zephyr/projects/nissa/nereid/project.conf +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_NEREID=y - -# Ensure recovery key combination (esc+refresh+power) is reliable: b/236580049 -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y - -# Sensor drivers -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 - -# No fan supported, and tach is default-enabled -CONFIG_TACH_IT8XXX2=n diff --git a/zephyr/projects/nissa/nereid/project.overlay b/zephyr/projects/nissa/nereid/project.overlay deleted file mode 100644 index 0aceac1c47..0000000000 --- a/zephyr/projects/nissa/nereid/project.overlay +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../cbi.dtsi" - -#include "generated.dtsi" -#include "keyboard.dtsi" -#include "motionsense.dtsi" -#include "overlay.dtsi" -#include "power_signals.dtsi" -#include "pwm_leds.dtsi" diff --git a/zephyr/projects/nissa/nereid/pwm_leds.dtsi b/zephyr/projects/nissa/nereid/pwm_leds.dtsi deleted file mode 100644 index aa4a76b271..0000000000 --- a/zephyr/projects/nissa/nereid/pwm_leds.dtsi +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm1 1 PWM_HZ(1296) PWM_POLARITY_INVERTED>, - <&pwm2 2 PWM_HZ(1296) PWM_POLARITY_INVERTED>, - <&pwm3 3 PWM_HZ(1296) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0>; - - /**/ - color-map-red = <100 0 0>; - color-map-green = < 0 100 0>; - color-map-blue = < 0 0 100>; - color-map-yellow = < 0 50 50>; - color-map-white = <100 100 100>; - color-map-amber = <100 15 0>; - - brightness-range = <100 100 100 0 0 0>; - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_BATTERY_LED"; - }; - }; -}; - -&pwm1 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm1_gpa1_default>; - pinctrl-names = "default"; -}; - -&pwm2 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm2_gpa2_default>; - pinctrl-names = "default"; -}; - -&pwm3 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm3_gpa3_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/nereid/src/charger.c b/zephyr/projects/nissa/nereid/src/charger.c deleted file mode 100644 index 181e9a61fd..0000000000 --- a/zephyr/projects/nissa/nereid/src/charger.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery.h" -#include "charger.h" -#include "console.h" -#include "driver/charger/sm5803.h" -#include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -int extpower_is_present(void) -{ - int port; - int rv; - bool acok; - - for (port = 0; port < board_get_usb_pd_port_count(); port++) { - rv = sm5803_is_acok(port, &acok); - if ((rv == EC_SUCCESS) && acok) - return 1; - } - - return 0; -} - -/* - * Nereid does not have a GPIO indicating whether extpower is present, - * so detect using the charger(s). - */ -__override void board_check_extpower(void) -{ - static int last_extpower_present; - int extpower_present = extpower_is_present(); - - if (last_extpower_present ^ extpower_present) - extpower_handle_update(extpower_present); - - last_extpower_present = extpower_present; -} - -__override void board_hibernate(void) -{ - /* Shut down the chargers */ - if (board_get_usb_pd_port_count() == 2) - sm5803_hibernate(CHARGER_SECONDARY); - sm5803_hibernate(CHARGER_PRIMARY); - LOG_INF("Charger(s) hibernated"); - cflush(); -} diff --git a/zephyr/projects/nissa/nereid/src/hdmi.c b/zephyr/projects/nissa/nereid/src/hdmi.c deleted file mode 100644 index 7e5708c6eb..0000000000 --- a/zephyr/projects/nissa/nereid/src/hdmi.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include "nissa_hdmi.h" - -__override void nissa_configure_hdmi_power_gpios(void) -{ - /* - * Nereid versions before 2 need hdmi-en-odl to be - * pulled down to enable VCC on the HDMI port, but later - * versions (and other boards) disconnect this so - * the port's VCC directly follows en-rails-odl. Only - * configure the GPIO if needed, to save power. - */ - uint32_t board_version = 0; - - /* CBI errors ignored, will configure the pin */ - cbi_get_board_version(&board_version); - if (board_version < 2) { - nissa_configure_hdmi_vcc(); - } - - /* Still always need core rails controlled */ - nissa_configure_hdmi_rails(); -} diff --git a/zephyr/projects/nissa/nereid/src/keyboard.c b/zephyr/projects/nissa/nereid/src/keyboard.c deleted file mode 100644 index b69bb4da33..0000000000 --- a/zephyr/projects/nissa/nereid/src/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config nereid_kb_legacy = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_FORWARD, /* T2 */ - TK_REFRESH, /* T3 */ - TK_FULLSCREEN, /* T4 */ - TK_OVERVIEW, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &nereid_kb_legacy; -} diff --git a/zephyr/projects/nissa/nereid/src/usbc.c b/zephyr/projects/nissa/nereid/src/usbc.c deleted file mode 100644 index 48f7cfd9cb..0000000000 --- a/zephyr/projects/nissa/nereid/src/usbc.c +++ /dev/null @@ -1,393 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "charge_state_v2.h" -#include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" -#include "driver/charger/sm5803.h" -#include "driver/tcpm/it83xx_pd.h" -#include "driver/tcpm/ps8xxx_public.h" -#include "driver/tcpm/tcpci.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_EMBEDDED, - /* TCPC is embedded within EC so no i2c config needed */ - .drv = &it8xxx2_tcpm_drv, - /* Alert is active-low, push-pull */ - .flags = 0, - }, - { - /* - * Sub-board: optional PS8745 TCPC+redriver. Behaves the same - * as PS8815. - */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, - }, - .drv = &ps8xxx_tcpm_drv, - /* PS8745 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0, - }, -}; - -/* Vconn control for integrated ITE TCPC */ -void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) -{ - /* Vconn control is only for port 0 */ - if (port) - return; - - if (cc_pin == USBPD_CC_PIN_1) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn), - !!enabled); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn), - !!enabled); -} - -__override bool pd_check_vbus_level(int port, enum vbus_level level) -{ - return sm5803_check_vbus_level(port, level); -} - -/* - * Putting chargers into LPM when in suspend reduces power draw by about 8mW - * per charger, but also seems critical to correct operation in source mode: - * if chargers are not in LPM when a sink is first connected, VBUS sourcing - * works even if the partner is later removed (causing LPM entry) and - * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS - * consistently causes the charger to report (apparently spurious) overcurrent - * failures. - * - * In short, this is important to making things work correctly but we don't - * understand why. - */ -static void board_chargers_suspend(struct ap_power_ev_callback *const cb, - const struct ap_power_ev_data data) -{ - void (*fn)(int chgnum); - - switch (data.event) { - case AP_POWER_SUSPEND: - fn = sm5803_enable_low_power_mode; - break; - case AP_POWER_RESUME: - fn = sm5803_disable_low_power_mode; - break; - default: - LOG_WRN("%s: power event %d is not recognized", __func__, - data.event); - return; - } - - fn(CHARGER_PRIMARY); - if (board_get_charger_chip_count() > 1) - fn(CHARGER_SECONDARY); -} - -static int board_chargers_suspend_init(const struct device *unused) -{ - static struct ap_power_ev_callback cb = { - .handler = board_chargers_suspend, - .events = AP_POWER_SUSPEND | AP_POWER_RESUME, - }; - ap_power_ev_add_callback(&cb); - return 0; -} -SYS_INIT(board_chargers_suspend_init, APPLICATION, 0); - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count()); - int i; - int old_port; - int rv; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - old_port = charge_manager_get_active_charge_port(); - LOG_INF("Charge update: p%d -> p%d", old_port, port); - - /* Check if port is sourcing VBUS. */ - if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) { - LOG_WRN("Skip enable p%d: already sourcing", port); - return EC_ERROR_INVAL; - } - - /* Disable sinking on all ports except the desired one */ - for (i = 0; i < board_get_usb_pd_port_count(); i++) { - if (i == port) - continue; - - if (sm5803_vbus_sink_enable(i, 0)) - /* - * Do not early-return because this can fail during - * power-on which would put us into a loop. - */ - LOG_WRN("p%d: sink path disable failed.", i); - } - - /* Don't enable anything (stop here) if no ports were requested */ - if ((port == CHARGE_PORT_NONE) || (old_port == port)) - return EC_SUCCESS; - - /* - * Stop the charger IC from switching while changing ports. Otherwise, - * we can overcurrent the adapter we're switching to. (crbug.com/926056) - */ - if (old_port != CHARGE_PORT_NONE) - charger_discharge_on_ac(1); - - /* Enable requested charge port. */ - rv = sm5803_vbus_sink_enable(port, 1); - if (rv) - LOG_WRN("p%d: sink path enable failed: code %d", port, rv); - - /* Allow the charger IC to begin/continue switching. */ - charger_discharge_on_ac(0); - - return rv; -} - -uint16_t tcpc_get_alert_status(void) -{ - /* - * TCPC 0 is embedded in the EC and processes interrupts in the chip - * code (it83xx/intc.c). This function only needs to poll port C1 if - * present. - */ - uint16_t status = 0; - int regval; - - /* Is the C1 port present and its IRQ line asserted? */ - if (board_get_usb_pd_port_count() == 2 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - /* - * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if - * it asserted the IRQ. - */ - if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { - if (regval) - status = PD_STATUS_TCPC_ALERT_1; - } - } - - return status; -} - -void pd_power_supply_reset(int port) -{ - int prev_en; - - if (port < 0 || port >= board_get_usb_pd_port_count()) - return; - - prev_en = charger_is_sourcing_otg_power(port); - - /* Disable Vbus */ - charger_enable_otg_power(port, 0); - - /* Discharge Vbus if previously enabled */ - if (prev_en) - sm5803_set_vbus_disch(port, 1); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - enum ec_error_list rv; - - if (port < 0 || port > board_get_usb_pd_port_count()) { - LOG_WRN("Port C%d does not exist, cannot enable VBUS", port); - return EC_ERROR_INVAL; - } - - /* Disable sinking */ - rv = sm5803_vbus_sink_enable(port, 0); - if (rv) { - LOG_WRN("C%d failed to disable sinking: %d", port, rv); - return rv; - } - - /* Disable Vbus discharge */ - rv = sm5803_set_vbus_disch(port, 0); - if (rv) { - LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv); - return rv; - } - - /* Provide Vbus */ - rv = charger_enable_otg_power(port, 1); - if (rv) { - LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv); - return rv; - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv; - const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500; - - rv = charger_set_otg_current_voltage(port, current, 5000); - if (rv != EC_SUCCESS) { - LOG_WRN("Failed to set source ilimit on port %d to %d: %d", - port, current, rv); - } -} - -void board_reset_pd_mcu(void) -{ - /* - * Do nothing. The integrated TCPC for C0 lacks a dedicated reset - * command, and C1 (if present) doesn't have a reset pin connected - * to the EC. - */ -} - -#define INT_RECHECK_US 5000 - -/* C0 interrupt line shared by BC 1.2 and charger */ - -static void check_c0_line(void); -DECLARE_DEFERRED(check_c0_line); - -static void notify_c0_chips(void) -{ - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - sm5803_interrupt(0); -} - -static void check_c0_line(void) -{ - /* - * If line is still being held low, see if there's more to process from - * one of the chips - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { - notify_c0_chips(); - hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); - } -} - -void usb_c0_interrupt(enum gpio_signal s) -{ - /* Cancel any previous calls to check the interrupt line */ - hook_call_deferred(&check_c0_line_data, -1); - - /* Notify all chips using this line that an interrupt came in */ - notify_c0_chips(); - - /* Check the line again in 5ms */ - hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); -} - -/* C1 interrupt line shared by BC 1.2, TCPC, and charger */ -static void check_c1_line(void); -DECLARE_DEFERRED(check_c1_line); - -static void notify_c1_chips(void) -{ - schedule_deferred_pd_interrupt(1); - usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); - /* Charger is handled in board_process_pd_alert */ -} - -static void check_c1_line(void) -{ - /* - * If line is still being held low, see if there's more to process from - * one of the chips. - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - notify_c1_chips(); - hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); - } -} - -void usb_c1_interrupt(enum gpio_signal s) -{ - /* Cancel any previous calls to check the interrupt line */ - hook_call_deferred(&check_c1_line_data, -1); - - /* Notify all chips using this line that an interrupt came in */ - notify_c1_chips(); - - /* Check the line again in 5ms */ - hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); -} - -/* - * Check state of IRQ lines at startup, ensuring an IRQ that happened before - * the EC started up won't get lost (leaving the IRQ line asserted and blocking - * any further interrupts on the port). - * - * Although the PD task will check for pending TCPC interrupts on startup, - * the charger sharing the IRQ will not be polled automatically. - */ -void board_handle_initial_typec_irq(void) -{ - check_c0_line(); - if (board_get_usb_pd_port_count() == 2) - check_c1_line(); -} -/* - * This must run after sub-board detection (which happens in EC main()), - * but isn't depended on by anything else either. - */ -DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST); - -/* - * Handle charger interrupts in the PD task. Not doing so can lead to a priority - * inversion where we fail to respond to TCPC alerts quickly enough because we - * don't get another edge on a shared IRQ until the charger interrupt is cleared - * (or the IRQ is polled again), which happens in the low-priority charger task: - * the high-priority type-C handler is thus blocked on the lower-priority - * charger. - * - * To avoid that, we run charger interrupts at the same priority. - */ -void board_process_pd_alert(int port) -{ - /* - * Port 0 doesn't use an external TCPC, so its interrupts don't need - * this special handling. - */ - if (port == 1 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - sm5803_handle_interrupt(port); - } -} - -int pd_snk_is_vbus_provided(int port) -{ - int chg_det = 0; - - sm5803_get_chg_det(port, &chg_det); - - return chg_det; -} diff --git a/zephyr/projects/nissa/nissa.csv b/zephyr/projects/nissa/nissa.csv deleted file mode 100644 index 45b73ea229..0000000000 --- a/zephyr/projects/nissa/nissa.csv +++ /dev/null @@ -1,122 +0,0 @@ -Signal Name,Subsystem,Description,DIR,Int,I/O Type,Internal PU,I/O Voltage,ICs attached,NPCX993 (Nivviks),NPCX993 (Nirwen),IT81302 (Nereid),Type,Enum,SW Notes,HW Notes -ESPI_SOC_CLK,ESPI,ESPI clock,IN,no,--,N,1.80 V,,M1,M1,L1,OTHER,,, -ESPI_SOC_CS_EC_L,ESPI,ESPI chip select,IN,F,--,N,1.80 V,,L2,L2,J2,OTHER,,, -ESPI_SOC_D0_EC,ESPI,ESPI DATA0,I/O,,TTL,N,1.80 V,,H1,H1,L2,OTHER,,, -ESPI_SOC_D1_EC,ESPI,ESPI DATA1,I/O,,TTL,N,1.80 V,,J1,J1,K1,OTHER,,, -ESPI_SOC_D2_EC,ESPI,ESPI DATA2,I/O,,TTL,N,1.80 V,,K1,K1,K2,OTHER,,, -ESPI_SOC_D3_EC,ESPI,ESPI DATA3,I/O,,TTL,N,1.80 V,,L1,L1,J1,OTHER,,, -ESPI_SOC_RST_EC_L,ESPI,ESPI reset,IN,F,,N,1.80 V,,K3,K3,R5,OTHER,,, -ESPI_EC_ALERT_SOC_L,ESPI,ESPI Alert,OUT,,TTL,N,1.80 V,,L3,L3,H1,OTHER,,, -GSC_EC_PWR_BTN_ODL,GSC,Power Button input from GSC,IN,both,--,Y,3.30 V,,E7,E7,B13,INPUT_PU,GPIO_POWER_BUTTON_L,GPIO00, -EC_RST_ODL,GSC,Reset signal for EC from GSC,IN,no,--,N,3.30 V,GSC,K6,K6,M2,OTHER,,, -EC_GSC_PACKET_MODE,GSC,Wakes/interrupts GSC and (maybe) vice-versa,I/O,both,--,N,3.30 V,,J6,J6,F9,OUTPUT,GPIO_PACKET_MODE_EN,, -EC_I2C_EEPROM_SCL,I2C,"I2C clock for CBI, reading INAs, programming EC (ITE only)",I/O,,OD,N,3.30 V,"EEPROMs, INAs",C12,C12,A5,I2C_CLOCK,I2C_PORT_EEPROM,, -EC_I2C_EEPROM_SDA,I2C,"I2C data for CBI, reading INAs, programming EC (ITE only)",I/O,,OD,N,3.30 V,"EEPROMs, INAs",B12,B12,B3,I2C_DATA,,, -EC_I2C_BATT_SDA,I2C,I2C data for battery pack,I/O,,OD,N,3.30 V,Battery Pack,K10,K10,A3,I2C_DATA,,, -EC_I2C_BATT_SCL,I2C,I2C clock for battery pack,I/O,,OD,N,3.30 V,Battery Pack,J10,J10,A4,I2C_CLOCK,I2C_PORT_BATTERY,, -EC_I2C_SENSOR_SCL,I2C,I2C clock for sensors,I/O,,OD,N,3.30 V,"IMU, accel, lid accel, kb bl",K8,K8,C2,I2C_CLOCK,I2C_PORT_SENSOR,, -EC_I2C_SENSOR_SDA,I2C,I2C data for sensors,I/O,,OD,N,3.30 V,"IMU, accel, lid accel, kb bl",K7,K7,D2,I2C_DATA,,, -EC_I2C_USB_C0_SDA,I2C,I2C clock for USB-C C0 and USB-A A0 port ICs,I/O,,OD,N,3.30 V,"TCPC, BC1.2, Charger",F9,F9,K7,I2C_DATA,,, -EC_I2C_USB_C0_SCL,I2C,I2C data for USB-C C0 and USB-A A0 port ICs,I/O,,OD,N,3.30 V,"TCPC, BC1.2, Charger",F8,F8,L7,I2C_CLOCK,I2C_PORT_USB_C0_TCPC,, -EC_I2C_SUB_USB_C1_SDA,I2C,I2C clock for USB-C C1 and USB-A A1 port ICs (HDMI: HDMI_EN_SUB_ODL - enable HDMI retimer/output/active low),I/O,,OD,N,3.30 V,"TCPC, BC1.2, Charger",E9,E9,R4,I2C_DATA,,, -EC_I2C_SUB_USB_C1_SCL,I2C,"I2C data for USB-C C1 and USB-A A1 port ICs (HDMI_HPD_SUB_ODL, hot-plug detection/input (interrupt)/active low)",I/O,,OD,N,3.30 V,"TCPC, BC1.2, Charger",E8,E8,P3,I2C_CLOCK,I2C_PORT_USB_C1_TCPC,, -EC_KSI_00,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,A2,A2,K15,OTHER,,, -KSI_01,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,A3,A3,K14,OTHER,,, -EC_KSI_02,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,A4,A4,K10,OTHER,,, -EC_KSI_03,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,B3,B3,J15,OTHER,,,Vivaldi Support -KSI_04,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,B4,B4,J10,OTHER,,, -KSI_05,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,C3,C3,J11,OTHER,,, -KSI_06,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,C4,C4,J14,OTHER,,, -KSI_07,Keyboard,Keyboard Input,IN,no,--,Y,3.30 V,,C5,C5,H10,OTHER,,, -KSO_00,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B5,B5,R9,OTHER,,, -KSO_01,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B6,B6,K8,OTHER,,, -EC_KSO_02_INV,Keyboard,Keyboard Output,OUT,,TTL,N,3.30 V,,B7,B7,P10,OUTPUT_L,,KEYBOARD_COL2_INVERTED, -KSO_03,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B8,B8,R10,OTHER,,, -KSO_04,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C7,C7,L9,OTHER,,, -KSO_05,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C6,C6,K9,OTHER,,, -KSO_06,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C8,C8,P11,OTHER,,, -KSO_07,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B9,B9,R11,OTHER,,, -KSO_08,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C9,C9,P12,OTHER,,, -KSO_09,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C10,C10,L10,OTHER,,, -KSO_10,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B11,B11,P13,OTHER,,, -KSO_11,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,B10,B10,P14,OTHER,,, -KSO_12,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,C11,C11,N14,OTHER,,, -KSO_13,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,D11,D11,M15,OTHER,,,Required only for NUM PAD -KSO_14,Keyboard,Keyboard Output,OUT,,OD,N,3.30 V,,D6,D6,M14,OTHER,,,Required only for NUM PAD -EN_KB_BL,MISC,Enable Keyboard backlight,OUT,,TTL,N,3.30 V,,G11,G11,D14,OUTPUT,GPIO_EN_KEYBOARD_BACKLIGHT,, -VOLDN_BTN_ODL,MISC,Volume down signal,IN,both,--,Y,3.30 V,Button,F12,E11,G15,INPUT_PU,GPIO_VOLUME_DOWN_L,, -VOLUP_BTN_ODL,MISC,Volume up signal,IN,both,--,Y,3.30 V,Button,E11,F12,F14,INPUT_PU,GPIO_VOLUME_UP_L,, -LID_OPEN,MISC,Indicator from lid switch that lid is open,IN,both,--,N,3.30 V,,G7,G7,A11,INPUT,GPIO_LID_OPEN,, -TABLET_MODE_L,MISC,Indicator from lid switch that lid is flipped all the way around,IN,both,--,N,3.30 V,,M12,M12,L8,INPUT,GPIO_TABLET_MODE_L,,Not required to connect to EC? -IMU_INT_L,MISC,Interrupt from base intertial measurement unit,IN,falling,,N,1.80 V,IMU,M2,M2,F15,INPUT,,, -ACC_INT_L,MISC,Interrupt from lid accel (only in convertibles),IN,falling,,N,1.80 V,ACC,G10,G10,E2,INPUT,,,Not required from Dedede? -EC_WP_ODL,MISC,Write protection status from GSC,IN,no,--,N,3.30 V,GSC,L12,L12,R8,INPUT_L,,, -EC_EDP_BL_EN_OD,MISC,EC override of backlight enable,OUT,,OD,N,3.30 V,,E10,E10,R15,OUTPUT_ODR,GPIO_ENABLE_BACKLIGHT,, -TEMP_SENSOR_1,MISC,NTC 1 - near memory,IN,no,ADC,N,ANA,,F2,F2,H15,ADC,ADC_TEMP_SENSOR_1,, -TEMP_SENSOR_2,MISC,NTC 2 - near chassis hot spot,IN,no,ADC,N,ANA,,E3,E3,G10,ADC,ADC_TEMP_SENSOR_2,, -TEMP_SENSOR_3,MISC,NTC 3 - Ambient/skin temp,IN,no,ADC,N,ANA,,,F4,A13,ADC,ADC_TEMP_SENSOR_3,, -USB_C0_INT_ODL,MISC,Interrupt for all ICs for Type-C port 0,IN,,--,Y,3.30 V,,E6,E6,P1,INPUT_PU,,, -USB_C0_PROT_FAULT_ODL,MISC,Fault out of the USB C0 protection IC,IN,falling,OD,Y,3.30 V,,,#N/A,,,,, -"SUB_USB_C1_INT_ODL -(HDMI: EN_SUB_RAILS_ODL)",MISC,"Interrupt for all ICs for Type-C port 1 or the sub-board -HDMI: Enable 5V power rail/output/active low",IN,,--,Y,3.30 V,,F7,F7,N2,OTHER,,, -HDMI_SEL,MISC,Configures AUX to be HDMI DDC,OUT,,TTL,N,3.30 V,,D10,D10,F2,OUTPUT,,, -CCD_MODE_ODL,MISC,Indicates whether H1 is using SBU lines for debug. Also can trigger CCD if the EC decides to.,I/O,falling,--/OD,N,3.30 V,GSC,A12,A12,B9,INPUT,GPIO_CCD_MODE_ODL,, -EC_BATTERY_PRES_ODL,MISC,or BATT_TEMP - indication of battery presence,IN,,--,N,3.30 V,Battery pack,K12,K12,G14,INPUT,GPIO_BATT_PRES_ODL,, -EC_ENTERING_RW,MISC,Indicate when EC is transitioning to RW code,OUT,,TTL,N,3.30 V,GSC,D9,D9,N1,OUTPUT,GPIO_ENTERING_RW,, -EN_USB_A0_VBUS,MISC,,OUT,,TTL,N,3.30 V,,K9,K9,B1,OUTPUT,,, -USB_A0_ILIMIT_SDP,MISC,,OUT,,TTL,N,3.30 V,,J8,J8,A1,OUTPUT,GPIO_USB1_ILIM_SEL,??, -EN_SUB_USB_A1_VBUS,MISC,,OUT,,TTL,N,3.30 V,,A9,A9,B12,OTHER,,??, -SUB_USB_A1_ILIMIT_SDP,MISC,,OUT,,TTL,N,3.30 V,,A10,A10,A12,OUTPUT,GPIO_USB2_ILIM_SEL,??, -PWM_FAN,MISC,,OUT,,PWM,N,3.30 V,,,J7,,PWM,,, -EC_FAN_TACH,MISC,,IN,,,,5.00 V,,,G5,,TACH,,, -EN_PP5000_FAN_X,MISC,,OUT,,TTL,N,3.30 V,,,J2,,OUTPUT,,, -EC_CBI_WP,MISC,Updated EC WP method,OUT,,TTL,N,3.30 V,,H5,H5,D15,OUTPUT,,cbi_latch_eeprom_wp, -IMVP91_VRRDY_OD,POWER SEQUENCE,,IN,,,,,,E2,E2,C14,INPUT,,, -EC_SOC_SYS_PWROK,POWER SEQUENCE,"Generic power good input to PCH (platform specific), system ready to exit reset.",OUT,,TTL,N,3.30 V,SOC,C1,C1,B11,OUTPUT,,PCH_PWROK, -EN_SLP_Z,POWER SEQUENCE,Enable Sleep State (Active high). For ITE only.,OUT,,TTL,N,3.30 V,,F3,F3,R3,OUTPUT,,, -EN_PP5000_S5,POWER SEQUENCE,"Enable PP5000_S5. Figure 523, states this has to come after 3.3V , why?",OUT,,TTL,N,3.30 V,,E5,E5,R14,OUTPUT,,, -EN_PP3300_S5,POWER SEQUENCE,Enable PP3300_S5.,OUT,,TTL,N,3.30 V,,L9,L9,K11,OUTPUT,GPIO_TEMP_SENSOR_POWER,, -EC_SOC_DSW_PWROK,POWER SEQUENCE,DSW Power is OK to AP (diode logic with PP3300_PG),OUT,,TTL,N,3.30 V,SOC,K4,K4,C1,OUTPUT,,, -EC_SOC_RSMRST_L,POWER SEQUENCE,"Asserted after S5-rails are stable, buffered to SOC from EC",OUT,,TTL,N,3.30 V,SOC,F11,F11,E9,OUTPUT,,, -RSMRST_PWRGD_L,POWER SEQUENCE,,IN,both,--,Y,3.30 V,,M11,M11,B14,INPUT_PU,,, -SLP_SUS_L,POWER SEQUENCE,"If high, EC must keep S5 on, used in both DSx and non-DSx platforms.",IN,both,--,N,3.30 V,,H2,H2,F8,INPUT,,,No virtual wire over eSPI -SLP_S4_L,POWER SEQUENCE,"PCH S4 Sleep control. When low, shut-off power to all non critical systems in S4 and lower.",IN,both,--,N,3.30 V,,J4,J4,G11,INPUT,,,This signal is also virtual wire on the eSPI interface. -SLP_S3_L,POWER SEQUENCE,"PCH S3 Sleep control. When low, shut-off power to all non critical systems in S3 and lower.",IN,both,--,N,3.30 V,,K11,K11,B10,INPUT,,,This signal is also virtual wire on the eSPI interface. -SLP_S0_L,POWER SEQUENCE,"PCH S0 Sleep control, asserted when PCH = idle & CPU = C10",IN,both,--,N,3.30 V,,L10,L10,F1,INPUT,,,No virtual wire over eSPI -CPU_C10_GATE_L,POWER SEQUENCE,Asserted low when going into CPU_C10,IN,both,--,N,3.30 V,"SOC, VRs, LS",J3,J3,B6,INPUT,,??, -EC_VSENSE_PP3300_S5,POWER SEQUENCE,Voltage sense (or PGOOD) for PP3300_S5,IN,no,ADC,N,ANA,,B2,B2,H11,ADC,ADC_PP3300_S5,??,"Nuvoton VREF=2.816V, ITE VREF = AVCC or AVCC/1.1 (3V)" -PG_PP5000_S5_OD,POWER SEQUENCE,PP5000_S5 power good signal.,IN,,--,N,3.30 V,,D3,D3,C15,INPUT,,, -EC_SOC_VCCST_PWRGD_OD,POWER SEQUENCE,,OUT,,OD,N,1.05 V,,H11,H11,P9,OUTPUT_ODR,,, -EC_SOC_PCH_PWROK_OD,POWER SEQUENCE,,OUT,,OD,N,3.30 V,,M4,M4,R12,OUTPUT_ODR,,, -ALL_SYS_PWRGD,POWER SEQUENCE,,IN,both,,N,3.30 V,,J11,J11,B2,INPUT,,,Figure 398 PDG 0.5 -PG_PP1050_MEM_S3_OD,POWER SEQUENCE,,IN,both,--,N,3.30 V,,D2,D2,P5,INPUT,,??, -EC_VSENSE_PP1050_PROC,POWER SEQUENCE,,IN,no,ADC,N,ANA,SOC,C2,C2,A14,ADC,ADC_PP1050_PROC,PP1050_PROC monitoring from FIVR output, -SYS_RST_ODL,POWER SEQUENCE,Reset for SOC,OUT,,OD,N,3.30 V,SOC,H7,H7,P4,OUTPUT_ODR,,, -EC_PCH_WAKE_ODL,POWER SEQUENCE,"Allows EC to wake AP (e.g., keyboard out of S0ix)",OUT,,OD,N,3.30 V,SOC,L11,L11,E1,OUTPUT_ODL,,EC_SOC_WAKE_ODL on schematic; software uses PCH_WAKE name, -EC_SOC_RTCRST,POWER SEQUENCE,Allows EC to reset logic on the AP's RTC well,OUT,,TTL,N,3.30 V,SOC,J5,J5,R2,OUTPUT,,, -VCCIN_AUX_VID0,POWER SEQUENCE,Debug purposes,IN,both,,N,1.80 V,,L8,L8,P2,INPUT,,, -VCCIN_AUX_VID1,POWER SEQUENCE,Debug purposes,IN,both,,N,1.80 V,,L7,L7,R1,INPUT,,, -PWM_KB_BL,PWM,Keyboard backlight PWM control signal,OUT,,PWM,N,3.30 V,,H8,H8,R6,PWM,,, -PWM_LED_1_ODL,PWM,LED 1,OUT,,PWM,N,3.30 V,,G8,G8,P6,PWM_INVERT,,, -PWM_LED_2_ODL,PWM,LED 2,OUT,,PWM,N,3.30 V,,G9,G9,R7,PWM_INVERT,,, -PWM_LED_3_ODL,PWM,LED 3,OUT,,PWM,N,3.30 V,,H10,H10,P7,PWM_INVERT,,, -EC_PSYS,PWM,System power monitoring output,OUT,,PWM,N,ANA,"Charger, IMVP9.1",G6,G6,E15,OTHER,,, -EC_SOC_PWR_BTN_ODL,SOC,Buffered power button signal from EC to SOC,OUT,,OD,N,3.30 V,SOC,H9,H9,J5,OUTPUT_ODR,GPIO_PCH_PWRBTN_L,, -EC_SOC_HDMI_HPD,SOC,HPD buffer output for HDMI,OUT,,TTL,N,3.30 V,,L6,L6,P15,OUTPUT,,, -EC_PROCHOT_ODL,SOC,Allows us to send/read PROCHOT,I/O,both,OD,N,1.05 V,SOC,G3,G3,H14,OUTPUT_ODR,,, -EC_PCHHOT_ODL,SOC,Allows us to send/read PCHHOT,,,,,,,#N/A,#N/A,#N/A,OTHER,,,Intel confirmed that this feature is not used. -EC_SOC_INT_ODL,SOC,EC interrupt to SOC,OUT,,OD,N,,,K5,K5,P8,OUTPUT_ODR,GPIO_EC_INT_L,,Is this needed? -UART_GSC_DBG_RX_EC_TX,UART,UART signal from EC to debugger,OUT,,TTL,N,3.30 V,,H4,H4,B4,OTHER,,, -UART_GSC_DBG_TX_EC_RX,UART,UART signal from debugger to EC,IN,,--,N,3.30 V,,G4,G4,B5,OTHER,,, -EN_PP5000_PEN_X,MISC,Enable signal for 5V PEN charging rail,OUT,,TTL,N,3.30 V,,A11,A11,G2,OUTPUT,,, -PEN_DETECT_ODL,MISC,"PEN detect signal. Internal debouncing, if required.",IN,both,--,Y,3.30 V,,G12,G12,E14,INPUT_PU,,, -USB_C0_CC1,USB-PD,CC1 for IT81302 only,I/O,,CC,PD,ANA,,#N/A,#N/A,E10,OTHER,,, -USB_C0_CC2,USB-PD,CC2 for IT81302 only,I/O,,CC,PD,ANA,,#N/A,#N/A,A10,OTHER,,, -USB_C0_FRS,USB-PD,FRS for IT81302 only,OUT,,TTL,N,3.30 V,,#N/A,#N/A,D1,OUTPUT,,, -EN_USB_C0_CC1_VCONN,USB-PD,CC1 vconn en for IT81302 only,OUT,,TTL,N,3.30 V,,#N/A,#N/A,A9,OUTPUT,,, -EN_USB_C0_CC2_VCONN,USB-PD,CC2 vconn en for IT81302 only,OUT,,TTL,N,3.30 V,,#N/A,#N/A,A8,OUTPUT,,, -EC_TRIS_L,DEBUG,Debug for NPCX993,,,,,,,E4,E4,#N/A,OTHER,,, -EC_TEST_L,DEBUG,Debug for NPCX994,,,,,,,K2,K2,#N/A,OTHER,,, -EC_32KXOUT,DEBUG,Debug for NPCX995,,,,,,,M5,M5,#N/A,OTHER,,, -EC_SHDF_ESPI_L,DEBUG,Debug for NPCX996,,,,,,,H3,H3,#N/A,OTHER,,, \ No newline at end of file diff --git a/zephyr/projects/nissa/nivviks/cbi.dtsi b/zephyr/projects/nissa/nivviks/cbi.dtsi deleted file mode 100644 index 112a2a885c..0000000000 --- a/zephyr/projects/nissa/nivviks/cbi.dtsi +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* Nivviks-specific fw_config fields. */ - nissa-fw-config { - /* - * FW_CONFIG field to describe mainboard orientation in chassis. - */ - base-inversion { - enum-name = "FW_BASE_INVERSION"; - start = <3>; - size = <1>; - - inverted { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_INVERTED"; - value = <0>; - }; - regular { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_REGULAR"; - value = <1>; - default; - }; - }; - }; -}; diff --git a/zephyr/projects/nissa/nivviks/generated.dtsi b/zephyr/projects/nissa/nivviks/generated.dtsi deleted file mode 100644 index 91718302b4..0000000000 --- a/zephyr/projects/nissa/nivviks/generated.dtsi +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * This file is auto-generated - do not edit! - */ - -/ { - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { - enum-name = "ADC_PP1050_PROC"; - io-channels = <&adc0 4>; - }; - adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { - enum-name = "ADC_PP3300_S5"; - io-channels = <&adc0 6>; - }; - adc_temp_sensor_1: temp_sensor_1 { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 0>; - }; - adc_temp_sensor_2: temp_sensor_2 { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 1>; - }; - adc_temp_sensor_3: temp_sensor_3 { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 10>; - }; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_acc_int_l: acc_int_l { - gpios = <&gpio5 0 GPIO_INPUT>; - }; - gpio_all_sys_pwrgd: all_sys_pwrgd { - gpios = <&gpioa 7 GPIO_INPUT>; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_cpu_c10_gate_l: cpu_c10_gate_l { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_ec_battery_pres_odl: ec_battery_pres_odl { - gpios = <&gpioa 3 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio7 4 GPIO_OUTPUT>; - }; - gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { - gpios = <&gpiod 3 GPIO_ODR_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_entering_rw: ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { - gpios = <&gpio7 5 GPIO_OUTPUT>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - gpio_ec_pch_wake_odl: ec_pch_wake_odl { - gpios = <&gpiob 0 GPIO_ODR_LOW>; - }; - gpio_ec_prochot_odl: ec_prochot_odl { - gpios = <&gpiof 1 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { - gpios = <&gpio6 1 GPIO_OUTPUT>; - }; - gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { - gpios = <&gpioe 4 GPIO_OUTPUT>; - }; - gpio_ec_soc_int_odl: ec_soc_int_odl { - gpios = <&gpio8 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { - gpios = <&gpio7 2 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { - gpios = <&gpioc 1 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioa 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_rtcrst: ec_soc_rtcrst { - gpios = <&gpio7 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { - gpios = <&gpio3 7 GPIO_OUTPUT>; - }; - gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { - gpios = <&gpioa 4 GPIO_ODR_HIGH>; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_en_kb_bl: en_kb_bl { - gpios = <&gpioa 0 GPIO_OUTPUT>; - enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; - }; - gpio_en_pp3300_s5: en_pp3300_s5 { - gpios = <&gpiob 6 GPIO_OUTPUT>; - enum-name = "GPIO_TEMP_SENSOR_POWER"; - }; - gpio_en_pp5000_pen_x: en_pp5000_pen_x { - gpios = <&gpioe 2 GPIO_OUTPUT>; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio4 0 GPIO_OUTPUT>; - }; - gpio_en_slp_z: en_slp_z { - gpios = <&gpioe 1 GPIO_OUTPUT>; - }; - gpio_en_usb_a0_vbus: en_usb_a0_vbus { - gpios = <&gpio9 1 GPIO_OUTPUT>; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_hdmi_sel: hdmi_sel { - gpios = <&gpioc 6 GPIO_OUTPUT>; - }; - gpio_imu_int_l: imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { - gpios = <&gpio4 3 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_pen_detect_odl: pen_detect_odl { - gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { - gpios = <&gpio4 2 GPIO_INPUT>; - }; - gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { - gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; - }; - gpio_slp_s0_l: slp_s0_l { - gpios = <&gpio9 7 GPIO_INPUT>; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpioa 5 GPIO_INPUT>; - }; - gpio_slp_s4_l: slp_s4_l { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_slp_sus_l: slp_sus_l { - gpios = <&gpio6 2 GPIO_INPUT>; - }; - gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { - gpios = <&gpiod 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB2_ILIM_SEL"; - }; - gpio_sys_rst_odl: sys_rst_odl { - gpios = <&gpioc 5 GPIO_ODR_HIGH>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpio9 5 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { - gpios = <&gpio8 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB1_ILIM_SEL"; - }; - gpio_usb_c0_int_odl: usb_c0_int_odl { - gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; - }; - gpio_vccin_aux_vid0: vccin_aux_vid0 { - gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_vccin_aux_vid1: vccin_aux_vid1 { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_ec_i2c_eeprom: ec_i2c_eeprom { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_ec_i2c_sensor: ec_i2c_sensor { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_C0_TCPC"; - }; - i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { - i2c-port = <&i2c5_1>; - enum-names = "I2C_PORT_USB_C1_TCPC"; - }; - i2c_ec_i2c_batt: ec_i2c_batt { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_BATTERY"; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan0_gp45 - &adc0_chan1_gp44 - &adc0_chan4_gp41 - &adc0_chan6_gp34 - &adc0_chan10_gpe0>; - pinctrl-names = "default"; -}; - - -&i2c0_0 { - status = "okay"; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; -}; - -&i2c1_0 { - status = "okay"; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; -}; - -&i2c3_0 { - status = "okay"; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; -}; - -&i2c5_1 { - status = "okay"; - pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>; - pinctrl-names = "default"; -}; - -&i2c7_0 { - status = "okay"; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/nissa/nivviks/keyboard.dtsi b/zephyr/projects/nissa/nivviks/keyboard.dtsi deleted file mode 100644 index 00610e4e18..0000000000 --- a/zephyr/projects/nissa/nivviks/keyboard.dtsi +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm6 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm6_gpc0>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/nivviks/motionsense.dtsi b/zephyr/projects/nissa/nivviks/motionsense.dtsi deleted file mode 100644 index 6297a07bf5..0000000000 --- a/zephyr/projects/nissa/nivviks/motionsense.dtsi +++ /dev/null @@ -1,166 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * Interrupt bindings for sensor devices. - */ - lsm6dso-int = &base_accel; - lis2dw12-int = &lid_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: base-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <(-1) 0 0 - 0 1 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rot-ref { - mat33 = <(-1) 0 0 - 0 (-1) 0 - 0 0 1>; - }; - - base_rot_inverted: base-rotation-inverted { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - lsm6dso_accel_data: lsm6dso-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - lsm6dso_gyro_data: lsm6dso-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - * TODO(b/238139272): The first entries of the array must be - * accelerometers,then gyroscope. Fix this dependency in the DTS - * processing which makes the devicetree entries independent. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,lsm6dso-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - /* - * May be replaced by alternate depending - * on board config. - */ - rot-standard-ref = <&base_rot_ref>; - drv-data = <&lsm6dso_accel_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,lsm6dso-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ - drv-data = <&lsm6dso_gyro_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/nissa/nivviks/overlay.dtsi b/zephyr/projects/nissa/nivviks/overlay.dtsi deleted file mode 100644 index c2d5e3f24b..0000000000 --- a/zephyr/projects/nissa/nivviks/overlay.dtsi +++ /dev/null @@ -1,418 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_odl; - int-wp = &int_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - ec-console { - compatible = "ec-console"; - disabled = "events", "lpc", "hostcmd"; - }; - - batteries { - default_battery: lgc { - compatible = "lgc,ap18c8k", "battery-smart"; - }; - lgc_ap19b8m { - compatible = "lgc,ap19b8m", "battery-smart"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_power_button - &int_lid_open - >; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_imu: ec_imu { - irq-pin = <&gpio_imu_int_l>; - flags = ; - handler = "lsm6dso_interrupt"; - }; - int_vol_down: vol_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_vol_up: vol_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_usb_c0: usb_c0 { - irq-pin = <&gpio_usb_c0_int_odl>; - flags = ; - handler = "usb_interrupt"; - }; - int_usb_c1: usb_c1 { - irq-pin = <&gpio_sb_1>; - flags = ; - handler = "usb_interrupt"; - }; - }; - - named-gpios { - gpio_sb_1: sb-1 { - gpios = <&gpio0 2 GPIO_PULL_UP>; - no-auto-init; - }; - - gpio_sb_2: sb-2 { - gpios = <&gpiod 4 GPIO_OUTPUT>; - no-auto-init; - }; - - /* - * Set I2C pins for type C sub-board to be low voltage (I2C5_1). - * We do this for all boards, since the pins are 3.3V tolerant, - * and the only 2 types of sub-boards used on nivviks both have - * type-C ports on them. - */ - gpio_sb_3: sb-3 { - gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; - no-auto-init; - }; - gpio_sb_4: sb-4 { - gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - no-auto-init; - }; - gpio_fan_enable: fan-enable { - gpios = <&gpio6 3 GPIO_OUTPUT>; - no-auto-init; - }; - ec-i2c-sensor-scl { - gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - }; - - /* - * Aliases used for sub-board GPIOs. - */ - aliases { - /* - * Input GPIO when used with type-C port 1 - * Output when used with HDMI sub-board - */ - gpio-usb-c1-int-odl = &gpio_sb_1; - gpio-en-rails-odl = &gpio_sb_1; - /* - * Sub-board with type A USB, enable. - */ - gpio-en-usb-a1-vbus = &gpio_sb_2; - /* - * HPD pins for HDMI sub-board. - */ - gpio-hdmi-en-odl = &gpio_sb_3; - gpio-hpd-odl = &gpio_sb_4; - /* - * Enable S5 rails for LTE sub-board - */ - gpio-en-sub-s5-rails = &gpio_sb_2; - }; - - temp_memory: memory { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_1>; - }; - temp_charger: charger { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_2>; - }; - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_3>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - memory { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_memory>; - }; - charger { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_charger>; - }; - ambient { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_ambient>; - }; - }; - - usba { - compatible = "cros-ec,usba-port-enable-pins"; - /* - * sb_2 is only configured as GPIO when USB-A1 is present, - * but it's still safe to control when disabled. - * - * ILIM_SEL pins are referred to by legacy enum name, - * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on - * sub-boards that don't have USB-A so is safe to control - * regardless of system configuration. - */ - enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; - status = "okay"; - }; - - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - chg = <&chg_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - /* - * TODO(b:211693800): port1 may not be present on some - * sub-boards. - */ - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - chg = <&chg_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; - }; - usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; - - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm5 5 PWM_KHZ(1) PWM_POLARITY_NORMAL>; - rpm_min = <2200>; - rpm_start = <2200>; - rpm_max = <4200>; - tach = <&tach2>; - enable_gpio = <&gpio_fan_enable>; - }; - }; - - /* - * Declare unused GPIOs so that they are shut down - * and use minimal power - */ - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio3 2 0>, - <&gpio3 3 0>, - <&gpio3 5 0>, - <&gpio3 6 0>, - <&gpio5 7 0>, - <&gpio6 0 0>, - <&gpio6 3 0>, - <&gpio6 6 0>, - <&gpio7 3 0>, - <&gpio8 3 0>, - <&gpio8 6 0>, - <&gpiob 1 0>, - <&gpiob 7 0>, - <&gpioc 7 0>, - <&gpiof 2 0>, - <&gpiof 3 0>; - }; -}; - -&thermistor_3V3_51K1_47K_4050B { - status = "okay"; -}; - -&adc_ec_vsense_pp3300_s5 { - /* - * Voltage divider on input has 47k upper and 220k lower legs with - * 2714 mV full-scale reading on the ADC. Apply the largest possible - * multiplier (without overflowing int32) to get the best possible - * approximation of the actual ratio, but derate by a factor of two to - * ensure unexpectedly high values won't overflow. - */ - mul = <(791261 / 2)>; - div = <(651975 / 2)>; -}; - -/* Set bus speeds for I2C */ -&i2c0_0 { - label = "I2C_EEPROM"; - clock-frequency = ; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c1_0 { - label = "I2C_SENSOR"; - clock-frequency = ; -}; - -&i2c3_0 { - label = "I2C_USB_C0_TCPC"; - clock-frequency = ; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - /* - * BC1.2 interrupt is shared with TCPC, so - * IRQ is not specified here and handled by - * usb_c0_interrupt. - */ - }; - - chg_port0: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&i2c5_1 { - label = "I2C_SUB_C1_TCPC"; - clock-frequency = ; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port1: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; - - anx7483_mux_1: anx7483-mux-1@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "anx7483_set_default_tuning"; - }; -}; - -&i2c7_0 { - label = "I2C_BATTERY"; - clock-frequency = ; -}; - -&pwm5_gpb7 { - drive-open-drain; -}; - -&pwm5 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm5_gpb7>; - pinctrl-names = "default"; -}; - -/* Tachometer for fan speed measurement */ -&tach2 { - status = "okay"; - pinctrl-0 = <&ta2_1_in_gp73>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; - -/* - * Declare GPIOs that have leakage current caused by board issues here. NPCX ec - * will disable their input buffers before entering deep sleep and restore them - * after waking up automatically for better power consumption. - */ -&power_leakage_io { - leak-gpios = <&gpioa 4 0 - &gpiof 1 0>; -}; diff --git a/zephyr/projects/nissa/nivviks/power_signals.dtsi b/zephyr/projects/nissa/nivviks/power_signals.dtsi deleted file mode 100644 index 1d2b23069d..0000000000 --- a/zephyr/projects/nissa/nivviks/power_signals.dtsi +++ /dev/null @@ -1,220 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <10>; - all-sys-pwrgd-timeout = <20>; - }; - - pwr-en-pp5000-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP5000_S5 enable output to regulator"; - enum-name = "PWR_EN_PP5000_A"; - gpios = <&gpio4 0 0>; - output; - }; - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpiob 6 0>; - output; - }; - pwr-pg-ec-rsmrst-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpio9 4 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioa 6 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-sus-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_SUS_L input from PCH"; - enum-name = "PWR_SLP_SUS"; - gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-ec-soc-dsw-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "DSW_PWROK output to PCH"; - enum-name = "PWR_EC_SOC_DSW_PWROK"; - gpios = <&gpio6 1 0>; - output; - }; - pwr-vccst-pwrgd-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VCCST_PWRGD output to PCH"; - enum-name = "PWR_VCCST_PWRGD"; - gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; - output; - }; - pwr-imvp9-vrrdy-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VRRDY input from IMVP9"; - enum-name = "PWR_IMVP9_VRRDY"; - gpios = <&gpio4 3 0>; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpio3 7 0>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - compatible = "intel,ap-pwrseq-external"; - dbg-label = "Combined all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - }; - pwr-adc-pp3300 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP3300 PWROK (from ADC)"; - enum-name = "PWR_DSW_PWROK"; - trigger-high = <&cmp_pp3300_s5_high>; - trigger-low = <&cmp_pp3300_s5_low>; - }; - pwr-adc-pp1p05 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP1P05 PWROK (from ADC)"; - enum-name = "PWR_PG_PP1P05"; - trigger-high = <&cmp_pp1p05_high>; - trigger-low = <&cmp_pp1p05_low>; - }; - - adc-cmp { - cmp_pp3300_s5_high: pp3300_high { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 6>; - comparison = "ADC_CMP_NPCX_GREATER"; - /* - * This is 90% of nominal voltage considering voltage - * divider on ADC input. - */ - threshold-mv = <2448>; - }; - cmp_pp3300_s5_low: pp3300_low { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 6>; - comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; - threshold-mv = <2448>; - }; - cmp_pp1p05_high: pp1p05_high { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 4>; - comparison = "ADC_CMP_NPCX_GREATER"; - /* Setting at 90% of nominal voltage */ - threshold-mv = <945>; - }; - cmp_pp1p05_low: pp1p05_low { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 4>; - comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; - threshold-mv = <945>; - }; - }; -}; - -/* - * Because the power signals directly reference the GPIOs, - * the correspinding named-gpios need to have no-auto-init set. - */ -&gpio_ec_soc_dsw_pwrok { - no-auto-init; -}; -&gpio_ec_soc_pch_pwrok_od { - no-auto-init; -}; -&gpio_ec_soc_rsmrst_l { - no-auto-init; -}; -&gpio_ec_soc_sys_pwrok { - no-auto-init; -}; -&gpio_ec_soc_vccst_pwrgd_od { - no-auto-init; -}; -&gpio_en_pp3300_s5 { - no-auto-init; -}; -&gpio_en_pp5000_s5 { - no-auto-init; -}; -&gpio_imvp91_vrrdy_od { - no-auto-init; -}; -&gpio_rsmrst_pwrgd_l { - no-auto-init; -}; -&gpio_slp_s0_l { - no-auto-init; -}; -&gpio_slp_s3_l { - no-auto-init; -}; -&gpio_slp_s4_l { - no-auto-init; -}; -&gpio_slp_sus_l { - no-auto-init; -}; -&gpio_sys_rst_odl { - no-auto-init; -}; diff --git a/zephyr/projects/nissa/nivviks/project.conf b/zephyr/projects/nissa/nivviks/project.conf deleted file mode 100644 index af9e4e2586..0000000000 --- a/zephyr/projects/nissa/nivviks/project.conf +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_NIVVIKS=y -CONFIG_PLATFORM_EC_OCPC=y - -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y diff --git a/zephyr/projects/nissa/nivviks/project.overlay b/zephyr/projects/nissa/nivviks/project.overlay deleted file mode 100644 index 9ca681d979..0000000000 --- a/zephyr/projects/nissa/nivviks/project.overlay +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../cbi.dtsi" - -#include "cbi.dtsi" -#include "generated.dtsi" -#include "keyboard.dtsi" -#include "motionsense.dtsi" -#include "overlay.dtsi" -#include "power_signals.dtsi" -#include "pwm_leds.dtsi" diff --git a/zephyr/projects/nissa/nivviks/pwm_leds.dtsi b/zephyr/projects/nissa/nivviks/pwm_leds.dtsi deleted file mode 100644 index a265a5929e..0000000000 --- a/zephyr/projects/nissa/nivviks/pwm_leds.dtsi +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm2 2 PWM_HZ(324) PWM_POLARITY_INVERTED>, - <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>, - <&pwm1 1 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0>; - - /**/ - color-map-red = <100 0 0>; - color-map-green = < 0 100 0>; - color-map-blue = < 0 0 100>; - color-map-yellow = < 0 50 50>; - color-map-white = <100 100 100>; - color-map-amber = <100 0 0>; - - brightness-range = <0 0 100 0 0 100>; - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_BATTERY_LED"; - }; - }; -}; - -/* Enable LEDs to work while CPU suspended */ - -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/nivviks/src/charger.c b/zephyr/projects/nissa/nivviks/src/charger.c deleted file mode 100644 index e2f9f966e7..0000000000 --- a/zephyr/projects/nissa/nivviks/src/charger.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery.h" -#include "charger.h" -#include "charger/isl923x_public.h" -#include "console.h" -#include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -int extpower_is_present(void) -{ - int port; - int rv; - bool acok; - - for (port = 0; port < board_get_usb_pd_port_count(); port++) { - rv = raa489000_is_acok(port, &acok); - if ((rv == EC_SUCCESS) && acok) - return 1; - } - - return 0; -} - -/* - * Nivviks does not have a GPIO indicating whether extpower is present, - * so detect using the charger(s). - */ -__override void board_check_extpower(void) -{ - static int last_extpower_present; - int extpower_present = extpower_is_present(); - - if (last_extpower_present ^ extpower_present) - extpower_handle_update(extpower_present); - - last_extpower_present = extpower_present; -} - -__override void board_hibernate(void) -{ - /* Shut down the chargers */ - if (board_get_usb_pd_port_count() == 2) - raa489000_hibernate(CHARGER_SECONDARY, true); - raa489000_hibernate(CHARGER_PRIMARY, true); - LOG_INF("Charger(s) hibernated"); - cflush(); -} diff --git a/zephyr/projects/nissa/nivviks/src/fan.c b/zephyr/projects/nissa/nivviks/src/fan.c deleted file mode 100644 index 840049722c..0000000000 --- a/zephyr/projects/nissa/nivviks/src/fan.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -/* - * Nirwen fan support - */ -static void fan_init(void) -{ - int ret; - uint32_t val; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - if (val != FW_FAN_PRESENT) { - /* Disable the fan */ - fan_set_count(0); - } else { - /* Configure the fan enable GPIO */ - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), - GPIO_OUTPUT); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/nissa/nivviks/src/form_factor.c b/zephyr/projects/nissa/nivviks/src/form_factor.c deleted file mode 100644 index 602b22baff..0000000000 --- a/zephyr/projects/nissa/nivviks/src/form_factor.c +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "accelgyro.h" -#include "cros_cbi.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -/* - * Mainboard orientation support. - */ - -#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_inverted)) -#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel)) -#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro)) - -static void form_factor_init(void) -{ - int ret; - uint32_t val; - /* - * If the firmware config indicates - * an inverted form factor, use the alternative - * rotation matrix. - */ - ret = cros_cbi_get_fw_config(FW_BASE_INVERSION, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", - FW_BASE_INVERSION); - return; - } - if (val == FW_BASE_INVERTED) { - LOG_INF("Switching to inverted base"); - motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT; - motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT; - } -} -DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/projects/nissa/nivviks/src/keyboard.c b/zephyr/projects/nissa/nivviks/src/keyboard.c deleted file mode 100644 index f13d5bf78c..0000000000 --- a/zephyr/projects/nissa/nivviks/src/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config nivviks_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &nivviks_kb; -} diff --git a/zephyr/projects/nissa/nivviks/src/led.c b/zephyr/projects/nissa/nivviks/src/led.c deleted file mode 100644 index 9087982604..0000000000 --- a/zephyr/projects/nissa/nivviks/src/led.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery LED control for nissa - */ -#include "common.h" -#include "ec_commands.h" -#include "led_common.h" -#include "led_onoff_states.h" -#include "led_pwm.h" - -__override const int led_charge_lvl_1 = 5; -__override const int led_charge_lvl_2 = 97; -__override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_BLUE, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, - 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - [STATE_FACTORY_TEST] = { { EC_LED_COLOR_AMBER, - 2 * LED_ONE_SEC }, - { EC_LED_COLOR_BLUE, - 2 * LED_ONE_SEC } }, - }; - -__override void led_set_color_battery(enum ec_led_colors color) -{ - switch (color) { - case EC_LED_COLOR_BLUE: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_BLUE); - break; - case EC_LED_COLOR_AMBER: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); - break; - default: /* LED_OFF and other unsupported colors */ - set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); - break; - } -} diff --git a/zephyr/projects/nissa/nivviks/src/usbc.c b/zephyr/projects/nissa/nivviks/src/usbc.c deleted file mode 100644 index 14fc5a071d..0000000000 --- a/zephyr/projects/nissa/nivviks/src/usbc.c +++ /dev/null @@ -1,277 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "charge_state_v2.h" -#include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" -#include "driver/charger/isl923x_public.h" -#include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" -#include "driver/tcpm/raa489000.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, - { /* sub-board */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - -int board_is_sourcing_vbus(int port) -{ - int regval; - - tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); - return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); -} - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; - int old_port; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - old_port = charge_manager_get_active_charge_port(); - - LOG_INF("New chg p%d", port); - - /* Disable all ports. */ - if (port == CHARGE_PORT_NONE) { - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - tcpc_write(i, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_LOW); - raa489000_enable_asgate(i, false); - } - - return EC_SUCCESS; - } - - /* Check if port is sourcing VBUS. */ - if (board_is_sourcing_vbus(port)) { - LOG_WRN("Skip enable p%d", port); - return EC_ERROR_INVAL; - } - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (i == port) - continue; - - if (tcpc_write(i, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_LOW)) - LOG_WRN("p%d: sink path disable failed.", i); - raa489000_enable_asgate(i, false); - } - - /* - * Stop the charger IC from switching while changing ports. Otherwise, - * we can overcurrent the adapter we're switching to. (crbug.com/926056) - */ - if (old_port != CHARGE_PORT_NONE) - charger_discharge_on_ac(1); - - /* Enable requested charge port. */ - if (raa489000_enable_asgate(port, true) || - tcpc_write(port, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { - LOG_WRN("p%d: sink path enable failed.", port); - charger_discharge_on_ac(0); - return EC_ERROR_UNKNOWN; - } - - /* Allow the charger IC to begin/continue switching. */ - charger_discharge_on_ac(0); - - return EC_SUCCESS; -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - int regval; - - /* - * The interrupt line is shared between the TCPC and BC1.2 detector IC. - * Therefore, go out and actually read the alert registers to report the - * alert status. - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { - if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { - /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ - if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_0; - } - } - - if (board_get_usb_pd_port_count() == 2 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { - /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ - if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_1; - } - } - - return status; -} - -void pd_power_supply_reset(int port) -{ - /* Disable VBUS */ - tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) -{ - if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) - return; - - raa489000_set_output_current(port, rp); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) - return EC_ERROR_INVAL; - - /* Disable charging. */ - rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); - if (rv) - return rv; - - /* Our policy is not to source VBUS when the AP is off. */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - return EC_ERROR_NOT_POWERED; - - /* Provide Vbus. */ - rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); - if (rv) - return rv; - - rv = raa489000_enable_asgate(port, true); - if (rv) - return rv; - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -void board_reset_pd_mcu(void) -{ - /* - * TODO(b:147316511): could send a reset command to the TCPC here - * if needed. - */ -} - -/* - * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible - * for an interrupt to be lost if one asserts the IRQ, the other does the same - * then the first releases it: there will only be one falling edge to trigger - * the interrupt, and the line will be held low. We handle this by running a - * deferred check after a falling edge to see whether the IRQ is still being - * asserted. If it is, we assume an interrupt may have been lost and we need - * to poll each chip for events again. - */ -#define USBC_INT_POLL_DELAY_US 5000 - -static void poll_c0_int(void); -DECLARE_DEFERRED(poll_c0_int); -static void poll_c1_int(void); -DECLARE_DEFERRED(poll_c1_int); - -static void usbc_interrupt_trigger(int port) -{ - schedule_deferred_pd_interrupt(port); - usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); -} - -static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, - const struct deferred_data *ud) -{ - if (!gpio_pin_get_dt(gpio)) { - usbc_interrupt_trigger(port); - hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); - } -} - -static void poll_c0_int(void) -{ - poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), - &poll_c0_int_data); -} - -static void poll_c1_int(void) -{ - poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), - &poll_c1_int_data); -} - -void usb_interrupt(enum gpio_signal signal) -{ - int port; - const struct deferred_data *ud; - - if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { - port = 0; - ud = &poll_c0_int_data; - } else { - port = 1; - ud = &poll_c1_int_data; - } - /* - * We've just been called from a falling edge, so there's definitely - * no lost IRQ right now. Cancel any pending check. - */ - hook_call_deferred(ud, -1); - /* Trigger polling of TCPC and BC1.2 in respective tasks */ - usbc_interrupt_trigger(port); - /* Check for lost interrupts in a bit */ - hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); -} diff --git a/zephyr/projects/nissa/npcx_program.conf b/zephyr/projects/nissa/npcx_program.conf deleted file mode 100644 index ae672cb63a..0000000000 --- a/zephyr/projects/nissa/npcx_program.conf +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# EC chip configuration: NPCX993 -CONFIG_CROS_FLASH_NPCX=y -CONFIG_CROS_SYSTEM_NPCX=y -CONFIG_SOC_SERIES_NPCX9=y -CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y -CONFIG_SYSCON=y -CONFIG_TACH_NPCX=y -CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=256 - -# Common sensor drivers -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y - -# Keyboard -CONFIG_CROS_KB_RAW_NPCX=y -CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y -# Ensure recovery key combination (esc+refresh+power) is reliable -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y - -# TCPC+PPC: both C0 and C1 (if present) are RAA489000 -CONFIG_PLATFORM_EC_USB_PD_TCPM_RAA489000=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US=100000 -# RAA489000 uses TCPCI but not a separate PPC, so custom function is required -CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y -# type C port 1 redriver -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Save some flash space, but retain some useful features -CONFIG_SHELL_MINIMAL=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y -CONFIG_SHELL_HELP=y -CONFIG_KERNEL_SHELL=y - -# FRS enable -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y - -# Charger driver and configuration -CONFIG_PLATFORM_EC_CHARGER_RAA489000=y -CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=22 - -# VSENSE: PP3300_S5 & PP1050_PROC -CONFIG_ADC_CMP_NPCX=y -CONFIG_ADC_CMP_NPCX_WORKQUEUE=y -CONFIG_ADC_CMP_NPCX_WORKQUEUE_PRIORITY=12 -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n diff --git a/zephyr/projects/nissa/program.conf b/zephyr/projects/nissa/program.conf deleted file mode 100644 index c23a7f1381..0000000000 --- a/zephyr/projects/nissa/program.conf +++ /dev/null @@ -1,156 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Core EC configuration: build the EC application, using ECOS shims -# (which are currently required for a number of features). -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_LTO=y - -# Debug options and features; can be disabled to save memory or once bringup -# is complete. -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y - -# RAM-saving options -# flash shell command is unused, allocated a 4kB buffer for flash test -CONFIG_FLASH_SHELL=n -# EC default 1kB buffer seems unnecessarily large, Zephyr default is 8 bytes -CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=128 - -# Standard shimmed features -CONFIG_PLATFORM_EC_BACKLIGHT_LID=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -CONFIG_PLATFORM_EC_VBOOT_EFS2=y -CONFIG_PLATFORM_EC_VBOOT_HASH=y - -# Application processor; communicates with EC via eSPI -CONFIG_AP=y -CONFIG_AP_X86_INTEL_ADL=y -CONFIG_ESPI=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y -CONFIG_PLATFORM_EC_HOSTCMD=y -CONFIG_HCDEBUG_OFF=y -CONFIG_PLATFORM_EC_THROTTLE_AP=y -CONFIG_PLATFORM_EC_PORT80=y -CONFIG_PLATFORM_EC_PORT80_QUIET=y - -# AP Power Sequencing -CONFIG_AP_PWRSEQ=y -CONFIG_X86_NON_DSX_PWRSEQ_ADL=y -CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y -CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y -CONFIG_AP_PWRSEQ_S0IX=y -CONFIG_AP_PWRSEQ_S0IX_ERROR_RECOVERY=y - -# I2C -CONFIG_I2C=y - -# Keyboard support -CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_CMD_BUTTON=n -# Column 2 is driven through the GSC, which inverts the signal going through it -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_PWM=y -CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n - -# MKBP event -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y - -# Temperature sensor support -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY=y - -# CBI EEPROM support -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y - - -# PWM support -CONFIG_PWM=y -CONFIG_PWM_SHELL=y - -# TODO(b/188605676): bring these features up -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n - -# Sensors support -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y - -# USB-C: enable PD on up to two ports -CONFIG_PLATFORM_EC_USBC=y -CONFIG_PLATFORM_EC_USBC_PPC=n -CONFIG_PLATFORM_EC_USB_VID=0x18d1 -CONFIG_PLATFORM_EC_USB_PID=0x505a -# USB4 and TBT are unsupported -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n - -CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -# ADL integrated muxes are slow: unblock PD -CONFIG_PLATFORM_EC_USB_MUX_TASK=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y - -# USB-C TCPC and PPC standard options -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y - -# USB-A host ports -CONFIG_PLATFORM_EC_USBA=y -CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC=y -# Both ports use a smart switch with CTL1..3 fixed high, for SDP2 or CDP only: -# either SLGC55545 or PI5USB2546. -CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART=y -CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_CDP_SDP_ONLY=y -CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_CDP=y -CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_INVERTED=y - -# Battery support -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y - -# Charger support -CONFIG_PLATFORM_EC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y - -# Dynamically select PD voltage to maximize charger efficiency -CONFIG_PLATFORM_EC_USB_PD_DPS=y -# Reduce logging so that state transitions do not cause protocol issues -# pd dump [1-3] can be used to increase the debugging level -CONFIG_PLATFORM_EC_USB_PD_INITIAL_DEBUG_LEVEL=0 diff --git a/zephyr/projects/nissa/pujjo/cbi.dtsi b/zephyr/projects/nissa/pujjo/cbi.dtsi deleted file mode 100644 index b5ba92bd9e..0000000000 --- a/zephyr/projects/nissa/pujjo/cbi.dtsi +++ /dev/null @@ -1,190 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* Pujjo-specific fw_config fields. */ - nissa-fw-config { - /* - * FW_CONFIG field to enable KB back light or not. - */ - kb-bl { - enum-name = "FW_KB_BL"; - start = <3>; - size = <1>; - - no-kb-bl { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_NOT_PRESENT"; - value = <0>; - }; - kb-bl-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_PRESENT"; - value = <1>; - }; - }; - - /* - * FW_CONFIG field for KB PWB present or not. - */ - kb-pwb { - enum-name = "FW_KB_PWB"; - start = <4>; - size = <1>; - - no-kb-pwb { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_PWB_NOT_PRESENT"; - value = <0>; - }; - kb-pwb-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_PWB_PRESENT"; - value = <1>; - }; - }; - - /* - * FW_CONFIG field for tablet present or not. - */ - tablet { - enum-name = "FW_TABLET"; - start = <5>; - size = <1>; - - no-tablet { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_TABLET_NOT_PRESENT"; - value = <0>; - }; - tablet-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_TABLET_PRESENT"; - value = <1>; - }; - }; - - /* - * FW_CONFIG field for LTE board present or not. - * - * start = <6>; - * size = <1>; - */ - - /* - * FW_CONFIG field for SD card present or not. - * - * start = <7>; - * size = <1>; - */ - - /* - * FW_CONFIG field for pen present or not. - */ - pen { - enum-name = "FW_PEN"; - start = <8>; - size = <1>; - - no-pen { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_PEN_NOT_PRESENT"; - value = <0>; - }; - pen-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_PEN_PRESENT"; - value = <1>; - }; - }; - - /* - * FW_CONFIG field for WF camera present or not. - * - * start = <9>; - * size = <1>; - */ - - /* - * FW_CONFIG field for multiple thermal table. - */ - therm-table { - enum-name = "THERM_TABLE"; - start = <10>; - size = <2>; - - therm-table-1 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "THERM_TABLE_1"; - value = <1>; - }; - }; - - /* - * FW_CONFIG field for multiple audio module. - * - * start = <12>; - * size = <3>; - */ - - /* - * FW_CONFIG field for EXT_VR. - * - * start = <15>; - * size = <1>; - */ - - /* - * FW_CONFIG field for multiple wi-fi SAR. - * - * start = <16>; - * size = <2>; - */ - }; - - /* Pujjo-specific ssfc fields. */ - cbi-ssfc { - compatible = "named-cbi-ssfc"; - /* - * SSFC field to identify BASE motion sensor. - */ - base-sensor { - enum-name = "BASE_SENSOR"; - size = <2>; - - base_sensor_0: bmi323 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <0>; - default; - }; - base_sensor_1: lsm6dsm { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <1>; - }; - }; - - /* - * SSFC field to identify LID motion sensor. - */ - lid-sensor { - enum-name = "LID_SENSOR"; - size = <2>; - - lid_sensor_0: bma422 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <0>; - default; - }; - lid_sensor_1: lis2dw12 { - compatible = "named-cbi-ssfc-value"; - status = "okay"; - value = <1>; - }; - }; - }; -}; diff --git a/zephyr/projects/nissa/pujjo/generated.dtsi b/zephyr/projects/nissa/pujjo/generated.dtsi deleted file mode 100644 index 727d2d3d53..0000000000 --- a/zephyr/projects/nissa/pujjo/generated.dtsi +++ /dev/null @@ -1,277 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * This file is auto-generated - do not edit! - */ - -/ { - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { - enum-name = "ADC_PP1050_PROC"; - io-channels = <&adc0 4>; - }; - adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { - enum-name = "ADC_PP3300_S5"; - io-channels = <&adc0 6>; - }; - adc_temp_sensor_1: temp_sensor_1 { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 0>; - }; - adc_temp_sensor_2: temp_sensor_2 { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 1>; - }; - adc_temp_sensor_3: temp_sensor_3 { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 10>; - }; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_acc_int_l: acc_int_l { - gpios = <&gpio5 0 GPIO_INPUT>; - }; - gpio_all_sys_pwrgd: all_sys_pwrgd { - gpios = <&gpioa 7 GPIO_INPUT>; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_cpu_c10_gate_l: cpu_c10_gate_l { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_ec_battery_pres_odl: ec_battery_pres_odl { - gpios = <&gpioa 3 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio7 4 GPIO_OUTPUT>; - }; - gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { - gpios = <&gpiod 3 GPIO_ODR_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_entering_rw: ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { - gpios = <&gpio7 5 GPIO_OUTPUT>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - gpio_ec_pch_wake_odl: ec_pch_wake_odl { - gpios = <&gpiob 0 GPIO_ODR_LOW>; - }; - gpio_ec_prochot_odl: ec_prochot_odl { - gpios = <&gpiof 1 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { - gpios = <&gpio6 1 GPIO_OUTPUT>; - }; - gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { - gpios = <&gpioe 4 GPIO_OUTPUT>; - }; - gpio_ec_soc_int_odl: ec_soc_int_odl { - gpios = <&gpio8 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { - gpios = <&gpio7 2 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { - gpios = <&gpioc 1 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioa 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_rtcrst: ec_soc_rtcrst { - gpios = <&gpio7 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { - gpios = <&gpio3 7 GPIO_OUTPUT>; - }; - gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { - gpios = <&gpioa 4 GPIO_ODR_HIGH>; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_en_kb_bl: en_kb_bl { - gpios = <&gpioa 0 GPIO_OUTPUT>; - enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; - }; - gpio_en_pp3300_s5: en_pp3300_s5 { - gpios = <&gpiob 6 GPIO_OUTPUT>; - enum-name = "GPIO_TEMP_SENSOR_POWER"; - }; - gpio_en_pp5000_pen_x: en_pp5000_pen_x { - gpios = <&gpioe 2 GPIO_OUTPUT>; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio4 0 GPIO_OUTPUT>; - }; - gpio_en_slp_z: en_slp_z { - gpios = <&gpioe 1 GPIO_OUTPUT>; - }; - gpio_en_usb_a0_vbus: en_usb_a0_vbus { - gpios = <&gpio9 1 GPIO_OUTPUT>; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_hdmi_sel: hdmi_sel { - gpios = <&gpioc 6 GPIO_OUTPUT>; - }; - gpio_imu_int_l: imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { - gpios = <&gpio4 3 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_pen_detect_odl: pen_detect_odl { - gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { - gpios = <&gpio4 2 GPIO_INPUT>; - }; - gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { - gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; - }; - gpio_slp_s0_l: slp_s0_l { - gpios = <&gpio9 7 GPIO_INPUT>; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpioa 5 GPIO_INPUT>; - }; - gpio_slp_s4_l: slp_s4_l { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_slp_sus_l: slp_sus_l { - gpios = <&gpio6 2 GPIO_INPUT>; - }; - gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { - gpios = <&gpiod 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB2_ILIM_SEL"; - }; - gpio_sys_rst_odl: sys_rst_odl { - gpios = <&gpioc 5 GPIO_ODR_HIGH>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpio9 5 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { - gpios = <&gpio8 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB1_ILIM_SEL"; - }; - gpio_usb_c0_int_odl: usb_c0_int_odl { - gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; - }; - gpio_vccin_aux_vid0: vccin_aux_vid0 { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - gpio_vccin_aux_vid1: vccin_aux_vid1 { - gpios = <&gpioe 3 GPIO_INPUT>; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_ec_i2c_eeprom: ec_i2c_eeprom { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_ec_i2c_sensor: ec_i2c_sensor { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_C0_TCPC"; - }; - i2c_ec_i2c_batt: ec_i2c_batt { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_BATTERY"; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan0_gp45 - &adc0_chan1_gp44 - &adc0_chan4_gp41 - &adc0_chan6_gp34 - &adc0_chan10_gpe0>; - pinctrl-names = "default"; -}; - - -&i2c0_0 { - status = "okay"; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; -}; - -&i2c1_0 { - status = "okay"; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; -}; - -&i2c3_0 { - status = "okay"; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; -}; - -&i2c7_0 { - status = "okay"; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/nissa/pujjo/keyboard.dtsi b/zephyr/projects/nissa/pujjo/keyboard.dtsi deleted file mode 100644 index 00610e4e18..0000000000 --- a/zephyr/projects/nissa/pujjo/keyboard.dtsi +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm6 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm6_gpc0>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/pujjo/motionsense.dtsi b/zephyr/projects/nissa/pujjo/motionsense.dtsi deleted file mode 100644 index 2dfca337c4..0000000000 --- a/zephyr/projects/nissa/pujjo/motionsense.dtsi +++ /dev/null @@ -1,245 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * Interrupt bindings for sensor devices. - */ - bmi3xx-int = &base_accel; - lsm6dsm-int = &base_accel; - lis2dw12-int = &lid_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: base-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - (-1) 0 0 - 0 0 (-1)>; - }; - - lid_rot_lis2dw12: lid-rotation-lis2dw12 { - mat33 = <0 (-1) 0 - (-1) 0 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_lsm6dsm: base-rotation-lsm6dsm { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bmi323_data: bmi323-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - - lsm6dsm_data_accel: lsm6dsm-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dsm"; - status = "okay"; - }; - - lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dsm"; - status = "okay"; - }; - - bma422_data: bma422-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - * TODO(b/238139272): The first entries of the array must be - * accelerometers,then gyroscope. Fix this dependency in the DTS - * processing which makes the devicetree entries independent. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma422_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi323_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi323_data>; - }; - }; - - motionsense-sensor-alt { - alt_lid_accel: alt-lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_lis2dw12>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS"; - alternate-for = <&lid_accel>; - alternate-ssfc-indicator = <&lid_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_accel: alt-base-accel { - compatible = "cros-ec,lsm6dsm-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_lsm6dsm>; - drv-data = <&lsm6dsm_data_accel>; - alternate-for = <&base_accel>; - alternate-ssfc-indicator = <&base_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - ec-rate = <0>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,lsm6dsm-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_lsm6dsm>; - drv-data = <&lsm6dsm_data_gyro>; - alternate-for = <&base_gyro>; - alternate-ssfc-indicator = <&base_sensor_1>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/nissa/pujjo/overlay.dtsi b/zephyr/projects/nissa/pujjo/overlay.dtsi deleted file mode 100644 index 60b3b60003..0000000000 --- a/zephyr/projects/nissa/pujjo/overlay.dtsi +++ /dev/null @@ -1,350 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_odl; - int-wp = &int_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - ec-console { - compatible = "ec-console"; - disabled = "events", "lpc", "hostcmd"; - }; - - batteries { - default_battery: smp { - compatible = "smp,l22m3pg0", "battery-smart"; - }; - smp_l22m3pg1 { - compatible = "smp,l22m3pg1", "battery-smart"; - }; - sunwoda_l22d3pg0 { - compatible = "sunwoda,l22d3pg0", "battery-smart"; - }; - sunwoda_l22d3pg1 { - compatible = "sunwoda,l22d3pg1", "battery-smart"; - }; - celxpert_l22c3pg0 { - compatible = "celxpert,l22c3pg0", "battery-smart"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_power_button - &int_lid_open - >; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_imu: ec_imu { - irq-pin = <&gpio_imu_int_l>; - flags = ; - handler = "motion_interrupt"; - }; - int_vol_down: vol_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_vol_up: vol_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_usb_c0: usb_c0 { - irq-pin = <&gpio_usb_c0_int_odl>; - flags = ; - handler = "usb_interrupt"; - }; - }; - - named-gpios { - gpio_sb_2: sb_2 { - gpios = <&gpiod 4 GPIO_OUTPUT>; - no-auto-init; - }; - - gpio_sb_3: sb_3 { - gpios = <&gpiof 5 GPIO_OPEN_DRAIN>; - no-auto-init; - }; - gpio_sb_4: sb_4 { - gpios = <&gpiof 4 GPIO_INPUT>; - no-auto-init; - }; - gpio_fan_enable: fan-enable { - gpios = <&gpio6 3 GPIO_OUTPUT>; - no-auto-init; - }; - gpio_power_led: power_led { - gpios = <&gpioc 2 GPIO_OUTPUT_LOW>; - }; - gpio_led_1_odl: led_1_odl { - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - gpio_led_2_odl: led_2_odl { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - }; - - /* - * Aliases used for sub-board GPIOs. - */ - aliases { - /* - * Sub-board with type A USB, enable. - */ - gpio-en-usb-a1-vbus = &gpio_sb_2; - /* - * HPD pins for HDMI sub-board. - */ - gpio-hdmi-en-odl = &gpio_sb_3; - gpio-hpd-odl = &gpio_sb_4; - /* - * Enable S5 rails for LTE sub-board - */ - gpio-en-sub-s5-rails = &gpio_sb_2; - }; - - temp_cpu: cpu { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_1>; - }; - temp_ddr: ddr { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_2>; - }; - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_3>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - cpu { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <90>; - temp_host_halt = <100>; - temp_host_release_high = <85>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_cpu>; - }; - ddr { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <90>; - temp_host_halt = <100>; - temp_host_release_high = <85>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_ddr>; - }; - ambient { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <90>; - temp_host_halt = <100>; - temp_host_release_high = <85>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_ambient>; - }; - }; - - usba { - compatible = "cros-ec,usba-port-enable-pins"; - /* - * sb_2 is only configured as GPIO when USB-A1 is present, - * but it's still safe to control when disabled. - * - * ILIM_SEL pins are referred to by legacy enum name, - * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on - * sub-boards that don't have USB-A so is safe to control - * regardless of system configuration. - */ - enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; - status = "okay"; - }; - - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - chg = <&chg_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; - - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm5 5 PWM_KHZ(1) PWM_POLARITY_NORMAL>; - rpm_min = <2200>; - rpm_start = <2200>; - rpm_max = <4200>; - tach = <&tach2>; - enable_gpio = <&gpio_fan_enable>; - }; - }; - - /* - * Declare unused GPIOs so that they are shut down - * and use minimal power - */ - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio3 3 0>, - <&gpio3 6 0>, - <&gpiod 7 0>, - <&gpiof 2 0>, - <&gpiof 3 0>; - }; -}; - -&thermistor_3V3_51K1_47K_4050B { - status = "okay"; -}; - -&adc_ec_vsense_pp3300_s5 { - /* - * Voltage divider on input has 47k upper and 220k lower legs with - * 2714 mV full-scale reading on the ADC. Apply the largest possible - * multiplier (without overflowing int32) to get the best possible - * approximation of the actual ratio, but derate by a factor of two to - * ensure unexpectedly high values won't overflow. - */ - mul = <(791261 / 2)>; - div = <(651975 / 2)>; -}; - -/* Set bus speeds for I2C */ -&i2c0_0 { - label = "I2C_EEPROM"; - clock-frequency = ; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c1_0 { - label = "I2C_SENSOR"; - clock-frequency = ; -}; - -&i2c3_0 { - label = "I2C_USB_C0_TCPC"; - clock-frequency = ; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - /* - * BC1.2 interrupt is shared with TCPC, so - * IRQ is not specified here and handled by - * usb_c0_interrupt. - */ - }; - - chg_port0: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&i2c7_0 { - label = "I2C_BATTERY"; - clock-frequency = ; -}; - -&pwm5_gpb7 { - drive-open-drain; -}; - -&pwm5 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm5_gpb7>; - pinctrl-names = "default"; -}; - -/* Tachometer for fan speed measurement */ -&tach2 { - status = "okay"; - pinctrl-0 = <&ta2_1_in_gp73>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; - -/* - * Declare GPIOs that have leakage current caused by board issues here. NPCX ec - * will disable their input buffers before entering deep sleep and restore them - * after waking up automatically for better power consumption. - */ -&power_leakage_io { - leak-gpios = <&gpioa 4 0 - &gpiof 1 0>; -}; diff --git a/zephyr/projects/nissa/pujjo/power_signals.dtsi b/zephyr/projects/nissa/pujjo/power_signals.dtsi deleted file mode 100644 index 1d2b23069d..0000000000 --- a/zephyr/projects/nissa/pujjo/power_signals.dtsi +++ /dev/null @@ -1,220 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <10>; - all-sys-pwrgd-timeout = <20>; - }; - - pwr-en-pp5000-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP5000_S5 enable output to regulator"; - enum-name = "PWR_EN_PP5000_A"; - gpios = <&gpio4 0 0>; - output; - }; - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpiob 6 0>; - output; - }; - pwr-pg-ec-rsmrst-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpio9 4 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioa 6 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-sus-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_SUS_L input from PCH"; - enum-name = "PWR_SLP_SUS"; - gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-ec-soc-dsw-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "DSW_PWROK output to PCH"; - enum-name = "PWR_EC_SOC_DSW_PWROK"; - gpios = <&gpio6 1 0>; - output; - }; - pwr-vccst-pwrgd-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VCCST_PWRGD output to PCH"; - enum-name = "PWR_VCCST_PWRGD"; - gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; - output; - }; - pwr-imvp9-vrrdy-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VRRDY input from IMVP9"; - enum-name = "PWR_IMVP9_VRRDY"; - gpios = <&gpio4 3 0>; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpio3 7 0>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - compatible = "intel,ap-pwrseq-external"; - dbg-label = "Combined all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - }; - pwr-adc-pp3300 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP3300 PWROK (from ADC)"; - enum-name = "PWR_DSW_PWROK"; - trigger-high = <&cmp_pp3300_s5_high>; - trigger-low = <&cmp_pp3300_s5_low>; - }; - pwr-adc-pp1p05 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP1P05 PWROK (from ADC)"; - enum-name = "PWR_PG_PP1P05"; - trigger-high = <&cmp_pp1p05_high>; - trigger-low = <&cmp_pp1p05_low>; - }; - - adc-cmp { - cmp_pp3300_s5_high: pp3300_high { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 6>; - comparison = "ADC_CMP_NPCX_GREATER"; - /* - * This is 90% of nominal voltage considering voltage - * divider on ADC input. - */ - threshold-mv = <2448>; - }; - cmp_pp3300_s5_low: pp3300_low { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 6>; - comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; - threshold-mv = <2448>; - }; - cmp_pp1p05_high: pp1p05_high { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 4>; - comparison = "ADC_CMP_NPCX_GREATER"; - /* Setting at 90% of nominal voltage */ - threshold-mv = <945>; - }; - cmp_pp1p05_low: pp1p05_low { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 4>; - comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; - threshold-mv = <945>; - }; - }; -}; - -/* - * Because the power signals directly reference the GPIOs, - * the correspinding named-gpios need to have no-auto-init set. - */ -&gpio_ec_soc_dsw_pwrok { - no-auto-init; -}; -&gpio_ec_soc_pch_pwrok_od { - no-auto-init; -}; -&gpio_ec_soc_rsmrst_l { - no-auto-init; -}; -&gpio_ec_soc_sys_pwrok { - no-auto-init; -}; -&gpio_ec_soc_vccst_pwrgd_od { - no-auto-init; -}; -&gpio_en_pp3300_s5 { - no-auto-init; -}; -&gpio_en_pp5000_s5 { - no-auto-init; -}; -&gpio_imvp91_vrrdy_od { - no-auto-init; -}; -&gpio_rsmrst_pwrgd_l { - no-auto-init; -}; -&gpio_slp_s0_l { - no-auto-init; -}; -&gpio_slp_s3_l { - no-auto-init; -}; -&gpio_slp_s4_l { - no-auto-init; -}; -&gpio_slp_sus_l { - no-auto-init; -}; -&gpio_sys_rst_odl { - no-auto-init; -}; diff --git a/zephyr/projects/nissa/pujjo/project.conf b/zephyr/projects/nissa/pujjo/project.conf deleted file mode 100644 index b9dc28b9cd..0000000000 --- a/zephyr/projects/nissa/pujjo/project.conf +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_PUJJO=y - -# Sensor drivers -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM=y -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y - -# Increase PD max power from default -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250 - -# LED -CONFIG_PLATFORM_EC_LED_PWM=n -CONFIG_PLATFORM_EC_LED_COMMON=y - -# CBI -CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# DPS -CONFIG_PLATFORM_EC_USB_PD_DPS=n - -# BTN -CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y - -# Charger -CONFIG_PLATFORM_EC_RAA489000_TRICKLE_CHARGE_CURRENT_256MA=y \ No newline at end of file diff --git a/zephyr/projects/nissa/pujjo/project.overlay b/zephyr/projects/nissa/pujjo/project.overlay deleted file mode 100644 index e498775714..0000000000 --- a/zephyr/projects/nissa/pujjo/project.overlay +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../cbi.dtsi" - -#include "cbi.dtsi" -#include "generated.dtsi" -#include "keyboard.dtsi" -#include "motionsense.dtsi" -#include "overlay.dtsi" -#include "power_signals.dtsi" diff --git a/zephyr/projects/nissa/pujjo/pujjo_vif.xml b/zephyr/projects/nissa/pujjo/pujjo_vif.xml deleted file mode 100644 index b7d462584a..0000000000 --- a/zephyr/projects/nissa/pujjo/pujjo_vif.xml +++ /dev/null @@ -1,350 +0,0 @@ - - - 3.19 - - USB-IF - VIF Editor - 3.2.4.0 - - Google - Pujjo - 1 - 0 - Port Product - End Product - - - - - - - - - 0 - Type-C® - - - DRP - DRP - - Charging Port - - - - - - - - - Revision 3 - - - - - - - 18D1 - 505A - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 15000 mW - Assured - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - FR_Swap not supported - - - - Over-Current Response - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - 0 msec - 3000 mA - - - - - - 60000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 20000 mV - - - - Variable - 4750 mV - 20000 mV - 3000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505A - 0000 - - - - - - - 1 - Type-C® - - - DRP - DRP - - Charging Port - - - - - - - - - Revision 3 - - - - - - - 18D1 - 505A - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 15000 mW - Assured - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - FR_Swap not supported - - - - Over-Current Response - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - 0 msec - 3000 mA - - - - - - 60000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 20000 mV - - - - Variable - 4750 mV - 20000 mV - 3000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505A - 0000 - - \ No newline at end of file diff --git a/zephyr/projects/nissa/pujjo/src/charger.c b/zephyr/projects/nissa/pujjo/src/charger.c deleted file mode 100644 index f1f1d57790..0000000000 --- a/zephyr/projects/nissa/pujjo/src/charger.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery.h" -#include "charger.h" -#include "charger/isl923x_public.h" -#include "driver/tcpm/raa489000.h" -#include "driver/charger/isl923x.h" -#include "console.h" -#include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" -#include "hooks.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -int extpower_is_present(void) -{ - int port; - int rv; - bool acok; - - for (port = 0; port < board_get_usb_pd_port_count(); port++) { - rv = raa489000_is_acok(port, &acok); - if ((rv == EC_SUCCESS) && acok) - return 1; - } - - return 0; -} - -/* - * Pujjo does not have a GPIO indicating whether extpower is present, - * so detect using the charger(s). - */ -__override void board_check_extpower(void) -{ - static int last_extpower_present; - int extpower_present = extpower_is_present(); - - if (last_extpower_present ^ extpower_present) - extpower_handle_update(extpower_present); - - last_extpower_present = extpower_present; -} - -__override void board_hibernate(void) -{ - /* Shut down the chargers */ - raa489000_hibernate(0, true); - LOG_INF("Charger(s) hibernated"); - cflush(); -} - -static void charger_prochot_init(void) -{ - isl923x_set_ac_prochot(CHARGER_SOLO, 3500); - isl923x_set_dc_prochot(CHARGER_SOLO, 6528); -} -DECLARE_HOOK(HOOK_INIT, charger_prochot_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/nissa/pujjo/src/fan.c b/zephyr/projects/nissa/pujjo/src/fan.c deleted file mode 100644 index 97323a7edf..0000000000 --- a/zephyr/projects/nissa/pujjo/src/fan.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -/* - * Pujjo fan support - */ -static void fan_init(void) -{ - int ret; - uint32_t val; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - if (val != FW_FAN_PRESENT) { - /* Disable the fan */ - fan_set_count(0); - } else { - /* Configure the fan enable GPIO */ - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), - GPIO_OUTPUT); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/nissa/pujjo/src/form_factor.c b/zephyr/projects/nissa/pujjo/src/form_factor.c deleted file mode 100644 index 6b02a258bc..0000000000 --- a/zephyr/projects/nissa/pujjo/src/form_factor.c +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "accelgyro.h" -#include "button.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/accelgyro_bmi323.h" -#include "driver/accelgyro_lsm6dsm.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "motionsense_sensors.h" -#include "motion_sense.h" -#include "tablet_mode.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -static bool use_alt_sensor; - -void motion_interrupt(enum gpio_signal signal) -{ - if (use_alt_sensor) - lsm6dsm_interrupt(signal); - else - bmi3xx_interrupt(signal); -} - -static void sensor_init(void) -{ - int ret; - uint32_t val; - /* check which base sensor is used for motion_interrupt */ - use_alt_sensor = cros_cbi_ssfc_check_match( - CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); - - motion_sensors_check_ssfc(); - - /* Check if it's tablet or not */ - ret = cros_cbi_get_fw_config(FW_TABLET, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_TABLET); - return; - } - if (val == FW_TABLET_NOT_PRESENT) { - LOG_INF("Clamshell: disable motionsense function."); - motion_sensor_count = 0; - gmr_tablet_switch_disable(); - gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu)); - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l), - GPIO_DISCONNECTED); - - LOG_INF("Clamshell: disable volume button function."); - button_disable_gpio(BUTTON_VOLUME_UP); - button_disable_gpio(BUTTON_VOLUME_DOWN); - } else { - LOG_INF("Tablet: Enable motionsense function."); - } -} -DECLARE_HOOK(HOOK_INIT, sensor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/projects/nissa/pujjo/src/hdmi.c b/zephyr/projects/nissa/pujjo/src/hdmi.c deleted file mode 100644 index 9461e7c53e..0000000000 --- a/zephyr/projects/nissa/pujjo/src/hdmi.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "nissa_hdmi.h" - -__override void nissa_configure_hdmi_power_gpios(void) -{ - /* Pujjo needs to drive VCC enable but not core rails */ - nissa_configure_hdmi_vcc(); -} diff --git a/zephyr/projects/nissa/pujjo/src/keyboard.c b/zephyr/projects/nissa/pujjo/src/keyboard.c deleted file mode 100644 index 1587030080..0000000000 --- a/zephyr/projects/nissa/pujjo/src/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config pujjo_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_BRIGHTNESS_DOWN, /* T5 */ - TK_BRIGHTNESS_UP, /* T6 */ - TK_MICMUTE, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &pujjo_kb; -} diff --git a/zephyr/projects/nissa/pujjo/src/led.c b/zephyr/projects/nissa/pujjo/src/led.c deleted file mode 100644 index bd04af5a25..0000000000 --- a/zephyr/projects/nissa/pujjo/src/led.c +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Pujjo specific PWM LED settings: there are 2 LEDs on each side of the board, - * each one can be controlled separately. The LED colors are white or amber, - * and the default behavior is tied to the charging process: both sides are - * amber while charging the battery and white when the battery is charged. - */ - -#include "common.h" -#include "led_onoff_states.h" -#include "led_common.h" -#include "gpio.h" - -#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) - -#define LED_OFF_LVL 1 -#define LED_ON_LVL 0 - -__override const int led_charge_lvl_1 = 5; - -__override const int led_charge_lvl_2 = 97; - -__override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, - LED_INDEFINITE } }, - [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, - { EC_LED_COLOR_GREEN, - 2 * LED_ONE_SEC } }, - }; - -__override const struct led_descriptor - led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { - [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, - [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, - 3 * LED_ONE_SEC }, - { LED_OFF, 0.5 * LED_ONE_SEC } }, - [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, - 3 * LED_ONE_SEC }, - { LED_OFF, - 0.5 * LED_ONE_SEC } }, - [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, - }; - -const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED, - EC_LED_ID_POWER_LED }; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -__override void led_set_color_power(enum ec_led_colors color) -{ - if (color == EC_LED_COLOR_WHITE) - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led), - LED_ON_LVL); - else - /* LED_OFF and unsupported colors */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led), - LED_OFF_LVL); -} - -__override void led_set_color_battery(enum ec_led_colors color) -{ - switch (color) { - case EC_LED_COLOR_AMBER: - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), - LED_ON_LVL); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), - LED_ON_LVL); - break; - case EC_LED_COLOR_RED: - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), - LED_ON_LVL); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), - LED_OFF_LVL); - break; - case EC_LED_COLOR_GREEN: - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), - LED_OFF_LVL); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), - LED_ON_LVL); - break; - default: /* LED_OFF and other unsupported colors */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), - LED_OFF_LVL); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), - LED_OFF_LVL); - break; - } -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - if (led_id == EC_LED_ID_BATTERY_LED) { - brightness_range[EC_LED_COLOR_RED] = 1; - brightness_range[EC_LED_COLOR_AMBER] = 1; - brightness_range[EC_LED_COLOR_GREEN] = 1; - } else if (led_id == EC_LED_ID_POWER_LED) { - brightness_range[EC_LED_COLOR_WHITE] = 1; - } -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - if (led_id == EC_LED_ID_BATTERY_LED) { - if (brightness[EC_LED_COLOR_RED] != 0) - led_set_color_battery(EC_LED_COLOR_RED); - else if (brightness[EC_LED_COLOR_AMBER] != 0) - led_set_color_battery(EC_LED_COLOR_AMBER); - else if (brightness[EC_LED_COLOR_GREEN] != 0) - led_set_color_battery(EC_LED_COLOR_GREEN); - else - led_set_color_battery(LED_OFF); - } else if (led_id == EC_LED_ID_POWER_LED) { - if (brightness[EC_LED_COLOR_WHITE] != 0) - led_set_color_power(EC_LED_COLOR_WHITE); - else - led_set_color_power(LED_OFF); - } - - return EC_SUCCESS; -} diff --git a/zephyr/projects/nissa/pujjo/src/usbc.c b/zephyr/projects/nissa/pujjo/src/usbc.c deleted file mode 100644 index 5d3d94c243..0000000000 --- a/zephyr/projects/nissa/pujjo/src/usbc.c +++ /dev/null @@ -1,242 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "charge_state_v2.h" -#include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" -#include "driver/charger/isl923x_public.h" -#include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" -#include "driver/tcpm/raa489000.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - -int board_is_sourcing_vbus(int port) -{ - int regval; - - tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); - return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); -} - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; - int old_port; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - old_port = charge_manager_get_active_charge_port(); - - LOG_INF("New chg p%d", port); - - /* Disable all ports. */ - if (port == CHARGE_PORT_NONE) { - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - tcpc_write(i, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_LOW); - raa489000_enable_asgate(i, false); - } - - return EC_SUCCESS; - } - - /* Check if port is sourcing VBUS. */ - if (board_is_sourcing_vbus(port)) { - LOG_WRN("Skip enable p%d", port); - return EC_ERROR_INVAL; - } - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (i == port) - continue; - - if (tcpc_write(i, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_LOW)) - LOG_WRN("p%d: sink path disable failed.", i); - raa489000_enable_asgate(i, false); - } - - /* - * Stop the charger IC from switching while changing ports. Otherwise, - * we can overcurrent the adapter we're switching to. (crbug.com/926056) - */ - if (old_port != CHARGE_PORT_NONE) - charger_discharge_on_ac(1); - - /* Enable requested charge port. */ - if (raa489000_enable_asgate(port, true) || - tcpc_write(port, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { - LOG_WRN("p%d: sink path enable failed.", port); - charger_discharge_on_ac(0); - return EC_ERROR_UNKNOWN; - } - - /* Allow the charger IC to begin/continue switching. */ - charger_discharge_on_ac(0); - - return EC_SUCCESS; -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - int regval; - - /* - * The interrupt line is shared between the TCPC and BC1.2 detector IC. - * Therefore, go out and actually read the alert registers to report the - * alert status. - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { - if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { - /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ - if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_0; - } - } - return status; -} - -void pd_power_supply_reset(int port) -{ - /* Disable VBUS */ - tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) -{ - if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) - return; - - raa489000_set_output_current(port, rp); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) - return EC_ERROR_INVAL; - - /* Disable charging. */ - rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); - if (rv) - return rv; - - /* Our policy is not to source VBUS when the AP is off. */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - return EC_ERROR_NOT_POWERED; - - /* Provide Vbus. */ - rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); - if (rv) - return rv; - - rv = raa489000_enable_asgate(port, true); - if (rv) - return rv; - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -void board_reset_pd_mcu(void) -{ - /* - * TODO(b:147316511): could send a reset command to the TCPC here - * if needed. - */ -} - -/* - * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible - * for an interrupt to be lost if one asserts the IRQ, the other does the same - * then the first releases it: there will only be one falling edge to trigger - * the interrupt, and the line will be held low. We handle this by running a - * deferred check after a falling edge to see whether the IRQ is still being - * asserted. If it is, we assume an interrupt may have been lost and we need - * to poll each chip for events again. - */ -#define USBC_INT_POLL_DELAY_US 5000 - -static void poll_c0_int(void); -DECLARE_DEFERRED(poll_c0_int); - -static void usbc_interrupt_trigger(int port) -{ - schedule_deferred_pd_interrupt(port); - usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); -} - -static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, - const struct deferred_data *ud) -{ - if (!gpio_pin_get_dt(gpio)) { - usbc_interrupt_trigger(port); - hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); - } -} - -static void poll_c0_int(void) -{ - poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), - &poll_c0_int_data); -} - -void usb_interrupt(enum gpio_signal signal) -{ - int port; - const struct deferred_data *ud; - - if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { - port = 0; - ud = &poll_c0_int_data; - } - /* - * We've just been called from a falling edge, so there's definitely - * no lost IRQ right now. Cancel any pending check. - */ - hook_call_deferred(ud, -1); - /* Trigger polling of TCPC and BC1.2 in respective tasks */ - usbc_interrupt_trigger(port); - /* Check for lost interrupts in a bit */ - hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); -} diff --git a/zephyr/projects/nissa/src/board_power.c b/zephyr/projects/nissa/src/board_power.c deleted file mode 100644 index d7fb4aeffe..0000000000 --- a/zephyr/projects/nissa/src/board_power.c +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "gpio_signal.h" -#include "gpio/gpio.h" - -LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); - -#define X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS 5 - -static bool s0_stable; - -static void generate_ec_soc_dsw_pwrok_handler(int delay) -{ - int in_sig_val = power_signal_get(PWR_DSW_PWROK); - - if (in_sig_val != power_signal_get(PWR_EC_SOC_DSW_PWROK)) { - if (in_sig_val) - k_msleep(delay); - power_signal_set(PWR_EC_SOC_DSW_PWROK, 1); - } -} - -void board_ap_power_force_shutdown(void) -{ - int timeout_ms = X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS; - - if (s0_stable) { - /* Enable these power signals in case of sudden shutdown */ - power_signal_enable(PWR_DSW_PWROK); - power_signal_enable(PWR_PG_PP1P05); - } - - power_signal_set(PWR_EC_SOC_DSW_PWROK, 0); - power_signal_set(PWR_EC_PCH_RSMRST, 0); - - while (power_signal_get(PWR_RSMRST) == 0 && - power_signal_get(PWR_SLP_SUS) == 0 && timeout_ms > 0) { - k_msleep(1); - timeout_ms--; - } - if (power_signal_get(PWR_SLP_SUS) == 0) { - LOG_WRN("SLP_SUS is not deasserted! Assuming G3"); - } - - if (power_signal_get(PWR_RSMRST) == 1) { - LOG_WRN("RSMRST is not deasserted! Assuming G3"); - } - - power_signal_set(PWR_EN_PP3300_A, 0); - - power_signal_set(PWR_EN_PP5000_A, 0); - - timeout_ms = X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS; - while (power_signal_get(PWR_DSW_PWROK) && timeout_ms > 0) { - k_msleep(1); - timeout_ms--; - }; - - if (power_signal_get(PWR_DSW_PWROK)) - LOG_WRN("DSW_PWROK didn't go low! Assuming G3."); - - power_signal_disable(PWR_DSW_PWROK); - power_signal_disable(PWR_PG_PP1P05); - s0_stable = false; -} - -void board_ap_power_action_g3_s5(void) -{ - power_signal_enable(PWR_DSW_PWROK); - power_signal_enable(PWR_PG_PP1P05); - - LOG_DBG("Turning on PWR_EN_PP5000_A and PWR_EN_PP3300_A"); - power_signal_set(PWR_EN_PP5000_A, 1); - power_signal_set(PWR_EN_PP3300_A, 1); - - power_wait_signals_timeout(IN_PGOOD_ALL_CORE, - AP_PWRSEQ_DT_VALUE(wait_signal_timeout)); - - generate_ec_soc_dsw_pwrok_handler(AP_PWRSEQ_DT_VALUE(dsw_pwrok_delay)); - s0_stable = false; -} - -void board_ap_power_action_s3_s0(void) -{ - s0_stable = false; -} - -void board_ap_power_action_s0_s3(void) -{ - power_signal_enable(PWR_DSW_PWROK); - power_signal_enable(PWR_PG_PP1P05); - s0_stable = false; -} - -void board_ap_power_action_s0(void) -{ - if (s0_stable) { - return; - } - LOG_INF("Reaching S0"); - power_signal_disable(PWR_DSW_PWROK); - power_signal_disable(PWR_PG_PP1P05); - s0_stable = true; -} - -int board_ap_power_assert_pch_power_ok(void) -{ - /* Pass though PCH_PWROK */ - if (power_signal_get(PWR_PCH_PWROK) == 0) { - k_msleep(AP_PWRSEQ_DT_VALUE(pch_pwrok_delay)); - power_signal_set(PWR_PCH_PWROK, 1); - } - - return 0; -} - -bool board_ap_power_check_power_rails_enabled(void) -{ - return power_signal_get(PWR_EN_PP3300_A) && - power_signal_get(PWR_EN_PP5000_A) && - power_signal_get(PWR_EC_SOC_DSW_PWROK); -} - -int board_power_signal_get(enum power_signal signal) -{ - switch (signal) { - default: - LOG_ERR("Unknown signal for board get: %d", signal); - return -EINVAL; - - case PWR_ALL_SYS_PWRGD: - /* - * All system power is good. - * Checks that PWR_SLP_S3 is off, and - * the GPIO signal for all power good is set, - * and that the 1.05 volt line is ready. - */ - if (power_signal_get(PWR_SLP_S3)) { - return 0; - } - if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_all_sys_pwrgd))) { - return 0; - } - if (!power_signal_get(PWR_PG_PP1P05)) { - return 0; - } - return 1; - } -} - -int board_power_signal_set(enum power_signal signal, int value) -{ - return -EINVAL; -} diff --git a/zephyr/projects/nissa/src/common.c b/zephyr/projects/nissa/src/common.c deleted file mode 100644 index 78f703ae49..0000000000 --- a/zephyr/projects/nissa/src/common.c +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "battery.h" -#include "charger.h" -#include "charge_state_v2.h" -#include "chipset.h" -#include "cros_cbi.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" - -#include "nissa_common.h" - -#include -LOG_MODULE_REGISTER(nissa, CONFIG_NISSA_LOG_LEVEL); - -static uint8_t cached_usb_pd_port_count; - -__override uint8_t board_get_usb_pd_port_count(void) -{ - __ASSERT(cached_usb_pd_port_count != 0, - "sub-board detection did not run before a port count request"); - if (cached_usb_pd_port_count == 0) - LOG_WRN("USB PD Port count not initialized!"); - return cached_usb_pd_port_count; -} - -static void board_power_change(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - /* - * Enable power to pen garage when system is active (safe even if no - * pen is present). - */ - const struct gpio_dt_spec *const pen_power_gpio = - GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_pen_x); - - switch (data.event) { - case AP_POWER_STARTUP: - gpio_pin_set_dt(pen_power_gpio, 1); - break; - case AP_POWER_SHUTDOWN: - gpio_pin_set_dt(pen_power_gpio, 0); - break; - default: - break; - } -} - -/* - * Initialise the USB PD port count, which - * depends on which sub-board is attached. - */ -static void board_setup_init(void) -{ - static struct ap_power_ev_callback cb; - - ap_power_ev_init_callback(&cb, board_power_change, - AP_POWER_STARTUP | AP_POWER_SHUTDOWN); - ap_power_ev_add_callback(&cb); - - switch (nissa_get_sb_type()) { - default: - cached_usb_pd_port_count = 1; - break; - - case NISSA_SB_C_A: - case NISSA_SB_C_LTE: - cached_usb_pd_port_count = 2; - break; - } -} -/* - * Make sure setup is done after EEPROM is readable. - */ -DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_INIT_I2C); - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * Assume charger overdraws by about 4%, keeping the actual draw - * within spec. This adjustment can be changed with characterization - * of actual hardware. - */ - icl = icl * 96 / 100; - charge_set_input_current_limit(icl, charge_mv); -} - -int pd_check_vconn_swap(int port) -{ - /* Allow VCONN swaps if the AP is on. */ - return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON); -} - -/* - * Count of chargers depends on sub board presence. - */ -__override uint8_t board_get_charger_chip_count(void) -{ - return board_get_usb_pd_port_count(); -} - -/* - * Retrieve sub-board type from FW_CONFIG. - */ -enum nissa_sub_board_type nissa_get_sb_type(void) -{ - static enum nissa_sub_board_type sb = NISSA_SB_UNKNOWN; - int ret; - uint32_t val; - - /* - * Return cached value. - */ - if (sb != NISSA_SB_UNKNOWN) - return sb; - - sb = NISSA_SB_NONE; /* Defaults to none */ - ret = cros_cbi_get_fw_config(FW_SUB_BOARD, &val); - if (ret != 0) { - LOG_WRN("Error retrieving CBI FW_CONFIG field %d", - FW_SUB_BOARD); - return sb; - } - switch (val) { - default: - LOG_WRN("No sub-board defined"); - break; - case FW_SUB_BOARD_1: - sb = NISSA_SB_C_A; - LOG_INF("SB: USB type C, USB type A"); - break; - - case FW_SUB_BOARD_2: - sb = NISSA_SB_C_LTE; - LOG_INF("SB: USB type C, WWAN LTE"); - break; - - case FW_SUB_BOARD_3: - sb = NISSA_SB_HDMI_A; - LOG_INF("SB: HDMI, USB type A"); - break; - } - return sb; -} diff --git a/zephyr/projects/nissa/src/led.c b/zephyr/projects/nissa/src/led.c deleted file mode 100644 index 2617d0092d..0000000000 --- a/zephyr/projects/nissa/src/led.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery LED control for nissa - */ -#include "common.h" -#include "ec_commands.h" -#include "led_common.h" -#include "led_onoff_states.h" -#include "led_pwm.h" - -__override const int led_charge_lvl_1 = 5; -__override const int led_charge_lvl_2 = 97; -__override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, - LED_INDEFINITE } }, - [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, - LED_INDEFINITE } }, - [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, - LED_INDEFINITE } }, - [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, - 1 * LED_ONE_SEC }, - { LED_OFF, 3 * LED_ONE_SEC } }, - [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, - [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, - { LED_OFF, 1 * LED_ONE_SEC } }, - [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, - { EC_LED_COLOR_GREEN, - 2 * LED_ONE_SEC } }, - }; - -__override void led_set_color_battery(enum ec_led_colors color) -{ - switch (color) { - case EC_LED_COLOR_RED: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_RED); - break; - case EC_LED_COLOR_GREEN: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_GREEN); - break; - case EC_LED_COLOR_AMBER: - set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); - break; - default: /* LED_OFF and other unsupported colors */ - set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); - break; - } -} diff --git a/zephyr/projects/nissa/src/sub_board.c b/zephyr/projects/nissa/src/sub_board.c deleted file mode 100644 index 3ccbcd9325..0000000000 --- a/zephyr/projects/nissa/src/sub_board.c +++ /dev/null @@ -1,298 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Nissa sub-board hardware configuration */ - -#include -#include -#include -#include -#include -#include - -#include "cros_board_info.h" -#include "driver/tcpm/tcpci.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "usb_charge.h" -#include "usb_pd.h" -#include "usbc/usb_muxes.h" -#include "task.h" - -#include "nissa_common.h" -#include "nissa_hdmi.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -#if NISSA_BOARD_HAS_HDMI_SUPPORT -static void hdmi_power_handler(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - /* Enable VCC on the HDMI port. */ - const struct gpio_dt_spec *s3_rail = - GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl); - /* Connect AP's DDC to sub-board (default is USB-C aux) */ - const struct gpio_dt_spec *ddc_select = - GPIO_DT_FROM_NODELABEL(gpio_hdmi_sel); - - switch (data.event) { - case AP_POWER_PRE_INIT: - LOG_DBG("Connecting HDMI DDC to sub-board"); - gpio_pin_set_dt(ddc_select, 1); - break; - case AP_POWER_STARTUP: - LOG_DBG("Enabling HDMI VCC"); - gpio_pin_set_dt(s3_rail, 1); - break; - case AP_POWER_SHUTDOWN: - LOG_DBG("Disabling HDMI VCC"); - gpio_pin_set_dt(s3_rail, 0); - break; - case AP_POWER_HARD_OFF: - LOG_DBG("Disconnecting HDMI sub-board DDC"); - gpio_pin_set_dt(ddc_select, 0); - break; - default: - LOG_ERR("Unhandled HDMI power event %d", data.event); - break; - } -} - -static void hdmi_hpd_interrupt(const struct device *device, - struct gpio_callback *callback, - gpio_port_pins_t pins) -{ - int state = gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_hpd_odl)); - - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_hdmi_hpd), state); - LOG_DBG("HDMI HPD changed state to %d", state); -} - -void nissa_configure_hdmi_rails(void) -{ -#if DT_NODE_EXISTS(GPIO_DT_FROM_ALIAS(gpio_en_rails_odl)) - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_rails_odl), - GPIO_OUTPUT_INACTIVE | GPIO_OPEN_DRAIN | - GPIO_PULL_UP | GPIO_ACTIVE_LOW); -#endif -} - -void nissa_configure_hdmi_vcc(void) -{ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl), - GPIO_OUTPUT_INACTIVE | GPIO_OPEN_DRAIN | - GPIO_ACTIVE_LOW); -} - -__overridable void nissa_configure_hdmi_power_gpios(void) -{ - nissa_configure_hdmi_rails(); -} - -#ifdef CONFIG_SOC_IT8XXX2 -/* - * On it8xxx2, the below condition will break the EC to enter deep doze mode - * (b:237717730): - * Enhance i2c (GPE0/E7, GPH1/GPH2 or GPA4/GPA5) is enabled and its clock and - * data pins aren't both at high level. - * - * Since HDMI+type A SKU doesn't use i2c4, disable it for better power number. - */ -#define I2C4_NODE DT_NODELABEL(i2c4) -#if DT_NODE_EXISTS(I2C4_NODE) -PINCTRL_DT_DEFINE(I2C4_NODE); - -/* disable i2c4 alternate function */ -static void soc_it8xxx2_disable_i2c4_alt(void) -{ - const struct pinctrl_dev_config *pcfg = - PINCTRL_DT_DEV_CONFIG_GET(I2C4_NODE); - - pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP); -} -#endif /* DT_NODE_EXISTS(I2C4_NODE) */ -#endif /* CONFIG_SOC_IT8XXX2 */ -#endif /* NISSA_BOARD_HAS_HDMI_SUPPORT */ - -static void lte_power_handler(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - /* Enable rails for S5 */ - const struct gpio_dt_spec *s5_rail = - GPIO_DT_FROM_ALIAS(gpio_en_sub_s5_rails); - switch (data.event) { - case AP_POWER_PRE_INIT: - LOG_DBG("Enabling LTE sub-board power rails"); - gpio_pin_set_dt(s5_rail, 1); - break; - case AP_POWER_HARD_OFF: - LOG_DBG("Disabling LTE sub-board power rails"); - gpio_pin_set_dt(s5_rail, 0); - break; - default: - LOG_ERR("Unhandled LTE power event %d", data.event); - break; - } -} - -/** - * Configure GPIOs (and other pin functions) that vary with present sub-board. - * - * The functions of some pins vary according to which sub-board is present - * (indicated by CBI fw_config); this function configures them according to the - * needs of the present sub-board. - */ -static void nereid_subboard_config(void) -{ - enum nissa_sub_board_type sb = nissa_get_sb_type(); - static struct ap_power_ev_callback power_cb; - - /* - * USB-A port: current limit output is configured by default and unused - * if this port is not present. VBUS enable must be configured if - * needed and is controlled by the usba-port-enable-pins driver. - */ - if (sb == NISSA_SB_C_A || sb == NISSA_SB_HDMI_A || - sb == NISSA_SB_NONE) { - /* - * Configure VBUS enable, default off. - * SB_NONE indicates missing fw_config; it's safe to enable VBUS - * control in this case since all that will happen is we turn - * off power to LTE, and it's useful to allow USB-A to work in - * such a configuration. - */ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus), - GPIO_OUTPUT_LOW); - } else { - /* Turn off unused pins */ - gpio_pin_configure_dt( - GPIO_DT_FROM_NODELABEL(gpio_sub_usb_a1_ilimit_sdp), - GPIO_DISCONNECTED); - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus), - GPIO_DISCONNECTED); - /* Disable second USB-A port enable GPIO */ - __ASSERT(USB_PORT_ENABLE_COUNT == 2, - "USB A port count != 2 (%d)", USB_PORT_ENABLE_COUNT); - usb_port_enable[1] = -1; - } - /* - * USB-C port: the default configuration has I2C on the I2C pins, - * but the interrupt line needs to be configured. - */ -#if CONFIG_USB_PD_PORT_MAX_COUNT > 1 - if (sb == NISSA_SB_C_A || sb == NISSA_SB_C_LTE) { - /* Configure interrupt input */ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), - GPIO_INPUT | GPIO_PULL_UP); - } else { - /* Port doesn't exist, doesn't need muxing */ - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_no_mux); - } -#endif - - switch (sb) { -#if NISSA_BOARD_HAS_HDMI_SUPPORT - case NISSA_SB_HDMI_A: { - /* - * HDMI: two outputs control power which must be configured to - * non-default settings, and HPD must be forwarded to the AP - * on another output pin. - */ - const struct gpio_dt_spec *hpd_gpio = - GPIO_DT_FROM_ALIAS(gpio_hpd_odl); - static struct gpio_callback hdmi_hpd_cb; - int rv, irq_key; - - nissa_configure_hdmi_power_gpios(); - -#if CONFIG_SOC_IT8XXX2 && DT_NODE_EXISTS(I2C4_NODE) - /* disable i2c4 alternate function for better power number */ - soc_it8xxx2_disable_i2c4_alt(); -#endif - - /* - * Control HDMI power according to AP power state. Some events - * won't do anything if the corresponding pin isn't configured, - * but that's okay. - */ - ap_power_ev_init_callback( - &power_cb, hdmi_power_handler, - AP_POWER_PRE_INIT | AP_POWER_HARD_OFF | - AP_POWER_STARTUP | AP_POWER_SHUTDOWN); - ap_power_ev_add_callback(&power_cb); - - /* - * Configure HPD input from sub-board; it's inverted by a buffer - * on the sub-board. - */ - gpio_pin_configure_dt(hpd_gpio, GPIO_INPUT | GPIO_ACTIVE_LOW); - /* Register interrupt handler for HPD changes */ - gpio_init_callback(&hdmi_hpd_cb, hdmi_hpd_interrupt, - BIT(hpd_gpio->pin)); - gpio_add_callback(hpd_gpio->port, &hdmi_hpd_cb); - rv = gpio_pin_interrupt_configure_dt(hpd_gpio, - GPIO_INT_EDGE_BOTH); - __ASSERT(rv == 0, - "HPD interrupt configuration returned error %d", rv); - /* - * Run the HPD handler once to ensure output is in sync. - * Lock interrupts to ensure that we don't cause desync if an - * HPD interrupt comes in between the internal read of the input - * and write to the output. - */ - irq_key = irq_lock(); - hdmi_hpd_interrupt(hpd_gpio->port, &hdmi_hpd_cb, - BIT(hpd_gpio->pin)); - irq_unlock(irq_key); - break; - } -#endif - case NISSA_SB_C_LTE: - /* - * LTE: Set up callbacks for enabling/disabling - * sub-board power on S5 state. - */ - gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_sub_s5_rails), - GPIO_OUTPUT_INACTIVE); - /* Control LTE power when CPU entering or - * exiting S5 state. - */ - ap_power_ev_init_callback(&power_cb, lte_power_handler, - AP_POWER_HARD_OFF | - AP_POWER_PRE_INIT); - ap_power_ev_add_callback(&power_cb); - break; - - default: - break; - } -} -DECLARE_HOOK(HOOK_INIT, nereid_subboard_config, HOOK_PRIO_POST_FIRST); - -/* - * Enable interrupts - */ -static void board_init(void) -{ - /* - * Enable USB-C interrupts. - */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0)); -#if CONFIG_USB_PD_PORT_MAX_COUNT > 1 - if (board_get_usb_pd_port_count() == 2) - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1)); -#endif -} -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); - -/* Trigger shutdown by enabling the Z-sleep circuit */ -__override void board_hibernate_late(void) -{ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_slp_z), 1); - /* - * The system should hibernate, but there may be - * a small delay, so return. - */ -} diff --git a/zephyr/projects/nissa/xivu/cbi.dtsi b/zephyr/projects/nissa/xivu/cbi.dtsi deleted file mode 100644 index 4149ea291c..0000000000 --- a/zephyr/projects/nissa/xivu/cbi.dtsi +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* Xivu-specific fw_config fields. */ - nissa-fw-config { - /* - * FW_CONFIG field to enable WFC or not. - */ - wfc { - enum-name = "FW_WFC"; - start = <0>; - size = <1>; - - wfc-mipi { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_WFC_MIPI"; - value = <0>; - }; - wfc-absent { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_WFC_ABSENT"; - value = <1>; - }; - }; - - /* - * FW_CONFIG field to enable stylus or not. - */ - stylus { - enum-name = "FW_STYLUS"; - start = <1>; - size = <1>; - - stylus-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_STYLUS_PRESENT"; - value = <0>; - }; - stylus-absent { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_STYLUS_ABSENT"; - value = <1>; - }; - }; - /* - * FW_CONFIG field to indicate which sub-board - * is attached. - */ - sub-board { - enum-name = "FW_SUB_BOARD"; - start = <2>; - size = <2>; - - sub-board-1 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_SUB_BOARD_1"; - value = <0>; - }; - sub-board-2 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_SUB_BOARD_2"; - value = <1>; - }; - sub-board-3 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_SUB_BOARD_3"; - value = <2>; - }; - }; - -/delete-node/ fan; - }; - -}; diff --git a/zephyr/projects/nissa/xivu/generated.dtsi b/zephyr/projects/nissa/xivu/generated.dtsi deleted file mode 100644 index 383054adf8..0000000000 --- a/zephyr/projects/nissa/xivu/generated.dtsi +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * This file is auto-generated - do not edit! - */ - -/ { - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { - enum-name = "ADC_PP1050_PROC"; - io-channels = <&adc0 4>; - }; - adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { - enum-name = "ADC_PP3300_S5"; - io-channels = <&adc0 6>; - }; - adc_temp_sensor_1: temp_sensor_1 { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 0>; - }; - adc_temp_sensor_2: temp_sensor_2 { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 1>; - }; - adc_temp_sensor_3: temp_sensor_3 { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 10>; - }; - adc_temp_sensor_4: temp_sensor_4 { - enum-name = "ADC_TEMP_SENSOR_4"; - io-channels = <&adc0 11>; - }; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_acc_int_l: acc_int_l { - gpios = <&gpio5 0 GPIO_INPUT>; - }; - gpio_all_sys_pwrgd: all_sys_pwrgd { - gpios = <&gpioa 7 GPIO_INPUT>; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_cpu_c10_gate_l: cpu_c10_gate_l { - gpios = <&gpio6 7 GPIO_INPUT>; - }; - gpio_ec_battery_pres_odl: ec_battery_pres_odl { - gpios = <&gpioa 3 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio7 4 GPIO_OUTPUT>; - }; - gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { - gpios = <&gpiod 3 GPIO_ODR_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_entering_rw: ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { - gpios = <&gpio7 5 GPIO_OUTPUT>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_ec_pch_wake_odl: ec_pch_wake_odl { - gpios = <&gpiob 0 GPIO_ODR_LOW>; - }; - gpio_ec_prochot_odl: ec_prochot_odl { - gpios = <&gpiof 1 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { - gpios = <&gpio6 1 GPIO_OUTPUT>; - }; - gpio_ec_acok_otg_c1: ec_acok_otg_c1 { - gpios = <&gpioe 4 GPIO_OUTPUT>; - }; - gpio_ec_soc_int_odl: ec_soc_int_odl { - gpios = <&gpio8 0 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { - gpios = <&gpio7 2 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { - gpios = <&gpioc 1 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioa 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_rtcrst: ec_soc_rtcrst { - gpios = <&gpio7 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { - gpios = <&gpio3 7 GPIO_OUTPUT>; - }; - gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { - gpios = <&gpioa 4 GPIO_ODR_HIGH>; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_en_pp3300_s5: en_pp3300_s5 { - gpios = <&gpiob 6 GPIO_OUTPUT>; - enum-name = "GPIO_TEMP_SENSOR_POWER"; - }; - gpio_en_pp5000_pen_x: en_pp5000_pen_x { - gpios = <&gpioe 2 GPIO_OUTPUT>; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpio4 0 GPIO_OUTPUT>; - }; - gpio_en_slp_z: en_slp_z { - gpios = <&gpioe 1 GPIO_OUTPUT>; - }; - gpio_en_usb_a0_vbus: en_usb_a0_vbus { - gpios = <&gpio9 1 GPIO_OUTPUT>; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_acok_otg_c0: ec_acok_otg_c0 { - gpios = <&gpioc 6 GPIO_OUTPUT>; - }; - gpio_imu_int_l: imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { - gpios = <&gpio4 3 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_pen_detect_odl: pen_detect_odl { - gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { - gpios = <&gpio4 2 GPIO_INPUT>; - }; - gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { - gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; - }; - gpio_slp_s0_l: slp_s0_l { - gpios = <&gpio9 7 GPIO_INPUT>; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpioa 5 GPIO_INPUT>; - }; - gpio_slp_s4_l: slp_s4_l { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_slp_sus_l: slp_sus_l { - gpios = <&gpio6 2 GPIO_INPUT>; - }; - gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { - gpios = <&gpiod 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB2_ILIM_SEL"; - }; - gpio_sys_rst_odl: sys_rst_odl { - gpios = <&gpioc 5 GPIO_ODR_HIGH>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpio9 5 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { - gpios = <&gpio3 3 GPIO_OUTPUT>; - enum-name = "GPIO_USB1_ILIM_SEL"; - }; - gpio_usb_c0_int_odl: usb_c0_int_odl { - gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; - }; - gpio_vccin_aux_vid0: vccin_aux_vid0 { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - gpio_vccin_aux_vid1: vccin_aux_vid1 { - gpios = <&gpioe 3 GPIO_INPUT>; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_ec_i2c_eeprom: ec_i2c_eeprom { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_ec_i2c_sensor: ec_i2c_sensor { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_C0_TCPC"; - }; - i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { - i2c-port = <&i2c5_1>; - enum-names = "I2C_PORT_USB_C1_TCPC"; - }; - i2c_ec_i2c_batt: ec_i2c_batt { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_BATTERY"; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan0_gp45 - &adc0_chan1_gp44 - &adc0_chan4_gp41 - &adc0_chan6_gp34 - &adc0_chan10_gpe0 - &adc0_chan11_gpc7>; - pinctrl-names = "default"; -}; - -&i2c0_0 { - status = "okay"; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; -}; - -&i2c1_0 { - status = "okay"; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; -}; - -&i2c3_0 { - status = "okay"; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; -}; - -&i2c5_1 { - status = "okay"; - pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>; - pinctrl-names = "default"; -}; - -&i2c7_0 { - status = "okay"; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/nissa/xivu/keyboard.dtsi b/zephyr/projects/nissa/xivu/keyboard.dtsi deleted file mode 100644 index 5248c4aaff..0000000000 --- a/zephyr/projects/nissa/xivu/keyboard.dtsi +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/xivu/led_pins.dtsi b/zephyr/projects/nissa/xivu/led_pins.dtsi deleted file mode 100644 index d85004a0c9..0000000000 --- a/zephyr/projects/nissa/xivu/led_pins.dtsi +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - pwm_led_y_c0: pwm_led_y_c0 { - #led-pin-cells = <1>; - pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - - pwm_led_w_c0: pwm_led_w_c0 { - #led-pin-cells = <1>; - pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - - pwm_led_y_c1: pwm_led_y_c1 { - #led-pin-cells = <1>; - pwms = <&pwm6 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - - pwm_led_w_c1: pwm_led_w_c1 { - #led-pin-cells = <1>; - pwms = <&pwm1 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_led_y_c0 0>, - <&pwm_led_y_c1 0>, - <&pwm_led_w_c0 0>, - <&pwm_led_w_c1 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_led_y_c0 1>, - <&pwm_led_y_c1 1>, - <&pwm_led_w_c0 0>, - <&pwm_led_w_c1 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_led_y_c0 0>, - <&pwm_led_y_c1 0>, - <&pwm_led_w_c0 1>, - <&pwm_led_w_c1 1>; - }; - }; -}; - -/* LED2 */ -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -/* LED3 */ -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -/* LED1 */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* LED0 */ -&pwm6 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm6_gpc0>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/xivu/led_policy.dtsi b/zephyr/projects/nissa/xivu/led_policy.dtsi deleted file mode 100644 index 562e361ec5..0000000000 --- a/zephyr/projects/nissa/xivu/led_policy.dtsi +++ /dev/null @@ -1,122 +0,0 @@ -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = <0 94>; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-charge-lvl-2 { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Near Full) */ - batt-lvl = <95 97>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= 11%, <= Full) */ - batt-lvl = <11 100>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= 10%) */ - batt-lvl = <0 10>; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-error-s0 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S0"; - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-error-s3 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S3"; - /* White 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-error-s5 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - }; -}; diff --git a/zephyr/projects/nissa/xivu/motionsense.dtsi b/zephyr/projects/nissa/xivu/motionsense.dtsi deleted file mode 100644 index 332252c4ef..0000000000 --- a/zephyr/projects/nissa/xivu/motionsense.dtsi +++ /dev/null @@ -1,156 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * Interrupt bindings for sensor devices. - */ - lsm6dso-int = &base_accel; - lis2dw12-int = &lid_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: base-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - lsm6dso_accel_data: lsm6dso-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - lsm6dso_gyro_data: lsm6dso-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - * TODO(b/238139272): The first entries of the array must be - * accelerometers,then gyroscope. Fix this dependency in the DTS - * processing which makes the devicetree entries independent. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,lsm6dso-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&lsm6dso_accel_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,lsm6dso-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ - drv-data = <&lsm6dso_gyro_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/nissa/xivu/overlay.dtsi b/zephyr/projects/nissa/xivu/overlay.dtsi deleted file mode 100644 index de45db75e7..0000000000 --- a/zephyr/projects/nissa/xivu/overlay.dtsi +++ /dev/null @@ -1,357 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_odl; - int-wp = &int_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - ec-console { - compatible = "ec-console"; - disabled = "events", "lpc", "hostcmd"; - }; - - batteries { - default_battery: smp_c31n2005 { - compatible = "smp,c31n2005", "battery-smart"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_power_button - &int_lid_open - >; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_imu: ec_imu { - irq-pin = <&gpio_imu_int_l>; - flags = ; - handler = "lsm6dso_interrupt"; - }; - int_vol_down: vol_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_vol_up: vol_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_usb_c0: usb_c0 { - irq-pin = <&gpio_usb_c0_int_odl>; - flags = ; - handler = "usb_interrupt"; - }; - int_usb_c1: usb_c1 { - irq-pin = <&gpio_sb_1>; - flags = ; - handler = "usb_interrupt"; - }; - }; - - named-gpios { - gpio_sb_1: sb-1 { - gpios = <&gpio0 2 GPIO_PULL_UP>; - no-auto-init; - }; - - gpio_sb_2: sb-2 { - gpios = <&gpiod 4 GPIO_OUTPUT>; - no-auto-init; - }; - - /* - * Set I2C pins for type C sub-board to be low voltage (I2C5_1). - * We do this for all boards, since the pins are 3.3V tolerant, - * and the only 2 types of sub-boards used on nivviks both have - * type-C ports on them. - */ - gpio_sb_3: sb-3 { - gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; - no-auto-init; - }; - gpio_sb_4: sb-4 { - gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - no-auto-init; - }; - }; - - /* - * Aliases used for sub-board GPIOs. - */ - aliases { - /* - * Input GPIO when used with type-C port 1 - */ - gpio-usb-c1-int-odl = &gpio_sb_1; - gpio-en-rails-odl = &gpio_sb_1; - /* - * Sub-board with type A USB, enable. - */ - gpio-en-usb-a1-vbus = &gpio_sb_2; - /* - * Enable S5 rails for LTE sub-board - */ - gpio-en-sub-s5-rails = &gpio_sb_2; - }; - - temp_memory: memory { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_1>; - }; - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_2>; - }; - temp_charger1: charger1 { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_3>; - }; - temp_charger2: charger2 { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_4>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - memory { - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_memory>; - }; - ambient { - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_ambient>; - }; - charger1 { - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_charger1>; - }; - charger2 { - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_charger2>; - }; - }; - - usba { - compatible = "cros-ec,usba-port-enable-pins"; - /* - * sb_2 is only configured as GPIO when USB-A1 is present, - * but it's still safe to control when disabled. - * - * ILIM_SEL pins are referred to by legacy enum name, - * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on - * sub-boards that don't have USB-A so is safe to control - * regardless of system configuration. - */ - enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; - status = "okay"; - }; - - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - chg = <&chg_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - /* - * TODO(b:211693800): port1 may not be present on some - * sub-boards. - */ - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - chg = <&chg_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; - }; - usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio8 5 0>, - <&gpio3 6 0>, - <&gpiod 7 0>, - <&gpio6 0 0>, - <&gpiof 2 0>, - <&gpiof 3 0>; - }; -}; - -&thermistor_3V3_51K1_47K_4050B { - status = "okay"; -}; - -&adc_ec_vsense_pp3300_s5 { - /* - * Voltage divider on input has 47k upper and 220k lower legs with - * 2714 mV full-scale reading on the ADC. Apply the largest possible - * multiplier (without overflowing int32) to get the best possible - * approximation of the actual ratio, but derate by a factor of two to - * ensure unexpectedly high values won't overflow. - */ - mul = <(791261 / 2)>; - div = <(651975 / 2)>; -}; - -/* Set bus speeds for I2C */ -&i2c0_0 { - label = "I2C_EEPROM"; - clock-frequency = ; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c1_0 { - label = "I2C_SENSOR"; - clock-frequency = ; -}; - -&i2c3_0 { - label = "I2C_USB_C0_TCPC"; - clock-frequency = ; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - /* - * BC1.2 interrupt is shared with TCPC, so - * IRQ is not specified here and handled by - * usb_c0_interrupt. - */ - }; - - chg_port0: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&i2c5_1 { - label = "I2C_SUB_C1_TCPC"; - clock-frequency = ; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port1: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; - - anx7483_mux_1: anx7483-mux-1@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "anx7483_set_default_tuning"; - }; -}; - -&i2c7_0 { - label = "I2C_BATTERY"; - clock-frequency = ; -}; - -&pwm6 { - status = "okay"; - pinctrl-0 = <&pwm6_gpc0>; - pinctrl-names = "default"; -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/xivu/power_signals.dtsi b/zephyr/projects/nissa/xivu/power_signals.dtsi deleted file mode 100644 index 1d2b23069d..0000000000 --- a/zephyr/projects/nissa/xivu/power_signals.dtsi +++ /dev/null @@ -1,220 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <10>; - all-sys-pwrgd-timeout = <20>; - }; - - pwr-en-pp5000-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP5000_S5 enable output to regulator"; - enum-name = "PWR_EN_PP5000_A"; - gpios = <&gpio4 0 0>; - output; - }; - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpiob 6 0>; - output; - }; - pwr-pg-ec-rsmrst-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpio9 4 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioa 6 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-sus-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_SUS_L input from PCH"; - enum-name = "PWR_SLP_SUS"; - gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-ec-soc-dsw-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "DSW_PWROK output to PCH"; - enum-name = "PWR_EC_SOC_DSW_PWROK"; - gpios = <&gpio6 1 0>; - output; - }; - pwr-vccst-pwrgd-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VCCST_PWRGD output to PCH"; - enum-name = "PWR_VCCST_PWRGD"; - gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; - output; - }; - pwr-imvp9-vrrdy-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VRRDY input from IMVP9"; - enum-name = "PWR_IMVP9_VRRDY"; - gpios = <&gpio4 3 0>; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpio3 7 0>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - compatible = "intel,ap-pwrseq-external"; - dbg-label = "Combined all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - }; - pwr-adc-pp3300 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP3300 PWROK (from ADC)"; - enum-name = "PWR_DSW_PWROK"; - trigger-high = <&cmp_pp3300_s5_high>; - trigger-low = <&cmp_pp3300_s5_low>; - }; - pwr-adc-pp1p05 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP1P05 PWROK (from ADC)"; - enum-name = "PWR_PG_PP1P05"; - trigger-high = <&cmp_pp1p05_high>; - trigger-low = <&cmp_pp1p05_low>; - }; - - adc-cmp { - cmp_pp3300_s5_high: pp3300_high { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 6>; - comparison = "ADC_CMP_NPCX_GREATER"; - /* - * This is 90% of nominal voltage considering voltage - * divider on ADC input. - */ - threshold-mv = <2448>; - }; - cmp_pp3300_s5_low: pp3300_low { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 6>; - comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; - threshold-mv = <2448>; - }; - cmp_pp1p05_high: pp1p05_high { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 4>; - comparison = "ADC_CMP_NPCX_GREATER"; - /* Setting at 90% of nominal voltage */ - threshold-mv = <945>; - }; - cmp_pp1p05_low: pp1p05_low { - compatible = "nuvoton,adc-cmp"; - io-channels = <&adc0 4>; - comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; - threshold-mv = <945>; - }; - }; -}; - -/* - * Because the power signals directly reference the GPIOs, - * the correspinding named-gpios need to have no-auto-init set. - */ -&gpio_ec_soc_dsw_pwrok { - no-auto-init; -}; -&gpio_ec_soc_pch_pwrok_od { - no-auto-init; -}; -&gpio_ec_soc_rsmrst_l { - no-auto-init; -}; -&gpio_ec_soc_sys_pwrok { - no-auto-init; -}; -&gpio_ec_soc_vccst_pwrgd_od { - no-auto-init; -}; -&gpio_en_pp3300_s5 { - no-auto-init; -}; -&gpio_en_pp5000_s5 { - no-auto-init; -}; -&gpio_imvp91_vrrdy_od { - no-auto-init; -}; -&gpio_rsmrst_pwrgd_l { - no-auto-init; -}; -&gpio_slp_s0_l { - no-auto-init; -}; -&gpio_slp_s3_l { - no-auto-init; -}; -&gpio_slp_s4_l { - no-auto-init; -}; -&gpio_slp_sus_l { - no-auto-init; -}; -&gpio_sys_rst_odl { - no-auto-init; -}; diff --git a/zephyr/projects/nissa/xivu/project.conf b/zephyr/projects/nissa/xivu/project.conf deleted file mode 100644 index fe56a9d562..0000000000 --- a/zephyr/projects/nissa/xivu/project.conf +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_XIVU=y -CONFIG_PLATFORM_EC_OCPC=y -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=n -CONFIG_PLATFORM_EC_LED_DT=y - -# USBC -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 - -# Battery -CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/projects/nissa/xivu/project.overlay b/zephyr/projects/nissa/xivu/project.overlay deleted file mode 100644 index a7c5b7e9e7..0000000000 --- a/zephyr/projects/nissa/xivu/project.overlay +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../cbi.dtsi" - -#include "cbi.dtsi" -#include "generated.dtsi" -#include "keyboard.dtsi" -#include "led_pins.dtsi" -#include "led_policy.dtsi" -#include "motionsense.dtsi" -#include "overlay.dtsi" -#include "power_signals.dtsi" diff --git a/zephyr/projects/nissa/xivu/src/charger.c b/zephyr/projects/nissa/xivu/src/charger.c deleted file mode 100644 index 5021a55758..0000000000 --- a/zephyr/projects/nissa/xivu/src/charger.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery.h" -#include "charger.h" -#include "charger/isl923x_public.h" -#include "console.h" -#include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -int extpower_is_present(void) -{ - int port; - int rv; - bool acok; - - for (port = 0; port < board_get_usb_pd_port_count(); port++) { - rv = raa489000_is_acok(port, &acok); - if ((rv == EC_SUCCESS) && acok) - return 1; - } - - return 0; -} - -/* - * Xivu does not have a GPIO indicating whether extpower is present, - * so detect using the charger(s). - */ -__override void board_check_extpower(void) -{ - static int last_extpower_present; - int extpower_present_p0 = 0; - int extpower_present_p1 = 0; - - int extpower_present = extpower_is_present(); - - if (last_extpower_present ^ extpower_present) - extpower_handle_update(extpower_present); - - last_extpower_present = extpower_present; - - if (pd_is_connected(0)) - extpower_present_p0 = extpower_is_present(); - else if (pd_is_connected(1)) - extpower_present_p1 = extpower_is_present(); - - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_acok_otg_c0), - extpower_present_p0); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_acok_otg_c1), - extpower_present_p1); -} - -__override void board_hibernate(void) -{ - /* Shut down the chargers */ - if (board_get_usb_pd_port_count() == 2) - raa489000_hibernate(CHARGER_SECONDARY, true); - raa489000_hibernate(CHARGER_PRIMARY, true); - LOG_INF("Charger(s) hibernated"); - cflush(); -} diff --git a/zephyr/projects/nissa/xivu/src/keyboard.c b/zephyr/projects/nissa/xivu/src/keyboard.c deleted file mode 100644 index ef799fb1d2..0000000000 --- a/zephyr/projects/nissa/xivu/src/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config xivu_kb_legacy = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* 8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &xivu_kb_legacy; -} diff --git a/zephyr/projects/nissa/xivu/src/usbc.c b/zephyr/projects/nissa/xivu/src/usbc.c deleted file mode 100644 index c4ba75f741..0000000000 --- a/zephyr/projects/nissa/xivu/src/usbc.c +++ /dev/null @@ -1,362 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "charge_state_v2.h" -#include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" -#include "driver/charger/isl923x_public.h" -#include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" -#include "driver/tcpm/raa489000.h" -#include "temp_sensor/temp_sensor.h" -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, - { /* sub-board */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - -int board_is_sourcing_vbus(int port) -{ - int regval; - - tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); - return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); -} - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; - int old_port; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - old_port = charge_manager_get_active_charge_port(); - - LOG_INF("New chg p%d", port); - - /* Disable all ports. */ - if (port == CHARGE_PORT_NONE) { - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - tcpc_write(i, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_LOW); - raa489000_enable_asgate(i, false); - } - - return EC_SUCCESS; - } - - /* Check if port is sourcing VBUS. */ - if (board_is_sourcing_vbus(port)) { - LOG_WRN("Skip enable p%d", port); - return EC_ERROR_INVAL; - } - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (i == port) - continue; - - if (tcpc_write(i, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_LOW)) - LOG_WRN("p%d: sink path disable failed.", i); - raa489000_enable_asgate(i, false); - } - - /* - * Stop the charger IC from switching while changing ports. Otherwise, - * we can overcurrent the adapter we're switching to. (crbug.com/926056) - */ - if (old_port != CHARGE_PORT_NONE) - charger_discharge_on_ac(1); - - /* Enable requested charge port. */ - if (raa489000_enable_asgate(port, true) || - tcpc_write(port, TCPC_REG_COMMAND, - TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { - LOG_WRN("p%d: sink path enable failed.", port); - charger_discharge_on_ac(0); - return EC_ERROR_UNKNOWN; - } - - /* Allow the charger IC to begin/continue switching. */ - charger_discharge_on_ac(0); - - return EC_SUCCESS; -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - int regval; - - /* - * The interrupt line is shared between the TCPC and BC1.2 detector IC. - * Therefore, go out and actually read the alert registers to report the - * alert status. - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { - if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { - /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ - if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_0; - } - } - - if (board_get_usb_pd_port_count() == 2 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { - /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ - if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_1; - } - } - - return status; -} - -void pd_power_supply_reset(int port) -{ - /* Disable VBUS */ - tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) -{ - if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) - return; - - raa489000_set_output_current(port, rp); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) - return EC_ERROR_INVAL; - - /* Disable charging. */ - rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); - if (rv) - return rv; - - /* Our policy is not to source VBUS when the AP is off. */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - return EC_ERROR_NOT_POWERED; - - /* Provide Vbus. */ - rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); - if (rv) - return rv; - - rv = raa489000_enable_asgate(port, true); - if (rv) - return rv; - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -void board_reset_pd_mcu(void) -{ - /* - * TODO(b:147316511): could send a reset command to the TCPC here - * if needed. - */ -} - -/* - * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible - * for an interrupt to be lost if one asserts the IRQ, the other does the same - * then the first releases it: there will only be one falling edge to trigger - * the interrupt, and the line will be held low. We handle this by running a - * deferred check after a falling edge to see whether the IRQ is still being - * asserted. If it is, we assume an interrupt may have been lost and we need - * to poll each chip for events again. - */ -#define USBC_INT_POLL_DELAY_US 5000 - -static void poll_c0_int(void); -DECLARE_DEFERRED(poll_c0_int); -static void poll_c1_int(void); -DECLARE_DEFERRED(poll_c1_int); - -static void usbc_interrupt_trigger(int port) -{ - schedule_deferred_pd_interrupt(port); - usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); -} - -static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, - const struct deferred_data *ud) -{ - if (!gpio_pin_get_dt(gpio)) { - usbc_interrupt_trigger(port); - hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); - } -} - -static void poll_c0_int(void) -{ - poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), - &poll_c0_int_data); -} - -static void poll_c1_int(void) -{ - poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), - &poll_c1_int_data); -} - -void usb_interrupt(enum gpio_signal signal) -{ - int port; - const struct deferred_data *ud; - - if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { - port = 0; - ud = &poll_c0_int_data; - } else { - port = 1; - ud = &poll_c1_int_data; - } - /* - * We've just been called from a falling edge, so there's definitely - * no lost IRQ right now. Cancel any pending check. - */ - hook_call_deferred(ud, -1); - /* Trigger polling of TCPC and BC1.2 in respective tasks */ - usbc_interrupt_trigger(port); - /* Check for lost interrupts in a bit */ - hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); -} - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_ma = (charge_ma * 90) / 100; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} - -struct chg_curr_step { - int on; - int off; - int curr_ma; -}; - -static const struct chg_curr_step chg_curr_table[] = { - { .on = 0, .off = 36, .curr_ma = 2800 }, - { .on = 46, .off = 36, .curr_ma = 1500 }, - { .on = 48, .off = 38, .curr_ma = 1000 }, -}; - -/* All charge current tables must have the same number of levels */ -#define NUM_CHG_CURRENT_LEVELS ARRAY_SIZE(chg_curr_table) - -int charger_profile_override(struct charge_state_data *curr) -{ - int rv; - int chg_temp_c; - int current; - int thermal_sensor0; - static int current_level; - static int prev_tmp; - - /* - * Precharge must be executed when communication is failed on - * dead battery. - */ - if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE)) - return 0; - - current = curr->requested_current; - - rv = temp_sensor_read( - TEMP_SENSOR_ID_BY_DEV(DT_NODELABEL(temp_charger1)), - &thermal_sensor0); - chg_temp_c = K_TO_C(thermal_sensor0); - - if (rv != EC_SUCCESS) - return 0; - - if (chipset_in_state(CHIPSET_STATE_ON)) { - if (chg_temp_c < prev_tmp) { - if (chg_temp_c <= chg_curr_table[current_level].off) - current_level = current_level - 1; - } else if (chg_temp_c > prev_tmp) { - if (chg_temp_c >= chg_curr_table[current_level + 1].on) - current_level = current_level + 1; - } - /* - * Prevent level always minus 0 or over table steps. - */ - if (current_level < 0) - current_level = 0; - else if (current_level >= NUM_CHG_CURRENT_LEVELS) - current_level = NUM_CHG_CURRENT_LEVELS - 1; - - prev_tmp = chg_temp_c; - current = chg_curr_table[current_level].curr_ma; - - curr->requested_current = MIN(curr->requested_current, current); - } - return 0; -} - -enum ec_status charger_profile_override_get_param(uint32_t param, - uint32_t *value) -{ - return EC_RES_INVALID_PARAM; -} - -enum ec_status charger_profile_override_set_param(uint32_t param, - uint32_t value) -{ - return EC_RES_INVALID_PARAM; -} diff --git a/zephyr/projects/nissa/yaviks/cbi.dtsi b/zephyr/projects/nissa/yaviks/cbi.dtsi deleted file mode 100644 index c5716cbd37..0000000000 --- a/zephyr/projects/nissa/yaviks/cbi.dtsi +++ /dev/null @@ -1,99 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* Yaviks-specific fw_config fields. */ - nissa-fw-config { - /* - * FW_CONFIG field for multiple wi-fi SAR. - * - * start = <2>; - * size = <2>; - */ - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <4>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - - /* - * FW_CONFIG field to indicate which keyboard layout - * should be used. - */ - keyboard { - enum-name = "FW_KB_LAYOUT"; - start = <5>; - size = <1>; - - layout-1 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_LAYOUT_DEFAULT"; - value = <0>; - default; - }; - layout-2 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_LAYOUT_US2"; - value = <1>; - }; - }; - - /* - * FW_CONFIG field to indicate which keyboard layout - * should be used. - */ - keyboard-backlight { - enum-name = "FW_KB_BACKLIGHT"; - start = <6>; - size = <1>; - - without-keyboard-backlight { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BACKLIGHT_OFF"; - value = <1>; - }; - with-keyboard-backlight { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BACKLIGHT_ON"; - value = <0>; - default; - }; - }; - - /* - * FW_CONFIG field for multiple touch panel. - * - * start = <7>; - * size = <2>; - */ - - /* - * FW_CONFIG field for multiple storage. - * - * start = <31>; - * size = <1>; - */ - }; -}; diff --git a/zephyr/projects/nissa/yaviks/gpio.dtsi b/zephyr/projects/nissa/yaviks/gpio.dtsi deleted file mode 100644 index dae1d641cd..0000000000 --- a/zephyr/projects/nissa/yaviks/gpio.dtsi +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { - enum-name = "ADC_PP1050_PROC"; - io-channels = <&adc0 14>; - }; - adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { - enum-name = "ADC_PP3300_S5"; - io-channels = <&adc0 0>; - }; - adc_temp_sensor_1: temp_sensor_1 { - enum-name = "ADC_TEMP_SENSOR_1"; - io-channels = <&adc0 2>; - }; - adc_temp_sensor_2: temp_sensor_2 { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 3>; - }; - adc_temp_sensor_3: temp_sensor_3 { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 13>; - }; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_all_sys_pwrgd: all_sys_pwrgd { - gpios = <&gpiob 7 GPIO_INPUT>; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioh 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_cpu_c10_gate_l: cpu_c10_gate_l { - gpios = <&gpiog 1 GPIO_INPUT>; - }; - gpio_ec_battery_pres_odl: ec_battery_pres_odl { - gpios = <&gpioi 4 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioj 5 GPIO_OUTPUT>; - }; - gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { - gpios = <&gpiok 4 GPIO_ODR_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_entering_rw: ec_entering_rw { - gpios = <&gpioc 7 GPIO_OUTPUT>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { - gpios = <&gpioh 1 GPIO_OUTPUT>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_pch_wake_odl: ec_pch_wake_odl { - gpios = <&gpiob 2 GPIO_ODR_LOW>; - }; - gpio_ec_prochot_odl: ec_prochot_odl { - gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { - gpios = <&gpiol 7 GPIO_OUTPUT>; - no-auto-init; - }; - gpio_ec_soc_int_odl: ec_soc_int_odl { - gpios = <&gpiod 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { - gpios = <&gpiod 6 GPIO_ODR_HIGH>; - no-auto-init; - }; - gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { - gpios = <&gpiob 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioh 0 GPIO_OUTPUT>; - no-auto-init; - }; - gpio_ec_soc_rtcrst: ec_soc_rtcrst { - gpios = <&gpiok 2 GPIO_OUTPUT>; - }; - gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { - gpios = <&gpiof 2 GPIO_OUTPUT>; - no-auto-init; - }; - gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { - gpios = <&gpioe 5 GPIO_ODR_HIGH>; - no-auto-init; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpioa 6 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_en_pp3300_s5: en_pp3300_s5 { - gpios = <&gpioc 5 GPIO_OUTPUT>; - enum-name = "GPIO_TEMP_SENSOR_POWER"; - no-auto-init; - }; - gpio_en_pp5000_pen_x: en_pp5000_pen_x { - gpios = <&gpiob 5 GPIO_OUTPUT>; - }; - gpio_en_pp5000_s5: en_pp5000_s5 { - gpios = <&gpiok 5 GPIO_OUTPUT>; - no-auto-init; - }; - gpio_en_slp_z: en_slp_z { - gpios = <&gpiok 3 GPIO_OUTPUT>; - }; - gpio_en_usb_a0_vbus: en_usb_a0_vbus { - gpios = <&gpiol 6 GPIO_OUTPUT>; - }; - gpio_en_usb_c0_cc1_vconn: en_usb_c0_cc1_vconn { - gpios = <&gpioh 4 GPIO_OUTPUT>; - }; - gpio_en_usb_c0_cc2_vconn: en_usb_c0_cc2_vconn { - gpios = <&gpioh 6 GPIO_OUTPUT>; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { - gpios = <&gpioj 4 GPIO_INPUT>; - no-auto-init; - }; - gpio_lid_open: lid_open { - gpios = <&gpiof 3 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_pen_detect_odl: pen_detect_odl { - gpios = <&gpioj 1 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { - gpios = <&gpiod 3 GPIO_INPUT>; - }; - gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { - gpios = <&gpioe 3 GPIO_INPUT>; - }; - gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { - gpios = <&gpioe 1 GPIO_INPUT_PULL_UP>; - no-auto-init; - }; - gpio_slp_s0_l: slp_s0_l { - gpios = <&gpioe 4 GPIO_INPUT>; - no-auto-init; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpioh 3 GPIO_INPUT>; - no-auto-init; - }; - gpio_slp_s4_l: slp_s4_l { - gpios = <&gpioi 5 GPIO_INPUT>; - }; - gpio_slp_sus_l: slp_sus_l { - gpios = <&gpiog 2 GPIO_INPUT>; - no-auto-init; - }; - gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { - gpios = <&gpiof 1 GPIO_OUTPUT>; - enum-name = "GPIO_USB2_ILIM_SEL"; - }; - gpio_sys_rst_odl: sys_rst_odl { - gpios = <&gpiod 1 GPIO_ODR_HIGH>; - no-auto-init; - }; - gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { - gpios = <&gpiol 5 GPIO_OUTPUT>; - enum-name = "GPIO_USB1_ILIM_SEL"; - }; - gpio_usb_c0_frs: usb_c0_frs { - gpios = <&gpioc 4 GPIO_OUTPUT>; - }; - gpio_usb_c0_int_odl: usb_c0_int_odl { - gpios = <&gpiok 0 GPIO_INPUT_PULL_UP>; - }; - gpio_vccin_aux_vid0: vccin_aux_vid0 { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_vccin_aux_vid1: vccin_aux_vid1 { - gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_c1_charger_led_white_l: c1_charger_led_white_l { - gpios = <&gpiol 4 GPIO_OUTPUT_HIGH>; - }; - gpio_c1_charger_led_amber_l: c1_charger_led_amber_l { - gpios = <&gpiod 4 GPIO_OUTPUT_HIGH>; - }; - gpio_c0_charger_led_white_l: c0_charger_led_white_l { - gpios = <&gpioc 3 GPIO_OUTPUT_HIGH>; - }; - gpio_c0_charger_led_amber_l: c0_charger_led_amber_l { - gpios = <&gpioj 7 GPIO_OUTPUT_HIGH>; - }; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_ec_i2c_eeprom: ec_i2c_eeprom { - i2c-port = <&i2c0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_ec_i2c_batt: ec_i2c_batt { - i2c-port = <&i2c1>; - enum-names = "I2C_PORT_BATTERY"; - }; - i2c_ec_i2c_sensor: ec_i2c_sensor { - i2c-port = <&i2c2>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { - i2c-port = <&i2c4>; - enum-names = "I2C_PORT_USB_C1_TCPC"; - }; - i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { - i2c-port = <&i2c5>; - enum-names = "I2C_PORT_USB_C0_TCPC"; - }; - }; -}; diff --git a/zephyr/projects/nissa/yaviks/keyboard.dtsi b/zephyr/projects/nissa/yaviks/keyboard.dtsi deleted file mode 100644 index 04a620767a..0000000000 --- a/zephyr/projects/nissa/yaviks/keyboard.dtsi +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - /* - * Use 324 Hz so that 32Khz clock source is used, - * which is not gated in power saving mode. - */ - pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm0 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm0_gpa0_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/yaviks/overlay.dtsi b/zephyr/projects/nissa/yaviks/overlay.dtsi deleted file mode 100644 index d768116444..0000000000 --- a/zephyr/projects/nissa/yaviks/overlay.dtsi +++ /dev/null @@ -1,402 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_odl; - int-wp = &int_wp_l; - /* - * USB-C: interrupt input. - * I2C pins are on i2c_ec_i2c_sub_usb_c1 - */ - gpio-usb-c1-int-odl = &gpio_sb_1; - /* - * USB-A: VBUS enable output - * LTE: power enable output - */ - gpio-en-usb-a1-vbus = &gpio_sb_2; - /* - * Enable S5 rails for LTE sub-board - */ - gpio-en-sub-s5-rails = &gpio_sb_2; - }; - - ec-console { - compatible = "ec-console"; - disabled = "events", "lpc", "hostcmd"; - }; - - batteries { - default_battery: cosmx { - compatible = "cosmx,gh02047xl", "battery-smart"; - }; - dynapack_atl_gh02047xl { - compatible = "dynapack,atl_gh02047xl", "battery-smart"; - }; - dynapack_cosmx_gh02047xl { - compatible = "dynapack,cosmx_gh02047xl", "battery-smart"; - }; - smp_coslight_gh02047xl { - compatible = "smp,coslight_gh02047xl", "battery-smart"; - }; - smp_highpower_gh02047xl { - compatible = "smp,highpower_gh02047xl", "battery-smart"; - }; - default_battery_3s:cosmx_si03058xl { - compatible = "cosmx,si03058xl", "battery-smart"; - }; - smp_highpower_si03058xl { - compatible = "smp,highpower_si03058xl", "battery-smart"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_power_button - &int_lid_open - >; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_wp_l: wp_l { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_usb_c0: usb_c0 { - irq-pin = <&gpio_usb_c0_int_odl>; - flags = ; - handler = "usb_c0_interrupt"; - }; - int_usb_c1: usb_c1 { - irq-pin = <&gpio_sb_1>; - flags = ; - handler = "usb_c1_interrupt"; - }; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = <&gpioa 7 0>, - <&gpioc 0 0>, - <&gpioc 6 0>, - <&gpiod 7 0>, - <&gpioh 2 0>, - <&gpioi 6 0>, - <&gpioi 7 0>, - <&gpioj 0 0>, - <&gpioj 3 0>, - <&gpiok 7 GPIO_OUTPUT>; - }; - - named-gpios { - /* - * EC doesn't take any specific action on CC/SBU disconnect due to - * fault, but this definition is useful for hardware testing. - */ - gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl { - gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>; - }; - - gpio_sb_1: sb_1 { - gpios = <&gpioe 6 0>; - no-auto-init; - }; - gpio_sb_2: sb_2 { - gpios = <&gpiof 0 0>; - no-auto-init; - }; - gpio_fan_enable: fan-enable { - gpios = <&gpioa 1 GPIO_OUTPUT>; - no-auto-init; - }; - }; - - temp_cpu: cpu { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_1>; - }; - temp_5v_regulator: 5v_regulator { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_2>; - }; - temp_charger: charger { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_51K1_47K_4050B>; - adc = <&adc_temp_sensor_3>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - cpu { - temp_fan_off = <45>; - temp_fan_max = <60>; - temp_host_high = <75>; - temp_host_halt = <85>; - temp_host_release_high = <65>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_cpu>; - }; - 5v_regulator { - temp_fan_off = <50>; - temp_fan_max = <65>; - temp_host_high = <75>; - temp_host_halt = <85>; - temp_host_release_high = <65>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_5v_regulator>; - }; - charger { - temp_fan_off = <50>; - temp_fan_max = <65>; - temp_host_high = <80>; - temp_host_halt = <85>; - temp_host_release_high = <75>; - power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_charger>; - }; - }; - - usba { - compatible = "cros-ec,usba-port-enable-pins"; - /* - * sb_2 is only configured as GPIO when USB-A1 is present, - * but it's still safe to control when disabled. - * - * ILIM_SEL pins are referred to by legacy enum name, - * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on - * sub-boards that don't have USB-A so is safe to control - * regardless of system configuration. - */ - enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; - status = "okay"; - }; - - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - chg = <&chg_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - chg = <&chg_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; - }; - usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - tcpci_mux_1: tcpci-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; - }; - - fans { - compatible = "cros-ec,fans"; - fan_0 { - pwms = <&pwm2 PWM_CHANNEL_2 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - tach = <&tach1>; - rpm_min = <2600>; - rpm_start = <2600>; - rpm_max = <4100>; - enable_gpio = <&gpio_fan_enable>; - }; - }; -}; - -&thermistor_3V3_51K1_47K_4050B { - status = "okay"; -}; - -&adc_ec_vsense_pp3300_s5 { - /* - * Voltage divider on input has 47k upper and 220k lower legs with 3 V - * full-scale reading on the ADC. Apply the largest possible multiplier - * (without overflowing int32) to get the best possible approximation - * of the actual ratio, but derate by a factor of two to ensure - * unexpectedly high values won't overflow. - */ - mul = <(715828 / 2)>; - div = <(589820 / 2)>; -}; - -&adc0 { - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch2_gpi2_default - &adc0_ch3_gpi3_default - &adc0_ch13_gpl0_default - &adc0_ch14_gpl1_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&pinctrl { - i2c4_clk_gpe0_sleep: i2c4_clk_gpe0_sleep { - pinmuxs = <&pinctrle 0 IT8XXX2_ALT_DEFAULT>; - }; - i2c4_data_gpe7_sleep: i2c4_data_gpe7_sleep { - pinmuxs = <&pinctrle 7 IT8XXX2_ALT_DEFAULT>; - }; - i2c2_clk_gpf6_default: i2c2_clk_gpf6_default { - gpio-voltage = "1v8"; - }; - i2c2_data_gpf7_default: i2c2_data_gpf7_default { - gpio-voltage = "1v8"; - }; -}; - -&i2c0 { - label = "I2C_EEPROM"; - clock-frequency = ; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - label = "EEPROM_CBI"; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; - pinctrl-0 = <&i2c0_clk_gpb3_default - &i2c0_data_gpb4_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&i2c1 { - label = "I2C_BATTERY"; - clock-frequency = <50000>; - pinctrl-0 = <&i2c1_clk_gpc1_default - &i2c1_data_gpc2_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&i2c2 { - label = "I2C_SENSOR"; - clock-frequency = ; - pinctrl-0 = <&i2c2_clk_gpf6_default - &i2c2_data_gpf7_default>; - pinctrl-names = "default"; - status = "okay"; -}; - -&i2c4 { - label = "I2C_SUB_C1_TCPC"; - clock-frequency = ; - pinctrl-0 = <&i2c4_clk_gpe0_default - &i2c4_data_gpe7_default>; - pinctrl-1 = <&i2c4_clk_gpe0_sleep - &i2c4_data_gpe7_sleep>; - pinctrl-names = "default", "sleep"; - status = "okay"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port1: sm5803@32 { - compatible = "siliconmitus,sm5803"; - status = "okay"; - reg = <0x32>; - }; -}; - -&i2c_ec_i2c_sub_usb_c1 { - /* - * Dynamic speed setting is used for AP-controlled firmware update - * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order - * to use more efficient window programming, then sets it back when - * done. - */ - dynamic-speed; -}; - -&i2c5 { - label = "I2C_USB_C0_TCPC"; - clock-frequency = ; - pinctrl-0 = <&i2c5_clk_gpa4_default - &i2c5_data_gpa5_default>; - pinctrl-names = "default"; - status = "okay"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - }; - - chg_port0: sm5803@32 { - compatible = "siliconmitus,sm5803"; - status = "okay"; - reg = <0x32>; - }; -}; - -&usbpd0 { - status = "okay"; -}; - -/* pwm for fan */ -&pwm2 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm2_gpa2_default>; - pinctrl-names = "default"; -}; -/* fan tachometer sensor */ -&tach1 { - status = "okay"; - channel = ; - pulses-per-round = <2>; - pinctrl-0 = <&tach1a_gpd7_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/nissa/yaviks/power_signals.dtsi b/zephyr/projects/nissa/yaviks/power_signals.dtsi deleted file mode 100644 index d64ac83150..0000000000 --- a/zephyr/projects/nissa/yaviks/power_signals.dtsi +++ /dev/null @@ -1,180 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <10>; - all-sys-pwrgd-timeout = <20>; - }; - - pwr-en-pp5000-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP5000_S5 enable output to regulator"; - enum-name = "PWR_EN_PP5000_A"; - gpios = <&gpiok 5 0>; - output; - }; - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpioc 5 0>; - output; - }; - pwr-pg-ec-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpioe 1 0>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioh 0 0>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpioe 4 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - gpios = <&gpioh 3 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-sus-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_SUS_L input from PCH"; - enum-name = "PWR_SLP_SUS"; - gpios = <&gpiog 2 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-ec-soc-dsw-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "DSW_PWROK output to PCH"; - enum-name = "PWR_EC_SOC_DSW_PWROK"; - gpios = <&gpiol 7 0>; - output; - }; - pwr-vccst-pwrgd-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VCCST_PWRGD output to PCH"; - enum-name = "PWR_VCCST_PWRGD"; - gpios = <&gpioe 5 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; - output; - }; - pwr-imvp9-vrrdy-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "VRRDY input from IMVP9"; - enum-name = "PWR_IMVP9_VRRDY"; - gpios = <&gpioj 4 0>; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpiod 6 GPIO_OPEN_DRAIN>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpiof 2 0>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpiod 1 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - /* - * This is a board level signal, since this - * signal needs some special processing. - */ - compatible = "intel,ap-pwrseq-external"; - dbg-label = "Combined all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - }; - pwr-adc-pp3300 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP3300_PROC"; - enum-name = "PWR_DSW_PWROK"; - trigger-high = <&vcmp0>; - trigger-low = <&vcmp1>; - }; - pwr-adc-pp1p05 { - compatible = "intel,ap-pwrseq-adc"; - dbg-label = "PP1P05_PROC"; - enum-name = "PWR_PG_PP1P05"; - trigger-high = <&vcmp2>; - trigger-low = <&vcmp3>; - }; - -}; - -&vcmp0 { - status = "okay"; - scan-period = ; - comparison = ; - /* - * This is 90% of nominal voltage considering voltage - * divider on ADC input. - */ - threshold-mv = <2448>; - io-channels = <&adc0 0>; -}; -&vcmp1 { - status = "okay"; - scan-period = ; - comparison = ; - threshold-mv = <2448>; - io-channels = <&adc0 0>; -}; -&vcmp2 { - status = "okay"; - scan-period = ; - comparison = ; - /* Setting at 90% of nominal voltage */ - threshold-mv = <945>; - io-channels = <&adc0 14>; -}; -&vcmp3 { - status = "okay"; - scan-period = ; - comparison = ; - threshold-mv = <945>; - io-channels = <&adc0 14>; -}; diff --git a/zephyr/projects/nissa/yaviks/project.conf b/zephyr/projects/nissa/yaviks/project.conf deleted file mode 100644 index 0e385b843e..0000000000 --- a/zephyr/projects/nissa/yaviks/project.conf +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_BOARD_YAVIKS=y - -# Ensure recovery key combination (esc+refresh+power) is reliable: b/236580049 -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y - -# Sensors: disabled; yaviks is clamshell-only -CONFIG_PLATFORM_EC_LID_ANGLE=n -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n -CONFIG_PLATFORM_EC_MOTIONSENSE=n -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n -CONFIG_PLATFORM_EC_ACCEL_FIFO=n -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n -CONFIG_PLATFORM_EC_TABLET_MODE=n -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n -CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y -CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=n - -# Fan -CONFIG_PLATFORM_EC_FAN=y - -# LED -CONFIG_PLATFORM_EC_LED_PWM=n diff --git a/zephyr/projects/nissa/yaviks/project.overlay b/zephyr/projects/nissa/yaviks/project.overlay deleted file mode 100644 index a7ce97a8b3..0000000000 --- a/zephyr/projects/nissa/yaviks/project.overlay +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../cbi.dtsi" - -#include "cbi.dtsi" -#include "gpio.dtsi" -#include "keyboard.dtsi" -#include "overlay.dtsi" -#include "power_signals.dtsi" diff --git a/zephyr/projects/nissa/yaviks/src/charger.c b/zephyr/projects/nissa/yaviks/src/charger.c deleted file mode 100644 index 9be2e685b0..0000000000 --- a/zephyr/projects/nissa/yaviks/src/charger.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery.h" -#include "charger.h" -#include "console.h" -#include "driver/charger/sm5803.h" -#include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" -#include "battery_fuel_gauge.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -int extpower_is_present(void) -{ - int port; - int rv; - bool acok; - - for (port = 0; port < board_get_usb_pd_port_count(); port++) { - rv = sm5803_is_acok(port, &acok); - if ((rv == EC_SUCCESS) && acok) - return 1; - } - - return 0; -} - -/* - * Yaviks does not have a GPIO indicating whether extpower is present, - * so detect using the charger(s). - */ -__override void board_check_extpower(void) -{ - static int last_extpower_present; - int extpower_present = extpower_is_present(); - - if (last_extpower_present ^ extpower_present) - extpower_handle_update(extpower_present); - - last_extpower_present = extpower_present; -} - -__override void board_hibernate(void) -{ - /* Shut down the chargers */ - if (board_get_usb_pd_port_count() == 2) - sm5803_hibernate(CHARGER_SECONDARY); - sm5803_hibernate(CHARGER_PRIMARY); - LOG_INF("Charger(s) hibernated"); - cflush(); -} - -__override int board_get_default_battery_type(void) -{ - int type = DEFAULT_BATTERY_TYPE; - int cells; - - if (charger_get_battery_cells(CHARGER_PRIMARY, &cells) == EC_SUCCESS) { - if (cells == 3) - type = DEFAULT_BATTERY_TYPE_3S; - if (cells != 2 && cells != 3) - LOG_ERR("Unexpected number of cells"); - } else { - LOG_ERR("Failed to get default battery type"); - } - - return type; -} diff --git a/zephyr/projects/nissa/yaviks/src/fan.c b/zephyr/projects/nissa/yaviks/src/fan.c deleted file mode 100644 index 23c3ec1143..0000000000 --- a/zephyr/projects/nissa/yaviks/src/fan.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include -#include -#include -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" -#include "nissa_common.h" -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -static void fan_init(void) -{ - int ret; - uint32_t val; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - if (val != FW_FAN_PRESENT) { - /* Disable the fan */ - fan_set_count(0); - } else { - /* Configure the fan enable GPIO */ - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), - GPIO_OUTPUT); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/nissa/yaviks/src/keyboard.c b/zephyr/projects/nissa/yaviks/src/keyboard.c deleted file mode 100644 index 46d6083dbf..0000000000 --- a/zephyr/projects/nissa/yaviks/src/keyboard.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include - -#include "cros_cbi.h" -#include "ec_commands.h" -#include "hooks.h" -#include "keyboard_8042_sharedlib.h" -#include "keyboard_scan.h" -#include "timer.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -/* Keyboard scan setting */ -__override struct keyboard_scan_config keyscan_config = { - /* Increase from 50 us, because KSO_02 passes through the H1. */ - .output_settle_us = 80, - /* Other values should be the same as the default configuration. */ - .debounce_down_us = 9 * MSEC, - .debounce_up_us = 30 * MSEC, - .scan_period_us = 3 * MSEC, - .min_post_scan_delay_us = 1000, - .poll_timeout_us = 100 * MSEC, - .actual_key_mask = { - 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xa4, 0xff, 0xf6, 0x55, 0xfe, 0xff, 0xff, 0xff, /* full set */ - }, -}; - -static const struct ec_response_keybd_config yaviks_kb_w_kb_light = { - .num_top_row_keys = 13, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_KBD_BKLIGHT_TOGGLE, /* T8 */ - TK_PLAY_PAUSE, /* T9 */ - TK_MICMUTE, /* T10 */ - TK_VOL_MUTE, /* T11 */ - TK_VOL_DOWN, /* T12 */ - TK_VOL_UP, /* T13 */ - }, - .capabilities = KEYBD_CAP_NUMERIC_KEYPAD, -}; - -static const struct ec_response_keybd_config yaviks_kb_wo_kb_light = { - .num_top_row_keys = 13, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_PLAY_PAUSE, /* T8 */ - TK_MICMUTE, /* T9 */ - TK_VOL_MUTE, /* T10 */ - TK_VOL_DOWN, /* T11 */ - TK_VOL_UP, /* T12 */ - TK_MENU, /* T13 */ - }, - .capabilities = KEYBD_CAP_NUMERIC_KEYPAD, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - uint32_t val; - - cros_cbi_get_fw_config(FW_KB_BACKLIGHT, &val); - - if (val == FW_KB_BACKLIGHT_OFF) - return &yaviks_kb_wo_kb_light; - else - return &yaviks_kb_w_kb_light; -} - -/* - * Keyboard layout decided by FW config. - */ -static void kb_layout_init(void) -{ - int ret; - uint32_t val; - - ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", - FW_KB_LAYOUT); - return; - } - /* - * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl - * to backslash(\|) key. - */ - if (val == FW_KB_LAYOUT_US2) - set_scancode_set2(4, 0, get_scancode_set2(2, 7)); -} -DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/nissa/yaviks/src/led.c b/zephyr/projects/nissa/yaviks/src/led.c deleted file mode 100644 index 88a476f1b0..0000000000 --- a/zephyr/projects/nissa/yaviks/src/led.c +++ /dev/null @@ -1,231 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery.h" -#include "charge_manager.h" -#include "charge_state.h" -#include "chipset.h" -#include "ec_commands.h" -#include "gpio.h" -#include "host_command.h" -#include "led_common.h" -#include "hooks.h" - -#define BAT_LED_ON 0 -#define BAT_LED_OFF 1 - -#define BATT_LOW_BCT 10 - -#define LED_TICKS_PER_CYCLE 4 -#define LED_TICKS_PER_CYCLE_S3 4 -#define LED_ON_TICKS 2 -#define POWER_LED_ON_S3_TICKS 2 - -const enum ec_led_id supported_led_ids[] = { EC_LED_ID_LEFT_LED, - EC_LED_ID_RIGHT_LED }; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -enum led_color { - LED_OFF = 0, - LED_AMBER, - LED_WHITE, - LED_COLOR_COUNT /* Number of colors, not a color itself */ -}; - -enum led_port { LEFT_PORT = 0, RIGHT_PORT }; - -static void led_set_color_battery(int port, enum led_color color) -{ - const struct gpio_dt_spec *amber_led, *white_led; - - if (port == LEFT_PORT) { - amber_led = GPIO_DT_FROM_NODELABEL(gpio_c0_charger_led_amber_l); - white_led = GPIO_DT_FROM_NODELABEL(gpio_c0_charger_led_white_l); - } else if (port == RIGHT_PORT) { - amber_led = GPIO_DT_FROM_NODELABEL(gpio_c1_charger_led_amber_l); - white_led = GPIO_DT_FROM_NODELABEL(gpio_c1_charger_led_white_l); - } - - switch (color) { - case LED_WHITE: - gpio_pin_set_dt(white_led, BAT_LED_ON); - gpio_pin_set_dt(amber_led, BAT_LED_OFF); - break; - case LED_AMBER: - gpio_pin_set_dt(white_led, BAT_LED_OFF); - gpio_pin_set_dt(amber_led, BAT_LED_ON); - break; - case LED_OFF: - gpio_pin_set_dt(white_led, BAT_LED_OFF); - gpio_pin_set_dt(amber_led, BAT_LED_OFF); - break; - default: - break; - } -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - switch (led_id) { - case EC_LED_ID_LEFT_LED: - brightness_range[EC_LED_COLOR_WHITE] = 1; - brightness_range[EC_LED_COLOR_AMBER] = 1; - break; - case EC_LED_ID_RIGHT_LED: - brightness_range[EC_LED_COLOR_WHITE] = 1; - brightness_range[EC_LED_COLOR_AMBER] = 1; - break; - default: - break; - } -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - switch (led_id) { - case EC_LED_ID_LEFT_LED: - if (brightness[EC_LED_COLOR_WHITE] != 0) - led_set_color_battery(LEFT_PORT, LED_WHITE); - else if (brightness[EC_LED_COLOR_AMBER] != 0) - led_set_color_battery(LEFT_PORT, LED_AMBER); - else - led_set_color_battery(LEFT_PORT, LED_OFF); - break; - case EC_LED_ID_RIGHT_LED: - if (brightness[EC_LED_COLOR_WHITE] != 0) - led_set_color_battery(RIGHT_PORT, LED_WHITE); - else if (brightness[EC_LED_COLOR_AMBER] != 0) - led_set_color_battery(RIGHT_PORT, LED_AMBER); - else - led_set_color_battery(RIGHT_PORT, LED_OFF); - break; - default: - return EC_ERROR_PARAM1; - } - - return EC_SUCCESS; -} - -/* - * Set active charge port color to the parameter, turn off all others. - * If no port is active (-1), turn off all LEDs. - */ -static void set_active_port_color(enum led_color color) -{ - int port = charge_manager_get_active_charge_port(); - - if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) - led_set_color_battery(RIGHT_PORT, - (port == RIGHT_PORT) ? color : LED_OFF); - if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) - led_set_color_battery(LEFT_PORT, - (port == LEFT_PORT) ? color : LED_OFF); -} - -static void led_set_battery(void) -{ - static unsigned int battery_ticks; - static int suspend_ticks; - - battery_ticks++; - - /* - * Override battery LEDs for Yaviks, Yaviks is non-power LED - * design, blinking both two side battery white LEDs to indicate - * system suspend with non-charging state. - */ - if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && - charge_get_state() != PWR_STATE_CHARGE) { - suspend_ticks++; - - led_set_color_battery(RIGHT_PORT, - suspend_ticks % LED_TICKS_PER_CYCLE_S3 < - POWER_LED_ON_S3_TICKS ? - LED_WHITE : - LED_OFF); - led_set_color_battery(LEFT_PORT, - suspend_ticks % LED_TICKS_PER_CYCLE_S3 < - POWER_LED_ON_S3_TICKS ? - LED_WHITE : - LED_OFF); - return; - } - - suspend_ticks = 0; - - switch (charge_get_state()) { - case PWR_STATE_CHARGE: - /* Always indicate when charging, even in suspend. */ - set_active_port_color(LED_AMBER); - break; - case PWR_STATE_DISCHARGE: - /* - * Blinking amber LEDs slowly if battery is lower 10 - * percentage. - */ - if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) { - if (charge_get_percent() < BATT_LOW_BCT) - led_set_color_battery( - RIGHT_PORT, - (battery_ticks % LED_TICKS_PER_CYCLE < - LED_ON_TICKS) ? - LED_AMBER : - LED_OFF); - else - led_set_color_battery(RIGHT_PORT, LED_OFF); - } - - if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) { - if (charge_get_percent() < BATT_LOW_BCT) - led_set_color_battery( - LEFT_PORT, - (battery_ticks % LED_TICKS_PER_CYCLE < - LED_ON_TICKS) ? - LED_AMBER : - LED_OFF); - else - led_set_color_battery(LEFT_PORT, LED_OFF); - } - break; - case PWR_STATE_ERROR: - if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) { - led_set_color_battery( - RIGHT_PORT, - (battery_ticks & 0x1) ? LED_AMBER : LED_OFF); - } - - if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) { - led_set_color_battery(LEFT_PORT, (battery_ticks & 0x1) ? - LED_AMBER : - LED_OFF); - } - break; - case PWR_STATE_CHARGE_NEAR_FULL: - set_active_port_color(LED_WHITE); - break; - case PWR_STATE_IDLE: /* External power connected in IDLE */ - set_active_port_color(LED_WHITE); - break; - case PWR_STATE_FORCED_IDLE: - set_active_port_color( - (battery_ticks % LED_TICKS_PER_CYCLE < LED_ON_TICKS) ? - LED_AMBER : - LED_OFF); - break; - default: - /* Other states don't alter LED behavior */ - break; - } -} - -/* Called by hook task every TICK(IT83xx 500ms) */ -static void led_tick(void) -{ - led_set_battery(); -} -DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/nissa/yaviks/src/usbc.c b/zephyr/projects/nissa/yaviks/src/usbc.c deleted file mode 100644 index 48f7cfd9cb..0000000000 --- a/zephyr/projects/nissa/yaviks/src/usbc.c +++ /dev/null @@ -1,393 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "charge_state_v2.h" -#include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" -#include "driver/charger/sm5803.h" -#include "driver/tcpm/it83xx_pd.h" -#include "driver/tcpm/ps8xxx_public.h" -#include "driver/tcpm/tcpci.h" - -#include "nissa_common.h" - -LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); - -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_EMBEDDED, - /* TCPC is embedded within EC so no i2c config needed */ - .drv = &it8xxx2_tcpm_drv, - /* Alert is active-low, push-pull */ - .flags = 0, - }, - { - /* - * Sub-board: optional PS8745 TCPC+redriver. Behaves the same - * as PS8815. - */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, - }, - .drv = &ps8xxx_tcpm_drv, - /* PS8745 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0, - }, -}; - -/* Vconn control for integrated ITE TCPC */ -void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) -{ - /* Vconn control is only for port 0 */ - if (port) - return; - - if (cc_pin == USBPD_CC_PIN_1) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn), - !!enabled); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn), - !!enabled); -} - -__override bool pd_check_vbus_level(int port, enum vbus_level level) -{ - return sm5803_check_vbus_level(port, level); -} - -/* - * Putting chargers into LPM when in suspend reduces power draw by about 8mW - * per charger, but also seems critical to correct operation in source mode: - * if chargers are not in LPM when a sink is first connected, VBUS sourcing - * works even if the partner is later removed (causing LPM entry) and - * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS - * consistently causes the charger to report (apparently spurious) overcurrent - * failures. - * - * In short, this is important to making things work correctly but we don't - * understand why. - */ -static void board_chargers_suspend(struct ap_power_ev_callback *const cb, - const struct ap_power_ev_data data) -{ - void (*fn)(int chgnum); - - switch (data.event) { - case AP_POWER_SUSPEND: - fn = sm5803_enable_low_power_mode; - break; - case AP_POWER_RESUME: - fn = sm5803_disable_low_power_mode; - break; - default: - LOG_WRN("%s: power event %d is not recognized", __func__, - data.event); - return; - } - - fn(CHARGER_PRIMARY); - if (board_get_charger_chip_count() > 1) - fn(CHARGER_SECONDARY); -} - -static int board_chargers_suspend_init(const struct device *unused) -{ - static struct ap_power_ev_callback cb = { - .handler = board_chargers_suspend, - .events = AP_POWER_SUSPEND | AP_POWER_RESUME, - }; - ap_power_ev_add_callback(&cb); - return 0; -} -SYS_INIT(board_chargers_suspend_init, APPLICATION, 0); - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count()); - int i; - int old_port; - int rv; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - old_port = charge_manager_get_active_charge_port(); - LOG_INF("Charge update: p%d -> p%d", old_port, port); - - /* Check if port is sourcing VBUS. */ - if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) { - LOG_WRN("Skip enable p%d: already sourcing", port); - return EC_ERROR_INVAL; - } - - /* Disable sinking on all ports except the desired one */ - for (i = 0; i < board_get_usb_pd_port_count(); i++) { - if (i == port) - continue; - - if (sm5803_vbus_sink_enable(i, 0)) - /* - * Do not early-return because this can fail during - * power-on which would put us into a loop. - */ - LOG_WRN("p%d: sink path disable failed.", i); - } - - /* Don't enable anything (stop here) if no ports were requested */ - if ((port == CHARGE_PORT_NONE) || (old_port == port)) - return EC_SUCCESS; - - /* - * Stop the charger IC from switching while changing ports. Otherwise, - * we can overcurrent the adapter we're switching to. (crbug.com/926056) - */ - if (old_port != CHARGE_PORT_NONE) - charger_discharge_on_ac(1); - - /* Enable requested charge port. */ - rv = sm5803_vbus_sink_enable(port, 1); - if (rv) - LOG_WRN("p%d: sink path enable failed: code %d", port, rv); - - /* Allow the charger IC to begin/continue switching. */ - charger_discharge_on_ac(0); - - return rv; -} - -uint16_t tcpc_get_alert_status(void) -{ - /* - * TCPC 0 is embedded in the EC and processes interrupts in the chip - * code (it83xx/intc.c). This function only needs to poll port C1 if - * present. - */ - uint16_t status = 0; - int regval; - - /* Is the C1 port present and its IRQ line asserted? */ - if (board_get_usb_pd_port_count() == 2 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - /* - * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if - * it asserted the IRQ. - */ - if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { - if (regval) - status = PD_STATUS_TCPC_ALERT_1; - } - } - - return status; -} - -void pd_power_supply_reset(int port) -{ - int prev_en; - - if (port < 0 || port >= board_get_usb_pd_port_count()) - return; - - prev_en = charger_is_sourcing_otg_power(port); - - /* Disable Vbus */ - charger_enable_otg_power(port, 0); - - /* Discharge Vbus if previously enabled */ - if (prev_en) - sm5803_set_vbus_disch(port, 1); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - enum ec_error_list rv; - - if (port < 0 || port > board_get_usb_pd_port_count()) { - LOG_WRN("Port C%d does not exist, cannot enable VBUS", port); - return EC_ERROR_INVAL; - } - - /* Disable sinking */ - rv = sm5803_vbus_sink_enable(port, 0); - if (rv) { - LOG_WRN("C%d failed to disable sinking: %d", port, rv); - return rv; - } - - /* Disable Vbus discharge */ - rv = sm5803_set_vbus_disch(port, 0); - if (rv) { - LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv); - return rv; - } - - /* Provide Vbus */ - rv = charger_enable_otg_power(port, 1); - if (rv) { - LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv); - return rv; - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv; - const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500; - - rv = charger_set_otg_current_voltage(port, current, 5000); - if (rv != EC_SUCCESS) { - LOG_WRN("Failed to set source ilimit on port %d to %d: %d", - port, current, rv); - } -} - -void board_reset_pd_mcu(void) -{ - /* - * Do nothing. The integrated TCPC for C0 lacks a dedicated reset - * command, and C1 (if present) doesn't have a reset pin connected - * to the EC. - */ -} - -#define INT_RECHECK_US 5000 - -/* C0 interrupt line shared by BC 1.2 and charger */ - -static void check_c0_line(void); -DECLARE_DEFERRED(check_c0_line); - -static void notify_c0_chips(void) -{ - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - sm5803_interrupt(0); -} - -static void check_c0_line(void) -{ - /* - * If line is still being held low, see if there's more to process from - * one of the chips - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { - notify_c0_chips(); - hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); - } -} - -void usb_c0_interrupt(enum gpio_signal s) -{ - /* Cancel any previous calls to check the interrupt line */ - hook_call_deferred(&check_c0_line_data, -1); - - /* Notify all chips using this line that an interrupt came in */ - notify_c0_chips(); - - /* Check the line again in 5ms */ - hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); -} - -/* C1 interrupt line shared by BC 1.2, TCPC, and charger */ -static void check_c1_line(void); -DECLARE_DEFERRED(check_c1_line); - -static void notify_c1_chips(void) -{ - schedule_deferred_pd_interrupt(1); - usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); - /* Charger is handled in board_process_pd_alert */ -} - -static void check_c1_line(void) -{ - /* - * If line is still being held low, see if there's more to process from - * one of the chips. - */ - if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - notify_c1_chips(); - hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); - } -} - -void usb_c1_interrupt(enum gpio_signal s) -{ - /* Cancel any previous calls to check the interrupt line */ - hook_call_deferred(&check_c1_line_data, -1); - - /* Notify all chips using this line that an interrupt came in */ - notify_c1_chips(); - - /* Check the line again in 5ms */ - hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); -} - -/* - * Check state of IRQ lines at startup, ensuring an IRQ that happened before - * the EC started up won't get lost (leaving the IRQ line asserted and blocking - * any further interrupts on the port). - * - * Although the PD task will check for pending TCPC interrupts on startup, - * the charger sharing the IRQ will not be polled automatically. - */ -void board_handle_initial_typec_irq(void) -{ - check_c0_line(); - if (board_get_usb_pd_port_count() == 2) - check_c1_line(); -} -/* - * This must run after sub-board detection (which happens in EC main()), - * but isn't depended on by anything else either. - */ -DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST); - -/* - * Handle charger interrupts in the PD task. Not doing so can lead to a priority - * inversion where we fail to respond to TCPC alerts quickly enough because we - * don't get another edge on a shared IRQ until the charger interrupt is cleared - * (or the IRQ is polled again), which happens in the low-priority charger task: - * the high-priority type-C handler is thus blocked on the lower-priority - * charger. - * - * To avoid that, we run charger interrupts at the same priority. - */ -void board_process_pd_alert(int port) -{ - /* - * Port 0 doesn't use an external TCPC, so its interrupts don't need - * this special handling. - */ - if (port == 1 && - !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { - sm5803_handle_interrupt(port); - } -} - -int pd_snk_is_vbus_provided(int port) -{ - int chg_det = 0; - - sm5803_get_chg_det(port, &chg_det); - - return chg_det; -} diff --git a/zephyr/projects/nissa/yaviks/yaviks_vif.xml b/zephyr/projects/nissa/yaviks/yaviks_vif.xml deleted file mode 100644 index edc6299c58..0000000000 --- a/zephyr/projects/nissa/yaviks/yaviks_vif.xml +++ /dev/null @@ -1,350 +0,0 @@ - - - 3.19 - - USB-IF - VIF Editor - 3.2.4.0 - - Google - Yaviks - 1 - 0 - Port Product - Reference Platform - - - - - - - - - 0 - Type-C® - - - DRP - DRP - - Charging Port - - - - - - - - - Revision 3 - - - - - - - 18D1 - 505A - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 15000 mW - Assured - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - FR_Swap not supported - - - - Over-Current Response - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - 0 msec - 3000 mA - - - - - - 45000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 15000 mV - - - - Variable - 4750 mV - 15000 mV - 3000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505A - 0000 - - - - - - - 1 - Type-C® - - - DRP - DRP - - Charging Port - - - - - - - - - Revision 3 - - - - - - - 18D1 - 505A - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 15000 mW - Assured - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - FR_Swap not supported - - - - Over-Current Response - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - 0 msec - 3000 mA - - - - - - 45000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 15000 mV - - - - Variable - 4750 mV - 15000 mV - 3000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505A - 0000 - - \ No newline at end of file diff --git a/zephyr/projects/npcx_evb/npcx7/BUILD.py b/zephyr/projects/npcx_evb/npcx7/BUILD.py deleted file mode 100644 index baa6774595..0000000000 --- a/zephyr/projects/npcx_evb/npcx7/BUILD.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for npcx7_evb.""" - -register_npcx_project( - project_name="npcx7", - zephyr_board="npcx7_evb", - dts_overlays=["gpio.dts", "interrupts.dts", "fan.dts", "keyboard.dts"], -) diff --git a/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt b/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt deleted file mode 100644 index 64429d586e..0000000000 --- a/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(npcx7) - -zephyr_include_directories(include) diff --git a/zephyr/projects/npcx_evb/npcx7/fan.dts b/zephyr/projects/npcx_evb/npcx7/fan.dts deleted file mode 100644 index dc4debdcb9..0000000000 --- a/zephyr/projects/npcx_evb/npcx7/fan.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - rpm_min = <1000>; - rpm_start = <1000>; - rpm_max = <5200>; - tach = <&tach1>; - pgood_gpio = <&gpio_pgood_fan>; - }; - }; -}; - -/* Tachometer for fan speed measurement */ -&tach1 { - status = "okay"; - pinctrl-0 = <&ta1_1_in_gp40>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/npcx_evb/npcx7/gpio.dts b/zephyr/projects/npcx_evb/npcx7/gpio.dts deleted file mode 100644 index d44927609d..0000000000 --- a/zephyr/projects/npcx_evb/npcx7/gpio.dts +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_wp; - }; - - named-gpios { - compatible = "named-gpios"; - - recovery_l { - gpios = <&gpio0 3 GPIO_INPUT_PULL_UP>; - }; - gpio_wp: wp_l { - gpios = <&gpio9 3 (GPIO_INPUT_PULL_UP | - GPIO_ACTIVE_LOW)>; - }; - gpio_ac_present: ac_present { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_power_button_l: power_button_l { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_lid_open: lid_open { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - entering_rw { - gpios = <&gpio3 6 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_pch_wake_odl: pch_wake_l { - gpios = <&gpio5 0 GPIO_OUTPUT_HIGH>; - }; - gpio_pgood_fan: pgood_fan { - gpios = <&gpioc 7 GPIO_INPUT_PULL_UP>; - }; - spi_cs_l { - gpios = <&gpioa 5 GPIO_OUTPUT_HIGH>; - }; - board_version1 { - gpios = <&gpio6 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - board_version2 { - gpios = <&gpio6 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - board_version3 { - gpios = <&gpio6 6 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_power_button - &int_lid_open - >; - }; -}; diff --git a/zephyr/projects/npcx_evb/npcx7/interrupts.dts b/zephyr/projects/npcx_evb/npcx7/interrupts.dts deleted file mode 100644 index 3e92428ef4..0000000000 --- a/zephyr/projects/npcx_evb/npcx7/interrupts.dts +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_ac_present: ac_present { - irq-pin = <&gpio_ac_present>; - flags = ; - handler = "extpower_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - }; -}; diff --git a/zephyr/projects/npcx_evb/npcx7/keyboard.dts b/zephyr/projects/npcx_evb/npcx7/keyboard.dts deleted file mode 100644 index 3fb6986f1a..0000000000 --- a/zephyr/projects/npcx_evb/npcx7/keyboard.dts +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - output-settle = <40>; - debounce-down = <6000>; - scan-period = <1500>; - poll-timeout = <1000000>; - - actual-key-mask = < - 0x14 /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xf6 /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xc8 /* C12 */ - >; - }; - - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm2 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm2 { - status = "okay"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/npcx_evb/npcx7/prj.conf b/zephyr/projects/npcx_evb/npcx7/prj.conf deleted file mode 100644 index 5f1fc03f88..0000000000 --- a/zephyr/projects/npcx_evb/npcx7/prj.conf +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_BRINGUP=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_SHIMMED_TASKS=y - -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -CONFIG_PLATFORM_EC_SWITCH=n -CONFIG_PLATFORM_EC_VBOOT_EFS2=n -CONFIG_PLATFORM_EC_VSTORE=n - -# Board version is selected over GPIO board ID pins. -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y - -# PWM -CONFIG_PWM=y - -# Sensors -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n - -# Console command -CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y - -CONFIG_TRACING=y -CONFIG_TRACING_ISR=y -CONFIG_TRACING_USER=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_IRQ=y - -# eSPI -CONFIG_ESPI=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y - -# Keyboard -CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y - -# RTC -CONFIG_PLATFORM_EC_RTC=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y - -# USB-C -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n - -# Zephyr feature -CONFIG_ASSERT=y -CONFIG_SHELL_MINIMAL=n -CONFIG_LOG=y - -# Avoid underflow info from tachometer -CONFIG_SENSOR_LOG_LEVEL_ERR=y - -CONFIG_SYSCON=y diff --git a/zephyr/projects/npcx_evb/npcx9/BUILD.py b/zephyr/projects/npcx_evb/npcx9/BUILD.py deleted file mode 100644 index 335f410d9b..0000000000 --- a/zephyr/projects/npcx_evb/npcx9/BUILD.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for npcx9_evb.""" - -register_npcx_project( - project_name="npcx9", - zephyr_board="npcx9_evb", - dts_overlays=[ - "gpio.dts", - "interrupts.dts", - "fan.dts", - "keyboard.dts", - ], -) diff --git a/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt b/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt deleted file mode 100644 index ef734c06f6..0000000000 --- a/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(npcx9) - -zephyr_include_directories(include) diff --git a/zephyr/projects/npcx_evb/npcx9/fan.dts b/zephyr/projects/npcx_evb/npcx9/fan.dts deleted file mode 100644 index dc4debdcb9..0000000000 --- a/zephyr/projects/npcx_evb/npcx9/fan.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - rpm_min = <1000>; - rpm_start = <1000>; - rpm_max = <5200>; - tach = <&tach1>; - pgood_gpio = <&gpio_pgood_fan>; - }; - }; -}; - -/* Tachometer for fan speed measurement */ -&tach1 { - status = "okay"; - pinctrl-0 = <&ta1_1_in_gp40>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/npcx_evb/npcx9/gpio.dts b/zephyr/projects/npcx_evb/npcx9/gpio.dts deleted file mode 100644 index 9a32112471..0000000000 --- a/zephyr/projects/npcx_evb/npcx9/gpio.dts +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_wp; - }; - - named-gpios { - compatible = "named-gpios"; - - recovery_l { - gpios = <&gpio0 3 GPIO_INPUT_PULL_UP>; - }; - gpio_wp: wp_l { - gpios = <&gpio9 3 (GPIO_INPUT_PULL_UP | - GPIO_ACTIVE_LOW)>; - }; - gpio_ac_present: ac_present { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_power_button_l: power_button_l { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_lid_open: lid_open { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - entering_rw { - gpios = <&gpio3 6 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_ec_pch_wake_odl: pch_wake_l { - gpios = <&gpio5 0 GPIO_OUTPUT_HIGH>; - }; - gpio_pgood_fan: pgood_fan { - gpios = <&gpioc 7 GPIO_INPUT_PULL_UP>; - }; - spi_cs_l { - gpios = <&gpioa 5 GPIO_OUTPUT_HIGH>; - }; - board_version1 { - gpios = <&gpio6 4 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - board_version2 { - gpios = <&gpio6 5 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - board_version3 { - gpios = <&gpio6 6 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - }; -}; - -/* A falling edge detection type for PSL_IN2 */ -&psl_in2_gp00 { - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in2_gp00>; -}; diff --git a/zephyr/projects/npcx_evb/npcx9/interrupts.dts b/zephyr/projects/npcx_evb/npcx9/interrupts.dts deleted file mode 100644 index 3e92428ef4..0000000000 --- a/zephyr/projects/npcx_evb/npcx9/interrupts.dts +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_ac_present: ac_present { - irq-pin = <&gpio_ac_present>; - flags = ; - handler = "extpower_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - }; -}; diff --git a/zephyr/projects/npcx_evb/npcx9/keyboard.dts b/zephyr/projects/npcx_evb/npcx9/keyboard.dts deleted file mode 100644 index 3fb6986f1a..0000000000 --- a/zephyr/projects/npcx_evb/npcx9/keyboard.dts +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - output-settle = <40>; - debounce-down = <6000>; - scan-period = <1500>; - poll-timeout = <1000000>; - - actual-key-mask = < - 0x14 /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xf6 /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xc8 /* C12 */ - >; - }; - - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm2 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm2 { - status = "okay"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/npcx_evb/npcx9/prj.conf b/zephyr/projects/npcx_evb/npcx9/prj.conf deleted file mode 100644 index 827b6366c6..0000000000 --- a/zephyr/projects/npcx_evb/npcx9/prj.conf +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_BRINGUP=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_SHIMMED_TASKS=y - -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -CONFIG_PLATFORM_EC_SWITCH=n -CONFIG_PLATFORM_EC_VBOOT_EFS2=n -CONFIG_PLATFORM_EC_VSTORE=n - -# Workaround npcx9 A1 chip's bug for download_from_flash API in th booter. -# This can be removed when A2 chip is available. -CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y - -# Board version is selected over GPIO board ID pins. -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y - -# PWM -CONFIG_PWM=y - -# Sensors -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n - -# Console command -CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y - -CONFIG_TRACING=y -CONFIG_TRACING_ISR=y -CONFIG_TRACING_USER=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_IRQ=y - -# eSPI -CONFIG_ESPI=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y - -# Keyboard -CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y - -# RTC -CONFIG_PLATFORM_EC_RTC=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y - -# USB-C -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n - -# Zephyr feature -CONFIG_ASSERT=y -CONFIG_SHELL_MINIMAL=n -CONFIG_LOG=y - -# Avoid underflow info from tachometer -CONFIG_SENSOR_LOG_LEVEL_ERR=y - -CONFIG_SYSCON=y diff --git a/zephyr/projects/rex/BUILD.py b/zephyr/projects/rex/BUILD.py deleted file mode 100644 index 2537f61226..0000000000 --- a/zephyr/projects/rex/BUILD.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Rex Projects.""" - - -def register_variant( - project_name, extra_dts_overlays=(), extra_kconfig_files=() -): - """Register a variant of rex.""" - register_npcx_project( - project_name=project_name, - zephyr_board="npcx9m7f", - dts_overlays=[ - # Common to all projects. - here / "rex.dts", - # Project-specific DTS customization. - *extra_dts_overlays, - ], - kconfig_files=[ - # Common to all projects. - here / "prj.conf", - # Project-specific KConfig customization. - *extra_kconfig_files, - ], - ) - - -register_variant( - project_name="rex", - extra_dts_overlays=[ - here / "generated.dts", - here / "interrupts.dts", - here / "power_signals.dts", - here / "battery.dts", - here / "usbc.dts", - here / "keyboard.dts", - here / "led.dts", - here / "fan.dts", - here / "temp_sensors.dts", - here / "motionsense.dts", - ], - extra_kconfig_files=[here / "prj_rex.conf"], -) diff --git a/zephyr/projects/rex/CMakeLists.txt b/zephyr/projects/rex/CMakeLists.txt deleted file mode 100644 index 27d7dff068..0000000000 --- a/zephyr/projects/rex/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.20.5) -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(rex) - -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") -zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ "src/board_power.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usbc_config.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy.c") diff --git a/zephyr/projects/rex/Kconfig b/zephyr/projects/rex/Kconfig deleted file mode 100644 index 7d17c27815..0000000000 --- a/zephyr/projects/rex/Kconfig +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -config BOARD_REX - bool "Google Rex Baseboard" - help - Build Google Rex reference board. The board uses Nuvoton - NPCX9 chip as the EC. - -source "Kconfig.zephyr" diff --git a/zephyr/projects/rex/battery.dts b/zephyr/projects/rex/battery.dts deleted file mode 100644 index e11346f48d..0000000000 --- a/zephyr/projects/rex/battery.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: batgqa05l22 { - compatible = "powertech,batgqa05l22", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/rex/fan.dts b/zephyr/projects/rex/fan.dts deleted file mode 100644 index aa6dcfde7d..0000000000 --- a/zephyr/projects/rex/fan.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan_0 { - pwms = <&pwm5 0 PWM_KHZ(1) PWM_POLARITY_NORMAL>; - rpm_min = <2200>; - rpm_start = <2200>; - rpm_max = <4200>; - tach = <&tach1>; - enable_gpio = <&gpio_en_pp5000_fan>; - }; - }; -}; - -/* Tachemeter for fan speed measurement */ -&tach1 { - status = "okay"; - pinctrl-0 = <&ta1_1_in_gp40>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm5_gpb7 { - drive-open-drain; -}; - -&pwm5 { - status = "okay"; - pinctrl-0 = <&pwm5_gpb7>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/rex/generated.dts b/zephyr/projects/rex/generated.dts deleted file mode 100644 index 5b6f9cd708..0000000000 --- a/zephyr/projects/rex/generated.dts +++ /dev/null @@ -1,363 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * This file is auto-generated - do not edit! - * - * TODO(b:/244441996): There are some errors in the main Rex EC GPIO spreadsheet - * which is used as input to create this device tree file. Until that issue is - * resolved, there are some edits required to this file to support EC - * functionality. - */ - -/ { - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_ddr_soc: ddr_soc { - enum-name = "ADC_TEMP_SENSOR_1_DDR_SOC"; - io-channels = <&adc0 0>; - }; - adc_ambient: ambient { - enum-name = "ADC_TEMP_SENSOR_2"; - io-channels = <&adc0 1>; - }; - adc_charger: charger { - enum-name = "ADC_TEMP_SENSOR_3"; - io-channels = <&adc0 8>; - }; - adc_wwan: wwan { - enum-name = "ADC_TEMP_SENSOR_4"; - io-channels = <&adc0 7>; - }; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_cpu_c10_gate_l: cpu_c10_gate_l { - gpios = <&gpioa 7 GPIO_INPUT>; - }; - gpio_ec_accel_int_r_l: ec_accel_int_r_l { - gpios = <&gpio8 1 GPIO_INPUT>; - }; - gpio_ec_als_rgb_int_r_l: ec_als_rgb_int_r_l { - gpios = <&gpiod 4 GPIO_INPUT_PULL_UP>; - }; - gpio_ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpioa 3 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio7 3 GPIO_OUTPUT>; - }; - gpio_ec_edp_bl_en: ec_edp_bl_en { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { - gpios = <&gpio7 5 GPIO_OUTPUT>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ec_imu_int_r_l: ec_imu_int_r_l { - gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>; - }; - gpio_ec_imvp92_en_smb: ec_imvp92_en_smb { - gpios = <&gpiob 1 GPIO_OUTPUT>; - }; - gpio_ec_kb_bl_en_l: ec_kb_bl_en_l { - gpios = <&gpio8 6 GPIO_OUTPUT>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_ec_prochot_in_l: ec_prochot_in_l { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_ec_prochot_odl: ec_prochot_odl { - gpios = <&gpio6 3 GPIO_ODR_HIGH>; - }; - gpio_ec_rst_r_odl: ec_rst_r_odl { - gpios = <&gpio7 7 GPIO_INPUT>; - }; - gpio_ec_soc_int_odl: ec_soc_int_odl { - gpios = <&gpio7 0 GPIO_ODR_LOW>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { - gpios = <&gpioc 1 GPIO_ODR_LOW>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioa 6 GPIO_OUTPUT>; - }; - gpio_ec_soc_rtcrst: ec_soc_rtcrst { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - }; - gpio_ec_soc_wake_r_odl: ec_soc_wake_r_odl { - gpios = <&gpioc 0 GPIO_ODR_LOW>; - }; - gpio_ec_spare_gpio42: ec_spare_gpio42 { - gpios = <&gpio4 2 GPIO_OUTPUT>; - }; - gpio_ec_spare_gpio66: ec_spare_gpio66 { - gpios = <&gpio6 6 GPIO_OUTPUT>; - }; - gpio_ec_spare_gpio94: ec_spare_gpio94 { - gpios = <&gpio9 4 GPIO_OUTPUT>; - }; - gpio_ec_spare_gpioa2: ec_spare_gpioa2 { - gpios = <&gpioa 2 GPIO_OUTPUT>; - }; - gpio_ec_spare_gpioa4: ec_spare_gpioa4 { - gpios = <&gpioa 4 GPIO_OUTPUT>; - }; - gpio_ec_spare_gpioc7: ec_spare_gpioc7 { - gpios = <&gpioc 7 GPIO_OUTPUT>; - }; - gpio_ec_spare_gpo32: ec_spare_gpo32 { - gpios = <&gpio3 2 GPIO_OUTPUT>; - }; - gpio_ec_spare_gpo35: ec_spare_gpo35 { - gpios = <&gpio3 5 GPIO_OUTPUT>; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpio9 7 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_l: ec_wp_l { - gpios = <&gpioa 1 GPIO_INPUT>; - }; - gpio_en_pp5000_fan: en_pp5000_fan { - gpios = <&gpio6 1 GPIO_OUTPUT_LOW>; - }; - gpio_en_pp5000_usba_r: en_pp5000_usba_r { - gpios = <&gpiod 7 GPIO_OUTPUT>; - }; - gpio_en_s5_rails: en_s5_rails { - gpios = <&gpiob 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_TEMP_SENSOR_POWER"; - }; - gpio_en_z1_rails: en_z1_rails { - gpios = <&gpio8 5 GPIO_OUTPUT>; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; - }; - gpio_imvp92_vrrdy_od: imvp92_vrrdy_od { - gpios = <&gpio4 3 GPIO_INPUT>; - }; - gpio_led_1_l: led_1_l { - gpios = <&gpioc 4 GPIO_OUTPUT>; - }; - gpio_led_2_l: led_2_l { - gpios = <&gpioc 3 GPIO_OUTPUT>; - }; - gpio_led_3_l: led_3_l { - gpios = <&gpioc 2 GPIO_OUTPUT>; - }; - gpio_led_4_l: led_4_l { - gpios = <&gpio6 0 GPIO_OUTPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_mech_pwr_btn_odl: mech_pwr_btn_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_seq_ec_all_sys_pg: seq_ec_all_sys_pg { - gpios = <&gpiof 4 GPIO_INPUT>; - }; - gpio_seq_ec_rsmrst_odl: seq_ec_rsmrst_odl { - gpios = <&gpioe 2 GPIO_INPUT>; - }; - gpio_slp_s3_ls_l: slp_s3_ls_l { - gpios = <&gpio4 1 GPIO_INPUT>; - }; - gpio_sochot_odl: sochot_odl { - gpios = <&gpio9 6 GPIO_INPUT>; - }; - gpio_soc_pwrok: soc_pwrok { - gpios = <&gpioa 5 GPIO_OUTPUT>; - }; - gpio_sys_pwrok: sys_pwrok { - gpios = <&gpiob 0 GPIO_OUTPUT>; - }; - gpio_sys_rst_odl: sys_rst_odl { - gpios = <&gpioc 5 GPIO_INPUT>; - }; - gpio_sys_slp_s0ix_3v3_l: sys_slp_s0ix_3v3_l { - gpios = <&gpiod 5 GPIO_INPUT>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpio9 5 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio6 2 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - gpio_usb_c0_rt_3p3_sx_en: usb_c0_rt_3p3_sx_en { - gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_rt_int_odl: usb_c0_rt_int_odl { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst_odl: usb_c0_tcpc_rst_odl { - gpios = <&gpio6 7 GPIO_ODR_HIGH>; - }; - gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { - gpios = <&gpio5 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_BC12_INT_ODL"; - }; - gpio_usb_c1_frs_en: usb_c1_frs_en { - gpios = <&gpio8 3 GPIO_ODR_HIGH>; - }; - gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PPC_INT_ODL"; - }; - gpio_usb_c1_rst_odl: usb_c1_rst_odl { - gpios = <&gpio3 7 GPIO_ODR_LOW>; - }; - gpio_usb_c1_rt_int_odl: usb_c1_rt_int_odl { - gpios = <&gpio7 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_rt_rst_r_odl: usb_c1_rt_rst_r_odl { - gpios = <&gpio7 4 GPIO_ODR_HIGH>; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpio3 4 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; - }; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_ec_i2c_sensor: ec_i2c_sensor { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_ec_i2c_usb_c0_tcp: ec_i2c_usb_c0_tcp { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_USB_C0_TCPC"; - }; - i2c_ec_i2c_usb_c0_ppc_b: ec_i2c_usb_c0_ppc_b { - i2c-port = <&i2c2_0>; - enum-names = "I2C_PORT_PPC0"; - }; - i2c_ec_i2c_usb_c0_rt: ec_i2c_usb_c0_rt { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_C0_RT"; - }; - i2c_ec_i2c_usb_c1_tcp: ec_i2c_usb_c1_tcp { - i2c-port = <&i2c4_1>; - enum-names = "I2C_PORT_USB_C1_TCPC"; - dynamic-speed; - }; - i2c_ec_i2c_bat: ec_i2c_bat { - i2c-port = <&i2c5_0>; - enum-names = "I2C_PORT_BATTERY"; - }; - i2c_ec_i2c_usb_c1_mix: ec_i2c_usb_c1_mix { - i2c-port = <&i2c6_1>; - enum-names = "I2C_PORT_USB_1_MIX"; - }; - i2c_ec_i2c_mi: ec_i2c_mi { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - }; -}; - -&adc0 { - status = "okay"; -}; - -&i2c0_0 { - status = "okay"; -}; - -&i2c1_0 { - status = "okay"; -}; - -&i2c2_0 { - status = "okay"; -}; - -&i2c3_0 { - status = "okay"; -}; - -&i2c4_1 { - status = "okay"; -}; - -&i2c5_0 { - status = "okay"; -}; - -&i2c6_1 { - status = "okay"; -}; - -&i2c7_0 { - status = "okay"; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c_ctrl4 { - status = "okay"; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c_ctrl6 { - status = "okay"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/rex/include/gpio_map.h b/zephyr/projects/rex/include/gpio_map.h deleted file mode 100644 index 01cbc44396..0000000000 --- a/zephyr/projects/rex/include/gpio_map.h +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __ZEPHYR_GPIO_MAP_H -#define __ZEPHYR_GPIO_MAP_H - -#endif /* __ZEPHYR_GPIO_MAP_H */ diff --git a/zephyr/projects/rex/interrupts.dts b/zephyr/projects/rex/interrupts.dts deleted file mode 100644 index 7de9141caf..0000000000 --- a/zephyr/projects/rex/interrupts.dts +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_ac_present: ac_present { - irq-pin = <&gpio_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_mech_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_usb_c0_sbu_fault: c0_sbu_fault { - irq-pin = <&ioex_usb_c0_sbu_fault_odl>; - flags = ; - handler = "sbu_fault_interrupt"; - }; - int_usb_c0_tcpc: usb_c0_tcpc { - irq-pin = <&gpio_usb_c0_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&gpio_usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c1_tcpc: usb_c1_tcpc { - irq-pin = <&gpio_usb_c1_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_ppc: usb_c1_ppc { - irq-pin = <&gpio_usb_c1_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_bc12: usb_c1_bc12 { - irq-pin = <&gpio_usb_c1_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_imu: ec_imu { - irq-pin = <&gpio_ec_imu_int_r_l>; - flags = ; - handler = "lsm6dso_interrupt"; - }; - int_als_rgb: ec_als_rgb { - irq-pin = <&gpio_ec_als_rgb_int_r_l>; - flags = ; - handler = "tcs3400_interrupt"; - }; - int_accel: ec_accel { - irq-pin = <&gpio_ec_accel_int_r_l>; - flags = ; - handler = "lis2dw12_interrupt"; - }; - }; -}; - -/* Required node label that doesn't is named differently on Rex */ -gpio_ec_pch_wake_odl: &gpio_ec_soc_wake_r_odl {}; - diff --git a/zephyr/projects/rex/keyboard.dts b/zephyr/projects/rex/keyboard.dts deleted file mode 100644 index 91fad2db92..0000000000 --- a/zephyr/projects/rex/keyboard.dts +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm3 0 PWM_HZ(2400) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm3 { - status = "okay"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/rex/led.dts b/zephyr/projects/rex/led.dts deleted file mode 100644 index 94acb6da5c..0000000000 --- a/zephyr/projects/rex/led.dts +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_led_1_l 1>, - <&gpio_led_2_l 1>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_led_1_l 1>, - <&gpio_led_2_l 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_led_1_l 0>, - <&gpio_led_2_l 1>; - }; - }; - - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* Blue 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Red 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* White 2 sec, Amber 2 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - }; - - power-state-idle-default { - charge-state = "PWR_STATE_IDLE"; - - color-0 { - led-color = <&color_white>; - }; - }; - }; -}; - -&gpio_led_1_l { - #led-pin-cells = <1>; -}; - -&gpio_led_2_l { - #led-pin-cells = <1>; -}; - -&gpio_led_3_l { - #led-pin-cells = <1>; -}; - -&gpio_led_4_l { - #led-pin-cells = <1>; -}; diff --git a/zephyr/projects/rex/motionsense.dts b/zephyr/projects/rex/motionsense.dts deleted file mode 100644 index 6af7cd2b12..0000000000 --- a/zephyr/projects/rex/motionsense.dts +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2022 The ChromiumOS Authors - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - lsm6dso-int = &base_accel; - lis2dw12-int = &lid_accel; - tcs3400-int = &als_clear; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - mutex_lis2dw12: lis2dw12-mutex { - }; - - mutex_lsm6dso: lsm6dso-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - - lsm6dso_accel_data: lsm6dso-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - lsm6dso_gyro_data: lsm6dso-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dso"; - status = "okay"; - }; - - tcs_clear_data: tcs3400-clear-drv-data { - compatible = "cros-ec,drvdata-tcs3400-clear"; - status = "okay"; - - als-drv-data { - compatible = "cros-ec,accelgyro-als-drv-data"; - als-cal { - scale = <1>; - uscale = <0>; - offset = <0>; - als-channel-scale { - compatible = - "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - - tcs_rgb_data: tcs3400-rgb-drv-data { - compatible = "cros-ec,drvdata-tcs3400-rgb"; - status = "okay"; - - /* node for rgb_calibration_t defined in accelgyro.h */ - rgb_calibration { - compatible = - "cros-ec,accelgyro-rgb-calibration"; - - irt = <1>; - - rgb-cal-x { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = - "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-y { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = - "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - rgb-cal-z { - offset = <0>; - coeff = <0 0 0 1>; - als-channel-scale { - compatible = - "cros-ec,accelgyro-als-channel-scale"; - k-channel-scale = <1>; - cover-scale = <1>; - }; - }; - }; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&mutex_lis2dw12>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,lsm6dso-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_lsm6dso>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <4>; - drv-data = <&lsm6dso_accel_data>; - i2c-spi-addr-flags = "LSM6DSO_ADDR0_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,lsm6dso-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_lsm6dso>; - port = <&i2c_ec_i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ - drv-data = <&lsm6dso_gyro_data>; - i2c-spi-addr-flags = "LSM6DSO_ADDR0_FLAGS"; - }; - - als_clear: base-als-clear { - compatible = "cros-ec,tcs3400-clear"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - port = <&i2c_ec_i2c_sensor>; - default-range = <0x10000>; - drv-data = <&tcs_clear_data>; - i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - /* Run ALS sensor in S0 */ - odr = <1000>; - }; - }; - }; - - base-als-rgb { - compatible = "cros-ec,tcs3400-rgb"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_CAMERA"; - default-range = <0x10000>; /* scale = 1x, uscale = 0 */ - drv-data = <&tcs_rgb_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* list of entries for motion_als_sensors */ - als-sensors = <&als_clear>; - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_imu &int_als_rgb &int_accel>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel &als_clear>; - }; -}; diff --git a/zephyr/projects/rex/power_signals.dts b/zephyr/projects/rex/power_signals.dts deleted file mode 100644 index 09c84b8558..0000000000 --- a/zephyr/projects/rex/power_signals.dts +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - chosen { - intel-ap-pwrseq,espi = &espi0; - }; - - common-pwrseq { - compatible = "intel,ap-pwrseq"; - - sys-pwrok-delay = <3>; - all-sys-pwrgd-timeout = <20>; - }; - - pwr-en-pp3300-s5 { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PP1800_S5/PP3300_S5 enable output to LS"; - enum-name = "PWR_EN_PP3300_A"; - gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>; - output; - }; - pwr-pg-ec-rsmrst-od { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST power good from regulator"; - enum-name = "PWR_RSMRST"; - gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>; - interrupt-flags = ; - }; - pwr-ec-pch-rsmrst-odl { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "RSMRST output to PCH"; - enum-name = "PWR_EC_PCH_RSMRST"; - gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>; - output; - }; - pwr-pch-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "PCH_PWROK output to PCH"; - enum-name = "PWR_PCH_PWROK"; - gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>; - output; - }; - pwr-ec-pch-sys-pwrok { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_PWROK output to PCH"; - enum-name = "PWR_EC_PCH_SYS_PWROK"; - gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>; - output; - }; - pwr-sys-rst-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SYS_RESET# output to PCH"; - enum-name = "PWR_SYS_RST"; - gpios = <&gpioc 5 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>; - output; - }; - pwr-slp-s0-l { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "SLP_S0_L input from PCH"; - enum-name = "PWR_SLP_S0"; - gpios = <&gpiod 5 GPIO_ACTIVE_LOW>; - interrupt-flags = ; - }; - pwr-slp-s3-l { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S3_L input from PCH"; - enum-name = "PWR_SLP_S3"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; -/* - * TODO: Initially, use virtual wire for sleep S3 signal instead of - * of the GPIO signal which also exists. - * compatible = "intel,ap-pwrseq-gpio"; - * gpios = <&gpio4 1 GPIO_ACTIVE_LOW>; - * interrupt-flags = ; - */ - }; - pwr-slp-s4 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S4 virtual wire input from PCH"; - enum-name = "PWR_SLP_S4"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; - vw-invert; - }; - pwr-slp-s5 { - compatible = "intel,ap-pwrseq-vw"; - dbg-label = "SLP_S5 virtual wire input from PCH"; - enum-name = "PWR_SLP_S5"; - virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; - vw-invert; - }; - pwr-all-sys-pwrgd { - compatible = "intel,ap-pwrseq-gpio"; - dbg-label = "all power good"; - enum-name = "PWR_ALL_SYS_PWRGD"; - gpios = <&gpiof 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - interrupt-flags = ; - }; -}; - -/* - * Because the power signals directly reference the GPIOs, - * the corresponding named-gpios need to have no-auto-init set. - */ - /* pwr-en-pp3300-s5 */ -&gpio_en_s5_rails { - no-auto-init; -}; - -/* pwr-pg-ec-rsmrst-od */ -&gpio_seq_ec_rsmrst_odl { - no-auto-init; -}; - -/* pwr-ec-pch-rsmrst-odl */ -&gpio_ec_soc_rsmrst_l { - no-auto-init; -}; - -/* pwr-pch-pwrok */ -&gpio_soc_pwrok { - no-auto-init; -}; - -/* pwr-ec-pch-sys-pwrok */ -&gpio_sys_pwrok { - no-auto-init; -}; - -/* pwr-sys-rst-l */ -&gpio_sys_rst_odl { - no-auto-init; -}; - -/* pwr-slp-s0-l */ -&gpio_sys_slp_s0ix_3v3_l { - no-auto-init; -}; - -/* pwr-slp-s3-l */ -&gpio_slp_s3_ls_l { - no-auto-init; -}; - -/* pwr-all-sys-pwrgd */ -&gpio_seq_ec_all_sys_pg { - no-auto-init; -}; - diff --git a/zephyr/projects/rex/prj.conf b/zephyr/projects/rex/prj.conf deleted file mode 100644 index 7dcb2894da..0000000000 --- a/zephyr/projects/rex/prj.conf +++ /dev/null @@ -1,180 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_PLATFORM_EC=y -CONFIG_CROS_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_SYSCON=y -# Enable during development -CONFIG_LTO=n -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y -CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y - -# Shell Commands -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y -CONFIG_KERNEL_SHELL=y - -# Logging -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y - -# Disable default features we don't want in a minimal example. -CONFIG_PLATFORM_EC_BACKLIGHT_LID=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_PLATFORM_EC_VBOOT_EFS2=y - -# Application processor; communicates with EC via eSPI -CONFIG_AP=y -CONFIG_ESPI=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y -CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y -CONFIG_PLATFORM_EC_HOSTCMD=y -# Disabling this until temp sensor support is in -CONFIG_PLATFORM_EC_THROTTLE_AP=n -CONFIG_PLATFORM_EC_PORT80=y - -# Power Sequecing -CONFIG_AP_X86_INTEL_MTL=y -CONFIG_X86_NON_DSX_PWRSEQ_MTL=y -CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y -# TODO (b/240434243): This may be needed, but using eSPI VW for now -CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n - -# Zephyr Inbuilt AP Power Sequencing Config -CONFIG_AP_PWRSEQ=y -CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y -CONFIG_AP_PWRSEQ_S0IX=y - -# ADC -CONFIG_ADC=y - -# I2C -CONFIG_I2C=y -CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y - -# PWM -CONFIG_PWM=y - -# Fan -CONFIG_TACH_NPCX=y - -# Temperature sensors -CONFIG_SENSOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y - -# CBI EEPROM support -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y -CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512 -CONFIG_PLATFORM_EC_CHARGER_ISL9241=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=30000 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 - -# USB-A -CONFIG_PLATFORM_EC_USBA=y - -# USBC -CONFIG_PLATFORM_EC_USBC_PPC=y -CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682X_SMART_DISCHARGE=y -CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y -CONFIG_PLATFORM_EC_USBC_VCONN=y - -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y -CONFIG_PLATFORM_EC_USB_PD_REV30=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y -CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y -CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y -CONFIG_PLATFORM_EC_USB_PD_USB4=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y -CONFIG_PLATFORM_EC_USB_PID=0x504D - -# IOEX -CONFIG_GPIO_NCT38XX=y - -# BC 1.2 -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y - -#USB Mux -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_MUX_TASK=y - -# External power -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y - -# Standard shimmed features -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_LID_SWITCH=y - -# Keyboard support -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y -# Column 2 is driven through the GSC, which inverts the signal going through it -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y - -# MKBP event -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y - -# Sensors console command -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y - -# Sensors -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y -CONFIG_PLATFORM_EC_ALS_TCS3400=y diff --git a/zephyr/projects/rex/prj_rex.conf b/zephyr/projects/rex/prj_rex.conf deleted file mode 100644 index 0f204b9669..0000000000 --- a/zephyr/projects/rex/prj_rex.conf +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Rex reference-board-specific Kconfig settings. -CONFIG_BOARD_REX=y - -# Keyboard -CONFIG_CROS_KB_RAW_NPCX=y diff --git a/zephyr/projects/rex/rex.dts b/zephyr/projects/rex/rex.dts deleted file mode 100644 index 2d7e1b89ba..0000000000 --- a/zephyr/projects/rex/rex.dts +++ /dev/null @@ -1,262 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #include - -/ { - aliases { - gpio-wp = &ec_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - ec_wp_l: write-protect { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - gpio_ec_entering_rw: ec_entering_rw { - enum-name = "GPIO_ENTERING_RW"; - }; - - ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl { - gpios = <&ioex_c0_port1 2 GPIO_INPUT>; - }; - ioex_usb_c0_rt_rst_ls_l: usb_c0_rt_rst_ls_l { - gpios = <&ioex_c0_port0 7 GPIO_OUTPUT>; - }; - - ioex_usb_c0_frs_en: usb_c0_frs_en { - gpios = <&ioex_c0_port0 6 GPIO_OUTPUT_LOW>; - }; - - /* Need to designate 1.8V for I2C buses on the 1800mV rail */ - ec-i2c-sensor-scl { - gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-c0-rt-scl { - gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-c0-rt-sda { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_pp5000_usba_r>; - }; -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; - -/* Power switch logic input pads */ -&psl_in1_gpd2 { - /* LID_OPEN */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in2_gp00 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* MECH_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; - -/* ADC and GPIO alt-function specifications */ -&adc0 { - pinctrl-0 = <&adc0_chan0_gp45 - &adc0_chan1_gp44 - &adc0_chan8_gpf1 - &adc0_chan7_gpe1>; - pinctrl-names = "default"; -}; - -&i2c0_0 { - label = "I2C_SENSOR"; - clock-frequency = ; - - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; -}; - -&i2c1_0 { - label = "I2C_USB_C0_TCPC"; - clock-frequency = ; - - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - tcpc_port0: nct38xx@70 { - compatible = "nuvoton,nct38xx"; - gpio-dev = <&nct3807_C0>; - reg = <0x70>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct3807_C0: nct3807_C0@70 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x70>; - label = "NCT3807_C0"; - - ioex_c0_port0: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3807_C0_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - pinmux_mask = <0xf7>; - }; - ioex_c0_port1: gpio@1 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x1>; - label = "NCT3807_C0_GPIO1"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - }; - }; - - nct3808_alert_0 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; - nct38xx-dev = <&nct3807_C0>; - label = "NCT3807_ALERT_0"; - }; -}; - -&i2c2_0 { - label = "I2C_PPC0"; - clock-frequency = ; - - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - ppc_port0_syv: ppc_syv@40 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x40>; - frs_en_gpio = <&ioex_usb_c0_frs_en>; - }; -}; - -&i2c3_0 { - label = "I2C_USB_C0_RT"; - clock-frequency = ; - - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; - - usb_c0_hb_retimer: jhl8040r-c0@56 { - compatible = "intel,jhl8040r"; - reg = <0x56>; - ls-en-pin = <&gpio_usb_c0_rt_3p3_sx_en>; - int-pin = <&gpio_usb_c0_rt_int_odl>; - reset-pin = <&ioex_usb_c0_rt_rst_ls_l>; - }; -}; - -&i2c4_1 { - label = "I2_USB_C1_TCPC"; - clock-frequency = ; - - pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; - pinctrl-names = "default"; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - tcpc-flags = <( - TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V | - TCPC_FLAGS_CONTROL_VCONN | - TCPC_FLAGS_CONTROL_FRS)>; - }; -}; - -&i2c5_0 { - label = "I2C__BATTERY"; - clock-frequency = ; - - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; -}; - -&i2c6_1 { - label = "I2C_USB_1_MIX"; - clock-frequency = ; - - pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; - pinctrl-names = "default"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c1_bc12>; - }; - - ppc_port1_nxp: nx20p348x@72 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x72>; - }; -}; - -&i2c7_0 { - label = "I2C_CHARGER"; - clock-frequency = ; - - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; - - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x09>; - }; -}; diff --git a/zephyr/projects/rex/rex0_gpio.csv b/zephyr/projects/rex/rex0_gpio.csv deleted file mode 100644 index 5c20f6fb00..0000000000 --- a/zephyr/projects/rex/rex0_gpio.csv +++ /dev/null @@ -1,122 +0,0 @@ -Signal Name,Pin Number,Type,Enum -USB_C1_BC12_INT_ODL,G10,INPUT,GPIO_USB_C1_BC12_INT_ODL -ESPI_SOC_CS0_L,L2,OTHER, -ESPI_SOC_RESET_L,K3,OTHER, -ESPI_SOC_CLK,M1,OTHER, -EC_IMU_INT_R_L,M2,INPUT_PU, -ESPI_SOC_IO0,H1,OTHER, -ESPI_SOC_IO1,J1,OTHER, -ESPI_SOC_IO2,K1,OTHER, -ESPI_SOC_IO3,L1,OTHER, -ESPI_SOC_ALERT_L_R,L3,OTHER, -EC_VOLDN_BTN_ODL,E11,INPUT_PU,GPIO_VOLUME_DOWN_L -TABLET_MODE_L,M12,INPUT_PU,GPIO_TABLET_MODE_L -SOCHOT_ODL,G12,INPUT, -EC_VOLUP_BTN_ODL,L10,INPUT_PU,GPIO_VOLUME_UP_L -USB_C0_RT_INT_ODL,G11,INPUT, -EC_WP_L,L12,INPUT, -EC_BATT_PRES_ODL,K12,INPUT,GPIO_BATT_PRES_ODL -CPU_C10_GATE_L,J11,INPUT, -SOC_PWROK,K11,OUTPUT, -EC_SOC_RSMRST_L,F11,OUTPUT, -SYS_PWROK,L11,OUTPUT, -EC_SPARE_GPIO94,M11,OUTPUT, -EC_SPARE_GPIOA2,F12,OUTPUT, -EC_SPARE_GPIOA4,H11,OUTPUT, -EC_ACCEL_INT_R_L,M7,INPUT, -SLP_S3_LS_L,C2,INPUT, -IMVP92_VRRDY_OD,E2,INPUT, -EC_PROCHOT_IN_L,D2,INPUT, -EC_SPARE_GPIO42,D3,OUTPUT, -TEMP_SENSOR_2,E3,ADC,ADC_TEMP_SENSOR_2 -TEMP_SENSOR_1,F2,ADC,ADC_TEMP_SENSOR_1 -TEMP_SENSOR_4,F3,ADC,ADC_TEMP_SENSOR_4 -TEMP_SENSOR_3,G3,ADC,ADC_TEMP_SENSOR_3 -SYS_RST_ODL,H7,INPUT, -EC_SOC_WAKE_R_ODL,H8,OUTPUT_ODL, -EC_PROCHOT_ODL,J2,OUTPUT_ODR, -EC_SOC_INT_ODL,J4,OUTPUT_ODL,GPIO_EC_INT_L -EC_SOC_RTCRST,J5,OUTPUT_ODR, -EC_SOC_PWR_BTN_ODL,H9,OUTPUT_ODL,GPIO_PCH_PWRBTN_L -USB_C0_RT_3P3_SX_EN,D9,OUTPUT_ODR, -KSO_13,D11,OTHER, -KSO_12,C11,OTHER, -KSO_11,B10,OTHER, -KSO_10,B11,OTHER, -KSO_09,C10,OTHER, -KSO_08,C9,OTHER, -KSO_05,C6,OTHER, -KSO_04,C7,OTHER, -KSO_03,B8,OTHER, -EC_KSO_02_INV,B7,OUTPUT_L, -KSO_01,B6,OTHER, -KSO_00,B5,OTHER, -KSI_07,C5,OTHER, -KSI_06,C4,OTHER, -KSI_05,C3,OTHER, -KSI_04,B4,OTHER, -EC_KSI_03,B3,OTHER, -EC_KSI_02,A4,OTHER, -KSI_01,A3,OTHER, -EC_KSI_00,A2,OTHER, -EC_I2C_BAT_SCL,D5,I2C_CLOCK,I2C_PORT_BATTERY -USB_C1_TCPC_INT_ODL,B2,INPUT,GPIO_USB_C1_TCPC_INT_ODL -EC_I2C_BAT_SDA,D4,I2C_DATA, -USB_C1_RST_ODL,C1,OUTPUT_ODL, -EC_FAN_TACH,E5,TACH, -LED_4_L,G6,OUTPUT, -EN_PP5000_FAN,K4,OUTPUT_ODR, -USB_C0_PPC_INT_ODL,H2,INPUT,GPIO_USB_C0_PPC_INT_ODL -UART_GSC_DBG_TX_EC_RX_R,G4,OTHER, -EC_SPARE_GPIO66,G2,OUTPUT, -USB_C0_TCPC_RST_ODL,J3,OUTPUT_ODL, -USB_C1_RT_INT_ODL,M4,INPUT_PU, -EC_CBI_WP,G5,OUTPUT, -USB_C1_RT_RST_R_ODL,H5,OUTPUT_ODL, -EC_GSC_PACKET_MODE,J6,OUTPUT_ODR,GPIO_PACKET_MODE_EN -EC_KB_BL_PWM,K5,PWM,GPIO_EN_KEYBOARD_BACKLIGHT -KSO_14,D6,OTHER, -USB_C1_FRS_EN,D7,OUTPUT_ODR, -EC_I2C_USB_C0_TCPC_SDA,K7,I2C_DATA, -EC_I2C_USB_C0_TCPC_SCL,K8,I2C_CLOCK,I2C_PORT_USB_C0_TCPC -EC_I2C_USB_C0_PPC_BC_SDA,K9,I2C_DATA, -EC_I2C_USB_C0_PPC_BC_SCL,L8,I2C_CLOCK,I2C_PORT_PPC0 -EC_IMVP92_EN_SMB,D8,OUTPUT, -EC_I2C_MISC_SDA,K10,I2C_DATA, -EC_I2C_MISC_SCL,J10,I2C_CLOCK,I2C_PORT_EEPROM -EC_I2C_SENSOR_SDA,B12,I2C_DATA, -EC_I2C_SENSOR_SCL,C12,I2C_CLOCK,I2C_PORT_SENSOR -EN_S5_RAILS,L9,OUTPUT_ODR, -FAN_PWM,J7,PWM, -LED_3_L,H10,OUTPUT, -LED_2_L,G9,OUTPUT, -LED_1_L,G8,OUTPUT, -USB_C0_BC12_INT_ODL,D10,INPUT,GPIO_USB_C0_BC12_INT_ODL -EC_SPARE_GPIOC7,F10,OUTPUT, -EC_I2C_USB_C0_RT_SDA,F9,I2C_DATA, -EC_I2C_USB_C0_RT_SCL,F8,I2C_CLOCK,I2C_PORT_USB_C0_RT -EC_EDP_BL_EN,E10,OUTPUT_ODR,GPIO_ENABLE_BACKLIGHT -EC_ALS_RGB_INT_R_L,A9,INPUT_PU, -SYS_SLP_S0IX_3V3_L,A10,INPUT, -USB_C0_TCPC_INT_ODL,F4,INPUT,GPIO_USB_C0_TCPC_INT_ODL -SEQ_EC_RSMRST_ODL,A11,INPUT, -EC_I2C_USB_C1_MIX_SDA,L7,I2C_DATA, -EC_I2C_USB_C1_MIX_SCL,L6,I2C_CLOCK,I2C_PORT_USB_1_MIX -CCD_MODE_ODL,A12,OUTPUT_ODL,GPIO_CCD_MODE_ODL -EC_I2C_USB_C1_TCPC_SDA,F6,I2C_DATA, -EC_I2C_USB_C1_TCPC_SCL,F5,I2C_CLOCK,I2C_PORT_USB_C1_TCPC -SEQ_EC_ALL_SYS_PG,E9,INPUT, -USB_C1_PPC_INT_ODL,E8,INPUT,GPIO_USB_C1_PPC_INT_ODL -EC_KSO_07_JEN_L,B9,OTHER, -EC_KSO_06_GP_SEL_L,C8,OTHER, -EC_SPARE_GPO32,E4,OUTPUT, -EC_SPARE_GPO35,K2,OUTPUT, -UART_GSC_DBG_RX_EC_TX_R,H4,OTHER, -EC_RST_R_ODL,K6,INPUT, -EC_KB_BL_EN_L,J9,OUTPUT, -ACOK_OD,E7,INPUT,GPIO_AC_PRESENT -GSC_EC_PWR_BTN_ODL,E6,INPUT_PU,GPIO_POWER_BUTTON_L -MECH_PWR_BTN_ODL,F7,INPUT, -LID_OPEN,G7,INPUT_PU,GPIO_LID_OPEN -EN_Z1_RAILS,J8,OUTPUT, -EN_PP5000_USBA_R,H6,OUTPUT, diff --git a/zephyr/projects/rex/src/board_power.c b/zephyr/projects/rex/src/board_power.c deleted file mode 100644 index c7f12d024e..0000000000 --- a/zephyr/projects/rex/src/board_power.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "gpio_signal.h" -#include "gpio/gpio.h" - -LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); - -#if CONFIG_X86_NON_DSX_PWRSEQ_MTL -#define X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS 50 - -void board_ap_power_force_shutdown(void) -{ - int timeout_ms = X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS; - - /* Turn off PCH_RMSRST to meet tPCH12 */ - power_signal_set(PWR_EC_PCH_RSMRST, 0); - - /* Turn off PRIM load switch. */ - power_signal_set(PWR_EN_PP3300_A, 0); - - /* Wait RSMRST to be off. */ - while (power_signal_get(PWR_RSMRST) && (timeout_ms > 0)) { - k_msleep(1); - timeout_ms--; - }; - - if (power_signal_get(PWR_RSMRST)) { - LOG_WRN("RSMRST_ODL didn't go low! Assuming G3."); - } -} - -void board_ap_power_action_g3_s5(void) -{ - /* Turn on the PP3300_PRIM rail. */ - power_signal_set(PWR_EN_PP3300_A, 1); - - if (!power_wait_signals_timeout( - IN_PGOOD_ALL_CORE, - AP_PWRSEQ_DT_VALUE(wait_signal_timeout))) { - ap_power_ev_send_callbacks(AP_POWER_PRE_INIT); - } -} - -bool board_ap_power_check_power_rails_enabled(void) -{ - return power_signal_get(PWR_EN_PP3300_A); -} -#endif /* CONFIG_X86_NON_DSX_PWRSEQ_MTL */ diff --git a/zephyr/projects/rex/src/usb_pd_policy.c b/zephyr/projects/rex/src/usb_pd_policy.c deleted file mode 100644 index 7e9876f9c1..0000000000 --- a/zephyr/projects/rex/src/usb_pd_policy.c +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Shared USB-C policy for Rex boards */ - -#include - -#include "charge_manager.h" -#include "chipset.h" -#include "common.h" -#include "compile_time_macros.h" -#include "console.h" -#include "ec_commands.h" -#include "ioexpander.h" -#include "system.h" -#include "usb_mux.h" -#include "usb_pd.h" -#include "usbc_ppc.h" -#include "util.h" - -int pd_check_vconn_swap(int port) -{ - /* Allow VCONN swaps if the AP is on. */ - return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON); -} - -void pd_power_supply_reset(int port) -{ - /* Disable VBUS. */ - ppc_vbus_source_enable(port, 0); - - /* Enable discharge if we were previously sourcing 5V */ - if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) - pd_set_vbus_discharge(port, 1); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - /* Disable charging. */ - rv = ppc_vbus_sink_enable(port, 0); - if (rv) - return rv; - - if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) { - pd_set_vbus_discharge(port, 0); - } - - /* Provide Vbus. */ - rv = ppc_vbus_source_enable(port, 1); - if (rv) { - return rv; - } - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */ -int board_vbus_source_enabled(int port) -{ - return tcpm_get_src_ctrl(port); -} - -/* Used by USB charger task with CONFIG_USB_PD_5V_EN_CUSTOM */ -int board_is_sourcing_vbus(int port) -{ - return board_vbus_source_enabled(port); -} diff --git a/zephyr/projects/rex/src/usbc_config.c b/zephyr/projects/rex/src/usbc_config.c deleted file mode 100644 index 66f3a1f45d..0000000000 --- a/zephyr/projects/rex/src/usbc_config.c +++ /dev/null @@ -1,300 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "battery_fuel_gauge.h" -#include "charger.h" -#include "charge_manager.h" -#include "charge_ramp.h" -#include "charge_state_v2.h" -#include "charge_state.h" -#include "charger.h" -#include "driver/charger/isl9241.h" -#include "driver/retimer/bb_retimer_public.h" -#include "driver/tcpm/nct38xx.h" -#include "driver/tcpm/ps8xxx_public.h" -#include "driver/tcpm/tcpci.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "i2c.h" -#include "ioexpander.h" -#include "driver/ppc/nx20p348x.h" -#include "ppc/syv682x_public.h" -#include "system.h" -#include "task.h" -#include "usb_mux.h" -#include "usbc_ppc.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/*******************************************************************/ -/* USB-C Configuration Start */ - -/* USB-C ports */ -enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; -BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); - -static void usbc_interrupt_init(void) -{ - /* Only reset TCPC if not sysjump */ - if (!system_jumped_late()) { - board_reset_pd_mcu(); - } - - /* Enable PPC interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc)); - - /* Enable TCPC interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc)); - - /* Enable BC 1.2 interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12)); - - /* Enable SBU fault interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault)); -} -DECLARE_HOOK(HOOK_INIT, usbc_interrupt_init, HOOK_PRIO_POST_I2C); - -void board_overcurrent_event(int port, int is_overcurrented) -{ - /* - * TODO: Meteorlake PCH does not use Physical GPIO for over current - * error, hence Send 'Over Current Virtual Wire' eSPI signal. - */ -} - -void sbu_fault_interrupt(enum gpio_signal signal) -{ - int port = USBC_PORT_C0; - - CPRINTSUSB("C%d: SBU fault", port); - pd_handle_overcurrent(port); -} - -void tcpc_alert_event(enum gpio_signal signal) -{ - int port; - - switch (signal) { - case GPIO_USB_C0_TCPC_INT_ODL: - port = 0; - break; - case GPIO_USB_C1_TCPC_INT_ODL: - port = 1; - break; - default: - return; - } - - schedule_deferred_pd_interrupt(port); -} - -static void reset_nct38xx_port(int port) -{ - const struct gpio_dt_spec *reset_gpio_l; - const struct device *ioex_port0, *ioex_port1; - - /* TODO(b/225189538): Save and restore ioex signals */ - if (port == USBC_PORT_C0) { - reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl); - ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0)); - ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port1)); - } else { - /* Invalid port: do nothing */ - return; - } - - gpio_pin_set_dt(reset_gpio_l, 0); - msleep(NCT38XX_RESET_HOLD_DELAY_MS); - gpio_pin_set_dt(reset_gpio_l, 1); - nct38xx_reset_notify(port); - if (NCT3807_RESET_POST_DELAY_MS != 0) { - msleep(NCT3807_RESET_POST_DELAY_MS); - } - - /* Re-enable the IO expander pins */ - gpio_reset_port(ioex_port0); - gpio_reset_port(ioex_port1); -} - -void board_reset_pd_mcu(void) -{ - /* Reset TCPC0 */ - reset_nct38xx_port(USBC_PORT_C0); - - /* Reset TCPC1 */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 0); - msleep(PS8XXX_RESET_DELAY_MS); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 1); - msleep(PS8815_FW_INIT_DELAY_MS); -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - const struct gpio_dt_spec *tcpc_c0_rst_l; - const struct gpio_dt_spec *tcpc_c0_int_l; - const struct gpio_dt_spec *tcpc_c1_rst_l; - const struct gpio_dt_spec *tcpc_c1_int_l; - - tcpc_c0_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl); - tcpc_c0_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl); - - tcpc_c1_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl); - tcpc_c1_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl); - - /* - * Check which port has the ALERT line set and ignore if that TCPC has - * its reset line active. - */ - if (!gpio_pin_get_dt(tcpc_c0_int_l) && gpio_pin_get_dt(tcpc_c0_rst_l)) { - status |= PD_STATUS_TCPC_ALERT_0; - } - - if (!gpio_pin_get_dt(tcpc_c1_int_l) && gpio_pin_get_dt(tcpc_c1_rst_l)) { - status |= PD_STATUS_TCPC_ALERT_1; - } - - return status; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - syv682x_interrupt(USBC_PORT_C0); - break; - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(USBC_PORT_C1); - break; - default: - break; - } -} - -void bc12_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_BC12_INT_ODL: - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - break; - case GPIO_USB_C1_BC12_INT_ODL: - usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); - break; - default: - break; - } -} - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} - -static void board_disable_charger_ports(void) -{ - int i; - - CPRINTSUSB("Disabling all charger ports"); - - /* Disable all ports. */ - for (i = 0; i < ppc_cnt; i++) { - /* - * If this port had booted in dead battery mode, go - * ahead and reset it so EN_SNK responds properly. - */ - if (nct38xx_get_boot_type(i) == NCT38XX_BOOT_DEAD_BATTERY) { - reset_nct38xx_port(i); - pd_set_error_recovery(i); - } - - /* - * Do not return early if one fails otherwise we can - * get into a boot loop assertion failure. - */ - if (ppc_vbus_sink_enable(i, 0)) { - CPRINTSUSB("Disabling C%d as sink failed.", i); - } - } -} - -int board_set_active_charge_port(int port) -{ - int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; - int rv; - - if (port == CHARGE_PORT_NONE) { - board_disable_charger_ports(); - return EC_SUCCESS; - } else if (!is_valid_port) { - return EC_ERROR_INVAL; - } - - /* - * Check if we can reset any ports in dead battery mode - * - * The NCT3807 may continue to keep EN_SNK low on the dead battery port - * and allow a dangerous level of voltage to pass through to the initial - * charge port (see b/183660105). We must reset the ports if we have - * sufficient battery to do so, which will bring EN_SNK back under - * normal control. - */ - rv = EC_SUCCESS; - if (port == USBC_PORT_C0 && - nct38xx_get_boot_type(port) == NCT38XX_BOOT_DEAD_BATTERY) { - /* Handle dead battery boot case */ - CPRINTSUSB("Found dead battery on C0"); - /* - * If we have battery, get this port reset ASAP. - * This means temporarily rejecting charge manager - * sets to it. - */ - if (pd_is_battery_capable()) { - reset_nct38xx_port(port); - pd_set_error_recovery(port); - } - } - - if (rv != EC_SUCCESS) { - return rv; - } - - /* Check if the port is sourcing VBUS. */ - if (tcpm_get_src_ctrl(port)) { - CPRINTSUSB("Skip enable C%d", port); - return EC_ERROR_INVAL; - } - - CPRINTSUSB("New charge port: C%d", port); - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < ppc_cnt; i++) { - if (i == port) { - continue; - } - if (ppc_vbus_sink_enable(i, 0)) { - CPRINTSUSB("C%d: sink path disable failed.", i); - } - } - - /* Enable requested charge port. */ - if (ppc_vbus_sink_enable(port, 1)) { - CPRINTSUSB("C%d: sink path enable failed.", port); - return EC_ERROR_UNKNOWN; - } - - return EC_SUCCESS; -} diff --git a/zephyr/projects/rex/temp_sensors.dts b/zephyr/projects/rex/temp_sensors.dts deleted file mode 100644 index 680ebc8954..0000000000 --- a/zephyr/projects/rex/temp_sensors.dts +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - temp_ddr_soc: ddr_soc { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_ddr_soc>; - }; - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_ambient>; - }; - temp_charger: charger { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_charger>; - }; - temp_wwan: wwan { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_wwan>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - ddr_soc { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - sensor = <&temp_ddr_soc>; - }; - ambient { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <85>; - temp_host_halt = <90>; - temp_host_release_high = <80>; - sensor = <&temp_ambient>; - }; - charger { - temp_fan_off = <35>; - temp_fan_max = <65>; - temp_host_high = <105>; - temp_host_halt = <120>; - temp_host_release_high = <90>; - sensor = <&temp_charger>; - }; - wwan { - temp_fan_off = <35>; - temp_fan_max = <60>; - temp_host_high = <130>; - temp_host_halt = <130>; - temp_host_release_high = <100>; - sensor = <&temp_wwan>; - }; - }; -}; - -&thermistor_3V3_30K9_47K_4050B { - status = "okay"; -}; diff --git a/zephyr/projects/rex/usbc.dts b/zephyr/projects/rex/usbc.dts deleted file mode 100644 index 84ae79fae6..0000000000 --- a/zephyr/projects/rex/usbc.dts +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - usbc_port0: port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0_syv>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_c0_hb_retimer - &virtual_mux_c0>; - }; - }; - port0-muxes { - virtual_mux_c0: virtual-mux-c0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - usbc_port1: port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1_nxp>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&virtual_mux_c1 &tcpci_mux_c1>; - }; - }; - port1-muxes { - tcpci_mux_c1: tcpci-mux-c1 { - compatible = "cros-ec,usbc-mux-tcpci"; - hpd-update = "ps8xxx_tcpc_update_hpd_status"; - }; - virtual_mux_c1: virtual-mux-c1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; diff --git a/zephyr/projects/skyrim/BUILD.py b/zephyr/projects/skyrim/BUILD.py deleted file mode 100644 index 3807150af9..0000000000 --- a/zephyr/projects/skyrim/BUILD.py +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for skyrim.""" - - -def register_skyrim_project( - project_name, - extra_dts_overlays=(), - extra_kconfig_files=(), -): - """Register a variant of skyrim.""" - register_npcx_project( - project_name=project_name, - zephyr_board="npcx9m3f", - dts_overlays=[ - # Common to all projects. - here / "adc.dts", - here / "fan.dts", - here / "gpio.dts", - here / "interrupts.dts", - here / "keyboard.dts", - here / "motionsense.dts", - here / "usbc.dts", - # Project-specific DTS customizations. - *extra_dts_overlays, - ], - kconfig_files=[here / "prj.conf", *extra_kconfig_files], - ) - - -register_skyrim_project( - project_name="morthal", - extra_dts_overlays=[ - here / "morthal.dts", - here / "battery_morthal.dts", - here / "led_pins_morthal.dts", - here / "led_policy_morthal.dts", - ], - extra_kconfig_files=[ - here / "prj_morthal.conf", - ], -) - - -register_skyrim_project( - project_name="skyrim", - extra_dts_overlays=[ - here / "skyrim.dts", - here / "battery_skyrim.dts", - here / "led_pins_skyrim.dts", - here / "led_policy_skyrim.dts", - ], - extra_kconfig_files=[ - here / "prj_skyrim.conf", - ], -) - - -register_skyrim_project( - project_name="winterhold", - extra_dts_overlays=[ - here / "winterhold.dts", - here / "battery_winterhold.dts", - here / "led_pins_winterhold.dts", - here / "led_policy_winterhold.dts", - ], - extra_kconfig_files=[ - here / "prj_winterhold.conf", - ], -) - - -register_skyrim_project( - project_name="frostflow", - extra_dts_overlays=[ - here / "frostflow.dts", - here / "battery_frostflow.dts", - here / "led_pins_frostflow.dts", - here / "led_policy_frostflow.dts", - ], - extra_kconfig_files=[ - here / "prj_frostflow.conf", - ], -) diff --git a/zephyr/projects/skyrim/CMakeLists.txt b/zephyr/projects/skyrim/CMakeLists.txt deleted file mode 100644 index 71b8427aa1..0000000000 --- a/zephyr/projects/skyrim/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") - -zephyr_library_sources("src/common.c") -zephyr_library_sources("src/power_signals.c") - -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/usb_pd_policy.c" - "src/usbc_config.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON - "src/led.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_AMD_STT - "src/stt.c") - -if(DEFINED CONFIG_BOARD_MORTHAL) - project(morthal) - zephyr_library_sources( - "src/morthal/ppc_config.c" - "src/morthal/usb_mux_config.c" -) -endif() - -if(DEFINED CONFIG_BOARD_SKYRIM) - project(skyrim) - cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include) - zephyr_library_sources( - "src/skyrim/usb_mux_config.c" - "src/skyrim/ppc_config.c" - "src/skyrim/form_factor.c" - "src/skyrim/alt_charger.c" - "src/skyrim/keyboard.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/skyrim/fan.c") -endif() - -if(DEFINED CONFIG_BOARD_WINTERHOLD) - project(winterhold) - zephyr_library_sources( - "src/winterhold/usb_mux_config.c" - "src/winterhold/ppc_config.c" - "src/winterhold/kb_backlight.c" - "src/winterhold/keyboard.c" - ) -endif() - -if(DEFINED CONFIG_BOARD_FROSTFLOW) - project(frostflow) - cros_ec_library_include_directories_ifdef(CONFIG_BOARD_FROSTFLOW include) - zephyr_include_directories("include/frostflow") - zephyr_library_sources( - "src/frostflow/usb_mux_config.c" - "src/frostflow/ppc_config.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION - "src/frostflow/keyboard.c" - "src/frostflow/keyboard_customization.c") -endif() diff --git a/zephyr/projects/skyrim/Kconfig b/zephyr/projects/skyrim/Kconfig deleted file mode 100644 index fbb797f6fc..0000000000 --- a/zephyr/projects/skyrim/Kconfig +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -config BOARD_MORTHAL - bool "Google Morthal Board" - help - Build Google Morthal reference board. This board uses an AMD SoC - and NPCX9 EC - -config BOARD_SKYRIM - bool "Google Skyrim Board" - help - Build Google Skyrim reference board. This board uses an AMD SoC - and NPCX9 EC - -config BOARD_WINTERHOLD - bool "Google Winterhold Board" - help - Build Google Winterhold reference board. This board uses an AMD SoC - and NPCX9 EC - -config BOARD_FROSTFLOW - bool "Google Frostflow Board" - help - Build Google Frostflow reference board. This board uses an AMD SoC - and NPCX9 EC - -config BOARD_INPUT_CURRENT_SCALE_FACTOR - int "Input current scale factor" - default 100 - help - Limit input current to fraction of negotiated limit. - -config BOARD_USB_HUB_RESET - bool "Support USB hub reset or not" - default y - help - Enable this if your board has a USB hub reset GPIO connect to EC to - reset the USB hub. - -module = SKYRIM -module-str = Skyrim board-specific code -source "subsys/logging/Kconfig.template.log_config" - -source "Kconfig.zephyr" diff --git a/zephyr/projects/skyrim/adc.dts b/zephyr/projects/skyrim/adc.dts deleted file mode 100644 index 952e5db1d0..0000000000 --- a/zephyr/projects/skyrim/adc.dts +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_temp_charger: temp-charger { - enum-name = "ADC_TEMP_SENSOR_CHARGER"; - io-channels = <&adc0 1>; - }; - adc_temp_memory: temp-memory { - enum-name = "ADC_TEMP_SENSOR_MEMORY"; - io-channels = <&adc0 2>; - }; - adc_core_imon1: core-imon1 { - enum-name = "ADC_CORE_IMON1"; - io-channels = <&adc0 3>; - }; - adc_core_imon2: core-imon2 { - enum-name = "ADC_SOC_IMON2"; - io-channels = <&adc0 4>; - }; - }; - - temp_charger_thermistor: charger-thermistor { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_temp_charger>; - }; - - temp_memory_thermistor: memory-thermistor { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_temp_memory>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - temp_sensor_charger: charger-thermistor { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - sensor = <&temp_charger_thermistor>; - }; - - temp_sensor_memory: memory-thermistor { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&temp_memory_thermistor>; - }; - - temp_sensor_cpu: cpu { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_fan_off = <60>; - temp_fan_max = <90>; - power-good-pin = <&gpio_s0_pgood>; - sensor = <&temp_cpu>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42 - &adc0_chan4_gp41>; - pinctrl-names = "default"; -}; - -&thermistor_3V3_30K9_47K_4050B { - status = "okay"; -}; diff --git a/zephyr/projects/skyrim/battery_frostflow.dts b/zephyr/projects/skyrim/battery_frostflow.dts deleted file mode 100644 index 2d6b28de70..0000000000 --- a/zephyr/projects/skyrim/battery_frostflow.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: cdt_c340152 { - compatible = "cdt,c340152", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/skyrim/battery_morthal.dts b/zephyr/projects/skyrim/battery_morthal.dts deleted file mode 100644 index 8c87cef7f9..0000000000 --- a/zephyr/projects/skyrim/battery_morthal.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: aec_5477109 { - compatible = "aec,5477109", "battery-smart"; - }; - smp_l20m3pg1 { - compatible = "smp,l20m3pg1", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/skyrim/battery_skyrim.dts b/zephyr/projects/skyrim/battery_skyrim.dts deleted file mode 100644 index 8c87cef7f9..0000000000 --- a/zephyr/projects/skyrim/battery_skyrim.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: aec_5477109 { - compatible = "aec,5477109", "battery-smart"; - }; - smp_l20m3pg1 { - compatible = "smp,l20m3pg1", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/skyrim/battery_winterhold.dts b/zephyr/projects/skyrim/battery_winterhold.dts deleted file mode 100644 index 8e82e0d1f2..0000000000 --- a/zephyr/projects/skyrim/battery_winterhold.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: lgc_xphx8 { - compatible = "lgc,xphx8", "battery-smart"; - }; - smp_atlxdy9k { - compatible = "smp,atlxdy9k", "battery-smart"; - }; - smp_cosxdy9k { - compatible = "smp,cosxdy9k", "battery-smart"; - }; - byd_wv3k8 { - compatible = "byd,wv3k8", "battery-smart"; - }; - cosmx_mvk11 { - compatible = "cosmx,mvk11", "battery-smart"; - }; - sunwoda_atlvkyjx { - compatible = "sunwoda,atlvkyjx", "battery-smart"; - }; - sunwoda_cosvkyjx { - compatible = "sunwoda,cosvkyjx", "battery-smart"; - }; - atl_cfd72 { - compatible = "atl,cfd72", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/skyrim/fan.dts b/zephyr/projects/skyrim/fan.dts deleted file mode 100644 index dff26bcb29..0000000000 --- a/zephyr/projects/skyrim/fan.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan0: fan_0 { - pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - rpm_min = <3100>; - rpm_start = <3100>; - rpm_max = <8000>; - tach = <&tach1>; - pgood_gpio = <&gpio_s0_pgood>; - }; - }; -}; - -/* Tachemeter for fan speed measurement */ -&tach1 { - status = "okay"; - pinctrl-0 = <&ta1_1_in_gp40>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/skyrim/frostflow.dts b/zephyr/projects/skyrim/frostflow.dts deleted file mode 100644 index 1ed0b4cb2b..0000000000 --- a/zephyr/projects/skyrim/frostflow.dts +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Frostflow-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <35>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; - -&cros_kb_raw { - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; -}; diff --git a/zephyr/projects/skyrim/gpio.dts b/zephyr/projects/skyrim/gpio.dts deleted file mode 100644 index 57abcc846d..0000000000 --- a/zephyr/projects/skyrim/gpio.dts +++ /dev/null @@ -1,370 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_wp; - gpio-cbi-wp = &gpio_cbi_wp; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - /* GPIOs shared by all boards */ - named-gpios { - compatible = "named-gpios"; - - ccd_mode_odl { - gpios = <&gpioc 6 GPIO_ODR_HIGH>; - }; - ec_gsc_packet_mode { - gpios = <&gpiob 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_mech_pwr_btn_odl: mech_pwr_btn_odl { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpio6 1 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S3_L"; - alias = "GPIO_PCH_SLP_S0_L"; - }; - gpio_slp_s5_l: slp_s5_l { - gpios = <&gpio7 2 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S5_L"; - }; - gpio_pg_pwr_s5: pg_pwr_s5 { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_S5_PGOOD"; - }; - gpio_s0_pgood: pg_pcore_s0_r_od { - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_S0_PGOOD"; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_en_pwr_s5: en_pwr_s5 { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PWR_A"; - }; - gpio_en_pwr_s0_r: en_pwr_s0_r { - gpios = <&gpiof 1 GPIO_OUTPUT_LOW>; - }; - gpio_en_pwr_pcore_s0_r: en_pwr_pcore_s0_r { - gpios = <&gpioe 1 GPIO_OUTPUT_LOW>; - }; - ec_sys_rst_l { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_SYS_RESET_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_RSMRST_L"; - }; - gpio_ec_pch_wake_odl: ec_soc_wake_l { - gpios = <&gpio0 3 GPIO_OUTPUT_HIGH>; - }; - prochot_odl { - gpios = <&gpiod 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_CPU_PROCHOT"; - }; - soc_alert_ec_l { - gpios = <&gpioe 2 GPIO_INPUT>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioc 7 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio7 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { - gpios = <&gpiod 4 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PPC_INT_ODL"; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpioa 4 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { - gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_USB_C1_BC12_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst_l: usb_c0_tcpc_rst_l { - gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_USB_C0_TCPC_RST_L"; - }; - gpio_usb_c1_tcpc_rst_l: usb_c1_tcpc_rst_l { - gpios = <&gpio3 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_USB_C1_TCPC_RST_L"; - }; - usb_c0_hpd { - gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_DP_HPD"; - }; - usb_c1_hpd { - gpios = <&gpiof 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_DP_HPD"; - }; - gpio_lid_open: lid_open { - gpios = <&gpio0 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - ec_batt_pres_odl { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_disable_disp_bl: ec_disable_disp_bl { - gpios = <&gpioa 6 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT_L"; - }; - gpio_usb_fault_odl: usb_fault_odl { - gpios = <&gpio5 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - gpio_en_pwr_s3: en_pwr_s3 { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_pg_groupc_s0_od: pg_groupc_s0_od { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_ec_i2c_usbc_pd_int: ec_i2c_usbc_pd_int { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_soc_thermtrip_odl: soc_thermtrip_odl { - gpios = <&gpio9 5 GPIO_INPUT>; - }; - gpio_hub_rst: hub_rst { - gpios = <&gpio6 6 GPIO_OUTPUT_HIGH>; - }; - ec_soc_int_l { - gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pwr_good: ec_soc_pwr_good { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - }; - gpio_pcore_ocp_r_l: pcore_ocp_r_l { - gpios = <&gpioa 5 GPIO_INPUT>; - }; - gpio_usb_hub_fault_q_odl: usb_hub_fault_q_odl { - gpios = <&gpioe 5 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_lpddr5_s3_od: pg_lpddr5_s3_od { - gpios = <&gpio7 3 GPIO_INPUT>; - }; - 3axis_int_l { - gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; - }; - gpio_ec_soc_pwr_btn_l: ec_soc_pwr_btn_l { - gpios = <&gpioa 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpio6 7 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - ec_sc_rst { - gpios = <&gpiob 0 GPIO_OUTPUT_LOW>; - }; - gpio_cbi_wp: ec_cbi_wp { - gpios = <&gpio8 1 GPIO_OUTPUT_LOW>; - }; - gpio_wp: ec_wp_l { - gpios = <&gpiod 7 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_pg_lpddr5_s0_od: pg_lpddr5_s0_od { - gpios = <&gpio6 0 GPIO_INPUT>; - }; - ec_espi_rst_l { - gpios = <&gpio5 4 GPIO_PULL_DOWN>; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - pch-sys-prwok { - enum-name = "GPIO_PCH_SYS_PWROK"; - }; - ec_i2c_usb_a0_c0_scl { - gpios = <&gpiob 5 GPIO_INPUT>; - }; - ec_i2c_usb_a0_c0_sda { - gpios = <&gpiob 4 GPIO_INPUT>; - }; - ec_i2c_usb_a1_c1_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_a1_c1_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_batt_scl { - gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_batt_sda { - gpios = <&gpio9 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_usbc_mux_scl { - gpios = <&gpiod 1 GPIO_INPUT>; - }; - ec_i2c_usbc_mux_sda { - gpios = <&gpiod 0 GPIO_INPUT>; - }; - ec_i2c_power_scl { - gpios = <&gpiof 3 GPIO_INPUT>; - }; - ec_i2c_power_sda { - gpios = <&gpiof 2 GPIO_INPUT>; - }; - ec_i2c_cbi_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_cbi_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - ec_i2c_sensor_scl { - gpios = <&gpioe 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_sensor_sda { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_soc_sic { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_soc_sid { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - en_kb_bl { - gpios = <&gpio9 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - tablet_mode_l { - gpios = <&gpioc 1 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ec_gpio56 { - gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>; - }; - ec_flprg2 { - gpios = <&gpio8 6 GPIO_INPUT_PULL_UP>; - }; - - usb_c0_tcpc_fastsw_ctl_en { - gpios = <&ioex_c0_port0 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN"; - }; - usb_c0_ppc_en_l { - gpios = <&ioex_c0_port1 0 GPIO_OUTPUT_LOW>; - }; - ioex_usb_c0_ilim_3a_en: usb_c0_ppc_ilim_3a_en { - gpios = <&ioex_c0_port1 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_PPC_ILIM_3A_EN"; - }; - ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl { - gpios = <&ioex_c0_port1 2 GPIO_INPUT>; - }; - ioex_en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&ioex_c0_port1 5 GPIO_OUTPUT_LOW>; - }; - ioex_usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&ioex_c0_port1 6 GPIO_INPUT>; - }; - ioex_usb_c0_sbu_flip: usb_c0_sbu_flip { - gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_SBU_FLIP"; - }; - - usb_a1_retimer_en { - gpios = <&ioex_c1_port0 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_A1_RETIMER_EN"; - }; - usb_a1_retimer_rst { - gpios = <&ioex_c1_port0 1 GPIO_OUTPUT_LOW>; - }; - usb_c1_in_hpd { - gpios = <&ioex_c1_port0 3 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_HPD_IN_DB"; - }; - usb_c1_tcpc_fastsw_ctl_en { - gpios = <&ioex_c1_port0 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN"; - }; - usb_c1_ppc_en_l { - gpios = <&ioex_c1_port1 0 GPIO_OUTPUT_LOW>; - }; - usb_c1_ppc_ilim_3a_en { - gpios = <&ioex_c1_port1 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_PPC_ILIM_3A_EN"; - }; - ioex_usb_c1_sbu_fault_odl: usb_c1_sbu_fault_odl { - gpios = <&ioex_c1_port1 2 GPIO_INPUT>; - enum-name = "IOEX_USB_C1_FAULT_ODL"; - }; - ioex_en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus { - gpios = <&ioex_c1_port1 5 GPIO_OUTPUT_LOW>; - }; - ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl { - gpios = <&ioex_c1_port1 6 GPIO_INPUT>; - }; - ioex_usb_c1_sbu_flip: usb_c1_sbu_flip { - gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_SBU_FLIP"; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&ioex_en_pp5000_usb_a0_vbus - &ioex_en_pp5000_usb_a1_vbus>; - }; -}; - -/* PSL input pads*/ -&psl_in1_gpd2 { - /* MECH_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in2_gp00 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* LID_OPEN */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>; -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/skyrim/i2c_common.dtsi b/zephyr/projects/skyrim/i2c_common.dtsi deleted file mode 100644 index 460a6bcfd2..0000000000 --- a/zephyr/projects/skyrim/i2c_common.dtsi +++ /dev/null @@ -1,294 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #include - -/ { - aliases { - i2c-0 = &i2c0_0; - i2c-1 = &i2c1_0; - i2c-2 = &i2c2_0; - i2c-3 = &i2c3_0; - i2c-4 = &i2c4_1; - i2c-5 = &i2c5_0; - i2c-7 = &i2c7_0; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_tcpc0: tcpc0 { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_TCPC0"; - }; - - i2c_tcpc1: tcpc1 { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_TCPC1"; - }; - - battery { - i2c-port = <&i2c2_0>; - remote-port = <0>; - enum-names = "I2C_PORT_BATTERY"; - }; - - usb-mux { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_MUX"; - }; - - i2c_charger: charger { - i2c-port = <&i2c4_1>; - enum-names = "I2C_PORT_CHARGER"; - }; - - eeprom { - i2c-port = <&i2c5_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - - i2c_sensor: sensor { - i2c-port = <&i2c6_1>; - enum-names = "I2C_PORT_SENSOR"; - }; - - i2c_soc_thermal: soc-thermal { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_THERMAL_AP"; - }; - }; - - -}; - -&i2c0_0 { - status = "okay"; - label = "I2C_TCPC0"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - tcpc_port0: nct38xx@70 { - compatible = "nuvoton,nct38xx"; - reg = <0x70>; - gpio-dev = <&nct3807_C0>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct3807_C0: nct3807_C0@70 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x70>; - label = "NCT3807_C0"; - - ioex_c0_port0: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3807_C0_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - pinmux_mask = <0xf7>; - }; - ioex_c0_port1: gpio@1 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x1>; - label = "NCT3807_C0_GPIO1"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - }; - }; - - nct3808_alert_0 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; - nct38xx-dev = <&nct3807_C0>; - label = "NCT3807_ALERT_0"; - }; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - status = "okay"; - label = "I2C_TCPC1"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c1_bc12>; - }; - - tcpc_port1: nct38xx@70 { - compatible = "nuvoton,nct38xx"; - reg = <0x70>; - gpio-dev = <&nct3807_C1>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct3807_C1: nct3807_C1@70 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x70>; - label = "NCT3807_C1"; - - ioex_c1_port0: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3807_C1_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - pinmux_mask = <0xf7>; - }; - ioex_c1_port1: gpio@1 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x1>; - label = "NCT3807_C1_GPIO1"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - }; - }; - - nct3808_alert_1 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpioc 7 GPIO_ACTIVE_LOW>; - nct38xx-dev = <&nct3807_C1>; - label = "NCT3807_ALERT_1"; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - status = "okay"; - label = "I2C_BATTERY"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - status = "okay"; - label = "I2C_USB_MUX"; - clock-frequency = ; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; - - amd_fp6_port0: amd_fp6@5c { - compatible = "amd,usbc-mux-amd-fp6"; - status = "okay"; - reg = <0x5c>; - }; - amd_fp6_port1: amd_fp6@52 { - compatible = "amd,usbc-mux-amd-fp6"; - status = "okay"; - reg = <0x52>; - }; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c4_1 { - status = "okay"; - label = "I2C_CHARGER"; - clock-frequency = ; - pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl4 { - status = "okay"; -}; - -&i2c5_0 { - status = "okay"; - label = "I2C_EEPROM"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c6_1 { - status = "okay"; - label = "I2C_SENSOR"; - clock-frequency = ; - pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; - pinctrl-names = "default"; - - soc_pct2075: soc-pct2075@48 { - compatible = "nxp,pct2075"; - reg = <0x48>; - }; - - amb_pct2075: amb-pct2075@4f { - compatible = "nxp,pct2075"; - reg = <0x4f>; - }; -}; - -&i2c_ctrl6 { - status = "okay"; -}; - -&i2c7_0 { - status = "okay"; - label = "I2C_THERMAL_AP"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; - - temp_cpu: cpu@4c { - compatible = "amd,sb-tsi"; - reg = <0x4c>; - }; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/skyrim/include/frostflow/keyboard_customization.h b/zephyr/projects/skyrim/include/frostflow/keyboard_customization.h deleted file mode 100644 index 2d2a997f91..0000000000 --- a/zephyr/projects/skyrim/include/frostflow/keyboard_customization.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Keyboard configuration */ - -#ifndef __KEYBOARD_CUSTOMIZATION_H -#define __KEYBOARD_CUSTOMIZATION_H - -/* - * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate - * exact spaces for arrays. Actual keyboard scanning is done using - * keyboard_cols, which holds a runtime column size. - */ -#ifdef CONFIG_KEYBOARD_CUSTOMIZATION -#undef KEYBOARD_COLS_MAX -#undef KEYBOARD_ROWS - -#define KEYBOARD_COLS_MAX 15 -#define KEYBOARD_ROWS 8 -#endif - -/* - * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols, - * instead. It checks whether you're eligible or not. - */ -extern uint8_t keyboard_cols; - -#define KEYBOARD_ROW_TO_MASK(r) (1 << (r)) - -/* Columns and masks for keys we particularly care about */ -#define KEYBOARD_COL_DOWN 11 -#define KEYBOARD_ROW_DOWN 5 -#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN) -#define KEYBOARD_COL_ESC 1 -#define KEYBOARD_ROW_ESC 1 -#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC) -#define KEYBOARD_COL_KEY_H 6 -#define KEYBOARD_ROW_KEY_H 1 -#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H) -#define KEYBOARD_COL_KEY_R 3 -#define KEYBOARD_ROW_KEY_R 7 -#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R) -#define KEYBOARD_COL_LEFT_ALT 10 -#define KEYBOARD_ROW_LEFT_ALT 6 -#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT) -#define KEYBOARD_COL_REFRESH 2 -#define KEYBOARD_ROW_REFRESH 3 -#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH) -#define KEYBOARD_COL_RIGHT_ALT 10 -#define KEYBOARD_ROW_RIGHT_ALT 0 -#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT) -#define KEYBOARD_DEFAULT_COL_VOL_UP 4 -#define KEYBOARD_DEFAULT_ROW_VOL_UP 1 -#define KEYBOARD_COL_LEFT_CTRL 0 -#define KEYBOARD_ROW_LEFT_CTRL 2 -#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL) -#define KEYBOARD_COL_RIGHT_CTRL 0 -#define KEYBOARD_ROW_RIGHT_CTRL 4 -#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL) -#define KEYBOARD_COL_SEARCH 0 -#define KEYBOARD_ROW_SEARCH 3 -#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH) -#define KEYBOARD_COL_KEY_0 9 -#define KEYBOARD_ROW_KEY_0 0 -#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) -#define KEYBOARD_COL_KEY_1 1 -#define KEYBOARD_ROW_KEY_1 7 -#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1) -#define KEYBOARD_COL_KEY_2 4 -#define KEYBOARD_ROW_KEY_2 6 -#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) -#define KEYBOARD_COL_LEFT_SHIFT 7 -#define KEYBOARD_ROW_LEFT_SHIFT 1 -#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT) - -#endif /* __KEYBOARD_CUSTOMIZATION_H */ diff --git a/zephyr/projects/skyrim/interrupts.dts b/zephyr/projects/skyrim/interrupts.dts deleted file mode 100644 index de4e87986a..0000000000 --- a/zephyr/projects/skyrim/interrupts.dts +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&gpio_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_mech_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_slp_s3: slp_s3 { - irq-pin = <&gpio_slp_s3_l>; - flags = ; - handler = "baseboard_en_pwr_s0"; - }; - int_slp_s5: slp_s5 { - irq-pin = <&gpio_slp_s5_l>; - flags = ; - handler = "baseboard_set_en_pwr_s3"; - }; - int_s5_pgood: s5_pgood { - irq-pin = <&gpio_pg_pwr_s5>; - flags = ; - handler = "baseboard_s5_pgood"; - }; - int_pg_groupc_s0: pg_groupc_s0 { - irq-pin = <&gpio_pg_groupc_s0_od>; - flags = ; - handler = "baseboard_set_en_pwr_pcore"; - }; - int_pg_lpddr_s3: pg_lpddr_s3 { - irq-pin = <&gpio_pg_lpddr5_s3_od>; - flags = ; - handler = "baseboard_set_en_pwr_pcore"; - }; - int_pg_lpddr_s0: pg_lpddr_s0 { - irq-pin = <&gpio_pg_lpddr5_s0_od>; - flags = ; - handler = "baseboard_set_soc_pwr_pgood"; - }; - int_s0_pgood: s0_pgood { - irq-pin = <&gpio_s0_pgood>; - flags = ; - handler = "baseboard_s0_pgood"; - }; - int_soc_thermtrip: soc_thermtrip { - irq-pin = <&gpio_soc_thermtrip_odl>; - flags = ; - handler = "baseboard_soc_thermtrip"; - }; - int_soc_pcore_ocp: soc_pcore_ocp { - irq-pin = <&gpio_pcore_ocp_r_l>; - flags = ; - handler = "baseboard_soc_pcore_ocp"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_usb_a0_fault: a0_fault { - irq-pin = <&ioex_usb_a0_fault_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_a1_fault: a1_fault { - irq-pin = <&ioex_usb_a1_fault_db_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_c0_sbu_fault: c0_sbu_fault { - irq-pin = <&ioex_usb_c0_sbu_fault_odl>; - flags = ; - handler = "sbu_fault_interrupt"; - }; - int_usb_c1_sbu_fault: c1_sbu_fault { - irq-pin = <&ioex_usb_c1_sbu_fault_odl>; - flags = ; - handler = "sbu_fault_interrupt"; - }; - int_usb_c0_tcpc: usb_c0_tcpc { - irq-pin = <&gpio_usb_c0_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_tcpc: usb_c1_tcpc { - irq-pin = <&gpio_usb_c1_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&gpio_usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_ppc: usb_c1_ppc { - irq-pin = <&gpio_usb_c1_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c1_bc12: usb_c1_bc12 { - irq-pin = <&gpio_usb_c1_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_hub_fault: hub_fault { - irq-pin = <&gpio_usb_hub_fault_q_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_pd_soc: usb_pd_soc { - irq-pin = <&gpio_ec_i2c_usbc_pd_int>; - flags = ; - handler = "usb_pd_soc_interrupt"; - }; - int_accel_gyro: accel_gyro { - irq-pin = <&gpio_accel_gyro_int_l>; - flags = ; - handler = "bmi3xx_interrupt"; - }; - }; -}; diff --git a/zephyr/projects/skyrim/keyboard.dts b/zephyr/projects/skyrim/keyboard.dts deleted file mode 100644 index df334ba54c..0000000000 --- a/zephyr/projects/skyrim/keyboard.dts +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/skyrim/led_pins_frostflow.dts b/zephyr/projects/skyrim/led_pins_frostflow.dts deleted file mode 100644 index d294490208..0000000000 --- a/zephyr/projects/skyrim/led_pins_frostflow.dts +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - - pwm_y: pwm_y { - #led-pin-cells = <1>; - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - - pwm_w: pwm_w { - #led-pin-cells = <1>; - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/skyrim/led_pins_morthal.dts b/zephyr/projects/skyrim/led_pins_morthal.dts deleted file mode 100644 index d294490208..0000000000 --- a/zephyr/projects/skyrim/led_pins_morthal.dts +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - - pwm_y: pwm_y { - #led-pin-cells = <1>; - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - - pwm_w: pwm_w { - #led-pin-cells = <1>; - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/skyrim/led_pins_skyrim.dts b/zephyr/projects/skyrim/led_pins_skyrim.dts deleted file mode 100644 index d294490208..0000000000 --- a/zephyr/projects/skyrim/led_pins_skyrim.dts +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - - pwm_y: pwm_y { - #led-pin-cells = <1>; - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - - pwm_w: pwm_w { - #led-pin-cells = <1>; - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/skyrim/led_pins_winterhold.dts b/zephyr/projects/skyrim/led_pins_winterhold.dts deleted file mode 100644 index d294490208..0000000000 --- a/zephyr/projects/skyrim/led_pins_winterhold.dts +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - - pwm_y: pwm_y { - #led-pin-cells = <1>; - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - - pwm_w: pwm_w { - #led-pin-cells = <1>; - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/skyrim/led_policy_frostflow.dts b/zephyr/projects/skyrim/led_policy_frostflow.dts deleted file mode 100644 index e5875640fb..0000000000 --- a/zephyr/projects/skyrim/led_policy_frostflow.dts +++ /dev/null @@ -1,122 +0,0 @@ -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = <0 94>; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-charge-lvl-2 { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Near Full) */ - batt-lvl = <95 97>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= 11%, <= Full) */ - batt-lvl = <11 100>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= 10%) */ - batt-lvl = <0 10>; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error-s0 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S0"; - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-error-s3 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S3"; - /* White 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-error-s5 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - }; -}; diff --git a/zephyr/projects/skyrim/led_policy_morthal.dts b/zephyr/projects/skyrim/led_policy_morthal.dts deleted file mode 100644 index a075c6b0d2..0000000000 --- a/zephyr/projects/skyrim/led_policy_morthal.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* White 2 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/projects/skyrim/led_policy_skyrim.dts b/zephyr/projects/skyrim/led_policy_skyrim.dts deleted file mode 100644 index a075c6b0d2..0000000000 --- a/zephyr/projects/skyrim/led_policy_skyrim.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* White 2 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/projects/skyrim/led_policy_winterhold.dts b/zephyr/projects/skyrim/led_policy_winterhold.dts deleted file mode 100644 index f1f8aa31ed..0000000000 --- a/zephyr/projects/skyrim/led_policy_winterhold.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s3-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/projects/skyrim/morthal.dts b/zephyr/projects/skyrim/morthal.dts deleted file mode 100644 index 508ce23bce..0000000000 --- a/zephyr/projects/skyrim/morthal.dts +++ /dev/null @@ -1,183 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Morthal-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <0>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - morthal-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - form-factor { - enum-name = "FW_FORM_FACTOR"; - start = <0>; - size = <1>; - - ff-clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CLAMSHELL"; - value = <0>; - }; - ff-convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CONVERTIBLE"; - value = <1>; - default; - }; - }; - io-db { - enum-name = "FW_IO_DB"; - start = <6>; - size = <2>; - - io-db-ps8811-ps8818 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_PS8811_PS8818"; - value = <0>; - }; - io-db-none-anx7483 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_NONE_ANX7483"; - value = <1>; - default; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <10>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - lid_rot_ref1: lid-rotation-ref1 { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; diff --git a/zephyr/projects/skyrim/motionsense.dts b/zephyr/projects/skyrim/motionsense.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/projects/skyrim/motionsense.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/skyrim/prj.conf b/zephyr/projects/skyrim/prj.conf deleted file mode 100644 index a0085258e4..0000000000 --- a/zephyr/projects/skyrim/prj.conf +++ /dev/null @@ -1,167 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_ESPI=y - -# Shell features -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y -CONFIG_KERNEL_SHELL=y - -# Power sequencing -CONFIG_AP=y -CONFIG_AP_X86_AMD=y -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM=y -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y -CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y -CONFIG_PLATFORM_EC_PORT80=y - -# Power button -CONFIG_PLATFORM_EC_POWER_BUTTON=y - -# ADC -CONFIG_ADC=y - -# I2C -CONFIG_I2C=y - -# CBI -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y -CONFIG_PLATFORM_EC_CBI_EEPROM=y - -# Temperature Sensors -CONFIG_PLATFORM_EC_AMD_SB_RMI=y -CONFIG_PLATFORM_EC_AMD_STT=y -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR_SB_TSI=y -CONFIG_PLATFORM_EC_THERMISTOR=y -CONFIG_PLATFORM_EC_THROTTLE_AP=y - -# External power -CONFIG_PLATFORM_EC_HOSTCMD=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y - -# Sensors -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n - -# Fan -CONFIG_TACH_NPCX=y - -# Lid switch -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_LID_SWITCH=y - -# Keyboard -CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -CONFIG_SYSCON=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512 -CONFIG_PLATFORM_EC_CHARGER_ISL9241=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 - -# USB-A -CONFIG_PLATFORM_EC_USBA=y - -# USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y -CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y -CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811=y -CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818=y -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_MUX_AMD_FP6=y -CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_PID=0x505F -CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_USB_PD_REV30=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y -# Give ourselves enough task space to use i2ctrace -CONFIG_TASK_PD_STACK_SIZE=1280 - -# IOEX -CONFIG_GPIO_NCT38XX=y - -# Motion sense -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y - -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y - -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -# Misc. -CONFIG_PLATFORM_EC_I2C_DEBUG=y -CONFIG_PLATFORM_EC_PORT80_4_BYTE=y - -# These are debug options that happen to be expensive in terms of flash space. -# Turn on as needed based on demand. -CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes -CONFIG_FLASH_SHELL=n # 1852 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes -# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes -CONFIG_THREAD_MONITOR=n # 1548 bytes diff --git a/zephyr/projects/skyrim/prj_frostflow.conf b/zephyr/projects/skyrim/prj_frostflow.conf deleted file mode 100644 index 29931de4d4..0000000000 --- a/zephyr/projects/skyrim/prj_frostflow.conf +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Frostflow reference-board-specific Kconfig settings. -CONFIG_BOARD_FROSTFLOW=y -CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR=90 - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Frostflow is capable of sinking 45W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000 -# Only Frostflow has the PCT2075 -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y - -# Frostflow not have the USB HUB -CONFIG_BOARD_USB_HUB_RESET=n diff --git a/zephyr/projects/skyrim/prj_morthal.conf b/zephyr/projects/skyrim/prj_morthal.conf deleted file mode 100644 index 3d2b3fddb7..0000000000 --- a/zephyr/projects/skyrim/prj_morthal.conf +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Morthal reference-board-specific Kconfig settings. -CONFIG_BOARD_MORTHAL=y - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Morthal is capable of sinking 100W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 - -# Only Morthal has the PCT2075 -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y diff --git a/zephyr/projects/skyrim/prj_skyrim.conf b/zephyr/projects/skyrim/prj_skyrim.conf deleted file mode 100644 index 2752854c8b..0000000000 --- a/zephyr/projects/skyrim/prj_skyrim.conf +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Skyrim reference-board-specific Kconfig settings. -CONFIG_BOARD_SKYRIM=y - -# CBI WP pin present -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Skyrim is capable of sinking 100W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 - -# Only Skyrim has the PCT2075 -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Enable alternative charger chip -CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y diff --git a/zephyr/projects/skyrim/prj_winterhold.conf b/zephyr/projects/skyrim/prj_winterhold.conf deleted file mode 100644 index 2ccd195a72..0000000000 --- a/zephyr/projects/skyrim/prj_winterhold.conf +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Winterhold reference-board-specific Kconfig settings. -CONFIG_BOARD_WINTERHOLD=y - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Only Winterhold has the PCT2075 -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Enable charger chip -CONFIG_PLATFORM_EC_CHARGER_ISL9238=y -CONFIG_PLATFORM_EC_CHARGER_ISL9241=n - -# Get the vbus voltage from TCPC -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y \ No newline at end of file diff --git a/zephyr/projects/skyrim/skyrim.dts b/zephyr/projects/skyrim/skyrim.dts deleted file mode 100644 index 6a812a55f3..0000000000 --- a/zephyr/projects/skyrim/skyrim.dts +++ /dev/null @@ -1,207 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Skyrim-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <35>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - skyrim-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - form-factor { - enum-name = "FW_FORM_FACTOR"; - start = <0>; - size = <1>; - - ff-clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CLAMSHELL"; - value = <0>; - }; - ff-convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CONVERTIBLE"; - value = <1>; - default; - }; - }; - io-db { - enum-name = "FW_IO_DB"; - start = <6>; - size = <2>; - - io-db-ps8811-ps8818 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_PS8811_PS8818"; - value = <0>; - }; - io-db-none-anx7483 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_NONE_ANX7483"; - value = <1>; - default; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <10>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - - charger-option { - enum-name = "FW_CHARGER"; - start = <11>; - size = <2>; - - charger-option-isl9241 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9241"; - value = <0>; - default; - }; - charger-option-isl9538 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9538"; - value = <1>; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - lid_rot_ref1: lid-rotation-ref1 { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; - alt_charger: isl9538@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - chg_alt = <&alt_charger>; - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; diff --git a/zephyr/projects/skyrim/src/common.c b/zephyr/projects/skyrim/src/common.c deleted file mode 100644 index af82139c1b..0000000000 --- a/zephyr/projects/skyrim/src/common.c +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -LOG_MODULE_REGISTER(skyrim, CONFIG_SKYRIM_LOG_LEVEL); diff --git a/zephyr/projects/skyrim/src/frostflow/keyboard.c b/zephyr/projects/skyrim/src/frostflow/keyboard.c deleted file mode 100644 index 2905f17941..0000000000 --- a/zephyr/projects/skyrim/src/frostflow/keyboard.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" -#include "keyboard_scan.h" -#include "timer.h" - -/* Keyboard scan setting */ -__override struct keyboard_scan_config keyscan_config = { - /* Increase from 50 us, because KSO_02 passes through the H1. */ - .output_settle_us = 80, - /* Other values should be the same as the default configuration. */ - .debounce_down_us = 9 * MSEC, - .debounce_up_us = 30 * MSEC, - .scan_period_us = 3 * MSEC, - .min_post_scan_delay_us = 1000, - .poll_timeout_us = 100 * MSEC, - .actual_key_mask = { - 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x86, 0xff, 0xff, 0x55, 0xff, 0xff, 0xff, 0xff, /* full set */ - }, -}; - -static const struct ec_response_keybd_config frostflow_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &frostflow_kb; -} - -/* - * Row Column info for Top row keys T1 - T15. - * on frostflow_kb keyboard Row Column is customization - * need define row col to mapping matrix layout. - */ -__override const struct key { - uint8_t row; - uint8_t col; -} vivaldi_keys[] = { - { .row = 4, .col = 2 }, /* T1 */ - { .row = 3, .col = 2 }, /* T2 */ - { .row = 2, .col = 2 }, /* T3 */ - { .row = 1, .col = 2 }, /* T4 */ - { .row = 4, .col = 4 }, /* T5 */ - { .row = 3, .col = 4 }, /* T6 */ - { .row = 2, .col = 4 }, /* T7 */ - { .row = 2, .col = 9 }, /* T8 */ - { .row = 1, .col = 9 }, /* T9 */ - { .row = 1, .col = 4 }, /* T10 */ - { .row = 0, .col = 4 }, /* T11 */ - { .row = 1, .col = 5 }, /* T12 */ - { .row = 3, .col = 5 }, /* T13 */ - { .row = 2, .col = 1 }, /* T14 */ - { .row = 0, .col = 1 }, /* T15 */ -}; -BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS); diff --git a/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c b/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c deleted file mode 100644 index d176323d80..0000000000 --- a/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "common.h" -#include "gpio.h" -#include "keyboard_customization.h" -#include "keyboard_protocol.h" -#include "keyboard_raw.h" - -static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { - { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 }, - { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 }, - { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a }, - { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d }, - { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d }, - { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 }, - { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c }, - { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 }, - { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d }, - { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a }, - { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 }, - { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 }, - { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d }, - { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 }, - { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 }, -}; - -uint16_t get_scancode_set2(uint8_t row, uint8_t col) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - return scancode_set2[col][row]; - return 0; -} - -void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - scancode_set2[col][row] = val; -} - -#ifdef CONFIG_KEYBOARD_DEBUG -static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { - { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO }, - { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' }, - { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3, - KLLI_UNKNO }, - { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC }, - { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' }, - { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' }, - { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' }, - { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' }, - { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO, - KLLI_LEFT, KLLI_UNKNO }, - { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' }, - { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' }, - { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO }, -}; - -char get_keycap_label(uint8_t row, uint8_t col) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - return keycap_label[col][row]; - return KLLI_UNKNO; -} - -void set_keycap_label(uint8_t row, uint8_t col, char val) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - keycap_label[col][row] = val; -} -#endif diff --git a/zephyr/projects/skyrim/src/frostflow/ppc_config.c b/zephyr/projects/skyrim/src/frostflow/ppc_config.c deleted file mode 100644 index 6072a788eb..0000000000 --- a/zephyr/projects/skyrim/src/frostflow/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Frostflow board-specific PPC code */ - -#include - -#include "driver/ppc/nx20p348x.h" -#include "driver/ppc/aoz1380_public.h" -#include "usbc_ppc.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c b/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c deleted file mode 100644 index e641e0d649..0000000000 --- a/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Frostflow board-specific USB-C mux configuration */ - -#include - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} diff --git a/zephyr/projects/skyrim/src/morthal/ppc_config.c b/zephyr/projects/skyrim/src/morthal/ppc_config.c deleted file mode 100644 index f3ec1d312e..0000000000 --- a/zephyr/projects/skyrim/src/morthal/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Morthal board-specific PPC code */ - -#include - -#include "driver/ppc/nx20p348x.h" -#include "driver/ppc/aoz1380_public.h" -#include "usbc_ppc.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/projects/skyrim/src/morthal/usb_mux_config.c b/zephyr/projects/skyrim/src/morthal/usb_mux_config.c deleted file mode 100644 index 8fe76233e2..0000000000 --- a/zephyr/projects/skyrim/src/morthal/usb_mux_config.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Morthal board-specific USB-C mux configuration */ - -#include - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} - -static void setup_mux(void) -{ - uint32_t val; - - if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) - CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); - /* Val will have our dts default on error, so continue setup */ - - if (val == FW_IO_DB_PS8811_PS8818) { - CPRINTSUSB("C1: Setting PS8818 mux"); - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); - } else if (val == FW_IO_DB_NONE_ANX7483) { - CPRINTSUSB("C1: Setting ANX7483 mux"); - } else { - CPRINTSUSB("Unexpected DB_IO board: %d", val); - } -} -DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/projects/skyrim/src/power_signals.c b/zephyr/projects/skyrim/src/power_signals.c deleted file mode 100644 index 5d372d35ae..0000000000 --- a/zephyr/projects/skyrim/src/power_signals.c +++ /dev/null @@ -1,245 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ap_power/ap_power.h" -#include "charger.h" -#include "chipset.h" -#include "config.h" -#include "gpio_signal.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "i2c.h" -#include "ioexpander.h" -#include "power.h" -#include "power/amd_x86.h" -#include "timer.h" - -/* Power Signal Input List */ -/* TODO: b/218904113: Convert to using Zephyr GPIOs */ -const struct power_signal_info power_signal_list[] = { - [X86_SLP_S3_N] = { - .gpio = GPIO_PCH_SLP_S3_L, - .flags = POWER_SIGNAL_ACTIVE_HIGH, - .name = "SLP_S3_DEASSERTED", - }, - [X86_SLP_S5_N] = { - .gpio = GPIO_PCH_SLP_S5_L, - .flags = POWER_SIGNAL_ACTIVE_HIGH, - .name = "SLP_S5_DEASSERTED", - }, - [X86_S0_PGOOD] = { - .gpio = GPIO_S0_PGOOD, - .flags = POWER_SIGNAL_ACTIVE_HIGH, - .name = "S0_PGOOD", - }, - [X86_S5_PGOOD] = { - .gpio = GPIO_S5_PGOOD, - .flags = POWER_SIGNAL_ACTIVE_HIGH, - .name = "S5_PGOOD", - }, -}; -BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); - -/* Chipset hooks */ -static void baseboard_suspend_change(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - switch (data.event) { - default: - return; - - case AP_POWER_SUSPEND: - /* Disable display backlight and retimer */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl), - 1); - ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0); - break; - - case AP_POWER_RESUME: - /* Enable retimer and display backlight */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl), - 0); - ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1); - /* Any retimer tuning can be done after the retimer turns on */ - break; - } -} - -static void baseboard_init(void) -{ - static struct ap_power_ev_callback cb; - - /* Setup a suspend/resume callback */ - ap_power_ev_init_callback(&cb, baseboard_suspend_change, - AP_POWER_RESUME | AP_POWER_SUSPEND); - ap_power_ev_add_callback(&cb); - /* Enable Power Group interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_groupc_s0)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_lpddr_s0)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_lpddr_s3)); - - /* Enable thermtrip interrupt */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_soc_thermtrip)); -} -DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_POST_I2C); - -/** - * b/227296844: On G3->S5, wait for RSMRST_L to be deasserted before asserting - * PCH_PWRBTN_L. This can be as long as ~65ms after cold boot. Then wait an - * additional delay of T1a defined in the EDS before changing the power button. - */ -#define RSMRST_WAIT_DELAY 70 -#define EDS_PWR_BTN_RSMRST_T1A_DELAY 16 -void board_pwrbtn_to_pch(int level) -{ - timestamp_t start; - - /* Add delay for G3 exit if asserting PWRBTN_L and RSMRST_L is low. */ - if (!level && - !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_rsmrst_l))) { - start = get_time(); - do { - usleep(500); - if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( - gpio_ec_soc_rsmrst_l))) - break; - } while (time_since32(start) < (RSMRST_WAIT_DELAY * MSEC)); - - if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_ec_soc_rsmrst_l))) - ccprints("Error pwrbtn: RSMRST_L still low"); - - msleep(EDS_PWR_BTN_RSMRST_T1A_DELAY); - } - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_pwr_btn_l), level); -} - -/* Note: signal parameter unused */ -void baseboard_set_soc_pwr_pgood(enum gpio_signal unused) -{ - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_ec_soc_pwr_good), - gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_pwr_pcore_s0_r)) && - gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_pg_lpddr5_s0_od)) && - gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood))); -} - -/* TODO(b/248284045): Remove when boards switch to new chip */ -#define MP2845A_I2C_ADDR_FLAGS 0x20 -#define MP2854A_MFR_VOUT_CMPS_MAX_REG 0x69 -#define MP2854A_MFR_LOW_PWR_SEL BIT(12) - -__overridable bool board_supports_pcore_ocp(void) -{ - return true; -} - -static void setup_mp2845(void) -{ - if (i2c_update16(chg_chips[CHARGER_SOLO].i2c_port, - MP2845A_I2C_ADDR_FLAGS, MP2854A_MFR_VOUT_CMPS_MAX_REG, - MP2854A_MFR_LOW_PWR_SEL, MASK_CLR)) - ccprints("Failed to send mp2845 workaround"); - - if (board_supports_pcore_ocp()) - gpio_enable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_soc_pcore_ocp)); -} -DECLARE_DEFERRED(setup_mp2845); - -void baseboard_s0_pgood(enum gpio_signal signal) -{ - baseboard_set_soc_pwr_pgood(signal); - - /* Chain off power signal interrupt handler for PG_PCORE_S0_R_OD */ - power_signal_interrupt(signal); - - /* Set up the MP2845, which is powered in S0 */ - if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood))) - hook_call_deferred(&setup_mp2845_data, 50 * MSEC); - else - gpio_disable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_soc_pcore_ocp)); -} - -/* Note: signal parameter unused */ -void baseboard_set_en_pwr_pcore(enum gpio_signal unused) -{ - /* - * EC must AND signals PG_LPDDR5_S3_OD, PG_GROUPC_S0_OD, and - * EN_PWR_S0_R - */ - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_pwr_pcore_s0_r), - gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_lpddr5_s3_od)) && - gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_pg_groupc_s0_od)) && - gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s0_r))); - - /* Update EC_SOC_PWR_GOOD based on our results */ - baseboard_set_soc_pwr_pgood(unused); -} - -void baseboard_en_pwr_s0(enum gpio_signal signal) -{ - /* EC must AND signals SLP_S3_L and PG_PWR_S5 */ - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s0_r), - gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) && - gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5))); - - /* Change EN_PWR_PCORE_S0_R if needed*/ - baseboard_set_en_pwr_pcore(signal); - - /* Now chain off to the normal power signal interrupt handler. */ - power_signal_interrupt(signal); -} -#ifdef CONFIG_BOARD_USB_HUB_RESET -void baseboard_enable_hub(void) -{ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hub_rst), 0); -} -DECLARE_DEFERRED(baseboard_enable_hub); -#endif /* CONFIG_BOARD_USB_HUB_RESET */ - -void baseboard_s5_pgood(enum gpio_signal signal) -{ -#ifdef CONFIG_BOARD_USB_HUB_RESET - /* We must enable the USB hub at least 30ms after S5 PGOOD */ - if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5))) - hook_call_deferred(&baseboard_enable_hub_data, 30 * MSEC); - else - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hub_rst), 1); -#endif /* CONFIG_BOARD_USB_HUB_RESET */ - - /* Continue to our signal AND-ing and power interrupt */ - baseboard_en_pwr_s0(signal); -} - -void baseboard_set_en_pwr_s3(enum gpio_signal signal) -{ - /* EC must enable PWR_S3 when SLP_S5_L goes high, disable on low */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s3), - gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s5_l))); - - /* Chain off the normal power signal interrupt handler */ - power_signal_interrupt(signal); -} - -void baseboard_soc_thermtrip(enum gpio_signal signal) -{ - ccprints("SoC thermtrip reported, shutting down"); - chipset_force_shutdown(CHIPSET_SHUTDOWN_THERMAL); -} - -void baseboard_soc_pcore_ocp(enum gpio_signal signal) -{ - ccprints("SoC Pcore OCP reported, shutting down"); - chipset_force_shutdown(CHIPSET_SHUTDOWN_BOARD_CUSTOM); -} diff --git a/zephyr/projects/skyrim/src/skyrim/alt_charger.c b/zephyr/projects/skyrim/src/skyrim/alt_charger.c deleted file mode 100644 index 4b717901cd..0000000000 --- a/zephyr/projects/skyrim/src/skyrim/alt_charger.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "charger_chips.h" -#include "common.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "hooks.h" - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -static void alt_charger_init(void) -{ - int ret; - uint32_t val; - - ret = cros_cbi_get_fw_config(FW_CHARGER, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); - return; - } - - if (val == FW_CHARGER_ISL9538) - CHG_ENABLE_ALTERNATE(0); -} -DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/skyrim/src/skyrim/fan.c b/zephyr/projects/skyrim/src/skyrim/fan.c deleted file mode 100644 index 0a368ee6f0..0000000000 --- a/zephyr/projects/skyrim/src/skyrim/fan.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Skyrim fan support - */ -static void fan_init(void) -{ - int ret; - uint32_t val; - uint32_t board_version; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - - ret = cbi_get_board_version(&board_version); - if (ret != EC_SUCCESS) { - LOG_ERR("Error retrieving CBI board version"); - return; - } - - if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { - /* Disable the fan */ - fan_set_count(0); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); - -/* - * Pcore OCP support - * Note: early boards should note enable this interrupt as they are not - * correctly configured for it. - */ -__override bool board_supports_pcore_ocp(void) -{ - uint32_t board_version; - - if (cbi_get_board_version(&board_version) == EC_SUCCESS && - board_version > 3) - return true; - - return false; -} diff --git a/zephyr/projects/skyrim/src/skyrim/form_factor.c b/zephyr/projects/skyrim/src/skyrim/form_factor.c deleted file mode 100644 index f137c6db31..0000000000 --- a/zephyr/projects/skyrim/src/skyrim/form_factor.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include "common.h" -#include "accelgyro.h" -#include "cros_board_info.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Mainboard orientation support. - */ - -#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) -#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) - -static void form_factor_init(void) -{ - int ret; - uint32_t val; - /* - * If the board version >=4 - * use ver1 rotation matrix. - */ - ret = cbi_get_board_version(&val); - if (ret == EC_SUCCESS && val >= 4) { - LOG_INF("Switching to ver1 lid"); - motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; - } -} -DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/projects/skyrim/src/skyrim/keyboard.c b/zephyr/projects/skyrim/src/skyrim/keyboard.c deleted file mode 100644 index e261321e86..0000000000 --- a/zephyr/projects/skyrim/src/skyrim/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config skyrim_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &skyrim_kb; -} diff --git a/zephyr/projects/skyrim/src/skyrim/ppc_config.c b/zephyr/projects/skyrim/src/skyrim/ppc_config.c deleted file mode 100644 index bebc8adcc7..0000000000 --- a/zephyr/projects/skyrim/src/skyrim/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Skyrim board-specific PPC code */ - -#include - -#include "driver/ppc/nx20p348x.h" -#include "driver/ppc/aoz1380_public.h" -#include "usbc_ppc.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/projects/skyrim/src/skyrim/usb_mux_config.c b/zephyr/projects/skyrim/src/skyrim/usb_mux_config.c deleted file mode 100644 index 6c65e56d9e..0000000000 --- a/zephyr/projects/skyrim/src/skyrim/usb_mux_config.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Skyrim board-specific USB-C mux configuration */ - -#include - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} - -static void setup_mux(void) -{ - uint32_t val; - - if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) - CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); - /* Val will have our dts default on error, so continue setup */ - - if (val == FW_IO_DB_PS8811_PS8818) { - CPRINTSUSB("C1: Setting PS8818 mux"); - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); - } else if (val == FW_IO_DB_NONE_ANX7483) { - CPRINTSUSB("C1: Setting ANX7483 mux"); - } else { - CPRINTSUSB("Unexpected DB_IO board: %d", val); - } -} -DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/projects/skyrim/src/stt.c b/zephyr/projects/skyrim/src/stt.c deleted file mode 100644 index 40743fbc68..0000000000 --- a/zephyr/projects/skyrim/src/stt.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Support code for STT temperature reporting */ - -#include "chipset.h" -#include "temp_sensor/pct2075.h" -#include "temp_sensor/temp_sensor.h" - -int board_get_soc_temp_mk(int *temp_mk) -{ - if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) - return EC_ERROR_NOT_POWERED; - - return pct2075_get_val_mk(PCT2075_SENSOR_ID(DT_NODELABEL(soc_pct2075)), - temp_mk); -} - -int board_get_ambient_temp_mk(int *temp_mk) -{ - if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) - return EC_ERROR_NOT_POWERED; - - return pct2075_get_val_mk(PCT2075_SENSOR_ID(DT_NODELABEL(amb_pct2075)), - temp_mk); -} diff --git a/zephyr/projects/skyrim/src/usb_pd_policy.c b/zephyr/projects/skyrim/src/usb_pd_policy.c deleted file mode 100644 index ec9f873863..0000000000 --- a/zephyr/projects/skyrim/src/usb_pd_policy.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Shared USB-C policy for Zork boards */ - -#include - -#include "charge_manager.h" -#include "chipset.h" -#include "common.h" -#include "compile_time_macros.h" -#include "console.h" -#include "ec_commands.h" -#include "ioexpander.h" -#include "system.h" -#include "usb_mux.h" -#include "usb_pd.h" -#include "usbc_ppc.h" -#include "util.h" - -int pd_check_vconn_swap(int port) -{ - /* - * Do not allow vconn swap 5V rail is off - * S5_PGOOD depends on PG_PP5000_S5 being asserted, - * so GPIO_S5_PGOOD is a reasonable proxy for PP5000_S5 - */ - return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5)); -} - -void pd_power_supply_reset(int port) -{ - /* Disable VBUS. */ - ppc_vbus_source_enable(port, 0); - - /* Enable discharge if we were previously sourcing 5V */ - if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) - pd_set_vbus_discharge(port, 1); - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - /* Disable charging. */ - rv = ppc_vbus_sink_enable(port, 0); - if (rv) - return rv; - - if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) - pd_set_vbus_discharge(port, 0); - - /* Provide Vbus. */ - rv = ppc_vbus_source_enable(port, 1); - if (rv) - return rv; - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -__override int board_pd_set_frs_enable(int port, int enable) -{ - /* - * Both PPCs require the FRS GPIO to be set as soon as FRS capability - * is established. - */ - if (port == 0) - ioex_set_level(IOEX_USB_C0_TCPC_FASTSW_CTL_EN, enable); - else - ioex_set_level(IOEX_USB_C1_TCPC_FASTSW_CTL_EN, enable); - - return EC_SUCCESS; -} - -/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */ -int board_vbus_source_enabled(int port) -{ - return tcpm_get_src_ctrl(port); -} - -/* Used by USB charger task with CONFIG_USB_PD_5V_EN_CUSTOM */ -int board_is_sourcing_vbus(int port) -{ - return board_vbus_source_enabled(port); -} diff --git a/zephyr/projects/skyrim/src/usbc_config.c b/zephyr/projects/skyrim/src/usbc_config.c deleted file mode 100644 index dec9f928b5..0000000000 --- a/zephyr/projects/skyrim/src/usbc_config.c +++ /dev/null @@ -1,403 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Skyrim family-specific USB-C configuration */ - -#include - -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "battery_fuel_gauge.h" -#include "charge_manager.h" -#include "charge_ramp.h" -#include "charge_state_v2.h" -#include "charge_state.h" -#include "charger.h" -#include "driver/bc12/pi3usb9201.h" -#include "driver/charger/isl9241.h" -#include "driver/ppc/nx20p348x.h" -#include "driver/retimer/anx7483_public.h" -#include "driver/retimer/ps8811.h" -#include "driver/retimer/ps8818_public.h" -#include "driver/tcpm/nct38xx.h" -#include "driver/usb_mux/amd_fp6.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "ioexpander.h" -#include "power.h" -#include "usb_mux.h" -#include "usb_pd_tcpm.h" -#include "usbc_ppc.h" -#include "usbc/usb_muxes.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* USB-A ports */ -enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_A1, USBA_PORT_COUNT }; - -/* USB-C ports */ -enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; -BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); - -static void reset_nct38xx_port(int port); - -static void usbc_interrupt_init(void) -{ - /* Enable PPC interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc)); - - /* Enable TCPC interrupts. */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc)); - - /* Enable BC 1.2 interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12)); - - /* Enable SBU fault interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_sbu_fault)); -} -DECLARE_HOOK(HOOK_INIT, usbc_interrupt_init, HOOK_PRIO_POST_I2C); - -static void usb_fault_interrupt_init(void) -{ - /* Enable USB fault interrupts when we hit S5 */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_hub_fault)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_fault)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a1_fault)); -} -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, usb_fault_interrupt_init, HOOK_PRIO_DEFAULT); - -static void usb_fault_interrupt_disable(void) -{ - /* Disable USB fault interrupts leaving S5 */ - gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_hub_fault)); - gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_fault)); - gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a1_fault)); -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_fault_interrupt_disable, - HOOK_PRIO_DEFAULT); - -int board_set_active_charge_port(int port) -{ - int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; - int rv; - - if (port == CHARGE_PORT_NONE) { - CPRINTSUSB("Disabling all charger ports"); - - /* Disable all ports. */ - for (i = 0; i < ppc_cnt; i++) { - /* - * If this port had booted in dead battery mode, go - * ahead and reset it so EN_SNK responds properly. - */ - if (nct38xx_get_boot_type(i) == - NCT38XX_BOOT_DEAD_BATTERY) { - reset_nct38xx_port(i); - pd_set_error_recovery(i); - } - - /* - * Do not return early if one fails otherwise we can - * get into a boot loop assertion failure. - */ - if (ppc_vbus_sink_enable(i, 0)) - CPRINTSUSB("Disabling C%d as sink failed.", i); - } - - return EC_SUCCESS; - } else if (!is_valid_port) { - return EC_ERROR_INVAL; - } - - /* - * Check if we can reset any ports in dead battery mode - * - * The NCT3807 may continue to keep EN_SNK low on the dead battery port - * and allow a dangerous level of voltage to pass through to the initial - * charge port (see b/183660105). We must reset the ports if we have - * sufficient battery to do so, which will bring EN_SNK back under - * normal control. - */ - rv = EC_SUCCESS; - for (i = 0; i < board_get_usb_pd_port_count(); i++) { - if (nct38xx_get_boot_type(i) == NCT38XX_BOOT_DEAD_BATTERY) { - CPRINTSUSB("Found dead battery on %d", i); - /* - * If we have battery, get this port reset ASAP. - * This means temporarily rejecting charge manager - * sets to it. - */ - if (pd_is_battery_capable()) { - reset_nct38xx_port(i); - pd_set_error_recovery(i); - - if (port == i) - rv = EC_ERROR_INVAL; - } else if (port != i) { - /* - * If other port is selected and in dead battery - * mode, reset this port. Otherwise, reject - * change because we'll brown out. - */ - if (nct38xx_get_boot_type(port) == - NCT38XX_BOOT_DEAD_BATTERY) { - reset_nct38xx_port(i); - pd_set_error_recovery(i); - } else { - rv = EC_ERROR_INVAL; - } - } - } - } - - if (rv != EC_SUCCESS) - return rv; - - /* Check if the port is sourcing VBUS. */ - if (tcpm_get_src_ctrl(port)) { - CPRINTSUSB("Skip enable C%d", port); - return EC_ERROR_INVAL; - } - - CPRINTSUSB("New charge port: C%d", port); - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < ppc_cnt; i++) { - if (i == port) - continue; - - if (ppc_vbus_sink_enable(i, 0)) - CPRINTSUSB("C%d: sink path disable failed.", i); - } - - /* Enable requested charge port. */ - if (ppc_vbus_sink_enable(port, 1)) { - CPRINTSUSB("C%d: sink path enable failed.", port); - return EC_ERROR_UNKNOWN; - } - - return EC_SUCCESS; -} - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_ma = (charge_ma * CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR) / 100; - - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} - -void sbu_fault_interrupt(enum gpio_signal signal) -{ - int port = signal == IOEX_USB_C1_FAULT_ODL ? 1 : 0; - - CPRINTSUSB("C%d: SBU fault", port); - pd_handle_overcurrent(port); -} - -void usb_fault_interrupt(enum gpio_signal signal) -{ - int out; - - CPRINTSUSB("USB fault(%d), alerting the SoC", signal); - out = gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_hub_fault_q_odl)) && - gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_a0_fault_odl)) && - gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_a1_fault_db_odl)); - - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_fault_odl), out); -} - -void usb_pd_soc_interrupt(enum gpio_signal signal) -{ - /* - * This interrupt is unexpected with our use of the SoC mux, so just log - * it as a point of interest. - */ - CPRINTSUSB("SOC PD Interrupt"); -} - -#ifdef CONFIG_CHARGER_ISL9241 -/* Round up 3250 max current to multiple of 128mA for ISL9241 AC prochot. */ -#define SKYRIM_AC_PROCHOT_CURRENT_MA 3328 -static void set_ac_prochot(void) -{ - isl9241_set_ac_prochot(CHARGER_SOLO, SKYRIM_AC_PROCHOT_CURRENT_MA); -} -DECLARE_HOOK(HOOK_INIT, set_ac_prochot, HOOK_PRIO_DEFAULT); -#endif /* CONFIG_CHARGER_ISL9241 */ - -void tcpc_alert_event(enum gpio_signal signal) -{ - int port; - - switch (signal) { - case GPIO_USB_C0_TCPC_INT_ODL: - port = 0; - break; - case GPIO_USB_C1_TCPC_INT_ODL: - port = 1; - break; - default: - return; - } - - schedule_deferred_pd_interrupt(port); -} - -static void reset_nct38xx_port(int port) -{ - const struct gpio_dt_spec *reset_gpio_l; - const struct device *ioex_port0, *ioex_port1; - - /* TODO(b/225189538): Save and restore ioex signals */ - if (port == USBC_PORT_C0) { - reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_l); - ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0)); - ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port1)); - } else if (port == USBC_PORT_C1) { - reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_rst_l); - ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c1_port0)); - ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c1_port1)); - } else { - /* Invalid port: do nothing */ - return; - } - - gpio_pin_set_dt(reset_gpio_l, 0); - msleep(NCT38XX_RESET_HOLD_DELAY_MS); - gpio_pin_set_dt(reset_gpio_l, 1); - nct38xx_reset_notify(port); - if (NCT3807_RESET_POST_DELAY_MS != 0) - msleep(NCT3807_RESET_POST_DELAY_MS); - - /* Re-enable the IO expander pins */ - gpio_reset_port(ioex_port0); - gpio_reset_port(ioex_port1); -} - -void board_reset_pd_mcu(void) -{ - /* Reset TCPC0 */ - reset_nct38xx_port(USBC_PORT_C0); - - /* Reset TCPC1 */ - reset_nct38xx_port(USBC_PORT_C1); -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - - /* - * Check which port has the ALERT line set and ignore if that TCPC has - * its reset line active. - */ - if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) { - if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( - gpio_usb_c0_tcpc_rst_l)) != 0) - status |= PD_STATUS_TCPC_ALERT_0; - } - - if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) { - if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( - gpio_usb_c1_tcpc_rst_l)) != 0) - status |= PD_STATUS_TCPC_ALERT_1; - } - - return status; -} - -void bc12_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_BC12_INT_ODL: - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - break; - - case GPIO_USB_C1_BC12_INT_ODL: - usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); - break; - - default: - break; - } -} - -/** - * Return if VBUS is sagging too low - * - * For legacy BC1.2 charging with CONFIG_CHARGE_RAMP_SW, ramp up input current - * until voltage drops to 4.5V. Don't go lower than this to be kind to the - * charger (see b/67964166). - */ -#define BC12_MIN_VOLTAGE 4500 -int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) -{ - int voltage = 0; - int rv; - - rv = charger_get_vbus_voltage(port, &voltage); - - if (rv) { - CPRINTSUSB("%s rv=%d", __func__, rv); - return 0; - } - - /* - * b/168569046: The ISL9241 sometimes incorrectly reports 0 for unknown - * reason, causing ramp to stop at 0.5A. Workaround this by ignoring 0. - * This partly defeats the point of ramping, but will still catch - * VBUS below 4.5V and above 0V. - */ - if (voltage == 0) { - CPRINTSUSB("%s vbus=0", __func__); - return 0; - } - - if (voltage < BC12_MIN_VOLTAGE) - CPRINTSUSB("%s vbus=%d", __func__, voltage); - - return voltage < BC12_MIN_VOLTAGE; -} - -#define SAFE_RESET_VBUS_DELAY_MS 900 -#define SAFE_RESET_VBUS_MV 5000 -void board_hibernate(void) -{ - int port; - enum ec_error_list ret; - - /* - * If we are charging, then drop the Vbus level down to 5V to ensure - * that we don't get locked out of the 6.8V OVLO for our PPCs in - * dead-battery mode. This is needed when the TCPC/PPC rails go away. - * (b/79218851, b/143778351, b/147007265) - */ - port = charge_manager_get_active_charge_port(); - if (port != CHARGE_PORT_NONE) { - pd_request_source_voltage(port, SAFE_RESET_VBUS_MV); - - /* Give PD task and PPC chip time to get to 5V */ - msleep(SAFE_RESET_VBUS_DELAY_MS); - } - - /* Try to put our battery fuel gauge into sleep mode */ - ret = battery_sleep_fuel_gauge(); - if ((ret != EC_SUCCESS) && (ret != EC_ERROR_UNIMPLEMENTED)) - cprints(CC_SYSTEM, "Failed to send battery sleep command"); -} diff --git a/zephyr/projects/skyrim/src/winterhold/kb_backlight.c b/zephyr/projects/skyrim/src/winterhold/kb_backlight.c deleted file mode 100644 index 049b99e3a1..0000000000 --- a/zephyr/projects/skyrim/src/winterhold/kb_backlight.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "board_config.h" -#include "common.h" -#include "cros_board_info.h" -#include "cros_cbi.h" - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -__override uint32_t board_override_feature_flags0(uint32_t flags0) -{ - int ret; - uint32_t val; - - /* - * Remove keyboard backlight feature for devices that don't support it. - */ - ret = cros_cbi_get_fw_config(FW_KB_BL, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL); - return flags0; - } - - if (val == FW_KB_BL_NOT_PRESENT) - return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB)); - else - return flags0; -} diff --git a/zephyr/projects/skyrim/src/winterhold/keyboard.c b/zephyr/projects/skyrim/src/winterhold/keyboard.c deleted file mode 100644 index d3aebe0f2e..0000000000 --- a/zephyr/projects/skyrim/src/winterhold/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config winterhold_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &winterhold_kb; -} diff --git a/zephyr/projects/skyrim/src/winterhold/ppc_config.c b/zephyr/projects/skyrim/src/winterhold/ppc_config.c deleted file mode 100644 index 72ddb6ce6c..0000000000 --- a/zephyr/projects/skyrim/src/winterhold/ppc_config.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Winterhold board-specific PPC code */ - -#include - -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - nx20p348x_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c b/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c deleted file mode 100644 index fdcf37e6b0..0000000000 --- a/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Winterhold board-specific USB-C mux configuration */ - -#include - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - /* - * Those registers all need to be set no matter what state the mux is - * in it needs to be set. - */ - RETURN_ERROR( - anx7483_set_eq(me, ANX7483_PIN_URX1, ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR( - anx7483_set_eq(me, ANX7483_PIN_URX2, ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR( - anx7483_set_eq(me, ANX7483_PIN_UTX1, ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR( - anx7483_set_eq(me, ANX7483_PIN_UTX2, ANX7483_EQ_SETTING_8_4DB)); - - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_0_5DB)); - - return EC_SUCCESS; -} diff --git a/zephyr/projects/skyrim/usbc.dts b/zephyr/projects/skyrim/usbc.dts deleted file mode 100644 index 8486927e8d..0000000000 --- a/zephyr/projects/skyrim/usbc.dts +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - usbc_port0: port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - }; - - usbc_port1: port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - tcpc = <&tcpc_port1>; - }; - }; -}; diff --git a/zephyr/projects/skyrim/winterhold.dts b/zephyr/projects/skyrim/winterhold.dts deleted file mode 100644 index 8a182ab835..0000000000 --- a/zephyr/projects/skyrim/winterhold.dts +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Winterhold-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <105>; - temp_host_halt = <110>; - temp_host_release_high = <95>; - temp_host_release_halt = <100>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - temp_host_warn = <50>; - temp_host_high = <105>; - temp_host_halt = <110>; - temp_host_release_warn = <45>; - temp_host_release_high = <95>; - temp_host_release_halt = <100>; - temp_fan_off = <35>; - temp_fan_max = <40>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - Winterhold-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - /* - * FW_CONFIG field to enable KB back light or not. - */ - kb-bl { - enum-name = "FW_KB_BL"; - start = <1>; - size = <1>; - - no-kb-bl { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_NOT_PRESENT"; - value = <0>; - }; - kb-bl-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_PRESENT"; - value = <1>; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - }; - ppc_port0: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; -}; - -&i2c4_1 { - charger: isl9238@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; -}; - -&fan0 { - pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>; - rpm_min = <2100>; - rpm_start = <2600>; - rpm_max = <4800>; -}; - -&temp_sensor_charger { - temp_host_high = <100>; - temp_host_halt = <110>; - temp_host_release_high = <90>; - temp_host_release_halt = <100>; -}; - -&temp_sensor_memory { - temp_host_high = <91>; - temp_host_halt = <96>; - temp_host_release_high = <81>; - temp_host_release_halt = <86>; -}; - -&temp_sensor_cpu { - /delete-property/ temp_host_high; - /delete-property/ temp_host_halt; - /delete-property/ temp_host_release_high; - /delete-property/ temp_fan_off; - /delete-property/ temp_fan_max; -}; diff --git a/zephyr/projects/trogdor/lazor/BUILD.py b/zephyr/projects/trogdor/lazor/BUILD.py deleted file mode 100644 index ca1a26bdcf..0000000000 --- a/zephyr/projects/trogdor/lazor/BUILD.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Define zmake projects for lazor.""" - -register_npcx_project( - project_name="lazor", - zephyr_board="npcx7", - dts_overlays=[ - "adc.dts", - "battery.dts", - "display.dts", - "gpio.dts", - "i2c.dts", - "host_interface_npcx.dts", - "interrupts.dts", - "keyboard.dts", - "led.dts", - "motionsense.dts", - "pwm_led.dts", - "usbc.dts", - "default_gpio_pinctrl.dts", - ], -) diff --git a/zephyr/projects/trogdor/lazor/CMakeLists.txt b/zephyr/projects/trogdor/lazor/CMakeLists.txt deleted file mode 100644 index b6d5024707..0000000000 --- a/zephyr/projects/trogdor/lazor/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.13.1) - -find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(lazor) - -cros_ec_library_include_directories(include) - -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC - "src/power.c" - "src/usb_pd_policy.c" - "src/usbc_config.c") - -zephyr_library_sources( - "src/sku.c" - "src/switchcap.c") - -# Board specific implementation -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C - "src/i2c.c") diff --git a/zephyr/projects/trogdor/lazor/adc.dts b/zephyr/projects/trogdor/lazor/adc.dts deleted file mode 100644 index b834001587..0000000000 --- a/zephyr/projects/trogdor/lazor/adc.dts +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - vbus { - enum-name = "ADC_VBUS"; - io-channels = <&adc0 1>; - /* Measure VBUS through a 1/10 voltage divider */ - mul = <10>; - }; - amon_bmon { - enum-name = "ADC_AMON_BMON"; - io-channels = <&adc0 2>; - /* - * Adapter current output or battery charging/ - * discharging current (uV) 18x amplification on - * charger side. - */ - mul = <1000>; - div = <18>; - }; - psys { - enum-name = "ADC_PSYS"; - io-channels = <&adc0 3>; - /* - * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor, - * to read 0.8V @ 99 W, i.e. 124000 uW/mV. - */ - mul = <124000>; - }; - }; - -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/trogdor/lazor/battery.dts b/zephyr/projects/trogdor/lazor/battery.dts deleted file mode 100644 index 2b17dd4761..0000000000 --- a/zephyr/projects/trogdor/lazor/battery.dts +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap16l5j { - compatible = "panasonic,ap16l5j", "battery-smart"; - }; - ap16l5j_009 { - compatible = "panasonic,ap16l5j-009", "battery-smart"; - }; - ap16l8j { - compatible = "lgc,ap16l8j", "battery-smart"; - }; - lgc_ap18c8k { - compatible = "lgc,ap18c8k", "battery-smart"; - }; - murata_ap18c4k { - compatible = "murata,ap18c4k", "battery-smart"; - }; - }; -}; diff --git a/zephyr/projects/trogdor/lazor/default_gpio_pinctrl.dts b/zephyr/projects/trogdor/lazor/default_gpio_pinctrl.dts deleted file mode 100644 index 1819bdbc3e..0000000000 --- a/zephyr/projects/trogdor/lazor/default_gpio_pinctrl.dts +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Adds the &alt1_no_lpc_espi setting over the NPCX7 default setting. */ -&{/def-io-conf-list} { - pinmux = <&alt0_gpio_no_spip - &alt0_gpio_no_fpip - &alt1_no_pwrgd - &alt1_no_lpc_espi - &alta_no_peci_en - &altd_npsl_in1_sl - &altd_npsl_in2_sl - &altd_psl_in3_sl - &altd_psl_in4_sl - &alt7_no_ksi0_sl - &alt7_no_ksi1_sl - &alt7_no_ksi2_sl - &alt7_no_ksi3_sl - &alt7_no_ksi4_sl - &alt7_no_ksi5_sl - &alt7_no_ksi6_sl - &alt7_no_ksi7_sl - &alt8_no_kso00_sl - &alt8_no_kso01_sl - &alt8_no_kso02_sl - &alt8_no_kso03_sl - &alt8_no_kso04_sl - &alt8_no_kso05_sl - &alt8_no_kso06_sl - &alt8_no_kso07_sl - &alt9_no_kso08_sl - &alt9_no_kso09_sl - &alt9_no_kso10_sl - &alt9_no_kso11_sl - &alt9_no_kso12_sl - &alt9_no_kso13_sl - &alt9_no_kso14_sl - &alt9_no_kso15_sl - &alta_no_kso16_sl - &alta_no_kso17_sl >; -}; diff --git a/zephyr/projects/trogdor/lazor/display.dts b/zephyr/projects/trogdor/lazor/display.dts deleted file mode 100644 index 65d3a2d91b..0000000000 --- a/zephyr/projects/trogdor/lazor/display.dts +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - displight { - compatible = "cros-ec,displight"; - pwms = <&pwm5 0 PWM_HZ(4800) PWM_POLARITY_NORMAL>; - generic-pwm-channel = <1>; - }; -}; - -&pwm5 { - status = "okay"; - pinctrl-0 = <&pwm5_gpb7>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/trogdor/lazor/gpio.dts b/zephyr/projects/trogdor/lazor/gpio.dts deleted file mode 100644 index a047d7e2f2..0000000000 --- a/zephyr/projects/trogdor/lazor/gpio.dts +++ /dev/null @@ -1,320 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-wp = &gpio_ec_wp_odl; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PD_INT_ODL"; - }; - gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl { - gpios = <&gpiof 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PD_INT_ODL"; - }; - gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl { - gpios = <&gpio0 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_SWCTL_INT_ODL"; - }; - gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl { - gpios = <&gpio4 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_SWCTL_INT_ODL"; - }; - gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { - gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { - gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; - }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiod 1 GPIO_INPUT_PULL_UP>; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 3 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - gpio_ec_pwr_btn_odl: ec_pwr_btn_odl { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpiof 2 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_wp_odl: ec_wp_odl { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_lid_open_ec: lid_open_ec { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ap_rst_l: ap_rst_l { - gpios = <&gpioc 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_AP_RST_L"; - }; - gpio_ps_hold: ps_hold { - gpios = <&gpioa 4 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_PS_HOLD"; - }; - gpio_ap_suspend: ap_suspend { - gpios = <&gpio5 7 GPIO_INPUT>; - enum-name = "GPIO_AP_SUSPEND"; - }; - gpio_deprecated_ap_rst_req: deprecated_ap_rst_req { - gpios = <&gpioc 2 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_DEPRECATED_AP_RST_REQ"; - }; - gpio_power_good: power_good { - gpios = <&gpio5 4 GPIO_INPUT_PULL_DOWN>; - enum-name = "GPIO_POWER_GOOD"; - }; - gpio_warm_reset_l: warm_reset_l { - gpios = <&gpiof 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_WARM_RESET_L"; - }; - ap_ec_spi_cs_l { - gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpioc 6 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - gpio_da9313_gpio0: da9313_gpio0 { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_DA9313_GPIO0"; - }; - /* - * Active low input - */ - gpio_switchcap_pg_int_l: switchcap_pg_int_l { - gpios = <&gpioe 2 (GPIO_ACTIVE_LOW | GPIO_INPUT)>; - }; - gpio_ec_rst_odl: ec_rst_odl { - gpios = <&gpio0 2 GPIO_INPUT>; - }; - ec_entering_rw { - gpios = <&gpioe 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - ec_batt_pres_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - pm845_resin_l { - gpios = <&gpio3 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_RESIN_L"; - }; - pmic_kpd_pwr_odl { - gpios = <&gpiod 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_PMIC_KPD_PWR_ODL"; - }; - ec_int_l { - gpios = <&gpioa 2 GPIO_ODR_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - qsip_on { - gpios = <&gpio5 0 GPIO_OUTPUT_LOW>; - }; - gpio_hibernate_l: hibernate_l { - gpios = <&gpio5 2 GPIO_OUTPUT_HIGH>; - }; - gpio_switchcap_on: switchcap_on { - gpios = <&gpiod 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_SWITCHCAP_ON"; - }; - gpio_vbob_en: vbob_en { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_VBOB_EN"; - }; - gpio_en_pp3300_a: en_pp3300_a { - gpios = <&gpioa 6 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP3300_A"; - }; - gpio_en_pp5000_a: en_pp5000_a { - gpios = <&gpio6 7 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP5000"; - }; - ec_bl_disable_l { - gpios = <&gpiob 6 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENABLE_BACKLIGHT"; - }; - gpio_lid_accel_int_l: lid_accel_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - trackpad_int_gate { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { - gpios = <&gpiof 1 GPIO_ODR_HIGH>; - }; - gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { - gpios = <&gpioe 4 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_oe_l: dp_mux_oe_l { - gpios = <&gpio9 6 GPIO_ODR_HIGH>; - }; - gpio_dp_mux_sel: dp_mux_sel { - gpios = <&gpio4 5 GPIO_OUTPUT_LOW>; - }; - gpio_dp_hot_plug_det: dp_hot_plug_det { - gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; - }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpio8 6 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; - gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { - #led-pin-cells = <1>; - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - gpio_ec_chg_led_b_c1: ec_chg_led_b_c1 { - #led-pin-cells = <1>; - gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; - }; - gpio_brd_id0: brd_id0 { - gpios = <&gpioc 7 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION1"; - }; - gpio_brd_id1: brd_id1 { - gpios = <&gpio9 3 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION2"; - }; - gpio_brd_id2: brd_id2 { - gpios = <&gpio6 3 GPIO_INPUT>; - enum-name = "GPIO_BOARD_VERSION3"; - }; - gpio_sku_id0: sku_id0 { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_sku_id1: sku_id1 { - gpios = <&gpio4 1 GPIO_INPUT>; - }; - gpio_sku_id2: sku_id2 { - gpios = <&gpiod 4 GPIO_INPUT>; - }; - arm_x86 { - gpios = <&gpio6 6 GPIO_OUTPUT_LOW>; - }; - ec-i2c-sensor-scl { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec-i2c-sensor-sda { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_power_button - &int_lid_open - &int_ec_rst - >; - }; - - ec-mkbp-host-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <( - HOST_EVENT_LID_OPEN | - HOST_EVENT_POWER_BUTTON | - HOST_EVENT_AC_CONNECTED | - HOST_EVENT_AC_DISCONNECTED | - HOST_EVENT_HANG_DETECT | - HOST_EVENT_RTC | - HOST_EVENT_MODE_CHANGE | - HOST_EVENT_DEVICE)>; - }; - - ec-mkbp-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | - MKBP_EVENT_HOST_EVENT | - MKBP_EVENT_SENSOR_FIFO)>; - }; - - sku { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_sku_id0 - &gpio_sku_id1 - &gpio_sku_id2 - >; - - system = "binary"; - }; - - board { - compatible = "cros-ec,gpio-id"; - - bits = < - &gpio_brd_id0 - &gpio_brd_id1 - &gpio_brd_id2 - >; - - system = "binary_first_base3"; - }; - - unused-pins { - compatible = "unused-gpios"; - unused-gpios = - <&gpio5 1 0>, - <&gpiod 0 0>, - <&gpiof 3 0>, - <&gpio0 4 0>, - <&gpioc 0 0>, - <&gpioa 7 0>, - <&gpio8 3 0>, - <&gpio8 1 0>, - <&gpio3 7 0>, - <&gpio7 6 0>, - <&gpio3 4 0>, - <&gpioc 5 0>, - <&gpioa 3 0>, - <&gpio7 3 0>, - <&gpiod 7 0>, - <&gpioa 5 0>, - <&gpiob 0 0>, - <&gpio9 4 0>, - <&gpiob 1 0>, - <&gpio6 2 0>, - <&gpio3 5 0>, - <&gpio9 7 0>, - <&gpio6 0 0>, - <&gpio7 2 0>; - }; -}; diff --git a/zephyr/projects/trogdor/lazor/gpio_led.dts b/zephyr/projects/trogdor/lazor/gpio_led.dts deleted file mode 100644 index c8c026506b..0000000000 --- a/zephyr/projects/trogdor/lazor/gpio_led.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_b_c1 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_b_c1 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_b_c1 1>; - }; - }; -}; diff --git a/zephyr/projects/trogdor/lazor/host_interface_npcx.dts b/zephyr/projects/trogdor/lazor/host_interface_npcx.dts deleted file mode 100644 index 14efa3c6b2..0000000000 --- a/zephyr/projects/trogdor/lazor/host_interface_npcx.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* host interface */ -&shi { - status = "okay"; - pinctrl-0 = <&shi_gp46_47_53_55>; - pinctrl-1 = <&shi_gpio_gp46_47_53_55>; - pinctrl-names = "default", "sleep"; -}; diff --git a/zephyr/projects/trogdor/lazor/i2c.dts b/zephyr/projects/trogdor/lazor/i2c.dts deleted file mode 100644 index e19ad224a9..0000000000 --- a/zephyr/projects/trogdor/lazor/i2c.dts +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_power: power { - i2c-port = <&i2c0_0>; - remote-port = <0>; - enum-names = "I2C_PORT_POWER", - "I2C_PORT_BATTERY", - "I2C_PORT_VIRTUAL_BATTERY", - "I2C_PORT_CHARGER"; - }; - i2c_tcpc0: tcpc0 { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_TCPC0"; - }; - i2c_tcpc1: tcpc1 { - i2c-port = <&i2c2_0>; - enum-names = "I2C_PORT_TCPC1"; - }; - i2c_eeprom: eeprom { - i2c-port = <&i2c5_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - i2c_sensor: sensor { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_SENSOR", - "I2C_PORT_ACCEL"; - }; - }; - -}; - -&i2c0_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - charger: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - ppc_port0: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - status = "okay"; - reg = <0xb>; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; - - ppc_port1: sn5s330@40{ - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - status = "okay"; - reg = <0xb>; - }; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - /* Not used as no WLC connected */ - clock-frequency = ; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c5_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c1_bc12>; - }; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c7_0 { - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/projects/trogdor/lazor/include/sku.h b/zephyr/projects/trogdor/lazor/include/sku.h deleted file mode 100644 index 76825bbba1..0000000000 --- a/zephyr/projects/trogdor/lazor/include/sku.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Lazor board-specific SKU configuration */ - -#ifndef __ZEPHYR_LAZOR_SKU_H -#define __ZEPHYR_LAZOR_SKU_H - -int board_get_version(void); -int board_is_clamshell(void); -int board_has_da9313(void); -int board_has_ln9310(void); -int board_has_buck_ic(void); - -#endif /* __ZEPHYR_LAZOR_SKU_H */ diff --git a/zephyr/projects/trogdor/lazor/interrupts.dts b/zephyr/projects/trogdor/lazor/interrupts.dts deleted file mode 100644 index 5c2ed35e90..0000000000 --- a/zephyr/projects/trogdor/lazor/interrupts.dts +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_ac_present: ac_present { - irq-pin = <&gpio_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open_ec>; - flags = ; - handler = "lid_interrupt"; - }; - int_wp: wp { - irq-pin = <&gpio_ec_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_ec_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_ec_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - /* - * Note this is an active low input, so - * the direction is from logical low to - * logical high. - */ - int_switchcap_pg: switchcap_pg { - irq-pin = <&gpio_switchcap_pg_int_l>; - flags = ; - handler = "ln9310_interrupt"; - }; - int_ap_rst: ap_rst { - irq-pin = <&gpio_ap_rst_l>; - flags = ; - handler = "chipset_ap_rst_interrupt"; - }; - int_ap_suspend: ap_suspend { - irq-pin = <&gpio_ap_suspend>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_deprecated_ap_rst_req: deprecated_ap_rst_req { - irq-pin = <&gpio_deprecated_ap_rst_req>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_power_good: power_good { - irq-pin = <&gpio_power_good>; - flags = ; - handler = "chipset_power_good_interrupt"; - }; - int_ps_hold: ps_hold { - irq-pin = <&gpio_ps_hold>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_warm_reset: warm_reset { - irq-pin = <&gpio_warm_reset_l>; - flags = ; - handler = "chipset_warm_reset_interrupt"; - }; - int_usb_c0_tcpc: usb_c0_tcpc { - irq-pin = <&gpio_usb_c0_pd_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_tcpc: usb_c1_tcpc { - irq-pin = <&gpio_usb_c1_pd_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_swctl: usb_c0_swctl { - irq-pin = <&gpio_usb_c0_swctl_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_swctl: usb_c1_swctl { - irq-pin = <&gpio_usb_c1_swctl_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_l>; - flags = ; - handler = "usb0_evt"; - }; - int_usb_c1_bc12: usb_c1_bc12 { - irq-pin = <&gpio_usb_c1_bc12_int_l>; - flags = ; - handler = "usb1_evt"; - }; - int_usb_a0_oc: usb_a0_oc { - irq-pin = <&gpio_usb_a0_oc_odl>; - flags = ; - handler = "usba_oc_interrupt"; - }; - int_ccd_mode: ccd_mode { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "board_connect_c0_sbu"; - }; - int_accel: accel { - irq-pin = <&gpio_accel_gyro_int_l>; - flags = ; - handler = "bmi160_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_ec_rst: ec_rst { - irq-pin = <&gpio_ec_rst_odl>; - flags = ; - handler = "wake_isr"; - }; - }; -}; diff --git a/zephyr/projects/trogdor/lazor/keyboard.dts b/zephyr/projects/trogdor/lazor/keyboard.dts deleted file mode 100644 index b8689b883c..0000000000 --- a/zephyr/projects/trogdor/lazor/keyboard.dts +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - actual-key-mask = < - 0x14 /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; - - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm3 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>; - generic-pwm-channel = <0>; - }; -}; - -&pwm3 { - status = "okay"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/trogdor/lazor/led.dts b/zephyr/projects/trogdor/lazor/led.dts deleted file mode 100644 index 4527afd34c..0000000000 --- a/zephyr/projects/trogdor/lazor/led.dts +++ /dev/null @@ -1,90 +0,0 @@ -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_blue>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Blue 2 sec, Amber 2 sec */ - color-0 { - led-color = <&color_blue>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - }; - - power-state-idle { - charge-state = "PWR_STATE_IDLE"; - - color-0 { - led-color = <&color_blue>; - }; - }; - }; -}; diff --git a/zephyr/projects/trogdor/lazor/motionsense.dts b/zephyr/projects/trogdor/lazor/motionsense.dts deleted file mode 100644 index 75fe31b997..0000000000 --- a/zephyr/projects/trogdor/lazor/motionsense.dts +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi160-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi160: bmi160-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <(-1) 0 0 - 0 (-1) 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma255_data: bma255-drv-data { - compatible = "cros-ec,drvdata-bma255"; - status = "okay"; - }; - - bmi160_data: bmi160-drv-data { - compatible = "cros-ec,drvdata-bmi160"; - status = "okay"; - }; - - kx022_data: kx022-drv-data { - compatible = "cros-ec,drvdata-kionix"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma255"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3_S5"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma255_data>; - i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS"; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi160-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3_S5"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi160>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi160_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi160-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3_S5"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi160>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi160_data>; - }; - }; - - /* - * List of alternative motion sensors that creates - * motion_sensors_alt array. - */ - motionsense-sensor-alt { - alt_lid_accel { - compatible = "cros-ec,kx022"; - status = "okay"; - active-mask = "SENSOR_ACTIVE_S0_S3_S5"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - drv-data = <&kx022_data>; - alternate-for = <&lid_accel>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/projects/trogdor/lazor/prj.conf b/zephyr/projects/trogdor/lazor/prj.conf deleted file mode 100644 index 358de69d68..0000000000 --- a/zephyr/projects/trogdor/lazor/prj.conf +++ /dev/null @@ -1,164 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -# -# Lazor actually has a NPCX7M6FC, but -# the NPCX7M7FC is actually the same die, without the -# extra RAM being tested. The code size really could -# do with the extra space, so we pretend the EC is the -# part with the larger RAM. YMMV. -# -CONFIG_SOC_NPCX7M7FC=y -CONFIG_SOC_SERIES_NPCX7=y -CONFIG_SHIMMED_TASKS=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_BRINGUP=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y - -# I2C -CONFIG_I2C=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# Application Processor is Qualcomm SC7180 -CONFIG_AP_ARM_QUALCOMM_SC7180=y - -# Board version is selected over GPIO board ID pins. -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y - -# LN9310 Switchcap -CONFIG_PLATFORM_EC_SWITCHCAP_LN9310=y - -# Power Sequencing -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y -CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y - -# Trogdor family does not use EFS2 -CONFIG_PLATFORM_EC_VBOOT_EFS2=n - -# MKBP event -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_CMD_BUTTON=y -CONFIG_CROS_KB_RAW_NPCX=y - -# ADC -CONFIG_ADC=y -CONFIG_ADC_SHELL=n - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y -CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238=y -CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y -CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y -CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION" -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=10000 -CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y - -# USB-A -CONFIG_PLATFORM_EC_USBA=y - -# USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n -CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y -CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_REV30=n -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_MULTI_PS8XXX=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8751=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y - -# USB ID -# This is allocated specifically for Trogdor -# http://google3/hardware/standards/usb/ -# TODO(b/183608112): Move to device tree -CONFIG_PLATFORM_EC_USB_PID=0x5043 - -# RTC -CONFIG_PLATFORM_EC_RTC=y -CONFIG_CROS_RTC_NPCX=y -CONFIG_PLATFORM_EC_HOSTCMD_RTC=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y - -# EC software sync -CONFIG_PLATFORM_EC_VBOOT_HASH=y - -# Sensors -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ACCEL_BMA255=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI160=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -# Console history -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_CMDS=y -CONFIG_SHELL_HELP=n -CONFIG_SHELL_MINIMAL=y - -# Taskinfo -CONFIG_THREAD_MONITOR=y -CONFIG_KERNEL_SHELL=y - -CONFIG_SYSCON=y - -# Features should be enabled. But the code RAM is not enough, disable them. -#CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y -#CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y diff --git a/zephyr/projects/trogdor/lazor/pwm_led.dts b/zephyr/projects/trogdor/lazor/pwm_led.dts deleted file mode 100644 index 0582966d6a..0000000000 --- a/zephyr/projects/trogdor/lazor/pwm_led.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - - pwm_y: pwm_y { - #led-pin-cells = <1>; - pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; - }; - - pwm_b: pwm_b { - #led-pin-cells = <1>; - pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_b 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_b 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&pwm_y 0>, - <&pwm_b 100>; - }; - }; -}; - -&pwm0 { - status = "okay"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -&pwm2 { - status = "okay"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; diff --git a/zephyr/projects/trogdor/lazor/src/hibernate.c b/zephyr/projects/trogdor/lazor/src/hibernate.c deleted file mode 100644 index 388ff1b087..0000000000 --- a/zephyr/projects/trogdor/lazor/src/hibernate.c +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "sku.h" -#include "system.h" -#include "usbc_ppc.h" - -void board_hibernate(void) -{ - int i; - - if (!board_is_clamshell()) { - /* - * Sensors are unpowered in hibernate. Apply PD to the - * interrupt lines such that they don't float. - */ - gpio_pin_configure_dt( - GPIO_DT_FROM_NODELABEL(gpio_accel_gyro_int_l), - GPIO_DISCONNECTED); - gpio_pin_configure_dt( - GPIO_DT_FROM_NODELABEL(gpio_lid_accel_int_l), - GPIO_DISCONNECTED); - } - - /* - * Board rev 5+ has the hardware fix. Don't need the following - * workaround. - */ - if (system_get_board_version() >= 5) - return; - - /* - * Enable the PPC power sink path before EC enters hibernate; - * otherwise, ACOK won't go High and can't wake EC up. Check the - * bug b/170324206 for details. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) - ppc_vbus_sink_enable(i, 1); -} - -void board_hibernate_late(void) -{ - /* Set the hibernate GPIO to turn off the rails */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hibernate_l), 0); -} diff --git a/zephyr/projects/trogdor/lazor/src/i2c.c b/zephyr/projects/trogdor/lazor/src/i2c.c deleted file mode 100644 index 6d737b410f..0000000000 --- a/zephyr/projects/trogdor/lazor/src/i2c.c +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * 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" - -/* Lazor board specific i2c implementation */ - -#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED -int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) -{ - return (i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY)); -} -#endif diff --git a/zephyr/projects/trogdor/lazor/src/power.c b/zephyr/projects/trogdor/lazor/src/power.c deleted file mode 100644 index 96f9bc43c5..0000000000 --- a/zephyr/projects/trogdor/lazor/src/power.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include -#include "power.h" -#include "task.h" -#include "gpio.h" - -static void board_power_change(struct ap_power_ev_callback *cb, - struct ap_power_ev_data data) -{ - switch (data.event) { - default: - return; - - case AP_POWER_PRE_INIT: - /* Turn on the 3.3V rail */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 1); - - /* Turn on the 5V rail. */ -#ifdef CONFIG_POWER_PP5000_CONTROL - power_5v_enable(task_get_current(), 1); -#else /* !defined(CONFIG_POWER_PP5000_CONTROL) */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 1); -#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ - break; - - case AP_POWER_SHUTDOWN_COMPLETE: - /* Turn off the 5V rail. */ -#ifdef CONFIG_POWER_PP5000_CONTROL - power_5v_enable(task_get_current(), 0); -#else /* !defined(CONFIG_POWER_PP5000_CONTROL) */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 0); -#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ - - /* Turn off the 3.3V and 5V rails. */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 0); - break; - } -} - -static int board_power_handler_init(const struct device *unused) -{ - static struct ap_power_ev_callback cb; - - /* Setup a suspend/resume callback */ - ap_power_ev_init_callback(&cb, board_power_change, - AP_POWER_PRE_INIT | - AP_POWER_SHUTDOWN_COMPLETE); - ap_power_ev_add_callback(&cb); - return 0; -} -SYS_INIT(board_power_handler_init, APPLICATION, 1); diff --git a/zephyr/projects/trogdor/lazor/src/sku.c b/zephyr/projects/trogdor/lazor/src/sku.c deleted file mode 100644 index 1d88437031..0000000000 --- a/zephyr/projects/trogdor/lazor/src/sku.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "config.h" -#include "console.h" -#include "driver/ln9310.h" -#include "tcpm/ps8xxx_public.h" -#include "hooks.h" -#include "sku.h" -#include "system.h" -#include "util.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -static uint8_t sku_id; - -enum board_model { - LAZOR, - LIMOZEEN, - UNKNOWN, -}; - -static const char *const model_name[] = { - "LAZOR", - "LIMOZEEN", - "UNKNOWN", -}; - -static enum board_model get_model(void) -{ - if (sku_id == 0 || sku_id == 1 || sku_id == 2 || sku_id == 3) - return LAZOR; - if (sku_id == 4 || sku_id == 5 || sku_id == 6) - return LIMOZEEN; - return UNKNOWN; -} - -/* Read SKU ID from GPIO and initialize variables for board variants */ -static void sku_init(void) -{ - sku_id = system_get_sku_id(); - CPRINTS("SKU: %u (%s)", sku_id, model_name[get_model()]); -} -DECLARE_HOOK(HOOK_INIT, sku_init, HOOK_PRIO_POST_I2C); - -enum battery_cell_type board_get_battery_cell_type(void) -{ - switch (get_model()) { - case LIMOZEEN: - return BATTERY_CELL_TYPE_3S; - default: - return BATTERY_CELL_TYPE_UNKNOWN; - } -} - -int board_is_clamshell(void) -{ - return get_model() == LIMOZEEN; -} - -__override uint16_t board_get_ps8xxx_product_id(int port) -{ - /* - * Lazor (SKU_ID: 0, 1, 2, 3) rev 3+ changes TCPC from PS8751 to - * PS8805. - * - * Limozeen (SKU_ID: 4, 5, 6) all-rev uses PS8805. - */ - if (get_model() == LAZOR && system_get_board_version() < 3) - return PS8751_PRODUCT_ID; - - return PS8805_PRODUCT_ID; -} - -int board_has_da9313(void) -{ - return get_model() == LAZOR; -} - -int board_has_buck_ic(void) -{ - return get_model() == LIMOZEEN && system_get_board_version() >= 8; -} - -int board_has_ln9310(void) -{ - return get_model() == LIMOZEEN && system_get_board_version() < 8; -} diff --git a/zephyr/projects/trogdor/lazor/src/switchcap.c b/zephyr/projects/trogdor/lazor/src/switchcap.c deleted file mode 100644 index d8205cbcfc..0000000000 --- a/zephyr/projects/trogdor/lazor/src/switchcap.c +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "common.h" -#include "config.h" -#include "console.h" -#include "driver/ln9310.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "i2c.h" -#include "power/qcom.h" -#include "system.h" -#include "sku.h" - -#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args) - -/* LN9310 switchcap */ -const struct ln9310_config_t ln9310_config = { - .i2c_port = I2C_PORT_POWER, - .i2c_addr_flags = LN9310_I2C_ADDR_0_FLAGS, -}; - -static void switchcap_init(void) -{ - if (board_has_da9313()) { - CPRINTS("Use switchcap: DA9313"); - - /* - * When the chip in power down mode, it outputs high-Z. - * Set pull-down to avoid floating. - */ - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0), - GPIO_INPUT | GPIO_PULL_DOWN); - - /* - * Configure DA9313 enable, push-pull output. Don't set the - * level here; otherwise, it will override its value and - * shutdown the switchcap when sysjump to RW. - */ - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), - GPIO_OUTPUT); - } else if (board_has_ln9310()) { - CPRINTS("Use switchcap: LN9310"); - - /* Enable interrupt for LN9310 */ - gpio_enable_dt_interrupt( - GPIO_INT_FROM_NODELABEL(int_switchcap_pg)); - - /* - * Configure LN9310 enable, open-drain output. Don't set the - * level here; otherwise, it will override its value and - * shutdown the switchcap when sysjump to RW. - * - * Note that the gpio.inc configures it GPIO_OUT_LOW. When - * sysjump to RW, will output push-pull a short period of - * time. As it outputs LOW, should be fine. - * - * This GPIO changes like: - * (1) EC boots from RO -> high-Z - * (2) GPIO init according to gpio.inc -> push-pull LOW - * (3) This function configures it -> open-drain HIGH - * (4) Power sequence turns on the switchcap -> open-drain LOW - * (5) EC sysjumps to RW - * (6) GPIO init according to gpio.inc -> push-pull LOW - * (7) This function configures it -> open-drain LOW - */ - gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), - GPIO_OUTPUT | GPIO_OPEN_DRAIN); - - /* Only configure the switchcap if not sysjump */ - if (!system_jumped_late()) { - /* - * Deassert the enable pin, so the - * switchcap won't be enabled after the switchcap is - * configured from standby mode to switching mode. - */ - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), 0); - ln9310_init(); - } - } else if (board_has_buck_ic()) { - CPRINTS("Use Buck IC"); - } else { - CPRINTS("ERROR: No switchcap solution"); - } -} -DECLARE_HOOK(HOOK_INIT, switchcap_init, HOOK_PRIO_DEFAULT); - -void board_set_switchcap_power(int enable) -{ - if (board_has_da9313()) { - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), - enable); - } else if (board_has_ln9310()) { - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), - enable); - ln9310_software_enable(enable); - } else if (board_has_buck_ic()) { - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_vbob_en), enable); - } -} - -int board_is_switchcap_enabled(void) -{ - if (board_has_da9313() || board_has_ln9310()) - return gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_switchcap_on)); - - /* Board has buck ic*/ - return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_vbob_en)); -} - -int board_is_switchcap_power_good(void) -{ - if (board_has_da9313()) - return gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0)); - else if (board_has_ln9310()) - return ln9310_power_good(); - - /* Board has buck ic no way to check POWER GOOD */ - return 1; -} diff --git a/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c b/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c deleted file mode 100644 index 8d046826f9..0000000000 --- a/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c +++ /dev/null @@ -1,261 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "charge_manager.h" -#include "chipset.h" -#include "console.h" -#include "system.h" -#include "usb_mux.h" -#include "usbc_ppc.h" -#include "util.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -int pd_check_vconn_swap(int port) -{ - /* In G3, do not allow vconn swap since PP5000 rail is off */ - return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a)); -} - -static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; -#if CONFIG_USB_PD_PORT_MAX_COUNT == 1 -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5 }; -#else -static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5, - TYPEC_RP_1A5 }; -#endif - -static void board_vbus_update_source_current(int port) -{ - /* Both port are controlled by PPC SN5S330. */ - ppc_set_vbus_source_current_limit(port, vbus_rp[port]); - ppc_vbus_source_enable(port, vbus_en[port]); -} - -void pd_power_supply_reset(int port) -{ - int prev_en; - - prev_en = vbus_en[port]; - - /* Disable VBUS */ - vbus_en[port] = 0; - board_vbus_update_source_current(port); - - /* Enable discharge if we were previously sourcing 5V */ - if (prev_en) - pd_set_vbus_discharge(port, 1); - - /* notify host of power info change */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - /* Disable charging */ - board_vbus_sink_enable(port, 0); - - pd_set_vbus_discharge(port, 0); - - /* Provide VBUS */ - vbus_en[port] = 1; - board_vbus_update_source_current(port); - - /* notify host of power info change */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; /* we are ready */ -} - -int board_vbus_source_enabled(int port) -{ - return vbus_en[port]; -} - -__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) -{ - vbus_rp[port] = rp; - board_vbus_update_source_current(port); -} - -int pd_snk_is_vbus_provided(int port) -{ - return tcpm_check_vbus_level(port, VBUS_PRESENT); -} - -/* ----------------- Vendor Defined Messages ------------------ */ -#ifdef CONFIG_USB_PD_ALT_MODE_DFP -__override int svdm_dp_config(int port, uint32_t *payload) -{ - int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); - uint8_t pin_mode = get_dp_pin_mode(port); - - if (!pin_mode) - return 0; - - /* - * Defer setting the usb_mux until HPD goes high, svdm_dp_attention(). - * The AP only supports one DP phy. An external DP mux switches between - * the two ports. Should switch those muxes when it is really used, - * i.e. HPD high; otherwise, the real use case is preempted, like: - * (1) plug a dongle without monitor connected to port-0, - * (2) plug a dongle without monitor connected to port-1, - * (3) plug a monitor to the port-1 dongle. - */ - - payload[0] = - VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); - payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ - 1, /* DPv1.3 signaling */ - 2); /* UFP connected */ - return 2; -}; - -__override void svdm_dp_post_config(int port) -{ - dp_flags[port] |= DP_FLAGS_DP_ON; -} - -/** - * Is the port fine to be muxed its DisplayPort lines? - * - * Only one port can be muxed to DisplayPort at a time. - * - * @param port Port number of TCPC. - * @return 1 is fine; 0 is bad as other port is already muxed; - */ -static int is_dp_muxable(int port) -{ - int i; - - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) - if (i != port) { - if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED) - return 0; - } - - return 1; -} - -__override int svdm_dp_attention(int port, uint32_t *payload) -{ - const struct gpio_dt_spec *hpd = - GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det); - int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); - int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); - int cur_lvl = gpio_pin_get_dt(hpd); - mux_state_t mux_state; - - dp_status[port] = payload[1]; - - if (!is_dp_muxable(port)) { - /* TODO(waihong): Info user? */ - CPRINTS("p%d: The other port is already muxed.", port); - return 0; - } - - /* - * Initial implementation to handle HPD. Only the first-plugged port - * works, i.e. sending HPD signal to AP. The second-plugged port - * will be ignored. - * - * TODO(waihong): Continue the above case, if the first-plugged port - * is then unplugged, switch to the second-plugged port and signal AP? - */ - if (lvl) { - /* - * Enable and switch the DP port selection mux to the - * correct port. - * - * TODO(waihong): Better to move switching DP mux to - * the usb_mux abstraction. - */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), - port == 1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0); - - /* Connect the SBU lines in PPC chip. */ - if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) - ppc_set_sbu(port, 1); - - /* - * Connect the USB SS/DP lines in TCPC chip. - * - * When mf_pref not true, still use the dock muxing - * because of the board USB-C topology (limited to 2 - * lanes DP). - */ - usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT, - polarity_rm_dts(pd_get_polarity(port))); - } else { - /* Disconnect the DP port selection mux. */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); - - /* Disconnect the SBU lines in PPC chip. */ - if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) - ppc_set_sbu(port, 0); - - /* Disconnect the DP but keep the USB SS lines in TCPC chip. */ - usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, - polarity_rm_dts(pd_get_polarity(port))); - } - - if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) - /* - * Wake up the AP. IRQ or level high indicates a DP sink is now - * present. - */ - pd_notify_dp_alt_mode_entry(port); - - /* Configure TCPC for the HPD event, for proper muxing */ - mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) | - (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED); - usb_mux_hpd_update(port, mux_state); - - /* Signal AP for the HPD event, through GPIO to AP */ - if (irq & cur_lvl) { - uint64_t now = get_time().val; - /* Wait for the minimum spacing between IRQ_HPD if needed */ - if (now < svdm_hpd_deadline[port]) - usleep(svdm_hpd_deadline[port] - now); - - /* Generate IRQ_HPD pulse */ - gpio_pin_set_dt(hpd, 0); - usleep(HPD_DSTREAM_DEBOUNCE_IRQ); - gpio_pin_set_dt(hpd, 1); - - /* Set the minimum time delay (2ms) for the next HPD IRQ */ - svdm_hpd_deadline[port] = - get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - } else if (irq & !lvl) { - CPRINTF("ERR:HPD:IRQ&LOW\n"); - return 0; - } - gpio_pin_set_dt(hpd, lvl); - /* Set the minimum time delay (2ms) for the next HPD IRQ */ - svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - - return 1; -} - -__override void svdm_exit_dp_mode(int port) -{ - if (is_dp_muxable(port)) { - /* Disconnect the DP port selection mux. */ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); - - /* Signal AP for the HPD low event */ - usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det), - 0); - } -} -#endif /* CONFIG_USB_PD_ALT_MODE_DFP */ diff --git a/zephyr/projects/trogdor/lazor/src/usbc_config.c b/zephyr/projects/trogdor/lazor/src/usbc_config.c deleted file mode 100644 index f6bfdfb186..0000000000 --- a/zephyr/projects/trogdor/lazor/src/usbc_config.c +++ /dev/null @@ -1,335 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Lazor board-specific USB-C configuration */ - -#include "battery_fuel_gauge.h" -#include "bc12/pi3usb9201_public.h" -#include "charger.h" -#include "charger/isl923x_public.h" -#include "charge_manager.h" -#include "charge_state.h" -#include "common.h" -#include "config.h" -#include "driver/ln9310.h" -#include "gpio_signal.h" -#include "gpio/gpio_int.h" -#include "hooks.h" -#include "ppc/sn5s330_public.h" -#include "system.h" -#include "tcpm/ps8xxx_public.h" -#include "tcpm/tcpci.h" -#include "timer.h" -#include "usb_pd.h" -#include "usb_mux.h" -#include "usbc_ocp.h" -#include "usbc_ppc.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -int charger_profile_override(struct charge_state_data *curr) -{ - int usb_mv; - int port; - - if (curr->state != ST_CHARGE) - return 0; - - /* Lower the max requested voltage to 5V when battery is full. */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF) && - !(curr->batt.flags & BATT_FLAG_BAD_STATUS) && - !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) && - (curr->batt.status & STATUS_FULLY_CHARGED)) - usb_mv = 5000; - else - usb_mv = PD_MAX_VOLTAGE_MV; - - if (pd_get_max_voltage() != usb_mv) { - CPRINTS("VBUS limited to %dmV", usb_mv); - for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) - pd_set_external_voltage_limit(port, usb_mv); - } - - return 0; -} - -enum ec_status charger_profile_override_get_param(uint32_t param, - uint32_t *value) -{ - return EC_RES_INVALID_PARAM; -} - -enum ec_status charger_profile_override_set_param(uint32_t param, - uint32_t value) -{ - return EC_RES_INVALID_PARAM; -} - -static void usba_oc_deferred(void) -{ - /* Use next number after all USB-C ports to indicate the USB-A port */ - board_overcurrent_event( - CONFIG_USB_PD_PORT_MAX_COUNT, - !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_a0_oc_odl))); -} -DECLARE_DEFERRED(usba_oc_deferred); - -void usba_oc_interrupt(enum gpio_signal signal) -{ - hook_call_deferred(&usba_oc_deferred_data, 0); -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_swctl_int_odl)): - sn5s330_interrupt(0); - break; - case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_swctl_int_odl)): - sn5s330_interrupt(1); - break; - default: - break; - } -} - -static void board_connect_c0_sbu_deferred(void) -{ - /* - * If CCD_MODE_ODL asserts, it means there's a debug accessory connected - * and we should enable the SBU FETs. - */ - ppc_set_sbu(0, 1); -} -DECLARE_DEFERRED(board_connect_c0_sbu_deferred); - -void board_connect_c0_sbu(enum gpio_signal s) -{ - hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0); -} - -/* GPIO Interrupt Handlers */ -void tcpc_alert_event(enum gpio_signal signal) -{ - int port = -1; - - switch (signal) { - case GPIO_USB_C0_PD_INT_ODL: - port = 0; - break; - case GPIO_USB_C1_PD_INT_ODL: - port = 1; - break; - default: - return; - } - - schedule_deferred_pd_interrupt(port); -} - -/* - * Port-0/1 USB mux driver. - * - * The USB mux is handled by TCPC chip and the HPD update is through a GPIO - * to AP. But the TCPC chip is also needed to know the HPD status; otherwise, - * the mux misbehaves. - */ -const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .mux = - &(const struct usb_mux){ - .usb_port = 0, - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, - }, - }, - { - .mux = - &(const struct usb_mux){ - .usb_port = 1, - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, - }, - } -}; - -__override int board_get_default_battery_type(void) -{ - /* - * A 2S battery is set as default. If the board is configured to use - * a 3S battery, according to its SKU_ID, return a 3S battery as - * default. It helps to configure the charger to output a correct - * voltage in case the battery is not attached. - */ - if (board_get_battery_cell_type() == BATTERY_CELL_TYPE_3S) - return BATTERY_LGC_AP18C8K; - - return DEFAULT_BATTERY_TYPE; -} - -/* Initialize board USC-C things */ -static void board_init_usbc(void) -{ - /* Enable USB-A overcurrent interrupt */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc)); - /* - * The H1 SBU line for CCD are behind PPC chip. The PPC internal FETs - * for SBU may be disconnected after DP alt mode is off. Should enable - * the CCD_MODE_ODL interrupt to make sure the SBU FETs are connected. - */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode)); -} -DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT); - -void board_tcpc_init(void) -{ - /* Only reset TCPC if not sysjump */ - if (!system_jumped_late()) { - /* TODO(crosbug.com/p/61098): How long do we need to wait? */ - board_reset_pd_mcu(); - } - - /* Enable PPC interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl)); - - /* Enable TCPC interrupts */ - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); - - /* - * Initialize HPD to low; after sysjump SOC needs to see - * HPD pulse to enable video path - */ - for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) - usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); -} -DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C); - -void board_reset_pd_mcu(void) -{ - cprints(CC_USB, "Resetting TCPCs..."); - cflush(); - - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0); - msleep(PS8XXX_RESET_DELAY_MS); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1); - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1); -} - -void board_set_tcpc_power_mode(int port, int mode) -{ - /* Ignore the "mode" to turn the chip on. We can only do a reset. */ - if (mode) - return; - - board_reset_pd_mcu(); -} - -int board_vbus_sink_enable(int port, int enable) -{ - /* Both ports are controlled by PPC SN5S330 */ - return ppc_vbus_sink_enable(port, enable); -} - -int board_is_sourcing_vbus(int port) -{ - /* Both ports are controlled by PPC SN5S330 */ - return ppc_is_sourcing_vbus(port); -} - -void board_overcurrent_event(int port, int is_overcurrented) -{ - /* TODO(b/120231371): Notify AP */ - CPRINTS("p%d: overcurrent!", port); -} - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - if (port == CHARGE_PORT_NONE) { - CPRINTS("Disabling all charging port"); - - /* Disable all ports. */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - /* - * Do not return early if one fails otherwise we can - * get into a boot loop assertion failure. - */ - if (board_vbus_sink_enable(i, 0)) - CPRINTS("Disabling p%d sink path failed.", i); - } - - return EC_SUCCESS; - } - - /* Check if the port is sourcing VBUS. */ - if (board_is_sourcing_vbus(port)) { - CPRINTS("Skip enable p%d", port); - return EC_ERROR_INVAL; - } - - CPRINTS("New charge port: p%d", port); - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (i == port) - continue; - - if (board_vbus_sink_enable(i, 0)) - CPRINTS("p%d: sink path disable failed.", i); - } - - /* Enable requested charge port. */ - if (board_vbus_sink_enable(port, 1)) { - CPRINTS("p%d: sink path enable failed.", port); - return EC_ERROR_UNKNOWN; - } - - return EC_SUCCESS; -} - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * Ignore lower charge ceiling on PD transition if our battery is - * critical, as we may brownout. - */ - if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 && - charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) { - CPRINTS("Using max ilim %d", max_ma); - charge_ma = max_ma; - } - - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; - - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) - if (gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l))) - status |= PD_STATUS_TCPC_ALERT_0; - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) - if (gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l))) - status |= PD_STATUS_TCPC_ALERT_1; - - return status; -} diff --git a/zephyr/projects/trogdor/lazor/usbc.dts b/zephyr/projects/trogdor/lazor/usbc.dts deleted file mode 100644 index 7864c2716b..0000000000 --- a/zephyr/projects/trogdor/lazor/usbc.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - /* TODO(b/227359762): lazor: move UBC-C configuration into the - * devicetree - */ - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - - bc12 = <&bc12_port0>; - tcpc = <&tcpc_port0>; - - ppc = <&ppc_port0>; - - chg = <&charger>; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - - bc12 = <&bc12_port1>; - tcpc = <&tcpc_port1>; - - ppc = <&ppc_port1>; - }; - }; -}; diff --git a/zephyr/test/drivers/led_driver/led_pins.dts b/zephyr/test/drivers/led_driver/led_pins.dts index f1488a59d8..7c14a48166 100644 --- a/zephyr/test/drivers/led_driver/led_pins.dts +++ b/zephyr/test/drivers/led_driver/led_pins.dts @@ -3,7 +3,7 @@ * found in the LICENSE file. */ - /* Based off of `ec/zephyr/projects/herobrine/led_pins_herobrine.dts` + /* Based off of `ec/zephyr/program/herobrine/led_pins_herobrine.dts` * Modified led-colors to obtain better test coverage. */ / { diff --git a/zephyr/test/drivers/led_driver/led_policy.dts b/zephyr/test/drivers/led_driver/led_policy.dts index fb6d37cb05..cad972bf11 100644 --- a/zephyr/test/drivers/led_driver/led_policy.dts +++ b/zephyr/test/drivers/led_driver/led_policy.dts @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* Based off of `ec/zephyr/projects/herobrine/led_policy_herobrine.dts` +/* Based off of `ec/zephyr/program/herobrine/led_policy_herobrine.dts` * Modified led-colors to obtain better test coverage. */ diff --git a/zephyr/test/herobrine/README.md b/zephyr/test/herobrine/README.md index 398b27e304..646c7ad985 100644 --- a/zephyr/test/herobrine/README.md +++ b/zephyr/test/herobrine/README.md @@ -1,3 +1,3 @@ -Tests for board specific code under `zephyr/projects/herobrine/src`. +Tests for board specific code under `zephyr/program/herobrine/src`. Run with ./twister -T zephyr/test/herobrine diff --git a/zephyr/test/kingler/README.md b/zephyr/test/kingler/README.md index bac3afced2..84dadc105b 100644 --- a/zephyr/test/kingler/README.md +++ b/zephyr/test/kingler/README.md @@ -1,3 +1,3 @@ -Tests for board specific code under `zephyr/projects/corsola/src/kingler`. +Tests for board specific code under `zephyr/program/corsola/src/kingler`. Run with ./twister -T zephyr/test/kingler diff --git a/zephyr/test/kingler/src/alt_sensor.c b/zephyr/test/kingler/src/alt_sensor.c index 88c8e0dfb3..0304656f4a 100644 --- a/zephyr/test/kingler/src/alt_sensor.c +++ b/zephyr/test/kingler/src/alt_sensor.c @@ -12,7 +12,7 @@ #include "gpio_signal.h" #include "hooks.h" -/* SSFC field defined in zephyr/projects/corsola/cbi_steelix.dts */ +/* SSFC field defined in zephyr/program/corsola/cbi_steelix.dts */ #define SSFC_BASE_MAIN_SENSOR (0x1) #define SSFC_BASE_ALT_SENSOR (0x1 << 1) diff --git a/zephyr/test/kingler/testcase.yaml b/zephyr/test/kingler/testcase.yaml index 9b7e9f58ff..7e26480c14 100644 --- a/zephyr/test/kingler/testcase.yaml +++ b/zephyr/test/kingler/testcase.yaml @@ -6,36 +6,36 @@ common: platform_allow: native_posix tests: kingler.steelix: - extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_FORM_FACTOR_CONVERTIBLE=y kingler.rusty: - extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_FORM_FACTOR_CLAMSHELL=y kingler.db_detect_typec: - extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/gpio_steelix.dts;" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/gpio_steelix.dts;" extra_configs: - CONFIG_TEST_DB_DETECT_TYPEC=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.db_detect_hdmi: - extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/gpio_steelix.dts" extra_configs: - CONFIG_TEST_DB_DETECT_HDMI=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.db_detect_none: - extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" extra_configs: - CONFIG_TEST_DB_DETECT_NONE=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.ccd: - extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" extra_configs: - CONFIG_TEST_KINGLER_CCD=y kingler.alt_sensor: - extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/interrupts_steelix.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/interrupts_steelix.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_ALT_SENSOR_PROBE=y diff --git a/zephyr/test/krabby/README.md b/zephyr/test/krabby/README.md index 8262d85fcc..027cdec4a4 100644 --- a/zephyr/test/krabby/README.md +++ b/zephyr/test/krabby/README.md @@ -1,3 +1,3 @@ -Tests for board specific code under `zephyr/projects/corsola/src/krabby`. +Tests for board specific code under `zephyr/program/corsola/src/krabby`. Run with ./twister -T zephyr/test/krabby diff --git a/zephyr/test/krabby/testcase.yaml b/zephyr/test/krabby/testcase.yaml index a748e45be5..5cc3c42428 100644 --- a/zephyr/test/krabby/testcase.yaml +++ b/zephyr/test/krabby/testcase.yaml @@ -6,12 +6,12 @@ common: platform_allow: native_posix tests: krabby.default: - extra_args: DTC_OVERLAY_FILE="common.dts;../projects/corsola/interrupts_krabby.dts;../projects/corsola/gpio_krabby.dts;pinctrl.dts" + extra_args: DTC_OVERLAY_FILE="common.dts;../program/corsola/interrupts_krabby.dts;../program/corsola/gpio_krabby.dts;pinctrl.dts" extra_configs: - CONFIG_TEST_KRABBY=y - CONFIG_MUX_INIT_ADC=y krabby.tentacruel: - extra_args: DTC_OVERLAY_FILE="common.dts;adc_temp.dts;../projects/corsola/interrupts_tentacruel.dts;../projects/corsola/gpio_tentacruel.dts;../projects/corsola/thermistor_tentacruel.dts;pinctrl.dts" + extra_args: DTC_OVERLAY_FILE="common.dts;adc_temp.dts;../program/corsola/interrupts_tentacruel.dts;../program/corsola/gpio_tentacruel.dts;../program/corsola/thermistor_tentacruel.dts;pinctrl.dts" extra_configs: - CONFIG_TEST_TENTACRUEL=y - CONFIG_PLATFORM_EC_TEMP_SENSOR=y diff --git a/zephyr/test/rex/README.md b/zephyr/test/rex/README.md index ef1848a627..454ed6ebb8 100644 --- a/zephyr/test/rex/README.md +++ b/zephyr/test/rex/README.md @@ -1,3 +1,3 @@ -Tests for board specific code under `zephyr/projects/rex/src`. +Tests for board specific code under `zephyr/program/rex/src`. Run with ./twister -T zephyr/test/rex -- cgit v1.2.1 From 0fe46137f42b811762bcaedcd93f2f4587f6ccfa Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Mon, 31 Oct 2022 15:18:27 -0600 Subject: Add EC_CMD_SET_TABLET_MODE Add EC host command EC_CMD_SET_TABLET_MODE, which will be used by 'ectool' to set the tablet mode. BRANCH=none BUG=b:256015402 TEST=CQ Change-Id: I7eae634bcebcdeee21fc170afaa8c844b3278e80 Signed-off-by: Tim Van Patten Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994294 Reviewed-by: Diana Z Code-Coverage: Zoss Reviewed-by: Raul Rangel --- include/ec_commands.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/ec_commands.h b/include/ec_commands.h index 82df1e6b54..f7e40b8c0a 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -3305,6 +3305,22 @@ struct ec_params_usb_charge_set_mode { uint8_t inhibit_charge : 1; /* enum usb_suspend_charge */ } __ec_align1; +/*****************************************************************************/ +/* Tablet mode commands */ + +/* Set tablet mode */ +#define EC_CMD_SET_TABLET_MODE 0x0031 + +enum tablet_mode_override { + TABLET_MODE_DEFAULT, + TABLET_MODE_FORCE_TABLET, + TABLET_MODE_FORCE_CLAMSHELL, +}; + +struct ec_params_set_tablet_mode { + uint8_t tablet_mode; /* enum tablet_mode_override */ +} __ec_align1; + /*****************************************************************************/ /* Persistent storage for host */ -- cgit v1.2.1 From 365143e8cea63db9b1016ff336cad37463899c88 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Fri, 4 Nov 2022 00:39:07 -0600 Subject: test: unit test uart_printf.c Add unit tests to get uart_printf.c to 100% coverage. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I2fdbea71a7048a2187c599052bf7180a97ee3ad2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4004509 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- common/uart_printf.c | 11 ++-- util/twister_tags.py | 1 + zephyr/test/uart_printf/CMakeLists.txt | 29 +++++++++ zephyr/test/uart_printf/include/common.h | 12 ++++ zephyr/test/uart_printf/include/printf.h | 23 +++++++ zephyr/test/uart_printf/include/uart.h | 28 +++++++++ zephyr/test/uart_printf/prj.conf | 6 ++ zephyr/test/uart_printf/src/fakes.cc | 36 +++++++++++ zephyr/test/uart_printf/src/main.cc | 103 +++++++++++++++++++++++++++++++ zephyr/test/uart_printf/testcase.yaml | 8 +++ 10 files changed, 253 insertions(+), 4 deletions(-) create mode 100644 zephyr/test/uart_printf/CMakeLists.txt create mode 100644 zephyr/test/uart_printf/include/common.h create mode 100644 zephyr/test/uart_printf/include/printf.h create mode 100644 zephyr/test/uart_printf/include/uart.h create mode 100644 zephyr/test/uart_printf/prj.conf create mode 100644 zephyr/test/uart_printf/src/fakes.cc create mode 100644 zephyr/test/uart_printf/src/main.cc create mode 100644 zephyr/test/uart_printf/testcase.yaml diff --git a/common/uart_printf.c b/common/uart_printf.c index 01fd1353d2..a4fecf5c73 100644 --- a/common/uart_printf.c +++ b/common/uart_printf.c @@ -31,9 +31,10 @@ int uart_putc(int c) int uart_puts(const char *outstr) { /* Put all characters in the output buffer */ - while (*outstr) { - if (__tx_char(NULL, *outstr++) != 0) + for (; *outstr != '\0'; ++outstr) { + if (__tx_char(NULL, *outstr) != 0) { break; + } } uart_tx_start(); @@ -48,8 +49,9 @@ int uart_put(const char *out, int len) /* Put all characters in the output buffer */ for (written = 0; written < len; written++) { - if (__tx_char(NULL, *out++) != 0) + if (__tx_char(NULL, *out++) != 0) { break; + } } uart_tx_start(); @@ -63,8 +65,9 @@ int uart_put_raw(const char *out, int len) /* Put all characters in the output buffer */ for (written = 0; written < len; written++) { - if (uart_tx_char_raw(NULL, *out++) != 0) + if (uart_tx_char_raw(NULL, *out++) != 0) { break; + } } uart_tx_start(); diff --git a/util/twister_tags.py b/util/twister_tags.py index 692fdc1e99..68ac5846bd 100755 --- a/util/twister_tags.py +++ b/util/twister_tags.py @@ -29,6 +29,7 @@ TAG_TO_DESCRIPTION = { "mkbp": "Testing the MKBP (Matrix Keyboard Protocol) stack", "system": "Directly test functions in common/system.c or shim/src/system.c", "spi": "SPI related tests", + "uart": "UART related tests", } SCRIPT_PATH = os.path.realpath(__file__) diff --git a/zephyr/test/uart_printf/CMakeLists.txt b/zephyr/test/uart_printf/CMakeLists.txt new file mode 100644 index 0000000000..78e0791652 --- /dev/null +++ b/zephyr/test/uart_printf/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.20.0) +set(CMAKE_CXX_STANDARD 20) + +project(uart_printf) + +set(SOURCES + ../../../common/uart_printf.c + src/fakes.cc + src/main.cc +) + +# Create the unittest libraries and binary +find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +target_sources(testbinary + PRIVATE + ../../../common/uart_printf.c + src/fakes.cc + src/main.cc +) + +target_include_directories(testbinary + PRIVATE + include +) diff --git a/zephyr/test/uart_printf/include/common.h b/zephyr/test/uart_printf/include/common.h new file mode 100644 index 0000000000..79af9594b3 --- /dev/null +++ b/zephyr/test/uart_printf/include/common.h @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ +#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ + +#define EC_SUCCESS 0 +#define EC_ERROR_OVERFLOW -1 + +#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ */ diff --git a/zephyr/test/uart_printf/include/printf.h b/zephyr/test/uart_printf/include/printf.h new file mode 100644 index 0000000000..b6fcf6337d --- /dev/null +++ b/zephyr/test/uart_printf/include/printf.h @@ -0,0 +1,23 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ +#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int (*vfnprintf_addchar_t)(void *, int); +DECLARE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *, + const char *, va_list); + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ */ diff --git a/zephyr/test/uart_printf/include/uart.h b/zephyr/test/uart_printf/include/uart.h new file mode 100644 index 0000000000..51fd42a17e --- /dev/null +++ b/zephyr/test/uart_printf/include/uart.h @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ +#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int uart_putc(int c); +int uart_puts(const char *outstr); +int uart_put(const char *out, int len); +int uart_put_raw(const char *out, int len); +int uart_printf(const char *format, ...); + +DECLARE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int); +DECLARE_FAKE_VOID_FUNC(uart_tx_start); + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ */ diff --git a/zephyr/test/uart_printf/prj.conf b/zephyr/test/uart_printf/prj.conf new file mode 100644 index 0000000000..6ec8f4d2a9 --- /dev/null +++ b/zephyr/test/uart_printf/prj.conf @@ -0,0 +1,6 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_ZTEST=y +CONFIG_ZTEST_NEW_API=y diff --git a/zephyr/test/uart_printf/src/fakes.cc b/zephyr/test/uart_printf/src/fakes.cc new file mode 100644 index 0000000000..0bb5fea1eb --- /dev/null +++ b/zephyr/test/uart_printf/src/fakes.cc @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "printf.h" +#include "uart.h" + +DEFINE_FFF_GLOBALS; + +/* printf.h */ +DEFINE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *, + const char *, va_list); + +/* uart.h */ +DEFINE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int); +DEFINE_FAKE_VOID_FUNC(uart_tx_start); + +static void fake_reset_rule_before(const struct ztest_unit_test *test, + void *data) +{ + ARG_UNUSED(test); + ARG_UNUSED(data); + + /* printf.h */ + RESET_FAKE(vfnprintf); + + /* uart.h */ + RESET_FAKE(uart_tx_char_raw); + RESET_FAKE(uart_tx_start); +} + +ZTEST_RULE(fake_reset, fake_reset_rule_before, nullptr); diff --git a/zephyr/test/uart_printf/src/main.cc b/zephyr/test/uart_printf/src/main.cc new file mode 100644 index 0000000000..e84c5c76ba --- /dev/null +++ b/zephyr/test/uart_printf/src/main.cc @@ -0,0 +1,103 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include + +#include "common.h" +#include "printf.h" +#include "uart.h" + +ZTEST_SUITE(uart_printf, nullptr, nullptr, nullptr, nullptr, nullptr); + +ZTEST(uart_printf, test_uart_putc) +{ + int return_vals[] = { 0, -1 }; + + SET_RETURN_SEQ(uart_tx_char_raw, return_vals, 2); + + zassert_ok(uart_putc(5)); + zassert_equal(EC_ERROR_OVERFLOW, uart_putc(5)); +} + +ZTEST(uart_printf, test_uart_put_success) +{ + const std::string test_string = "test string"; + std::string output_string; + + /* Print the whole string */ + zassert_equal(test_string.size(), + static_cast(uart_put(test_string.c_str(), + test_string.size()))); + zassert_equal(test_string.size(), uart_tx_char_raw_fake.call_count); + + /* Copy the history so it's easier to assert */ + for (auto i : + std::views::iota(static_cast(0), test_string.size())) { + output_string += uart_tx_char_raw_fake.arg1_history[i]; + } + + /* Verify that the string was passed to uart_tx_char_raw() */ + zassert_equal(test_string, output_string); +} + +ZTEST(uart_printf, test_uart_put_fail_tx) +{ + const char test_string[] = "\n"; + + uart_tx_char_raw_fake.return_val = -1; + + /* Try printing the newline */ + zassert_equal(0, uart_put(test_string, 1)); + zassert_equal(1, uart_tx_char_raw_fake.call_count); + zassert_equal('\r', uart_tx_char_raw_fake.arg1_val); +} + +ZTEST(uart_printf, test_uart_puts_fail_tx) +{ + const char test_string[] = "\n\0"; + + uart_tx_char_raw_fake.return_val = -1; + + /* Try printing the newline */ + zassert_equal(EC_ERROR_OVERFLOW, uart_puts(test_string)); + zassert_equal(1, uart_tx_char_raw_fake.call_count); + zassert_equal('\r', uart_tx_char_raw_fake.arg1_val); +} + +ZTEST(uart_printf, test_uart_put_raw_fail_tx) +{ + const char test_string[] = "\n"; + + uart_tx_char_raw_fake.return_val = -1; + + /* Try printing the newline */ + zassert_equal(0, uart_put_raw(test_string, 1)); + zassert_equal(1, uart_tx_char_raw_fake.call_count); + zassert_equal('\n', uart_tx_char_raw_fake.arg1_val); +} + +static int vfnprintf_custom_fake_expect_int_arg; +static int vfnprintf_custom_fake(vfnprintf_addchar_t, void *, const char *, + va_list alist) +{ + zassert_equal(vfnprintf_custom_fake_expect_int_arg, va_arg(alist, int)); + return 0; +} +ZTEST(uart_printf, test_uart_printf) +{ + const char test_format[] = "d=%d"; + + vfnprintf_custom_fake_expect_int_arg = 5; + vfnprintf_fake.custom_fake = vfnprintf_custom_fake; + + zassert_ok( + uart_printf(test_format, vfnprintf_custom_fake_expect_int_arg)); + zassert_equal(1, vfnprintf_fake.call_count); + zassert_equal(test_format, vfnprintf_fake.arg2_val); +} diff --git a/zephyr/test/uart_printf/testcase.yaml b/zephyr/test/uart_printf/testcase.yaml new file mode 100644 index 0000000000..0315abab6f --- /dev/null +++ b/zephyr/test/uart_printf/testcase.yaml @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +tests: + uart.printf: + tags: uart + type: unit -- cgit v1.2.1 From 39caf07089611bcd1ac01ac33907c77f415b93c5 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 28 Oct 2022 09:09:14 -0700 Subject: chip/mchp/lfw: Discard ARM.* sections Linking with clang/lld fails since it tries to include .ARM.exidx in the VECTOR region: ld.lld: error: section '.ARM.exidx' will not fit in region 'VECTOR': overflowed by 328 bytes We don't need the exception index table or exception table (see https://crrev.com/c/3857943). This matches the behavior in our other linker scripts: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/core/cortex-m/ec.lds.S;l=745;drc=84b2904dead700e10073080c54e69ea162d8a7c5 This change does not affect the gcc/ld build (identical output before and after). BRANCH=none BUG=b:172020503 TEST=./util/compare_build.sh -b all -j 120 => MATCH Signed-off-by: Tom Hughes Change-Id: I65df11f3ab0c439ea3d4ce2805afaac942b22a0e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3989667 Reviewed-by: Diana Z Code-Coverage: Zoss --- chip/mchp/lfw/ec_lfw.ld | 8 ++++++++ chip/mchp/lfw/ec_lfw_416kb.ld | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/chip/mchp/lfw/ec_lfw.ld b/chip/mchp/lfw/ec_lfw.ld index 1c745d5d2a..d178a42280 100644 --- a/chip/mchp/lfw/ec_lfw.ld +++ b/chip/mchp/lfw/ec_lfw.ld @@ -82,4 +82,12 @@ SECTIONS } >SRAM __image_size = LOADADDR(.text) + SIZEOF(.text) - ORIGIN(VECTOR); + + /* + * Discard C++ exception index table and exception table. These are + * described in more detail in "Exception Handling ABI for ARM + * Architecture": + * https://github.com/ARM-software/abi-aa/blob/60a8eb8c55e999d74dac5e368fc9d7e36e38dda4/ehabi32/ehabi32.rst#54the-object-producer-interface + */ + /DISCARD/ : { *(.ARM.*) } } diff --git a/chip/mchp/lfw/ec_lfw_416kb.ld b/chip/mchp/lfw/ec_lfw_416kb.ld index 93d70ffbe8..c7dfacada3 100644 --- a/chip/mchp/lfw/ec_lfw_416kb.ld +++ b/chip/mchp/lfw/ec_lfw_416kb.ld @@ -86,4 +86,12 @@ SECTIONS } >SRAM __image_size = LOADADDR(.text) + SIZEOF(.text) - ORIGIN(VECTOR); + + /* + * Discard C++ exception index table and exception table. These are + * described in more detail in "Exception Handling ABI for ARM + * Architecture": + * https://github.com/ARM-software/abi-aa/blob/60a8eb8c55e999d74dac5e368fc9d7e36e38dda4/ehabi32/ehabi32.rst#54the-object-producer-interface + */ + /DISCARD/ : { *(.ARM.*) } } -- cgit v1.2.1 From 9fd0cedfd82a0fe3068af096d224eb6f48ee3c31 Mon Sep 17 00:00:00 2001 From: Yi Chou Date: Mon, 7 Nov 2022 03:18:30 +0000 Subject: Revert "test: unit test uart_printf.c" This reverts commit 365143e8cea63db9b1016ff336cad37463899c88. Reason for revert: b/257859791, the original CL might break the firmware-zephyr-cov-cq Original change's description: > test: unit test uart_printf.c > > Add unit tests to get uart_printf.c to 100% coverage. > > BRANCH=none > BUG=none > TEST=twister > > Signed-off-by: Yuval Peress > Change-Id: I2fdbea71a7048a2187c599052bf7180a97ee3ad2 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4004509 > Reviewed-by: Abe Levkoy > Code-Coverage: Zoss Bug: none Change-Id: I6e064a7878d08e29906d73d33113b90befd9fba2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003486 Tested-by: Yi Chou Reviewed-by: Yuval Peress Reviewed-by: Chung-sheng Wu Commit-Queue: Yuval Peress Code-Coverage: Yuval Peress --- common/uart_printf.c | 11 ++-- util/twister_tags.py | 1 - zephyr/test/uart_printf/CMakeLists.txt | 29 --------- zephyr/test/uart_printf/include/common.h | 12 ---- zephyr/test/uart_printf/include/printf.h | 23 ------- zephyr/test/uart_printf/include/uart.h | 28 --------- zephyr/test/uart_printf/prj.conf | 6 -- zephyr/test/uart_printf/src/fakes.cc | 36 ----------- zephyr/test/uart_printf/src/main.cc | 103 ------------------------------- zephyr/test/uart_printf/testcase.yaml | 8 --- 10 files changed, 4 insertions(+), 253 deletions(-) delete mode 100644 zephyr/test/uart_printf/CMakeLists.txt delete mode 100644 zephyr/test/uart_printf/include/common.h delete mode 100644 zephyr/test/uart_printf/include/printf.h delete mode 100644 zephyr/test/uart_printf/include/uart.h delete mode 100644 zephyr/test/uart_printf/prj.conf delete mode 100644 zephyr/test/uart_printf/src/fakes.cc delete mode 100644 zephyr/test/uart_printf/src/main.cc delete mode 100644 zephyr/test/uart_printf/testcase.yaml diff --git a/common/uart_printf.c b/common/uart_printf.c index a4fecf5c73..01fd1353d2 100644 --- a/common/uart_printf.c +++ b/common/uart_printf.c @@ -31,10 +31,9 @@ int uart_putc(int c) int uart_puts(const char *outstr) { /* Put all characters in the output buffer */ - for (; *outstr != '\0'; ++outstr) { - if (__tx_char(NULL, *outstr) != 0) { + while (*outstr) { + if (__tx_char(NULL, *outstr++) != 0) break; - } } uart_tx_start(); @@ -49,9 +48,8 @@ int uart_put(const char *out, int len) /* Put all characters in the output buffer */ for (written = 0; written < len; written++) { - if (__tx_char(NULL, *out++) != 0) { + if (__tx_char(NULL, *out++) != 0) break; - } } uart_tx_start(); @@ -65,9 +63,8 @@ int uart_put_raw(const char *out, int len) /* Put all characters in the output buffer */ for (written = 0; written < len; written++) { - if (uart_tx_char_raw(NULL, *out++) != 0) { + if (uart_tx_char_raw(NULL, *out++) != 0) break; - } } uart_tx_start(); diff --git a/util/twister_tags.py b/util/twister_tags.py index 68ac5846bd..692fdc1e99 100755 --- a/util/twister_tags.py +++ b/util/twister_tags.py @@ -29,7 +29,6 @@ TAG_TO_DESCRIPTION = { "mkbp": "Testing the MKBP (Matrix Keyboard Protocol) stack", "system": "Directly test functions in common/system.c or shim/src/system.c", "spi": "SPI related tests", - "uart": "UART related tests", } SCRIPT_PATH = os.path.realpath(__file__) diff --git a/zephyr/test/uart_printf/CMakeLists.txt b/zephyr/test/uart_printf/CMakeLists.txt deleted file mode 100644 index 78e0791652..0000000000 --- a/zephyr/test/uart_printf/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -cmake_minimum_required(VERSION 3.20.0) -set(CMAKE_CXX_STANDARD 20) - -project(uart_printf) - -set(SOURCES - ../../../common/uart_printf.c - src/fakes.cc - src/main.cc -) - -# Create the unittest libraries and binary -find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) - -target_sources(testbinary - PRIVATE - ../../../common/uart_printf.c - src/fakes.cc - src/main.cc -) - -target_include_directories(testbinary - PRIVATE - include -) diff --git a/zephyr/test/uart_printf/include/common.h b/zephyr/test/uart_printf/include/common.h deleted file mode 100644 index 79af9594b3..0000000000 --- a/zephyr/test/uart_printf/include/common.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ -#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ - -#define EC_SUCCESS 0 -#define EC_ERROR_OVERFLOW -1 - -#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ */ diff --git a/zephyr/test/uart_printf/include/printf.h b/zephyr/test/uart_printf/include/printf.h deleted file mode 100644 index b6fcf6337d..0000000000 --- a/zephyr/test/uart_printf/include/printf.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ -#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int (*vfnprintf_addchar_t)(void *, int); -DECLARE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *, - const char *, va_list); - -#ifdef __cplusplus -} -#endif - -#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ */ diff --git a/zephyr/test/uart_printf/include/uart.h b/zephyr/test/uart_printf/include/uart.h deleted file mode 100644 index 51fd42a17e..0000000000 --- a/zephyr/test/uart_printf/include/uart.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ -#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int uart_putc(int c); -int uart_puts(const char *outstr); -int uart_put(const char *out, int len); -int uart_put_raw(const char *out, int len); -int uart_printf(const char *format, ...); - -DECLARE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int); -DECLARE_FAKE_VOID_FUNC(uart_tx_start); - -#ifdef __cplusplus -} -#endif - -#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ */ diff --git a/zephyr/test/uart_printf/prj.conf b/zephyr/test/uart_printf/prj.conf deleted file mode 100644 index 6ec8f4d2a9..0000000000 --- a/zephyr/test/uart_printf/prj.conf +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_ZTEST=y -CONFIG_ZTEST_NEW_API=y diff --git a/zephyr/test/uart_printf/src/fakes.cc b/zephyr/test/uart_printf/src/fakes.cc deleted file mode 100644 index 0bb5fea1eb..0000000000 --- a/zephyr/test/uart_printf/src/fakes.cc +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "printf.h" -#include "uart.h" - -DEFINE_FFF_GLOBALS; - -/* printf.h */ -DEFINE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *, - const char *, va_list); - -/* uart.h */ -DEFINE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int); -DEFINE_FAKE_VOID_FUNC(uart_tx_start); - -static void fake_reset_rule_before(const struct ztest_unit_test *test, - void *data) -{ - ARG_UNUSED(test); - ARG_UNUSED(data); - - /* printf.h */ - RESET_FAKE(vfnprintf); - - /* uart.h */ - RESET_FAKE(uart_tx_char_raw); - RESET_FAKE(uart_tx_start); -} - -ZTEST_RULE(fake_reset, fake_reset_rule_before, nullptr); diff --git a/zephyr/test/uart_printf/src/main.cc b/zephyr/test/uart_printf/src/main.cc deleted file mode 100644 index e84c5c76ba..0000000000 --- a/zephyr/test/uart_printf/src/main.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include - -#include - -#include "common.h" -#include "printf.h" -#include "uart.h" - -ZTEST_SUITE(uart_printf, nullptr, nullptr, nullptr, nullptr, nullptr); - -ZTEST(uart_printf, test_uart_putc) -{ - int return_vals[] = { 0, -1 }; - - SET_RETURN_SEQ(uart_tx_char_raw, return_vals, 2); - - zassert_ok(uart_putc(5)); - zassert_equal(EC_ERROR_OVERFLOW, uart_putc(5)); -} - -ZTEST(uart_printf, test_uart_put_success) -{ - const std::string test_string = "test string"; - std::string output_string; - - /* Print the whole string */ - zassert_equal(test_string.size(), - static_cast(uart_put(test_string.c_str(), - test_string.size()))); - zassert_equal(test_string.size(), uart_tx_char_raw_fake.call_count); - - /* Copy the history so it's easier to assert */ - for (auto i : - std::views::iota(static_cast(0), test_string.size())) { - output_string += uart_tx_char_raw_fake.arg1_history[i]; - } - - /* Verify that the string was passed to uart_tx_char_raw() */ - zassert_equal(test_string, output_string); -} - -ZTEST(uart_printf, test_uart_put_fail_tx) -{ - const char test_string[] = "\n"; - - uart_tx_char_raw_fake.return_val = -1; - - /* Try printing the newline */ - zassert_equal(0, uart_put(test_string, 1)); - zassert_equal(1, uart_tx_char_raw_fake.call_count); - zassert_equal('\r', uart_tx_char_raw_fake.arg1_val); -} - -ZTEST(uart_printf, test_uart_puts_fail_tx) -{ - const char test_string[] = "\n\0"; - - uart_tx_char_raw_fake.return_val = -1; - - /* Try printing the newline */ - zassert_equal(EC_ERROR_OVERFLOW, uart_puts(test_string)); - zassert_equal(1, uart_tx_char_raw_fake.call_count); - zassert_equal('\r', uart_tx_char_raw_fake.arg1_val); -} - -ZTEST(uart_printf, test_uart_put_raw_fail_tx) -{ - const char test_string[] = "\n"; - - uart_tx_char_raw_fake.return_val = -1; - - /* Try printing the newline */ - zassert_equal(0, uart_put_raw(test_string, 1)); - zassert_equal(1, uart_tx_char_raw_fake.call_count); - zassert_equal('\n', uart_tx_char_raw_fake.arg1_val); -} - -static int vfnprintf_custom_fake_expect_int_arg; -static int vfnprintf_custom_fake(vfnprintf_addchar_t, void *, const char *, - va_list alist) -{ - zassert_equal(vfnprintf_custom_fake_expect_int_arg, va_arg(alist, int)); - return 0; -} -ZTEST(uart_printf, test_uart_printf) -{ - const char test_format[] = "d=%d"; - - vfnprintf_custom_fake_expect_int_arg = 5; - vfnprintf_fake.custom_fake = vfnprintf_custom_fake; - - zassert_ok( - uart_printf(test_format, vfnprintf_custom_fake_expect_int_arg)); - zassert_equal(1, vfnprintf_fake.call_count); - zassert_equal(test_format, vfnprintf_fake.arg2_val); -} diff --git a/zephyr/test/uart_printf/testcase.yaml b/zephyr/test/uart_printf/testcase.yaml deleted file mode 100644 index 0315abab6f..0000000000 --- a/zephyr/test/uart_printf/testcase.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -tests: - uart.printf: - tags: uart - type: unit -- cgit v1.2.1 From d8fe1d3cec2a996bc1fd60b61d781e7f0f8dbf2e Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 7 Nov 2022 08:46:32 +0800 Subject: steelix: Remove CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL pd log level = 0 can't pass FAFT_PD, so we remove the config CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL for steelix, so that it is set to the default value. BUG=b:257575658 BRANCH=none TEST=test FAFT_PD pass. Signed-off-by: mike Change-Id: I2007f5813c549971b12133f8a6c5b24316e70dd7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005049 Reviewed-by: wen zhang Code-Coverage: Zoss Commit-Queue: Knox Chiou Reviewed-by: Knox Chiou --- zephyr/program/corsola/prj_steelix.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/zephyr/program/corsola/prj_steelix.conf b/zephyr/program/corsola/prj_steelix.conf index 16f622989f..bf2de72512 100644 --- a/zephyr/program/corsola/prj_steelix.conf +++ b/zephyr/program/corsola/prj_steelix.conf @@ -29,7 +29,6 @@ CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n CONFIG_LOG=n CONFIG_LOG_MODE_MINIMAL=n CONFIG_SHELL_MINIMAL=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=0 # AC_OK debounce time CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 -- cgit v1.2.1 From 79d48dcca63668f5a1f7ae1b495ad20d89772cd5 Mon Sep 17 00:00:00 2001 From: Li Feng Date: Wed, 26 Oct 2022 23:55:17 -0700 Subject: adl_ish_lite: Not enter D0i3 This increases D0i3 entering threshold to 3 seconds. With orignial 50ms, we run into some power consumption issue. ISH enters D0i3, wakes up every ~100ms and does DMA copy. DMA copy causes host being waken up, and the time host stays in S0i3 is too short. Power consumption also increases. Changing threshold to 3 seconds, current ISH won't enter D0i3. It only enter D0i2 and IPAPG. The power consumption is within range, also can meet S0i3 requirement. BUG=b:234136500 BRANCH=none TEST=On Nirwen platform, pass S0ix test, can hit S0i3; and ISH power state is D0i2. Signed-off-by: Leifu Zhao Signed-off-by: Li Feng Change-Id: I712ff66601770c1431b20a507f2277365b976099 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3983417 Code-Coverage: Zoss Reviewed-by: Reka Norman --- board/tglrvp_ish/board.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/board/tglrvp_ish/board.h b/board/tglrvp_ish/board.h index 3912e8803a..e285014e5e 100644 --- a/board/tglrvp_ish/board.h +++ b/board/tglrvp_ish/board.h @@ -79,8 +79,11 @@ #define CONFIG_ISH_IPAPG #define CONFIG_ISH_D0I2_MIN_USEC (15 * MSEC) +#ifdef BOARD_ADL_ISH_LITE +#define CONFIG_ISH_D0I3_MIN_USEC (3000 * MSEC) +#else #define CONFIG_ISH_D0I3_MIN_USEC (50 * MSEC) - +#endif #define CONFIG_ISH_NEW_PM #ifndef __ASSEMBLER__ -- cgit v1.2.1 From 900253911e0404c5d13c3f80921d71df03833186 Mon Sep 17 00:00:00 2001 From: Sue Chen Date: Fri, 21 Oct 2022 15:46:39 +0800 Subject: keyboard_raw: add function keyboard_raw_config_alt Using keyboard_raw_config_alt to set KSI/KSO alternative function. Add all the keyboard gpio pins in pinctrl for setting sleep state in cros_kb_raw. BUG=b:252950988 BRANCH=none TEST=none LOW_COVERAGE_REASON=b:256669239 cros_kb_raw_npcx.c needs tests Signed-off-by: Sue Chen Change-Id: I45d6de5b1f950f7e6c8d8b67ec03ba1e219c635b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3970401 Reviewed-by: Keith Short Code-Coverage: Zoss --- include/keyboard_raw.h | 10 +++ zephyr/boards/arm/npcx9/npcx9.dtsi | 106 ++++++++++++++++++++++++++ zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c | 13 ++++ zephyr/include/drivers/cros_kb_raw.h | 36 +++++++++ zephyr/shim/src/keyboard_raw.c | 8 ++ 5 files changed, 173 insertions(+) diff --git a/include/keyboard_raw.h b/include/keyboard_raw.h index dca7b3c79a..2b2254e56c 100644 --- a/include/keyboard_raw.h +++ b/include/keyboard_raw.h @@ -11,6 +11,8 @@ #ifndef __CROS_EC_KEYBOARD_RAW_H #define __CROS_EC_KEYBOARD_RAW_H +#include + #include "builtin/assert.h" #include "common.h" #include "gpio_signal.h" @@ -62,6 +64,14 @@ int keyboard_raw_read_rows(void); */ void keyboard_raw_enable_interrupt(int enable); +/** + * Enable or disable keyboard alternative function. + * + * @param enable 1 enable KSI/KSO alternative function, + * 0 set all KSI/KSO pins to normal GPIO. + */ +void keybaord_raw_config_alt(bool enable); + #ifdef HAS_TASK_KEYSCAN /** diff --git a/zephyr/boards/arm/npcx9/npcx9.dtsi b/zephyr/boards/arm/npcx9/npcx9.dtsi index 15547d5802..38901af696 100644 --- a/zephyr/boards/arm/npcx9/npcx9.dtsi +++ b/zephyr/boards/arm/npcx9/npcx9.dtsi @@ -56,6 +56,112 @@ pinmux = <&altc_shi_sl>; pinmux-gpio; }; + + /* Keyboard peripheral interfaces */ + /omit-if-no-ref/ ksi0_gpio_gp31: periph-kbscan-ksi0-gpio { + pinmux = <&alt7_no_ksi0_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ ksi1_gpio_gp30: periph-kbscan-ksi1-gpio { + pinmux = <&alt7_no_ksi1_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ ksi2_gpio_gp27: periph-kbscan-ksi2-gpio { + pinmux = <&alt7_no_ksi2_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ ksi3_gpio_gp26: periph-kbscan-ksi3-gpio { + pinmux = <&alt7_no_ksi3_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ ksi4_gpio_gp25: periph-kbscan-ksi4-gpio { + pinmux = <&alt7_no_ksi4_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ ksi5_gpio_gp24: periph-kbscan-ksi5-gpio { + pinmux = <&alt7_no_ksi5_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ ksi6_gpio_gp23: periph-kbscan-ksi6-gpio { + pinmux = <&alt7_no_ksi6_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ ksi7_gpio_gp22: periph-kbscan-ksi7-gpio { + pinmux = <&alt7_no_ksi7_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso00_gpio_gp21: periph-kbscan-kso00-gpio { + pinmux = <&alt8_no_kso00_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso01_gpio_gp20: periph-kbscan-kso01-gpio { + pinmux = <&alt8_no_kso01_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso02_gpio_gp17: periph-kbscan-kso02-gpio { + pinmux = <&alt8_no_kso02_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso03_gpio_gp16: periph-kbscan-kso03-gpio { + pinmux = <&alt8_no_kso03_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso04_gpio_gp15: periph-kbscan-kso04-gpio { + pinmux = <&alt8_no_kso04_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso05_gpio_gp14: periph-kbscan-kso05-gpio { + pinmux = <&alt8_no_kso05_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso06_gpio_gp13: periph-kbscan-kso06-gpio { + pinmux = <&alt8_no_kso06_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso07_gpio_gp12: periph-kbscan-kso07-gpio { + pinmux = <&alt8_no_kso07_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso08_gpio_gp11: periph-kbscan-kso08-gpio { + pinmux = <&alt9_no_kso08_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso09_gpio_gp10: periph-kbscan-kso09-gpio { + pinmux = <&alt9_no_kso09_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso10_gpio_gp07: periph-kbscan-kso10-gpio { + pinmux = <&alt9_no_kso10_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso11_gpio_gp06: periph-kbscan-kso11-gpio { + pinmux = <&alt9_no_kso11_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso12_gpio_gp05: periph-kbscan-kso12-gpio { + pinmux = <&alt9_no_kso12_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso13_gpio_gp04: periph-kbscan-kso13-gpio { + pinmux = <&alt9_no_kso13_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso14_gpio_gp82: periph-kbscan-kso14-gpio { + pinmux = <&alt9_no_kso14_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso15_gpio_gp83: periph-kbscan-kso15-gpio { + pinmux = <&alt9_no_kso15_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso16_gpio_gp03: periph-kbscan-kso16-gpio { + pinmux = <&alta_no_kso16_sl>; + pinmux-gpio; + }; + /omit-if-no-ref/ kso17_gpio_gpb1: periph-kbscan-kso17-gpio { + pinmux = <&alta_no_kso17_sl>; + pinmux-gpio; + }; }; /* PSL_OUT is fixed to GPIO85 in npcx9 series. */ diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c index c720f4b431..1d1f2b4918 100644 --- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c +++ b/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c @@ -218,11 +218,24 @@ static int cros_kb_raw_npcx_init(const struct device *dev) return 0; } +#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST +static int cros_kb_raw_npcx_config_alt(const struct device *dev, bool enable) +{ + const struct cros_kb_raw_npcx_config *const config = DRV_CONFIG(dev); + uint8_t id = enable ? PINCTRL_STATE_DEFAULT : PINCTRL_STATE_SLEEP; + + return pinctrl_apply_state(config->pcfg, id); +} +#endif + static const struct cros_kb_raw_driver_api cros_kb_raw_npcx_driver_api = { .init = cros_kb_raw_npcx_init, .drive_colum = cros_kb_raw_npcx_drive_column, .read_rows = cros_kb_raw_npcx_read_row, .enable_interrupt = cros_kb_raw_npcx_enable_interrupt, +#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST + .config_alt = cros_kb_raw_npcx_config_alt, +#endif }; PINCTRL_DT_INST_DEFINE(0); diff --git a/zephyr/include/drivers/cros_kb_raw.h b/zephyr/include/drivers/cros_kb_raw.h index d370a3bbde..cbf461866c 100644 --- a/zephyr/include/drivers/cros_kb_raw.h +++ b/zephyr/include/drivers/cros_kb_raw.h @@ -60,11 +60,17 @@ typedef int (*cros_kb_raw_api_read_rows)(const struct device *dev); typedef int (*cros_kb_raw_api_enable_interrupt)(const struct device *dev, int enable); +typedef int (*cros_kb_raw_api_config_alt)(const struct device *dev, + bool enable); + __subsystem struct cros_kb_raw_driver_api { cros_kb_raw_api_init init; cros_kb_raw_api_drive_column drive_colum; cros_kb_raw_api_read_rows read_rows; cros_kb_raw_api_enable_interrupt enable_interrupt; +#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST + cros_kb_raw_api_config_alt config_alt; +#endif }; /** @@ -173,6 +179,36 @@ static inline int z_impl_cros_kb_raw_enable_interrupt(const struct device *dev, return api->enable_interrupt(dev, enable); } +/** + * @brief Enable or disable keyboard alternative function. + * + * Enabling alternative function. + * + * @param dev Pointer to the device structure for the keyboard driver instance. + * @param enable If 1, enable keyboard function. Otherwise, disable it (as + * GPIO). + * + * @return 0 If successful. + * @retval -ENOTSUP Not supported api function. + */ + +#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST +__syscall int cros_kb_raw_config_alt(const struct device *dev, bool enable); + +static inline int z_impl_cros_kb_raw_config_alt(const struct device *dev, + bool enable) +{ + const struct cros_kb_raw_driver_api *api = + (const struct cros_kb_raw_driver_api *)dev->api; + + if (!api->config_alt) { + return -ENOTSUP; + } + + return api->config_alt(dev, enable); +} +#endif + /** * @brief Set the logical level of the keyboard column 2 output. * diff --git a/zephyr/shim/src/keyboard_raw.c b/zephyr/shim/src/keyboard_raw.c index c9f465d06d..7d27e5ce39 100644 --- a/zephyr/shim/src/keyboard_raw.c +++ b/zephyr/shim/src/keyboard_raw.c @@ -63,3 +63,11 @@ void keyboard_raw_enable_interrupt(int enable) { cros_kb_raw_enable_interrupt(cros_kb_raw_dev, enable); } + +/** + * Enable or disable keyboard alternative function. + */ +void keybaord_raw_config_alt(bool enable) +{ + cros_kb_raw_config_alt(cros_kb_raw_dev, enable); +} -- cgit v1.2.1 From 42d6df2a6bc0659b8f6b5b6837b1fa39bbb46c58 Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Mon, 31 Oct 2022 15:19:53 -0600 Subject: Add EC_CMD_SET_TABLET_MODE handler Add the EC_CMD_SET_TABLET_MODE host command handler. This will update the tablet mode status in the EC, based on the parameters of the EC_CMD_SET_TABLET_MODE command. BRANCH=none BUG=b:256015402 TEST=CQ TEST=./twister -v -i --coverage -p native_posix \ -p unit_testing -s zephyr/test/drivers/drivers.host_cmd https://luci-milo.appspot.com/ui/inv/u-timvp-2022-11-04-18-57-00-c115adba47827acf Change-Id: Ia7d8ad44a284742bb347004ba355a8419d047faa Signed-off-by: Tim Van Patten Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994295 Reviewed-by: Diana Z Code-Coverage: Zoss Reviewed-by: Raul Rangel --- common/tablet_mode.c | 41 ++++++++- zephyr/test/drivers/host_cmd/CMakeLists.txt | 1 + zephyr/test/drivers/host_cmd/src/tablet_mode.c | 111 +++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 zephyr/test/drivers/host_cmd/src/tablet_mode.c diff --git a/common/tablet_mode.c b/common/tablet_mode.c index 576e80c0ef..1a86997eb4 100644 --- a/common/tablet_mode.c +++ b/common/tablet_mode.c @@ -28,6 +28,12 @@ static uint32_t tablet_mode; */ static bool tablet_mode_forced; +/* + * Console command can force the value of tablet_mode. If tablet_mode_force is + * false, use stored tablet mode value before it was (possibly) overridden. + */ +static uint32_t tablet_mode_store; + /* True if GMR sensor is reporting 360 degrees. */ static bool gmr_sensor_at_360; @@ -173,11 +179,42 @@ void gmr_tablet_switch_disable(void) } #endif +static enum ec_status tablet_mode_command(struct host_cmd_handler_args *args) +{ + const struct ec_params_set_tablet_mode *p = args->params; + + if (tablet_mode_forced == false) + tablet_mode_store = tablet_mode; + + switch (p->tablet_mode) { + case TABLET_MODE_DEFAULT: + tablet_mode = tablet_mode_store; + tablet_mode_forced = false; + break; + case TABLET_MODE_FORCE_TABLET: + tablet_mode = TABLET_TRIGGER_LID; + tablet_mode_forced = true; + break; + case TABLET_MODE_FORCE_CLAMSHELL: + tablet_mode = 0; + tablet_mode_forced = true; + break; + default: + CPRINTS("Invalid EC_CMD_SET_TABLET_MODE parameter: %d", + p->tablet_mode); + return EC_RES_INVALID_PARAM; + } + + notify_tablet_mode_change(); + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_SET_TABLET_MODE, tablet_mode_command, + EC_VER_MASK(0) | EC_VER_MASK(1)); + #ifdef CONFIG_TABLET_MODE static int command_settabletmode(int argc, const char **argv) { - static uint32_t tablet_mode_store; - if (argc == 1) { print_tablet_mode(); return EC_SUCCESS; diff --git a/zephyr/test/drivers/host_cmd/CMakeLists.txt b/zephyr/test/drivers/host_cmd/CMakeLists.txt index d1567ec635..14733253c3 100644 --- a/zephyr/test/drivers/host_cmd/CMakeLists.txt +++ b/zephyr/test/drivers/host_cmd/CMakeLists.txt @@ -21,6 +21,7 @@ target_sources(app PRIVATE src/pd_chip_info.c src/pd_control.c src/pd_log.c + src/tablet_mode.c src/usb_pd_control.c src/usb_pd_host_cmd.c ) diff --git a/zephyr/test/drivers/host_cmd/src/tablet_mode.c b/zephyr/test/drivers/host_cmd/src/tablet_mode.c new file mode 100644 index 0000000000..cb65899c4f --- /dev/null +++ b/zephyr/test/drivers/host_cmd/src/tablet_mode.c @@ -0,0 +1,111 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "hooks.h" +#include "host_command.h" +#include "tablet_mode.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_smart_battery.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" + +struct host_cmd_tablet_mode_fixture { + const struct emul *emul; + struct i2c_common_emul_data *i2c_emul; +}; + +static void host_cmd_tablet_mode_before(void *f) +{ + ARG_UNUSED(f); + tablet_reset(); +} + +static void host_cmd_tablet_mode_after(void *f) +{ + ARG_UNUSED(f); + tablet_reset(); +} + +ZTEST_SUITE(host_cmd_tablet_mode, drivers_predicate_post_main, NULL, + host_cmd_tablet_mode_before, host_cmd_tablet_mode_after, NULL); + +/* Test tablet mode can be enabled with a host command. */ +ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_on) +{ + int rv; + struct ec_params_set_tablet_mode params = { + .tablet_mode = TABLET_MODE_FORCE_TABLET + }; + + struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS( + EC_CMD_SET_TABLET_MODE, UINT8_C(0), params); + + rv = host_command_process(&args); + zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d", + rv); + /* Return 1 if in tablet mode, 0 otherwise */ + rv = tablet_get_mode(); + zassert_equal(rv, 1, "unexpected tablet mode: %d", rv); +} + +/* Test tablet mode can be disabled with a host command. */ +ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_off) +{ + int rv; + struct ec_params_set_tablet_mode params = { + .tablet_mode = TABLET_MODE_FORCE_CLAMSHELL + }; + + struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS( + EC_CMD_SET_TABLET_MODE, UINT8_C(0), params); + + rv = host_command_process(&args); + zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d", + rv); + /* Return 1 if in tablet mode, 0 otherwise */ + rv = tablet_get_mode(); + zassert_equal(rv, 0, "unexpected tablet mode: %d", rv); +} + +/* Test tablet mode can be reset with a host command. */ +ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_reset) +{ + int rv; + struct ec_params_set_tablet_mode params = { + .tablet_mode = TABLET_MODE_DEFAULT + }; + + struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS( + EC_CMD_SET_TABLET_MODE, UINT8_C(0), params); + + rv = host_command_process(&args); + zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d", + rv); + /* Return 1 if in tablet mode, 0 otherwise */ + rv = tablet_get_mode(); + zassert_equal(rv, 0, "unexpected tablet mode: %d", rv); +} + +/* Test tablet mode can handle invalid host command parameters. */ +ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_invalid_parameter) +{ + int rv; + struct ec_params_set_tablet_mode params = { + .tablet_mode = 0xEE /* Sufficiently random, bad value.*/ + }; + + struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS( + EC_CMD_SET_TABLET_MODE, UINT8_C(0), params); + + rv = host_command_process(&args); + zassert_equal(EC_RES_INVALID_PARAM, rv, + "Expected EC_RES_INVALID_PARAM, but got %d", rv); + /* Return 1 if in tablet mode, 0 otherwise */ + rv = tablet_get_mode(); + zassert_equal(rv, 0, "unexpected tablet mode: %d", rv); +} -- cgit v1.2.1 From b7d535ca00ea3dfee2d200408c18c1da0c1fab18 Mon Sep 17 00:00:00 2001 From: Sue Chen Date: Tue, 11 Oct 2022 15:32:21 +0800 Subject: zephyr: add keyboard factory test support Add support for factory keyboard test through command 'ectool kbfactorytest' command. BUG=b:252950988 BRANCH=none TEST=none LOW_COVERAGE_REASON=b:256670141 create unit test for keyboard factory test Signed-off-by: Sue Chen Change-Id: I6c0c9c6098a306baa1a64eb664818db28f01041e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3944300 Commit-Queue: Keith Short Reviewed-by: Keith Short Code-Coverage: Zoss --- common/keyboard_scan.c | 13 +++++++++++-- util/config_allowed.txt | 1 - zephyr/Kconfig.keyboard | 7 +++++++ zephyr/shim/include/config_chip.h | 5 +++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 6c3756170b..bd820ae881 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -1078,6 +1078,10 @@ int keyboard_factory_test_scan(void) keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_CLOSED); flags = gpio_get_default_flags(GPIO_KBD_KSO2); + if (IS_ENABLED(CONFIG_ZEPHYR)) + /* set all KSI/KSO pins to GPIO_ALT_FUNC_NONE */ + keybaord_raw_config_alt(0); + /* Set all of KSO/KSI pins to internal pull-up and input */ for (i = 0; i < keyboard_factory_scan_pins_used; i++) { if (keyboard_factory_scan_pins[i][0] < 0) @@ -1086,7 +1090,9 @@ int keyboard_factory_test_scan(void) port = keyboard_factory_scan_pins[i][0]; id = keyboard_factory_scan_pins[i][1]; - gpio_set_alternate_function(port, 1 << id, GPIO_ALT_FUNC_NONE); + if (!IS_ENABLED(CONFIG_ZEPHYR)) + gpio_set_alternate_function(port, 1 << id, + GPIO_ALT_FUNC_NONE); gpio_set_flags_by_mask(port, 1 << id, GPIO_INPUT | GPIO_PULL_UP); } @@ -1119,7 +1125,10 @@ int keyboard_factory_test_scan(void) GPIO_INPUT | GPIO_PULL_UP); } done: - gpio_config_module(MODULE_KEYBOARD_SCAN, 1); + if (IS_ENABLED(CONFIG_ZEPHYR)) + keybaord_raw_config_alt(1); + else + gpio_config_module(MODULE_KEYBOARD_SCAN, 1); gpio_set_flags(GPIO_KBD_KSO2, flags); keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_CLOSED); diff --git a/util/config_allowed.txt b/util/config_allowed.txt index fd5fcc2e30..dcb614c033 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -558,7 +558,6 @@ CONFIG_ITE_FLASH_SUPPORT CONFIG_KEYBOARD_ASSISTANT_KEY CONFIG_KEYBOARD_BACKLIGHT CONFIG_KEYBOARD_BOOT_KEYS -CONFIG_KEYBOARD_FACTORY_TEST CONFIG_KEYBOARD_IRQ_GPIO CONFIG_KEYBOARD_KSO_BASE CONFIG_KEYBOARD_KSO_HIGH_DRIVE diff --git a/zephyr/Kconfig.keyboard b/zephyr/Kconfig.keyboard index e0f1b2517e..505f292e8b 100644 --- a/zephyr/Kconfig.keyboard +++ b/zephyr/Kconfig.keyboard @@ -62,6 +62,13 @@ config PLATFORM_EC_KEYBOARD_DEBUG if the board is currently headless and keyboard functionality is being checked. +config PLATFORM_EC_KEYBOARD_FACTORY_TEST + bool "Support keyboard factory test" + help + Enable support "ectool kbfactorytest" command. + Need to map keyboard connector pins to EC GPIO pins in + keyboard_factory_scan_pins table. + config PLATFORM_EC_KEYBOARD_KEYPAD bool "Support a numeric keypad" help diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 2680e647d5..51c5a9e85e 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -711,6 +711,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #define CONFIG_KEYBOARD_REFRESH_ROW3 #endif /* CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3 */ +#undef CONFIG_KEYBOARD_FACTORY_TEST +#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST +#define CONFIG_KEYBOARD_FACTORY_TEST +#endif + #undef CONFIG_KEYBOARD_KEYPAD #ifdef CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD #define CONFIG_KEYBOARD_KEYPAD -- cgit v1.2.1 From 7956342b8d3d11e68d4c12a3745f82b26e81e620 Mon Sep 17 00:00:00 2001 From: Sue Chen Date: Tue, 11 Oct 2022 16:03:04 +0800 Subject: Craask: enable CONFIG_KEYBOARD_FACTORY_TEST Support factory keyboard test through command 'ectool kbfactorytest'. BUG=b:252950988 BRANCH=none TEST=`ectool kbfactorytest` can detect shorted pins. Signed-off-by: Sue Chen Change-Id: If11e5d7e46f5391741991cef3b0a4822f18ee863 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3944650 Commit-Queue: Keith Short Reviewed-by: Keith Short Code-Coverage: Zoss --- zephyr/dts/bindings/gpio/gpio-enum-name.yaml | 1 + zephyr/program/nissa/craask/generated.dtsi | 1 + zephyr/program/nissa/craask/keyboard.dtsi | 24 +++++++++++++++++++++++- zephyr/program/nissa/craask/project.conf | 2 ++ zephyr/program/nissa/craask/src/keyboard.c | 16 ++++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/zephyr/dts/bindings/gpio/gpio-enum-name.yaml b/zephyr/dts/bindings/gpio/gpio-enum-name.yaml index 8252ca75e1..5041b0646a 100644 --- a/zephyr/dts/bindings/gpio/gpio-enum-name.yaml +++ b/zephyr/dts/bindings/gpio/gpio-enum-name.yaml @@ -55,6 +55,7 @@ properties: - GPIO_EN_USB_A_5V - GPIO_IMVP9_VRRDY_OD - GPIO_KB_DISCRETE_INT + - GPIO_KBD_KSO2 - GPIO_LID_ACCEL_INT_L - GPIO_LID_OPEN - GPIO_PACKET_MODE_EN diff --git a/zephyr/program/nissa/craask/generated.dtsi b/zephyr/program/nissa/craask/generated.dtsi index 4303bbd4c5..b10ec5f08b 100644 --- a/zephyr/program/nissa/craask/generated.dtsi +++ b/zephyr/program/nissa/craask/generated.dtsi @@ -67,6 +67,7 @@ }; gpio_ec_kso_02_inv: ec_kso_02_inv { gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_KBD_KSO2"; }; gpio_ec_pch_wake_odl: ec_pch_wake_odl { gpios = <&gpiob 0 GPIO_ODR_LOW>; diff --git a/zephyr/program/nissa/craask/keyboard.dtsi b/zephyr/program/nissa/craask/keyboard.dtsi index f9e46de1f2..06eb6bacfb 100644 --- a/zephyr/program/nissa/craask/keyboard.dtsi +++ b/zephyr/program/nissa/craask/keyboard.dtsi @@ -28,5 +28,27 @@ &kso11_gp06 &kso12_gp05 >; - pinctrl-names = "default"; + pinctrl-1 = < + &ksi0_gpio_gp31 + &ksi1_gpio_gp30 + &ksi2_gpio_gp27 + &ksi3_gpio_gp26 + &ksi4_gpio_gp25 + &ksi5_gpio_gp24 + &ksi6_gpio_gp23 + &ksi7_gpio_gp22 + &kso00_gpio_gp21 + &kso01_gpio_gp20 + &kso03_gpio_gp16 + &kso04_gpio_gp15 + &kso05_gpio_gp14 + &kso06_gpio_gp13 + &kso07_gpio_gp12 + &kso08_gpio_gp11 + &kso09_gpio_gp10 + &kso10_gpio_gp07 + &kso11_gpio_gp06 + &kso12_gpio_gp05 + >; + pinctrl-names = "default", "sleep"; }; diff --git a/zephyr/program/nissa/craask/project.conf b/zephyr/program/nissa/craask/project.conf index b7f31cee63..85cef7caba 100644 --- a/zephyr/program/nissa/craask/project.conf +++ b/zephyr/program/nissa/craask/project.conf @@ -13,3 +13,5 @@ CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y + +CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST=y diff --git a/zephyr/program/nissa/craask/src/keyboard.c b/zephyr/program/nissa/craask/src/keyboard.c index 65229eb43f..1d2102b655 100644 --- a/zephyr/program/nissa/craask/src/keyboard.c +++ b/zephyr/program/nissa/craask/src/keyboard.c @@ -27,3 +27,19 @@ board_vivaldi_keybd_config(void) { return &craask_kb; } + +/* + * We have total 30 pins for keyboard connecter {-1, -1} mean + * the N/A pin that don't consider it and reserve index 0 area + * that we don't have pin 0. + */ +const int keyboard_factory_scan_pins[][2] = { + { -1, -1 }, { 0, 5 }, { 1, 1 }, { 1, 0 }, { 0, 6 }, { 0, 7 }, + { -1, -1 }, { -1, -1 }, { 1, 4 }, { 1, 3 }, { -1, -1 }, { 1, 6 }, + { 1, 7 }, { 3, 1 }, { 2, 0 }, { 1, 5 }, { 2, 6 }, { 2, 7 }, + { 2, 1 }, { 2, 4 }, { 2, 5 }, { 1, 2 }, { 2, 3 }, { 2, 2 }, + { 3, 0 }, { -1, -1 }, { 0, 4 }, { -1, -1 }, { 8, 2 }, { -1, -1 }, + { -1, -1 }, +}; +const int keyboard_factory_scan_pins_used = + ARRAY_SIZE(keyboard_factory_scan_pins); -- cgit v1.2.1 From 70ddb59e62ce02cb48e180a8080ceb4a83859ff8 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 24 Oct 2022 11:22:38 -0700 Subject: chip/mchp: Fix clang compilation error When building with clang, it fails with: chip/mchp/lfw/ec_lfw.c:310:2: error: non-ASM statement in naked function is not supported uart_puts("EXCEPTION!\nTriggering watchdog reset\n"); ^ chip/mchp/lfw/ec_lfw.h:25:41: note: attribute is here void fault_handler(void) __attribute__((naked)); ^ BRANCH=none BUG=b:172020503 TEST=./util/build_with_clang.py Signed-off-by: Tom Hughes Change-Id: If998119e285b3a068623909a373f3ebaf426b2e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3977110 Reviewed-by: Eric Yilun Lin Code-Coverage: Zoss --- chip/mchp/lfw/ec_lfw.c | 7 ++++++- util/build_with_clang.py | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/chip/mchp/lfw/ec_lfw.c b/chip/mchp/lfw/ec_lfw.c index dfd9814e6e..3a9d7160dc 100644 --- a/chip/mchp/lfw/ec_lfw.c +++ b/chip/mchp/lfw/ec_lfw.c @@ -305,7 +305,7 @@ void uart_init(void) } #endif /* #ifdef CONFIG_UART_CONSOLE */ -void fault_handler(void) +noreturn void watchdog_reset(void) { uart_puts("EXCEPTION!\nTriggering watchdog reset\n"); /* trigger reset in 1 ms */ @@ -315,6 +315,11 @@ void fault_handler(void) ; } +void fault_handler(void) +{ + asm("b watchdog_reset"); +} + void jump_to_image(uintptr_t init_addr) { void (*resetvec)(void) = (void (*)(void))init_addr; diff --git a/util/build_with_clang.py b/util/build_with_clang.py index a0afb8a4cd..455cd1f1c0 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -75,6 +75,11 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "wand", "zed", "zinger", + # Boards that use CHIP:=mchp + # git grep --name-only 'CHIP:=mchp' | sed 's#board/\(.*\)/build.mk#"\1",#' + "adlrvpp_mchp1727", + "mchpevb1", + "reef_mchp", # Boards that use CHIP:=max32660 # git grep --name-only 'CHIP:=max32660' | sed 's#board/\(.*\)/build.mk#"\1",#' "max32660-eval", @@ -285,10 +290,7 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ "willow", # overflows flash # Boards that use CHIP:=mchp # git grep --name-only 'CHIP:=mchp' | sed 's#board/\(.*\)/build.mk#"\1",#' - "adlrvpp_mchp1521", # compilation errors - "adlrvpp_mchp1727", # compilation errors - "mchpevb1", # compilation errors - "reef_mchp", # compilation errors + "adlrvpp_mchp1521", # overflows flash # Boards that use CHIP:=npcx "garg", # overflows flash "gelarshie", # overflows flash -- cgit v1.2.1 From 3ec3123fe184197b3a5c255592ba4b5355208442 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 4 Nov 2022 11:22:34 -0600 Subject: ec: Fix stack smashing Tests are printing a message after passing "Stack smashing detected" Fix this by refusing to print a stacktrace if sz - offset would be a negative number. BRANCH=None BUG=None TEST=Ran fan test LOW_COVERAGE_REASON=core/host is only test code Signed-off-by: Jeremy Bettis Change-Id: I1587b7b1388132fc18c12957201cd20236ec8f41 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005657 Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Commit-Queue: Jeremy Bettis Reviewed-by: Peter Marheine Code-Coverage: Zoss --- core/host/stack_trace.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/host/stack_trace.c b/core/host/stack_trace.c index f8918b1c57..14d6abcab2 100644 --- a/core/host/stack_trace.c +++ b/core/host/stack_trace.c @@ -40,6 +40,11 @@ static void __attribute__((noinline)) _task_dump_trace_impl(int offset) int i, nb; sz = backtrace(trace, MAX_TRACE); + if (sz < offset) { + fprintf(stderr, "Can't print backtrace: %ld < %d\n", sz, + offset); + return; + } messages = backtrace_symbols(trace + offset, sz - offset); for (i = 0; i < sz - offset; ++i) { -- cgit v1.2.1 From f6f538b30c0ab39e604c98cdb1b5c80864d68671 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 7 Nov 2022 18:49:23 +0000 Subject: gitlab: Switch to new docker image, and remove pip Switch to a new docker image that includes g++-multilib and contains the pip packages pre-installed. BRANCH=None BUG=b:243712810 TEST=Ran zephyr-coverage step locally Change-Id: Ib1289ba356641729deb41970952f46294a33edf2 Signed-off-by: Jeremy Bettis Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010000 Reviewed-by: Yuval Peress Commit-Queue: Yuval Peress Tested-by: Jeremy Bettis Code-Coverage: Zoss Auto-Submit: Jeremy Bettis Commit-Queue: Jeremy Bettis --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f65ddfa9e..77d7d0a3a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -image: jbettis/ubuntu-07sep22 +image: jbettis/ubuntu-07nov22 # You can update that image using this repo: # https://gitlab.com/zephyr-ec/gitlab-ci-runner/-/tree/main @@ -78,7 +78,6 @@ before_script: # Install Python and packages - python3 -V # Print out python version for debugging - python3 -m pip install "${EC_DIR}/zephyr/zmake[tests]" --user - - python3 -m pip install pyyaml packaging ply psutil 'pyelftools>=0.28' - export PATH="$PATH:$HOME/.local/bin" - export PYTHONIOENCODING=utf-8 # Build directory -- cgit v1.2.1 From d81eb64c92a80bcc7211bf522f91a6839d6fc8a5 Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Mon, 31 Oct 2022 15:21:05 -0600 Subject: Add ectool command tabletmode Add the ectool command tabletmode. This matches the EC console command tabletmode, which turns tablet mode on/off. BRANCH=none BUG=b:256015402 TEST=ectool tabletmode on 22-11-03 16:01:49.043 [151.513200 HC 0x0002] 22-11-03 16:01:51.496 [151.515300 HC 0x000b] 22-11-03 16:01:51.501 [15[151.520400 event clear 0x0000000010000000] 22-11-03 16:01:51.504 [151.523200 ACPI query = 29] 22-11-03 16:01:51.507 1.516400 HC 0x0031] 22-11-03 16:01:51.510 [151.517200 tablet mode enabled] 22-11-03 16:01:51.512 [151.518000 mkbp switches: 3] 22-11-03 16:01:51.518 [151.519200 event set 0x0000000010000000] 22-11-03 16:01:51.521 [151.527200 HC 0x0067 err 9] 22-11-03 16:01:51.527 [151.533000 lid-accel ODR: 12500 - roundup 1 from config 0 [AP 12500]] TEST=ectool tabletmode off 22-11-03 16:02:17.579 [180.879700 HC 0x0002] 22-11-03 16:02:21.199 [180.882200 HC 0x000b] 22-11-03 16:02:21.205 [180.883300 HC 0x003[180.887300 event clear 0x0000000010000000] 22-11-03 16:02:21.210 [180.891000 ACPI query = 29] 22-11-03 16:02:21.213 1] 22-11-03 16:02:21.213 [180.884100 tablet mode disabled] 22-11-03 16:02:21.216 [180.884800 mkbp switches: 1] 22-11-03 16:02:21.221 [180.885600 event set 0x0000000010000000] 22-11-03 16:02:21.224 [180.897300 HC 0x0067 err 9] 22-11-03 16:02:21.230 [180.900500 lid-accel ODR: 12500 - roundup 1 from config 1 [AP 0]] TEST=ectool tabletmode reset 22-11-03 16:02:54.397 [216.057600 HC 0x0002] 22-11-03 16:02:56.776 [216.060100 HC 0x000b] 22-11-03 16:02:56.782 [216.061200 HC 0x0031[216.065300 event clear 0x0000000010000000] 22-11-03 16:02:56.787 [216.069000 ACPI query = 29] 22-11-03 16:02:56.790 ] 22-11-03 16:02:56.790 [216.062000 tablet mode disabled] 22-11-03 16:02:56.793 [216.062800 mkbp switches: 1] 22-11-03 16:02:56.798 [216.063500 event set 0x0000000010000000] 22-11-03 16:02:56.801 [216.073700 HC 0x0067 err 9] Change-Id: I1fd435dc2ac32e94384402407c7efaf6997387e2 Signed-off-by: Tim Van Patten Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3994296 Reviewed-by: Raul Rangel Reviewed-by: Diana Z Code-Coverage: Zoss --- util/ectool.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/util/ectool.cc b/util/ectool.cc index 0b3ee18791..09673f7fd6 100644 --- a/util/ectool.cc +++ b/util/ectool.cc @@ -33,6 +33,7 @@ #include "lock/gec_lock.h" #include "misc_util.h" #include "panic.h" +#include "tablet_mode.h" #include "usb_pd.h" /* Maximum flash size (16 MB, conservative) */ @@ -313,6 +314,8 @@ const char help_str[] = " Display system info.\n" " switches\n" " Prints current EC switch positions\n" + " tabletmode [on | off | reset]\n" + " Manually force tablet mode to on, off or reset.\n" " temps \n" " Print temperature and temperature ratio between fan_off and\n" " fan_max values, which could be a fan speed if it's controlled\n" @@ -7271,6 +7274,37 @@ int cmd_switches(int argc, char *argv[]) return 0; } +int cmd_tabletmode(int argc, char *argv[]) +{ + struct ec_params_set_tablet_mode p; + + if (argc != 2) + return EC_ERROR_PARAM_COUNT; + + memset(&p, 0, sizeof(p)); + if (argv[1][0] == 'o' && argv[1][1] == 'n') { + p.tablet_mode = TABLET_MODE_FORCE_TABLET; + } else if (argv[1][0] == 'o' && argv[1][1] == 'f') { + p.tablet_mode = TABLET_MODE_FORCE_CLAMSHELL; + } else if (argv[1][0] == 'r') { + // Match tablet mode to the current HW orientation. + p.tablet_mode = TABLET_MODE_DEFAULT; + } else { + return EC_ERROR_PARAM1; + } + + int rv = ec_command(EC_CMD_SET_TABLET_MODE, 0, &p, sizeof(p), NULL, 0); + rv = (rv < 0 ? rv : 0); + + if (rv < 0) { + fprintf(stderr, "Failed to set tablet mode, rv=%d\n", rv); + } else { + printf("\n"); + printf("SUCCESS. The tablet mode has been set.\n"); + } + return rv; +} + int cmd_wireless(int argc, char *argv[]) { char *e; @@ -11023,6 +11057,7 @@ const struct command commands[] = { { "sysinfo", cmd_sysinfo }, { "port80flood", cmd_port_80_flood }, { "switches", cmd_switches }, + { "tabletmode", cmd_tabletmode }, { "temps", cmd_temperature }, { "tempsinfo", cmd_temp_sensor_info }, { "test", cmd_test }, -- cgit v1.2.1 From ab3d72c29309591e4b04678e804271a77e77020e Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 4 Nov 2022 14:17:08 -0600 Subject: util: Fix lint errors in run_host_test Fixed all warnings from cros lint util/run_host_test BRANCH=None BUG=b:256073822 TEST=cros lint Signed-off-by: Jeremy Bettis Change-Id: I7e80dc2cc4c2b460d3b93353b51ed9fa76ecfcd1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4004891 Code-Coverage: Zoss Commit-Queue: Jeremy Bettis Auto-Submit: Jeremy Bettis Commit-Queue: Edward Hill Tested-by: Jeremy Bettis Reviewed-by: Edward Hill --- util/run_host_test | 82 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/util/run_host_test b/util/run_host_test index d1fac8f2ac..3ee8ccc7ed 100755 --- a/util/run_host_test +++ b/util/run_host_test @@ -26,6 +26,7 @@ class TestResult(enum.Enum): @property def reason(self): + """Return a map of test result enums to descriptions.""" return { TestResult.SUCCESS: 'passed', TestResult.FAIL: 'failed', @@ -35,11 +36,12 @@ class TestResult(enum.Enum): def run_test(path, timeout=10): + """Runs a test.""" start_time = time.monotonic() env = dict(os.environ) env['ASAN_OPTIONS'] = 'log_path=stderr' - proc = subprocess.Popen( + with subprocess.Popen( [path], bufsize=0, stdin=subprocess.PIPE, @@ -47,47 +49,48 @@ def run_test(path, timeout=10): env=env, encoding='utf-8', errors='replace', - ) - - # Put the output pipe in non-blocking mode. We will then select(2) - # on the pipe to know when we have bytes to process. - os.set_blocking(proc.stdout.fileno(), False) - - try: - output_buffer = io.StringIO() - while True: - select_timeout = timeout - (time.monotonic() - start_time) - if select_timeout <= 0: - return TestResult.TIMEOUT, output_buffer.getvalue() - - readable, _, _ = select.select( - [proc.stdout], [], [], select_timeout) - - if not readable: - # Indicates that select(2) timed out. - return TestResult.TIMEOUT, output_buffer.getvalue() - - output_buffer.write(proc.stdout.read()) - output_log = output_buffer.getvalue() - - if 'Pass!' in output_log: - return TestResult.SUCCESS, output_log - if 'Fail!' in output_log: - return TestResult.FAIL, output_log - if proc.poll(): - return TestResult.UNEXPECTED_TERMINATION, output_log - finally: - # Check if the process has exited. If not, send it a SIGTERM, wait for - # it to exit, and if it times out, kill the process directly. - if not proc.poll(): - try: - proc.terminate() - proc.wait(timeout) - except subprocess.TimeoutExpired: - proc.kill() + ) as proc: + + # Put the output pipe in non-blocking mode. We will then select(2) + # on the pipe to know when we have bytes to process. + os.set_blocking(proc.stdout.fileno(), False) + + try: + output_buffer = io.StringIO() + while True: + select_timeout = timeout - (time.monotonic() - start_time) + if select_timeout <= 0: + return TestResult.TIMEOUT, output_buffer.getvalue() + + readable, _, _ = select.select( + [proc.stdout], [], [], select_timeout) + + if not readable: + # Indicates that select(2) timed out. + return TestResult.TIMEOUT, output_buffer.getvalue() + + output_buffer.write(proc.stdout.read()) + output_log = output_buffer.getvalue() + + if 'Pass!' in output_log: + return TestResult.SUCCESS, output_log + if 'Fail!' in output_log: + return TestResult.FAIL, output_log + if proc.poll(): + return TestResult.UNEXPECTED_TERMINATION, output_log + finally: + # Check if the process has exited. If not, send it a SIGTERM, wait + # for it to exit, and if it times out, kill the process directly. + if not proc.poll(): + try: + proc.terminate() + proc.wait(timeout) + except subprocess.TimeoutExpired: + proc.kill() def parse_options(argv): + """Parse command line flags.""" parser = argparse.ArgumentParser() parser.add_argument('-t', '--timeout', type=float, default=120, help='Timeout to kill test after.') @@ -101,6 +104,7 @@ def parse_options(argv): def main(argv): + """The main function.""" opts = parse_options(argv) # Tests will be located in build/host, unless the --coverage flag was -- cgit v1.2.1 From ba4a8bacfbf7a92d68e7f4e70fd51c8b48cdfc0d Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 20 Oct 2022 11:37:46 -0600 Subject: zephyr: Update documentation for project organization Update the documentation for the program and project organization. BUG=b:254064666 BRANCH=none TEST=View docs in preview mode. Signed-off-by: Keith Short Change-Id: Ifd647eafa9e0ca9d1d60528fa75f54244b154426 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3968445 Code-Coverage: Zoss Reviewed-by: Wai-Hong Tam --- docs/zephyr/README.md | 2 +- docs/zephyr/project_config.md | 460 +++++++++++++++++++++++++++--- docs/zephyr/zephyr_battery.md | 5 +- docs/zephyr/zephyr_charger.md | 6 +- docs/zephyr/zephyr_leds.md | 8 +- docs/zephyr/zephyr_mkbp.md | 2 +- docs/zephyr/zephyr_new_board_checklist.md | 2 +- docs/zephyr/zephyr_temperature_sensor.md | 2 +- docs/zephyr/zephyr_troubleshooting.md | 8 +- 9 files changed, 436 insertions(+), 59 deletions(-) diff --git a/docs/zephyr/README.md b/docs/zephyr/README.md index 3b8b8dc05e..84239d3b05 100644 --- a/docs/zephyr/README.md +++ b/docs/zephyr/README.md @@ -110,7 +110,7 @@ The following provides an overview of the sub-directories found under sub-directory. * `zephyr/linker/` - Linker directive files used to construct the Zephyr EC binaries. -* `zephyr/projects/` - Program-specific configurations for each program +* `zephyr/program/` - Program-specific configurations for each program supported by Zephyr. * `zephyr/shim/` - Source code that adapts the legacy EC APIs to the equivalent Zephyr OS API. diff --git a/docs/zephyr/project_config.md b/docs/zephyr/project_config.md index f930908502..f81cc083c9 100644 --- a/docs/zephyr/project_config.md +++ b/docs/zephyr/project_config.md @@ -3,29 +3,174 @@ Project Configuration [TOC] -## Setting up a new program ("reference board" or "baseboard") - -Unlike the legacy EC codebase, Zephyr projects all live together in -one big happy directory. The intent of this design is to encourage -code-sharing between projects, and reduce the amount of copy/paste -that is required to bring up a new project. This directory can, but -does not have to, correlate to the unified build Chrome OS board, -however firmware authors can always choose a different structure if it -makes sense for the specific scenario. As a hypothetical example, -similar Chromeboxes and Chromebooks may wish to share the Zephyr EC -project directory instead of use separate directories, even if they -are using a different unified build board. - -To set up a new EC program, create a new directory under -[`zephyr/projects`](../../zephyr/projects) with the following files: - -- `BUILD.py` - specifies which builds can be made from this directory, - and what the device-tree overlays and Kconfig files are for each - build. -- `CMakeLists.txt` - Baseboard-specific C files can be listed here. -- `prj.conf` (optional) - Default Kconfig settings for all projects. -- `Kconfig` (optional) - Set options for your reference design here, - which variants can use to install optional C sources. +## Overview + +This document defines the organization of the program and project specific files +needed by Zephyr EC projects. + +The goals of the project organization include: + +* Minimize code duplication, allowing multiple projects to share common + configuration options and devicetree nodes. +* Define the set of files required by each project. +* Define the best practices for devicetrees. + + +### Glossary + +- **program**: The name of a Chromebook reference design. The **program** + includes all Chromebooks based on a single AP SoC, such as Intel MeteorLake, + Qualcomm 7c G3, or AMD Mendocino. The **program** corresponds to a single + board overlay in the ChromeOS SDK. The term *baseboard* is often used as a + synonym for **program**. + +- **project**: The name of a specific Chromebook model or variant. All + Chromebook **programs** contain at least one **project** which serves as the + reference design(s) for the **program**. The reference **project** may or may + not use the same name as the **program**. For example, the reference + **project** for the skyrim **program** is also called skyrim. The corsola + **program** included two reference **projects**, kingler and krabby. For the + legacy ECOS builds, *board* was used as a synonym for **project**. + +This document uses bold to highlight the terms **program** and **project** to +reference the definitions above. + +## Directory Structure + +The [`zephyr/program`](../../zephyr/program) contains the **program** and +**project** configuration files for all Zephyr based EC builds. + +### `zephyr/program` directory + +Each **program** has it's own subdirectory under `zephyr/program`. + +``` +zephyr/program/ +├── brya/ +├── corsola/ +├── herobrine/ +├── intelrvp/ +├── it8xxx2_evb/ +├── minimal/ +├── nissa/ +├── npcx_evb/ +├── rex/ +├── skyrim/ +└── trogdor/ +``` + +> The [`zephyr/program/minimal`](../../zephyr/program/minimal/) **program** +contains example EC projects that demonstrate how to build a Zephyr EC with the +minimum feature set enabled. These projects require only a working UART on the +target board. + +### `zephyr/program/`**``**`/` Directory Overview + +Each **program** subdirectory contains a subdirectory foreach each **project**, +including a subdirectory for the reference **project**. + +The minimum configuration for a **program** named *skyrim* with just a single +reference **project**, also named *skyrim*, is shown below. + +``` +zephyr/program/skyrim/ +├── include/ +│ └── .h +├── skyrim/ +│ ├── include/ +│ │ └── .h +│ ├── src/ +│ │ └── .c +│ ├── CMakeLists.txt +│ ├── project.conf +│ └── project.overlay +├── src/ +│ └── .c +├── BUILD.py +├── CMakeLists.txt +├── Kconfig +├── program.conf +└── .dtsi +``` + +#### `zephyr/program/`**``**`/` Directory Details + +Description of the files and directories found directly in the **** +level directory. Note that all paths are relative to the `zephyr/program/` +directory. + +- **``**`/`: Top level directory for the **program**. [skyrim] is the + *program* name in the example above. +- **``**`/include/`: Directory containing the header files common to + all **projects** in the **program**. Use of **program** level includes is + discouraged. Instead, consider creating a generic driver that can be shared + across all **programs**. +- **``**`/src/`: Directory containing the C source files common to all + **projects** in the **program**. +- [**``**`/BUILD.py`](#build_py): Defines which **projects** can be + made from this directory. +- [**``**`/CMakeLists.txt`](#cmakelists_txt): CMake file for the + **program**. +- [**``**`/Kconfig`](#kconfig) - Defines new Kconfig options, used by + all **projects** in the **program**. +- [**``**`/program.conf`](#program_conf) - Sets the default Kconfig + settings for all **projects**. +- **``**`/.dtsi` - One or more devicetree files, organized + by the hardware module or EC feature. See the [Devicetree Best + Practices](#devicetree-best-practices) section for additional information. +- **``**`/`**``**`/`: Top level directory for the + **. Create a separate directory for each **project** defined by the + **program**. + +### `zephyr/program/`**``**`/`**``**`/` Directory Details + +Each **project** provides the following files. Note that all paths are relative +to the `zephyr/program/`**``**`/` directory. + +- **``**`/include/`: The **project** may optionally provide a public + include directory, but this is discouraged. There are some exceptions where + the legacy EC code expects the project to define a public header, such as the + keyboard_customization.h file. +- **``**`/src/`: Directory containing the C source files specific to + the **project**. +- [**``**`/CMakeLists.txt`](#cmakelists_txt): CMake file for the + **project**. +- [**``**`/project.conf`](#project_conf): Kconfig settings for the + **project**. +- [**``**`/project.overlay`](#project_overlay): Main devicetree overlay + for the **project**. + +Creation of custom C source files specific to the **program** or **project** is +discouaraged. You can usually project manage project specific settings with +Kconfig and devicetree changes only. + +Note that **program** and **project** custom C files are still subject to the +same unit test requirements. So all custom C files also require that you write +tests. + +## Setting up a new **program** + +To set up a new EC **program**, create a new directory under +[`zephyr/program`] with the organization shown below. +Note that for this example, the new **program** is called "my_program", and the +reference **project** is called "my_reference_project". + +> Tip - Copy one the **projects** defined by the [*minimal*] **program** to +> start with the bare miminimum of features required to boot the Zephyr EC +> appliation. Then follow the steps in the detailed in [Creating a New Zephyr EC +> Project]. + +``` +zephyr/program/my_program/ +├── my_reference_project/ +│ ├── CMakeLists.txt +│ ├── project.conf +│ └── project.overlay +├── BUILD.py +├── CMakeLists.txt +├── Kconfig +└── program.conf +``` An in-depth example of each file is given below: @@ -50,18 +195,24 @@ When `BUILD.py` is sourced, the following two globals are defined: Google codename). This name must be unique amongst all projects known to `zmake`, and `zmake` will error if you choose a conflicting name. -- `zephyr_board` (required): The name of the Zephyr board to use for - the project. The Zephyr build system expects a Zephyr board - directory under `boards/${ARCH}/${ZEPHYR_BOARD_NAME}`. **Note:** - the concept of a Zephyr board does not align with the Chrome OS - concept of a board: for most projects this will typically be the - name of the EC chip used, not the name of the model or overlay. +- `zephyr_board` (required): The name of the EC chip used. **Note:** the concept + of a Zephyr board does not align with the ChromeOS concept of a board. The + Zephyr build system requires a set of devicetree and Kconfig files under under + `boards/${ARCH}/${ZEPHYR_BOARD_NAME}`. For the Zephyr EC application, the EC + chip is mapped onto the Zephyr board organization. Supported `zephyr_boards` + include: + - `mec1727`: Microchip MEC1727, 416 KiB RAM, 512 KiB flash + - `npcx7`: Nuvoton NPCX7m7FC, 384 KiB, 512 KiB flash + - `npcx9m3f`: Nuvoton NPCX9m3F, 320 KiB RAM, 512 KiB flash + - `npcx9m7f`: Nuvoton NPCX9m7F, 384 KiB RAM, 1 MiB flash + - `it81202bx`: ITE IT81202, 60 KiB RAM, 1 MiB flash + - `it81302bx`: ITE IT81302, 60 KiB RAM, 1 MiB flash - `supported_toolchains` (required): A list of the toolchain names - supported by the build. Valid values are `coreboot-sdk`, `host`, - `llvm`, and `zephyr`. Note that only `coreboot-sdk` and `llvm` are - supported in the chroot, and all projects must be able to build in - the chroot, so your project must at least list one of `coreboot-sdk` - or `llvm`. + supported by the build. Valid values are: + - `coreboot-sdk`: only supported in the chroot + - `host`: used for unit and integration tests + - `llvm`: only supported in the chroot + - `zephyr`: only supported outside the chroot - `output_packer` (required): An output packer type which defines which builds get generated, and how they get assembled together into a binary. @@ -77,9 +228,22 @@ When `BUILD.py` is sourced, the following two globals are defined: be used when running the test. Instances of `{test_temp_dir}` inside of an argument will be replaced with a path to a temporary directory guaranteed to be unique for the current execution. -- `dts_overlays` (optional): A list of files which should be - concatenated together and applied as a Zephyr device-tree overlay. - Defaults to no overlays (empty list). +- `dts_overlays` (optional): A list of files which should be concatenated + together and applied as a Zephyr device-tree overlay. The recommended setting + is to select the **project** specific devicetree overlay file. + + ``` python + dts_overlays=[here / project_name / "project.overlay"] + ``` + +- `kconfig_files` (optional): A list of files that contain the Kconfig settings + for the **project**. The recommended setting is select the **program** + configuration file followed by the **project** configuration file. + + ``` python + kconfig_files=[here / "program.conf", here / / "project.conf",] + ``` + - `project_dir` (optional): The path to where `CMakeLists.txt` and `Kconfig` can be found for the project, defaulting to `here`. @@ -113,18 +277,33 @@ This file, should at minimum contain the following: cmake_minimum_required(VERSION 3.20.1) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") -project(ec) +project(**project**) +``` + +If your **program** provides any C files, add them to your program CMake file +using `zephyr_library_sources()`. + +``` cmake +zephyr_library_sources("src/my_program_source.c") +``` + +For your **project** C files, create **`/`**`CMakeLists.txt` and use +`add_subdirectory()` to include the **project** CMake file. + +``` cmake +add_subdirectory("my_reference_project") ``` -You may additionally want to specify any C files your project needs -using `zephyr_library_sources`. If you need to add extra include -directories, use `cros_ec_library_include_directories`. +Add the requires `zephyr_library_souces()` calls to the +**`/`**`CMakeLists.txt` file. -### prj.conf and prj_${project_name}.conf +If your **program** or **project** provides a public header, make the include +directory visible to rest of the code using +`cros_ec_library_include_directories()`. -`prj.conf` has default Kconfig settings for all projects, and -`prj_${project_name}.conf` can contain overrides for certain projects. -The format is `KEY=VALUE`, as typical for Kconfig. +``` cmake +cros_ec_library_include_directories("include") +``` ### Kconfig @@ -136,6 +315,33 @@ The file must end with a single line that reads `source "Kconfig.zephyr"`. Note that this file is optional, so it's recommended to only include it if you really need it. +### program.conf + +`program.conf` has default Kconfig settings for all **projects** defined for the +**program**. The format is `KEY=VALUE`, as typical for Kconfig. + +### project.conf + +`project.conf` has the Kconfig settings for a single **project**. The format is +`KEY=VALUE`, as typical for Kconfig. + +Kconfig settings in `project.conf` take precedence over the Kconfig settings +from `program.conf`. + +### project.overlay + +`project.overlay` is the main devicetree overlay for the **project**. The +`project.overlay` contains the following components: +- One or more `#include` statements to add devicetrees defined by the + **program** into project. +- `/delete-node/` statements to remove specific devicetree nodes defined by the + **program** devicetrees. +- New devicetree nodes for **project** specific settings that are not provided + by any **program** devicetrees. + +> Tip: After building your **project**, you can view the final devicetree in the +file `build/zephyr/`**``**`/build-ro/zephyr/zephyr.dts`. + ## Setting up a new variant of an EC program **Unlike our legacy EC, there are no files or directories to copy and @@ -194,3 +400,167 @@ With this simple variant syntax, lists (like Kconfig files and DTS overlays) are concatenated. This means it's not possible to remove files during variant registration for this syntax, so it's only recommended for the simple case. + +## Devicetree Best Practices + +Below are the best practices for devicetree organization: + +* Split the devicetree across multiple files, organized by the functional block. + This organization applies to the shared **program** devicetrees only. + * FW_CONFIG + * GPIOs + * I2C + * Interrupts + * Keyboard + * LEDs + * Sensors + * Thermal (fans and temperature sensors) + * USB-C +* When creating **program**, usually with a single reference project, add the + shared devicetree files in the program directory, separated by the functional + area noted above. +* Each project creates a `project.overlay` file, and uses `#include` statements + to add shared devicetree files from the program directory. An example + project.overlay for the skyrim project is shown below. + + ``` c + /* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + /* Skyrim program common DTS includes */ + #include "../adc.dtsi" + #include "../fan.dtsi" + #include "../gpio.dtsi" + #include "../i2c.dtsi" + #include "../interrupts.dtsi" + #include "../keyboard.dtsi" + #include "../motionsense.dtsi" + #include "../usbc.dtsi" + + /* Skyrim project node overrides */ + /* ... */ + ``` + +### Managing **project** specific settings + +When the **project** needs to make changes to the shared devicetree files, there +are two strategies: + +* For small changes, add the `/delete-node/` attribute to the `project.overlay` + file to remove the specific devices and devicetree nodes from the **project** + final devicetree. +* For larger changes, remove the corresponding `#include` statements from the + `project.overlay` file. Then,dDirectly add any required nodes to the + `project.overlay` file. + +In both cases, the shared devicetree file in the **program** directory is not +changed. + +### Small Devicetree Changes + +Examples of small devicetree changes include: +* Change the I2C peripheral address of a device. +* Changing USB-C related chips. +* Changing motionsense properties, such as the odr and ec-rate properties. +* Overriding a specific property of a node - for instance modifying the + `pinctrl-0` property to adjust the EC pins connected to a device driver. + +The example below demonstrates how to define a device in a **program** +devicetree file and then override the setting in the `project.overlay` file. + +* The herobrine program defines the TCPC at I2C address `0xb` in the file +`zephyr/program/herobrine/i2c.dtsi`. This I2C address is valid for the +herobrine, evoker, and villager projects while the hoglin project needs to +change the I2C address to `0x1b`. + + ``` c + /* zephyr/program/herobrine/i2c.dtsi */ + + &i2c1_0 { + status = "okay"; + /* ... */ + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; + }; + ```` +* The hoglin `project.overlay` file deletes the TCPC node at address `0xb` and +creates a new node at address `0x1b`. The node name “tcpc_port0” is kept the +same, so any references to this node name do not change, such as the USB-C port +configuration. + + ``` c + /* zephyr/program/herobrine/hoglin/project.overlay */ + + #include “../i2c.dtsi” + + &i2c1_0 { + /delete-node/ ps8xxx@b; + tcpc_port0: ps8xxx@1b { + compatible = "parade,ps8xxx"; + reg = <0x1b>; + }; + }; + ``` + +While it is also possible to change a device’s I2C address by directly +overriding the `reg` property, this should not be done. Changing only the `reg` +property causes a mismatch between the node name, `ps8xxx@b`, and the actual +device address, `0x1b`. + +Your `project.overlay` file can also directly override properties defined by the +**program** devicetree files. + +* The skyrim **program** sets the I2C clock frequency for first I2C bus to fast + (400 KHz). + ``` c + /* zephyr/program/skyrim/i2c.dtsi */ + &i2c0_0 { + status = "okay"; + label = "I2C_TCPC0"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + }; + ``` +* Override the I2C clock frequency to fast-plus (1 MHz) in the winterhold + `project.overlay`. + ``` c + /* zephyr/program/skyrim/winterhold/project.overlay */ + #include "../i2c.dtsi" + &i2c0_0 { + clock-frequency = ; + }; + ``` +### Large Devicetree Changes + +For large devicetree changes, the preference is to copy the relevant devicetree +fragment into the `project.overlay` file and edit the fragment directly. + +Examples of large devicetree changes (or changes that don’t benefit from using +the /delete-node/ attribute) include: +* GPIOs - specifically the “named-gpios” node. This integrates better with the + arbitrage and the pinmap utility, which auto-generates the EC GPIO settings + based on schematic data. +* Changes to the motionsense sensor types. Currently x86 architectures impose a + fixed ordering for the accelerometers and gryoscopes when accessed through the + LPC memory map (see the [`EC_MEMMAP_ACC_DATA`]). Deleting nodes changes the + order of the children under the motionsense-sense node and causes the test + [`hardware.SensorAccel`] to fail. Copy the motionsense nodes into the + project.overlay file and modify as required. +* LED policies - generally each OEM/ODM defines unique LED policies for their + designs to establish differentiation for their brand. There is little value to + creating common LED policies for all **projects** in the **program**. +* Batteries - batteries also are generally specific to the OEM/ODM. Define the + **project** batteries directly in the `project.overlay` file. + + +[skyrim]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform/ec/zephyr/program/skyrim +[`zephyr/program`]: ../../zephyr/program/ +[*minimal*]: ../../zephyr/program/minimal/ +[Creating a New Zephyr EC Project]: ./zephyr_new_board_checklist.md +[`EC_MEMMAP_ACC_DATA`]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform/ec/include/ec_commands.h;l=181 +[`hardware.SensorAccel`]: https://crsrc.org/o/src/platform/tast-tests/src/chromiumos/tast/local/bundles/cros/hardware/sensor_accel.go;drc=8fbf2c53960bc8917a6a01fda5405cad7c17201e;l=30 diff --git a/docs/zephyr/zephyr_battery.md b/docs/zephyr/zephyr_battery.md index 3dde8cb9cf..02ed5d424b 100644 --- a/docs/zephyr/zephyr_battery.md +++ b/docs/zephyr/zephyr_battery.md @@ -17,7 +17,8 @@ Refer to [Kconfig.battery] for all sub-options controlling battery behavior. #### Enable battery feature configs -Add battery configs to `ec/zephyr/projects/{project}/{board}/prj.conf`. +Add battery configs to either the [`program.conf`] or [`project.conf`] file for +your project. Example: @@ -271,3 +272,5 @@ Usage: [ectool]: ../ap-ec-comm.md [task]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/shim/include/shimmed_task_id.h [*node label*]: https://docs.zephyrproject.org/latest/build/dts/intro.html#dt-node-labels +[`program.conf`]: ./project_config.md#program_conf +[`project.conf`]: ./project_config.md#project_conf diff --git a/docs/zephyr/zephyr_charger.md b/docs/zephyr/zephyr_charger.md index 8bb4f8d3f5..0dc62f2b5d 100644 --- a/docs/zephyr/zephyr_charger.md +++ b/docs/zephyr/zephyr_charger.md @@ -20,7 +20,9 @@ charging configuration found in [Kconfig.usb_charger]. ### Example of enabled configs -In `ec/zephyr/projects/{project}/{board}/prj.conf`, one may add: +Enable and disable charger configs in either the [`program.conf`] or +[`project.conf`] file for your project. + ``` # Charger @@ -289,3 +291,5 @@ The [chargestate] command may also be invoked. [ectool]: ../docs/ap-ec-comm.md [mapping legacy I2C port numbers to Zephyr devicetree nodes]: ./zephyr_i2c.md#mapping-legacy-i2c-port-numbers-to-zephyr-devicetree-nodes [pwr_avg]: ./zephyr_battery.md#pwr_avg +[`program.conf`]: ./project_config.md#program_conf +[`project.conf`]: ./project_config.md#project_conf diff --git a/docs/zephyr/zephyr_leds.md b/docs/zephyr/zephyr_leds.md index b29b4ab610..bed81933eb 100644 --- a/docs/zephyr/zephyr_leds.md +++ b/docs/zephyr/zephyr_leds.md @@ -215,9 +215,9 @@ TODO: Enable support for ledtest [cros-ec,gpio_led_pins.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml [cros-ec,pwm_led_pins.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml [cros-ec,pwm_led_pin_config.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,pwm-led-pin-config.yaml -[led_policy_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/skyrim/led_policy_skyrim.dts -[led_pins_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/skyrim/led_pins_skyrim.dts -[led_policy_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/herobrine/led_policy_herobrine.dts -[led_pins_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/herobrine/led_pins_herobrine.dts +[led_policy_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/skyrim/led_policy_skyrim.dts +[led_pins_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/skyrim/led_pins_skyrim.dts +[led_policy_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/herobrine/led_policy_herobrine.dts +[led_pins_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/herobrine/led_pins_herobrine.dts [Example CL enabling single port pwm based LEDs]: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3651490 [Example CL enabling dual port gpio based LEDs]: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3635067 diff --git a/docs/zephyr/zephyr_mkbp.md b/docs/zephyr/zephyr_mkbp.md index bedc550f7d..186ea9ce44 100644 --- a/docs/zephyr/zephyr_mkbp.md +++ b/docs/zephyr/zephyr_mkbp.md @@ -76,7 +76,7 @@ Possible enums to use in these nodes are specified in file: [MKBP event mask enu ## Examples -[Lazor wake-up masks](https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/trogdor/lazor/gpio.dts?q=ec-mkbp-host-event-wakeup-mask) +[Lazor wake-up masks](https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/trogdor/lazor/gpio.dts?q=ec-mkbp-host-event-wakeup-mask) For detailed descriptions of the MKBP and host event types, please see [ec_commands.h](/include/ec_commands.h) header file. diff --git a/docs/zephyr/zephyr_new_board_checklist.md b/docs/zephyr/zephyr_new_board_checklist.md index 9baaaf4c42..4b3917581b 100644 --- a/docs/zephyr/zephyr_new_board_checklist.md +++ b/docs/zephyr/zephyr_new_board_checklist.md @@ -37,7 +37,7 @@ Each feature includes the following sub-tasks: - **Example** - This section walks through a complete example for configuring an EC feature based on existing board implementation. -## Adding a new board to zmake +## Adding a new project to zmake Refer the [project configuration](project_config.md) documentation to add a new board project to zmake. diff --git a/docs/zephyr/zephyr_temperature_sensor.md b/docs/zephyr/zephyr_temperature_sensor.md index 8ee87a84f7..7be5f5ccaf 100644 --- a/docs/zephyr/zephyr_temperature_sensor.md +++ b/docs/zephyr/zephyr_temperature_sensor.md @@ -76,7 +76,7 @@ on Zephyr-based boards. Temperature sensors are declared as separate nodes and additional properties are defined by the `cros-ec,temp-sensors` node in the device tree. This example is -from [zephyr/projects/brya/temp_sensors.dts](../../zephyr/projects/brya/temp_sensors.dts): +from [zephyr/program/brya/temp_sensors.dts](../../zephyr/program/brya/temp_sensors.dts): ``` temp_ddr_soc: ddr_soc { diff --git a/docs/zephyr/zephyr_troubleshooting.md b/docs/zephyr/zephyr_troubleshooting.md index 646240ce18..a7a7716e5e 100644 --- a/docs/zephyr/zephyr_troubleshooting.md +++ b/docs/zephyr/zephyr_troubleshooting.md @@ -12,10 +12,10 @@ The build system lists the various overlay files specified by `BUILD.py`, for example: ``` --- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/projects/brya/adc.dts --- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/projects/brya/battery.dts --- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/projects/brya/cbi_eeprom.dts --- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/projects/brya/fan.dts +-- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/program/brya/adc.dts +-- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/program/brya/battery.dts +-- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/program/brya/cbi_eeprom.dts +-- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/program/brya/fan.dts ... ``` -- cgit v1.2.1 From 1736458970a8f2e7e70c47260d856da9f9c1466a Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Mon, 31 Oct 2022 12:34:56 -0700 Subject: tpcmv2: dpm: Rename attempt_mode_entry/exit functions This CL renames these two functions as part of DPM refactoring. In addition, the functions are moved in the file to be adjacent to the state handler functions. This CL does not change any functionality. Instead this change is intended to help track the changes to these 2 functions for the subsequent CL which adds a msg_wait state. BUG=b:194504052 BRANCH=none LOW_COVERAGE_REASON=trivial change which is only renaming 2 functions and moving their location in a file TEST=Verified that mode entry/exit is successful for DP, TBT, and USB4 on Voxel. ectool typeccontrol 0 -> exit mode ectool typeccontrol 2 0 -> DP ectool typeccontrol 2 1 -> TBT ectool typeccontrol 2 2 -> USB4 Signed-off-by: Scott Collyer Change-Id: I9ea39368ae819ade972eebb771f863d3c7e5bd58 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3965270 Code-Coverage: Zoss Commit-Queue: Scott Collyer Tested-by: Scott Collyer Reviewed-by: Abe Levkoy --- common/usbc/usb_pd_dpm.c | 464 +++++++++++++++++++++++------------------------ 1 file changed, 232 insertions(+), 232 deletions(-) diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index e9963811fc..b276dcbcad 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -342,236 +342,6 @@ void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid, } } -/* - * Requests that the PE send one VDM, whichever is next in the mode entry - * sequence. This only happens if preconditions for mode entry are met. If - * CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY is enabled, this function waits for the - * AP to direct mode entry. - */ -static void dpm_attempt_mode_entry(int port) -{ - int vdo_count = 0; - uint32_t vdm[VDO_MAX_SIZE]; - enum tcpci_msg_type tx_type = TCPCI_MSG_SOP; - bool enter_mode_requested = - IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true; - enum dpm_msg_setup_status status = MSG_SETUP_UNSUPPORTED; - - if (pd_get_data_role(port) != PD_ROLE_DFP) { - if (DPM_CHK_FLAG(port, DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT | - DPM_FLAG_ENTER_USB4)) - DPM_CLR_FLAG(port, DPM_FLAG_ENTER_DP | - DPM_FLAG_ENTER_TBT | - DPM_FLAG_ENTER_USB4); - /* - * TODO(b/168030639): Notify the AP that the enter mode request - * failed. - */ - return; - } - -#ifdef CONFIG_AP_POWER_CONTROL - /* - * Do not try to enter mode while CPU is off. - * CPU transitions (e.g b/158634281) can occur during the discovery - * phase or during enter/exit negotiations, and the state - * of the modes can get out of sync, causing the attempt to - * enter the mode to fail prematurely. - */ - if (!chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON)) - return; -#endif - /* - * If discovery has not occurred for modes, do not attempt to switch - * to alt mode. - */ - if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE || - pd_get_modes_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE) - return; - - if (dp_entry_is_done(port) || - (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && - tbt_entry_is_done(port)) || - (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port))) { - dpm_set_mode_entry_done(port); - return; - } - - /* - * If muxes are still settling, then wait on our next VDM. We must - * ensure we correctly sequence actions such as USB safe state with TBT - * entry or DP configuration. - */ - if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port)) - return; - - if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) && - IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && - DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY) && - !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) && - !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - pd_dpm_request(port, DPM_REQUEST_DATA_RESET); - DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); - return; - } - - if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) && - IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && - !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - return; - } - - /* Check if port, port partner and cable support USB4. */ - if (IS_ENABLED(CONFIG_USB_PD_USB4) && board_is_tbt_usb4_port(port) && - enter_usb_port_partner_is_capable(port) && - enter_usb_cable_is_capable(port) && - dpm_mode_entry_requested(port, TYPEC_MODE_USB4)) { - /* - * For certain cables, enter Thunderbolt alt mode with the - * cable and USB4 mode with the port partner. - */ - if (tbt_cable_entry_required_for_usb4(port)) { - vdo_count = ARRAY_SIZE(vdm); - status = tbt_setup_next_vdm(port, &vdo_count, vdm, - &tx_type); - } else { - pd_dpm_request(port, DPM_REQUEST_ENTER_USB); - return; - } - } - - /* If not, check if they support Thunderbolt alt mode. */ - if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && - board_is_tbt_usb4_port(port) && - pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP, - USB_VID_INTEL) && - dpm_mode_entry_requested(port, TYPEC_MODE_TBT)) { - enter_mode_requested = true; - vdo_count = ARRAY_SIZE(vdm); - status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type); - } - - /* If not, check if they support DisplayPort alt mode. */ - if (status == MSG_SETUP_UNSUPPORTED && - !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE) && - pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP, - USB_SID_DISPLAYPORT) && - dpm_mode_entry_requested(port, TYPEC_MODE_DP)) { - enter_mode_requested = true; - vdo_count = ARRAY_SIZE(vdm); - status = dp_setup_next_vdm(port, &vdo_count, vdm); - } - - /* Not ready to send a VDM, check again next cycle */ - if (status == MSG_SETUP_MUX_WAIT) - return; - - /* - * If the PE didn't discover any supported (requested) alternate mode, - * just mark setup done and get out of here. - */ - if (status != MSG_SETUP_SUCCESS && - !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) { - if (enter_mode_requested) { - /* - * TODO(b/168030639): Notify the AP that mode entry - * failed. - */ - CPRINTS("C%d: No supported alt mode discovered", port); - } - /* - * If the AP did not request mode entry, it may do so in the - * future, but the DPM is done trying for now. - */ - dpm_set_mode_entry_done(port); - return; - } - - if (status != MSG_SETUP_SUCCESS) { - dpm_set_mode_entry_done(port); - CPRINTS("C%d: Couldn't construct alt mode VDM", port); - return; - } - - /* - * TODO(b/155890173): Provide a host command to request that the PE send - * an arbitrary VDM via this mechanism. - */ - if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) { - dpm_set_mode_entry_done(port); - return; - } - - pd_dpm_request(port, DPM_REQUEST_VDM); -} - -static void dpm_attempt_mode_exit(int port) -{ - uint32_t vdm[VDO_MAX_SIZE]; - int vdo_count = ARRAY_SIZE(vdm); - enum dpm_msg_setup_status status = MSG_SETUP_ERROR; - enum tcpci_msg_type tx_type = TCPCI_MSG_SOP; - - /* First, try Data Reset. If Data Reset completes, all the alt mode - * state checked below will reset to its inactive state. If Data Reset - * is not supported, exit active modes individually. - */ - if (IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG)) { - if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) && - !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - pd_dpm_request(port, DPM_REQUEST_DATA_RESET); - DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); - return; - } else if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - return; - } - } - - /* TODO(b/209625351): Data Reset is the only real way to exit from USB4 - * mode. If that failed, the TCPM shouldn't try anything else. - */ - if (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port)) { - CPRINTS("C%d: USB4 teardown", port); - usb4_exit_mode_request(port); - } - - /* - * If muxes are still settling, then wait on our next VDM. We must - * ensure we correctly sequence actions such as USB safe state with TBT - * or DP mode exit. - */ - if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port)) - return; - - if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && tbt_is_active(port)) { - /* - * When the port is in USB4 mode and receives an exit request, - * it leaves USB4 SOP in active state. - */ - CPRINTS("C%d: TBT teardown", port); - tbt_exit_mode_request(port); - status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type); - } else if (dp_is_active(port)) { - CPRINTS("C%d: DP teardown", port); - status = dp_setup_next_vdm(port, &vdo_count, vdm); - } else { - /* Clear exit mode request */ - dpm_clear_mode_exit_request(port); - return; - } - - /* This covers error, wait mux, and unsupported cases */ - if (status != MSG_SETUP_SUCCESS) - return; - - if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) { - dpm_clear_mode_exit_request(port); - return; - } - - pd_dpm_request(port, DPM_REQUEST_VDM); -} - static void dpm_send_req_vdm(int port) { /* Set up VDM REQ msg that was passed in previously */ @@ -1238,6 +1008,236 @@ uint8_t pd_get_bist_share_mode(void) return bist_shared_mode_enabled; } +/* + * Requests that the PE send one VDM, whichever is next in the mode entry + * sequence. This only happens if preconditions for mode entry are met. If + * CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY is enabled, this function waits for the + * AP to direct mode entry. + */ +static void dpm_dfp_enter_mode_msg(int port) +{ + int vdo_count = 0; + uint32_t vdm[VDO_MAX_SIZE]; + enum tcpci_msg_type tx_type = TCPCI_MSG_SOP; + bool enter_mode_requested = + IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true; + enum dpm_msg_setup_status status = MSG_SETUP_UNSUPPORTED; + + if (pd_get_data_role(port) != PD_ROLE_DFP) { + if (DPM_CHK_FLAG(port, DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT | + DPM_FLAG_ENTER_USB4)) + DPM_CLR_FLAG(port, DPM_FLAG_ENTER_DP | + DPM_FLAG_ENTER_TBT | + DPM_FLAG_ENTER_USB4); + /* + * TODO(b/168030639): Notify the AP that the enter mode request + * failed. + */ + return; + } + +#ifdef CONFIG_AP_POWER_CONTROL + /* + * Do not try to enter mode while CPU is off. + * CPU transitions (e.g b/158634281) can occur during the discovery + * phase or during enter/exit negotiations, and the state + * of the modes can get out of sync, causing the attempt to + * enter the mode to fail prematurely. + */ + if (!chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON)) + return; +#endif + /* + * If discovery has not occurred for modes, do not attempt to switch + * to alt mode. + */ + if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE || + pd_get_modes_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE) + return; + + if (dp_entry_is_done(port) || + (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && + tbt_entry_is_done(port)) || + (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port))) { + dpm_set_mode_entry_done(port); + return; + } + + /* + * If muxes are still settling, then wait on our next VDM. We must + * ensure we correctly sequence actions such as USB safe state with TBT + * entry or DP configuration. + */ + if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port)) + return; + + if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) && + IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && + DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY) && + !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) && + !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { + pd_dpm_request(port, DPM_REQUEST_DATA_RESET); + DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); + return; + } + + if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) && + IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && + !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { + return; + } + + /* Check if port, port partner and cable support USB4. */ + if (IS_ENABLED(CONFIG_USB_PD_USB4) && board_is_tbt_usb4_port(port) && + enter_usb_port_partner_is_capable(port) && + enter_usb_cable_is_capable(port) && + dpm_mode_entry_requested(port, TYPEC_MODE_USB4)) { + /* + * For certain cables, enter Thunderbolt alt mode with the + * cable and USB4 mode with the port partner. + */ + if (tbt_cable_entry_required_for_usb4(port)) { + vdo_count = ARRAY_SIZE(vdm); + status = tbt_setup_next_vdm(port, &vdo_count, vdm, + &tx_type); + } else { + pd_dpm_request(port, DPM_REQUEST_ENTER_USB); + return; + } + } + + /* If not, check if they support Thunderbolt alt mode. */ + if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && + board_is_tbt_usb4_port(port) && + pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP, + USB_VID_INTEL) && + dpm_mode_entry_requested(port, TYPEC_MODE_TBT)) { + enter_mode_requested = true; + vdo_count = ARRAY_SIZE(vdm); + status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type); + } + + /* If not, check if they support DisplayPort alt mode. */ + if (status == MSG_SETUP_UNSUPPORTED && + !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE) && + pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP, + USB_SID_DISPLAYPORT) && + dpm_mode_entry_requested(port, TYPEC_MODE_DP)) { + enter_mode_requested = true; + vdo_count = ARRAY_SIZE(vdm); + status = dp_setup_next_vdm(port, &vdo_count, vdm); + } + + /* Not ready to send a VDM, check again next cycle */ + if (status == MSG_SETUP_MUX_WAIT) + return; + + /* + * If the PE didn't discover any supported (requested) alternate mode, + * just mark setup done and get out of here. + */ + if (status != MSG_SETUP_SUCCESS && + !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) { + if (enter_mode_requested) { + /* + * TODO(b/168030639): Notify the AP that mode entry + * failed. + */ + CPRINTS("C%d: No supported alt mode discovered", port); + } + /* + * If the AP did not request mode entry, it may do so in the + * future, but the DPM is done trying for now. + */ + dpm_set_mode_entry_done(port); + return; + } + + if (status != MSG_SETUP_SUCCESS) { + dpm_set_mode_entry_done(port); + CPRINTS("C%d: Couldn't construct alt mode VDM", port); + return; + } + + /* + * TODO(b/155890173): Provide a host command to request that the PE send + * an arbitrary VDM via this mechanism. + */ + if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) { + dpm_set_mode_entry_done(port); + return; + } + + pd_dpm_request(port, DPM_REQUEST_VDM); +} + +static void dpm_dfp_exit_mode_msg(int port) +{ + uint32_t vdm[VDO_MAX_SIZE]; + int vdo_count = ARRAY_SIZE(vdm); + enum dpm_msg_setup_status status = MSG_SETUP_ERROR; + enum tcpci_msg_type tx_type = TCPCI_MSG_SOP; + + /* First, try Data Reset. If Data Reset completes, all the alt mode + * state checked below will reset to its inactive state. If Data Reset + * is not supported, exit active modes individually. + */ + if (IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG)) { + if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) && + !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { + pd_dpm_request(port, DPM_REQUEST_DATA_RESET); + DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); + return; + } else if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { + return; + } + } + + /* TODO(b/209625351): Data Reset is the only real way to exit from USB4 + * mode. If that failed, the TCPM shouldn't try anything else. + */ + if (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port)) { + CPRINTS("C%d: USB4 teardown", port); + usb4_exit_mode_request(port); + } + + /* + * If muxes are still settling, then wait on our next VDM. We must + * ensure we correctly sequence actions such as USB safe state with TBT + * or DP mode exit. + */ + if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port)) + return; + + if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && tbt_is_active(port)) { + /* + * When the port is in USB4 mode and receives an exit request, + * it leaves USB4 SOP in active state. + */ + CPRINTS("C%d: TBT teardown", port); + tbt_exit_mode_request(port); + status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type); + } else if (dp_is_active(port)) { + CPRINTS("C%d: DP teardown", port); + status = dp_setup_next_vdm(port, &vdo_count, vdm); + } else { + /* Clear exit mode request */ + dpm_clear_mode_exit_request(port); + return; + } + + /* This covers error, wait mux, and unsupported cases */ + if (status != MSG_SETUP_SUCCESS) + return; + + if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) { + dpm_clear_mode_exit_request(port); + return; + } + + pd_dpm_request(port, DPM_REQUEST_VDM); +} + void dpm_run(int port, int evt, int en) { switch (local_state[port]) { @@ -1301,9 +1301,9 @@ static void dpm_ready_run(const int port) if (pd_get_data_role(port) == PD_ROLE_DFP) { /* Run DFP related DPM requests */ if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST)) - dpm_attempt_mode_exit(port); + dpm_dfp_exit_mode_msg(port); else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) - dpm_attempt_mode_entry(port); + dpm_dfp_enter_mode_msg(port); /* Run USB PD Power button state machine */ dpm_run_pd_button_sm(port); -- cgit v1.2.1 From b191de95537ad2617f21d83f282d33a5b803f31b Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 7 Nov 2022 15:24:57 -0700 Subject: zephyr: Add cmake files for host toolchain In order to allow building with the host toolchain inside the chroot, which should use /usr/bin/x86_64-pc-linux-gnu-gcc, add cmake files for the host toolchain, that uses the same cross compiler gcc configs with the cross compile target set to x86_64-pc-linux-gnu. BRANCH=None BUG=None TEST=ZEPHYR_TOOLCHAIN_VARIANT=host ./twister \ -x=CMAKE_VERBOSE_MAKEFILE=ON Signed-off-by: Jeremy Bettis Change-Id: I9148f9fc58ccb0cbbf278c467c21d7ae78d099d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011098 Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Commit-Queue: Tristan Honscheid Commit-Queue: Jeremy Bettis Reviewed-by: Tristan Honscheid Code-Coverage: Zoss --- zephyr/cmake/compiler/gcc/generic.cmake | 5 +++++ zephyr/cmake/toolchain/host/generic.cmake | 17 +++++++++++++++++ zephyr/cmake/toolchain/host/target.cmake | 5 +++++ 3 files changed, 27 insertions(+) create mode 100644 zephyr/cmake/compiler/gcc/generic.cmake create mode 100644 zephyr/cmake/toolchain/host/generic.cmake create mode 100644 zephyr/cmake/toolchain/host/target.cmake diff --git a/zephyr/cmake/compiler/gcc/generic.cmake b/zephyr/cmake/compiler/gcc/generic.cmake new file mode 100644 index 0000000000..8f41f59bee --- /dev/null +++ b/zephyr/cmake/compiler/gcc/generic.cmake @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +include("${ZEPHYR_BASE}/cmake/compiler/gcc/generic.cmake") diff --git a/zephyr/cmake/toolchain/host/generic.cmake b/zephyr/cmake/toolchain/host/generic.cmake new file mode 100644 index 0000000000..41ce729fa4 --- /dev/null +++ b/zephyr/cmake/toolchain/host/generic.cmake @@ -0,0 +1,17 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu) +set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}}) + +set(CC gcc) +set(CROSS_COMPILE "/usr/bin/${CROSS_COMPILE_TARGET}-") + +set(COMPILER gcc) +set(LINKER ld) +set(BINTOOLS gnu) + +set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib") + +message(STATUS "Found toolchain: host ${ARCH} (gcc/ld)") diff --git a/zephyr/cmake/toolchain/host/target.cmake b/zephyr/cmake/toolchain/host/target.cmake new file mode 100644 index 0000000000..9d540f97ff --- /dev/null +++ b/zephyr/cmake/toolchain/host/target.cmake @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +include("${ZEPHYR_BASE}/cmake/toolchain/host/target.cmake") -- cgit v1.2.1 From 0e069f3247492a9c6f25ce20b9e12c44ecd737de Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Mon, 7 Nov 2022 14:39:40 -0800 Subject: ctn730: Log optional NDEF message Currently, optional NDEF messages (0x1f) are logged as unknown events. This patch makes them logged with a proper name. BUG=b:245806799 BRANCH=None TEST=Redrix Signed-off-by: Daisuke Nojiri Change-Id: Ic0326a7358b2648654ec2b16222e5e72aecc742c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010581 Reviewed-by: Keith Short Code-Coverage: Zoss Reviewed-by: caveh jalali Commit-Queue: Keith Short --- driver/nfc/ctn730.c | 6 ++++++ driver/nfc/ctn730.h | 1 + 2 files changed, 7 insertions(+) diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c index e72f4459ad..4864d43080 100644 --- a/driver/nfc/ctn730.c +++ b/driver/nfc/ctn730.c @@ -66,6 +66,8 @@ static const char *_text_instruction(uint8_t instruction) return "CHARGING_STATE"; case WLC_CHG_CTRL_CHARGING_INFO: return "CHARGING_INFO"; + case WLC_CHG_CTRL_OPTIONAL_NDEF: + return "OPTIONAL_NDEF"; default: return "UNDEF"; } @@ -484,6 +486,10 @@ static int _process_payload_event(struct pchg *ctx, struct ctn730_msg *res) ctx->event = PCHG_EVENT_CHARGE_UPDATE; ctx->battery_percent = buf[0]; break; + case WLC_CHG_CTRL_OPTIONAL_NDEF: + if (len == 0) + return EC_ERROR_INVAL; + break; default: CPRINTS("Received unknown event (%d)", res->instruction); break; diff --git a/driver/nfc/ctn730.h b/driver/nfc/ctn730.h index 45314428a9..e1ae7ab754 100644 --- a/driver/nfc/ctn730.h +++ b/driver/nfc/ctn730.h @@ -32,6 +32,7 @@ #define WLC_CHG_CTRL_DEVICE_STATE 0b010010 #define WLC_CHG_CTRL_CHARGING_STATE 0b010100 #define WLC_CHG_CTRL_CHARGING_INFO 0b010101 +#define WLC_CHG_CTRL_OPTIONAL_NDEF 0b011111 /* WLC_HOST_CTRL_RESET constants */ #define WLC_HOST_CTRL_RESET_CMD_SIZE 1 -- cgit v1.2.1 From 004f930719cfa38aaf8619874560c3ab97e1883b Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Tue, 1 Nov 2022 11:33:09 +1100 Subject: Nissa: OCPC PID Controller hasn't been tuned for each Nissa board Re-tuned the OCPC PID controller for Nissa devices and added the ability to take into account the charger chip input error. BUG=b:249616030 TEST=Manually checked charging response in ChromeOS for Nereid and Nirwen; Scoped the battery voltage on Nereid and Nirwen; Logged data from EC console and plotted response over a full charging cycle from 1% to 100% charge; zmake build -a --clobber BRANCH=main Signed-off-by: Adam Mills Change-Id: Iddca075edf2629bdc03d50e10afb311ae260326e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995282 Commit-Queue: Andrew McRae Tested-by: Andrew McRae Reviewed-by: Peter Marheine Code-Coverage: Andrew McRae --- common/ocpc.c | 63 +++++++++++++++++++++++++++++---------- include/config.h | 3 ++ include/ocpc.h | 17 ++++++----- zephyr/Kconfig.charger | 7 +++++ zephyr/program/nissa/program.conf | 1 + zephyr/program/nissa/src/common.c | 11 +++++++ zephyr/shim/include/config_chip.h | 5 ++++ 7 files changed, 83 insertions(+), 24 deletions(-) diff --git a/common/ocpc.c b/common/ocpc.c index c27cf4efe5..88308e5bc7 100644 --- a/common/ocpc.c +++ b/common/ocpc.c @@ -58,6 +58,7 @@ static int k_d = KD; static int k_p_div = KP_DIV; static int k_i_div = KI_DIV; static int k_d_div = KD_DIV; +static int drive_limit = CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS; static int debug_output; static int viz_output; @@ -247,9 +248,10 @@ enum ec_error_list ocpc_calc_resistances(struct ocpc_data *ocpc, return EC_SUCCESS; } -int ocpc_config_secondary_charger(int *desired_input_current, - struct ocpc_data *ocpc, int voltage_mv, - int current_ma) +int ocpc_config_secondary_charger(int *desired_charger_input_current, + struct ocpc_data *ocpc, + int desired_batt_voltage_mv, + int desired_batt_current_ma) { int rv = EC_SUCCESS; struct batt_params batt; @@ -285,8 +287,8 @@ int ocpc_config_secondary_charger(int *desired_input_current, batt_info = battery_get_info(); - if (current_ma == 0) { - vsys_target = voltage_mv; + if (desired_batt_current_ma == 0) { + vsys_target = desired_batt_voltage_mv; goto set_vsys; } @@ -317,8 +319,8 @@ int ocpc_config_secondary_charger(int *desired_input_current, if (!timestamp_expired(delay, NULL)) return EC_ERROR_BUSY; - result = charger_set_vsys_compensation(chgnum, ocpc, current_ma, - voltage_mv); + result = charger_set_vsys_compensation( + chgnum, ocpc, desired_batt_current_ma, desired_batt_voltage_mv); switch (result) { case EC_SUCCESS: /* No further action required, so we're done here. */ @@ -376,8 +378,9 @@ int ocpc_config_secondary_charger(int *desired_input_current, if (batt.desired_voltage) { if (((batt.voltage < batt_info->voltage_min) || ((batt.voltage < batt_info->voltage_normal) && - (current_ma >= 0) && - (current_ma <= batt_info->precharge_current))) && + (desired_batt_current_ma >= 0) && + (desired_batt_current_ma <= + batt_info->precharge_current))) && (ph != PHASE_PRECHARGE)) { /* * If the charger IC doesn't support the linear charge @@ -389,11 +392,12 @@ int ocpc_config_secondary_charger(int *desired_input_current, } else if (result == EC_SUCCESS) { CPRINTS("OCPC: Enabling linear precharge"); ph = PHASE_PRECHARGE; - i_ma = current_ma; + i_ma = desired_batt_current_ma; } } else if (batt.voltage < batt.desired_voltage) { if ((ph == PHASE_PRECHARGE) && - (current_ma > batt_info->precharge_current)) { + (desired_batt_current_ma > + batt_info->precharge_current)) { /* * Precharge phase is complete. Now set the * target VSYS to the battery voltage to prevent @@ -422,7 +426,7 @@ int ocpc_config_secondary_charger(int *desired_input_current, if ((ph != PHASE_PRECHARGE) && (ph < PHASE_CV_TRIP)) ph = PHASE_CC; - i_ma = current_ma; + i_ma = desired_batt_current_ma; } else { /* * Once the battery voltage reaches the desired voltage, @@ -452,6 +456,16 @@ int ocpc_config_secondary_charger(int *desired_input_current, */ if (ocpc->last_vsys != OCPC_UNINIT) { error = i_ma - batt.current; + + /* Uses charger input error if controller is proportional only. + */ + if ((k_i == 0) && (k_d == 0)) { + int charger_input_error = + (*desired_charger_input_current - + ocpc->secondary_ibus_ma); + error = MIN(error, charger_input_error); + } + /* Add some hysteresis. */ if (ABS(error) < (i_step / 2)) error = 0; @@ -490,11 +504,15 @@ int ocpc_config_secondary_charger(int *desired_input_current, * VSYS rather quickly, but we'll be conservative on * increasing VSYS. */ - if (drive > 10) - drive = 10; + if (drive > drive_limit) + drive = drive_limit; CPRINTS_DBG("drive = %d", drive); } + CPRINTS_DBG("##DATA = %d %d %d %d %d %d %d", batt.desired_current, + batt.current, *desired_charger_input_current, + ocpc->secondary_ibus_ma, error, ocpc->last_vsys, drive); + /* * For the pre-charge phase, simply keep the VSYS target at the desired * voltage. @@ -537,7 +555,7 @@ int ocpc_config_secondary_charger(int *desired_input_current, /* If we're input current limited, we cannot increase VSYS any more. */ CPRINTS_DBG("OCPC: Inst. Input Current: %dmA (Limit: %dmA)", - ocpc->secondary_ibus_ma, *desired_input_current); + ocpc->secondary_ibus_ma, *desired_charger_input_current); if (charger_is_icl_reached(chgnum, &icl_reached) != EC_SUCCESS) { /* @@ -546,7 +564,7 @@ int ocpc_config_secondary_charger(int *desired_input_current, * 95% of the limit. */ if (ocpc->secondary_ibus_ma >= - (*desired_input_current * 95 / 100)) + (*desired_charger_input_current * 95 / 100)) icl_reached = true; } @@ -765,3 +783,16 @@ static int command_ocpcpid(int argc, const char **argv) DECLARE_SAFE_CONSOLE_COMMAND(ocpcpid, command_ocpcpid, "[ ]", "Show/Set PID constants for OCPC PID loop"); + +static int command_ocpcdrvlmt(int argc, const char **argv) +{ + if (argc == 2) { + drive_limit = atoi(argv[1]); + } + + /* Print the current constants */ + ccprintf("Drive Limit = %d\n", drive_limit); + return EC_SUCCESS; +} +DECLARE_SAFE_CONSOLE_COMMAND(ocpcdrvlmt, command_ocpcdrvlmt, "[]", + "Show/Set drive limit for OCPC PID loop"); diff --git a/include/config.h b/include/config.h index a0ce35e62c..e7b3b76683 100644 --- a/include/config.h +++ b/include/config.h @@ -1333,6 +1333,9 @@ */ #undef CONFIG_OCPC_DEF_RBATT_MOHMS +/* Set a default OCPC drive limit for legacy boards */ +#define CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS 10 + /* Enable trickle charging */ #undef CONFIG_TRICKLE_CHARGING diff --git a/include/ocpc.h b/include/ocpc.h index da1c6907d4..20ec35c797 100644 --- a/include/ocpc.h +++ b/include/ocpc.h @@ -42,15 +42,16 @@ struct ocpc_data { /** Set the VSYS target for the secondary charger IC. * - * @param curr: Pointer to desired_input_current + * @param desired_charger_input_current: Pointer to desired_input_current * @param ocpc: Pointer to OCPC data - * @param voltage_mv: The desired voltage - * @param current_ma: The desired current + * @param desired_batt_current_ma: The desired voltage + * @param desired_batt_voltage_mv: The desired current * @return EC_SUCCESS on success, error otherwise. */ -int ocpc_config_secondary_charger(int *desired_input_current, - struct ocpc_data *ocpc, int voltage_mv, - int current_ma); +int ocpc_config_secondary_charger(int *desired_charger_input_current, + struct ocpc_data *ocpc, + int desired_batt_voltage_mv, + int desired_batt_current_ma); /** Get the runtime data from the various ADCs. * @@ -59,8 +60,8 @@ int ocpc_config_secondary_charger(int *desired_input_current, void ocpc_get_adcs(struct ocpc_data *ocpc); /* Set the PID constants for the charging loop */ -__overridable void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, - int *ki_div, int *kd, int *kd_div); +__override_proto void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, + int *ki_div, int *kd, int *kd_div); /* ** Set up some initial values for the OCPC data structure. This will call off diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger index 4f231c5e68..34fe34397a 100644 --- a/zephyr/Kconfig.charger +++ b/zephyr/Kconfig.charger @@ -214,6 +214,13 @@ config PLATFORM_EC_OCPC_DEF_RBATT_MOHMS This should be at a minimum the Rds(on) resistance of the BFET plus the series sense resistor. +config PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS + int "Drive Limit for the OCPC PID control loop" + default 10 + help + Sets how agressively the OCPC PID control loop can adjust VSYS to drive + the battery with the correct current. + endif # PLATFORM_EC_OCPC config PLATFORM_EC_CHARGER_DISCHARGE_ON_AC diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index c23a7f1381..ae08a9020d 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -148,6 +148,7 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS=200 # Dynamically select PD voltage to maximize charger efficiency CONFIG_PLATFORM_EC_USB_PD_DPS=y diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c index 78f703ae49..e278387a84 100644 --- a/zephyr/program/nissa/src/common.c +++ b/zephyr/program/nissa/src/common.c @@ -152,3 +152,14 @@ enum nissa_sub_board_type nissa_get_sb_type(void) } return sb; } + +__override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, + int *ki_div, int *kd, int *kd_div) +{ + *kp = 1; + *kp_div = 32; + *ki = 0; + *ki_div = 1; + *kd = 0; + *kd_div = 1; +} diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 51c5a9e85e..265b64403f 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -312,6 +312,11 @@ #ifdef CONFIG_PLATFORM_EC_OCPC #define CONFIG_OCPC #define CONFIG_OCPC_DEF_RBATT_MOHMS CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS +#ifdef CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS +#undef CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS +#define CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS \ + CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS +#endif #endif #undef CONFIG_CHARGER_SINGLE_CHIP -- cgit v1.2.1 From 13fb850f68d55998cedb4400428646495469fb9b Mon Sep 17 00:00:00 2001 From: Josh Tsai Date: Thu, 29 Sep 2022 14:16:47 +0800 Subject: zephyr: skyrim: add the motionsense dts file per board variant Create an motionsense file per board variant if the variants don't have the same motionsense nodes. BRANCH=none BUG=none LOW_COVERAGE_REASON=no unit test for skyrim board yet: b/247151116 TEST=zmake build $all_skyrim_variants Signed-off-by: Josh Tsai Change-Id: Ic3e601da2a616bc7c4896ceb3d16d8a0232dd4c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3989457 Reviewed-by: Diana Z Code-Coverage: Zoss Reviewed-by: Elthan Huang --- zephyr/program/skyrim/BUILD.py | 5 +- zephyr/program/skyrim/motionsense_frostflow.dts | 135 +++++++++++++++++++++++ zephyr/program/skyrim/motionsense_morthal.dts | 135 +++++++++++++++++++++++ zephyr/program/skyrim/motionsense_skyrim.dts | 135 +++++++++++++++++++++++ zephyr/program/skyrim/motionsense_winterhold.dts | 135 +++++++++++++++++++++++ 5 files changed, 544 insertions(+), 1 deletion(-) create mode 100644 zephyr/program/skyrim/motionsense_frostflow.dts create mode 100644 zephyr/program/skyrim/motionsense_morthal.dts create mode 100644 zephyr/program/skyrim/motionsense_skyrim.dts create mode 100644 zephyr/program/skyrim/motionsense_winterhold.dts diff --git a/zephyr/program/skyrim/BUILD.py b/zephyr/program/skyrim/BUILD.py index 3807150af9..5eb2f01503 100644 --- a/zephyr/program/skyrim/BUILD.py +++ b/zephyr/program/skyrim/BUILD.py @@ -21,7 +21,6 @@ def register_skyrim_project( here / "gpio.dts", here / "interrupts.dts", here / "keyboard.dts", - here / "motionsense.dts", here / "usbc.dts", # Project-specific DTS customizations. *extra_dts_overlays, @@ -37,6 +36,7 @@ register_skyrim_project( here / "battery_morthal.dts", here / "led_pins_morthal.dts", here / "led_policy_morthal.dts", + here / "motionsense_morthal.dts", ], extra_kconfig_files=[ here / "prj_morthal.conf", @@ -51,6 +51,7 @@ register_skyrim_project( here / "battery_skyrim.dts", here / "led_pins_skyrim.dts", here / "led_policy_skyrim.dts", + here / "motionsense_skyrim.dts", ], extra_kconfig_files=[ here / "prj_skyrim.conf", @@ -65,6 +66,7 @@ register_skyrim_project( here / "battery_winterhold.dts", here / "led_pins_winterhold.dts", here / "led_policy_winterhold.dts", + here / "motionsense_winterhold.dts", ], extra_kconfig_files=[ here / "prj_winterhold.conf", @@ -79,6 +81,7 @@ register_skyrim_project( here / "battery_frostflow.dts", here / "led_pins_frostflow.dts", here / "led_policy_frostflow.dts", + here / "motionsense_frostflow.dts", ], extra_kconfig_files=[ here / "prj_frostflow.conf", diff --git a/zephyr/program/skyrim/motionsense_frostflow.dts b/zephyr/program/skyrim/motionsense_frostflow.dts new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/motionsense_frostflow.dts @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/motionsense_morthal.dts b/zephyr/program/skyrim/motionsense_morthal.dts new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/motionsense_morthal.dts @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/motionsense_skyrim.dts b/zephyr/program/skyrim/motionsense_skyrim.dts new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/motionsense_skyrim.dts @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/motionsense_winterhold.dts b/zephyr/program/skyrim/motionsense_winterhold.dts new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/motionsense_winterhold.dts @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; -- cgit v1.2.1 From 3870d43d576de7d29f6b244bd5a9a22d0ccfc393 Mon Sep 17 00:00:00 2001 From: Josh-Tsai Date: Sun, 6 Nov 2022 09:40:09 +0800 Subject: Winterhold: remove unused lid, tablet mode and motion sensor configuration Winterhold only support base sensor, so remove unused configuration BUG=none BRANCH=none TEST=ectool motionsense only show base sensor value Signed-off-by: Josh-Tsai Change-Id: Ib7392e50bdcec29f8ade60e56887cb3ef3f8ade0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3989458 Reviewed-by: Elthan Huang Reviewed-by: Diana Z Code-Coverage: Zoss --- zephyr/program/skyrim/motionsense_winterhold.dts | 48 ------------------------ zephyr/program/skyrim/prj_winterhold.conf | 14 ++++++- 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/zephyr/program/skyrim/motionsense_winterhold.dts b/zephyr/program/skyrim/motionsense_winterhold.dts index f943bea4c8..9bafa618aa 100644 --- a/zephyr/program/skyrim/motionsense_winterhold.dts +++ b/zephyr/program/skyrim/motionsense_winterhold.dts @@ -24,10 +24,6 @@ * instance of the mutex. */ motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - mutex_bmi3xx: bmi3xx-mutex { }; }; @@ -42,11 +38,6 @@ * "struct als_drv_data_t" in accelgyro.h */ motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - bmi3xx_data: bmi3xx-drv-data { compatible = "cros-ec,drvdata-bmi3xx"; status = "okay"; @@ -59,30 +50,6 @@ * motion sensor IDs for lid angle calculation. */ motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - base_accel: base-accel { compatible = "cros-ec,bmi3xx-accel"; status = "okay"; @@ -106,18 +73,6 @@ }; }; }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; }; motionsense-sensor-info { @@ -128,8 +83,5 @@ * be enabled at initial stage */ sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; }; }; diff --git a/zephyr/program/skyrim/prj_winterhold.conf b/zephyr/program/skyrim/prj_winterhold.conf index 2ccd195a72..2643eabe61 100644 --- a/zephyr/program/skyrim/prj_winterhold.conf +++ b/zephyr/program/skyrim/prj_winterhold.conf @@ -23,4 +23,16 @@ CONFIG_PLATFORM_EC_CHARGER_ISL9241=n # Get the vbus voltage from TCPC CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y \ No newline at end of file +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y + +# Remove unused sensor +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n + +# Disable lid configuration +CONFIG_PLATFORM_EC_LID_ANGLE=n +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n + +# Disable tablet mode configuration +CONFIG_PLATFORM_EC_TABLET_MODE=n +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n -- cgit v1.2.1 From 53627e4363cd6db55bbc73601d188cd6eb975c35 Mon Sep 17 00:00:00 2001 From: Josh-Tsai Date: Mon, 31 Oct 2022 16:28:45 +0800 Subject: Winterhold: add second source for base accel Add LIS2DW12 for winterhold, enable the alternative motion sensors by checking board id. BUG=b:236668095 BRANCH=none LOW_COVERAGE_REASON=no unit test for skyrim board yet: b/247151116 TEST=1.zmake build winterhold 2.ectool motionsense can read the value on board id=0 and board id=1 (with slave address 0x18) Signed-off-by: Josh-Tsai Change-Id: I9b3bfbb9de86f495c2bf8aae794e87de843a4e18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3989459 Reviewed-by: Diana Z Code-Coverage: Zoss Reviewed-by: Elthan Huang --- zephyr/program/skyrim/CMakeLists.txt | 1 + zephyr/program/skyrim/motionsense_winterhold.dts | 36 ++++++++++++++++++++++- zephyr/program/skyrim/prj_winterhold.conf | 3 ++ zephyr/program/skyrim/src/winterhold/sensor.c | 37 ++++++++++++++++++++++++ zephyr/program/skyrim/winterhold.dts | 5 ++++ 5 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 zephyr/program/skyrim/src/winterhold/sensor.c diff --git a/zephyr/program/skyrim/CMakeLists.txt b/zephyr/program/skyrim/CMakeLists.txt index 71b8427aa1..cfa4a22a0b 100644 --- a/zephyr/program/skyrim/CMakeLists.txt +++ b/zephyr/program/skyrim/CMakeLists.txt @@ -45,6 +45,7 @@ if(DEFINED CONFIG_BOARD_WINTERHOLD) "src/winterhold/ppc_config.c" "src/winterhold/kb_backlight.c" "src/winterhold/keyboard.c" + "src/winterhold/sensor.c" ) endif() diff --git a/zephyr/program/skyrim/motionsense_winterhold.dts b/zephyr/program/skyrim/motionsense_winterhold.dts index 9bafa618aa..514687da79 100644 --- a/zephyr/program/skyrim/motionsense_winterhold.dts +++ b/zephyr/program/skyrim/motionsense_winterhold.dts @@ -14,6 +14,7 @@ * its own <>_INT_EVENT. */ bmi3xx-int = &base_accel; + lis2dw12-int = &base_accel; }; /* @@ -26,6 +27,8 @@ motionsense-mutex { mutex_bmi3xx: bmi3xx-mutex { }; + mutex_lis2dw12: lis2dw12-mutex { + }; }; /* @@ -42,6 +45,10 @@ compatible = "cros-ec,drvdata-bmi3xx"; status = "okay"; }; + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; }; /* @@ -51,6 +58,33 @@ */ motionsense-sensor { base_accel: base-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_lis2dw12>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS"; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + }; + + motionsense-sensor-alt { + alt_base_accel: alt-base-accel { compatible = "cros-ec,bmi3xx-accel"; status = "okay"; @@ -60,7 +94,7 @@ port = <&i2c_sensor>; rot-standard-ref = <&base_rot_ref>; drv-data = <&bmi3xx_data>; - + alternate-for = <&base_accel>; configs { compatible = "cros-ec,motionsense-sensor-config"; diff --git a/zephyr/program/skyrim/prj_winterhold.conf b/zephyr/program/skyrim/prj_winterhold.conf index 2643eabe61..81fd9f367e 100644 --- a/zephyr/program/skyrim/prj_winterhold.conf +++ b/zephyr/program/skyrim/prj_winterhold.conf @@ -28,6 +28,9 @@ CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y # Remove unused sensor CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n +# Support LIS2DW12 sensor +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y + # Disable lid configuration CONFIG_PLATFORM_EC_LID_ANGLE=n CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n diff --git a/zephyr/program/skyrim/src/winterhold/sensor.c b/zephyr/program/skyrim/src/winterhold/sensor.c new file mode 100644 index 0000000000..52cd201705 --- /dev/null +++ b/zephyr/program/skyrim/src/winterhold/sensor.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "cros_board_info.h" +#include "driver/accel_lis2dw12.h" +#include "driver/accelgyro_bmi3xx.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +void base_accel_interrupt(enum gpio_signal signal) +{ + int ret; + uint32_t val; + + ret = cbi_get_board_version(&val); + + if (ret == EC_SUCCESS && val < 1) + bmi3xx_interrupt(signal); + else + lis2dw12_interrupt(signal); +} + +static void motionsense_init(void) +{ + int ret; + uint32_t val; + + ret = cbi_get_board_version(&val); + + if (ret == EC_SUCCESS && val < 1) { + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); + } +} +DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/skyrim/winterhold.dts b/zephyr/program/skyrim/winterhold.dts index 8a182ab835..5377403c48 100644 --- a/zephyr/program/skyrim/winterhold.dts +++ b/zephyr/program/skyrim/winterhold.dts @@ -159,3 +159,8 @@ /delete-property/ temp_fan_off; /delete-property/ temp_fan_max; }; + +/* Override handler */ +&int_accel_gyro { + handler = "base_accel_interrupt"; +}; -- cgit v1.2.1 From 8848a7d064ea40e88c94ff6fddd672b627cd8fb8 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Fri, 26 Aug 2022 13:33:21 -0700 Subject: buggzy: Enable on/off body detection Add gesture recognition and body detection. BUG=b:236799854 BRANCH=dedede TEST=Check EC report transition on bugzzy 22-08-26 12:11:07.754 [3656.977247 body_detect changed state to: on body] ... 22-08-26 12:11:33.109 [3682.305873 body_detect changed state to: off body] ... 22-08-26 12:12:04.271 [3713.439070 body_detect changed state to: on body] ... 22-08-26 12:12:20.636 [3729.790796 body_detect changed state to: off body] Change-Id: I8d9a8243ec8c31be1f4ec378e2cd95ed00d24e61 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3860190 Code-Coverage: Zoss Reviewed-by: Diana Z Reviewed-by: Bob Moragues --- board/bugzzy/board.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/board/bugzzy/board.h b/board/bugzzy/board.h index 707314d02a..b1d8568ee1 100644 --- a/board/bugzzy/board.h +++ b/board/bugzzy/board.h @@ -183,6 +183,14 @@ #define CONFIG_TABLET_MODE #define CONFIG_TABLET_MODE_SWITCH +/* On-body detection */ +#define CONFIG_BODY_DETECTION +#define CONFIG_BODY_DETECTION_SENSOR BASE_ACCEL +#define CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR 150 /* % */ +#define CONFIG_GESTURE_DETECTION +#define CONFIG_GESTURE_DETECTION_MASK BIT(CONFIG_BODY_DETECTION_SENSOR) +#define CONFIG_GESTURE_HOST_DETECTION + /* LIS2DS Lid accel */ #define CONFIG_ACCEL_LIS2DS -- cgit v1.2.1 From 4028694bc78b4ef5af3052b33f00207e00d75ee4 Mon Sep 17 00:00:00 2001 From: Liam Flaherty Date: Fri, 4 Nov 2022 10:42:58 +1100 Subject: dibbi: Create initial EC image Create the initial EC image for the dibbi variant by forking the waddledee reference board. BUG=b:256707714 BRANCH=dedede TEST=make -j BOARD=dibbi Signed-off-by: Liam Flaherty Change-Id: I102364df22d0a9871f0a2106ba29e4c10339c0c8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005237 Code-Coverage: Zoss Commit-Queue: Liam Flaherty Reviewed-by: Adam Mills Reviewed-by: Sam McNally Tested-by: Liam Flaherty --- board/dibbi/battery.c | 331 ++++++++++++++++++++++++ board/dibbi/board.c | 580 +++++++++++++++++++++++++++++++++++++++++++ board/dibbi/board.h | 142 +++++++++++ board/dibbi/build.mk | 15 ++ board/dibbi/cbi_ssfc.c | 36 +++ board/dibbi/cbi_ssfc.h | 59 +++++ board/dibbi/ec.tasklist | 24 ++ board/dibbi/gpio.inc | 138 ++++++++++ board/dibbi/led.c | 82 ++++++ board/dibbi/usb_pd_policy.c | 74 ++++++ board/dibbi/vif_override.xml | 3 + util/build_with_clang.py | 1 + 12 files changed, 1485 insertions(+) create mode 100644 board/dibbi/battery.c create mode 100644 board/dibbi/board.c create mode 100644 board/dibbi/board.h create mode 100644 board/dibbi/build.mk create mode 100644 board/dibbi/cbi_ssfc.c create mode 100644 board/dibbi/cbi_ssfc.h create mode 100644 board/dibbi/ec.tasklist create mode 100644 board/dibbi/gpio.inc create mode 100644 board/dibbi/led.c create mode 100644 board/dibbi/usb_pd_policy.c create mode 100644 board/dibbi/vif_override.xml diff --git a/board/dibbi/battery.c b/board/dibbi/battery.c new file mode 100644 index 0000000000..99f458a4aa --- /dev/null +++ b/board/dibbi/battery.c @@ -0,0 +1,331 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery pack vendor provided charging profile + */ + +#include "battery_fuel_gauge.h" +#include "charge_state.h" +#include "common.h" + +/* + * Battery info for all waddledee battery types. Note that the fields + * start_charging_min/max and charging_min/max are not used for the charger. + * The effective temperature limits are given by discharging_min/max_c. + * + * Fuel Gauge (FG) parameters which are used for determining if the battery + * is connected, the appropriate ship mode (battery cutoff) command, and the + * charge/discharge FETs status. + * + * Ship mode (battery cutoff) requires 2 writes to the appropriate smart battery + * register. For some batteries, the charge/discharge FET bits are set when + * charging/discharging is active, in other types, these bits set mean that + * charging/discharging is disabled. Therefore, in addition to the mask for + * these bits, a disconnect value must be specified. Note that for TI fuel + * gauge, the charge/discharge FET status is found in Operation Status (0x54), + * but a read of Manufacturer Access (0x00) will return the lower 16 bits of + * Operation status which contains the FET status bits. + * + * The assumption for battery types supported is that the charge/discharge FET + * status can be read with a sb_read() command and therefore, only the register + * address, mask, and disconnect value need to be provided. + */ +const struct board_batt_params board_battery_info[] = { + /* LGC AC15A8J Battery Information */ + [BATTERY_LGC15] = { + .fuel_gauge = { + .manuf_name = "LGC", + .device_name = "AC15A8J", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .mfgacc_support = 1, + .reg_addr = 0x0, + .reg_mask = 0x0002, + .disconnect_val = 0x0, + } + }, + .batt_info = { + .voltage_max = 13200, + .voltage_normal = 11520, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 60, + }, + }, + + /* Panasonic AP1505L Battery Information */ + [BATTERY_PANASONIC_AP15O5L] = { + .fuel_gauge = { + .manuf_name = "PANASONIC", + .device_name = "AP15O5L", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x4000, + .disconnect_val = 0x0, + } + }, + .batt_info = { + .voltage_max = 13200, + .voltage_normal = 11550, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 60, + }, + }, + + /* SANYO AC15A3J Battery Information */ + [BATTERY_SANYO] = { + .fuel_gauge = { + .manuf_name = "SANYO", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x4000, + .disconnect_val = 0x0, + } + }, + .batt_info = { + .voltage_max = TARGET_WITH_MARGIN(13200, 5), + .voltage_normal = 11550, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 60, + }, + }, + + /* Sony Ap13J4K Battery Information */ + [BATTERY_SONY] = { + .fuel_gauge = { + .manuf_name = "SONYCorp", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x8000, + .disconnect_val = 0x8000, + .cfet_mask = 0x4000, + .cfet_off_val = 0x4000, + } + }, + .batt_info = { + .voltage_max = TARGET_WITH_MARGIN(13200, 5), + .voltage_normal = 11400, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 60, + }, + }, + + /* Simplo AP13J7K Battery Information */ + [BATTERY_SMP_AP13J7K] = { + .fuel_gauge = { + .manuf_name = "SIMPLO", + .device_name = "AP13J7K", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .mfgacc_support = 1, + .reg_addr = 0x0, + .reg_mask = 0x0002, + .disconnect_val = 0x0000, + } + }, + .batt_info = { + .voltage_max = 13050, + .voltage_normal = 11400, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 45, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 60, + }, + }, + + /* Panasonic AC15A3J Battery Information */ + [BATTERY_PANASONIC_AC15A3J] = { + .fuel_gauge = { + .manuf_name = "PANASONIC", + .device_name = "AC15A3J", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x4000, + .disconnect_val = 0x0, + } + }, + .batt_info = { + .voltage_max = 13200, + .voltage_normal = 11550, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = -20, + .discharging_max_c = 75, + }, + }, + + /* LGC AP18C8K Battery Information */ + [BATTERY_LGC_AP18C8K] = { + .fuel_gauge = { + .manuf_name = "LGC KT0030G020", + .device_name = "AP18C8K", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x43, + .reg_mask = 0x0001, + .disconnect_val = 0x0, + }, + }, + .batt_info = { + .voltage_max = 13050, + .voltage_normal = 11250, + .voltage_min = 9000, + .precharge_current = 256, + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = -20, + .discharging_max_c = 75, + }, + }, + + /* Murata AP18C4K Battery Information */ + [BATTERY_MURATA_AP18C4K] = { + .fuel_gauge = { + .manuf_name = "Murata KT00304012", + .device_name = "AP18C4K", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x2000, + .disconnect_val = 0x2000, + }, + }, + .batt_info = { + .voltage_max = 13200, + .voltage_normal = 11400, + .voltage_min = 9000, + .precharge_current = 256, + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = -20, + .discharging_max_c = 75, + }, + }, + + /* LGC AP19A8K Battery Information */ + [BATTERY_LGC_AP19A8K] = { + .fuel_gauge = { + .manuf_name = "LGC KTxxxxGxxx", + .device_name = "AP19A8K", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x43, + .reg_mask = 0x0001, + .disconnect_val = 0x0, + .cfet_mask = 0x0002, + .cfet_off_val = 0x0, + }, + }, + .batt_info = { + .voltage_max = 13200, + .voltage_normal = 11550, + .voltage_min = 9000, + .precharge_current = 256, + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = -20, + .discharging_max_c = 75, + }, + }, + + /* LGC KT0030G023 Battery Information */ + [BATTERY_LGC_G023] = { + .fuel_gauge = { + .manuf_name = "LGC KT0030G023", + .device_name = "AP19A8K", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x43, + .reg_mask = 0x0001, + .disconnect_val = 0x0, + }, + }, + .batt_info = { + .voltage_max = 13200, + .voltage_normal = 11550, + .voltage_min = 9000, + .precharge_current = 256, + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = -20, + .discharging_max_c = 75, + }, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); + +const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_PANASONIC_AC15A3J; diff --git a/board/dibbi/board.c b/board/dibbi/board.c new file mode 100644 index 0000000000..a07f2ff1ee --- /dev/null +++ b/board/dibbi/board.c @@ -0,0 +1,580 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Waddledee board-specific configuration */ + +#include "adc_chip.h" +#include "button.h" +#include "charge_manager.h" +#include "charge_state_v2.h" +#include "charger.h" +#include "driver/accel_kionix.h" +#include "driver/accelgyro_lsm6dsm.h" +#include "driver/bc12/pi3usb9201.h" +#include "driver/charger/sm5803.h" +#include "driver/retimer/tusb544.h" +#include "driver/temp_sensor/thermistor.h" +#include "driver/tcpm/anx7447.h" +#include "driver/tcpm/it83xx_pd.h" +#include "driver/usb_mux/it5205.h" +#include "gpio.h" +#include "hooks.h" +#include "intc.h" +#include "keyboard_scan.h" +#include "lid_switch.h" +#include "power.h" +#include "power_button.h" +#include "pwm.h" +#include "pwm_chip.h" +#include "switch.h" +#include "system.h" +#include "tablet_mode.h" +#include "task.h" +#include "tcpm/tcpci.h" +#include "temp_sensor.h" +#include "uart.h" +#include "usb_charge.h" +#include "usb_mux.h" +#include "usb_pd.h" +#include "usb_pd_tcpm.h" + +#define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) + +#define INT_RECHECK_US 5000 + +/* C1 interrupt line swapped between board versions, track it in a variable */ +static enum gpio_signal c1_int_line; + +/* C0 interrupt line shared by BC 1.2 and charger */ +static void check_c0_line(void); +DECLARE_DEFERRED(check_c0_line); + +static void notify_c0_chips(void) +{ + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + sm5803_interrupt(0); +} + +static void check_c0_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips + */ + if (!gpio_get_level(GPIO_USB_C0_INT_ODL)) { + notify_c0_chips(); + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); + } +} + +static void usb_c0_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c0_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c0_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); +} + +/* C1 interrupt line shared by BC 1.2, TCPC, and charger */ +static void check_c1_line(void); +DECLARE_DEFERRED(check_c1_line); + +static void notify_c1_chips(void) +{ + schedule_deferred_pd_interrupt(1); + usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); + sm5803_interrupt(1); +} + +static void check_c1_line(void) +{ + /* + * If line is still being held low, see if there's more to process from + * one of the chips. + */ + if (!gpio_get_level(c1_int_line)) { + notify_c1_chips(); + hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); + } +} + +static void usb_c1_interrupt(enum gpio_signal s) +{ + /* Cancel any previous calls to check the interrupt line */ + hook_call_deferred(&check_c1_line_data, -1); + + /* Notify all chips using this line that an interrupt came in */ + notify_c1_chips(); + + /* Check the line again in 5ms */ + hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); +} + +static void c0_ccsbu_ovp_interrupt(enum gpio_signal s) +{ + cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event"); + pd_handle_cc_overvoltage(0); +} + +/* Must come after other header files and interrupt handler declarations */ +#include "gpio_list.h" + +/* ADC channels */ +const struct adc_t adc_channels[] = { + [ADC_VSNS_PP3300_A] = { .name = "PP3300_A_PGOOD", + .factor_mul = ADC_MAX_MVOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + .channel = CHIP_ADC_CH0 }, + [ADC_TEMP_SENSOR_1] = { .name = "TEMP_SENSOR1", + .factor_mul = ADC_MAX_MVOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + .channel = CHIP_ADC_CH2 }, + [ADC_TEMP_SENSOR_2] = { .name = "TEMP_SENSOR2", + .factor_mul = ADC_MAX_MVOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + .channel = CHIP_ADC_CH3 }, + [ADC_SUB_ANALOG] = { .name = "SUB_ANALOG", + .factor_mul = ADC_MAX_MVOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + .channel = CHIP_ADC_CH13 }, +}; +BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); + +/* BC 1.2 chips */ +const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { + { + .i2c_port = I2C_PORT_USB_C0, + .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, + .flags = PI3USB9201_ALWAYS_POWERED, + }, + { + .i2c_port = I2C_PORT_SUB_USB_C1, + .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, + .flags = PI3USB9201_ALWAYS_POWERED, + }, +}; + +/* Charger chips */ +const struct charger_config_t chg_chips[] = { + [CHARGER_PRIMARY] = { + .i2c_port = I2C_PORT_USB_C0, + .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS, + .drv = &sm5803_drv, + }, + [CHARGER_SECONDARY] = { + .i2c_port = I2C_PORT_SUB_USB_C1, + .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS, + .drv = &sm5803_drv, + }, +}; + +/* TCPCs */ +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_EMBEDDED, + .drv = &it83xx_tcpm_drv, + }, + { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_SUB_USB_C1, + .addr_flags = AN7447_TCPC0_I2C_ADDR_FLAGS, + }, + .drv = &anx7447_tcpm_drv, + .flags = TCPC_FLAGS_TCPCI_REV2_0, + }, +}; + +/* USB Retimer */ +const struct usb_mux_chain usbc1_retimer = { + .mux = + &(const struct usb_mux){ + .usb_port = 1, + .i2c_port = I2C_PORT_SUB_USB_C1, + .i2c_addr_flags = TUSB544_I2C_ADDR_FLAGS0, + .driver = &tusb544_drv, + }, +}; + +/* USB Muxes */ +const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .mux = + &(const struct usb_mux){ + .usb_port = 0, + .i2c_port = I2C_PORT_USB_C0, + .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS, + .driver = &it5205_usb_mux_driver, + }, + }, + { + .mux = + &(const struct usb_mux){ + .usb_port = 1, + .i2c_port = I2C_PORT_SUB_USB_C1, + .i2c_addr_flags = AN7447_TCPC0_I2C_ADDR_FLAGS, + .driver = &anx7447_usb_mux_driver, + }, + .next = &usbc1_retimer, + }, +}; + +void board_init(void) +{ + int on; + + if (system_get_board_version() <= 0) { + pd_set_max_voltage(5000); + c1_int_line = GPIO_USB_C1_INT_V0_ODL; + } else { + c1_int_line = GPIO_USB_C1_INT_V1_ODL; + } + + gpio_enable_interrupt(GPIO_USB_C0_INT_ODL); + gpio_enable_interrupt(c1_int_line); + + /* + * If interrupt lines are already low, schedule them to be processed + * after inits are completed. + */ + check_c0_line(); + check_c1_line(); + + gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL); + /* Enable Base Accel interrupt */ + gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); + + /* Charger on the MB will be outputting PROCHOT_ODL and OD CHG_DET */ + sm5803_configure_gpio0(CHARGER_PRIMARY, GPIO0_MODE_PROCHOT, 1); + sm5803_configure_chg_det_od(CHARGER_PRIMARY, 1); + + /* Charger on the sub-board will be a push-pull GPIO */ + sm5803_configure_gpio0(CHARGER_SECONDARY, GPIO0_MODE_OUTPUT, 0); + + /* Turn on 5V if the system is on, otherwise turn it off */ + on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND | + CHIPSET_STATE_SOFT_OFF); + board_power_5v_enable(on); +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); + +static void board_resume(void) +{ + sm5803_disable_low_power_mode(CHARGER_PRIMARY); + if (board_get_charger_chip_count() > 1) + sm5803_disable_low_power_mode(CHARGER_SECONDARY); +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_resume, HOOK_PRIO_DEFAULT); + +static void board_suspend(void) +{ + sm5803_enable_low_power_mode(CHARGER_PRIMARY); + if (board_get_charger_chip_count() > 1) + sm5803_enable_low_power_mode(CHARGER_SECONDARY); +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_suspend, HOOK_PRIO_DEFAULT); + +void board_hibernate(void) +{ + /* + * Put all charger ICs present into low power mode before entering + * z-state. + */ + sm5803_hibernate(CHARGER_PRIMARY); + if (board_get_charger_chip_count() > 1) + sm5803_hibernate(CHARGER_SECONDARY); +} + +__override void board_ocpc_init(struct ocpc_data *ocpc) +{ + /* There's no provision to measure Isys */ + ocpc->chg_flags[CHARGER_SECONDARY] |= OCPC_NO_ISYS_MEAS_CAP; +} + +void board_reset_pd_mcu(void) +{ + /* + * Nothing to do. TCPC C0 is internal, TCPC C1 reset pin is not + * connected to the EC. + */ +} + +__override void board_power_5v_enable(int enable) +{ + /* + * Motherboard has a GPIO to turn on the 5V regulator, but the sub-board + * sets it through the charger GPIO. + */ + gpio_set_level(GPIO_EN_PP5000, !!enable); + gpio_set_level(GPIO_EN_USB_A0_VBUS, !!enable); + if (sm5803_set_gpio0_level(1, !!enable)) + CPRINTUSB("Failed to %sable sub rails!", enable ? "en" : "dis"); +} + +uint16_t tcpc_get_alert_status(void) +{ + /* + * TCPC 0 is embedded in the EC and processes interrupts in the chip + * code (it83xx/intc.c) + */ + + uint16_t status = 0; + int regval; + + /* Check whether TCPC 1 pulled the shared interrupt line */ + if (!gpio_get_level(c1_int_line)) { + if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { + if (regval) + status = PD_STATUS_TCPC_ALERT_1; + } + } + + return status; +} + +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) +{ + int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); + + /* + * TODO(b/151955431): Characterize the input current limit in case a + * scaling needs to be applied here + */ + charge_set_input_current_limit(icl, charge_mv); +} + +int board_set_active_charge_port(int port) +{ + int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count()); + + if (!is_valid_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + if (port == CHARGE_PORT_NONE) { + CPRINTUSB("Disabling all charge ports"); + + sm5803_vbus_sink_enable(CHARGER_PRIMARY, 0); + + if (board_get_charger_chip_count() > 1) + sm5803_vbus_sink_enable(CHARGER_SECONDARY, 0); + + return EC_SUCCESS; + } + + CPRINTUSB("New chg p%d", port); + + /* + * Ensure other port is turned off, then enable new charge port + */ + if (port == 0) { + if (board_get_charger_chip_count() > 1) + sm5803_vbus_sink_enable(CHARGER_SECONDARY, 0); + sm5803_vbus_sink_enable(CHARGER_PRIMARY, 1); + + } else { + sm5803_vbus_sink_enable(CHARGER_PRIMARY, 0); + sm5803_vbus_sink_enable(CHARGER_SECONDARY, 1); + } + + return EC_SUCCESS; +} + +/* Vconn control for integrated ITE TCPC */ +void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) +{ + /* Vconn control is only for port 0 */ + if (port) + return; + + if (cc_pin == USBPD_CC_PIN_1) + gpio_set_level(GPIO_EN_USB_C0_CC1_VCONN, !!enabled); + else + gpio_set_level(GPIO_EN_USB_C0_CC2_VCONN, !!enabled); +} + +__override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, + int *ki_div, int *kd, int *kd_div) +{ + *kp = 3; + *kp_div = 14; + + *ki = 3; + *ki_div = 500; + + *kd = 4; + *kd_div = 40; +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int current; + + if (port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT) + return; + + current = (rp == TYPEC_RP_3A0) ? 3000 : 1500; + + charger_set_otg_current_voltage(port, current, 5000); +} + +/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */ +const struct pwm_t pwm_channels[] = { + [PWM_CH_KBLIGHT] = { + .channel = 0, + .flags = PWM_CONFIG_DSLEEP, + .freq_hz = 10000, + }, + + [PWM_CH_LED_RED] = { + .channel = 1, + .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, + .freq_hz = 2400, + }, + + [PWM_CH_LED_GREEN] = { + .channel = 2, + .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, + .freq_hz = 2400, + }, + + [PWM_CH_LED_BLUE] = { + .channel = 3, + .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, + .freq_hz = 2400, + } + +}; +BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); + +/* Sensor Mutexes */ +static struct mutex g_lid_mutex; +static struct mutex g_base_mutex; + +/* Sensor Data */ +static struct kionix_accel_data g_kx022_data; +static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA; + +/* Drivers */ +struct motion_sensor_t motion_sensors[] = { + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_KX022, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &kionix_accel_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_kx022_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = KX022_ADDR1_FLAGS, + .rot_standard_ref = NULL, + .default_range = 2, /* g */ + /* We only use 2g because its resolution is only 8-bits */ + .min_frequency = KX022_ACCEL_MIN_FREQ, + .max_frequency = KX022_ACCEL_MAX_FREQ, + .config = { + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + }, + }, + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_ACCEL), + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, + .rot_standard_ref = NULL, + .default_range = 4, /* g */ + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, + .config = { + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, + }, + [BASE_GYRO] = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSM, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dsm_drv, + .mutex = &g_base_mutex, + .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, + MOTIONSENSE_TYPE_GYRO), + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, + .default_range = 1000 | ROUND_UP_FLAG, /* dps */ + .rot_standard_ref = NULL, + .min_frequency = LSM6DSM_ODR_MIN_VAL, + .max_frequency = LSM6DSM_ODR_MAX_VAL, + }, +}; + +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +/* Thermistors */ +const struct temp_sensor_t temp_sensors[] = { + [TEMP_SENSOR_1] = { .name = "Memory", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_1 }, + [TEMP_SENSOR_2] = { .name = "Ambient", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_2 }, +}; +BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); + +/* This callback disables keyboard when convertibles are fully open */ +__override void lid_angle_peripheral_enable(int enable) +{ + int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON); + + /* + * If the lid is in tablet position via other sensors, + * ignore the lid angle, which might be faulty then + * disable keyboard. + */ + if (tablet_get_mode()) + enable = 0; + + if (enable) { + keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE); + } else { + /* + * Ensure that the chipset is off before disabling the keyboard. + * When the chipset is on, the EC keeps the keyboard enabled and + * the AP decides whether to ignore input devices or not. + */ + if (!chipset_in_s0) + keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE); + } +} diff --git a/board/dibbi/board.h b/board/dibbi/board.h new file mode 100644 index 0000000000..6799e7e113 --- /dev/null +++ b/board/dibbi/board.h @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Waddledee board configuration */ + +#ifndef __CROS_EC_BOARD_H +#define __CROS_EC_BOARD_H + +/* Select Baseboard features */ +#define VARIANT_DEDEDE_EC_IT8320 +#include "baseboard.h" + +/* System unlocked in early development */ +#define CONFIG_SYSTEM_UNLOCKED + +#define CONFIG_CMD_CHARGER_DUMP + +/* Battery */ +#define CONFIG_BATTERY_FUEL_GAUGE + +/* BC 1.2 */ +#define CONFIG_BC12_DETECT_PI3USB9201 + +/* Charger */ +#define CONFIG_CHARGER_SM5803 /* C0 and C1: Charger */ +#define PD_MAX_VOLTAGE_MV 15000 +#define CONFIG_USB_PD_VBUS_DETECT_CHARGER +#define CONFIG_USB_PD_5V_CHARGER_CTRL +#define CONFIG_CHARGER_OTG +#undef CONFIG_CHARGER_SINGLE_CHIP +#define CONFIG_OCPC +#define CONFIG_OCPC_DEF_RBATT_MOHMS \ + 21 /* R_DS(on) 10.7mOhm + 10mOhm sns rstr \ + */ + +/* + * GPIO for C1 interrupts, for baseboard use + * + * Note this will only be valid for board revision 1 + */ +#define GPIO_USB_C1_INT_ODL GPIO_USB_C1_INT_V1_ODL + +/* LED */ +#define CONFIG_LED_PWM +#define CONFIG_LED_PWM_COUNT 1 + +/* PWM */ +#define CONFIG_PWM + +/* Sensors */ +#define CONFIG_ACCEL_KX022 /* Lid accel */ +#define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ +#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) +/* Sensors without hardware FIFO are in forced mode */ +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) + +/* Enable sensor fifo, must also define the _SIZE and _THRES */ +#define CONFIG_ACCEL_FIFO +/* Power of 2 - Too large of a fifo causes too much timestamp jitter */ +#define CONFIG_ACCEL_FIFO_SIZE 256 +#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3) + +#define CONFIG_LID_ANGLE +#define CONFIG_LID_ANGLE_UPDATE +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL + +#define CONFIG_TABLET_MODE +#define CONFIG_TABLET_MODE_SWITCH +#define CONFIG_GMR_TABLET_MODE + +/* TCPC */ +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 +#define CONFIG_USB_PD_TCPM_ITE_ON_CHIP /* C0: ITE EC TCPC */ +#define CONFIG_USB_PD_TCPM_ANX7447 /* C1: ANX TCPC + Mux */ +#define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT 1 + +/* Thermistors */ +#define CONFIG_TEMP_SENSOR +#define CONFIG_THERMISTOR +#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B + +/* USB Mux and Retimer */ +#define CONFIG_USB_MUX_IT5205 /* C1: ITE Mux */ +#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */ + +#define CONFIG_USBC_RETIMER_TUSB544 /* C1 Redriver: TUSB544 */ + +#ifndef __ASSEMBLER__ + +#include "gpio_signal.h" +#include "registers.h" + +enum chg_id { + CHARGER_PRIMARY, + CHARGER_SECONDARY, + CHARGER_NUM, +}; + +enum pwm_channel { + PWM_CH_KBLIGHT, + PWM_CH_LED_RED, + PWM_CH_LED_GREEN, + PWM_CH_LED_BLUE, + PWM_CH_COUNT, +}; + +/* Motion sensors */ +enum sensor_id { LID_ACCEL, BASE_ACCEL, BASE_GYRO, SENSOR_COUNT }; + +/* ADC channels */ +enum adc_channel { + ADC_VSNS_PP3300_A, /* ADC0 */ + ADC_TEMP_SENSOR_1, /* ADC2 */ + ADC_TEMP_SENSOR_2, /* ADC3 */ + ADC_SUB_ANALOG, /* ADC13 */ + ADC_CH_COUNT +}; + +enum temp_sensor_id { TEMP_SENSOR_1, TEMP_SENSOR_2, TEMP_SENSOR_COUNT }; + +/* List of possible batteries */ +enum battery_type { + BATTERY_LGC15, + BATTERY_PANASONIC_AP15O5L, + BATTERY_SANYO, + BATTERY_SONY, + BATTERY_SMP_AP13J7K, + BATTERY_PANASONIC_AC15A3J, + BATTERY_LGC_AP18C8K, + BATTERY_MURATA_AP18C4K, + BATTERY_LGC_AP19A8K, + BATTERY_LGC_G023, + BATTERY_TYPE_COUNT, +}; + +#endif /* !__ASSEMBLER__ */ + +#endif /* __CROS_EC_BOARD_H */ diff --git a/board/dibbi/build.mk b/board/dibbi/build.mk new file mode 100644 index 0000000000..317174e0d5 --- /dev/null +++ b/board/dibbi/build.mk @@ -0,0 +1,15 @@ +# -*- makefile -*- +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Board specific files build +# + +CHIP:=it83xx +CHIP_FAMILY:=it8320 +CHIP_VARIANT:=it8320dx +BASEBOARD:=dedede + +board-y=board.o cbi_ssfc.o led.o usb_pd_policy.o +board-$(CONFIG_BATTERY_SMART)+=battery.o diff --git a/board/dibbi/cbi_ssfc.c b/board/dibbi/cbi_ssfc.c new file mode 100644 index 0000000000..9b19af1053 --- /dev/null +++ b/board/dibbi/cbi_ssfc.c @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "cbi_ssfc.h" +#include "common.h" +#include "console.h" +#include "cros_board_info.h" +#include "hooks.h" + +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) + +/* Cache SSFC on init since we don't expect it to change in runtime */ +static union dedede_cbi_ssfc cached_ssfc; +BUILD_ASSERT(sizeof(cached_ssfc) == sizeof(uint32_t)); + +static void cbi_ssfc_init(void) +{ + if (cbi_get_ssfc(&cached_ssfc.raw_value) != EC_SUCCESS) + /* Default to 0 when CBI isn't populated */ + cached_ssfc.raw_value = 0; + + CPRINTS("Read CBI SSFC : 0x%04X", cached_ssfc.raw_value); +} +DECLARE_HOOK(HOOK_INIT, cbi_ssfc_init, HOOK_PRIO_FIRST); + +enum ec_ssfc_base_sensor get_cbi_ssfc_base_sensor(void) +{ + return (enum ec_ssfc_base_sensor)cached_ssfc.base_sensor; +} + +enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void) +{ + return (enum ec_ssfc_lid_sensor)cached_ssfc.lid_sensor; +} diff --git a/board/dibbi/cbi_ssfc.h b/board/dibbi/cbi_ssfc.h new file mode 100644 index 0000000000..df8334879d --- /dev/null +++ b/board/dibbi/cbi_ssfc.h @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef _DEDEDE_CBI_SSFC__H_ +#define _DEDEDE_CBI_SSFC__H_ + +#include "stdint.h" + +/**************************************************************************** + * Dedede CBI Second Source Factory Cache + */ + +/* + * Base Sensor (Bits 0-2) + */ +enum ec_ssfc_base_sensor { + SSFC_SENSOR_BASE_DEFAULT = 0, + SSFC_SENSOR_BMI160 = 1, + SSFC_SENSOR_ICM426XX = 2, + SSFC_SENSOR_LSM6DSM = 3, + SSFC_SENSOR_ICM42607 = 4 +}; + +/* + * Lid Sensor (Bits 3-5) + */ +enum ec_ssfc_lid_sensor { + SSFC_SENSOR_LID_DEFAULT = 0, + SSFC_SENSOR_BMA255 = 1, + SSFC_SENSOR_KX022 = 2, + SSFC_SENSOR_LIS2DWL = 3 +}; + +union dedede_cbi_ssfc { + struct { + uint32_t base_sensor : 3; + uint32_t lid_sensor : 3; + uint32_t reserved_2 : 26; + }; + uint32_t raw_value; +}; + +/** + * Get the Base sensor type from SSFC_CONFIG. + * + * @return the Base sensor board type. + */ +enum ec_ssfc_base_sensor get_cbi_ssfc_base_sensor(void); + +/** + * Get the Lid sensor type from SSFC_CONFIG. + * + * @return the Lid sensor board type. + */ +enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void); + +#endif /* _DEDEDE_CBI_SSFC__H_ */ diff --git a/board/dibbi/ec.tasklist b/board/dibbi/ec.tasklist new file mode 100644 index 0000000000..5ecc92b40e --- /dev/null +++ b/board/dibbi/ec.tasklist @@ -0,0 +1,24 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * See CONFIG_TASK_LIST in config.h for details. + */ + +#define CONFIG_TASK_LIST \ + TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 1, LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(CHARGER, charger_task, NULL, TRENTA_TASK_STACK_SIZE) \ + TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(HOSTCMD, host_command_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(POWERBTN, power_button_task, NULL, ULTRA_TASK_STACK_SIZE) \ + TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, ULTRA_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_C0, pd_task, NULL, ULTRA_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_C1, pd_task, NULL, ULTRA_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, ULTRA_TASK_STACK_SIZE) diff --git a/board/dibbi/gpio.inc b/board/dibbi/gpio.inc new file mode 100644 index 0000000000..731d2c4cda --- /dev/null +++ b/board/dibbi/gpio.inc @@ -0,0 +1,138 @@ +/* -*- mode:c -*- + * + * Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Declare symbolic names for all the GPIOs that we care about. + * Note: Those with interrupt handlers must be declared first. */ + +/* Power State interrupts */ +GPIO_INT(SLP_S4_L, PIN(I, 5), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(SLP_S3_L, PIN(H, 3), GPIO_INT_BOTH, baseboard_all_sys_pgood_interrupt) +GPIO_INT(SLP_S0_L, PIN(E, 4), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(SLP_SUS_L, PIN(G, 2), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(VCCIN_AUX_VID0, PIN(D, 0), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(RSMRST_PWRGD_L, PIN(E, 1), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(CPU_C10_GATE_L, PIN(G, 1), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(PG_DRAM_OD, PIN(D, 3), GPIO_INT_BOTH, baseboard_all_sys_pgood_interrupt) +GPIO_INT(PG_PP1050_ST_OD, PIN(L, 1), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(VCCIN_AUX_VID1, PIN(K, 1), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(PG_VCCIO_EXT_OD, PIN(D, 7), GPIO_INT_BOTH, baseboard_all_sys_pgood_interrupt) +GPIO_INT(ESPI_RESET_L, PIN(D, 2), GPIO_INT_FALLING | GPIO_SEL_1P8V, espi_reset_pin_asserted_interrupt) + +GPIO_INT(H1_EC_PWR_BTN_ODL, PIN(E, 2), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt) +#ifdef CONFIG_LOW_POWER_IDLE +/* Used to wake up the EC from Deep Doze mode when writing to console */ +GPIO_INT(UART1_RX, PIN(B, 0), GPIO_INT_BOTH, uart_deepsleep_interrupt) /* UART_DBG_TX_EC_RX */ +#endif + +/* USB-C interrupts */ +GPIO_INT(USB_C0_INT_ODL, PIN(K, 0), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c0_interrupt) /* BC12 and charger */ +GPIO_INT(USB_C1_INT_V0_ODL, PIN(B, 5), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c1_interrupt) /* TCPC, charger, BC12 - board version 0 */ +GPIO_INT(USB_C1_INT_V1_ODL, PIN(E, 6), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c1_interrupt) /* TCPC, charger, BC12 - board version 1 */ +GPIO_INT(USB_C0_CCSBU_OVP_ODL, PIN(K, 6), GPIO_INT_FALLING | GPIO_PULL_UP, c0_ccsbu_ovp_interrupt) /* Fault protection */ + +/* Other interrupts */ +GPIO_INT(LID_OPEN, PIN(F, 3), GPIO_INT_BOTH, lid_interrupt) +GPIO_INT(LID_360_L, PIN(A, 7), GPIO_INT_BOTH, gmr_tablet_switch_isr) +GPIO_INT(VOLDN_BTN_ODL, PIN(I, 6), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) +GPIO_INT(VOLUP_BTN_ODL, PIN(I, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) +GPIO_INT(BASE_SIXAXIS_INT_L, PIN(J, 0), GPIO_INT_FALLING | GPIO_SEL_1P8V, lsm6dsm_interrupt) +GPIO_INT(EC_WP_OD, PIN(A, 6), GPIO_INT_BOTH, switch_interrupt) + +/* Power sequence GPIOs */ +GPIO(EC_AP_RTCRST, PIN(K, 2), GPIO_OUT_LOW) +GPIO(EC_AP_PWR_BTN_ODL, PIN(B, 6), GPIO_ODR_HIGH) +GPIO(EC_AP_DPWROK, PIN(L, 7), GPIO_OUT_LOW) +GPIO(EC_AP_RSMRST_L, PIN(H, 0), GPIO_OUT_LOW) +GPIO(EC_AP_WAKE_ODL, PIN(D, 5), GPIO_ODR_HIGH) +GPIO(SYS_RST_ODL, PIN(D, 1), GPIO_ODR_HIGH) +GPIO(EC_AP_SYS_PWROK, PIN(F, 2), GPIO_OUT_LOW) +GPIO(PG_PP5000_U_OD, PIN(E, 3), GPIO_INPUT) +GPIO(EN_PP3300_A, PIN(C, 5), GPIO_OUT_LOW) +GPIO(EC_AP_PCH_PWROK_OD, PIN(D, 6), GPIO_ODR_LOW) +GPIO(EN_PP5000_U, PIN(K, 5), GPIO_OUT_LOW) +/* TODO(b:149775160) - Modify if needed if we ever use this signal. */ +GPIO(EN_VCCST, PIN(D, 4), GPIO_INPUT) +GPIO(EN_VCCIO_EXT, PIN(B, 2), GPIO_OUT_LOW) +GPIO(EC_PROCHOT_ODL, PIN(I, 1), GPIO_ODR_HIGH | GPIO_SEL_1P8V) +GPIO(EC_AP_VCCST_PWRGD_OD, PIN(E, 5), GPIO_ODR_LOW) +GPIO(ALL_SYS_PWRGD, PIN(B, 7), GPIO_OUT_LOW) +GPIO(EN_SLP_Z, PIN(K, 3), GPIO_OUT_LOW) + +/* Required for icelake chipset code, but implemented through other means for dedede */ +UNIMPLEMENTED(AC_PRESENT) +UNIMPLEMENTED(PG_EC_DSW_PWROK) +UNIMPLEMENTED(PG_EC_ALL_SYS_PWRGD) + +/* I2C pins - Alternate function below configures I2C module on these pins */ +GPIO(EC_I2C_EEPROM_SCL, PIN(B, 3), GPIO_INPUT) +GPIO(EC_I2C_EEPROM_SDA, PIN(B, 4), GPIO_INPUT) +GPIO(EC_I2C_BATTERY_SCL, PIN(C, 1), GPIO_INPUT) +GPIO(EC_I2C_BATTERY_SDA, PIN(C, 2), GPIO_INPUT) +GPIO(EC_I2C_SENSOR_SCL, PIN(F, 6), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_SENSOR_SDA, PIN(F, 7), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_SUB_USB_C1_SCL, PIN(E, 0), GPIO_INPUT) +GPIO(EC_I2C_SUB_USB_C1_SDA, PIN(E, 7), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_SCL, PIN(A, 4), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_SDA, PIN(A, 5), GPIO_INPUT) + +/* USB pins */ +GPIO(EN_USB_C0_CC1_VCONN, PIN(H, 4), GPIO_OUT_LOW) +GPIO(EN_USB_C0_CC2_VCONN, PIN(H, 6), GPIO_OUT_LOW) +GPIO(EC_AP_USB_C0_HPD, PIN(L, 4), GPIO_OUT_LOW) +GPIO(EC_AP_USB_C1_HDMI_HPD, PIN(K, 7), GPIO_OUT_LOW) +GPIO(USB_C0_FRS, PIN(C, 4), GPIO_OUT_LOW) +GPIO(HDMI_SEL_L, PIN(C, 6), GPIO_OUT_HIGH) +GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW) /* Board rev 1, NC board rev 0 */ + +/* MKBP event synchronization */ +GPIO(EC_AP_MKBP_INT_L, PIN(L, 5), GPIO_ODR_HIGH) + +/* Misc pins which will run to the I/O board */ +GPIO(EC_SUB_IO_1_1, PIN(L, 3), GPIO_INPUT) +GPIO(EC_SUB_IO_1_2, PIN(F, 0), GPIO_INPUT) +GPIO(EC_SUB_IO_2_1, PIN(F, 1), GPIO_INPUT) +GPIO(EC_SUB_IO_2_2, PIN(L, 2), GPIO_INPUT) + +/* Misc */ +GPIO(EN_BL_OD, PIN(K, 4), GPIO_ODR_LOW) +GPIO(EC_ENTERING_RW, PIN(G, 0), GPIO_OUT_LOW) +GPIO(CCD_MODE_ODL, PIN(H, 5), GPIO_ODR_HIGH) +GPIO(EC_BATTERY_PRES_ODL, PIN(I, 4), GPIO_INPUT) +GPIO(PEN_DET_ODL, PIN(J, 1), GPIO_INPUT | GPIO_PULL_UP) +GPIO(EN_KB_BL, PIN(J, 3), GPIO_OUT_LOW) /* Currently unused */ +GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW) + +/* NC pins, enable internal pull-down to avoid floating state. */ +GPIO(GPIOC0_NC, PIN(C, 0), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOC3_NC, PIN(C, 3), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOG3_NC, PIN(G, 3), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOG4_NC, PIN(G, 4), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOG5_NC, PIN(G, 5), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOG6_NC, PIN(G, 6), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOG7_NC, PIN(G, 7), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOJ4_NC, PIN(J, 4), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOJ5_NC, PIN(J, 5), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOJ6_NC, PIN(J, 6), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOM6_NC, PIN(M, 6), GPIO_INPUT | GPIO_PULL_DOWN) + +/* Alternate functions GPIO definitions */ +/* UART */ +ALTERNATE(PIN_MASK(B, BIT(0) | BIT(1)), 0, MODULE_UART, 0) /* UART for debug */ + +/* I2C */ +ALTERNATE(PIN_MASK(B, BIT(3) | BIT(4)), 0, MODULE_I2C, 0) /* I2C0 */ +ALTERNATE(PIN_MASK(C, BIT(1) | BIT(2)), 0, MODULE_I2C, 0) /* I2C1 */ +ALTERNATE(PIN_MASK(F, BIT(6) | BIT(7)), 0, MODULE_I2C, GPIO_SEL_1P8V) /* I2C2 - 1.8V */ +ALTERNATE(PIN_MASK(E, BIT(0) | BIT(7)), 0, MODULE_I2C, 0) /* I2C4 */ +ALTERNATE(PIN_MASK(A, BIT(4) | BIT(5)), 0, MODULE_I2C, 0) /* I2C5 */ + +/* ADC */ +ALTERNATE(PIN_MASK(L, BIT(0)), 0, MODULE_ADC, 0) /* ADC13: EC_SUB_ANALOG */ +ALTERNATE(PIN_MASK(I, BIT(0) | BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC0: EC_VSNS_PP3300_A, ADC2: TEMP_SENSOR_1, ADC3: TEMP_SENSOR_2 */ + +/* PWM */ +ALTERNATE(PIN_MASK(A, BIT(0) | BIT(1) | BIT(2) | BIT(3)), 0, MODULE_PWM, 0) /* KB_BL_PWM, LED_[R,G,B]_ODL */ diff --git a/board/dibbi/led.c b/board/dibbi/led.c new file mode 100644 index 0000000000..74d6419aea --- /dev/null +++ b/board/dibbi/led.c @@ -0,0 +1,82 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Waddledee specific PWM LED settings. */ + +#include "common.h" +#include "ec_commands.h" +#include "led_pwm.h" +#include "pwm.h" +#include "util.h" + +const enum ec_led_id supported_led_ids[] = { + EC_LED_ID_POWER_LED, +}; +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +/* + * Board has one physical LED with red, green, and blue + */ +struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = { + /* Red, Green, Blue */ + [EC_LED_COLOR_RED] = { 100, 0, 0 }, + [EC_LED_COLOR_GREEN] = { 0, 100, 0 }, + [EC_LED_COLOR_BLUE] = { 0, 0, 100 }, + [EC_LED_COLOR_YELLOW] = { 50, 50, 0 }, + [EC_LED_COLOR_WHITE] = { 50, 50, 50 }, + [EC_LED_COLOR_AMBER] = { 70, 30, 0 }, +}; + +/* One logical LED with red, green, and blue channels. */ +struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { + { + .ch0 = PWM_CH_LED_RED, + .ch1 = PWM_CH_LED_GREEN, + .ch2 = PWM_CH_LED_BLUE, + .enable = &pwm_enable, + .set_duty = &pwm_set_duty, + }, +}; + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + memset(brightness_range, '\0', + sizeof(*brightness_range) * EC_LED_COLOR_COUNT); + brightness_range[EC_LED_COLOR_RED] = 100; + brightness_range[EC_LED_COLOR_GREEN] = 100; + brightness_range[EC_LED_COLOR_BLUE] = 100; + brightness_range[EC_LED_COLOR_YELLOW] = 100; + brightness_range[EC_LED_COLOR_WHITE] = 100; + brightness_range[EC_LED_COLOR_AMBER] = 100; +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + enum pwm_led_id pwm_id; + + /* Convert ec_led_id to pwm_led_id. */ + if (led_id == EC_LED_ID_POWER_LED) + pwm_id = PWM_LED0; + else + return EC_ERROR_UNKNOWN; + + if (brightness[EC_LED_COLOR_RED]) + set_pwm_led_color(pwm_id, EC_LED_COLOR_RED); + else if (brightness[EC_LED_COLOR_GREEN]) + set_pwm_led_color(pwm_id, EC_LED_COLOR_GREEN); + else if (brightness[EC_LED_COLOR_BLUE]) + set_pwm_led_color(pwm_id, EC_LED_COLOR_BLUE); + else if (brightness[EC_LED_COLOR_YELLOW]) + set_pwm_led_color(pwm_id, EC_LED_COLOR_YELLOW); + else if (brightness[EC_LED_COLOR_WHITE]) + set_pwm_led_color(pwm_id, EC_LED_COLOR_WHITE); + else if (brightness[EC_LED_COLOR_AMBER]) + set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER); + else + /* Otherwise, the "color" is "off". */ + set_pwm_led_color(pwm_id, -1); + + return EC_SUCCESS; +} diff --git a/board/dibbi/usb_pd_policy.c b/board/dibbi/usb_pd_policy.c new file mode 100644 index 0000000000..40dc896050 --- /dev/null +++ b/board/dibbi/usb_pd_policy.c @@ -0,0 +1,74 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "battery_smart.h" +#include "charge_manager.h" +#include "charger.h" +#include "chipset.h" +#include "common.h" +#include "console.h" +#include "driver/charger/sm5803.h" +#include "driver/tcpm/tcpci.h" +#include "usb_pd.h" + +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) + +int pd_check_vconn_swap(int port) +{ + /* Allow VCONN swaps if the AP is on */ + return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON); +} + +void pd_power_supply_reset(int port) +{ + int prev_en; + + if (port < 0 || port >= board_get_usb_pd_port_count()) + return; + + prev_en = charger_is_sourcing_otg_power(port); + + /* Disable Vbus */ + charger_enable_otg_power(port, 0); + + /* Discharge Vbus if previously enabled */ + if (prev_en) + sm5803_set_vbus_disch(port, 1); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_set_power_supply_ready(int port) +{ + enum ec_error_list rv; + + /* Disable sinking */ + rv = sm5803_vbus_sink_enable(port, 0); + if (rv) + return rv; + + /* Disable Vbus discharge */ + sm5803_set_vbus_disch(port, 0); + + /* Provide Vbus */ + charger_enable_otg_power(port, 1); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +__override bool pd_check_vbus_level(int port, enum vbus_level level) +{ + return sm5803_check_vbus_level(port, level); +} + +int pd_snk_is_vbus_provided(int port) +{ + return sm5803_is_vbus_present(port); +} diff --git a/board/dibbi/vif_override.xml b/board/dibbi/vif_override.xml new file mode 100644 index 0000000000..32736caf64 --- /dev/null +++ b/board/dibbi/vif_override.xml @@ -0,0 +1,3 @@ + diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 455cd1f1c0..9b1cbca944 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -231,6 +231,7 @@ NDS32_BOARDS = [ "beetley", "blipper", "boten", + "dibbi", "drawcia", "galtic", "gooey", -- cgit v1.2.1 From d97f9707e984a98f7b7ca8b52c85e635c9c37e99 Mon Sep 17 00:00:00 2001 From: Zick Wei Date: Thu, 13 Oct 2022 10:43:47 +0800 Subject: zephyr: add fan rpm deviation to shim BUG=none BRANCH=none TEST=On yaviks, make sure fan work intended. Signed-off-by: Zick Wei Change-Id: I43a29b337d5a61d8bc36554c944a93171742f984 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3951609 Reviewed-by: Andrew McRae Commit-Queue: Andrew McRae Code-Coverage: Andrew McRae Tested-by: Andrew McRae Reviewed-by: Peter Marheine --- include/fan.h | 3 +++ zephyr/dts/bindings/fan/cros-ec,fans.yaml | 6 ++++++ zephyr/shim/src/fan.c | 16 +++++----------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/fan.h b/include/fan.h index 31af7a58ff..cefb4c0dba 100644 --- a/include/fan.h +++ b/include/fan.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_FAN_H #define __CROS_EC_FAN_H +#include + #ifdef CONFIG_ZEPHYR #ifdef CONFIG_PLATFORM_EC_FAN @@ -40,6 +42,7 @@ struct fan_rpm { int rpm_min; int rpm_start; int rpm_max; + uint8_t rpm_deviation; }; /* Characteristic of each physical fan */ diff --git a/zephyr/dts/bindings/fan/cros-ec,fans.yaml b/zephyr/dts/bindings/fan/cros-ec,fans.yaml index 9aa6317f61..a9d198e37c 100644 --- a/zephyr/dts/bindings/fan/cros-ec,fans.yaml +++ b/zephyr/dts/bindings/fan/cros-ec,fans.yaml @@ -24,6 +24,12 @@ child-binding: type: int description: Maximum fan speed (in RPM) + rpm_deviation: + required: false + default: 7 + type: int + description: + Percentage of fan rpm deviation pwms: type: phandle-array required: true diff --git a/zephyr/shim/src/fan.c b/zephyr/shim/src/fan.c index c7074b0c4d..a18a33beec 100644 --- a/zephyr/shim/src/fan.c +++ b/zephyr/shim/src/fan.c @@ -43,6 +43,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, .rpm_min = DT_PROP(node_id, rpm_min), \ .rpm_start = DT_PROP(node_id, rpm_start), \ .rpm_max = DT_PROP(node_id, rpm_max), \ + .rpm_deviation = DT_PROP(node_id, rpm_deviation), \ }; #define FAN_INST(node_id) \ @@ -61,14 +62,6 @@ DT_INST_FOREACH_CHILD(0, FAN_CONFIGS) const struct fan_t fans[FAN_CH_COUNT] = { DT_INST_FOREACH_CHILD(0, FAN_INST) }; -/* Rpm deviation (Unit:percent) */ -#ifndef RPM_DEVIATION -#define RPM_DEVIATION 7 -#endif - -/* Margin of target rpm */ -#define RPM_MARGIN(rpm_target) (((rpm_target)*RPM_DEVIATION) / 100) - /* Fan mode */ enum fan_mode { /* FAN rpm mode */ @@ -226,9 +219,10 @@ enum fan_status fan_smart_control(int ch) int duty, rpm_diff; int rpm_actual = data->rpm_actual; int rpm_target = data->rpm_target; + int deviation = fans[ch].rpm->rpm_deviation; /* wait rpm is stable */ - if (ABS(rpm_actual - data->rpm_pre) > RPM_MARGIN(rpm_actual)) { + if (ABS(rpm_actual - data->rpm_pre) > (rpm_target * deviation / 100)) { data->rpm_pre = rpm_actual; return FAN_STATUS_CHANGING; } @@ -243,7 +237,7 @@ enum fan_status fan_smart_control(int ch) return FAN_STATUS_STOPPED; } - if (rpm_diff > RPM_MARGIN(rpm_target)) { + if (rpm_diff > (rpm_target * deviation / 100)) { /* Increase PWM duty */ if (duty == 100) { return FAN_STATUS_FRUSTRATED; @@ -251,7 +245,7 @@ enum fan_status fan_smart_control(int ch) fan_adjust_duty(ch, rpm_diff, duty); return FAN_STATUS_CHANGING; - } else if (rpm_diff < -RPM_MARGIN(rpm_target)) { + } else if (rpm_diff < -(rpm_target * deviation / 100)) { /* Decrease PWM duty */ if (duty == 1 && rpm_target != 0) { return FAN_STATUS_FRUSTRATED; -- cgit v1.2.1 From 8f692937051c72814c1856c472b2a8cb0ccd9851 Mon Sep 17 00:00:00 2001 From: Zick Wei Date: Fri, 14 Oct 2022 12:58:06 +0800 Subject: zephyr: add fan custom control config BUG=none BRANCH=none TEST=On yaviks, verify fan work intended. Signed-off-by: Zick Wei Change-Id: I85f144b6b84f9a4a559cbce89ed141af8657207d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3955203 Commit-Queue: Andrew McRae Tested-by: Andrew McRae Code-Coverage: Andrew McRae Reviewed-by: Andrew McRae Code-Coverage: Zoss --- util/config_allowed.txt | 1 - zephyr/Kconfig.temperature | 7 +++++++ zephyr/shim/include/config_chip.h | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/util/config_allowed.txt b/util/config_allowed.txt index dcb614c033..bdf8e0eca8 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -340,7 +340,6 @@ CONFIG_CROS_EC_RW_MEM_SIZE CONFIG_CTN730 CONFIG_CTS_TASK_LIST CONFIG_CURVE25519 -CONFIG_CUSTOM_FAN_CONTROL CONFIG_DATA_RAM_SIZE CONFIG_DEBUG_BRINGUP CONFIG_DEBUG_DISABLE_WRITE_BUFFER diff --git a/zephyr/Kconfig.temperature b/zephyr/Kconfig.temperature index 09756663bc..8b46d323a8 100644 --- a/zephyr/Kconfig.temperature +++ b/zephyr/Kconfig.temperature @@ -90,6 +90,13 @@ config PLATFORM_EC_FAN available. Also enables a periodic task (1s) to verify fan is running (is not stalled). +config PLATFORM_EC_CUSTOM_FAN_CONTROL + bool "Fan custom control support" + default n + help + Enable fan custom control to let projects define + their own fan control mechanism by EC. + if PLATFORM_EC_FAN config PLATFORM_EC_NUM_FANS diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 265b64403f..3ecfd5baf7 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -641,6 +641,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #define CONFIG_FAN_BYPASS_SLOW_RESPONSE #endif +#undef CONFIG_CUSTOM_FAN_CONTROL +#ifdef CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL +#define CONFIG_CUSTOM_FAN_CONTROL +#endif + #ifdef CONFIG_PLATFORM_EC_I2C /* Also see shim/include/i2c/i2c.h which defines the ports enum */ #define CONFIG_I2C_CONTROLLER -- cgit v1.2.1 From 54e6e96e64196737aa491b1d647cb765d5170b84 Mon Sep 17 00:00:00 2001 From: Zick Wei Date: Wed, 2 Nov 2022 09:12:54 +0800 Subject: zephyr: add device tree binding for fan steps Some variant may want use EC control fan steps with their own algorithm, introduce fan_steps to zephyr device binding allow variant create their own fan steps with differnet thermal sensor temperature. BUG=b:253557900 BRANCH=none TEST=zmake build -a Signed-off-by: Zick Wei Change-Id: I96dd23b492321113d8b3cda2cb26eb0286e996f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997772 Reviewed-by: Andrew McRae Code-Coverage: Zoss Commit-Queue: Andrew McRae Reviewed-by: Devin Lu Tested-by: Andrew McRae Code-Coverage: Andrew McRae --- zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml diff --git a/zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml b/zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml new file mode 100644 index 0000000000..3befe43868 --- /dev/null +++ b/zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml @@ -0,0 +1,27 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +description: Fan steps parent node +compatible: "cros-ec,fan-steps" +child-binding: + description: Support multiple thermal sensor temperature to trigger different fans speed, + each step could have different rpm for each fan + properties: + temp_on: + required: false + type: array + description: + Temperatures for each sensor to trigger next fan level, + mapping to variant overlay + temp_off: + required: false + type: array + description: + Temperatures for each sensor to trigger previous fan level, + mapping to variant overlay + rpm_target: + required: false + type: array + description: + Support multiple fan speed target for each level (in RPM), + -- cgit v1.2.1 From b33d0923d0965cc478ef43ec1c2e4eac6f20e4b4 Mon Sep 17 00:00:00 2001 From: Zick Wei Date: Wed, 2 Nov 2022 09:55:37 +0800 Subject: yaviks: update fan table to v1-1 Implement fan steps table V1-1_20221015, and enable config CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL, set fan rpm deviation to 1. BUG=b:253557900 BRANCH=none TEST=make sure fan follow fan steps. Signed-off-by: Zick Wei Change-Id: Ie9876af7a0cb85b9bd8dfa85a9b3b4950c24c50f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997773 Code-Coverage: Andrew McRae Reviewed-by: Andrew McRae Commit-Queue: Andrew McRae Tested-by: Andrew McRae --- zephyr/program/nissa/CMakeLists.txt | 1 + zephyr/program/nissa/yaviks/fan.dtsi | 71 ++++++++++++++++++ zephyr/program/nissa/yaviks/overlay.dtsi | 46 +++--------- zephyr/program/nissa/yaviks/project.conf | 1 + zephyr/program/nissa/yaviks/project.overlay | 1 + zephyr/program/nissa/yaviks/src/thermal.c | 107 ++++++++++++++++++++++++++++ 6 files changed, 190 insertions(+), 37 deletions(-) create mode 100644 zephyr/program/nissa/yaviks/fan.dtsi create mode 100644 zephyr/program/nissa/yaviks/src/thermal.c diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index 8769af58ba..7088092ae6 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -77,6 +77,7 @@ if(DEFINED CONFIG_BOARD_YAVIKS) zephyr_library_sources( "yaviks/src/led.c" "yaviks/src/keyboard.c" + "yaviks/src/thermal.c" ) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "yaviks/src/usbc.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "yaviks/src/charger.c") diff --git a/zephyr/program/nissa/yaviks/fan.dtsi b/zephyr/program/nissa/yaviks/fan.dtsi new file mode 100644 index 0000000000..229530b57a --- /dev/null +++ b/zephyr/program/nissa/yaviks/fan.dtsi @@ -0,0 +1,71 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/ { + fans { + compatible = "cros-ec,fans"; + fan_0 { + pwms = <&pwm2 PWM_CHANNEL_2 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + tach = <&tach1>; + rpm_min = <2500>; + rpm_start = <2500>; + rpm_max = <4100>; + rpm_deviation = <1>; + enable_gpio = <&gpio_fan_enable>; + }; + }; + fan_steps { + compatible = "cros-ec,fan-steps"; + level_0 { + temp_on = <44 47 0>; + temp_off = <99 99 99>; + rpm_target = <0>; + }; + level_1 { + temp_on = <48 48 0>; + temp_off = <43 45 99>; + rpm_target = <2600>; + }; + level_2 { + temp_on = <50 49 0>; + temp_off = <47 46 99>; + rpm_target = <2800>; + }; + level_3 { + temp_on = <52 50 54>; + temp_off = <49 47 51>; + rpm_target = <3000>; + }; + level_4 { + temp_on = <54 56 60>; + temp_off = <51 48 52>; + rpm_target = <3300>; + }; + level_5 { + temp_on = <60 60 64>; + temp_off = <53 52 56>; + rpm_target = <3600>; + }; + level_6 { + temp_on = <100 100 100>; + temp_off = <59 54 58>; + rpm_target = <4100>; + }; + }; +}; +/* pwm for fan */ +&pwm2 { + status = "okay"; + prescaler-cx = ; + pinctrl-0 = <&pwm2_gpa2_default>; + pinctrl-names = "default"; +}; +/* fan tachometer sensor */ +&tach1 { + status = "okay"; + channel = ; + pulses-per-round = <2>; + pinctrl-0 = <&tach1a_gpd7_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/yaviks/overlay.dtsi b/zephyr/program/nissa/yaviks/overlay.dtsi index d768116444..2a5a8561a0 100644 --- a/zephyr/program/nissa/yaviks/overlay.dtsi +++ b/zephyr/program/nissa/yaviks/overlay.dtsi @@ -130,17 +130,17 @@ }; }; - temp_cpu: cpu { + temp_cpu_thermistor: cpu { compatible = "cros-ec,temp-sensor-thermistor"; thermistor = <&thermistor_3V3_51K1_47K_4050B>; adc = <&adc_temp_sensor_1>; }; - temp_5v_regulator: 5v_regulator { + temp_5v_regulator_thermistor: 5v-regulator { compatible = "cros-ec,temp-sensor-thermistor"; thermistor = <&thermistor_3V3_51K1_47K_4050B>; adc = <&adc_temp_sensor_2>; }; - temp_charger: charger { + temp_charger_thermistor: charger { compatible = "cros-ec,temp-sensor-thermistor"; thermistor = <&thermistor_3V3_51K1_47K_4050B>; adc = <&adc_temp_sensor_3>; @@ -148,32 +148,32 @@ named-temp-sensors { compatible = "cros-ec,temp-sensors"; - cpu { + temp_cpu: cpu { temp_fan_off = <45>; temp_fan_max = <60>; temp_host_high = <75>; temp_host_halt = <85>; temp_host_release_high = <65>; power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_cpu>; + sensor = <&temp_cpu_thermistor>; }; - 5v_regulator { + temp_5v_regulator: 5v-regulator { temp_fan_off = <50>; temp_fan_max = <65>; temp_host_high = <75>; temp_host_halt = <85>; temp_host_release_high = <65>; power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_5v_regulator>; + sensor = <&temp_5v_regulator_thermistor>; }; - charger { + temp_charger: charger { temp_fan_off = <50>; temp_fan_max = <65>; temp_host_high = <80>; temp_host_halt = <85>; temp_host_release_high = <75>; power-good-pin = <&gpio_ec_soc_dsw_pwrok>; - sensor = <&temp_charger>; + sensor = <&temp_charger_thermistor>; }; }; @@ -235,18 +235,6 @@ }; }; }; - - fans { - compatible = "cros-ec,fans"; - fan_0 { - pwms = <&pwm2 PWM_CHANNEL_2 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - tach = <&tach1>; - rpm_min = <2600>; - rpm_start = <2600>; - rpm_max = <4100>; - enable_gpio = <&gpio_fan_enable>; - }; - }; }; &thermistor_3V3_51K1_47K_4050B { @@ -384,19 +372,3 @@ &usbpd0 { status = "okay"; }; - -/* pwm for fan */ -&pwm2 { - status = "okay"; - prescaler-cx = ; - pinctrl-0 = <&pwm2_gpa2_default>; - pinctrl-names = "default"; -}; -/* fan tachometer sensor */ -&tach1 { - status = "okay"; - channel = ; - pulses-per-round = <2>; - pinctrl-0 = <&tach1a_gpd7_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/nissa/yaviks/project.conf b/zephyr/program/nissa/yaviks/project.conf index 0e385b843e..80a9e9ea97 100644 --- a/zephyr/program/nissa/yaviks/project.conf +++ b/zephyr/program/nissa/yaviks/project.conf @@ -28,6 +28,7 @@ CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=n # Fan CONFIG_PLATFORM_EC_FAN=y +CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y # LED CONFIG_PLATFORM_EC_LED_PWM=n diff --git a/zephyr/program/nissa/yaviks/project.overlay b/zephyr/program/nissa/yaviks/project.overlay index a7ce97a8b3..fecd1c98c8 100644 --- a/zephyr/program/nissa/yaviks/project.overlay +++ b/zephyr/program/nissa/yaviks/project.overlay @@ -6,6 +6,7 @@ #include "../cbi.dtsi" #include "cbi.dtsi" +#include "fan.dtsi" #include "gpio.dtsi" #include "keyboard.dtsi" #include "overlay.dtsi" diff --git a/zephyr/program/nissa/yaviks/src/thermal.c b/zephyr/program/nissa/yaviks/src/thermal.c new file mode 100644 index 0000000000..43b30f0497 --- /dev/null +++ b/zephyr/program/nissa/yaviks/src/thermal.c @@ -0,0 +1,107 @@ +/* Copyright 2022 The ChromiumOS Authors. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include "common.h" +#include "fan.h" +#include "temp_sensor/temp_sensor.h" +#include "thermal.h" +#include "util.h" + +#define TEMP_CPU TEMP_SENSOR_ID(DT_NODELABEL(temp_cpu)) +#define TEMP_5V TEMP_SENSOR_ID(DT_NODELABEL(temp_5v_regulator)) +#define TEMP_CHARGER TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)) + +struct fan_step { + /* + * Sensor 1~3 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int8_t on[TEMP_SENSOR_COUNT]; + /* + * Sensor 1~3 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int8_t off[TEMP_SENSOR_COUNT]; + /* Fan rpm */ + uint16_t rpm[FAN_CH_COUNT]; +}; + +#define FAN_TABLE_ENTRY(nd) \ + { \ + .on = DT_PROP(nd, temp_on), \ + .off = DT_PROP(nd, temp_off), \ + .rpm = DT_PROP(nd, rpm_target), \ + }, + +static const struct fan_step fan_step_table[] = { DT_FOREACH_CHILD( + DT_INST(0, cros_ec_fan_steps), FAN_TABLE_ENTRY) }; + +int fan_table_to_rpm(int fan, int *temp) +{ + /* current fan level */ + static int current_level; + /* previous sensor temperature */ + static int prev_tmp[TEMP_SENSOR_COUNT]; + int i; + /* + * Compare the current and previous temperature, we have + * the three paths : + * 1. decreasing path. (check the release point) + * 2. increasing path. (check the trigger point) + * 3. invariant path. (return the current RPM) + * + * Yaviks thermal table V1-1 + * Increase path judgment: CPU || (5V && Charger) + * Decrease path judgment: CPU && 5V && Charger + */ + if (temp[TEMP_CPU] < prev_tmp[TEMP_CPU] || + temp[TEMP_5V] < prev_tmp[TEMP_5V] || + temp[TEMP_CHARGER] < prev_tmp[TEMP_CHARGER]) { + for (i = current_level; i > 0; i--) { + if (temp[TEMP_CPU] < fan_step_table[i].off[TEMP_CPU] && + temp[TEMP_5V] < fan_step_table[i].off[TEMP_5V] && + temp[TEMP_CHARGER] < + fan_step_table[i].off[TEMP_CHARGER]) { + current_level = i - 1; + } else + break; + } + } else if (temp[TEMP_CPU] > prev_tmp[TEMP_CPU] || + temp[TEMP_5V] > prev_tmp[TEMP_5V] || + temp[TEMP_CHARGER] > prev_tmp[TEMP_CHARGER]) { + for (i = current_level; i < ARRAY_SIZE(fan_step_table); i++) { + if (temp[TEMP_CPU] > fan_step_table[i].on[TEMP_CPU] || + (temp[TEMP_5V] > fan_step_table[i].on[TEMP_5V] && + temp[TEMP_CHARGER] > + fan_step_table[i].on[TEMP_CHARGER])) { + current_level = i + 1; + } else + break; + } + } + if (current_level < 0) + current_level = 0; + + if (current_level >= ARRAY_SIZE(fan_step_table)) + current_level = ARRAY_SIZE(fan_step_table) - 1; + + for (i = 0; i < TEMP_SENSOR_COUNT; ++i) + prev_tmp[i] = temp[i]; + + return fan_step_table[current_level].rpm[fan]; +} + +void board_override_fan_control(int fan, int *temp) +{ + /* + * In common/fan.c pwm_fan_stop() will turn off fan + * when chipset suspend or shutdown. + */ + if (ap_power_in_state(AP_POWER_STATE_ON)) { + fan_set_rpm_mode(fan, 1); + fan_set_rpm_target(fan, fan_table_to_rpm(fan, temp)); + } +} -- cgit v1.2.1 From 21cc4a3c8faed2ecf6784ef505775483367f71e9 Mon Sep 17 00:00:00 2001 From: Ivy Jian Date: Fri, 4 Nov 2022 09:20:59 +0800 Subject: flash_fp_mcu: Add config_rex BUG=b:256112341 BRANCH=NONE TEST=On rex device, ran /usr/local/bin/flash_fp_mcu successfully Change-Id: I3392782ae936d4d9b706755dca9dc4a5eb4b904f Signed-off-by: Ivy Jian Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005483 Reviewed-by: Subrata Banik Reviewed-by: Ofer Fried Code-Coverage: Zoss Commit-Queue: Subrata Banik Reviewed-by: Andrea Grandi --- util/flash_fp_mcu | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu index 578382c213..4f8fa26749 100644 --- a/util/flash_fp_mcu +++ b/util/flash_fp_mcu @@ -702,6 +702,26 @@ config_ghost() { config_brya } +config_rex() { + readonly TRANSPORT="SPI" + readonly DEVICE="/dev/spidev0.0" + + # See kernel/v5.15/drivers/pinctrl/intel/pinctrl-meteorlake.c + # for pin name and pin number. + # Examine `cat /sys/kernel/debug/pinctrl/INTC1083:00/gpio-ranges` on a + # rex device to determine gpio number from pin number. + # For example: GPP_B11, the pin number is 215 from the pinctrl-meteorlake.c. + # From the gpio-ranges, the gpio value is 925 + (215-204) = 936 + + readonly GPIO_CHIP="gpiochip573" + # FPMCU RST_ODL is on GPP_C23 = 637 + (52 - 29) = 660 + readonly GPIO_NRST=660 + # FPMCU BOOT0 is on GPP_C22 = 637 + (51 - 29) = 659 + readonly GPIO_BOOT0=659 + # FP_PWR_EN is on GPP_B11 = 925 + (215-204) = 936 + readonly GPIO_PWREN=936 +} + config_zork() { readonly TRANSPORT="UART" readonly DEVICE="/dev/ttyS1" -- cgit v1.2.1 From eef651fc8df30c36eaf4afefa154444f387ad731 Mon Sep 17 00:00:00 2001 From: Sue Chen Date: Tue, 8 Nov 2022 12:04:56 +0800 Subject: Craask: fix the orientation of alt base sensor Fix rotation matrix of ALT BASE sensor. BUG=b:258093784 BRANCH=nissa TEST=Factory test item, Sreen Rotation, Pass Signed-off-by: Sue Chen Change-Id: I902792e324e3116db91e74780ba38cf15c762e5f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011360 Reviewed-by: Andrew McRae Code-Coverage: Zoss --- zephyr/program/nissa/craask/motionsense.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/program/nissa/craask/motionsense.dtsi b/zephyr/program/nissa/craask/motionsense.dtsi index 448aed6991..fafdf8fe61 100644 --- a/zephyr/program/nissa/craask/motionsense.dtsi +++ b/zephyr/program/nissa/craask/motionsense.dtsi @@ -66,8 +66,8 @@ }; base_rot_bmi323: base-rotation-bmi323 { - mat33 = <1 0 0 - 0 (-1) 0 + mat33 = <0 (-1) 0 + (-1) 0 0 0 0 (-1)>; }; }; -- cgit v1.2.1 From 55df308bd5a9de7dce31f6d449b545296b2338bf Mon Sep 17 00:00:00 2001 From: Sue Chen Date: Tue, 8 Nov 2022 16:06:19 +0800 Subject: Craask: Fix the D-FET state location for new AP20CBL fet_reg_mask=0x2000 fet_disconnect_val=0x2000 fet_cfet_mask=0x4000 fet_cfet_off_val=0x4000 BUG=b:257860663 BRANCH=nissa TEST=EC log won't show "Batt disconnected" Signed-off-by: Sue Chen Change-Id: I85f0672c20375a59120ecd67a3702c0eddda4d35 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011002 Code-Coverage: Zoss Reviewed-by: Andrew McRae --- zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml b/zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml index 5e64834f15..7faceedb11 100644 --- a/zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml +++ b/zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml @@ -17,22 +17,22 @@ properties: default: 0x3A ship_mode_reg_data: default: [ 0xC574, 0xC574 ] - # Documentation: b/243772306 + # Documentation: b/257860663#comment7 # Manufacturer Access 0x00 - # b14: C-FET Status (0: Off, 1: On) - # b15: D-FET Status (0: Off, 1: On) + # b14: Charging Disabled (0: Off, 1: On) + # b13: Discharging Disabled (0: Off, 1: On) fet_mfgacc_support: default: 1 fet_reg_addr: default: 0x0 fet_reg_mask: - default: 0x8000 + default: 0x2000 fet_disconnect_val: - default: 0x0000 + default: 0x2000 fet_cfet_mask: default: 0x4000 fet_cfet_off_val: - default: 0x0000 + default: 0x4000 # Battery info voltage_max: -- cgit v1.2.1 From 31464f3f210db243a6a61739827a813d89fbe823 Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 8 Nov 2022 15:48:14 +0800 Subject: corsola: Enable CONFIG_PLATFORM_EC_USB_PD_CLEAR_HARD_RESET_STATUS Enable this config will clear the Hard Reset event status after the PD connection is finished initialization,to avoid the AP getting a stale event notification. BUG=b:257223913 BRANCH=none TEST=1. shutdown and boot AP many times, and ensure the external monitor has display 2. USB_MUX status is updated at cros-ec-typec after HARD_RESET event cleared Signed-off-by: mike Change-Id: I43fd666bec7615fbe7a485494888669afa9b7a37 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4012838 Commit-Queue: Eric Yilun Lin Code-Coverage: Zoss Reviewed-by: Eric Yilun Lin Reviewed-by: wen zhang --- zephyr/program/corsola/prj.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf index 110b91bbbb..41162d1a0e 100644 --- a/zephyr/program/corsola/prj.conf +++ b/zephyr/program/corsola/prj.conf @@ -62,6 +62,7 @@ CONFIG_PLATFORM_EC_USB_PD_DPS=y CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_USB_PD_CLEAR_HARD_RESET_STATUS=y # Power Seq CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y -- cgit v1.2.1 From 9ab8139e10cac64e8f2c12ee75bcbf183fe4e294 Mon Sep 17 00:00:00 2001 From: Yi Chou Date: Tue, 8 Nov 2022 11:36:40 +0800 Subject: test/usb_pd_fuzz: Fix the done_cond race conditions We should lock the mutex before using the condition variable, and init/destroy them correctly. BRANCH=none BUG=b:258086787 TEST=make -j buildfuzztests && \ ./build/host/usb_pd_fuzz/usb_pd_fuzz.exe > /dev/null Signed-off-by: Yi Chou Change-Id: I0c5a601d1496ea6b70341c6849230a440d836d82 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011647 Code-Coverage: Zoss Reviewed-by: Paul Fagerburg --- fuzz/usb_pd_fuzz.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fuzz/usb_pd_fuzz.c b/fuzz/usb_pd_fuzz.c index bb462b9e61..23f0ce6884 100644 --- a/fuzz/usb_pd_fuzz.c +++ b/fuzz/usb_pd_fuzz.c @@ -224,7 +224,9 @@ void run_test(int argc, const char **argv) task_wait_event(50 * MSEC); } + pthread_mutex_lock(&lock); pthread_cond_signal(&done_cond); + pthread_mutex_unlock(&lock); } } @@ -266,8 +268,17 @@ int test_fuzz_one_input(const uint8_t *data, unsigned int size) return 0; } + pthread_mutex_init(&lock, NULL); + pthread_cond_init(&done_cond, NULL); + task_set_event(TASK_ID_TEST_RUNNER, TASK_EVENT_FUZZ); + + pthread_mutex_lock(&lock); pthread_cond_wait(&done_cond, &lock); + pthread_mutex_unlock(&lock); + + pthread_cond_destroy(&done_cond); + pthread_mutex_destroy(&lock); return 0; } -- cgit v1.2.1 From 31cf129cb7cb8ae61186ff276c7c68ded80660df Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 8 Nov 2022 03:14:01 -0700 Subject: test: verify common paths for charge_prevent_power_on Check that pressing the power button and having enough charge will allow power-on, while having too little charge and going through the "auto-power-on" will not. This change required moving the static 'automatic_power_on' outside of the charge_prevent_power_on() function so it can be properly reset between tests. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: Iff500728493ad8002fb1daf50845db85690a0a8d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011171 Code-Coverage: Zoss Reviewed-by: Al Semjonovs Commit-Queue: Al Semjonovs --- common/charge_state_v2.c | 22 ++++--- include/charge_state.h | 11 ++-- zephyr/test/drivers/default/CMakeLists.txt | 1 + .../default/src/charge_state_prevent_power_on.c | 77 ++++++++++++++++++++++ 4 files changed, 96 insertions(+), 15 deletions(-) create mode 100644 zephyr/test/drivers/default/src/charge_state_prevent_power_on.c diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 54c49320c6..cd1b5988e2 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -2082,14 +2082,15 @@ int charge_want_shutdown(void) (curr.batt.state_of_charge < battery_level_shutdown); } -int charge_prevent_power_on(int power_button_pressed) +#ifdef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON +test_export_static int charge_prevent_power_on_automatic_power_on = 1; +#endif + +bool charge_prevent_power_on(bool power_button_pressed) { int prevent_power_on = 0; struct batt_params params; struct batt_params *current_batt_params = &curr.batt; -#ifdef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON - static int automatic_power_on = 1; -#endif /* If battery params seem uninitialized then retrieve them */ if (current_batt_params->is_present == BP_NOT_SURE) { @@ -2104,7 +2105,7 @@ int charge_prevent_power_on(int power_button_pressed) * power-ups are user-requested and non-automatic. */ if (power_button_pressed) - automatic_power_on = 0; + charge_prevent_power_on_automatic_power_on = 0; /* * Require a minimum battery level to power on and ensure that the * battery can provide power to the system. @@ -2150,12 +2151,13 @@ int charge_prevent_power_on(int power_button_pressed) * except when auto-power-on at EC startup and the battery * is physically present. */ - prevent_power_on &= - (system_is_locked() || (automatic_power_on + prevent_power_on &= (system_is_locked() || + (charge_prevent_power_on_automatic_power_on #ifdef CONFIG_BATTERY_HW_PRESENT_CUSTOM - && battery_hw_present() == BP_YES + + && battery_hw_present() == BP_YES #endif - )); + )); #endif /* CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON */ #ifdef CONFIG_CHARGE_MANAGER @@ -2189,7 +2191,7 @@ int charge_prevent_power_on(int power_button_pressed) prevent_power_on = 1; #endif /* CONFIG_SYSTEM_UNLOCKED */ - return prevent_power_on; + return prevent_power_on != 0; } static int battery_near_full(void) diff --git a/include/charge_state.h b/include/charge_state.h index 221947b9d1..f8edd604ea 100644 --- a/include/charge_state.h +++ b/include/charge_state.h @@ -158,18 +158,19 @@ static inline int battery_is_below_threshold(enum batt_threshold_type type, #endif /** - * Return non-zero if the battery level is too low to allow power on, even if - * a charger is attached. + * @brief whether or not the charge state will prevent power-on * * @param power_button_pressed True if the power-up attempt is caused by a * power button press. + * @return True if the battery level is too low to allow power on, even if a + * charger is attached. */ #ifdef CONFIG_BATTERY -int charge_prevent_power_on(int power_button_pressed); +bool charge_prevent_power_on(bool power_button_pressed); #else -static inline int charge_prevent_power_on(int power_button_pressed) +static inline bool charge_prevent_power_on(bool power_button_pressed) { - return 0; + return false; } #endif diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt index 617dbe7df5..8f79160878 100644 --- a/zephyr/test/drivers/default/CMakeLists.txt +++ b/zephyr/test/drivers/default/CMakeLists.txt @@ -7,6 +7,7 @@ target_sources(app PRIVATE src/bmi160.c src/bmi260.c src/charge_manager.c + src/charge_state_prevent_power_on.c src/console.c src/console_cmd/adc.c src/console_cmd/battery.c diff --git a/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c b/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c new file mode 100644 index 0000000000..8c563d4de1 --- /dev/null +++ b/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c @@ -0,0 +1,77 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charge_state.h" +#include "charge_state_v2.h" +#include "test/drivers/test_state.h" + +/* Test external variable defined in charge_state_v2 */ +extern int charge_prevent_power_on_automatic_power_on; + +struct charge_state_prevent_power_on_fixture { + struct charge_state_data charge_state_backup; + int automatic_power_on; +}; + +static void *setup(void) +{ + static struct charge_state_prevent_power_on_fixture fixture; + + return &fixture; +} + +static void before(void *f) +{ + struct charge_state_prevent_power_on_fixture *fixture = f; + + /* Backup the current state */ + fixture->charge_state_backup = *charge_get_status(); + fixture->automatic_power_on = + charge_prevent_power_on_automatic_power_on; + + /* Reset the automatic_power_on global */ + charge_prevent_power_on_automatic_power_on = 1; +} + +static void after(void *f) +{ + struct charge_state_prevent_power_on_fixture *fixture = f; + + /* Restore the state from 'before' */ + *charge_get_status() = fixture->charge_state_backup; + charge_prevent_power_on_automatic_power_on = + fixture->automatic_power_on; +} + +ZTEST_SUITE(charge_state_prevent_power_on, drivers_predicate_post_main, setup, + before, after, NULL); + +ZTEST(charge_state_prevent_power_on, test_allow_power_on) +{ + struct batt_params *params = &charge_get_status()->batt; + + /* Force a call to refresh the battery parameters */ + params->is_present = BP_NOT_SURE; + /* Set the charge state to be high enough */ + params->state_of_charge = + CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON; + + /* Verify that we can power on when the power button was pressed */ + zassert_false(charge_prevent_power_on(true)); +} + +ZTEST(charge_state_prevent_power_on, test_low_charge) +{ + struct batt_params *params = &charge_get_status()->batt; + + /* Force a low charge state */ + params->state_of_charge = + CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON - 1; + + /* Verify that we cannot power on during an automatic power-on */ + zassert_true(charge_prevent_power_on(false)); +} -- cgit v1.2.1 From 6b2517c5abe101698343678a7082aaf926627bf5 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 8 Nov 2022 03:27:53 -0700 Subject: test: verify paths in charge_is_consuming_full_input_current() BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: Ib5e1861a033c6df08a41efe3f74389ec84b44fba Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011172 Code-Coverage: Zoss Reviewed-by: Aaron Massey --- .../drivers/default/src/charge_state_prevent_power_on.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c b/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c index 8c563d4de1..83890ee6a1 100644 --- a/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c +++ b/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c @@ -75,3 +75,17 @@ ZTEST(charge_state_prevent_power_on, test_low_charge) /* Verify that we cannot power on during an automatic power-on */ zassert_true(charge_prevent_power_on(false)); } + +ZTEST(charge_state_prevent_power_on, test_consuming_full_input_current) +{ + struct batt_params *params = &charge_get_status()->batt; + + params->state_of_charge = 50; + zassert_true(charge_is_consuming_full_input_current()); + + params->state_of_charge = 0; + zassert_false(charge_is_consuming_full_input_current()); + + params->state_of_charge = 100; + zassert_false(charge_is_consuming_full_input_current()); +} -- cgit v1.2.1 From e28685b395bb082a1ff37e1bede87cf42560c891 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 8 Nov 2022 03:28:37 -0700 Subject: test: add more edge case tests for "chgstate sustain" Catch cases when non-numbers are passed into "chgstate sustain" console command. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I541897ecb27e87cda63b5650d06c187a09186a7b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011173 Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- zephyr/test/drivers/default/src/console_cmd/charge_state.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/zephyr/test/drivers/default/src/console_cmd/charge_state.c b/zephyr/test/drivers/default/src/console_cmd/charge_state.c index 5eb21f9ff8..70b18beb9b 100644 --- a/zephyr/test/drivers/default/src/console_cmd/charge_state.c +++ b/zephyr/test/drivers/default/src/console_cmd/charge_state.c @@ -159,6 +159,16 @@ ZTEST_USER(console_cmd_charge_state, test_sustain_invalid_params) zassert_equal(shell_execute_cmd(get_ec_shell(), "chgstate sustain 50 101"), EC_ERROR_INVAL, NULL); + + /* Verify invalid lower bound (not a number) */ + zassert_equal(shell_execute_cmd(get_ec_shell(), + "chgstate sustain a 50"), + EC_ERROR_PARAM2); + + /* Verify invalid uppoer bound (not a number) */ + zassert_equal(shell_execute_cmd(get_ec_shell(), + "chgstate sustain 30 a"), + EC_ERROR_PARAM3); } struct console_cmd_charge_state_fixture { -- cgit v1.2.1 From 6b59717dd28ec2d41115a3d9e7756ba5274b1569 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 8 Nov 2022 10:39:26 -0700 Subject: test: add wake_mask_events Enable the 'ec-mkbp-host-event-wakeup-mask' node. Currently, all tests should pass the same, additional tests will be added later. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I9fcb2e4e2e3bc7a34b8a2af6401fe920a404c70e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4012961 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/test/drivers/boards/native_posix.overlay | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index 1106ad37d1..c194474052 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -8,6 +8,7 @@ #include #include #include +#include #include / { @@ -34,6 +35,19 @@ disabled = "events", "lpc", "hostcmd"; }; + ec-mkbp-host-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <( + HOST_EVENT_LID_OPEN | + HOST_EVENT_POWER_BUTTON | + HOST_EVENT_AC_CONNECTED | + HOST_EVENT_AC_DISCONNECTED | + HOST_EVENT_HANG_DETECT | + HOST_EVENT_RTC | + HOST_EVENT_MODE_CHANGE | + HOST_EVENT_DEVICE)>; + }; + usbc { #address-cells = <1>; #size-cells = <0>; -- cgit v1.2.1 From 60b60d19496ac295901c7eba888375dbcae3b6b7 Mon Sep 17 00:00:00 2001 From: Yu-An Chen Date: Thu, 3 Nov 2022 12:30:09 +0800 Subject: herobrine: Enable USB C1 PPC interrupt Enable USB C1 PPC interrupt BUG=b:256996124 BRANCH=none TEST=manual check evoker C1 PPC interrupt working LOW_COVERAGE_REASON=no unit test for herobrine board yet. Also, It is a 1-line CL. Signed-off-by: Yu-An Chen Change-Id: I51f97c4842ec8cf6db5a22a983a2e41428db8fc8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000343 Reviewed-by: Wai-Hong Tam Code-Coverage: Zoss Reviewed-by: Bob Moragues Commit-Queue: Wai-Hong Tam --- zephyr/program/herobrine/src/usbc_config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/program/herobrine/src/usbc_config.c b/zephyr/program/herobrine/src/usbc_config.c index f040ab12cb..aea175e1fb 100644 --- a/zephyr/program/herobrine/src/usbc_config.c +++ b/zephyr/program/herobrine/src/usbc_config.c @@ -136,6 +136,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_swctl)); /* Enable TCPC interrupts */ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_pd)); -- cgit v1.2.1 From 5c7a034ffcebd3b392fede60e8a3896685f40d58 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 7 Nov 2022 15:51:52 -0700 Subject: twister: Implement --gcc and --clang options In the CQ we call twister with quite a lot of flags, and those could be in the twister wrapper instead. Add twister arg --toolchain=xxx (with aliases --gcc, --llvm, --clang) which will set the gcov-tool, ZEPHYR_TOOLCHAIN_VARIANT env var, cmake vars CMAKE_C_COMPILER and CMAKE_CXX_COMPILER. Remove now surplus args from firmware_builder.py. BRANCH=None BUG=None TEST=./twister --clobber --gcc --coverage TEST=./twister --clobber --toolchain=host --coverage TEST=./twister --clobber --toolchain=llvm --coverage TEST=./twister --clobber --clang --coverage TEST=./twister --clobber --llvm --coverage Signed-off-by: Jeremy Bettis Change-Id: Ida16653bbe24891fd1114d71cdd3445b4146757d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010583 Commit-Queue: Jeremy Bettis Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- util/twister_launcher.py | 101 +++++++++++++++++++++++++++++++++------------ zephyr/firmware_builder.py | 27 +++--------- 2 files changed, 79 insertions(+), 49 deletions(-) diff --git a/util/twister_launcher.py b/util/twister_launcher.py index 48c9a0e960..023ffbd2fa 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -80,6 +80,7 @@ import os import pathlib import re import shlex +import shutil import subprocess import sys import time @@ -93,7 +94,8 @@ def find_checkout() -> Path: if cros_checkout is not None: return Path(cros_checkout) - # Attempt to locate checkout location relatively if being run outside of chroot. + # Attempt to locate checkout location relatively if being run outside of + # chroot. try: cros_checkout = Path(__file__).resolve().parents[4] assert (cros_checkout / "src").exists() @@ -221,6 +223,16 @@ def check_for_skipped_tests(outdir): return found_skipped +def append_cmake_compiler(cmdline, cmake_var, exe_options): + """Picks the first available exe from exe_options and adds a cmake variable + to cmdline.""" + for exe in exe_options: + exe_path = shutil.which(exe) + if exe_path: + cmdline.append(f"-x={cmake_var}={exe_path}") + return + + def main(): """Run Twister using defaults for the EC project.""" @@ -234,21 +246,6 @@ def main(): if ec_base.resolve() not in zephyr_modules: zephyr_modules.append(ec_base) - # Prepare environment variables for export to Twister. Inherit the parent - # process's environment, but set some default values if not already set. - twister_env = dict(os.environ) - is_in_chroot = Path("/etc/cros_chroot_version").is_file() - extra_env_vars = { - "TOOLCHAIN_ROOT": os.environ.get( - "TOOLCHAIN_ROOT", - str(ec_base / "zephyr") if is_in_chroot else zephyr_base, - ), - "ZEPHYR_TOOLCHAIN_VARIANT": os.environ.get( - "ZEPHYR_TOOLCHAIN_VARIANT", "llvm" if is_in_chroot else "host" - ), - } - twister_env.update(extra_env_vars) - # Twister CLI args # TODO(b/239165779): Reduce or remove the usage of label properties # Zephyr upstream has deprecated the label property. We need to allow @@ -264,6 +261,7 @@ def main(): f"-x=ZEPHYR_BASE={zephyr_base}", f"-x=ZEPHYR_MODULES={';'.join([str(p) for p in zephyr_modules])}", ] + is_in_chroot = Path("/etc/cros_chroot_version").is_file() # `-T` flags (used for specifying test directories to build and run) # require special handling. When run without `-T` flags, Twister will @@ -277,9 +275,7 @@ def main(): parser.add_argument("-T", "--testsuite-root", action="append") parser.add_argument("-p", "--platform", action="append") parser.add_argument("-v", "--verbose", action="count", default=0) - parser.add_argument( - "--gcov-tool", default=str(ec_base / "util" / "llvm-gcov.sh") - ) + parser.add_argument("--gcov-tool") parser.add_argument( "--no-upload-cros-rdb", dest="upload_cros_rdb", action="store_false" ) @@ -288,6 +284,23 @@ def main(): "--outdir", default=os.path.join(os.getcwd(), "twister-out"), ) + parser.add_argument( + "--toolchain", + default=os.environ.get( + "ZEPHYR_TOOLCHAIN_VARIANT", + "llvm" if is_in_chroot else "host", + ), + ) + parser.add_argument( + "--gcc", dest="toolchain", action="store_const", const="host" + ) + parser.add_argument( + "--llvm", + "--clang", + dest="toolchain", + action="store_const", + const="llvm", + ) intercepted_args, other_args = parser.parse_known_args() @@ -305,14 +318,6 @@ def main(): twister_cli.extend(["-T", str(ec_base)]) twister_cli.extend(["-T", str(zephyr_base / "tests/subsys/shell")]) - # Pass through the chosen coverage tool, or fall back on the default choice - # (see add_argument above). - twister_cli.extend( - [ - "--gcov-tool", - intercepted_args.gcov_tool, - ] - ) if intercepted_args.platform: # Pass user-provided -p args when present. for arg in intercepted_args.platform: @@ -324,6 +329,48 @@ def main(): twister_cli.extend(["--outdir", intercepted_args.outdir]) + # Prepare environment variables for export to Twister. Inherit the parent + # process's environment, but set some default values if not already set. + twister_env = dict(os.environ) + extra_env_vars = { + "TOOLCHAIN_ROOT": os.environ.get( + "TOOLCHAIN_ROOT", + str(ec_base / "zephyr") if is_in_chroot else str(zephyr_base), + ), + "ZEPHYR_TOOLCHAIN_VARIANT": intercepted_args.toolchain, + } + gcov_tool = None + if intercepted_args.toolchain == "host": + append_cmake_compiler( + twister_cli, "CMAKE_C_COMPILER", ["x86_64-pc-linux-gnu-gcc", "gcc"] + ) + append_cmake_compiler( + twister_cli, + "CMAKE_CXX_COMPILER", + ["x86_64-pc-linux-gnu-g++", "g++"], + ) + gcov_tool = "gcov" + elif intercepted_args.toolchain == "llvm": + append_cmake_compiler( + twister_cli, + "CMAKE_C_COMPILER", + ["x86_64-pc-linux-gnu-clang", "clang"], + ) + append_cmake_compiler( + twister_cli, + "CMAKE_CXX_COMPILER", + ["x86_64-pc-linux-gnu-clang++", "clang++"], + ) + gcov_tool = str(ec_base / "util" / "llvm-gcov.sh") + else: + print("Unknown toolchain specified:", intercepted_args.toolchain) + if intercepted_args.gcov_tool: + gcov_tool = intercepted_args.gcov_tool + if gcov_tool: + twister_cli.extend(["--gcov-tool", gcov_tool]) + + twister_env.update(extra_env_vars) + # Append additional user-supplied args twister_cli.extend(other_args) diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index 3a709d231e..9f19fd17cb 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -10,7 +10,6 @@ This is the entry point for the custom firmware builder workflow recipe. import argparse import multiprocessing -import os import pathlib import re import shlex @@ -48,34 +47,21 @@ def run_twister( Returns the path to the twister-out dir. """ - third_party_zephyr = platform_ec.parent.parent / "third_party/zephyr/main" if use_gcc: - c_compiler = "/usr/bin/x86_64-pc-linux-gnu-gcc" - cxx_compiler = "/usr/bin/x86_64-pc-linux-gnu-g++" outdir = "twister-out-gcc" - env = { - "ZEPHYR_TOOLCHAIN_VARIANT": "host", - "TOOLCHAIN_ROOT": third_party_zephyr, - } + toolchain = "host" else: - c_compiler = "/usr/bin/x86_64-pc-linux-gnu-clang" - cxx_compiler = "/usr/bin/x86_64-pc-linux-gnu-clang++" outdir = "twister-out-llvm" - env = {} - + toolchain = "llvm" cmd = [ platform_ec / "twister", "--outdir", platform_ec / outdir, "-v", "-i", - "-p", - "native_posix", - "-p", - "unit_testing", "--no-upload-cros-rdb", - "-x=CMAKE_C_COMPILER=" + c_compiler, - "-x=CMAKE_CXX_COMPILER=" + cxx_compiler, + "--toolchain", + toolchain, ] if extra_args: @@ -89,16 +75,13 @@ def run_twister( "--coverage", ] ) - log_cmd(cmd, env=env) - my_env = os.environ.copy() - my_env.update(env) + log_cmd(cmd) subprocess.run( cmd, check=True, cwd=platform_ec, stdin=subprocess.DEVNULL, - env=my_env, ) return platform_ec / outdir -- cgit v1.2.1 From 57cae6062acd7e2f1d009fb2ba43e9fc701a0ce8 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 7 Nov 2022 16:28:57 -0700 Subject: gitlab: Remove twister workarounds Twister should use toolchain host and set the toolchain dir to zephyr by default in gitlab now. BRANCH=None BUG=None TEST=Ran gitlab runner locally on zephyr_coverage and zephyr_boards_coverage Signed-off-by: Jeremy Bettis Change-Id: I8b8d14f21722e42bc903303b98cf185ea68b198e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011463 Code-Coverage: Zoss Tested-by: Jeremy Bettis Reviewed-by: Tristan Honscheid Commit-Queue: Jeremy Bettis --- .gitlab-ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 77d7d0a3a7..bc8dea37fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,10 +83,6 @@ before_script: # Build directory - export BUILD_DIR=${EC_DIR}/build - export TWISTER_OUT_DIR=${EC_DIR}/twister-out - # Set up Twister to use the "host" toolchain, as defined in upstream Zephyr - # repo, ultimately including ${ZEPHYR_BASE}/cmake/toolchain/host/generic.cmake - - export TOOLCHAIN_ROOT=${ZEPHYR_BASE} - - export ZEPHYR_TOOLCHAIN_VARIANT=host # Users of this template must set: # $PROJECT to the project to build. E.g., "lazor" @@ -295,7 +291,7 @@ zephyr_coverage: needs: [] script: - python3 ${EC_DIR}/twister --coverage --outdir "${TWISTER_OUT_DIR}" - -v -i --gcov-tool gcov -x=ALLOW_WARNINGS=ON + -v -i -x=ALLOW_WARNINGS=ON artifacts: paths: - ec_dir/twister-out/coverage.info -- cgit v1.2.1 From 00fb03e257cba6b00234de2fa7fb984a8c405df0 Mon Sep 17 00:00:00 2001 From: Caveh Jalali Date: Mon, 7 Nov 2022 18:21:34 -0800 Subject: util/ectool: Fix EC_CMD_GSV_PAUSE_IN_S5 result parameter type This fixes the struct type for EC_CMD_GSV_PAUSE_IN_S5 responses. Verified in the command implementation that EC_CMD_GSV_PAUSE_IN_S5 takes a struct ec_params_get_set_value and returns a struct ec_response_get_set_value. The two structs are identical, so there should be no functional impact. BRANCH=none BUG=none TEST=rebuilt ectool Change-Id: I9ca4f6889b4fecec8b1a964cdf5788daf49be01a Signed-off-by: Caveh Jalali Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010707 Code-Coverage: Zoss Reviewed-by: Daisuke Nojiri --- util/ectool.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/ectool.cc b/util/ectool.cc index 09673f7fd6..8f2a1c153f 100644 --- a/util/ectool.cc +++ b/util/ectool.cc @@ -887,7 +887,7 @@ int cmd_test(int argc, char *argv[]) int cmd_s5(int argc, char *argv[]) { struct ec_params_get_set_value p; - struct ec_params_get_set_value r; + struct ec_response_get_set_value r; int rv, param; p.flags = 0; -- cgit v1.2.1 From 44da6f397ba3627735745cb704cbad3264ecd7e5 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Tue, 8 Nov 2022 09:48:14 +1100 Subject: zephyr/shell: enable convenience features by default CONFIG_MINIMAL_SHELL provides meaningful flash size reduction (about 8k on NPCX) but turns off features that are important to us. Add EC defaults that keep those on, even if MINIMAL_SHELL=y. BUG=b:230486318 TEST=no change in flash usage on nivviks BRANCH=none Signed-off-by: Peter Marheine Change-Id: I3e4e37f409a473ff38e145ecacb0c4f24382fd14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011358 Code-Coverage: Zoss Reviewed-by: Keith Short --- zephyr/app/ec/Kconfig | 18 ++++++++++++++++++ zephyr/program/nissa/npcx_program.conf | 8 ++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/zephyr/app/ec/Kconfig b/zephyr/app/ec/Kconfig index fbf6185740..f630c252ed 100644 --- a/zephyr/app/ec/Kconfig +++ b/zephyr/app/ec/Kconfig @@ -154,4 +154,22 @@ config SHIMMED_TASKS build. The CROS_EC_TASK_LIST defines a list of CROS_EC_TASK that should be shimmed in. +# +# These shell options are turned off by MINIMAL_SHELL, but are important to us; +# override Zephyr's default to keep them on. +# +config SHELL_HISTORY + default y + +config SHELL_TAB + default y + +config SHELL_TAB_AUTOCOMPLETION + default y if SHELL_TAB + +config SHELL_HELP + default y + +config KERNEL_SHELL + default y endif # CROS_EC diff --git a/zephyr/program/nissa/npcx_program.conf b/zephyr/program/nissa/npcx_program.conf index ae672cb63a..1af7c9531f 100644 --- a/zephyr/program/nissa/npcx_program.conf +++ b/zephyr/program/nissa/npcx_program.conf @@ -31,13 +31,9 @@ CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y # type C port 1 redriver CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y -# Save some flash space, but retain some useful features +# Save some flash space by turning off features we don't care much about +# (EC Kconfig.console turns the ones we do care about on by default) CONFIG_SHELL_MINIMAL=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y -CONFIG_SHELL_HELP=y -CONFIG_KERNEL_SHELL=y # FRS enable CONFIG_PLATFORM_EC_USB_PD_FRS=y -- cgit v1.2.1 From c683ca77b029fd75bfce8e0c240a8348278e8b6f Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 8 Nov 2022 11:24:13 -0700 Subject: ec: Track coverage for rex. BRANCH=None BUG=None TEST=None Signed-off-by: Jeremy Bettis Change-Id: I67a103199dbb07178c3f263e44eb6aeb7eb2af16 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4012963 Tested-by: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Abe Levkoy Commit-Queue: Jeremy Bettis --- .gitlab-ci.yml | 10 ++++++++++ zephyr/firmware_builder.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bc8dea37fc..a0848a8779 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -270,6 +270,16 @@ skyrim_coverage: PROJECT: "skyrim" <<: *coverage_template +rex: + variables: + PROJECT: "rex" + <<: *build_template + +rex_coverage: + variables: + PROJECT: "rex" + <<: *coverage_template + ec_coverage: stage: test needs: [] diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index 9f19fd17cb..904ff248bb 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -24,7 +24,7 @@ DEFAULT_BUNDLE_DIRECTORY = "/tmp/artifact_bundles" DEFAULT_BUNDLE_METADATA_FILE = "/tmp/artifact_bundle_metadata" # Boards that we want to track the coverage of our own files specifically. -SPECIAL_BOARDS = ["herobrine", "krabby", "nivviks", "skyrim", "kingler"] +SPECIAL_BOARDS = ["herobrine", "krabby", "nivviks", "skyrim", "kingler", "rex"] def log_cmd(cmd, env=None): -- cgit v1.2.1 From 05dee9db4e4d863665925dfa374f37b9641af036 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Fri, 4 Nov 2022 15:30:24 +1100 Subject: pujjo: enable interrupts for lid accel The BMA4xx driver now supports interrupts, so stop polling the lid accel. BUG=b:254380338 TEST=accelinfo still shows accurate lid angle on pujjo with LIS2DW12 sensor installed BRANCH=none LOW_COVERAGE_REASON=board-specific code is not tested Signed-off-by: Peter Marheine Change-Id: I29b8675736d38e1f737f9faf139ae9aa0058758c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005683 Reviewed-by: Andrew McRae Code-Coverage: Zoss --- driver/accel_bma4xx.h | 2 ++ zephyr/program/nissa/pujjo/motionsense.dtsi | 5 ++--- zephyr/program/nissa/pujjo/overlay.dtsi | 5 +++++ zephyr/program/nissa/pujjo/src/form_factor.c | 15 ++++++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/driver/accel_bma4xx.h b/driver/accel_bma4xx.h index afa0776a38..0e5c24e8aa 100644 --- a/driver/accel_bma4xx.h +++ b/driver/accel_bma4xx.h @@ -209,6 +209,8 @@ extern const struct accelgyro_drv bma4_accel_drv; */ #define CONFIG_ACCEL_BMA4XX_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(bma4xx_int))) + +void bma4xx_interrupt(enum gpio_signal signal); #endif /* DT_NODE_EXISTS */ #endif /* CONFIG_ZEPHYR */ diff --git a/zephyr/program/nissa/pujjo/motionsense.dtsi b/zephyr/program/nissa/pujjo/motionsense.dtsi index 2dfca337c4..1ca53252b6 100644 --- a/zephyr/program/nissa/pujjo/motionsense.dtsi +++ b/zephyr/program/nissa/pujjo/motionsense.dtsi @@ -14,6 +14,7 @@ bmi3xx-int = &base_accel; lsm6dsm-int = &base_accel; lis2dw12-int = &lid_accel; + bma4xx-int = &lid_accel; }; /* @@ -238,8 +239,6 @@ * list of GPIO interrupts that have to * be enabled at initial stage */ - sensor-irqs = <&int_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; + sensor-irqs = <&int_imu &int_lid_accel>; }; }; diff --git a/zephyr/program/nissa/pujjo/overlay.dtsi b/zephyr/program/nissa/pujjo/overlay.dtsi index 60b3b60003..a2c5ff4471 100644 --- a/zephyr/program/nissa/pujjo/overlay.dtsi +++ b/zephyr/program/nissa/pujjo/overlay.dtsi @@ -72,6 +72,11 @@ flags = ; handler = "motion_interrupt"; }; + int_lid_accel: lid_accel { + irq-pin = <&gpio_acc_int_l>; + flags = ; + handler = "lid_accel_interrupt"; + }; int_vol_down: vol_down { irq-pin = <&gpio_voldn_btn_odl>; flags = ; diff --git a/zephyr/program/nissa/pujjo/src/form_factor.c b/zephyr/program/nissa/pujjo/src/form_factor.c index 6b02a258bc..1b096e8fa4 100644 --- a/zephyr/program/nissa/pujjo/src/form_factor.c +++ b/zephyr/program/nissa/pujjo/src/form_factor.c @@ -10,6 +10,8 @@ #include "button.h" #include "cros_board_info.h" #include "cros_cbi.h" +#include "driver/accel_bma4xx.h" +#include "driver/accel_lis2dw12_public.h" #include "driver/accelgyro_bmi323.h" #include "driver/accelgyro_lsm6dsm.h" #include "gpio/gpio_int.h" @@ -23,6 +25,7 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); static bool use_alt_sensor; +static bool use_alt_lid_accel; void motion_interrupt(enum gpio_signal signal) { @@ -32,13 +35,23 @@ void motion_interrupt(enum gpio_signal signal) bmi3xx_interrupt(signal); } +void lid_accel_interrupt(enum gpio_signal signal) +{ + if (use_alt_lid_accel) + lis2dw12_interrupt(signal); + else + bma4xx_interrupt(signal); +} + static void sensor_init(void) { int ret; uint32_t val; - /* check which base sensor is used for motion_interrupt */ + /* check which sensors are installed */ use_alt_sensor = cros_cbi_ssfc_check_match( CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); + use_alt_lid_accel = cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(lid_sensor_1))); motion_sensors_check_ssfc(); -- cgit v1.2.1 From 2fbedc6447dd18e7e9062dcb6818f5ae7e013857 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Mon, 7 Nov 2022 11:24:11 +1100 Subject: craask: use interrupts for lid accel The BMA4xx driver now supports interrupts, so use them instead of polling the lid accelerometer. BUG=b:254380338 TEST=lid angle still reports correctly on craask with BMA422 BRANCH=none LOW_COVERAGE_REASON=board-specific code is not tested Change-Id: I8ec9565b9c160b9a4274610f7b91ab1bc0836620 Signed-off-by: Peter Marheine Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005617 Reviewed-by: Andrew McRae Code-Coverage: Zoss --- zephyr/program/nissa/craask/motionsense.dtsi | 5 ++--- zephyr/program/nissa/craask/overlay.dtsi | 5 +++++ zephyr/program/nissa/craask/src/form_factor.c | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/zephyr/program/nissa/craask/motionsense.dtsi b/zephyr/program/nissa/craask/motionsense.dtsi index fafdf8fe61..941dfa2240 100644 --- a/zephyr/program/nissa/craask/motionsense.dtsi +++ b/zephyr/program/nissa/craask/motionsense.dtsi @@ -14,6 +14,7 @@ lsm6dso-int = &base_accel; lis2dw12-int = &lid_accel; bmi3xx-int = &base_accel; + bma4xx-int = &lid_accel; }; /* @@ -250,8 +251,6 @@ * list of GPIO interrupts that have to * be enabled at initial stage */ - sensor-irqs = <&int_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; + sensor-irqs = <&int_imu &int_lid_accel>; }; }; diff --git a/zephyr/program/nissa/craask/overlay.dtsi b/zephyr/program/nissa/craask/overlay.dtsi index 257dc299e3..3aa95ea7fc 100644 --- a/zephyr/program/nissa/craask/overlay.dtsi +++ b/zephyr/program/nissa/craask/overlay.dtsi @@ -66,6 +66,11 @@ flags = ; handler = "motion_interrupt"; }; + int_lid_accel: ec_lid_accel { + irq-pin = <&gpio_acc_int_l>; + flags = ; + handler = "lid_accel_interrupt"; + }; int_vol_down: vol_down { irq-pin = <&gpio_voldn_btn_odl>; flags = ; diff --git a/zephyr/program/nissa/craask/src/form_factor.c b/zephyr/program/nissa/craask/src/form_factor.c index 59869eaa2f..285901ea42 100644 --- a/zephyr/program/nissa/craask/src/form_factor.c +++ b/zephyr/program/nissa/craask/src/form_factor.c @@ -10,6 +10,8 @@ #include "button.h" #include "cros_board_info.h" #include "cros_cbi.h" +#include "driver/accel_bma4xx.h" +#include "driver/accel_lis2dw12_public.h" #include "driver/accelgyro_bmi323.h" #include "driver/accelgyro_lsm6dso.h" #include "gpio/gpio_int.h" @@ -35,6 +37,7 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); #define ALT_LID_S SENSOR_ID(DT_NODELABEL(alt_lid_accel)) static bool use_alt_sensor; +static bool use_alt_lid_accel; void motion_interrupt(enum gpio_signal signal) { @@ -44,6 +47,14 @@ void motion_interrupt(enum gpio_signal signal) lsm6dso_interrupt(signal); } +void lid_accel_interrupt(enum gpio_signal signal) +{ + if (use_alt_lid_accel) + lis2dw12_interrupt(signal); + else + bma4xx_interrupt(signal); +} + static void form_factor_init(void) { int ret; @@ -97,9 +108,11 @@ static void form_factor_init(void) motion_sensors_alt[ALT_LID_S].rot_standard_ref = &BMA_ALT_MAT; } - /* check which base sensor is used for motion_interrupt */ + /* check which motion sensors are used */ use_alt_sensor = cros_cbi_ssfc_check_match( CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1))); + use_alt_lid_accel = cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(lid_sensor_1))); motion_sensors_check_ssfc(); -- cgit v1.2.1 From 50e25f8df748d1e1e0e2c25b065be3544414149c Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Mon, 7 Nov 2022 11:35:39 +1100 Subject: joxer: enable interrupts for lid accel The BMA4xx driver now supports interrupts, so stop polling the lid accel. BUG=b:254380338 TEST=zmake build joxer BRANCH=none LOW_COVERAGE_REASON=board-specific code is not tested Signed-off-by: Peter Marheine Change-Id: Iff99f9b9d912f56054085dad0fb0560d0766e0a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005048 Reviewed-by: Andrew McRae Code-Coverage: Zoss --- zephyr/program/nissa/joxer/motionsense.dtsi | 5 ++--- zephyr/program/nissa/joxer/overlay.dtsi | 11 ++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/zephyr/program/nissa/joxer/motionsense.dtsi b/zephyr/program/nissa/joxer/motionsense.dtsi index 537cc34451..e9c46a849a 100644 --- a/zephyr/program/nissa/joxer/motionsense.dtsi +++ b/zephyr/program/nissa/joxer/motionsense.dtsi @@ -12,6 +12,7 @@ * Interrupt bindings for sensor devices. */ bmi3xx-int = &base_accel; + bma4xx-int = &lid_accel; }; /* @@ -142,8 +143,6 @@ * list of GPIO interrupts that have to * be enabled at initial stage */ - sensor-irqs = <&int_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; + sensor-irqs = <&int_imu &int_lid_accel>; }; }; diff --git a/zephyr/program/nissa/joxer/overlay.dtsi b/zephyr/program/nissa/joxer/overlay.dtsi index b587da8fb1..d0c592a717 100644 --- a/zephyr/program/nissa/joxer/overlay.dtsi +++ b/zephyr/program/nissa/joxer/overlay.dtsi @@ -98,9 +98,14 @@ handler = "gmr_tablet_switch_isr"; }; int_imu: ec_imu { - irq-pin = <&gpio_imu_int_l>; - flags = ; - handler = "bmi3xx_interrupt"; + irq-pin = <&gpio_imu_int_l>; + flags = ; + handler = "bmi3xx_interrupt"; + }; + int_lid_accel: ec_lid_accel { + irq-pin = <&gpio_acc_int_l>; + flags = ; + handler = "bma4xx_interrupt"; }; int_usb_c0: usb_c0 { irq-pin = <&gpio_usb_c0_int_odl>; -- cgit v1.2.1 From c0b5a7d0405289beae2af1cd6edde3a0b86cec17 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 4 Nov 2022 14:03:22 -0700 Subject: Makefile.toolchain: Enable -ftrapv for fingerprint boards The "-ftrapv" flag generates an exception for *signed* integer overflow: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html. This commit adds a unit test to verify the behavior. For now this is clang-only, since the gcc toolchain is missing the "trapping arithmetic functions": __addvsi3, __subvsi3, etc. https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html BRANCH=none BUG=b:144957935, b:258074414 TEST=./test/run_device_tests.py --board dartmonkey -t ftrapv TEST=./test/run_device_tests.py --board bloonchipper -t ftrapv Signed-off-by: Tom Hughes Change-Id: I2235c2d289bab2a17d7915978c17aaa07302403d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4007158 Code-Coverage: Zoss Reviewed-by: Andrea Grandi --- Makefile.toolchain | 4 +- board/hatch_fp/build.mk | 1 + board/nocturne_fp/build.mk | 1 + include/test_util.h | 1 + test/build.mk | 1 + test/ftrapv.c | 265 +++++++++++++++++++++++++++++++++++++++++++++ test/ftrapv.tasklist | 10 ++ test/run_device_tests.py | 1 + 8 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 test/ftrapv.c create mode 100644 test/ftrapv.tasklist diff --git a/Makefile.toolchain b/Makefile.toolchain index 30d0fe7418..181888ed8c 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -47,6 +47,8 @@ ifeq ($(filter $(BOARD), $(CLANG_BOARDS)), $(BOARD)) CC=clang USE_BUILTIN_STDLIB:=0 USE_CXX_COMPILER:=1 +# b/144957935: Generate exception on signed integer overflow. +COMMON_WARN+=-ftrapv endif ifeq ($(USE_CXX_COMPILER), 1) @@ -113,7 +115,7 @@ endif C_WARN = -Wstrict-prototypes -Wdeclaration-after-statement -Wno-pointer-sign C_WARN += -Werror-implicit-function-declaration -COMMON_WARN = -Wall -Wundef \ +COMMON_WARN += -Wall -Wundef \ -Wno-trigraphs -Wno-format-security -Wno-address-of-packed-member \ -fno-common -fno-strict-aliasing -fno-strict-overflow -Wimplicit-fallthrough # See https://www.chromium.org/chromium-os/build/c-exception-support diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk index 17e85cfb05..541ac5f198 100644 --- a/board/hatch_fp/build.mk +++ b/board/hatch_fp/build.mk @@ -40,6 +40,7 @@ test-list-y=\ flash_write_protect \ fpsensor \ fpsensor_hw \ + ftrapv \ libc_printf \ mpu \ mutex \ diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk index d91229c7e3..1d8e9174f7 100644 --- a/board/nocturne_fp/build.mk +++ b/board/nocturne_fp/build.mk @@ -40,6 +40,7 @@ test-list-y=\ flash_write_protect \ fpsensor \ fpsensor_hw \ + ftrapv \ libc_printf \ mpu \ mutex \ diff --git a/include/test_util.h b/include/test_util.h index 004e8aaf0d..47b73605d4 100644 --- a/include/test_util.h +++ b/include/test_util.h @@ -124,6 +124,7 @@ enum test_state_t { TEST_STATE_STEP_7, TEST_STATE_STEP_8, TEST_STATE_STEP_9, + TEST_STATE_STEP_10, TEST_STATE_PASSED, TEST_STATE_FAILED, }; diff --git a/test/build.mk b/test/build.mk index eee0e86179..384ad60a59 100644 --- a/test/build.mk +++ b/test/build.mk @@ -198,6 +198,7 @@ fpsensor-y=fpsensor.o fpsensor_crypto-y=fpsensor_crypto.o fpsensor_hw-y=fpsensor_hw.o fpsensor_state-y=fpsensor_state.o +ftrapv-y=ftrapv.o gyro_cal-y=gyro_cal.o gyro_cal_init_for_test.o hooks-y=hooks.o host_command-y=host_command.o diff --git a/test/ftrapv.c b/test/ftrapv.c new file mode 100644 index 0000000000..60d76d25d0 --- /dev/null +++ b/test/ftrapv.c @@ -0,0 +1,265 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "common.h" +#include "panic.h" +#include "system.h" +#include "task.h" +#include "test_util.h" + +/* + * trapping addition: __addvsi3. + */ +test_static int test_ftrapv_addition(void) +{ + int32_t test_overflow = INT32_MAX; + int32_t ret; + + ccprintf("Testing signed integer addition overflow\n"); + cflush(); + ret = test_overflow + 1; + + /* Should never reach this. */ + ccprintf("ret: %d\n", ret); + cflush(); + + return EC_ERROR_UNKNOWN; +} + +/* + * trapping subtraction: __subvsi3. + */ +test_static int test_ftrapv_subtraction(void) +{ + int32_t test_overflow = INT32_MIN; + int32_t ret; + + ccprintf("Testing signed integer subtraction overflow\n"); + cflush(); + ret = test_overflow - 1; + + /* Should never reach this. */ + ccprintf("ret: %d\n", ret); + cflush(); + + return EC_ERROR_UNKNOWN; +} + +/* + * trapping multiplication: __mulvsi3. + */ +test_static int test_ftrapv_multiplication(void) +{ + int32_t test_overflow = INT32_MAX; + int32_t ret; + + ccprintf("Testing signed integer multiplication overflow\n"); + cflush(); + ret = test_overflow * 2; + + /* Should never reach this. */ + ccprintf("ret: %d\n", ret); + cflush(); + + return EC_ERROR_UNKNOWN; +} + +/* + * trapping negation: __negvsi2. + */ +test_static int test_ftrapv_negation(void) +{ + int32_t test_overflow = INT32_MIN; + int32_t ret; + + ccprintf("Testing signed integer negation overflow\n"); + cflush(); + ret = -test_overflow; + + /* Should never reach this. */ + ccprintf("ret: %d\n", ret); + cflush(); + + return EC_ERROR_UNKNOWN; +} + +/* + * trapping absolute value: __absvsi2. + * + * TODO(b/258074414): Trapping on absolute value overflow is broken in clang. + */ +test_static int test_ftrapv_absolute_value(void) +{ + int32_t test_overflow = INT32_MIN; + int32_t ret; + + ccprintf("Testing signed integer absolute value overflow\n"); + cflush(); + + ret = abs(test_overflow); + + /* Should never reach this. */ + ccprintf("ret: %d\n", ret); + cflush(); + + return EC_ERROR_UNKNOWN; +} + +test_static int test_panic_data(void) +{ + const uint32_t expected_reason = 0; + const uint32_t expected_info = 0; + /* + * https://developer.arm.com/documentation/dui0552/a/the-cortex-m3-processor/exception-model/exception-types + */ + const uint8_t expected_exception = 6; /* usage fault */ + + uint32_t reason = UINT32_MAX; + uint32_t info = UINT32_MAX; + uint8_t exception = UINT8_MAX; + + panic_get_reason(&reason, &info, &exception); + + TEST_EQ(reason, expected_reason, "%08x"); + TEST_EQ(info, expected_info, "%d"); + TEST_EQ(exception, expected_exception, "%d"); + + return EC_SUCCESS; +} + +test_static void run_test_step1(void) +{ + test_set_next_step(TEST_STATE_STEP_2); + RUN_TEST(test_ftrapv_addition); +} + +test_static void run_test_step2(void) +{ + RUN_TEST(test_panic_data); + + if (test_get_error_count()) + test_reboot_to_next_step(TEST_STATE_FAILED); + else + test_reboot_to_next_step(TEST_STATE_STEP_3); +} + +test_static void run_test_step3(void) +{ + test_set_next_step(TEST_STATE_STEP_4); + RUN_TEST(test_ftrapv_subtraction); +} + +test_static void run_test_step4(void) +{ + RUN_TEST(test_panic_data); + + if (test_get_error_count()) + test_reboot_to_next_step(TEST_STATE_FAILED); + else + test_reboot_to_next_step(TEST_STATE_STEP_5); +} + +test_static void run_test_step5(void) +{ + test_set_next_step(TEST_STATE_STEP_6); + RUN_TEST(test_ftrapv_multiplication); +} + +test_static void run_test_step6(void) +{ + RUN_TEST(test_panic_data); + + if (test_get_error_count()) + test_reboot_to_next_step(TEST_STATE_FAILED); + else + test_reboot_to_next_step(TEST_STATE_STEP_7); +} + +test_static void run_test_step7(void) +{ + test_set_next_step(TEST_STATE_STEP_8); + RUN_TEST(test_ftrapv_negation); +} + +test_static void run_test_step8(void) +{ + RUN_TEST(test_panic_data); + + if (test_get_error_count()) + test_reboot_to_next_step(TEST_STATE_FAILED); + else + test_reboot_to_next_step(TEST_STATE_STEP_9); +} + +test_static void run_test_step9(void) +{ + /* + * TODO(b/258074414): Trapping on absolute value overflow is broken in + * clang, so skip the check. + */ +#if 0 + test_set_next_step(TEST_STATE_STEP_10); + RUN_TEST(test_ftrapv_absolute_value); +#else + test_reboot_to_next_step(TEST_STATE_STEP_10); +#endif +} + +test_static void run_test_step10(void) +{ + /* + * TODO(b/258074414): Trapping on absolute value overflow is broken in + * clang, so skip the check. + */ +#if 0 + RUN_TEST(test_panic_data); +#endif + + if (test_get_error_count()) + test_reboot_to_next_step(TEST_STATE_FAILED); + else + test_reboot_to_next_step(TEST_STATE_PASSED); +} + +void test_run_step(uint32_t state) +{ + if (state & TEST_STATE_MASK(TEST_STATE_STEP_1)) { + run_test_step1(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_2)) { + run_test_step2(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_3)) { + run_test_step3(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_4)) { + run_test_step4(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_5)) { + run_test_step5(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_6)) { + run_test_step6(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_7)) { + run_test_step7(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_8)) { + run_test_step8(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_9)) { + run_test_step9(); + } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_10)) { + run_test_step10(); + } +} + +int task_test(void *unused) +{ + if (IS_ENABLED(SECTION_IS_RW)) + test_run_multistep(); + return EC_SUCCESS; +} + +void run_test(int argc, const char **argv) +{ + test_reset(); + msleep(30); /* Wait for TASK_ID_TEST to initialize */ + task_wake(TASK_ID_TEST); +} diff --git a/test/ftrapv.tasklist b/test/ftrapv.tasklist new file mode 100644 index 0000000000..273a9664c0 --- /dev/null +++ b/test/ftrapv.tasklist @@ -0,0 +1,10 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * See CONFIG_TASK_LIST in config.h for details. + */ +#define CONFIG_TEST_TASK_LIST \ + TASK_TEST(TEST, task_test, NULL, TASK_STACK_SIZE) diff --git a/test/run_device_tests.py b/test/run_device_tests.py index cfa034ac91..0b5a291b6c 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -236,6 +236,7 @@ class AllTests: test_name="fpsensor", test_args=["uart"], ), + TestConfig(test_name="ftrapv"), TestConfig( test_name="libc_printf", finish_regexes=[PRINTF_CALLED_REGEX], -- cgit v1.2.1 From 7063dd20c35b905248bd76bf84310d64625f54fd Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Wed, 26 Oct 2022 15:37:00 +0800 Subject: winterhold: fix battery cannot be charged After battery is over-drained, EC_BATT_PRES_ODL will be always high cause EC won't wake battery. BUG=b:249438144 BRANCH=none TEST=zmake build winterhold successfully TEST=winterhold can boot up to OS from battery cut off TEST=use the battery cell voltage less than 2.5V can boot to OS LOW_COVERAGE_REASON=Skyrim board not create the battery hw present function Signed-off-by: Matt Wang Change-Id: I02a7da58d51693595fc7bb18d01e8e12a5f42908 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3980937 Reviewed-by: Diana Z Reviewed-by: Elthan Huang Code-Coverage: Zoss --- zephyr/program/skyrim/CMakeLists.txt | 1 + zephyr/program/skyrim/gpio.dts | 2 +- zephyr/program/skyrim/prj.conf | 1 - zephyr/program/skyrim/prj_frostflow.conf | 3 + zephyr/program/skyrim/prj_morthal.conf | 3 + zephyr/program/skyrim/prj_skyrim.conf | 3 + zephyr/program/skyrim/prj_winterhold.conf | 3 + .../skyrim/src/winterhold/battery_present.c | 81 ++++++++++++++++++++++ 8 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 zephyr/program/skyrim/src/winterhold/battery_present.c diff --git a/zephyr/program/skyrim/CMakeLists.txt b/zephyr/program/skyrim/CMakeLists.txt index cfa4a22a0b..cf357a4a0a 100644 --- a/zephyr/program/skyrim/CMakeLists.txt +++ b/zephyr/program/skyrim/CMakeLists.txt @@ -46,6 +46,7 @@ if(DEFINED CONFIG_BOARD_WINTERHOLD) "src/winterhold/kb_backlight.c" "src/winterhold/keyboard.c" "src/winterhold/sensor.c" + "src/winterhold/battery_present.c" ) endif() diff --git a/zephyr/program/skyrim/gpio.dts b/zephyr/program/skyrim/gpio.dts index 57abcc846d..2b79bad222 100644 --- a/zephyr/program/skyrim/gpio.dts +++ b/zephyr/program/skyrim/gpio.dts @@ -118,7 +118,7 @@ gpios = <&gpio0 2 GPIO_INPUT>; enum-name = "GPIO_LID_OPEN"; }; - ec_batt_pres_odl { + gpio_ec_batt_pres_odl: ec_batt_pres_odl { gpios = <&gpio9 4 GPIO_INPUT>; enum-name = "GPIO_BATT_PRES_ODL"; }; diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index a0085258e4..760f1f3275 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -85,7 +85,6 @@ CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y # Charger diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf index 29931de4d4..d347d3e435 100644 --- a/zephyr/program/skyrim/prj_frostflow.conf +++ b/zephyr/program/skyrim/prj_frostflow.conf @@ -28,3 +28,6 @@ CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y # Frostflow not have the USB HUB CONFIG_BOARD_USB_HUB_RESET=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_morthal.conf b/zephyr/program/skyrim/prj_morthal.conf index 3d2b3fddb7..f0833418ca 100644 --- a/zephyr/program/skyrim/prj_morthal.conf +++ b/zephyr/program/skyrim/prj_morthal.conf @@ -21,3 +21,6 @@ CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_skyrim.conf b/zephyr/program/skyrim/prj_skyrim.conf index 2752854c8b..0ebd1e91fa 100644 --- a/zephyr/program/skyrim/prj_skyrim.conf +++ b/zephyr/program/skyrim/prj_skyrim.conf @@ -24,3 +24,6 @@ CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y # Enable alternative charger chip CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_winterhold.conf b/zephyr/program/skyrim/prj_winterhold.conf index 81fd9f367e..4501e0e6ff 100644 --- a/zephyr/program/skyrim/prj_winterhold.conf +++ b/zephyr/program/skyrim/prj_winterhold.conf @@ -39,3 +39,6 @@ CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n CONFIG_PLATFORM_EC_TABLET_MODE=n CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y diff --git a/zephyr/program/skyrim/src/winterhold/battery_present.c b/zephyr/program/skyrim/src/winterhold/battery_present.c new file mode 100644 index 0000000000..eb5a5bba90 --- /dev/null +++ b/zephyr/program/skyrim/src/winterhold/battery_present.c @@ -0,0 +1,81 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include + +#include "battery.h" +#include "battery_smart.h" +#include "common.h" + +static enum battery_present batt_pres_prev = BP_NOT_SURE; + +__overridable bool board_battery_is_initialized(void) +{ + int batt_status; + + return battery_status(&batt_status) != EC_SUCCESS ? + false : + !!(batt_status & STATUS_INITIALIZED); +} + +/* + * Physical detection of battery. + */ +static enum battery_present battery_check_present_status(void) +{ + enum battery_present batt_pres; + + if (battery_is_cut_off()) + return BP_NO; + + /* Get the physical hardware status */ + batt_pres = battery_hw_present(); + + /* + * If the battery is not physically connected, then no need to perform + * any more checks. + */ + if (batt_pres == BP_NO) + return BP_NO; + + /* + * If the battery is present now and was present last time we checked, + * return early. + */ + if ((batt_pres == BP_YES) && (batt_pres == batt_pres_prev)) + return BP_YES; + + /* + * Check battery initialization. If the battery is not initialized, + * then return BP_NOT_SURE. Battery could be in ship + * mode and might require pre-charge current to wake it up. BP_NO is not + * returned here because charger state machine will not provide + * pre-charge current assuming that battery is not present. + */ + if (!board_battery_is_initialized()) + return BP_NOT_SURE; + + return BP_YES; +} + +enum battery_present battery_is_present(void) +{ + batt_pres_prev = battery_check_present_status(); + return batt_pres_prev; +} + +enum battery_present battery_hw_present(void) +{ + const struct gpio_dt_spec *batt_pres; + + batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl); + + /* + * The GPIO is low when the battery is physically present. + * But if battery cell voltage < 2.5V, it will not able to + * pull down EC_BATT_PRES_ODL. So we need to set pre-charge + * current even EC_BATT_PRES_ODL is high. + */ + return gpio_pin_get_dt(batt_pres) ? BP_NOT_SURE : BP_YES; +} -- cgit v1.2.1 From 10d8f20b90c9462ffe24222df4dad6829eb31067 Mon Sep 17 00:00:00 2001 From: Zick Wei Date: Tue, 8 Nov 2022 16:46:10 +0800 Subject: nissa: update usba1 enable pin initial state Set USBA1 enable pin to output only during initialize, which retaining current value. BUG=b:255269471 BRANCH=none TEST=Not lost USBA storage after sysjump manually. Signed-off-by: Zick Wei Change-Id: Ib2b6d1900de974150d5a8d677016deeb40e98a26 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4012839 Reviewed-by: Devin Lu Reviewed-by: Peter Marheine Code-Coverage: Zoss --- zephyr/program/nissa/src/sub_board.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/program/nissa/src/sub_board.c b/zephyr/program/nissa/src/sub_board.c index 3ccbcd9325..f50c0bdca8 100644 --- a/zephyr/program/nissa/src/sub_board.c +++ b/zephyr/program/nissa/src/sub_board.c @@ -157,14 +157,14 @@ static void nereid_subboard_config(void) if (sb == NISSA_SB_C_A || sb == NISSA_SB_HDMI_A || sb == NISSA_SB_NONE) { /* - * Configure VBUS enable, default off. + * Configure VBUS enable, retaining current value. * SB_NONE indicates missing fw_config; it's safe to enable VBUS * control in this case since all that will happen is we turn * off power to LTE, and it's useful to allow USB-A to work in * such a configuration. */ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus), - GPIO_OUTPUT_LOW); + GPIO_OUTPUT); } else { /* Turn off unused pins */ gpio_pin_configure_dt( -- cgit v1.2.1 From 8719017bc82deb7cbce218057c516f878bdf9dc7 Mon Sep 17 00:00:00 2001 From: Zick Wei Date: Tue, 8 Nov 2022 10:01:50 +0800 Subject: nissa: enable CONFIG_PLATFORM_EC_BACKLIGHT_LID BUG=b:257861378 BRANCH=none TEST=verify panel backlight turn off when system in factory image with lid close. Signed-off-by: Zick Wei Change-Id: Idf2565cd78e6a98d43cc85d6a13ba238438292bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011740 Code-Coverage: Zoss Reviewed-by: Peter Marheine --- zephyr/program/nissa/program.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index ae08a9020d..35d0efde17 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -93,9 +93,6 @@ CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y CONFIG_PWM=y CONFIG_PWM_SHELL=y -# TODO(b/188605676): bring these features up -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n - # Sensors support CONFIG_PLATFORM_EC_LID_ANGLE=y CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -- cgit v1.2.1 From c35cfd0ad41d7feb840a0e45c799f5fc3468976d Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 13:00:25 -0600 Subject: zephyr: test: common charger code charger_enable_otg_power Add some infrastructure for mocking out the charger driver functions to simplify testing the remainder of `common/charger.c` and use it to test charger_enable_otg_power() BUG=None BRANCH=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: I61b74c4cd2f8b7303b37c78cff0156db03c6191e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000827 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/test/drivers/common_charger/CMakeLists.txt | 1 + .../src/test_common_charger_mocked.c | 98 ++++++++++++++++++++++ zephyr/test/drivers/testcase.yaml | 1 + 3 files changed, 100 insertions(+) create mode 100644 zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c diff --git a/zephyr/test/drivers/common_charger/CMakeLists.txt b/zephyr/test/drivers/common_charger/CMakeLists.txt index 58fc3229ef..63da1783f1 100644 --- a/zephyr/test/drivers/common_charger/CMakeLists.txt +++ b/zephyr/test/drivers/common_charger/CMakeLists.txt @@ -7,4 +7,5 @@ target_sources(app PRIVATE src/test_charge_state_v2.c src/test_common_charger.c + src/test_common_charger_mocked.c ) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c new file mode 100644 index 0000000000..4c225dbffd --- /dev/null +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -0,0 +1,98 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include +#include + +#include "charger.h" +#include "test/drivers/charger_utils.h" +#include "test/drivers/test_state.h" + +/* This test suite only works if the chg_chips array is not const. */ +BUILD_ASSERT(IS_ENABLED(CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG), + "chg_chips array cannot be const."); + +/** Index of the charger chip we are overriding / working with. */ +#define CHG_NUM (0) + +/* FFF fakes for driver functions. These get assigned to members of the + * charger_drv struct + */ +FAKE_VALUE_FUNC(enum ec_error_list, enable_otg_power, int, int); + +struct common_charger_mocked_driver_fixture { + /* The original driver pointer that gets restored after the tests */ + const struct charger_drv *saved_driver_ptr; + /* Mock driver that gets substituted */ + struct charger_drv mock_driver; +}; + +ZTEST(common_charger_mocked_driver, test_charger_enable_otg_power__invalid) +{ + /* charger number out of bounds */ + zassert_equal(EC_ERROR_INVAL, charger_enable_otg_power(-1, 0)); + zassert_equal(EC_ERROR_INVAL, charger_enable_otg_power(INT_MAX, 0)); +} + +ZTEST(common_charger_mocked_driver, test_charger_enable_otg_power__unimpl) +{ + /* enable_otg_power is NULL */ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + charger_enable_otg_power(CHG_NUM, 1)); +} + +ZTEST_F(common_charger_mocked_driver, test_charger_enable_otg_power) +{ + fixture->mock_driver.enable_otg_power = enable_otg_power; + enable_otg_power_fake.return_val = 123; + + zassert_equal(enable_otg_power_fake.return_val, + charger_enable_otg_power(CHG_NUM, 1)); + + zassert_equal(1, enable_otg_power_fake.call_count); + zassert_equal(CHG_NUM, enable_otg_power_fake.arg0_history[0]); + zassert_equal(1, enable_otg_power_fake.arg1_history[0]); +} + +static void *setup(void) +{ + static struct common_charger_mocked_driver_fixture f; + + zassert_true(board_get_charger_chip_count() > 0, + "Need at least one charger chip present."); + + /* Back up the current charger driver and substitute our own */ + f.saved_driver_ptr = chg_chips[CHG_NUM].drv; + chg_chips[CHG_NUM].drv = &f.mock_driver; + + return &f; +} + +static void reset(void *data) +{ + struct common_charger_mocked_driver_fixture *f = data; + + /* Reset the mock driver's function pointer table. Each tests adds these + * as-needed + */ + f->mock_driver = (struct charger_drv){ 0 }; + + /* Reset fakes */ + RESET_FAKE(enable_otg_power); +} + +static void teardown(void *data) +{ + struct common_charger_mocked_driver_fixture *f = data; + + /* Restore the original driver */ + chg_chips[CHG_NUM].drv = f->saved_driver_ptr; +} + +ZTEST_SUITE(common_charger_mocked_driver, drivers_predicate_post_main, setup, + reset, reset, teardown); diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index a6c250c361..4eb41bc6e3 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -58,6 +58,7 @@ tests: # Set to focus testing for Herobrine # Config is y only in nissa - CONFIG_PLATFORM_EC_CHARGER_RAA489000=n + - CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y drivers.chargesplash: timeout: 240 extra_configs: -- cgit v1.2.1 From e1d52c9817fdf5da3978620047b69e761815835c Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 13:17:19 -0600 Subject: zephyr: tests: Test charger.c charger_set_otg_current_voltage() Test charger_set_otg_current_voltage in common/charger.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: Ibbb3e36b51809aca754d802c6b4f9cc4267e0eb4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000828 Reviewed-by: Tomasz Michalec Code-Coverage: Zoss --- .../src/test_common_charger_mocked.c | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index 4c225dbffd..6d13f971c4 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -24,6 +24,7 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG), * charger_drv struct */ FAKE_VALUE_FUNC(enum ec_error_list, enable_otg_power, int, int); +FAKE_VALUE_FUNC(enum ec_error_list, set_otg_current_voltage, int, int, int); struct common_charger_mocked_driver_fixture { /* The original driver pointer that gets restored after the tests */ @@ -59,6 +60,38 @@ ZTEST_F(common_charger_mocked_driver, test_charger_enable_otg_power) zassert_equal(1, enable_otg_power_fake.arg1_history[0]); } +ZTEST(common_charger_mocked_driver, + test_charger_set_otg_current_voltage__invalid) +{ + /* charger number out of bounds */ + zassert_equal(EC_ERROR_INVAL, + charger_set_otg_current_voltage(-1, 0, 0)); + zassert_equal(EC_ERROR_INVAL, + charger_set_otg_current_voltage(INT_MAX, 0, 0)); +} + +ZTEST(common_charger_mocked_driver, + test_charger_set_otg_current_voltage__unimpl) +{ + /* set_otg_current_voltage is NULL */ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + charger_set_otg_current_voltage(CHG_NUM, 0, 0)); +} + +ZTEST_F(common_charger_mocked_driver, test_charger_set_otg_current_voltage) +{ + fixture->mock_driver.set_otg_current_voltage = set_otg_current_voltage; + set_otg_current_voltage_fake.return_val = 123; + + zassert_equal(set_otg_current_voltage_fake.return_val, + charger_set_otg_current_voltage(CHG_NUM, 10, 20)); + + zassert_equal(1, set_otg_current_voltage_fake.call_count); + zassert_equal(CHG_NUM, set_otg_current_voltage_fake.arg0_history[0]); + zassert_equal(10, set_otg_current_voltage_fake.arg1_history[0]); + zassert_equal(20, set_otg_current_voltage_fake.arg2_history[0]); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -84,6 +117,7 @@ static void reset(void *data) /* Reset fakes */ RESET_FAKE(enable_otg_power); + RESET_FAKE(set_otg_current_voltage); } static void teardown(void *data) -- cgit v1.2.1 From 4449ac2bbf9349456a3c1c286acef203f4611f81 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 13:28:55 -0600 Subject: zephyr: tests: Test charger.c charger_is_sourcing_otg_power() Test charger_is_sourcing_otg_power in common/charger.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: I8cd233035230264e8da6cbbd543fc7cd31bbe50f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000829 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- .../common_charger/src/test_common_charger_mocked.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index 6d13f971c4..2319256315 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -25,6 +25,7 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG), */ FAKE_VALUE_FUNC(enum ec_error_list, enable_otg_power, int, int); FAKE_VALUE_FUNC(enum ec_error_list, set_otg_current_voltage, int, int, int); +FAKE_VALUE_FUNC(int, is_sourcing_otg_power, int, int); struct common_charger_mocked_driver_fixture { /* The original driver pointer that gets restored after the tests */ @@ -92,6 +93,23 @@ ZTEST_F(common_charger_mocked_driver, test_charger_set_otg_current_voltage) zassert_equal(20, set_otg_current_voltage_fake.arg2_history[0]); } +ZTEST(common_charger_mocked_driver, test_charger_is_sourcing_otg_power__invalid) +{ + /* is_sourcing_otg_power is NULL */ + zassert_equal(0, charger_is_sourcing_otg_power(0)); +} + +ZTEST_F(common_charger_mocked_driver, test_charger_is_sourcing_otg_power) +{ + fixture->mock_driver.is_sourcing_otg_power = is_sourcing_otg_power; + is_sourcing_otg_power_fake.return_val = 123; + + zassert_equal(is_sourcing_otg_power_fake.return_val, + charger_is_sourcing_otg_power(0)); + + zassert_equal(1, is_sourcing_otg_power_fake.call_count); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -118,6 +136,7 @@ static void reset(void *data) /* Reset fakes */ RESET_FAKE(enable_otg_power); RESET_FAKE(set_otg_current_voltage); + RESET_FAKE(is_sourcing_otg_power); } static void teardown(void *data) -- cgit v1.2.1 From f95572076ab223eb99e84435d974fd96ffde5b5f Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 13:38:07 -0600 Subject: zephyr: tests: Test charger.c charger_get_actual_current() Test charger_get_actual_current in common/charger.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: Idd220b05371d90621f874e9b8152522d124da131 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000830 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- .../src/test_common_charger_mocked.c | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index 2319256315..060f0cf748 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -26,6 +26,7 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG), FAKE_VALUE_FUNC(enum ec_error_list, enable_otg_power, int, int); FAKE_VALUE_FUNC(enum ec_error_list, set_otg_current_voltage, int, int, int); FAKE_VALUE_FUNC(int, is_sourcing_otg_power, int, int); +FAKE_VALUE_FUNC(enum ec_error_list, get_actual_current, int, int *); struct common_charger_mocked_driver_fixture { /* The original driver pointer that gets restored after the tests */ @@ -110,6 +111,49 @@ ZTEST_F(common_charger_mocked_driver, test_charger_is_sourcing_otg_power) zassert_equal(1, is_sourcing_otg_power_fake.call_count); } +ZTEST(common_charger_mocked_driver, test_charger_get_actual_current__invalid) +{ + /* charger number out of bounds */ + zassert_equal(EC_ERROR_INVAL, charger_get_actual_current(-1, NULL)); + zassert_equal(EC_ERROR_INVAL, + charger_get_actual_current(INT_MAX, NULL)); +} + +ZTEST(common_charger_mocked_driver, test_charger_get_actual_current__unimpl) +{ + /* get_actual_current is NULL */ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + charger_get_actual_current(CHG_NUM, NULL)); +} + +/** + * @brief Custom fake for get_actual_current that can write to the output param + */ +static enum ec_error_list get_actual_current_custom_fake(int chgnum, + int *current) +{ + ARG_UNUSED(chgnum); + + *current = 1000; + + return EC_SUCCESS; +} + +ZTEST_F(common_charger_mocked_driver, test_charger_get_actual_current) +{ + int current; + + fixture->mock_driver.get_actual_current = get_actual_current; + get_actual_current_fake.custom_fake = get_actual_current_custom_fake; + + zassert_equal(EC_SUCCESS, + charger_get_actual_current(CHG_NUM, ¤t)); + + zassert_equal(1, get_actual_current_fake.call_count); + zassert_equal(CHG_NUM, get_actual_current_fake.arg0_history[0]); + zassert_equal(1000, current); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -137,6 +181,7 @@ static void reset(void *data) RESET_FAKE(enable_otg_power); RESET_FAKE(set_otg_current_voltage); RESET_FAKE(is_sourcing_otg_power); + RESET_FAKE(get_actual_current); } static void teardown(void *data) -- cgit v1.2.1 From 78f474275cfe0be44551f9f15ff0be56da8af08c Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 13:43:07 -0600 Subject: zephyr: tests: Test charger.c charger_get_actual_voltage() Test charger_get_actual_voltage in common/charger.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: I82421e3141d657d7b6290187eb7ed18024732af2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000831 Code-Coverage: Zoss Reviewed-by: Simon Glass --- .../src/test_common_charger_mocked.c | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index 060f0cf748..a8b01b3c87 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -27,6 +27,7 @@ FAKE_VALUE_FUNC(enum ec_error_list, enable_otg_power, int, int); FAKE_VALUE_FUNC(enum ec_error_list, set_otg_current_voltage, int, int, int); FAKE_VALUE_FUNC(int, is_sourcing_otg_power, int, int); FAKE_VALUE_FUNC(enum ec_error_list, get_actual_current, int, int *); +FAKE_VALUE_FUNC(enum ec_error_list, get_actual_voltage, int, int *); struct common_charger_mocked_driver_fixture { /* The original driver pointer that gets restored after the tests */ @@ -154,6 +155,49 @@ ZTEST_F(common_charger_mocked_driver, test_charger_get_actual_current) zassert_equal(1000, current); } +ZTEST(common_charger_mocked_driver, test_charger_get_actual_voltage__invalid) +{ + /* charger number out of bounds */ + zassert_equal(EC_ERROR_INVAL, charger_get_actual_voltage(-1, NULL)); + zassert_equal(EC_ERROR_INVAL, + charger_get_actual_voltage(INT_MAX, NULL)); +} + +ZTEST(common_charger_mocked_driver, test_charger_get_actual_voltage__unimpl) +{ + /* get_actual_voltage is NULL */ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + charger_get_actual_voltage(CHG_NUM, NULL)); +} + +/** + * @brief Custom fake for get_actual_voltage that can write to the output param + */ +static enum ec_error_list get_actual_voltage_custom_fake(int chgnum, + int *voltage) +{ + ARG_UNUSED(chgnum); + + *voltage = 2000; + + return EC_SUCCESS; +} + +ZTEST_F(common_charger_mocked_driver, test_charger_get_actual_voltage) +{ + int voltage; + + fixture->mock_driver.get_actual_voltage = get_actual_voltage; + get_actual_voltage_fake.custom_fake = get_actual_voltage_custom_fake; + + zassert_equal(EC_SUCCESS, + charger_get_actual_voltage(CHG_NUM, &voltage)); + + zassert_equal(1, get_actual_voltage_fake.call_count); + zassert_equal(CHG_NUM, get_actual_voltage_fake.arg0_history[0]); + zassert_equal(2000, voltage); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -182,6 +226,7 @@ static void reset(void *data) RESET_FAKE(set_otg_current_voltage); RESET_FAKE(is_sourcing_otg_power); RESET_FAKE(get_actual_current); + RESET_FAKE(get_actual_voltage); } static void teardown(void *data) -- cgit v1.2.1 From ea365efe7e50a25f4982a48bf39c5914618fad0f Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Tue, 8 Nov 2022 15:52:48 +0800 Subject: krabby: rename i2c_krabby_tentacruel.dtsi This file is shared with all krabby followers, it should not have the _tentacruel suffix. rename to ite_i2c.dtsi to comply with the new layout standard. BUG=none TEST=zmake build BRANCH=none Signed-off-by: Ting Shen Change-Id: I931f6a1bc0f51bd68ee8eb2001f716142f136eef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010983 Code-Coverage: Zoss Reviewed-by: Eric Yilun Lin Tested-by: Ting Shen Commit-Queue: Eric Yilun Lin Auto-Submit: Ting Shen --- zephyr/program/corsola/i2c_krabby.dts | 2 +- zephyr/program/corsola/i2c_krabby_tentacruel.dtsi | 138 ---------------------- zephyr/program/corsola/i2c_magikarp.dts | 2 +- zephyr/program/corsola/i2c_tentacruel.dts | 2 +- zephyr/program/corsola/ite_i2c.dtsi | 138 ++++++++++++++++++++++ 5 files changed, 141 insertions(+), 141 deletions(-) delete mode 100644 zephyr/program/corsola/i2c_krabby_tentacruel.dtsi create mode 100644 zephyr/program/corsola/ite_i2c.dtsi diff --git a/zephyr/program/corsola/i2c_krabby.dts b/zephyr/program/corsola/i2c_krabby.dts index a5dc03b655..a873210ff7 100644 --- a/zephyr/program/corsola/i2c_krabby.dts +++ b/zephyr/program/corsola/i2c_krabby.dts @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "i2c_krabby_tentacruel.dtsi" +#include "ite_i2c.dtsi" &i2c0 { charger: rt9490@53 { diff --git a/zephyr/program/corsola/i2c_krabby_tentacruel.dtsi b/zephyr/program/corsola/i2c_krabby_tentacruel.dtsi deleted file mode 100644 index 6fd153e1fa..0000000000 --- a/zephyr/program/corsola/i2c_krabby_tentacruel.dtsi +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - named-i2c-ports { - compatible = "named-i2c-ports"; - - battery { - i2c-port = <&i2c1>; - remote-port = <1>; - enum-names = "I2C_PORT_BATTERY", - "I2C_PORT_VIRTUAL_BATTERY"; - }; - i2c_charger: charger { - i2c-port = <&i2c0>; - enum-names = "I2C_PORT_CHARGER", - "I2C_PORT_EEPROM"; - }; - i2c_sensor: sensor { - i2c-port = <&i2c3>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_usb_c0: usb-c0 { - i2c-port = <&i2c2>; - enum-names = "I2C_PORT_USB_C0", - "I2C_PORT_USB_MUX0"; - }; - i2c_usb_c1: usb-c1 { - i2c-port = <&i2c4>; - enum-names = "I2C_PORT_USB_C1", - "I2C_PORT_USB_MUX1"; - }; - }; - -}; - -&pinctrl { - i2c3_clk_gpf2_sleep: i2c3_clk_gpf2_sleep { - pinmuxs = <&pinctrlf 2 IT8XXX2_ALT_DEFAULT>; - }; - i2c3_data_gpf3_sleep: i2c3_data_gpf3_sleep { - pinmuxs = <&pinctrlf 3 IT8XXX2_ALT_DEFAULT>; - }; -}; - -&i2c0 { - /* EC_I2C_PWR_CBI */ - label = "I2C_PWR_CBI"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_clk_gpb3_default - &i2c0_data_gpb4_default>; - pinctrl-names = "default"; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; - - bc12_port1: rt9490-bc12@53 { - compatible = "richtek,rt9490-bc12"; - status = "okay"; - reg = <0x53>; - irq = <&int_usb_c1_bc12_charger>; - }; -}; - -&i2c1 { - /* EC_I2C_BATTERY */ - label = "I2C_BATTERY"; - status = "okay"; - clock-frequency = <50000>; - pinctrl-0 = <&i2c1_clk_gpc1_default - &i2c1_data_gpc2_default>; - pinctrl-names = "default"; - fifo-enable; -}; - -&i2c2 { - /* EC_I2C_USB_C0 */ - label = "I2C_USB_C0"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_clk_gpf6_default - &i2c2_data_gpf7_default>; - pinctrl-names = "default"; - /delete-property/ fifo-enable; - - bc12_ppc_port0: rt1739@70 { - compatible = "richtek,rt1739"; - status = "okay"; - reg = <0x70>; - }; - - it5205_mux_0: it5205-mux-0@48 { - compatible = "ite,it5205"; - reg = <0x48>; - }; -}; - -&i2c3 { - /* EC_I2C_SENSOR */ - label = "I2C_SENSOR"; - status = "okay"; - clock-frequency = ; - scl-gpios = <&gpiof 2 0>; - sda-gpios = <&gpiof 3 0>; - pinctrl-0 = <&i2c3_clk_gpf2_default - &i2c3_data_gpf3_default>; - pinctrl-1 = <&i2c3_clk_gpf2_sleep - &i2c3_data_gpf3_sleep>; - pinctrl-names = "default", "sleep"; - prescale-scl-low = <1>; -}; - -&i2c4 { - /* EC_I2C_USB_C1 */ - label = "I2C_USB_C1"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c4_clk_gpe0_default - &i2c4_data_gpe7_default>; - pinctrl-names = "default"; - prescale-scl-low = <1>; - - ppc_port1: syv682x@40 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x40>; - frs_en_gpio = <&gpio_ec_x_gpio1>; - }; -}; diff --git a/zephyr/program/corsola/i2c_magikarp.dts b/zephyr/program/corsola/i2c_magikarp.dts index fbf5ed6337..45b7cf20fb 100644 --- a/zephyr/program/corsola/i2c_magikarp.dts +++ b/zephyr/program/corsola/i2c_magikarp.dts @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "i2c_krabby_tentacruel.dtsi" +#include "ite_i2c.dtsi" &i2c0 { charger: rt9490@53 { diff --git a/zephyr/program/corsola/i2c_tentacruel.dts b/zephyr/program/corsola/i2c_tentacruel.dts index a635adcf5c..e56119ff86 100644 --- a/zephyr/program/corsola/i2c_tentacruel.dts +++ b/zephyr/program/corsola/i2c_tentacruel.dts @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "i2c_krabby_tentacruel.dtsi" +#include "ite_i2c.dtsi" &i2c0 { charger: rt9490@53 { diff --git a/zephyr/program/corsola/ite_i2c.dtsi b/zephyr/program/corsola/ite_i2c.dtsi new file mode 100644 index 0000000000..6fd153e1fa --- /dev/null +++ b/zephyr/program/corsola/ite_i2c.dtsi @@ -0,0 +1,138 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + + battery { + i2c-port = <&i2c1>; + remote-port = <1>; + enum-names = "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY"; + }; + i2c_charger: charger { + i2c-port = <&i2c0>; + enum-names = "I2C_PORT_CHARGER", + "I2C_PORT_EEPROM"; + }; + i2c_sensor: sensor { + i2c-port = <&i2c3>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_usb_c0: usb-c0 { + i2c-port = <&i2c2>; + enum-names = "I2C_PORT_USB_C0", + "I2C_PORT_USB_MUX0"; + }; + i2c_usb_c1: usb-c1 { + i2c-port = <&i2c4>; + enum-names = "I2C_PORT_USB_C1", + "I2C_PORT_USB_MUX1"; + }; + }; + +}; + +&pinctrl { + i2c3_clk_gpf2_sleep: i2c3_clk_gpf2_sleep { + pinmuxs = <&pinctrlf 2 IT8XXX2_ALT_DEFAULT>; + }; + i2c3_data_gpf3_sleep: i2c3_data_gpf3_sleep { + pinmuxs = <&pinctrlf 3 IT8XXX2_ALT_DEFAULT>; + }; +}; + +&i2c0 { + /* EC_I2C_PWR_CBI */ + label = "I2C_PWR_CBI"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_clk_gpb3_default + &i2c0_data_gpb4_default>; + pinctrl-names = "default"; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; + + bc12_port1: rt9490-bc12@53 { + compatible = "richtek,rt9490-bc12"; + status = "okay"; + reg = <0x53>; + irq = <&int_usb_c1_bc12_charger>; + }; +}; + +&i2c1 { + /* EC_I2C_BATTERY */ + label = "I2C_BATTERY"; + status = "okay"; + clock-frequency = <50000>; + pinctrl-0 = <&i2c1_clk_gpc1_default + &i2c1_data_gpc2_default>; + pinctrl-names = "default"; + fifo-enable; +}; + +&i2c2 { + /* EC_I2C_USB_C0 */ + label = "I2C_USB_C0"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_clk_gpf6_default + &i2c2_data_gpf7_default>; + pinctrl-names = "default"; + /delete-property/ fifo-enable; + + bc12_ppc_port0: rt1739@70 { + compatible = "richtek,rt1739"; + status = "okay"; + reg = <0x70>; + }; + + it5205_mux_0: it5205-mux-0@48 { + compatible = "ite,it5205"; + reg = <0x48>; + }; +}; + +&i2c3 { + /* EC_I2C_SENSOR */ + label = "I2C_SENSOR"; + status = "okay"; + clock-frequency = ; + scl-gpios = <&gpiof 2 0>; + sda-gpios = <&gpiof 3 0>; + pinctrl-0 = <&i2c3_clk_gpf2_default + &i2c3_data_gpf3_default>; + pinctrl-1 = <&i2c3_clk_gpf2_sleep + &i2c3_data_gpf3_sleep>; + pinctrl-names = "default", "sleep"; + prescale-scl-low = <1>; +}; + +&i2c4 { + /* EC_I2C_USB_C1 */ + label = "I2C_USB_C1"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c4_clk_gpe0_default + &i2c4_data_gpe7_default>; + pinctrl-names = "default"; + prescale-scl-low = <1>; + + ppc_port1: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&gpio_ec_x_gpio1>; + }; +}; -- cgit v1.2.1 From 51744809b3cb5d5ff97bd8a34a0efc87428cee18 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 11:34:11 +0000 Subject: zephyr: Kconfig: enable CONFIG_PLATFORM_EC_BATTERY automatically Enable CONFIG_PLATFORM_EC_BATTERY automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I909a29f6516b225541d878fd6df7de93d8d61754 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999725 Code-Coverage: Zoss Reviewed-by: Wai-Hong Tam --- zephyr/Kconfig.battery | 2 ++ zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/prj.conf | 1 - zephyr/program/herobrine/program.conf | 1 - zephyr/program/intelrvp/prj.conf | 1 - zephyr/program/nissa/program.conf | 1 - zephyr/program/rex/prj.conf | 1 - zephyr/program/skyrim/prj.conf | 1 - zephyr/program/trogdor/lazor/prj.conf | 1 - zephyr/test/drivers/prj.conf | 1 - zephyr/test/krabby/prj.conf | 1 - zephyr/test/vboot_efs2/prj.conf | 1 - 12 files changed, 2 insertions(+), 11 deletions(-) diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery index 92bce6b618..2aedc00dca 100644 --- a/zephyr/Kconfig.battery +++ b/zephyr/Kconfig.battery @@ -4,6 +4,8 @@ menuconfig PLATFORM_EC_BATTERY bool "Battery support" + default y + depends on DT_HAS_BATTERY_SMART_ENABLED help Enables battery support on the board. Requires selection of a battery and a charger IC. diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 422f862809..55968ea8a5 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -108,7 +108,6 @@ CONFIG_CROS_KB_RAW_NPCX=y CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y # Battery -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf index 41162d1a0e..63d128fcc4 100644 --- a/zephyr/program/corsola/prj.conf +++ b/zephyr/program/corsola/prj.conf @@ -82,7 +82,6 @@ CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y CONFIG_PLATFORM_EC_HOSTCMD=y # Battery -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 3391e60dce..9e0b6bd3fc 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -70,7 +70,6 @@ CONFIG_ADC=y CONFIG_ADC_SHELL=n # Battery -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y diff --git a/zephyr/program/intelrvp/prj.conf b/zephyr/program/intelrvp/prj.conf index df04eca101..46e332d91c 100644 --- a/zephyr/program/intelrvp/prj.conf +++ b/zephyr/program/intelrvp/prj.conf @@ -12,7 +12,6 @@ CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y CONFIG_SHIMMED_TASKS=y # Battery -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 35d0efde17..9c4f6ca0b0 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -132,7 +132,6 @@ CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_CDP=y CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_INVERTED=y # Battery support -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 7dcb2894da..05c8a5e9d8 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -82,7 +82,6 @@ CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y CONFIG_PLATFORM_EC_LED_DT=y # Battery -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 760f1f3275..29dd50c151 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -81,7 +81,6 @@ CONFIG_PWM_SHELL=n CONFIG_SYSCON=y # Battery -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 358de69d68..84a71ee5a8 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -68,7 +68,6 @@ CONFIG_ADC=y CONFIG_ADC_SHELL=n # Battery -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 97257c1c75..7492366f27 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -84,7 +84,6 @@ CONFIG_PLATFORM_EC_USB_CHARGER=y CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USB_POWER_DELIVERY=y CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y diff --git a/zephyr/test/krabby/prj.conf b/zephyr/test/krabby/prj.conf index ddf5a29c21..85648b523c 100644 --- a/zephyr/test/krabby/prj.conf +++ b/zephyr/test/krabby/prj.conf @@ -19,7 +19,6 @@ CONFIG_I2C_EMUL=y CONFIG_PLATFORM_EC=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_CHARGER=y diff --git a/zephyr/test/vboot_efs2/prj.conf b/zephyr/test/vboot_efs2/prj.conf index f085fa8f73..fd7d59caca 100644 --- a/zephyr/test/vboot_efs2/prj.conf +++ b/zephyr/test/vboot_efs2/prj.conf @@ -13,7 +13,6 @@ CONFIG_I2C=y CONFIG_I2C_EMUL=y CONFIG_PLATFORM_EC=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -CONFIG_PLATFORM_EC_BATTERY=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_BATTERY_SMART=y -- cgit v1.2.1 From 7f7528f4a06ef78a068a8b949d7bd08ae9773b3c Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 11:54:07 +0000 Subject: zephyr: shim: add a CONFIG_PLATFORM_EC_CBI option. Add a CONFIG_PLATFORM_EC_CBI option that way we can associate it with an explicit build rule instead of having overlapping file list for the various CBI storage types. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: If7f8e68979118392cc4f7af236640b15c74d91fa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999726 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/CMakeLists.txt | 3 +-- zephyr/Kconfig.cbi | 15 ++++++++++++--- zephyr/shim/src/cbi/CMakeLists.txt | 7 ++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 9ca984dbfa..ec88fa7e43 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -244,10 +244,9 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CPS8100 zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_OCPC "${PLATFORM_EC}/common/ocpc.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI "${PLATFORM_EC}/common/cbi.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_GPIO - "${PLATFORM_EC}/common/cbi.c" "${PLATFORM_EC}/common/cbi_gpio.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM "${PLATFORM_EC}/common/memory_commands.c") diff --git a/zephyr/Kconfig.cbi b/zephyr/Kconfig.cbi index a2be51375e..bd89ca854e 100644 --- a/zephyr/Kconfig.cbi +++ b/zephyr/Kconfig.cbi @@ -19,9 +19,9 @@ config PLATFORM_EC_EEPROM_CBI_WP signal. The accompanying hardware must ensure that the CBI WP gets latched and is only reset when EC_RST_ODL is asserted. -choice PLATFORM_EC_CBI_STORAGE_TYPE - prompt "Select CBI storage Type" - optional +config PLATFORM_EC_CBI + bool "CBI support" + default y help CBI is a means for accessing board information, typically set during the factory process. This allows selection of the physical @@ -31,6 +31,13 @@ choice PLATFORM_EC_CBI_STORAGE_TYPE https://chromium.googlesource.com/chromiumos/docs/+/HEAD/design_docs/cros_board_info.md +if PLATFORM_EC_CBI + +choice PLATFORM_EC_CBI_STORAGE_TYPE + prompt "CBI storage type" + help + Select the backing storage type for CBI data. + config PLATFORM_EC_CBI_EEPROM bool "CBI EEPROM support" depends on EEPROM @@ -46,3 +53,5 @@ config PLATFORM_EC_CBI_GPIO CBI for AP to query. endchoice + +endif # PLATFORM_EC_CBI diff --git a/zephyr/shim/src/cbi/CMakeLists.txt b/zephyr/shim/src/cbi/CMakeLists.txt index 4b14f0bb1d..a5d3894ad0 100644 --- a/zephyr/shim/src/cbi/CMakeLists.txt +++ b/zephyr/shim/src/cbi/CMakeLists.txt @@ -1,9 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM cbi_eeprom.c - cros_cbi.c - cros_cbi_fw_config.c - cros_cbi_ssfc.c) -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_GPIO cros_cbi.c +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI cros_cbi.c cros_cbi_fw_config.c cros_cbi_ssfc.c) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM cbi_eeprom.c) -- cgit v1.2.1 From 34780313d94adc7988b7926e03b707c5ec37a0ec Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 12:17:59 +0000 Subject: zephyr: bindings: rename named-cbi-ssfc to cros-ec,cbi-ssfc Rename the SSFC dts bindings for consistency with the FW_CONFIG ones. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Ic47e60948ca6cf3face5903ecbfc8d9b3d0b6c7e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999727 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- docs/zephyr/zephyr_ssfc.md | 20 ++++---- .../dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml | 22 +++++++++ zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml | 56 ++++++++++++++++++++++ zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml | 22 --------- zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml | 56 ---------------------- zephyr/program/corsola/cbi_steelix.dts | 10 ++-- zephyr/program/nissa/craask/cbi.dtsi | 10 ++-- zephyr/program/nissa/pujjo/cbi.dtsi | 10 ++-- zephyr/shim/include/cros_cbi.h | 5 +- zephyr/shim/src/cbi/cros_cbi_fw_config.c | 12 ++--- zephyr/shim/src/cbi/cros_cbi_ssfc.c | 25 +++++----- zephyr/test/drivers/boards/native_posix.overlay | 6 +-- 12 files changed, 126 insertions(+), 128 deletions(-) create mode 100644 zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml create mode 100644 zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml delete mode 100644 zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml delete mode 100644 zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml diff --git a/docs/zephyr/zephyr_ssfc.md b/docs/zephyr/zephyr_ssfc.md index d40fdbc9c4..6a3fe079d3 100644 --- a/docs/zephyr/zephyr_ssfc.md +++ b/docs/zephyr/zephyr_ssfc.md @@ -25,11 +25,11 @@ Device tree is used to define and specify the field sizes and values. ## Devicetree Nodes -The [`SSFC`] device tree nodes are defined via the [`named-cbi-ssfc`] and -[`named-cbi-ssfc-value`] YAML bindings. +The [`SSFC`] device tree nodes are defined via the [`cros-ec,cbi-ssfc`] and +[`cros-ec,cbi-ssfc-value`] YAML bindings. -The [`named-cbi-ssfc`] bindings define the name and size of each field. -The [`named-cbi-ssfc-value`] bindings allow names/values to be defined for each +The [`cros-ec,cbi-ssfc`] bindings define the name and size of each field. +The [`cros-ec,cbi-ssfc-value`] bindings allow names/values to be defined for each value that may be stored in the field. One of the values may be designated as the default, which is used if the [`CBI`] data cannot be accessed. @@ -41,12 +41,12 @@ value is used as a default, indicating the default field. An example definition is: ``` cbi-ssfc { - compatible = "named-cbi-ssfc"; + compatible = "cros-ec,cbi-ssfc"; base_sensor { enum-name = "BASE_SENSOR"; size = <3>; base_sensor_0: bmi160 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; }; @@ -55,7 +55,7 @@ cbi-ssfc { enum-name = "LID_SENSOR"; size = <3>; lid_sensor_0: bma255 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; }; @@ -64,7 +64,7 @@ cbi-ssfc { enum-name = "LIGHTBAR"; size = <2>; lightbar_0: 10_led { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; }; @@ -99,6 +99,6 @@ The [`ectool cbi`] command can be used to read and set the [`SSFC`]. [`CBI`]: https://chromium.googlesource.com/chromiumos/docs/+/HEAD/design_docs/cros_board_info.md [`CBI Configuration`]: ./zephyr_cbi.md [`ectool cbi`]: ./zephyr_cbi.md#testing-and-debugging -[`named-cbi-ssfc`]: ../../zephyr/dts/bindings/cbi/named-cbi-fw-config.yaml -[`named-cbi-ssfc-value`]: ../../zephyr/dts/bindings/cbi/named-cbi-fw-config-value.yaml +[`cros-ec,cbi-ssfc`]: ../../zephyr/dts/bindings/cbi/cros-ec,cbi-fw-config.yaml +[`cros-ec,cbi-ssfc-value`]: ../../zephyr/dts/bindings/cbi/cros-ec,cbi-fw-config-value.yaml [`SSFC`]: https://chromium.googlesource.com/chromiumos/docs/+/HEAD/design_docs/firmware_config.md diff --git a/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml b/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml new file mode 100644 index 0000000000..6bbba1bdd7 --- /dev/null +++ b/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml @@ -0,0 +1,22 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: + Possible CBI SSFC field values. + It has to be defined as grandchild on the "cros-ec,cbi-ssfc" + +compatible: "cros-ec,cbi-ssfc-value" + +properties: + value: + type: int + required: true + description: + Unique value of CBI SSFC field + default: + type: boolean + description: + Indicates that the specified value is default for the parent + CBI SSFC field node. It should appear only once for the CBI SSFC + definition. diff --git a/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml b/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml new file mode 100644 index 0000000000..d1cc4c26e5 --- /dev/null +++ b/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml @@ -0,0 +1,56 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: CBI Second Source Factory Cache (SSFC) + +compatible: "cros-ec,cbi-ssfc" + +child-binding: + description: + CBI SSFC fields definition. + The order of the children in this node define the order + of the SSFC bit fields from least significant bit to most + significant bit. The total size of all SSFC bit fields + must not exceed 32 bits. + properties: + enum-name: + type: string + required: true + description: + Enum values used only for description purposes + enum: + - AUDIO_CODEC + - BASE_SENSOR + - LID_SENSOR + - LIGHTBAR + - USB_SS_MUX + size: + type: int + required: true + description: The size of the field in bits. + +# Example: +# +# cbi-ssfc { +# compatible = "cros-ec,cbi-ssfc"; +# +# base_sensor { +# enum-name = "BASE_SENSOR"; +# size = <3>; +# bmi160 { +# compatible = "cros-ec,cbi-ssfc-value"; +# status = "okay"; +# +# value = <1>; +# devices = <&alt_base_accel &alt_base_gyro>; +# }; +# kx022 { +# compatible = "cros-ec,cbi-ssfc-value"; +# status = "okay"; +# +# value = <3>; +# devices = <&base_accel_kx022>; +# }; +# }; +# }; diff --git a/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml b/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml deleted file mode 100644 index 7e04afed87..0000000000 --- a/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: - Possible CBI SSFC field values. - It has to be defied as grandchild on the "named-cbi-ssfc" - -compatible: "named-cbi-ssfc-value" - -properties: - value: - type: int - required: true - description: - Unique value of CBI SSFC field - default: - type: boolean - description: - Indicates that the specified value is default for the parent - CBI SSFC field node. It should appear only once for the CBI SSFC - definition. diff --git a/zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml b/zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml deleted file mode 100644 index 2db330079d..0000000000 --- a/zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: CBI Second Source Factory Cache (SSFC) - -compatible: "named-cbi-ssfc" - -child-binding: - description: - CBI SSFC fields definition. - The order of the children in this node define the order - of the SSFC bit fields from least significant bit to most - significant bit. The total size of all SSFC bit fields - must not exceed 32 bits. - properties: - enum-name: - type: string - required: true - description: - Enum values used only for description purposes - enum: - - AUDIO_CODEC - - BASE_SENSOR - - LID_SENSOR - - LIGHTBAR - - USB_SS_MUX - size: - type: int - required: true - description: The size of the field in bits. - -# Example: -# -# cbi-ssfc { -# compatible = "named-cbi-ssfc"; -# -# base_sensor { -# enum-name = "BASE_SENSOR"; -# size = <3>; -# bmi160 { -# compatible = "named-cbi-ssfc-value"; -# status = "okay"; -# -# value = <1>; -# devices = <&alt_base_accel &alt_base_gyro>; -# }; -# kx022 { -# compatible = "named-cbi-ssfc-value"; -# status = "okay"; -# -# value = <3>; -# devices = <&base_accel_kx022>; -# }; -# }; -# }; \ No newline at end of file diff --git a/zephyr/program/corsola/cbi_steelix.dts b/zephyr/program/corsola/cbi_steelix.dts index f4918b1577..6636b53a96 100644 --- a/zephyr/program/corsola/cbi_steelix.dts +++ b/zephyr/program/corsola/cbi_steelix.dts @@ -54,7 +54,7 @@ /* Steelix-specific ssfc fields. */ steelix-ssfc { - compatible = "named-cbi-ssfc"; + compatible = "cros-ec,cbi-ssfc"; /* SSFC field to identify BASE motion sensor. */ base-sensor { @@ -62,13 +62,13 @@ size = <3>; base_sensor_0: bmi323 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; default; }; base_sensor_1: lsm6dsm { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <2>; }; @@ -80,13 +80,13 @@ size = <3>; lid_sensor_0: bma422 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; default; }; lid_sensor_1: lis2dw12 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <2>; }; diff --git a/zephyr/program/nissa/craask/cbi.dtsi b/zephyr/program/nissa/craask/cbi.dtsi index 4c2e052f4d..ef36a58d9d 100644 --- a/zephyr/program/nissa/craask/cbi.dtsi +++ b/zephyr/program/nissa/craask/cbi.dtsi @@ -55,7 +55,7 @@ }; /* Craask-specific ssfc fields. */ cbi-ssfc { - compatible = "named-cbi-ssfc"; + compatible = "cros-ec,cbi-ssfc"; /* * SSFC bit0-1 was defined for AUDIO CODEC. * 0: ALC5682I_VS @@ -73,13 +73,13 @@ size = <2>; lid_sensor_0: lis2dw12 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <0>; default; }; lid_sensor_1: bma422 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; }; @@ -92,13 +92,13 @@ size = <2>; base_sensor_0: lsm6dso { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <0>; default; }; base_sensor_1: bmi323 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; }; diff --git a/zephyr/program/nissa/pujjo/cbi.dtsi b/zephyr/program/nissa/pujjo/cbi.dtsi index b5ba92bd9e..02057140a5 100644 --- a/zephyr/program/nissa/pujjo/cbi.dtsi +++ b/zephyr/program/nissa/pujjo/cbi.dtsi @@ -146,7 +146,7 @@ /* Pujjo-specific ssfc fields. */ cbi-ssfc { - compatible = "named-cbi-ssfc"; + compatible = "cros-ec,cbi-ssfc"; /* * SSFC field to identify BASE motion sensor. */ @@ -155,13 +155,13 @@ size = <2>; base_sensor_0: bmi323 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <0>; default; }; base_sensor_1: lsm6dsm { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; }; @@ -175,13 +175,13 @@ size = <2>; lid_sensor_0: bma422 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <0>; default; }; lid_sensor_1: lis2dw12 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; }; diff --git a/zephyr/shim/include/cros_cbi.h b/zephyr/shim/include/cros_cbi.h index 1f8a1b3dfa..6f5bfd4d70 100644 --- a/zephyr/shim/include/cros_cbi.h +++ b/zephyr/shim/include/cros_cbi.h @@ -13,10 +13,9 @@ /* * Macros are _INST_ types, so require DT_DRV_COMPAT to be defined. */ -#define DT_DRV_COMPAT named_cbi_ssfc_value -#define CROS_CBI_LABEL "cros_cbi" +#define DT_DRV_COMPAT cros_ec_cbi_ssfc_value -#define CBI_SSFC_VALUE_COMPAT named_cbi_ssfc_value +#define CBI_SSFC_VALUE_COMPAT DT_DRV_COMPAT #define CBI_SSFC_VALUE_ID(id) DT_CAT(CBI_SSFC_VALUE_, id) #define CBI_SSFC_VALUE_ID_WITH_COMMA(id) CBI_SSFC_VALUE_ID(id), #define CBI_SSFC_VALUE_INST_ENUM(inst, _) \ diff --git a/zephyr/shim/src/cbi/cros_cbi_fw_config.c b/zephyr/shim/src/cbi/cros_cbi_fw_config.c index 6710a30726..605c7ca0f7 100644 --- a/zephyr/shim/src/cbi/cros_cbi_fw_config.c +++ b/zephyr/shim/src/cbi/cros_cbi_fw_config.c @@ -47,13 +47,13 @@ LOG_MODULE_REGISTER(cros_cbi_fw_config, LOG_LEVEL_ERR); #define FW_SHIFT_MASK(id) (FW_MASK(id) << FW_START(id)) /* - * For a child "named-cbi-fw-config-value" node, retrieve the + * For a child "cros-ec,cbi-fw-config-value" node, retrieve the * size of the parent field this value is associated with. */ #define FW_PARENT_SIZE(id) DT_PROP(DT_PARENT(id), size) /* - * For a child "named-cbi-fw-config-value" node, retrieve the + * For a child "cros-ec,cbi-fw-config-value" node, retrieve the * start of the parent field this value is associated with. */ #define FW_PARENT_START(id) DT_PROP(DT_PARENT(id), start) @@ -115,7 +115,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT) /* * Define bit fields based on the device tree entries. Example: * cbi-fw-config { - * compatible = "named-cbi-fw-config"; + * compatible = "cros-ec,cbi-fw-config"; * * fan { * enum-name = "FW_CONFIG_FAN"; @@ -123,7 +123,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT) * size = <1>; * fan_present { * enum-name = "FW_FAN_PRESENT" - * compatible = "named-cbi-fw-config-value"; + * compatible = "cros-ec,cbi-fw-config-value"; * value = <1>; * }; * }; @@ -148,7 +148,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT) break; /* - * Create a case for every child of this "named-cbi-fw-config" node. + * Create a case for every child of this "cros-ec,cbi-fw-config" node. */ #define FW_FIELD_NODES(inst, cached, value) \ DT_FOREACH_CHILD_STATUS_OKAY_VARGS(inst, FW_FIELD_CASE, cached, value) @@ -177,7 +177,7 @@ static int cros_cbi_fw_config_get_field(uint32_t cached_fw_config, { switch (field_id) { /* - * Iterate through all the the "named-cbi-fw-config" nodes, + * Iterate through all the the "cros-ec,cbi-fw-config" nodes, * and create cases for all of their child nodes. */ DT_FOREACH_STATUS_OKAY_VARGS(CBI_FW_CONFIG_COMPAT, diff --git a/zephyr/shim/src/cbi/cros_cbi_ssfc.c b/zephyr/shim/src/cbi/cros_cbi_ssfc.c index eb0f69b1cb..9158e9f215 100644 --- a/zephyr/shim/src/cbi/cros_cbi_ssfc.c +++ b/zephyr/shim/src/cbi/cros_cbi_ssfc.c @@ -10,18 +10,17 @@ LOG_MODULE_REGISTER(cros_cbi_ssfc, LOG_LEVEL_ERR); -/* Actually, two "compatible" values are handle here - - * named_cbi_ssfc_value and named_cbi_ssfc. named_cbi_ssfc_value nodes are - * grandchildren of the named_cbi_ssfc node. named_cbi_ssfc_value is introduced - * to iterate over grandchildren of the named_cbi_ssfc(macro - * DT_FOREACH_CHILD can not be nested) and it can be pointed by a sensor dts to - * indicate alternative usage. +/* Actually, two "compatible" values are handle here - cros_ec_cbi_ssfc_value + * and cros_ec_cbi_ssfc. cros_ec_cbi_ssfc_value nodes are grandchildren of the + * cros_ec_cbi_ssfc node. cros_ec_cbi_ssfc_value is introduced to iterate over + * grandchildren of the cros_ec_cbi_ssfc (macro DT_FOREACH_CHILD can not be + * nested) and it can be pointed by a sensor dts to indicate alternative usage. */ -#define DT_DRV_COMPAT named_cbi_ssfc_value +#define DT_DRV_COMPAT cros_ec_cbi_ssfc_value -BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(named_cbi_ssfc) < 2, +BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(cros_ec_cbi_ssfc) < 2, "More than 1 CBI SSFS node"); -#define CBI_SSFC_NODE DT_INST(0, named_cbi_ssfc) +#define CBI_SSFC_NODE DT_INST(0, cros_ec_cbi_ssfc) #define CBI_SSFC_INIT_DEFAULT_ID(id, ssfc) \ do { \ @@ -73,13 +72,13 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits"); /* * Define union bit fields based on the device tree entries. Example: * cbi-ssfc { - * compatible = "named-cbi-ssfc"; + * compatible = "cros-ec,cbi-ssfc"; * * base_sensor { * enum-name = "BASE_SENSOR"; * size = <3>; * bmi160 { - * compatible = "named-cbi-ssfc-value"; + * compatible = "cros-ec,cbi-ssfc-value"; * status = "okay"; * value = <1>; * }; @@ -88,7 +87,7 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits"); * enum-name = "LID_SENSOR"; * size = <3>; * bma255 { - * compatible = "named-cbi-ssfc-value"; + * compatible = "cros-ec,cbi-ssfc-value"; * status = "okay"; * value = <1>; * }; @@ -97,7 +96,7 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits"); * enum-name = "LIGHTBAR"; * size = <2>; * 10_led { - * compatible = "named-cbi-ssfc-value"; + * compatible = "cros-ec,cbi-ssfc-value"; * status = "okay"; * value = <1>; * }; diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index c194474052..3a0461badd 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -341,18 +341,18 @@ }; cbi-ssfc { - compatible = "named-cbi-ssfc"; + compatible = "cros-ec,cbi-ssfc"; cbi_ssfc_base_sensor: base_sensor { enum-name = "BASE_SENSOR"; size = <2>; base_sensor_0: base0 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <1>; default; }; base_sensor_1: base1 { - compatible = "named-cbi-ssfc-value"; + compatible = "cros-ec,cbi-ssfc-value"; status = "okay"; value = <2>; }; -- cgit v1.2.1 From 8aba017d5e446ad1b2acb45f15dd80499d06726c Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 12:28:23 +0000 Subject: zephyr: shim: select the correct CBI source automatically Select the right CBI data source config option depending on what's defined in the devicetree for the project. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Ia1d2755fdaae9062d1265e9ae9bd0017530d2ae0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999728 Code-Coverage: Zoss Reviewed-by: Sam Hurst --- zephyr/Kconfig.cbi | 1 + zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/prj.conf | 1 - zephyr/program/herobrine/program.conf | 1 - zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 1 - zephyr/program/intelrvp/adlrvp/prj.conf | 1 - zephyr/program/intelrvp/mtlrvp/prj.conf | 1 - zephyr/program/nissa/program.conf | 2 -- zephyr/program/rex/prj.conf | 1 - zephyr/program/skyrim/prj.conf | 1 - zephyr/test/drivers/testcase.yaml | 6 +----- zephyr/test/kingler/prj.conf | 1 - 12 files changed, 2 insertions(+), 16 deletions(-) diff --git a/zephyr/Kconfig.cbi b/zephyr/Kconfig.cbi index bd89ca854e..db54c87fbb 100644 --- a/zephyr/Kconfig.cbi +++ b/zephyr/Kconfig.cbi @@ -35,6 +35,7 @@ if PLATFORM_EC_CBI choice PLATFORM_EC_CBI_STORAGE_TYPE prompt "CBI storage type" + default PLATFORM_EC_CBI_EEPROM if $(dt_nodelabel_enabled,cbi_eeprom) help Select the backing storage type for CBI data. diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 55968ea8a5..97781f6e48 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -30,7 +30,6 @@ CONFIG_ARM_MPU=y CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y # eSPI diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf index 63d128fcc4..c0ae213f6c 100644 --- a/zephyr/program/corsola/prj.conf +++ b/zephyr/program/corsola/prj.conf @@ -31,7 +31,6 @@ CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y -CONFIG_PLATFORM_EC_CBI_EEPROM=y # I2C CONFIG_I2C=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 9e0b6bd3fc..ee137554cf 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -11,7 +11,6 @@ CONFIG_PLATFORM_EC_SWITCH=y CONFIG_PLATFORM_EC_LID_SWITCH=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=y CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_CBI_GPIO=y CONFIG_KERNEL_SHELL=y CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf index 083530c858..5bd99f7b6e 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf @@ -57,7 +57,6 @@ CONFIG_PLATFORM_EC_THROTTLE_AP=n CONFIG_EEPROM=n CONFIG_EEPROM_AT24=n CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=n # LED CONFIG_PLATFORM_EC_LED_COMMON=n diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index 4bcee4a953..f23aed87df 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -19,7 +19,6 @@ CONFIG_PLATFORM_EC_USB_CHARGER=n CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y # Charger CONFIG_PLATFORM_EC_CHARGER=y diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index 1a521d4c89..86726dabd3 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -16,7 +16,6 @@ CONFIG_PLATFORM_EC_BATTERY_V2=y CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 9c4f6ca0b0..ff3a727568 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -85,10 +85,8 @@ CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY=y CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y - # PWM support CONFIG_PWM=y CONFIG_PWM_SHELL=y diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 05c8a5e9d8..75083dd9be 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -74,7 +74,6 @@ CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 29dd50c151..e20db16b2c 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -38,7 +38,6 @@ CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y -CONFIG_PLATFORM_EC_CBI_EEPROM=y # Temperature Sensors CONFIG_PLATFORM_EC_AMD_SB_RMI=y diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 4eb41bc6e3..43387183b9 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -9,7 +9,6 @@ tests: - CONFIG_LINK_TEST_SUITE_USB_MALFUNCTION_SINK=y - CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y - - CONFIG_PLATFORM_EC_CBI_EEPROM=y - CONFIG_PLATFORM_EC_USB_PD_DPS=y drivers.default.mock_power: timeout: 240 @@ -20,7 +19,6 @@ tests: - CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y - CONFIG_POWER_SEQUENCE_MOCK=y - - CONFIG_PLATFORM_EC_CBI_EEPROM=y - CONFIG_PLATFORM_EC_USB_PD_DPS=y drivers.anx7447: extra_args: CONF_FILE="prj.conf;anx7447/prj.conf" DTC_OVERLAY_FILE="./boards/native_posix.overlay;./anx7447/tcpc_policy.dts" @@ -47,7 +45,6 @@ tests: drivers.common_cbi: extra_configs: - CONFIG_LINK_TEST_SUITE_COMMON_CBI=y - - CONFIG_PLATFORM_EC_CBI_EEPROM=y drivers.common_cbi_gpio: extra_configs: - CONFIG_LINK_TEST_SUITE_COMMON_CBI_GPIO=y @@ -93,7 +90,6 @@ tests: extra_args: DTC_OVERLAY_FILE="./boards/native_posix.overlay;i2c_controller/i2c.dts" extra_configs: - CONFIG_LINK_TEST_SUITE_I2C_CONTROLLER=y - - CONFIG_PLATFORM_EC_CBI_EEPROM=y drivers.keyboard_scan: extra_configs: - CONFIG_LINK_TEST_SUITE_KEYBOARD_SCAN=y @@ -104,6 +100,7 @@ tests: drivers.locate_chip: extra_configs: - CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS=y + - CONFIG_PLATFORM_EC_CBI=n drivers.mkbp: extra_configs: - CONFIG_LINK_TEST_SUITE_MKBP=y @@ -155,7 +152,6 @@ tests: extra_configs: - CONFIG_LINK_TEST_SUITE_SYSTEM=y - CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y - - CONFIG_PLATFORM_EC_CBI_EEPROM=y - CONFIG_POWER_SEQUENCE_MOCK=y drivers.timer: extra_configs: diff --git a/zephyr/test/kingler/prj.conf b/zephyr/test/kingler/prj.conf index 2eb14afb0e..76f4434bc6 100644 --- a/zephyr/test/kingler/prj.conf +++ b/zephyr/test/kingler/prj.conf @@ -21,7 +21,6 @@ CONFIG_PLATFORM_EC_LID_ANGLE=y CONFIG_I2C=y CONFIG_I2C_NPCX=n -CONFIG_PLATFORM_EC_CBI_EEPROM=y CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y -- cgit v1.2.1 From d4c91c3c58f5b77fba796e6a1a4a6a470abde4ed Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 15:32:34 +0000 Subject: zephyr: config drop explicit CONFIG_PLATFORM_EC_CHARGER=y The option already defaults to the correct value, no need to set it explicitly. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I66b0722df26d3685d3e8414aab8f14786ba09b73 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000380 Code-Coverage: Zoss Reviewed-by: Aaron Massey --- zephyr/program/corsola/prj.conf | 1 - zephyr/program/intelrvp/adlrvp/prj.conf | 1 - zephyr/program/intelrvp/mtlrvp/prj.conf | 1 - zephyr/program/nissa/program.conf | 1 - zephyr/test/krabby/prj.conf | 1 - 5 files changed, 5 deletions(-) diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf index c0ae213f6c..ea72d0890f 100644 --- a/zephyr/program/corsola/prj.conf +++ b/zephyr/program/corsola/prj.conf @@ -91,7 +91,6 @@ CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y # Charger CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y -CONFIG_PLATFORM_EC_CHARGER=y CONFIG_PLATFORM_EC_CHARGE_MANAGER=y # Button diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index f23aed87df..76ae3db975 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -21,7 +21,6 @@ CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n # Charger -CONFIG_PLATFORM_EC_CHARGER=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index 86726dabd3..71f0feae63 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -23,7 +23,6 @@ CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y CONFIG_PLATFORM_EC_USB_CHARGER=n # Charger -CONFIG_PLATFORM_EC_CHARGER=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index ff3a727568..622d82837c 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -137,7 +137,6 @@ CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y # Charger support -CONFIG_PLATFORM_EC_CHARGER=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y diff --git a/zephyr/test/krabby/prj.conf b/zephyr/test/krabby/prj.conf index 85648b523c..a3a77e5547 100644 --- a/zephyr/test/krabby/prj.conf +++ b/zephyr/test/krabby/prj.conf @@ -21,7 +21,6 @@ CONFIG_PLATFORM_EC=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_CHARGER=y CONFIG_PLATFORM_EC_CHARGER_RT9490=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -- cgit v1.2.1 From 2cfd8332057c7427c22500b76aba7926ba6df6bf Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 15:40:18 +0000 Subject: zephyr: Kconfig: enable PLATFORM_EC_CHARGER_RT9490 automatically Enable PLATFORM_EC_CHARGER_RT9490 automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I0d45ea628e539b9bed608be346e7051bc465f405 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000381 Reviewed-by: Keith Short Code-Coverage: Zoss --- zephyr/Kconfig.charger | 2 ++ zephyr/program/corsola/prj_it81202_base.conf | 1 - zephyr/test/drivers/rt9490/prj.conf | 1 - zephyr/test/krabby/prj.conf | 1 - 4 files changed, 2 insertions(+), 3 deletions(-) diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger index 34fe34397a..35bd8590ab 100644 --- a/zephyr/Kconfig.charger +++ b/zephyr/Kconfig.charger @@ -186,6 +186,8 @@ config PLATFORM_EC_CHARGER_RAA489000 config PLATFORM_EC_CHARGER_RT9490 bool "Use the RT9490 charger" + default y + depends on DT_HAS_RICHTEK_RT9490_ENABLED || DT_HAS_ZEPHYR_RT9490_EMUL_ENABLED depends on PLATFORM_EC_I2C select PLATFORM_EC_CHARGER_OTG_SUPPORTED help diff --git a/zephyr/program/corsola/prj_it81202_base.conf b/zephyr/program/corsola/prj_it81202_base.conf index 04283bcf5c..2d4af86300 100644 --- a/zephyr/program/corsola/prj_it81202_base.conf +++ b/zephyr/program/corsola/prj_it81202_base.conf @@ -17,7 +17,6 @@ CONFIG_PLATFORM_EC_LID_SWITCH=y CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_RT9490=y CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y CONFIG_PLATFORM_EC_CHARGER_PSYS=y CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y diff --git a/zephyr/test/drivers/rt9490/prj.conf b/zephyr/test/drivers/rt9490/prj.conf index 29c63c48f3..4ee5b96518 100644 --- a/zephyr/test/drivers/rt9490/prj.conf +++ b/zephyr/test/drivers/rt9490/prj.conf @@ -5,7 +5,6 @@ CONFIG_EMUL_RT9490=y CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n CONFIG_PLATFORM_EC_CHARGER_OTG=y -CONFIG_PLATFORM_EC_CHARGER_RT9490=y CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y CONFIG_PLATFORM_EC_HOOKS=y diff --git a/zephyr/test/krabby/prj.conf b/zephyr/test/krabby/prj.conf index a3a77e5547..063904d19f 100644 --- a/zephyr/test/krabby/prj.conf +++ b/zephyr/test/krabby/prj.conf @@ -21,7 +21,6 @@ CONFIG_PLATFORM_EC=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_CHARGER_RT9490=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 CONFIG_PLATFORM_EC_CHARGE_MANAGER=n -- cgit v1.2.1 From 9b240f06ea67164112c47f4341ad52202a114887 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 15:48:51 +0000 Subject: zephyr: Kconfig: enable CONFIG_CROS_FLASH_XEC automatically Enable CONFIG_CROS_FLASH_XEC automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Ia887e3743b47a4383b4d13db12fd5f4f5b255aeb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000382 Code-Coverage: Zoss Reviewed-by: Keith Short --- zephyr/drivers/cros_flash/Kconfig | 2 +- zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/zephyr/drivers/cros_flash/Kconfig b/zephyr/drivers/cros_flash/Kconfig index 8931f413e4..731ce31105 100644 --- a/zephyr/drivers/cros_flash/Kconfig +++ b/zephyr/drivers/cros_flash/Kconfig @@ -39,8 +39,8 @@ config CROS_FLASH_IT8XXX2 config CROS_FLASH_XEC bool "Microchip XEC flash driver for the Zephyr shim" - depends on SOC_FAMILY_MEC default y + depends on DT_HAS_MICROCHIP_XEC_CROS_FLASH_ENABLED select PLATFORM_EC_FLASH_CROS select PLATFORM_EC_SPI_FLASH_REGS help diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf index 5bd99f7b6e..0d4333ddc4 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf @@ -3,7 +3,6 @@ # found in the LICENSE file. CONFIG_BOARD_ADLRVP_MCHP=y -CONFIG_CROS_FLASH_XEC=y CONFIG_CROS_SYSTEM_XEC=y CONFIG_CROS_KB_RAW_XEC=y -- cgit v1.2.1 From 274ddb17a7cf89ad68cc768cec887ccb8c5a8cef Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 15:51:12 +0000 Subject: zephyr: Kconfig: enable CROS_FLASH_NPCX automatically Enable CROS_FLASH_NPCX automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I59b2559a1db08ab9e33f7b6409d5774a247ee1ed Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000383 Reviewed-by: Yuval Peress Code-Coverage: Zoss --- zephyr/drivers/cros_flash/Kconfig | 2 +- zephyr/program/brya/prj.conf | 1 - zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf | 1 - zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf | 1 - zephyr/program/nissa/npcx_program.conf | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/zephyr/drivers/cros_flash/Kconfig b/zephyr/drivers/cros_flash/Kconfig index 731ce31105..06f2b9f8c0 100644 --- a/zephyr/drivers/cros_flash/Kconfig +++ b/zephyr/drivers/cros_flash/Kconfig @@ -4,8 +4,8 @@ menuconfig CROS_FLASH_NPCX bool "Nuvoton NPCX flash driver for the Zephyr shim" - depends on SOC_FAMILY_NPCX default y + depends on DT_HAS_NUVOTON_NPCX_CROS_FLASH_ENABLED select PLATFORM_EC_FLASH_CROS select PLATFORM_EC_SPI_FLASH_REGS help diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 97781f6e48..6bd30affb4 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -9,7 +9,6 @@ CONFIG_PLATFORM_EC_POWER_BUTTON=y CONFIG_PLATFORM_EC_LID_SWITCH=y CONFIG_PLATFORM_EC_SWITCH=y CONFIG_LTO=y -CONFIG_CROS_FLASH_NPCX=y CONFIG_CROS_SYSTEM_NPCX=y CONFIG_PLATFORM_EC_VBOOT_EFS2=y CONFIG_PLATFORM_EC_VBOOT_HASH=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf index 2c98fd9330..52d3bac798 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf @@ -3,7 +3,6 @@ # found in the LICENSE file. CONFIG_BOARD_ADLRVP_NPCX=y -CONFIG_CROS_FLASH_NPCX=y CONFIG_CROS_SYSTEM_NPCX=y CONFIG_SYSCON=y diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf index 45b101a7ac..162c6c24dc 100644 --- a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf @@ -3,7 +3,6 @@ # found in the LICENSE file. CONFIG_BOARD_MTLRVP_NPCX=y -CONFIG_CROS_FLASH_NPCX=y CONFIG_CROS_SYSTEM_NPCX=y CONFIG_SYSCON=y diff --git a/zephyr/program/nissa/npcx_program.conf b/zephyr/program/nissa/npcx_program.conf index 1af7c9531f..875c4bb2ef 100644 --- a/zephyr/program/nissa/npcx_program.conf +++ b/zephyr/program/nissa/npcx_program.conf @@ -3,7 +3,6 @@ # found in the LICENSE file. # EC chip configuration: NPCX993 -CONFIG_CROS_FLASH_NPCX=y CONFIG_CROS_SYSTEM_NPCX=y CONFIG_SOC_SERIES_NPCX9=y CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y -- cgit v1.2.1 From 2bf71ffe5b810888bf9dd458bc67f7c48a96fc60 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 15:53:17 +0000 Subject: zephyr: Kconfig: enable CONFIG_CROS_KB_RAW_ITE automatically Enable CONFIG_CROS_KB_RAW_ITE automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Ib58406766c74ab1839c75879ac74ed064749b21d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000384 Reviewed-by: Keith Short Code-Coverage: Zoss --- zephyr/drivers/cros_kb_raw/Kconfig | 2 +- zephyr/program/it8xxx2_evb/prj.conf | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/zephyr/drivers/cros_kb_raw/Kconfig b/zephyr/drivers/cros_kb_raw/Kconfig index 1055c8a4b2..788684cdcb 100644 --- a/zephyr/drivers/cros_kb_raw/Kconfig +++ b/zephyr/drivers/cros_kb_raw/Kconfig @@ -27,8 +27,8 @@ endif # CROS_KB_RAW_NPCX config CROS_KB_RAW_ITE bool "ITE raw-keyboard-scan driver for the Zephyr shim" - depends on SOC_FAMILY_RISCV_ITE default y + depends on DT_HAS_ITE_IT8XXX2_CROS_KB_RAW_ENABLED help This option enables a driver for providing raw access to the keyboard-scan peripheral in the chip. This is used instead of the diff --git a/zephyr/program/it8xxx2_evb/prj.conf b/zephyr/program/it8xxx2_evb/prj.conf index d6d422e490..5d561eb4e4 100644 --- a/zephyr/program/it8xxx2_evb/prj.conf +++ b/zephyr/program/it8xxx2_evb/prj.conf @@ -34,7 +34,6 @@ CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n CONFIG_PLATFORM_EC_KEYBOARD=n -CONFIG_CROS_KB_RAW_ITE=n CONFIG_PLATFORM_EC_SWITCH=n CONFIG_PLATFORM_EC_VBOOT_EFS2=n CONFIG_PLATFORM_EC_VBOOT_HASH=n -- cgit v1.2.1 From 81d08d61a3737c35e805ebd2057cf378489af4ed Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 15:55:04 +0000 Subject: zephyr: Kconfig: enable CONFIG_CROS_KB_RAW_XEC automatically Enable CONFIG_CROS_KB_RAW_XEC automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I6acaef6880dab79f16d3d394c83c54601d1c09c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000385 Reviewed-by: Tristan Honscheid Code-Coverage: Zoss --- zephyr/drivers/cros_kb_raw/Kconfig | 2 +- zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/zephyr/drivers/cros_kb_raw/Kconfig b/zephyr/drivers/cros_kb_raw/Kconfig index 788684cdcb..439a1d4abf 100644 --- a/zephyr/drivers/cros_kb_raw/Kconfig +++ b/zephyr/drivers/cros_kb_raw/Kconfig @@ -37,8 +37,8 @@ config CROS_KB_RAW_ITE menuconfig CROS_KB_RAW_XEC bool "Microchip raw-keyboard-scan driver for the Zephyr shim" - depends on SOC_FAMILY_MEC default y + depends on DT_HAS_MICROCHIP_XEC_CROS_KB_RAW_ENABLED help This option enables a driver for providing raw access to the keyboard-scan peripheral in the chip. This is used instead of the diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf index 0d4333ddc4..d18e9c14b0 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf @@ -4,7 +4,6 @@ CONFIG_BOARD_ADLRVP_MCHP=y CONFIG_CROS_SYSTEM_XEC=y -CONFIG_CROS_KB_RAW_XEC=y # For MCHP ESPI Drivers CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y -- cgit v1.2.1 From a4ca8b234ff5d77b6c935756cc76eaca1b7cb4b7 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 15:56:46 +0000 Subject: zephyr: Kconfig: enable CONFIG_CROS_KB_RAW_NPCX automatically Enable CONFIG_CROS_KB_RAW_NPCX automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I340b51d0337644b828c09df59a63819201b1cdbe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000386 Code-Coverage: Zoss Reviewed-by: Jeremy Bettis --- zephyr/drivers/cros_kb_raw/Kconfig | 2 +- zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/prj_npcx993_base.conf | 1 - zephyr/program/herobrine/program.conf | 1 - zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf | 3 --- zephyr/program/nissa/npcx_program.conf | 1 - zephyr/program/rex/prj_rex.conf | 3 --- zephyr/program/trogdor/lazor/prj.conf | 1 - 8 files changed, 1 insertion(+), 12 deletions(-) diff --git a/zephyr/drivers/cros_kb_raw/Kconfig b/zephyr/drivers/cros_kb_raw/Kconfig index 439a1d4abf..1e10f38bbe 100644 --- a/zephyr/drivers/cros_kb_raw/Kconfig +++ b/zephyr/drivers/cros_kb_raw/Kconfig @@ -6,8 +6,8 @@ if PLATFORM_EC_KEYBOARD menuconfig CROS_KB_RAW_NPCX bool "Nuvoton NPCX raw-keyboard-scan driver for the Zephyr shim" - depends on SOC_FAMILY_NPCX default y + depends on DT_HAS_NUVOTON_NPCX_CROS_KB_RAW_ENABLED help This option enables a driver for providing raw access to the keyboard-scan peripheral in the chip. This is used instead of the diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 6bd30affb4..5d80ff9b34 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -101,7 +101,6 @@ CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CMD_BUTTON=n -CONFIG_CROS_KB_RAW_NPCX=y CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y diff --git a/zephyr/program/corsola/prj_npcx993_base.conf b/zephyr/program/corsola/prj_npcx993_base.conf index 0642bcd331..35189ea2f7 100644 --- a/zephyr/program/corsola/prj_npcx993_base.conf +++ b/zephyr/program/corsola/prj_npcx993_base.conf @@ -87,7 +87,6 @@ CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n # Keyboard -CONFIG_CROS_KB_RAW_NPCX=y CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y CONFIG_SYSCON=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index ee137554cf..18ebb67471 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -62,7 +62,6 @@ CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CMD_BUTTON=y -CONFIG_CROS_KB_RAW_NPCX=y # ADC CONFIG_ADC=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf index 52d3bac798..e6063b953c 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf @@ -12,9 +12,6 @@ CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y # FAN CONFIG_TACH_NPCX=y -# Keyboard -CONFIG_CROS_KB_RAW_NPCX=y - # PWM CONFIG_PWM=y CONFIG_PWM_SHELL=n diff --git a/zephyr/program/nissa/npcx_program.conf b/zephyr/program/nissa/npcx_program.conf index 875c4bb2ef..4995f0e809 100644 --- a/zephyr/program/nissa/npcx_program.conf +++ b/zephyr/program/nissa/npcx_program.conf @@ -14,7 +14,6 @@ CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=256 CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y # Keyboard -CONFIG_CROS_KB_RAW_NPCX=y CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y # Ensure recovery key combination (esc+refresh+power) is reliable CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y diff --git a/zephyr/program/rex/prj_rex.conf b/zephyr/program/rex/prj_rex.conf index 0f204b9669..b724a881b9 100644 --- a/zephyr/program/rex/prj_rex.conf +++ b/zephyr/program/rex/prj_rex.conf @@ -4,6 +4,3 @@ # Rex reference-board-specific Kconfig settings. CONFIG_BOARD_REX=y - -# Keyboard -CONFIG_CROS_KB_RAW_NPCX=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 84a71ee5a8..60822404ce 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -61,7 +61,6 @@ CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CMD_BUTTON=y -CONFIG_CROS_KB_RAW_NPCX=y # ADC CONFIG_ADC=y -- cgit v1.2.1 From 49e7bf91d1e474d82a4918cab1da56290cb41124 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 3 Nov 2022 12:24:54 +0000 Subject: zephyr: rtc: select CROS_RTC_TYPE automatically Use DT_HAS_* config to select the correct RTC TYPE automatically. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I7895d7a1cae339f168c063e225222222ff434cbd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003278 Reviewed-by: Sam Hurst Code-Coverage: Zoss --- zephyr/drivers/cros_rtc/Kconfig | 7 ++++++- zephyr/program/herobrine/program.conf | 1 - zephyr/program/trogdor/lazor/prj.conf | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/zephyr/drivers/cros_rtc/Kconfig b/zephyr/drivers/cros_rtc/Kconfig index 2839b03c62..fb84416d70 100644 --- a/zephyr/drivers/cros_rtc/Kconfig +++ b/zephyr/drivers/cros_rtc/Kconfig @@ -6,7 +6,12 @@ if PLATFORM_EC_RTC && !ARCH_POSIX choice CROS_RTC_TYPE prompt "Select the RTC to use" - default CROS_RTC_NPCX if SOC_FAMILY_NPCX + # List standalone controllers before embedded once so that they get + # higher priority. + default CROS_RTC_NXP_PCF85063A if DT_HAS_NXP_RTC_PCF85063A_ENABLED + default CROS_RTC_RENESAS_IDT1337AG if DT_HAS_RENESAS_RTC_IDT1337AG_ENABLED + default CROS_RTC_NPCX if DT_HAS_NUVOTON_NPCX_CROS_MTC_ENABLED + default CROS_RTC_XEC if DT_HAS_MICROCHIP_XEC_CROS_RTC_ENABLED help Select the RTC used on the board. diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 18ebb67471..961a47dcb0 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -126,7 +126,6 @@ CONFIG_PLATFORM_EC_USB_PID=0x5055 # RTC CONFIG_PLATFORM_EC_RTC=y -CONFIG_CROS_RTC_NXP_PCF85063A=y CONFIG_PLATFORM_EC_HOSTCMD_RTC=y CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 60822404ce..2674945090 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -121,7 +121,6 @@ CONFIG_PLATFORM_EC_USB_PID=0x5043 # RTC CONFIG_PLATFORM_EC_RTC=y -CONFIG_CROS_RTC_NPCX=y CONFIG_PLATFORM_EC_HOSTCMD_RTC=y CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y -- cgit v1.2.1 From 0a4c660df17d5d41afe00b3e64dda9c4510c0319 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 3 Nov 2022 14:39:05 +0000 Subject: zephyr: shi: select SHI driver automatically Change SHI device driver config entries to select the right one automatically based on what's enabled in the devicetree. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I0b82a52b8da4c9b6021c5bdfbedc273454dadf37 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003279 Code-Coverage: Zoss Reviewed-by: Al Semjonovs --- zephyr/drivers/cros_shi/Kconfig | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zephyr/drivers/cros_shi/Kconfig b/zephyr/drivers/cros_shi/Kconfig index ebcd937c7d..3b93ad48ee 100644 --- a/zephyr/drivers/cros_shi/Kconfig +++ b/zephyr/drivers/cros_shi/Kconfig @@ -2,17 +2,19 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +if PLATFORM_EC_HOST_INTERFACE_SHI + config CROS_SHI_NPCX bool - depends on SOC_FAMILY_NPCX - depends on PLATFORM_EC_HOST_INTERFACE_SHI default y + depends on DT_HAS_NUVOTON_NPCX_CROS_SHI_ENABLED help This option enables Serial Host Interface driver for the NPCX family of processors. This is used for host-command communication on the platform which AP is ARM-based SoC. if CROS_SHI_NPCX + config CROS_SHI_MAX_REQUEST hex "Max data size for the version 3 request packet" default 0x220 @@ -38,9 +40,8 @@ endif # CROS_SHI_NPCX config CROS_SHI_IT8XXX2 bool - depends on SOC_FAMILY_RISCV_ITE - depends on PLATFORM_EC_HOST_INTERFACE_SHI default y + depends on DT_HAS_ITE_IT8XXX2_CROS_SHI_ENABLED help This option enables spi host interface driver which is required to communicate with the EC when the CPU is the ARM processor. @@ -58,3 +59,5 @@ config CROS_SHI_IT8XXX2_INIT_PRIORITY configuration these pins to alt function of SHI. endif # CROS_SHI_IT8XXX2 + +endif # PLATFORM_EC_HOST_INTERFACE_SHI -- cgit v1.2.1 From e615a219c1694276467dbfc5c0874ae50895ccb0 Mon Sep 17 00:00:00 2001 From: Rob Barnes Date: Tue, 8 Nov 2022 17:56:13 +0000 Subject: test/kb_scan: Add 1ms delay at the beginning of each test step There's a race condition between this test and system init. Specifically, calling weak functions during system init can cause kb_scan test to fail. I don't fully understand the source of the race condition, but adding just a 1ms delay at the beginning of each test step resolves the issue. BUG=b:258231435 BRANCH=None TEST=kb_scan and kb_scan_strict pass on host Change-Id: I624d4f62533d25fb128ab6f39408fd643c2fa869 Signed-off-by: Rob Barnes Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4012962 Code-Coverage: Zoss Reviewed-by: Jeremy Bettis --- test/kb_scan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/kb_scan.c b/test/kb_scan.c index 82693ff525..031c972d0e 100644 --- a/test/kb_scan.c +++ b/test/kb_scan.c @@ -578,6 +578,7 @@ static void run_test_step1(void) lid_open = 1; hook_notify(HOOK_LID_CHANGE); test_reset(); + msleep(1); RUN_TEST(deghost_test); @@ -606,6 +607,7 @@ static void run_test_step2(void) lid_open = 1; hook_notify(HOOK_LID_CHANGE); test_reset(); + msleep(1); RUN_TEST(test_check_boot_esc); @@ -620,6 +622,7 @@ static void run_test_step3(void) lid_open = 1; hook_notify(HOOK_LID_CHANGE); test_reset(); + msleep(1); RUN_TEST(test_check_boot_down); -- cgit v1.2.1 From 23c8f3cf3e17dafa7eaa4afc646183dca1570ee2 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 8 Nov 2022 23:37:45 +0000 Subject: Revert "cq: Run verbose make for better debugging" This reverts commit 23fd725b83abdcb50eb99f69e6a4b102489ba3f7. Reason for revert: The build output for EC is 109Mb. Too big. Original change's description: > cq: Run verbose make for better debugging > > There have been several mysterious failures in the CQ and it's hard to > see what is going on since make doesn't print the commands by default. > > BRANCH=None > BUG=b:257393779 > TEST=CQ > > Signed-off-by: Jeremy Bettis > Change-Id: I4e4db7ef328b01f52d820405db036ef881d06405 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4005654 > Commit-Queue: Jeremy Bettis > Tested-by: Jeremy Bettis > Auto-Submit: Jeremy Bettis > Reviewed-by: Al Semjonovs > Code-Coverage: Zoss > Commit-Queue: Al Semjonovs Bug: b:257393779 Change-Id: I9fbde348c12ec77b2447a264d7190c3d75423958 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4014811 Reviewed-by: Al Semjonovs Commit-Queue: Al Semjonovs Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Code-Coverage: Zoss --- firmware_builder.py | 10 +++++----- zephyr/firmware_builder.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/firmware_builder.py b/firmware_builder.py index e24d87459e..ff7f524d78 100755 --- a/firmware_builder.py +++ b/firmware_builder.py @@ -74,11 +74,11 @@ def build(opts): ec_dir = pathlib.Path(__file__).parent subprocess.run([ec_dir / "util" / "check_clang_format.py"], check=True) - cmd = ["make", "clobber", "V=1"] + cmd = ["make", "clobber"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) - cmd = ["make", "buildall_only", f"-j{opts.cpus}", "V=1"] + cmd = ["make", "buildall_only", f"-j{opts.cpus}"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) @@ -239,7 +239,7 @@ def test(opts): # Otherwise, build the 'runtests' target, which verifies all # posix-based unit tests build and pass. target = "coverage" if opts.code_coverage else "runtests" - cmd = ["make", target, f"-j{opts.cpus}", "V=1"] + cmd = ["make", target, f"-j{opts.cpus}"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) @@ -247,13 +247,13 @@ def test(opts): # Verify compilation of the on-device unit test binaries. # TODO(b/172501728) These should build for all boards, but they've bit # rotted, so we only build the ones that compile. - cmd = ["make", f"-j{opts.cpus}", "V=1"] + cmd = ["make", f"-j{opts.cpus}"] cmd.extend(["tests-" + b for b in BOARDS_UNIT_TEST]) print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) # Verify the tests pass with ASan also - cmd = ["make", "TEST_ASAN=y", target, f"-j{opts.cpus}", "V=1"] + cmd = ["make", "TEST_ASAN=y", target, f"-j{opts.cpus}"] print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index 904ff248bb..7973a9d74c 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -100,7 +100,7 @@ def build(opts): ) # Start with a clean build environment - cmd = ["make", "clobber", "V=1"] + cmd = ["make", "clobber"] log_cmd(cmd) subprocess.run(cmd, cwd=platform_ec, check=True, stdin=subprocess.DEVNULL) @@ -307,7 +307,7 @@ def test(opts): ).stdout _extract_lcov_summary("EC_ZEPHYR_TESTS_GCC", metrics, output) - cmd = ["make", "test-coverage", f"-j{opts.cpus}", "V=1"] + cmd = ["make", "test-coverage", f"-j{opts.cpus}"] log_cmd(cmd) subprocess.run( cmd, cwd=platform_ec, check=True, stdin=subprocess.DEVNULL -- cgit v1.2.1 From ebf438687ee32b81f89520fa4a6fbf9337cb84bb Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 14:43:32 -0600 Subject: zephyr: tests: Test charger.c charger_set_voltage() Test charger_set_voltage in common/charger.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: I719540c87271b57ab60a7bd87eba6671daed9c62 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000832 Commit-Queue: Aaron Massey Reviewed-by: Aaron Massey Code-Coverage: Zoss --- .../src/test_common_charger_mocked.c | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index a8b01b3c87..9df5b79dd1 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -28,6 +28,7 @@ FAKE_VALUE_FUNC(enum ec_error_list, set_otg_current_voltage, int, int, int); FAKE_VALUE_FUNC(int, is_sourcing_otg_power, int, int); FAKE_VALUE_FUNC(enum ec_error_list, get_actual_current, int, int *); FAKE_VALUE_FUNC(enum ec_error_list, get_actual_voltage, int, int *); +FAKE_VALUE_FUNC(enum ec_error_list, set_voltage, int, int); struct common_charger_mocked_driver_fixture { /* The original driver pointer that gets restored after the tests */ @@ -198,6 +199,32 @@ ZTEST_F(common_charger_mocked_driver, test_charger_get_actual_voltage) zassert_equal(2000, voltage); } +ZTEST(common_charger_mocked_driver, test_charger_set_voltage__invalid) +{ + /* charger number out of bounds */ + zassert_equal(EC_ERROR_INVAL, charger_set_voltage(-1, 0)); + zassert_equal(EC_ERROR_INVAL, charger_set_voltage(INT_MAX, 0)); +} + +ZTEST(common_charger_mocked_driver, test_charger_set_voltage__unimpl) +{ + /* set_voltage is NULL */ + zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_set_voltage(CHG_NUM, 0)); +} + +ZTEST_F(common_charger_mocked_driver, test_charger_set_voltage) +{ + fixture->mock_driver.set_voltage = set_voltage; + set_voltage_fake.return_val = 123; + + zassert_equal(set_voltage_fake.return_val, + charger_set_voltage(CHG_NUM, 2000)); + + zassert_equal(1, set_voltage_fake.call_count); + zassert_equal(CHG_NUM, set_voltage_fake.arg0_history[0]); + zassert_equal(2000, set_voltage_fake.arg1_history[0]); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -227,6 +254,7 @@ static void reset(void *data) RESET_FAKE(is_sourcing_otg_power); RESET_FAKE(get_actual_current); RESET_FAKE(get_actual_voltage); + RESET_FAKE(set_voltage); } static void teardown(void *data) -- cgit v1.2.1 From b88c21df1ce78b3ede533f0edca0523f246aaabf Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Wed, 9 Nov 2022 09:55:53 -0700 Subject: gitlab: Add instructions for adding vms to doc Document the commands needed to add a new VM to the gitlab runners. One of the VMs ran out of disk space, so add a daily cleanup cron job to delete old docker data. BRANCH=None BUG=b:244590155 TEST=Ran the crontab commands Signed-off-by: Jeremy Bettis Change-Id: I0196cad3fbe113614feea33582741a3d15f27fca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4016955 Tested-by: Jeremy Bettis Commit-Queue: Al Semjonovs Code-Coverage: Zoss Auto-Submit: Jeremy Bettis Reviewed-by: Al Semjonovs --- docs/gitlab.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/docs/gitlab.md b/docs/gitlab.md index 617c8a9154..2ebc5c60f7 100644 --- a/docs/gitlab.md +++ b/docs/gitlab.md @@ -82,3 +82,72 @@ If you used the command as shown above, all of the build artifacts and source, as checked out by the Gitlab runner, should be under `~/gitlab-runner-output`. This will persist after the container exits but also get overwritten again on the next run. + +## Gitlab runners + +The gitlab builds run on a number of [virtual and real machines](https://gitlab.com/groups/zephyr-ec/-/runners) +which are currently at Simon's house, and cloud virtual machines. + +### Create a new VM + +* Visit https://pantheon.corp.google.com/compute/instances?onCreate=true&project=chromeos-ec-gitlab + * Click on instance-1 + * Click create similar +* Wait for new instance to be created +* Click on SSH +* Install docker +``` +sudo apt-get remove docker docker-engine docker.io containerd runc +sudo apt-get update +sudo apt-get install \ + ca-certificates \ + curl \ + gnupg \ + lsb-release +sudo mkdir -p /etc/apt/keyrings +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg +echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update +sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin +sudo docker run hello-world +``` +* Install gitlab runner +``` +sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 +sudo chmod +x /usr/local/bin/gitlab-runner +sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash +sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner +sudo gitlab-runner start +``` +* Register new runner using command from https://gitlab.com/groups/zephyr-ec/-/runners (click on Register a group runner, click on show instructions, click on Linux) +``` +sudo gitlab-runner register --url https://gitlab.com/ --registration-token TOKENGOESHERE +Runtime platform arch=amd64 os=linux pid=56156 revision=bbcb5aba version=15.3.0 +Running in system-mode. + +Enter the GitLab instance URL (for example, https://gitlab.com/): +[https://gitlab.com/]: +Enter the registration token: +[TOKENGOESHERE]: +Enter a description for the runner: +[instance-2]: Cloud runner instance-2 +Enter tags for the runner (comma-separated): + +Enter optional maintenance note for the runner: + +Registering runner... succeeded runner=TOKENGOESHERE +Enter an executor: docker, parallels, shell, docker-ssh+machine, custom, docker-ssh, ssh, virtualbox, docker+machine, kubernetes: +docker +Enter the default Docker image (for example, ruby:2.7): +ruby:2.7 +Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! + +Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml" +``` + +* Install cleanup docker cleanup daily cron +``` +( echo "0 3 * * * /usr/bin/docker system prune -f -a --volumes" ; sudo crontab -l -u root ) | sudo crontab -u root - +``` -- cgit v1.2.1 From 52f16c1fa021592d92bd597d6768dbfeedb65881 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 3 Nov 2022 14:44:08 +0000 Subject: zephyr: ioex: select PLATFORM_EC_IOEX_CROS_DRV automatically Enable PLATFORM_EC_IOEX_CROS_DRV automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Ic42cdfc3ce19580219a0ac00750d237aa66a7736 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003280 Code-Coverage: Zoss Reviewed-by: Wai-Hong Tam --- zephyr/Kconfig.ioex | 3 ++- zephyr/program/intelrvp/adlrvp/prj.conf | 1 - zephyr/program/intelrvp/mtlrvp/prj.conf | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/zephyr/Kconfig.ioex b/zephyr/Kconfig.ioex index e9bb8065e1..9be34197db 100644 --- a/zephyr/Kconfig.ioex +++ b/zephyr/Kconfig.ioex @@ -4,7 +4,8 @@ menuconfig PLATFORM_EC_IOEX_CROS_DRV bool "IO expander support" - depends on I2C + default y + depends on I2C && DT_HAS_CROS_IOEX_CHIP_ENABLED help Enable support for CrOS EC ioex drivers. diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index 76ae3db975..b0b8b7ead2 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -63,7 +63,6 @@ CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y # IOEX -CONFIG_PLATFORM_EC_IOEX_CROS_DRV=y CONFIG_PLATFORM_EC_IOEX_PCA9675=y CONFIG_GPIO_PCA95XX=y diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index 71f0feae63..1dc120933e 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -31,7 +31,6 @@ CONFIG_PLATFORM_EC_CHARGER_ISL9241=y CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y # IOEX -CONFIG_PLATFORM_EC_IOEX_CROS_DRV=y CONFIG_PLATFORM_EC_IOEX_CCGXXF=y CONFIG_GPIO_PCA95XX=y CONFIG_GPIO_NCT38XX=y -- cgit v1.2.1 From f5b7387ee495845838e7eb0c839ca6668588edb8 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 3 Nov 2022 15:17:32 +0000 Subject: zephyr: gpio_id: use nodelabels, add a build option Few minor cleanups around the gpio_id.c file: - stop using DT_PATH, use a known nodelabel instead, makes it easier to define bits in dts files without relying on a known path - use an explicit Kconfig automatic option instead of always having the file in the build and macro'ing out if not needed - add a build warning if neither sku or board nodes are found, should catch misconfigured nodes at build time BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Iddaf737a2a2efd647ffd303d3f3692e90a49318b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003281 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/Kconfig | 10 ++++++++++ zephyr/program/herobrine/evoker/gpio.dtsi | 8 ++------ zephyr/program/herobrine/gpio.dtsi | 10 +++------- zephyr/program/herobrine/hoglin/gpio.dtsi | 8 ++------ zephyr/program/herobrine/villager/gpio.dtsi | 8 ++------ zephyr/program/herobrine/zombie/gpio.dtsi | 8 ++------ zephyr/program/trogdor/lazor/gpio.dts | 8 ++------ zephyr/shim/src/CMakeLists.txt | 3 ++- zephyr/shim/src/gpio_id.c | 17 ++++++++++------- zephyr/test/drivers/shim_gpio_id/gpio_id.dts | 8 ++------ 10 files changed, 37 insertions(+), 51 deletions(-) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 98f40aaa97..5e3a7d3302 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -809,4 +809,14 @@ config PLATFORM_EC_MATH_UTIL Math utilities including bitmask manipulation, division rounding, trigonometric function, etc. +config PLATFORM_EC_GPIO_ID + bool "Enable GPIO ID handling for board and sku ids" + default y + depends on DT_HAS_CROS_EC_GPIO_ID_ENABLED + help + Enable setting board and sku IDs using GPIOs. Defines the + board_get_sku_id and board_get_version functions based on the + devicetree node using the known nodelabels gpio_id_sku and + gpio_id_board. + endif # PLATFORM_EC diff --git a/zephyr/program/herobrine/evoker/gpio.dtsi b/zephyr/program/herobrine/evoker/gpio.dtsi index d60fdf93c7..bb693158fa 100644 --- a/zephyr/program/herobrine/evoker/gpio.dtsi +++ b/zephyr/program/herobrine/evoker/gpio.dtsi @@ -243,27 +243,23 @@ enable-pins = <&gpio_en_usb_a_5v>; }; - sku { + gpio_id_sku: sku { compatible = "cros-ec,gpio-id"; - bits = < &gpio_sku_id0 &gpio_sku_id1 &gpio_sku_id2 >; - system = "ternary"; }; - board { + gpio_id_board: board { compatible = "cros-ec,gpio-id"; - bits = < &gpio_brd_id0 &gpio_brd_id1 &gpio_brd_id2 >; - system = "ternary"; }; diff --git a/zephyr/program/herobrine/gpio.dtsi b/zephyr/program/herobrine/gpio.dtsi index a355aaf099..89aebe365c 100644 --- a/zephyr/program/herobrine/gpio.dtsi +++ b/zephyr/program/herobrine/gpio.dtsi @@ -243,27 +243,23 @@ enable-pins = <&gpio_en_usb_a_5v>; }; - sku { + gpio_id_sku: sku { compatible = "cros-ec,gpio-id"; - bits = < &gpio_sku_id0 &gpio_sku_id1 &gpio_sku_id2 >; - system = "ternary"; }; - board { + gpio_id_board: board { compatible = "cros-ec,gpio-id"; - bits = < &gpio_brd_id0 &gpio_brd_id1 &gpio_brd_id2 >; - system = "ternary"; }; @@ -326,4 +322,4 @@ status = "okay"; pinctrl-names = "sleep"; pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; -}; \ No newline at end of file +}; diff --git a/zephyr/program/herobrine/hoglin/gpio.dtsi b/zephyr/program/herobrine/hoglin/gpio.dtsi index cb7babc9cf..4be8af5775 100644 --- a/zephyr/program/herobrine/hoglin/gpio.dtsi +++ b/zephyr/program/herobrine/hoglin/gpio.dtsi @@ -241,27 +241,23 @@ enable-pins = <&gpio_en_usb_a_5v>; }; - sku { + gpio_id_sku: sku { compatible = "cros-ec,gpio-id"; - bits = < &gpio_sku_id0 &gpio_sku_id1 &gpio_sku_id2 >; - system = "ternary"; }; - board { + gpio_id_board: board { compatible = "cros-ec,gpio-id"; - bits = < &gpio_brd_id0 &gpio_brd_id1 &gpio_brd_id2 >; - system = "ternary"; }; diff --git a/zephyr/program/herobrine/villager/gpio.dtsi b/zephyr/program/herobrine/villager/gpio.dtsi index 1e7625ff6a..9ad9df6a0d 100644 --- a/zephyr/program/herobrine/villager/gpio.dtsi +++ b/zephyr/program/herobrine/villager/gpio.dtsi @@ -235,27 +235,23 @@ enable-pins = <&gpio_en_usb_a_5v>; }; - sku { + gpio_id_sku: sku { compatible = "cros-ec,gpio-id"; - bits = < &gpio_sku_id0 &gpio_sku_id1 &gpio_sku_id2 >; - system = "ternary"; }; - board { + gpio_id_board: board { compatible = "cros-ec,gpio-id"; - bits = < &gpio_brd_id0 &gpio_brd_id1 &gpio_brd_id2 >; - system = "ternary"; }; diff --git a/zephyr/program/herobrine/zombie/gpio.dtsi b/zephyr/program/herobrine/zombie/gpio.dtsi index 14ed1f54d6..e154d2a62a 100644 --- a/zephyr/program/herobrine/zombie/gpio.dtsi +++ b/zephyr/program/herobrine/zombie/gpio.dtsi @@ -235,27 +235,23 @@ enable-pins = <&gpio_en_usb_a_5v>; }; - sku { + gpio_id_sku: sku { compatible = "cros-ec,gpio-id"; - bits = < &gpio_sku_id0 &gpio_sku_id1 &gpio_sku_id2 >; - system = "ternary"; }; - board { + gpio_id_board: board { compatible = "cros-ec,gpio-id"; - bits = < &gpio_brd_id0 &gpio_brd_id1 &gpio_brd_id2 >; - system = "ternary"; }; diff --git a/zephyr/program/trogdor/lazor/gpio.dts b/zephyr/program/trogdor/lazor/gpio.dts index a047d7e2f2..c5d982a3cb 100644 --- a/zephyr/program/trogdor/lazor/gpio.dts +++ b/zephyr/program/trogdor/lazor/gpio.dts @@ -265,27 +265,23 @@ MKBP_EVENT_SENSOR_FIFO)>; }; - sku { + gpio_id_sku: sku { compatible = "cros-ec,gpio-id"; - bits = < &gpio_sku_id0 &gpio_sku_id1 &gpio_sku_id2 >; - system = "binary"; }; - board { + gpio_id_board: board { compatible = "cros-ec,gpio-id"; - bits = < &gpio_brd_id0 &gpio_brd_id1 &gpio_brd_id2 >; - system = "binary_first_base3"; }; diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 1ad4d6546e..c2cb0b92da 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -6,7 +6,6 @@ zephyr_library_sources(button_config.c) zephyr_library_sources(console.c) zephyr_library_sources(crc.c) zephyr_library_sources(gpio.c) -zephyr_library_sources(gpio_id.c) zephyr_library_sources(gpio_int.c) zephyr_library_sources(power.c) @@ -32,6 +31,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI espi.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN fan.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FLASH_CROS flash.c) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_GPIO_ID + gpio_id.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOOKS hooks.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD host_command.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE diff --git a/zephyr/shim/src/gpio_id.c b/zephyr/shim/src/gpio_id.c index b994154cd1..154924866d 100644 --- a/zephyr/shim/src/gpio_id.c +++ b/zephyr/shim/src/gpio_id.c @@ -11,9 +11,6 @@ #include "gpio.h" #include "util.h" -#define IS_BOARD_COMPATIBLE DT_NODE_HAS_COMPAT(DT_PATH(board), cros_ec_gpio_id) -#define IS_SKU_COMPATIBLE DT_NODE_HAS_COMPAT(DT_PATH(sku), cros_ec_gpio_id) - #define CONVERT_NUMERAL_SYSTEM_EVAL(system, bits, nbits) \ system##_from_bits(bits, nbits) #define CONVERT_NUMERAL_SYSTEM(system, bits, nbits) \ @@ -23,14 +20,15 @@ #define READ_PIN_FROM_PHANDLE(node_id, prop, idx) \ gpio_get_ternary(GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, idx))), -#if DT_NODE_EXISTS(DT_PATH(sku)) && IS_SKU_COMPATIBLE +#define SKU_GPIO_ID_NODE DT_NODELABEL(gpio_id_sku) +#if DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay) __override uint32_t board_get_sku_id(void) { static uint32_t sku_id = (uint32_t)-1; if (sku_id == (uint32_t)-1) { - int bits[] = { DT_FOREACH_PROP_ELEM(DT_PATH(sku), bits, + int bits[] = { DT_FOREACH_PROP_ELEM(SKU_GPIO_ID_NODE, bits, READ_PIN_FROM_PHANDLE) }; if (sizeof(bits) == 0) @@ -46,14 +44,15 @@ __override uint32_t board_get_sku_id(void) #endif -#if DT_NODE_EXISTS(DT_PATH(board)) && IS_BOARD_COMPATIBLE +#define BOARD_GPIO_ID_NODE DT_NODELABEL(gpio_id_board) +#if DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay) __override int board_get_version(void) { static int board_version = -1; if (board_version == -1) { - int bits[] = { DT_FOREACH_PROP_ELEM(DT_PATH(board), bits, + int bits[] = { DT_FOREACH_PROP_ELEM(BOARD_GPIO_ID_NODE, bits, READ_PIN_FROM_PHANDLE) }; if (sizeof(bits) == 0) @@ -68,3 +67,7 @@ __override int board_get_version(void) } #endif + +BUILD_ASSERT(DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay) || + DT_NODE_HAS_STATUS(BOARD_GPIO_ID_NODE, okay), + "neither sku or board id nodelabels found"); diff --git a/zephyr/test/drivers/shim_gpio_id/gpio_id.dts b/zephyr/test/drivers/shim_gpio_id/gpio_id.dts index 050272141f..cd2303cfa9 100644 --- a/zephyr/test/drivers/shim_gpio_id/gpio_id.dts +++ b/zephyr/test/drivers/shim_gpio_id/gpio_id.dts @@ -5,20 +5,16 @@ / { /* Required to compile board_get_sku_id() from shim/gpio_id.c */ - sku { + gpio_id_sku: sku { compatible = "cros-ec,gpio-id"; - bits = <&gpio_sku_id0>; - system = "ternary"; }; /* Required to compile board_get_version() from shim/gpio_id.c */ - board { + gpio_id_board: board { compatible = "cros-ec,gpio-id"; - bits = <&gpio_brd_id0>; - system = "ternary"; }; }; -- cgit v1.2.1 From 85e2dd2916894347fb627d57bd0e7c2a517d3124 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 3 Nov 2022 15:29:32 +0000 Subject: zephyr: ioex: select PLATFORM_EC_USBA automatically Enable PLATFORM_EC_USBA automatically based devicetree compatible nodes. Drop a bunch of now unnecessary config and a macro guard. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I824e7f7f01fda9145b682897d3262de221f9000a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003282 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/Kconfig.usba | 2 ++ zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/prj_it81202_base.conf | 3 --- zephyr/program/corsola/prj_npcx993_base.conf | 3 --- zephyr/program/herobrine/program.conf | 3 --- zephyr/program/nissa/program.conf | 1 - zephyr/program/rex/prj.conf | 3 --- zephyr/program/skyrim/prj.conf | 3 --- zephyr/program/trogdor/lazor/prj.conf | 3 --- zephyr/shim/src/usba.c | 4 ---- zephyr/test/drivers/testcase.yaml | 1 - 11 files changed, 2 insertions(+), 25 deletions(-) diff --git a/zephyr/Kconfig.usba b/zephyr/Kconfig.usba index 8abbe839f6..b5413d2c83 100644 --- a/zephyr/Kconfig.usba +++ b/zephyr/Kconfig.usba @@ -4,6 +4,8 @@ menuconfig PLATFORM_EC_USBA bool "USB Type-A support" + default y + depends on DT_HAS_CROS_EC_USBA_PORT_ENABLE_PINS_ENABLED help Enable USB Type A ports diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 5d80ff9b34..1678eb29d2 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -151,7 +151,6 @@ CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT=y -CONFIG_PLATFORM_EC_USBA=y CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP=n CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n diff --git a/zephyr/program/corsola/prj_it81202_base.conf b/zephyr/program/corsola/prj_it81202_base.conf index 2d4af86300..2a8b46bb28 100644 --- a/zephyr/program/corsola/prj_it81202_base.conf +++ b/zephyr/program/corsola/prj_it81202_base.conf @@ -62,9 +62,6 @@ CONFIG_TASK_CHIPSET_STACK_SIZE=1440 CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024 CONFIG_TASK_PD_STACK_SIZE=1280 -# USB-A -CONFIG_PLATFORM_EC_USBA=y - # USB-C CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y diff --git a/zephyr/program/corsola/prj_npcx993_base.conf b/zephyr/program/corsola/prj_npcx993_base.conf index 35189ea2f7..5d685679e7 100644 --- a/zephyr/program/corsola/prj_npcx993_base.conf +++ b/zephyr/program/corsola/prj_npcx993_base.conf @@ -58,9 +58,6 @@ CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y CONFIG_PLATFORM_EC_TABLET_MODE=y CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -# USBA -CONFIG_PLATFORM_EC_USBA=y - # USBC CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 961a47dcb0..5fdf9bcfec 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -90,9 +90,6 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y -# USB-A -CONFIG_PLATFORM_EC_USBA=y - # USB-C CONFIG_PLATFORM_EC_USB_PD_FRS=y CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 622d82837c..dad804a8ee 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -120,7 +120,6 @@ CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y # USB-A host ports -CONFIG_PLATFORM_EC_USBA=y CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC=y # Both ports use a smart switch with CTL1..3 fixed high, for SDP2 or CDP only: # either SLGC55545 or PI5USB2546. diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 75083dd9be..16b29fc8ca 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -96,9 +96,6 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=30000 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 -# USB-A -CONFIG_PLATFORM_EC_USBA=y - # USBC CONFIG_PLATFORM_EC_USBC_PPC=y CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index e20db16b2c..023d58e611 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -93,9 +93,6 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 -# USB-A -CONFIG_PLATFORM_EC_USBA=y - # USB-C CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 2674945090..c05717d7ad 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -89,9 +89,6 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y -# USB-A -CONFIG_PLATFORM_EC_USBA=y - # USB-C CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n diff --git a/zephyr/shim/src/usba.c b/zephyr/shim/src/usba.c index 4db8c31e6a..c8c056bad0 100644 --- a/zephyr/shim/src/usba.c +++ b/zephyr/shim/src/usba.c @@ -8,8 +8,6 @@ #include #include "hooks.h" -#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) - #define PIN(node_id, prop, idx) \ GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, idx)), @@ -23,5 +21,3 @@ const #endif int usb_port_enable[] = { DT_INST_FOREACH_STATUS_OKAY( USBA_ENABLE_PINS) }; - -#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 43387183b9..48317113c9 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -163,7 +163,6 @@ tests: extra_args: DTC_OVERLAY_FILE="./boards/native_posix.overlay;./usb_port_power_dumb/usba.dts" extra_configs: - CONFIG_LINK_TEST_SUITE_USB_PORT_POWER_DUMB=y - - CONFIG_PLATFORM_EC_USBA=y - CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y drivers.usb_pd_discharge: extra_configs: -- cgit v1.2.1 From df7862fa54ab94007110e1683351ee8d24a74f9a Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 12:33:02 +0000 Subject: zephyr: cbi_eeprom: stop silently drop the code if misconfigured Change the cbi_eeprom code to not get blanked if enabled but no eeprom device is defined, fire a build warning instead. Also make sure that the device is ready before trying to use it. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I9c3a00be98c40ea8c1be307ef02c08c856aa770f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999729 Code-Coverage: Zoss Reviewed-by: Al Semjonovs --- zephyr/shim/src/cbi/cbi_eeprom.c | 29 +++++++++++++++++----- zephyr/test/drivers/boards/native_posix.overlay | 6 ++++- .../test/drivers/common_cbi/src/test_common_cbi.c | 11 ++++++++ zephyr/test/drivers/testcase.yaml | 1 + 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/zephyr/shim/src/cbi/cbi_eeprom.c b/zephyr/shim/src/cbi/cbi_eeprom.c index ecc78ba41e..652c76f959 100644 --- a/zephyr/shim/src/cbi/cbi_eeprom.c +++ b/zephyr/shim/src/cbi/cbi_eeprom.c @@ -10,8 +10,9 @@ #include "cros_board_info.h" #include "write_protect.h" -#if DT_NODE_EXISTS(DT_NODELABEL(cbi_eeprom)) -#define CBI_EEPROM_DEV DEVICE_DT_GET(DT_NODELABEL(cbi_eeprom)) +#define CBI_EEPROM_NODE DT_NODELABEL(cbi_eeprom) + +BUILD_ASSERT(DT_NODE_EXISTS(CBI_EEPROM_NODE), "cbi_eeprom node not defined"); #ifdef CONFIG_PLATFORM_EC_EEPROM_CBI_WP #if !DT_NODE_EXISTS(DT_ALIAS(gpio_cbi_wp)) @@ -27,20 +28,37 @@ void cbi_latch_eeprom_wp(void) test_mockable_static int eeprom_load(uint8_t offset, uint8_t *data, int len) { - return eeprom_read(CBI_EEPROM_DEV, offset, data, len); + const struct device *dev; + + dev = DEVICE_DT_GET(CBI_EEPROM_NODE); + + if (!device_is_ready(dev)) { + return -ENODEV; + } + + return eeprom_read(dev, offset, data, len); } static int eeprom_is_write_protected(void) { - if (IS_ENABLED(CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK)) + if (IS_ENABLED(CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK)) { return 0; + } return write_protect_is_asserted(); } static int eeprom_store(uint8_t *cbi) { - return eeprom_write(CBI_EEPROM_DEV, 0, cbi, + const struct device *dev; + + dev = DEVICE_DT_GET(CBI_EEPROM_NODE); + + if (!device_is_ready(dev)) { + return -ENODEV; + } + + return eeprom_write(dev, 0, cbi, ((struct cbi_header *)cbi)->total_size); } @@ -54,4 +72,3 @@ const struct cbi_storage_config_t cbi_config = { .storage_type = CBI_STORAGE_TYPE_EEPROM, .drv = &eeprom_drv, }; -#endif diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index 3a0461badd..0a8547930d 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -27,6 +27,7 @@ bmi160-int = &ms_bmi160_accel; tcs3400-int = &tcs3400_clear; gpio-wp = &gpio_wp_l; + gpio-cbi-wp = &gpio_ec_cbi_wp; gpio-kbd-kso2 = &gpio_ec_kso_02_inv; }; @@ -236,6 +237,9 @@ gpio_brd_id0: brd_id0 { gpios = <&gpio1 8 GPIO_INPUT>; }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio1 9 GPIO_OUTPUT>; + }; }; gpio1: gpio@101 { @@ -248,7 +252,7 @@ low-level; gpio-controller; #gpio-cells = <2>; - ngpios = <9>; + ngpios = <10>; }; gpio-interrupts { diff --git a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c index ab29f7c2e6..fcd5624e09 100644 --- a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c +++ b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c @@ -34,6 +34,17 @@ static int __test_eeprom_load_default_impl(uint8_t offset, uint8_t *data, return ret; } +ZTEST(common_cbi, test_cbi_latch_eeprom_wp) +{ + const struct gpio_dt_spec *wp = GPIO_DT_FROM_ALIAS(gpio_cbi_wp); + + zassert_equal(gpio_emul_output_get(wp->port, wp->pin), 0); + + cbi_latch_eeprom_wp(); + + zassert_equal(gpio_emul_output_get(wp->port, wp->pin), 1); +} + ZTEST(common_cbi, test_do_cbi_read__cant_load_head) { enum cbi_data_tag arbitrary_unused_tag = CBI_TAG_SKU_ID; diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 48317113c9..f364612897 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -45,6 +45,7 @@ tests: drivers.common_cbi: extra_configs: - CONFIG_LINK_TEST_SUITE_COMMON_CBI=y + - CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y drivers.common_cbi_gpio: extra_configs: - CONFIG_LINK_TEST_SUITE_COMMON_CBI_GPIO=y -- cgit v1.2.1 From 621d0ee7ce950e99763175cca796f51df29785a6 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 3 Nov 2022 12:09:49 +0000 Subject: zephyr: shim: use a Kconfig option for building power.c Use an automatic Kconfig option to include power.c in the build, rather than including it unconditionally. Removes some precompiler guards from the source file and also move some macro that are only used in power.c out of the header file. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I021ec1384ef374f1c1dc841ea861e848ee9e65f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003277 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- zephyr/Kconfig | 8 ++++++++ zephyr/shim/include/power/power.h | 34 +++------------------------------- zephyr/shim/src/CMakeLists.txt | 3 ++- zephyr/shim/src/power.c | 26 ++++++++++++++++++++++++-- 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 5e3a7d3302..7f9dee962c 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -465,6 +465,14 @@ config PLATFORM_EC_POWER_COMMON help Compile common code for AP power state machine. +config CROS_EC_POWER_SIGNAL_LIST + bool "Define the power signal list from the devicetree" + default y + depends on $(dt_nodelabel_enabled,power_signal_list) + help + Define the global power_signal_list[] from the devicetree. Requires a + node with nodelabel power_signal_list. + config PLATFORM_EC_MKBP_EVENT bool "MKBP event" help diff --git a/zephyr/shim/include/power/power.h b/zephyr/shim/include/power/power.h index 1e780646af..a764e0c8b5 100644 --- a/zephyr/shim/include/power/power.h +++ b/zephyr/shim/include/power/power.h @@ -9,29 +9,9 @@ #include #include -#define POWER_SIGNAL_LIST_NODE DT_NODELABEL(power_signal_list) - -#define SYSTEM_DT_POWER_SIGNAL_CONFIG DT_NODE_EXISTS(POWER_SIGNAL_LIST_NODE) - -#if (SYSTEM_DT_POWER_SIGNAL_CONFIG) - -#define GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid) \ - DT_STRING_UPPER_TOKEN(DT_PROP(cid, power_gpio_pin), enum_name) -#define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \ - (DT_GPIO_FLAGS(DT_PROP(cid, power_gpio_pin), gpios) & \ - GPIO_ACTIVE_LOW ? \ - POWER_SIGNAL_ACTIVE_LOW : \ - POWER_SIGNAL_ACTIVE_HIGH) -#define GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) DT_PROP(cid, power_enum_name) +#if CONFIG_CROS_EC_POWER_SIGNAL_LIST -#define GEN_POWER_SIGNAL_STRUCT_ENTRY(cid) \ - { \ - .gpio = GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid), \ - .flags = GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid), \ - .name = GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) \ - } -#define GEN_POWER_SIGNAL_STRUCT(cid) \ - [GEN_POWER_SIGNAL_ENUM_ENTRY(cid)] = GEN_POWER_SIGNAL_STRUCT_ENTRY(cid), +#define POWER_SIGNAL_LIST_NODE DT_NODELABEL(power_signal_list) #define GEN_POWER_SIGNAL_ENUM_ENTRY(cid) \ DT_STRING_UPPER_TOKEN(cid, power_enum_name) @@ -42,13 +22,5 @@ enum power_signal { POWER_SIGNAL_COUNT }; -/* - * Verify the number of required power-signals are specified in - * the DeviceTree - */ -#define POWER_SIGNALS_REQUIRED \ - DT_PROP(POWER_SIGNAL_LIST_NODE, power_signals_required) -BUILD_ASSERT(POWER_SIGNALS_REQUIRED == POWER_SIGNAL_COUNT); - -#endif /* SYSTEM_DT_POWER_SIGNAL_CONFIG */ +#endif /* CONFIG_CROS_EC_POWER_SIGNAL_LIST */ #endif /* ZEPHYR_CHROME_POWER_POWER_H */ diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index c2cb0b92da..d5de268be5 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -7,7 +7,6 @@ zephyr_library_sources(console.c) zephyr_library_sources(crc.c) zephyr_library_sources(gpio.c) zephyr_library_sources(gpio_int.c) -zephyr_library_sources(power.c) add_subdirectory("cbi") add_subdirectory("led_driver") @@ -51,6 +50,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MKBP_EVENT mkbp_event.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MOTIONSENSE motionsense_sensors.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC panic.c) +zephyr_library_sources_ifdef(CONFIG_CROS_EC_POWER_SIGNAL_LIST + power.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_HC pwm_hc.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM pwm_led.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_RTC rtc.c) diff --git a/zephyr/shim/src/power.c b/zephyr/shim/src/power.c index 007c40ab71..51ae788d98 100644 --- a/zephyr/shim/src/power.c +++ b/zephyr/shim/src/power.c @@ -9,10 +9,32 @@ #include "power.h" #include "power/power.h" -#if (SYSTEM_DT_POWER_SIGNAL_CONFIG) +#define GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid) \ + DT_STRING_UPPER_TOKEN(DT_PROP(cid, power_gpio_pin), enum_name) +#define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \ + (DT_GPIO_FLAGS(DT_PROP(cid, power_gpio_pin), gpios) & \ + GPIO_ACTIVE_LOW ? \ + POWER_SIGNAL_ACTIVE_LOW : \ + POWER_SIGNAL_ACTIVE_HIGH) +#define GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) DT_PROP(cid, power_enum_name) + +#define GEN_POWER_SIGNAL_STRUCT_ENTRY(cid) \ + { \ + .gpio = GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid), \ + .flags = GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid), \ + .name = GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) \ + } +#define GEN_POWER_SIGNAL_STRUCT(cid) \ + [GEN_POWER_SIGNAL_ENUM_ENTRY(cid)] = GEN_POWER_SIGNAL_STRUCT_ENTRY(cid), const struct power_signal_info power_signal_list[] = { DT_FOREACH_CHILD( POWER_SIGNAL_LIST_NODE, GEN_POWER_SIGNAL_STRUCT) }; BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); -#endif /* SYSTEM_DT_POWER_SIGNAL_CONFIG */ +/* + * Verify the number of required power-signals are specified in + * the DeviceTree + */ +#define POWER_SIGNALS_REQUIRED \ + DT_PROP(POWER_SIGNAL_LIST_NODE, power_signals_required) +BUILD_ASSERT(POWER_SIGNALS_REQUIRED == POWER_SIGNAL_COUNT); -- cgit v1.2.1 From e8dbeb2cd4b075b3d26c2ea7a4f853ebee5ac093 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 11:25:34 +0000 Subject: zephyr: Kconfig: enable CONFIG_ADC automatically Enable CONFIG_ADC automatically based devicetree compatible nodes. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I6ed3e352cf442d260c55073ec5e7cb82a5b3d52d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999721 Reviewed-by: Yuval Peress Code-Coverage: Zoss --- zephyr/Kconfig.adc | 4 ++++ zephyr/boards/arm/mec1727/mec1727_defconfig | 1 - zephyr/boards/arm/npcx7/npcx7_defconfig | 1 - zephyr/boards/arm/npcx9/npcx9m3f_defconfig | 1 - zephyr/boards/arm/npcx9/npcx9m7f_defconfig | 1 - zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig | 1 - zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig | 1 - zephyr/boards/riscv/it8xxx2/it81202bx_defconfig | 1 - zephyr/boards/riscv/it8xxx2/it81302bx_defconfig | 1 - zephyr/program/corsola/prj_npcx993_base.conf | 3 --- zephyr/program/herobrine/program.conf | 1 - zephyr/program/rex/prj.conf | 3 --- zephyr/program/skyrim/prj.conf | 3 --- zephyr/program/trogdor/lazor/prj.conf | 1 - zephyr/test/drivers/prj.conf | 1 - zephyr/test/krabby/prj.conf | 2 +- zephyr/test/vboot_efs2/prj.conf | 1 - 17 files changed, 5 insertions(+), 22 deletions(-) diff --git a/zephyr/Kconfig.adc b/zephyr/Kconfig.adc index 40ec1e4e89..5efc1a9bd5 100644 --- a/zephyr/Kconfig.adc +++ b/zephyr/Kconfig.adc @@ -2,6 +2,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +config ADC + default y + depends on DT_HAS_NAMED_ADC_CHANNELS_ENABLED + # Note - CONFIG_ADC is defined in upstream Zephyr if ADC diff --git a/zephyr/boards/arm/mec1727/mec1727_defconfig b/zephyr/boards/arm/mec1727/mec1727_defconfig index e8c189750e..fa67548e06 100644 --- a/zephyr/boards/arm/mec1727/mec1727_defconfig +++ b/zephyr/boards/arm/mec1727/mec1727_defconfig @@ -13,7 +13,6 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768 CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768 # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # Serial Drivers diff --git a/zephyr/boards/arm/npcx7/npcx7_defconfig b/zephyr/boards/arm/npcx7/npcx7_defconfig index c6c8f6c3f4..c982644fa0 100644 --- a/zephyr/boards/arm/npcx7/npcx7_defconfig +++ b/zephyr/boards/arm/npcx7/npcx7_defconfig @@ -13,7 +13,6 @@ CONFIG_SERIAL=y CONFIG_UART_INTERRUPT_DRIVEN=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # Enable console diff --git a/zephyr/boards/arm/npcx9/npcx9m3f_defconfig b/zephyr/boards/arm/npcx9/npcx9m3f_defconfig index d3b4bcc3a2..8202cf3e12 100644 --- a/zephyr/boards/arm/npcx9/npcx9m3f_defconfig +++ b/zephyr/boards/arm/npcx9/npcx9m3f_defconfig @@ -10,7 +10,6 @@ CONFIG_SOC_NPCX9M3F=y CONFIG_BOARD_NPCX9=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # Serial Drivers diff --git a/zephyr/boards/arm/npcx9/npcx9m7f_defconfig b/zephyr/boards/arm/npcx9/npcx9m7f_defconfig index e742904aed..4deeccb897 100644 --- a/zephyr/boards/arm/npcx9/npcx9m7f_defconfig +++ b/zephyr/boards/arm/npcx9/npcx9m7f_defconfig @@ -10,7 +10,6 @@ CONFIG_SOC_NPCX9M7F=y CONFIG_BOARD_NPCX9=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # Serial Drivers diff --git a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig index faee09f492..b5d098fcb2 100644 --- a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig @@ -41,7 +41,6 @@ CONFIG_WATCHDOG=y CONFIG_I2C=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # PWM diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig index da75b3d113..db990a38bb 100644 --- a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig @@ -41,7 +41,6 @@ CONFIG_WATCHDOG=y CONFIG_I2C=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # PWM diff --git a/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig b/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig index a024ab5824..8831b3310d 100644 --- a/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig +++ b/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig @@ -11,7 +11,6 @@ CONFIG_SOC_IT81202_BX=y CONFIG_BOARD_IT8XXX2=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # Power Management diff --git a/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig b/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig index 2841b9663c..a989662991 100644 --- a/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig +++ b/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig @@ -11,7 +11,6 @@ CONFIG_SOC_IT81302_BX=y CONFIG_BOARD_IT8XXX2=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # Power Management diff --git a/zephyr/program/corsola/prj_npcx993_base.conf b/zephyr/program/corsola/prj_npcx993_base.conf index 5d685679e7..e144e345ed 100644 --- a/zephyr/program/corsola/prj_npcx993_base.conf +++ b/zephyr/program/corsola/prj_npcx993_base.conf @@ -12,9 +12,6 @@ CONFIG_SHELL_MINIMAL=n CONFIG_LOG=y CONFIG_LOG_MODE_MINIMAL=y -# ADC -CONFIG_ADC=y - # Charger CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 5fdf9bcfec..8ffd46d565 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -64,7 +64,6 @@ CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CMD_BUTTON=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # Battery diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 16b29fc8ca..6be79dca70 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -51,9 +51,6 @@ CONFIG_AP_PWRSEQ=y CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y CONFIG_AP_PWRSEQ_S0IX=y -# ADC -CONFIG_ADC=y - # I2C CONFIG_I2C=y CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 023d58e611..874f823010 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -27,9 +27,6 @@ CONFIG_PLATFORM_EC_PORT80=y # Power button CONFIG_PLATFORM_EC_POWER_BUTTON=y -# ADC -CONFIG_ADC=y - # I2C CONFIG_I2C=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index c05717d7ad..934be6e303 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -63,7 +63,6 @@ CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CMD_BUTTON=y # ADC -CONFIG_ADC=y CONFIG_ADC_SHELL=n # Battery diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 7492366f27..3e3f9db02c 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -57,7 +57,6 @@ CONFIG_EMUL_EEPROM_AT2X=y CONFIG_EMUL_SMART_BATTERY=y CONFIG_EMUL_BC12_DETECT_PI3USB9201=y CONFIG_EMUL_PPC_SYV682X=y -CONFIG_ADC=y CONFIG_ADC_EMUL=y CONFIG_EMUL_BMA255=y CONFIG_EMUL_BMI=y diff --git a/zephyr/test/krabby/prj.conf b/zephyr/test/krabby/prj.conf index 063904d19f..c83242059d 100644 --- a/zephyr/test/krabby/prj.conf +++ b/zephyr/test/krabby/prj.conf @@ -6,8 +6,8 @@ CONFIG_ZTEST=y CONFIG_ZTEST_ASSERT_VERBOSE=1 CONFIG_ZTEST_NEW_API=y -CONFIG_ADC=y CONFIG_ASSERT=y +CONFIG_ADC=y CONFIG_CROS_EC=y CONFIG_EMUL=y CONFIG_EMUL_RT9490=y diff --git a/zephyr/test/vboot_efs2/prj.conf b/zephyr/test/vboot_efs2/prj.conf index fd7d59caca..172f5ca886 100644 --- a/zephyr/test/vboot_efs2/prj.conf +++ b/zephyr/test/vboot_efs2/prj.conf @@ -2,7 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -CONFIG_ADC=y CONFIG_ADC_EMUL=y CONFIG_CROS_EC=y CONFIG_EMUL_CROS_FLASH=y -- cgit v1.2.1 From e25163f03927764caa20c7751964a683c597355f Mon Sep 17 00:00:00 2001 From: Diana Z Date: Wed, 9 Nov 2022 17:56:43 +0000 Subject: Revert "hibernate: Add hibernate support to ap power code" This reverts commit 16c8fce71986d50d9e10ea089d9d9352818129ad. Reason for revert: Breaks hibernation on PSL boards (undefines CONFIG_HIBERNATE, which disables hibernate in common/system.c) BUG=b:258093781 Original change's description: > hibernate: Add hibernate support to ap power code > > Add hibernate support to the AP power sequence code. > > The smart discharge system isn't supported yet. > > The system will hibernate after a delay when the AP is in G3 > and there is no external power connected. > > v2: add tests > > BUG=b:246643307 > TEST=Run on nivviks with short delay > BRANCH=none > > Signed-off-by: Andrew McRae > Cq-Depend: chromium:3985352 > Change-Id: Ib7bb62c3d650a607343a6ea243645346f4b2a797 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3983631 > Reviewed-by: Peter Marheine > Code-Coverage: Zoss Bug: b:246643307 Change-Id: Ia33273d4ebd1903b628cd163a5e3b35882badf14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4017054 Auto-Submit: Diana Z Reviewed-by: Keith Short Code-Coverage: Zoss Tested-by: Diana Z Commit-Queue: Diana Z --- power/hibernate.c | 181 ------------------------------ util/config_allowed.txt | 2 + zephyr/CMakeLists.txt | 3 - zephyr/Kconfig.system | 19 ---- zephyr/shim/include/config_chip.h | 9 -- zephyr/test/ap_power/CMakeLists.txt | 2 - zephyr/test/ap_power/include/test_mocks.h | 21 ---- zephyr/test/ap_power/prj.conf | 3 - zephyr/test/ap_power/src/board.c | 5 + zephyr/test/ap_power/src/hibdelay.c | 37 ------ zephyr/test/ap_power/src/hibernate.c | 41 ------- zephyr/test/ap_power/src/host_command.c | 28 ----- zephyr/test/ap_power/src/test_mocks.c | 30 ----- 13 files changed, 7 insertions(+), 374 deletions(-) delete mode 100644 power/hibernate.c delete mode 100644 zephyr/test/ap_power/include/test_mocks.h delete mode 100644 zephyr/test/ap_power/src/hibdelay.c delete mode 100644 zephyr/test/ap_power/src/hibernate.c delete mode 100644 zephyr/test/ap_power/src/host_command.c delete mode 100644 zephyr/test/ap_power/src/test_mocks.c diff --git a/power/hibernate.c b/power/hibernate.c deleted file mode 100644 index 322adca3ea..0000000000 --- a/power/hibernate.c +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include -#include - -#include "console.h" -#include "extpower.h" -#include "hooks.h" -#include "host_command.h" -#include "system.h" -#include "util.h" - -LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL); - -/* - * Hibernate processing. - * - * When enabled, the system will be put into an extreme low - * power state after the AP is in G3 for a configurable period of time, - * and there is no external power connected (i.e on battery). - * - * The delay has a configurable default, and may be set dynamically - * via a host command, or an EC console command. A typical delay - * may be 1 hour (3600 seconds). - * - * AP events such as AP_POWER_HARD_OFF are listened for, and - * a timer is used to detect when the AP has been off for the - * selected delay time. If the AP is started again, the timer is canceled. - * Once the timer expires, the system_hibernate() function is called, - * and this will suspend the EC until a wake signal is received. - */ -static uint32_t hibernate_delay = CONFIG_HIBERNATE_DELAY_SEC; - -/* - * Return true if conditions are right for hibernation. - */ -static inline bool ready_to_hibernate(void) -{ - return ap_power_in_or_transitioning_to_state(AP_POWER_STATE_HARD_OFF) && - !extpower_is_present(); -} - -/* - * The AP has been off for the delay period, so hibernate the system, - * if ready. Called from system work queue. - */ -static void hibernate_handler(struct k_work *unused) -{ - if (ready_to_hibernate()) { - LOG_INF("System hibernating due to %d seconds AP off", - hibernate_delay); - system_hibernate(0, 0); - } -} - -K_WORK_DEFINE(hibernate_work, hibernate_handler); - -/* - * Hibernate timer handler. - * Called when timer has expired. - * Schedule hibernate_handler to run via system work queue. - */ -static void timer_handler(struct k_timer *timer) -{ - k_work_submit(&hibernate_work); -} - -K_TIMER_DEFINE(hibernate_timer, timer_handler, NULL); - -/* - * A change has been detected in either the AP state or the - * external power supply. - */ -static void change_detected(void) -{ - if (ready_to_hibernate()) { - /* - * AP is off, and there is no external power. - * Start the timer if it is not already running. - */ - if (k_timer_remaining_get(&hibernate_timer) == 0) { - k_timer_start(&hibernate_timer, - K_SECONDS(hibernate_delay), K_NO_WAIT); - } - - } else { - /* - * AP is either on, or external power is on. - * Either way, no hibernation is done. - * Make sure the timer is not running. - */ - k_timer_stop(&hibernate_timer); - } -} - -static void ap_change(struct ap_power_ev_callback *callback, - struct ap_power_ev_data data) -{ - change_detected(); -} - -/* - * Hook to listen for external power supply changes. - */ -DECLARE_HOOK(HOOK_AC_CHANGE, change_detected, HOOK_PRIO_DEFAULT); - -/* - * EC Console command to get/set the hibernation delay - */ -static int command_hibernation_delay(int argc, const char **argv) -{ - char *e; - uint32_t remaining; - - if (argc >= 2) { - uint32_t s = strtoi(argv[1], &e, 0); - - if (*e) - return EC_ERROR_PARAM1; - - hibernate_delay = s; - } - - /* Print the current setting */ - ccprintf("Hibernation delay: %d s\n", hibernate_delay); - remaining = k_timer_remaining_get(&hibernate_timer); - if (remaining == 0) { - ccprintf("Timer not running\n"); - } else { - ccprintf("Time remaining: %d s\n", remaining / 1000); - } - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(hibdelay, command_hibernation_delay, "[sec]", - "Set the delay before going into hibernation"); -/* - * Host command to set the hibernation delay - */ -static enum ec_status -host_command_hibernation_delay(struct host_cmd_handler_args *args) -{ - const struct ec_params_hibernation_delay *p = args->params; - struct ec_response_hibernation_delay *r = args->response; - - /* Only change the hibernation delay if seconds is non-zero. */ - if (p->seconds) - hibernate_delay = p->seconds; - - r->hibernate_delay = hibernate_delay; - /* - * It makes no sense to try and set these values since - * they are only valid when the AP is in G3 (so this - * host command will never be called at that point). - */ - r->time_g3 = 0; - r->time_remaining = 0; - - args->response_size = sizeof(struct ec_response_hibernation_delay); - return EC_RES_SUCCESS; -} -DECLARE_HOST_COMMAND(EC_CMD_HIBERNATION_DELAY, host_command_hibernation_delay, - EC_VER_MASK(0)); - -static int hibernate_init(const struct device *unused) -{ - static struct ap_power_ev_callback cb; - - ap_power_ev_init_callback(&cb, ap_change, - AP_POWER_INITIALIZED | AP_POWER_HARD_OFF | - AP_POWER_STARTUP); - ap_power_ev_add_callback(&cb); - return 0; -} - -SYS_INIT(hibernate_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/util/config_allowed.txt b/util/config_allowed.txt index bdf8e0eca8..66109880ed 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -455,8 +455,10 @@ CONFIG_H2RAM_BASE CONFIG_H2RAM_HOST_LPC_IO_BASE CONFIG_H2RAM_SIZE CONFIG_HAS_TASK_PD_INT +CONFIG_HIBERNATE CONFIG_HIBERNATE_BATT_PCT CONFIG_HIBERNATE_BATT_SEC +CONFIG_HIBERNATE_DELAY_SEC CONFIG_HIBERNATE_PSL_COMPENSATE_RTC CONFIG_HIBERNATE_PSL_OUT_FLAGS CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index ec88fa7e43..65f5c5b92d 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -361,9 +361,6 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_SC7180 "${PLATFORM_EC}/power/qcom.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_SC7280 "${PLATFORM_EC}/power/qcom.c") -if (CONFIG_PLATFORM_EC_HIBERNATE AND CONFIG_AP_PWRSEQ) - zephyr_library_sources( "${PLATFORM_EC}/power/hibernate.c") -endif () zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC "${PLATFORM_EC}/common/panic_output.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SHA256_SW diff --git a/zephyr/Kconfig.system b/zephyr/Kconfig.system index ffba537558..5467bc7422 100644 --- a/zephyr/Kconfig.system +++ b/zephyr/Kconfig.system @@ -28,25 +28,6 @@ config PLATFORM_EC_HIBERNATE_PSL rail for ultra-low power consumption and uses PSL inputs rely on VSBY power rail to wake up ec and the whole system. -config PLATFORM_EC_HIBERNATE - bool "System hibernating with wake-source pins" - default y - depends on !PLATFORM_EC_HIBERNATE_PSL - help - Use wake source pins for hibernating. It turns off VCC power - rail for ultra-low power consumption and uses a low power - power rail. Changes on wake source pins will wake up the EC. - By default this is enabled if PLATFORM_EC_HIBERNATE_PSL is not - enabled. - -config PLATFORM_EC_HIBERNATE_DELAY_SEC - int "Delay in seconds from AP power off to hibernate" - depends on PLATFORM_EC_HIBERNATE - default 3600 - help - This value is the delay in seconds from when the AP enters G3 - to when the system is hibernated. - config PLATFORM_EC_SYSTEM_PRE_INIT_PRIORITY int "System pre-initialization priority" default 20 diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 3ecfd5baf7..d2b5bbf577 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -2434,15 +2434,6 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #define CONFIG_HIBERNATE_PSL #endif -#undef CONFIG_HIBERNATE -#ifdef CONFIG_PLATFORM_EC_HIBERNATE -#define CONFIG_HIBERNATE -#ifdef CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC -#undef CONFIG_HIBERNATE_DELAY_SEC -#define CONFIG_HIBERNATE_DELAY_SEC CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC -#endif -#endif - #undef CONFIG_BATTERY_DEVICE_CHEMISTRY #ifdef CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY #define CONFIG_BATTERY_DEVICE_CHEMISTRY \ diff --git a/zephyr/test/ap_power/CMakeLists.txt b/zephyr/test/ap_power/CMakeLists.txt index 4669dac07e..7b44013961 100644 --- a/zephyr/test/ap_power/CMakeLists.txt +++ b/zephyr/test/ap_power/CMakeLists.txt @@ -6,8 +6,6 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(ap_power) -add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) - # Include the local test directory for shimmed_test_tasks.h zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") diff --git a/zephyr/test/ap_power/include/test_mocks.h b/zephyr/test/ap_power/include/test_mocks.h deleted file mode 100644 index 8e9c80ad43..0000000000 --- a/zephyr/test/ap_power/include/test_mocks.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __TEST_AP_POWER_TEST_MOCKS_H -#define __TEST_AP_POWER_TEST_MOCKS_H - -#include - -/* - * Mock declarations - */ - -/* Mocks for common/extpower_gpio.c */ -DECLARE_FAKE_VALUE_FUNC(int, extpower_is_present); - -/* Mocks for common/system.c */ -DECLARE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); - -#endif /* __TEST_AP_POWER_TEST_MOCKS_H */ diff --git a/zephyr/test/ap_power/prj.conf b/zephyr/test/ap_power/prj.conf index 122b84e877..c72eace288 100644 --- a/zephyr/test/ap_power/prj.conf +++ b/zephyr/test/ap_power/prj.conf @@ -52,9 +52,6 @@ CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y CONFIG_PLATFORM_EC_HOSTCMD=y CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y -# Short delay for hibernate -CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC=20 - # These items are not required. CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_SWITCH=n diff --git a/zephyr/test/ap_power/src/board.c b/zephyr/test/ap_power/src/board.c index bada154bb3..294cb942c9 100644 --- a/zephyr/test/ap_power/src/board.c +++ b/zephyr/test/ap_power/src/board.c @@ -102,3 +102,8 @@ bool board_ap_power_check_power_rails_enabled(void) { return true; } + +int extpower_is_present(void) +{ + return 0; +} diff --git a/zephyr/test/ap_power/src/hibdelay.c b/zephyr/test/ap_power/src/hibdelay.c deleted file mode 100644 index 02442adec8..0000000000 --- a/zephyr/test/ap_power/src/hibdelay.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "console.h" -#include "ec_commands.h" -#include "test_state.h" - -ZTEST_SUITE(console_cmd_hibdelay, ap_power_predicate_post_main, NULL, NULL, - NULL, NULL); - -ZTEST_USER(console_cmd_hibdelay, test_too_many_args) -{ - zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay 1 2"), NULL); -} - -ZTEST_USER(console_cmd_hibdelay, test_no_args) -{ - zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay"), NULL); -} - -ZTEST_USER(console_cmd_hibdelay, test_invalid_arg) -{ - int rv = shell_execute_cmd(get_ec_shell(), "hibdelay 3.4"); - - zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d", - EC_ERROR_PARAM1, rv); -} - -ZTEST_USER(console_cmd_hibdelay, test_valid_args) -{ - zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay 5"), NULL); -} diff --git a/zephyr/test/ap_power/src/hibernate.c b/zephyr/test/ap_power/src/hibernate.c deleted file mode 100644 index 2309508f4b..0000000000 --- a/zephyr/test/ap_power/src/hibernate.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include -#include -#include - -#include -#include -#include - -#include "hooks.h" - -#include "test_mocks.h" -#include "test_state.h" - -ZTEST(hibernate, test_g3_hibernate) -{ - extpower_is_present_fake.return_val = 0; - ap_power_ev_send_callbacks(AP_POWER_HARD_OFF); - k_sleep(K_SECONDS(30)); - zassert_equal(1, system_hibernate_fake.call_count); -} - -ZTEST(hibernate, test_ac_changed) -{ - extpower_is_present_fake.return_val = 1; - hook_notify(HOOK_AC_CHANGE); - k_sleep(K_SECONDS(30)); - zassert_equal(0, system_hibernate_fake.call_count); - extpower_is_present_fake.return_val = 0; - hook_notify(HOOK_AC_CHANGE); - k_sleep(K_SECONDS(30)); - zassert_equal(1, system_hibernate_fake.call_count); -} - -ZTEST_SUITE(hibernate, ap_power_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/ap_power/src/host_command.c b/zephyr/test/ap_power/src/host_command.c deleted file mode 100644 index 4367f8fa44..0000000000 --- a/zephyr/test/ap_power/src/host_command.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "ec_commands.h" -#include "host_command.h" -#include "test_state.h" - -ZTEST(host_cmd, test_hibernate_get) -{ - struct ec_response_hibernation_delay response; - struct ec_params_hibernation_delay params = { - .seconds = 0, - }; - - struct host_cmd_handler_args args = BUILD_HOST_COMMAND( - EC_CMD_HIBERNATION_DELAY, 0, response, params); - - zassert_ok(host_command_process(&args)); - params.seconds = 123; - zassert_ok(host_command_process(&args)); - zassert_equal(123, response.hibernate_delay, NULL); -} - -ZTEST_SUITE(host_cmd, ap_power_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/ap_power/src/test_mocks.c b/zephyr/test/ap_power/src/test_mocks.c deleted file mode 100644 index 5dae36a6ab..0000000000 --- a/zephyr/test/ap_power/src/test_mocks.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include - -#include "test_mocks.h" - -/* Mocks for common/extpower_gpio.c */ -DEFINE_FAKE_VALUE_FUNC(int, extpower_is_present); - -/* Mocks for common/system.c */ -DEFINE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); - -/** - * @brief Reset all the fakes before each test. - */ -static void fff_reset_rule_before(const struct ztest_unit_test *test, - void *data) -{ - ARG_UNUSED(test); - ARG_UNUSED(data); - - RESET_FAKE(extpower_is_present); - RESET_FAKE(system_hibernate); -} - -ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); -- cgit v1.2.1 From d134c157a5bfd00fd7e907c9477d094ed93f2d97 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Wed, 9 Nov 2022 11:13:23 -0700 Subject: test: add wp interrupt alias Add the wp interrupt alias to DT. Additional tests will be added later. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I552ac33eda5917ab9d7af0d6a460b0b2ae2b1398 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4018172 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- zephyr/test/drivers/boards/native_posix.overlay | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index 0a8547930d..56f857f17e 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -29,6 +29,7 @@ gpio-wp = &gpio_wp_l; gpio-cbi-wp = &gpio_ec_cbi_wp; gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + int-wp = &int_wp_l; }; ec-console { @@ -308,6 +309,11 @@ flags = ; handler = "power_button_interrupt"; }; + int_wp_l: wp_l { + irq-pin = <&gpio_wp_l>; + flags = ; + handler = "switch_interrupt"; + }; }; named-i2c-ports { -- cgit v1.2.1 From 80f11e66bba16a5b2a0d7838b399f5cbee5fc68c Mon Sep 17 00:00:00 2001 From: Jason Yuan Date: Tue, 8 Nov 2022 14:00:19 -0800 Subject: zephyr: Devicetree organization - herobrine Organized herobrine devicetrees and merged into program directory. Small devicetree changes are made in the overlay file. LED pins, LED policy, GPIO, and motion sense are kept as separate .dtsi files in the project directory. BUG=b:254097836 TEST=Ran zmake compare-builds BRANCH=none Change-Id: Ie9bfeb2a19365c8067e715cb1c5c0e3679e4ea8f Signed-off-by: Jason Yuan Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4014808 Tested-by: zhi cheng yuan Reviewed-by: Keith Short Code-Coverage: Zoss Commit-Queue: zhi cheng yuan Reviewed-by: Wai-Hong Tam --- zephyr/program/herobrine/evoker/battery.dtsi | 15 ------- zephyr/program/herobrine/evoker/i2c.dtsi | 46 --------------------- zephyr/program/herobrine/evoker/project.overlay | 36 ++++++++++++++-- zephyr/program/herobrine/evoker/usbc.dtsi | 42 ------------------- zephyr/program/herobrine/herobrine/battery.dtsi | 12 ------ zephyr/program/herobrine/herobrine/i2c.dtsi | 39 ------------------ zephyr/program/herobrine/herobrine/project.overlay | 48 ++++++++++++++++++++-- zephyr/program/herobrine/herobrine/usbc.dtsi | 43 ------------------- zephyr/program/herobrine/hoglin/battery.dtsi | 12 ------ zephyr/program/herobrine/hoglin/i2c.dtsi | 34 --------------- zephyr/program/herobrine/hoglin/project.overlay | 41 ++++++++++++++++-- zephyr/program/herobrine/hoglin/switchcap.dtsi | 12 ------ zephyr/program/herobrine/hoglin/usbc.dtsi | 42 ------------------- zephyr/program/herobrine/i2c.dtsi | 24 +++++++++++ zephyr/program/herobrine/usbc.dtsi | 42 +++++++++++++++++++ zephyr/program/herobrine/villager/battery.dtsi | 15 ------- zephyr/program/herobrine/villager/i2c.dtsi | 34 --------------- zephyr/program/herobrine/villager/project.overlay | 18 ++++++-- zephyr/program/herobrine/villager/usbc.dtsi | 42 ------------------- zephyr/program/herobrine/zoglin/project.overlay | 17 +------- zephyr/program/herobrine/zombie/battery.dtsi | 15 ------- zephyr/program/herobrine/zombie/i2c.dtsi | 34 --------------- zephyr/program/herobrine/zombie/project.overlay | 18 ++++++-- zephyr/program/herobrine/zombie/usbc.dtsi | 42 ------------------- 24 files changed, 212 insertions(+), 511 deletions(-) delete mode 100644 zephyr/program/herobrine/evoker/battery.dtsi delete mode 100644 zephyr/program/herobrine/evoker/i2c.dtsi delete mode 100644 zephyr/program/herobrine/evoker/usbc.dtsi delete mode 100644 zephyr/program/herobrine/herobrine/battery.dtsi delete mode 100644 zephyr/program/herobrine/herobrine/i2c.dtsi delete mode 100644 zephyr/program/herobrine/herobrine/usbc.dtsi delete mode 100644 zephyr/program/herobrine/hoglin/battery.dtsi delete mode 100644 zephyr/program/herobrine/hoglin/i2c.dtsi delete mode 100644 zephyr/program/herobrine/hoglin/switchcap.dtsi delete mode 100644 zephyr/program/herobrine/hoglin/usbc.dtsi create mode 100644 zephyr/program/herobrine/usbc.dtsi delete mode 100644 zephyr/program/herobrine/villager/battery.dtsi delete mode 100644 zephyr/program/herobrine/villager/i2c.dtsi delete mode 100644 zephyr/program/herobrine/villager/usbc.dtsi delete mode 100644 zephyr/program/herobrine/zombie/battery.dtsi delete mode 100644 zephyr/program/herobrine/zombie/i2c.dtsi delete mode 100644 zephyr/program/herobrine/zombie/usbc.dtsi diff --git a/zephyr/program/herobrine/evoker/battery.dtsi b/zephyr/program/herobrine/evoker/battery.dtsi deleted file mode 100644 index 0e09616c1d..0000000000 --- a/zephyr/program/herobrine/evoker/battery.dtsi +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: pc_vp_bp153 { - compatible = "smp,pc-vp-bp153", "battery-smart"; - }; - ap16l5j { - compatible = "panasonic,ap16l5j", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/herobrine/evoker/i2c.dtsi b/zephyr/program/herobrine/evoker/i2c.dtsi deleted file mode 100644 index 6de6863f60..0000000000 --- a/zephyr/program/herobrine/evoker/i2c.dtsi +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - ppc_port0_alt: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - ppc_port1_alt: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/program/herobrine/evoker/project.overlay b/zephyr/program/herobrine/evoker/project.overlay index 5731bf3312..04f6b2443d 100644 --- a/zephyr/program/herobrine/evoker/project.overlay +++ b/zephyr/program/herobrine/evoker/project.overlay @@ -6,17 +6,47 @@ /* Herobrine program common DTS includes */ #include "../adc.dtsi" #include "../common.dtsi" +#include "../i2c.dtsi" #include "../interrupts.dtsi" #include "../keyboard.dtsi" #include "../default_gpio_pinctrl.dtsi" #include "../display.dtsi" #include "../switchcap.dtsi" +#include "../usbc.dtsi" /* Evoker project DTS includes*/ -#include "battery.dtsi" #include "gpio.dtsi" -#include "i2c.dtsi" #include "led_pins.dtsi" #include "led_policy.dtsi" #include "motionsense.dtsi" -#include "usbc.dtsi" + +/* evoker overrides follow... */ +/* battery overrides */ +/ { + batteries { + default_battery: pc_vp_bp153 { + compatible = "smp,pc-vp-bp153", "battery-smart"; + }; + ap16l5j { + compatible = "panasonic,ap16l5j", "battery-smart"; + }; + }; + +}; + +/* i2c overrides */ +&i2c1_0 { + ppc_port0_alt: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; +}; + +&i2c2_0 { + ppc_port1_alt: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; +}; diff --git a/zephyr/program/herobrine/evoker/usbc.dtsi b/zephyr/program/herobrine/evoker/usbc.dtsi deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/program/herobrine/evoker/usbc.dtsi +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/program/herobrine/herobrine/battery.dtsi b/zephyr/program/herobrine/herobrine/battery.dtsi deleted file mode 100644 index b347ec4c3c..0000000000 --- a/zephyr/program/herobrine/herobrine/battery.dtsi +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap16l5j { - compatible = "panasonic,ap16l5j", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/herobrine/herobrine/i2c.dtsi b/zephyr/program/herobrine/herobrine/i2c.dtsi deleted file mode 100644 index 6f2d89aa71..0000000000 --- a/zephyr/program/herobrine/herobrine/i2c.dtsi +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - ppc_port0_alt: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: sn5s330@40 { - compatible = "ti,sn5s330"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/program/herobrine/herobrine/project.overlay b/zephyr/program/herobrine/herobrine/project.overlay index a74db66815..6ee53f67f0 100644 --- a/zephyr/program/herobrine/herobrine/project.overlay +++ b/zephyr/program/herobrine/herobrine/project.overlay @@ -6,6 +6,7 @@ /* Herobrine program common DTS includes */ #include "../adc.dtsi" #include "../common.dtsi" +#include "../i2c.dtsi" #include "../interrupts.dtsi" #include "../keyboard.dtsi" #include "../default_gpio_pinctrl.dtsi" @@ -13,10 +14,51 @@ #include "../gpio.dtsi" #include "../motionsense.dtsi" #include "../switchcap.dtsi" +#include "../usbc.dtsi" /* Herobrine project DTS includes*/ -#include "battery.dtsi" -#include "i2c.dtsi" #include "led_pins.dtsi" #include "led_policy.dtsi" -#include "usbc.dtsi" + +/* herobrine overrides follow... */ +/* battery overrides */ +/ { + batteries { + default_battery: ap16l5j { + compatible = "panasonic,ap16l5j", "battery-smart"; + }; + }; +}; + +/* i2c overrides */ +&i2c1_0 { + + /delete-node/ syv682x@41; + ppc_port0: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; + + ppc_port0_alt: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; +}; + +&i2c2_0 { + + /delete-node/ syv682x@41; + ppc_port1: sn5s330@40 { + compatible = "ti,sn5s330"; + status = "okay"; + reg = <0x40>; + }; +}; + +/* usbc overrides */ +&port0 { + ppc_alt = <&ppc_port0_alt>; +}; diff --git a/zephyr/program/herobrine/herobrine/usbc.dtsi b/zephyr/program/herobrine/herobrine/usbc.dtsi deleted file mode 100644 index 675286ecd7..0000000000 --- a/zephyr/program/herobrine/herobrine/usbc.dtsi +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - ppc_alt = <&ppc_port0_alt>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/program/herobrine/hoglin/battery.dtsi b/zephyr/program/herobrine/hoglin/battery.dtsi deleted file mode 100644 index 11180c3988..0000000000 --- a/zephyr/program/herobrine/hoglin/battery.dtsi +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: 7c01 { - compatible = "ganfeng,7c01", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/herobrine/hoglin/i2c.dtsi b/zephyr/program/herobrine/hoglin/i2c.dtsi deleted file mode 100644 index ca2529cbaa..0000000000 --- a/zephyr/program/herobrine/hoglin/i2c.dtsi +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@1b { - compatible = "parade,ps8xxx"; - reg = <0x1b>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@1b { - compatible = "parade,ps8xxx"; - reg = <0x1b>; - }; -}; diff --git a/zephyr/program/herobrine/hoglin/project.overlay b/zephyr/program/herobrine/hoglin/project.overlay index d68a5a80d1..e37a325654 100644 --- a/zephyr/program/herobrine/hoglin/project.overlay +++ b/zephyr/program/herobrine/hoglin/project.overlay @@ -6,16 +6,49 @@ /* Herobrine program common DTS includes */ #include "../adc.dtsi" #include "../common.dtsi" +#include "../i2c.dtsi" #include "../interrupts.dtsi" #include "../keyboard.dtsi" #include "../default_gpio_pinctrl.dtsi" +#include "../usbc.dtsi" +#include "../switchcap.dtsi" /* Hoglin project DTS includes*/ -#include "battery.dtsi" #include "gpio.dtsi" -#include "i2c.dtsi" #include "led_pins.dtsi" #include "led_policy.dtsi" #include "motionsense.dtsi" -#include "switchcap.dtsi" -#include "usbc.dtsi" + +/* hoglin overrides follow... */ +/* battery overrides */ +/ { + batteries { + default_battery: 7c01 { + compatible = "ganfeng,7c01", "battery-smart"; + }; + }; + +}; + +/* switchcap overrides */ +&{/switchcap} { + /delete-property/ power-good-pin; + poff-delay-ms = <550>; +}; + +/* i2c overrides */ +&i2c1_0 { + /delete-node/ ps8xxx@b; + tcpc_port0: ps8xxx@1b { + compatible = "parade,ps8xxx"; + reg = <0x1b>; + }; +}; + +&i2c2_0 { + /delete-node/ ps8xxx@b; + tcpc_port1: ps8xxx@1b { + compatible = "parade,ps8xxx"; + reg = <0x1b>; + }; +}; diff --git a/zephyr/program/herobrine/hoglin/switchcap.dtsi b/zephyr/program/herobrine/hoglin/switchcap.dtsi deleted file mode 100644 index 7c083667a1..0000000000 --- a/zephyr/program/herobrine/hoglin/switchcap.dtsi +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - switchcap { - compatible = "switchcap-gpio"; - enable-pin = <&gpio_switchcap_on>; - poff-delay-ms = <550>; - }; -}; diff --git a/zephyr/program/herobrine/hoglin/usbc.dtsi b/zephyr/program/herobrine/hoglin/usbc.dtsi deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/program/herobrine/hoglin/usbc.dtsi +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/program/herobrine/i2c.dtsi b/zephyr/program/herobrine/i2c.dtsi index b1ed0242c0..58c3f8d014 100644 --- a/zephyr/program/herobrine/i2c.dtsi +++ b/zephyr/program/herobrine/i2c.dtsi @@ -84,6 +84,18 @@ clock-frequency = ; pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; pinctrl-names = "default"; + + ppc_port0: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c0_frs_en>; + }; + + tcpc_port0: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; }; &i2c_ctrl1 { @@ -96,6 +108,18 @@ clock-frequency = ; pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; pinctrl-names = "default"; + + ppc_port1: syv682x@41 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x41>; + frs_en_gpio = <&gpio_usb_c1_frs_en>; + }; + + tcpc_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + }; }; &i2c_ctrl2 { diff --git a/zephyr/program/herobrine/usbc.dtsi b/zephyr/program/herobrine/usbc.dtsi new file mode 100644 index 0000000000..bed94800dd --- /dev/null +++ b/zephyr/program/herobrine/usbc.dtsi @@ -0,0 +1,42 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0: port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_0>; + }; + }; + usb_mux_0: usb-mux-0 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + + port1: port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&tcpc_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_mux_1>; + }; + }; + usb_mux_1: usb-mux-1 { + compatible = "parade,usbc-mux-ps8xxx"; + }; + }; +}; diff --git a/zephyr/program/herobrine/villager/battery.dtsi b/zephyr/program/herobrine/villager/battery.dtsi deleted file mode 100644 index dafd473a6e..0000000000 --- a/zephyr/program/herobrine/villager/battery.dtsi +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap19a5k { - compatible = "panasonic,ap19a5k", "battery-smart"; - }; - ap19a8k { - compatible = "lgc,ap19a8k", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/herobrine/villager/i2c.dtsi b/zephyr/program/herobrine/villager/i2c.dtsi deleted file mode 100644 index 02d1729dd1..0000000000 --- a/zephyr/program/herobrine/villager/i2c.dtsi +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/program/herobrine/villager/project.overlay b/zephyr/program/herobrine/villager/project.overlay index a18d6416dd..5f968e4e9b 100644 --- a/zephyr/program/herobrine/villager/project.overlay +++ b/zephyr/program/herobrine/villager/project.overlay @@ -6,16 +6,28 @@ /* Herobrine program common DTS includes */ #include "../adc.dtsi" #include "../common.dtsi" +#include "../i2c.dtsi" #include "../interrupts.dtsi" #include "../keyboard.dtsi" #include "../default_gpio_pinctrl.dtsi" #include "../switchcap.dtsi" +#include "../usbc.dtsi" /* Villager project DTS includes*/ -#include "battery.dtsi" #include "gpio.dtsi" -#include "i2c.dtsi" #include "led_pins.dtsi" #include "led_policy.dtsi" #include "motionsense.dtsi" -#include "usbc.dtsi" + +/* villager overrides follow... */ +/* battery overrides */ +/ { + batteries { + default_battery: ap19a5k { + compatible = "panasonic,ap19a5k", "battery-smart"; + }; + ap19a8k { + compatible = "lgc,ap19a8k", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/herobrine/villager/usbc.dtsi b/zephyr/program/herobrine/villager/usbc.dtsi deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/program/herobrine/villager/usbc.dtsi +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; diff --git a/zephyr/program/herobrine/zoglin/project.overlay b/zephyr/program/herobrine/zoglin/project.overlay index 55f7dd73fc..b631d4b490 100644 --- a/zephyr/program/herobrine/zoglin/project.overlay +++ b/zephyr/program/herobrine/zoglin/project.overlay @@ -3,19 +3,4 @@ * found in the LICENSE file. */ -/* Herobrine program common DTS includes */ -#include "../adc.dtsi" -#include "../common.dtsi" -#include "../interrupts.dtsi" -#include "../keyboard.dtsi" -#include "../default_gpio_pinctrl.dtsi" - -/* Zoglin project DTS includes*/ -#include "../hoglin/battery.dtsi" -#include "../hoglin/gpio.dtsi" -#include "../hoglin/i2c.dtsi" -#include "../hoglin/led_pins.dtsi" -#include "../hoglin/led_policy.dtsi" -#include "../hoglin/motionsense.dtsi" -#include "../hoglin/switchcap.dtsi" -#include "../hoglin/usbc.dtsi" +#include "../hoglin/project.overlay" diff --git a/zephyr/program/herobrine/zombie/battery.dtsi b/zephyr/program/herobrine/zombie/battery.dtsi deleted file mode 100644 index dafd473a6e..0000000000 --- a/zephyr/program/herobrine/zombie/battery.dtsi +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: ap19a5k { - compatible = "panasonic,ap19a5k", "battery-smart"; - }; - ap19a8k { - compatible = "lgc,ap19a8k", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/herobrine/zombie/i2c.dtsi b/zephyr/program/herobrine/zombie/i2c.dtsi deleted file mode 100644 index 02d1729dd1..0000000000 --- a/zephyr/program/herobrine/zombie/i2c.dtsi +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "../i2c.dtsi" - -&i2c1_0 { - ppc_port0: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c0_frs_en>; - }; - - tcpc_port0: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; - -&i2c2_0 { - ppc_port1: syv682x@41 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x41>; - frs_en_gpio = <&gpio_usb_c1_frs_en>; - }; - - tcpc_port1: ps8xxx@b { - compatible = "parade,ps8xxx"; - reg = <0xb>; - }; -}; diff --git a/zephyr/program/herobrine/zombie/project.overlay b/zephyr/program/herobrine/zombie/project.overlay index 7b44350e5a..a1a3113132 100644 --- a/zephyr/program/herobrine/zombie/project.overlay +++ b/zephyr/program/herobrine/zombie/project.overlay @@ -6,16 +6,28 @@ /* Herobrine program common DTS includes */ #include "../adc.dtsi" #include "../common.dtsi" +#include "../i2c.dtsi" #include "../interrupts.dtsi" #include "../keyboard.dtsi" #include "../default_gpio_pinctrl.dtsi" #include "../switchcap.dtsi" +#include "../usbc.dtsi" /* Zombie project DTS includes*/ -#include "battery.dtsi" #include "gpio.dtsi" -#include "i2c.dtsi" #include "led_pins.dtsi" #include "led_policy.dtsi" #include "motionsense.dtsi" -#include "usbc.dtsi" + +/* zombie overrides follow... */ +/* battery overrides */ +/ { + batteries { + default_battery: ap19a5k { + compatible = "panasonic,ap19a5k", "battery-smart"; + }; + ap19a8k { + compatible = "lgc,ap19a8k", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/herobrine/zombie/usbc.dtsi b/zephyr/program/herobrine/zombie/usbc.dtsi deleted file mode 100644 index 20bd48382f..0000000000 --- a/zephyr/program/herobrine/zombie/usbc.dtsi +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_0>; - }; - }; - usb_mux_0: usb-mux-0 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&tcpc_port1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&usb_mux_1>; - }; - }; - usb_mux_1: usb-mux-1 { - compatible = "parade,usbc-mux-ps8xxx"; - }; - }; -}; -- cgit v1.2.1 From eecd4959ca079103f76fca139626c071679a210b Mon Sep 17 00:00:00 2001 From: Liam Flaherty Date: Wed, 9 Nov 2022 15:23:06 +1100 Subject: dibbi: Remove select unused features from waddledee fork Remove: * Sensors * USB C1 * Inbuilt keyboard/keyboard backlight * Screen backlight * Volume buttons * Lid switch * Pen detection BUG=b:257370402 BRANCH=dedede TEST=make -j BOARD=dibbi Signed-off-by: Liam Flaherty Change-Id: I7116c450f71fde7f0b7d4db31d9e770f638b1af9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4015962 Reviewed-by: Sam McNally Code-Coverage: Zoss Reviewed-by: Adam Mills --- board/dibbi/board.c | 273 +++----------------------------------------- board/dibbi/board.h | 92 +++++++-------- board/dibbi/build.mk | 2 +- board/dibbi/cbi_ssfc.c | 36 ------ board/dibbi/cbi_ssfc.h | 59 ---------- board/dibbi/ec.tasklist | 15 +-- board/dibbi/gpio.inc | 25 ++-- board/dibbi/usb_pd_policy.c | 4 +- 8 files changed, 83 insertions(+), 423 deletions(-) delete mode 100644 board/dibbi/cbi_ssfc.c delete mode 100644 board/dibbi/cbi_ssfc.h diff --git a/board/dibbi/board.c b/board/dibbi/board.c index a07f2ff1ee..467e238d8a 100644 --- a/board/dibbi/board.c +++ b/board/dibbi/board.c @@ -14,16 +14,12 @@ #include "driver/accelgyro_lsm6dsm.h" #include "driver/bc12/pi3usb9201.h" #include "driver/charger/sm5803.h" -#include "driver/retimer/tusb544.h" #include "driver/temp_sensor/thermistor.h" -#include "driver/tcpm/anx7447.h" #include "driver/tcpm/it83xx_pd.h" #include "driver/usb_mux/it5205.h" #include "gpio.h" #include "hooks.h" #include "intc.h" -#include "keyboard_scan.h" -#include "lid_switch.h" #include "power.h" #include "power_button.h" #include "pwm.h" @@ -44,8 +40,7 @@ #define INT_RECHECK_US 5000 -/* C1 interrupt line swapped between board versions, track it in a variable */ -static enum gpio_signal c1_int_line; +/* TODO(b/257377326) remove SM5803 references */ /* C0 interrupt line shared by BC 1.2 and charger */ static void check_c0_line(void); @@ -81,41 +76,6 @@ static void usb_c0_interrupt(enum gpio_signal s) hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); } -/* C1 interrupt line shared by BC 1.2, TCPC, and charger */ -static void check_c1_line(void); -DECLARE_DEFERRED(check_c1_line); - -static void notify_c1_chips(void) -{ - schedule_deferred_pd_interrupt(1); - usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); - sm5803_interrupt(1); -} - -static void check_c1_line(void) -{ - /* - * If line is still being held low, see if there's more to process from - * one of the chips. - */ - if (!gpio_get_level(c1_int_line)) { - notify_c1_chips(); - hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); - } -} - -static void usb_c1_interrupt(enum gpio_signal s) -{ - /* Cancel any previous calls to check the interrupt line */ - hook_call_deferred(&check_c1_line_data, -1); - - /* Notify all chips using this line that an interrupt came in */ - notify_c1_chips(); - - /* Check the line again in 5ms */ - hook_call_deferred(&check_c1_line_data, INT_RECHECK_US); -} - static void c0_ccsbu_ovp_interrupt(enum gpio_signal s) { cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event"); @@ -157,25 +117,16 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, .flags = PI3USB9201_ALWAYS_POWERED, }, - { - .i2c_port = I2C_PORT_SUB_USB_C1, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, - .flags = PI3USB9201_ALWAYS_POWERED, - }, }; /* Charger chips */ const struct charger_config_t chg_chips[] = { - [CHARGER_PRIMARY] = { + [CHARGER_SOLO] = { + /* TODO(b/257377326) change - SM5803 not in use */ .i2c_port = I2C_PORT_USB_C0, .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS, .drv = &sm5803_drv, }, - [CHARGER_SECONDARY] = { - .i2c_port = I2C_PORT_SUB_USB_C1, - .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS, - .drv = &sm5803_drv, - }, }; /* TCPCs */ @@ -184,26 +135,6 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { .bus_type = EC_BUS_TYPE_EMBEDDED, .drv = &it83xx_tcpm_drv, }, - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_SUB_USB_C1, - .addr_flags = AN7447_TCPC0_I2C_ADDR_FLAGS, - }, - .drv = &anx7447_tcpm_drv, - .flags = TCPC_FLAGS_TCPCI_REV2_0, - }, -}; - -/* USB Retimer */ -const struct usb_mux_chain usbc1_retimer = { - .mux = - &(const struct usb_mux){ - .usb_port = 1, - .i2c_port = I2C_PORT_SUB_USB_C1, - .i2c_addr_flags = TUSB544_I2C_ADDR_FLAGS0, - .driver = &tusb544_drv, - }, }; /* USB Muxes */ @@ -217,16 +148,6 @@ const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { .driver = &it5205_usb_mux_driver, }, }, - { - .mux = - &(const struct usb_mux){ - .usb_port = 1, - .i2c_port = I2C_PORT_SUB_USB_C1, - .i2c_addr_flags = AN7447_TCPC0_I2C_ADDR_FLAGS, - .driver = &anx7447_usb_mux_driver, - }, - .next = &usbc1_retimer, - }, }; void board_init(void) @@ -234,32 +155,26 @@ void board_init(void) int on; if (system_get_board_version() <= 0) { + /* TODO(b/257377326) possibly update/delete */ pd_set_max_voltage(5000); - c1_int_line = GPIO_USB_C1_INT_V0_ODL; - } else { - c1_int_line = GPIO_USB_C1_INT_V1_ODL; } gpio_enable_interrupt(GPIO_USB_C0_INT_ODL); - gpio_enable_interrupt(c1_int_line); /* * If interrupt lines are already low, schedule them to be processed * after inits are completed. */ check_c0_line(); - check_c1_line(); gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL); - /* Enable Base Accel interrupt */ - gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); /* Charger on the MB will be outputting PROCHOT_ODL and OD CHG_DET */ - sm5803_configure_gpio0(CHARGER_PRIMARY, GPIO0_MODE_PROCHOT, 1); - sm5803_configure_chg_det_od(CHARGER_PRIMARY, 1); + sm5803_configure_gpio0(CHARGER_SOLO, GPIO0_MODE_PROCHOT, 1); + sm5803_configure_chg_det_od(CHARGER_SOLO, 1); /* Charger on the sub-board will be a push-pull GPIO */ - sm5803_configure_gpio0(CHARGER_SECONDARY, GPIO0_MODE_OUTPUT, 0); + sm5803_configure_gpio0(CHARGER_SOLO, GPIO0_MODE_OUTPUT, 0); /* Turn on 5V if the system is on, otherwise turn it off */ on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND | @@ -270,17 +185,13 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); static void board_resume(void) { - sm5803_disable_low_power_mode(CHARGER_PRIMARY); - if (board_get_charger_chip_count() > 1) - sm5803_disable_low_power_mode(CHARGER_SECONDARY); + sm5803_disable_low_power_mode(CHARGER_SOLO); } DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_resume, HOOK_PRIO_DEFAULT); static void board_suspend(void) { - sm5803_enable_low_power_mode(CHARGER_PRIMARY); - if (board_get_charger_chip_count() > 1) - sm5803_enable_low_power_mode(CHARGER_SECONDARY); + sm5803_enable_low_power_mode(CHARGER_SOLO); } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_suspend, HOOK_PRIO_DEFAULT); @@ -290,22 +201,13 @@ void board_hibernate(void) * Put all charger ICs present into low power mode before entering * z-state. */ - sm5803_hibernate(CHARGER_PRIMARY); - if (board_get_charger_chip_count() > 1) - sm5803_hibernate(CHARGER_SECONDARY); -} - -__override void board_ocpc_init(struct ocpc_data *ocpc) -{ - /* There's no provision to measure Isys */ - ocpc->chg_flags[CHARGER_SECONDARY] |= OCPC_NO_ISYS_MEAS_CAP; + sm5803_hibernate(CHARGER_SOLO); } void board_reset_pd_mcu(void) { /* - * Nothing to do. TCPC C0 is internal, TCPC C1 reset pin is not - * connected to the EC. + * Nothing to do. TCPC C0 is internal. */ } @@ -327,19 +229,7 @@ uint16_t tcpc_get_alert_status(void) * TCPC 0 is embedded in the EC and processes interrupts in the chip * code (it83xx/intc.c) */ - - uint16_t status = 0; - int regval; - - /* Check whether TCPC 1 pulled the shared interrupt line */ - if (!gpio_get_level(c1_int_line)) { - if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { - if (regval) - status = PD_STATUS_TCPC_ALERT_1; - } - } - - return status; + return 0; } void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, @@ -356,6 +246,10 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int board_set_active_charge_port(int port) { + /* + * TODO(b/257377326) since this now enable/disable on one port, look + * into updating this method + */ int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count()); if (!is_valid_port && port != CHARGE_PORT_NONE) @@ -364,10 +258,7 @@ int board_set_active_charge_port(int port) if (port == CHARGE_PORT_NONE) { CPRINTUSB("Disabling all charge ports"); - sm5803_vbus_sink_enable(CHARGER_PRIMARY, 0); - - if (board_get_charger_chip_count() > 1) - sm5803_vbus_sink_enable(CHARGER_SECONDARY, 0); + sm5803_vbus_sink_enable(CHARGER_SOLO, 0); return EC_SUCCESS; } @@ -378,13 +269,9 @@ int board_set_active_charge_port(int port) * Ensure other port is turned off, then enable new charge port */ if (port == 0) { - if (board_get_charger_chip_count() > 1) - sm5803_vbus_sink_enable(CHARGER_SECONDARY, 0); - sm5803_vbus_sink_enable(CHARGER_PRIMARY, 1); - + sm5803_vbus_sink_enable(CHARGER_SOLO, 1); } else { - sm5803_vbus_sink_enable(CHARGER_PRIMARY, 0); - sm5803_vbus_sink_enable(CHARGER_SECONDARY, 1); + sm5803_vbus_sink_enable(CHARGER_SOLO, 0); } return EC_SUCCESS; @@ -403,19 +290,6 @@ void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) gpio_set_level(GPIO_EN_USB_C0_CC2_VCONN, !!enabled); } -__override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, - int *ki_div, int *kd, int *kd_div) -{ - *kp = 3; - *kp_div = 14; - - *ki = 3; - *ki_div = 500; - - *kd = 4; - *kd_div = 40; -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { int current; @@ -457,89 +331,6 @@ const struct pwm_t pwm_channels[] = { }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); -/* Sensor Mutexes */ -static struct mutex g_lid_mutex; -static struct mutex g_base_mutex; - -/* Sensor Data */ -static struct kionix_accel_data g_kx022_data; -static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA; - -/* Drivers */ -struct motion_sensor_t motion_sensors[] = { - [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_KX022, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &kionix_accel_drv, - .mutex = &g_lid_mutex, - .drv_data = &g_kx022_data, - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = KX022_ADDR1_FLAGS, - .rot_standard_ref = NULL, - .default_range = 2, /* g */ - /* We only use 2g because its resolution is only 8-bits */ - .min_frequency = KX022_ACCEL_MIN_FREQ, - .max_frequency = KX022_ACCEL_MAX_FREQ, - .config = { - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - }, - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - }, - }, - }, - [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, - MOTIONSENSE_TYPE_ACCEL), - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, - .rot_standard_ref = NULL, - .default_range = 4, /* g */ - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - .config = { - [SENSOR_CONFIG_EC_S0] = { - .odr = 13000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, - }, - [BASE_GYRO] = { - .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = LSM6DSM_ST_DATA(lsm6dsm_data, - MOTIONSENSE_TYPE_GYRO), - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LSM6DSM_ADDR0_FLAGS, - .default_range = 1000 | ROUND_UP_FLAG, /* dps */ - .rot_standard_ref = NULL, - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - }, -}; - -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - /* Thermistors */ const struct temp_sensor_t temp_sensors[] = { [TEMP_SENSOR_1] = { .name = "Memory", @@ -552,29 +343,3 @@ const struct temp_sensor_t temp_sensors[] = { .idx = ADC_TEMP_SENSOR_2 }, }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); - -/* This callback disables keyboard when convertibles are fully open */ -__override void lid_angle_peripheral_enable(int enable) -{ - int chipset_in_s0 = chipset_in_state(CHIPSET_STATE_ON); - - /* - * If the lid is in tablet position via other sensors, - * ignore the lid angle, which might be faulty then - * disable keyboard. - */ - if (tablet_get_mode()) - enable = 0; - - if (enable) { - keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_ANGLE); - } else { - /* - * Ensure that the chipset is off before disabling the keyboard. - * When the chipset is on, the EC keeps the keyboard enabled and - * the AP decides whether to ignore input devices or not. - */ - if (!chipset_in_s0) - keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE); - } -} diff --git a/board/dibbi/board.h b/board/dibbi/board.h index 6799e7e113..8a11b01996 100644 --- a/board/dibbi/board.h +++ b/board/dibbi/board.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* Waddledee board configuration */ +/* Dibbi board configuration */ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H @@ -24,23 +24,11 @@ #define CONFIG_BC12_DETECT_PI3USB9201 /* Charger */ -#define CONFIG_CHARGER_SM5803 /* C0 and C1: Charger */ +#define CONFIG_CHARGER_SM5803 /* C0: Charger */ #define PD_MAX_VOLTAGE_MV 15000 #define CONFIG_USB_PD_VBUS_DETECT_CHARGER #define CONFIG_USB_PD_5V_CHARGER_CTRL #define CONFIG_CHARGER_OTG -#undef CONFIG_CHARGER_SINGLE_CHIP -#define CONFIG_OCPC -#define CONFIG_OCPC_DEF_RBATT_MOHMS \ - 21 /* R_DS(on) 10.7mOhm + 10mOhm sns rstr \ - */ - -/* - * GPIO for C1 interrupts, for baseboard use - * - * Note this will only be valid for board revision 1 - */ -#define GPIO_USB_C1_INT_ODL GPIO_USB_C1_INT_V1_ODL /* LED */ #define CONFIG_LED_PWM @@ -49,57 +37,60 @@ /* PWM */ #define CONFIG_PWM -/* Sensors */ -#define CONFIG_ACCEL_KX022 /* Lid accel */ -#define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ -#define CONFIG_ACCEL_LSM6DSM_INT_EVENT \ - TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) -/* Sensors without hardware FIFO are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(LID_ACCEL) - -/* Enable sensor fifo, must also define the _SIZE and _THRES */ -#define CONFIG_ACCEL_FIFO -/* Power of 2 - Too large of a fifo causes too much timestamp jitter */ -#define CONFIG_ACCEL_FIFO_SIZE 256 -#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3) - -#define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_UPDATE -#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL -#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL - -#define CONFIG_TABLET_MODE -#define CONFIG_TABLET_MODE_SWITCH -#define CONFIG_GMR_TABLET_MODE - /* TCPC */ -#define CONFIG_USB_PD_PORT_MAX_COUNT 2 +#define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPM_ITE_ON_CHIP /* C0: ITE EC TCPC */ -#define CONFIG_USB_PD_TCPM_ANX7447 /* C1: ANX TCPC + Mux */ #define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT 1 +/* Power: Dedicated barreljack charger port */ +#undef CONFIG_DEDICATED_CHARGE_PORT_COUNT +#define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1 +#define DEDICATED_CHARGE_PORT 1 + /* Thermistors */ #define CONFIG_TEMP_SENSOR #define CONFIG_THERMISTOR #define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B /* USB Mux and Retimer */ -#define CONFIG_USB_MUX_IT5205 /* C1: ITE Mux */ +#define CONFIG_USB_MUX_IT5205 /* C0: ITE Mux */ #define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */ -#define CONFIG_USBC_RETIMER_TUSB544 /* C1 Redriver: TUSB544 */ +/* No Keyboard */ +#undef CONFIG_MKBP_EVENT +#undef CONFIG_MKBP_EVENT_WAKEUP_MASK +#undef CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT +#undef CONFIG_KEYBOARD_COL2_INVERTED +#undef CONFIG_KEYBOARD_PROTOCOL_8042 +#undef CONFIG_MKBP_INPUT_DEVICES +#undef CONFIG_CMD_KEYBOARD +#undef CONFIG_KEYBOARD_BOOT_KEYS +#undef CONFIG_KEYBOARD_RUNTIME_KEYS + +/* No backlight */ +#undef CONFIG_BACKLIGHT_LID +#undef GPIO_ENABLE_BACKLIGHT + +/* Buttons */ +#define CONFIG_POWER_BUTTON_IGNORE_LID + +/* Unused features - Misc */ +#undef CONFIG_VOLUME_BUTTONS +#undef CONFIG_LID_SWITCH + +#undef CONFIG_TABLET_MODE +#undef CONFIG_TABLET_MODE_SWITCH +#undef CONFIG_GMR_TABLET_MODE +#undef GPIO_TABLET_MODE_L + +/* Unused GPIOs */ +#undef GPIO_USB_C1_DP_HPD #ifndef __ASSEMBLER__ #include "gpio_signal.h" #include "registers.h" -enum chg_id { - CHARGER_PRIMARY, - CHARGER_SECONDARY, - CHARGER_NUM, -}; - enum pwm_channel { PWM_CH_KBLIGHT, PWM_CH_LED_RED, @@ -108,9 +99,6 @@ enum pwm_channel { PWM_CH_COUNT, }; -/* Motion sensors */ -enum sensor_id { LID_ACCEL, BASE_ACCEL, BASE_GYRO, SENSOR_COUNT }; - /* ADC channels */ enum adc_channel { ADC_VSNS_PP3300_A, /* ADC0 */ @@ -137,6 +125,10 @@ enum battery_type { BATTERY_TYPE_COUNT, }; +/* Board specific handlers */ +/* TODO(b/257377326) Update this with power re-work */ +#define PORT_TO_HPD(port) (GPIO_USB_C0_DP_HPD) + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/dibbi/build.mk b/board/dibbi/build.mk index 317174e0d5..e75f1c6725 100644 --- a/board/dibbi/build.mk +++ b/board/dibbi/build.mk @@ -11,5 +11,5 @@ CHIP_FAMILY:=it8320 CHIP_VARIANT:=it8320dx BASEBOARD:=dedede -board-y=board.o cbi_ssfc.o led.o usb_pd_policy.o +board-y=board.o led.o usb_pd_policy.o board-$(CONFIG_BATTERY_SMART)+=battery.o diff --git a/board/dibbi/cbi_ssfc.c b/board/dibbi/cbi_ssfc.c deleted file mode 100644 index 9b19af1053..0000000000 --- a/board/dibbi/cbi_ssfc.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "cbi_ssfc.h" -#include "common.h" -#include "console.h" -#include "cros_board_info.h" -#include "hooks.h" - -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) - -/* Cache SSFC on init since we don't expect it to change in runtime */ -static union dedede_cbi_ssfc cached_ssfc; -BUILD_ASSERT(sizeof(cached_ssfc) == sizeof(uint32_t)); - -static void cbi_ssfc_init(void) -{ - if (cbi_get_ssfc(&cached_ssfc.raw_value) != EC_SUCCESS) - /* Default to 0 when CBI isn't populated */ - cached_ssfc.raw_value = 0; - - CPRINTS("Read CBI SSFC : 0x%04X", cached_ssfc.raw_value); -} -DECLARE_HOOK(HOOK_INIT, cbi_ssfc_init, HOOK_PRIO_FIRST); - -enum ec_ssfc_base_sensor get_cbi_ssfc_base_sensor(void) -{ - return (enum ec_ssfc_base_sensor)cached_ssfc.base_sensor; -} - -enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void) -{ - return (enum ec_ssfc_lid_sensor)cached_ssfc.lid_sensor; -} diff --git a/board/dibbi/cbi_ssfc.h b/board/dibbi/cbi_ssfc.h deleted file mode 100644 index df8334879d..0000000000 --- a/board/dibbi/cbi_ssfc.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef _DEDEDE_CBI_SSFC__H_ -#define _DEDEDE_CBI_SSFC__H_ - -#include "stdint.h" - -/**************************************************************************** - * Dedede CBI Second Source Factory Cache - */ - -/* - * Base Sensor (Bits 0-2) - */ -enum ec_ssfc_base_sensor { - SSFC_SENSOR_BASE_DEFAULT = 0, - SSFC_SENSOR_BMI160 = 1, - SSFC_SENSOR_ICM426XX = 2, - SSFC_SENSOR_LSM6DSM = 3, - SSFC_SENSOR_ICM42607 = 4 -}; - -/* - * Lid Sensor (Bits 3-5) - */ -enum ec_ssfc_lid_sensor { - SSFC_SENSOR_LID_DEFAULT = 0, - SSFC_SENSOR_BMA255 = 1, - SSFC_SENSOR_KX022 = 2, - SSFC_SENSOR_LIS2DWL = 3 -}; - -union dedede_cbi_ssfc { - struct { - uint32_t base_sensor : 3; - uint32_t lid_sensor : 3; - uint32_t reserved_2 : 26; - }; - uint32_t raw_value; -}; - -/** - * Get the Base sensor type from SSFC_CONFIG. - * - * @return the Base sensor board type. - */ -enum ec_ssfc_base_sensor get_cbi_ssfc_base_sensor(void); - -/** - * Get the Lid sensor type from SSFC_CONFIG. - * - * @return the Lid sensor board type. - */ -enum ec_ssfc_lid_sensor get_cbi_ssfc_lid_sensor(void); - -#endif /* _DEDEDE_CBI_SSFC__H_ */ diff --git a/board/dibbi/ec.tasklist b/board/dibbi/ec.tasklist index 5ecc92b40e..ed73e778fe 100644 --- a/board/dibbi/ec.tasklist +++ b/board/dibbi/ec.tasklist @@ -9,16 +9,17 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \ - TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 1, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, TRENTA_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \ - TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(POWERBTN, power_button_task, NULL, ULTRA_TASK_STACK_SIZE) \ - TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, ULTRA_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C0, pd_task, NULL, ULTRA_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C1, pd_task, NULL, ULTRA_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, ULTRA_TASK_STACK_SIZE) + TASK_ALWAYS(PD_C0, pd_task, NULL, ULTRA_TASK_STACK_SIZE) + +/* + * TODO(b/257377326): + * determine what tasks are required for PD power + * determine whether there should be a PD_INT_C0 (waddledee only had + * PD_INT_C1) + */ diff --git a/board/dibbi/gpio.inc b/board/dibbi/gpio.inc index 731d2c4cda..9f98e2171b 100644 --- a/board/dibbi/gpio.inc +++ b/board/dibbi/gpio.inc @@ -30,16 +30,13 @@ GPIO_INT(UART1_RX, PIN(B, 0), GPIO_INT_BOTH, uart_deepsleep_interrupt) /* UART_ /* USB-C interrupts */ GPIO_INT(USB_C0_INT_ODL, PIN(K, 0), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c0_interrupt) /* BC12 and charger */ -GPIO_INT(USB_C1_INT_V0_ODL, PIN(B, 5), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c1_interrupt) /* TCPC, charger, BC12 - board version 0 */ -GPIO_INT(USB_C1_INT_V1_ODL, PIN(E, 6), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c1_interrupt) /* TCPC, charger, BC12 - board version 1 */ GPIO_INT(USB_C0_CCSBU_OVP_ODL, PIN(K, 6), GPIO_INT_FALLING | GPIO_PULL_UP, c0_ccsbu_ovp_interrupt) /* Fault protection */ /* Other interrupts */ -GPIO_INT(LID_OPEN, PIN(F, 3), GPIO_INT_BOTH, lid_interrupt) -GPIO_INT(LID_360_L, PIN(A, 7), GPIO_INT_BOTH, gmr_tablet_switch_isr) -GPIO_INT(VOLDN_BTN_ODL, PIN(I, 6), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) -GPIO_INT(VOLUP_BTN_ODL, PIN(I, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) -GPIO_INT(BASE_SIXAXIS_INT_L, PIN(J, 0), GPIO_INT_FALLING | GPIO_SEL_1P8V, lsm6dsm_interrupt) +/* TODO(b/257377326) PIN(A, 7) changed from LID_360_L to BJ_ADP_PRESENT_L */ +/* TODO(b/257833880) PIN(I, 6) changed from VOLDN_BTN_ODL to USB_C0_VBUS_ILIM */ +/* TODO(b/257833880) PIN(I, 7) changed from VOLUP_BTN_ODL to EN_USB_C0_VBUS */ +/* TODO(b/257377326) PIN(J, 0) changed from BASE_SIXAXIS_INT_L to EN_PVAR_BJ_ADP_L */ GPIO_INT(EC_WP_OD, PIN(A, 6), GPIO_INT_BOTH, switch_interrupt) /* Power sequence GPIOs */ @@ -74,8 +71,6 @@ GPIO(EC_I2C_BATTERY_SCL, PIN(C, 1), GPIO_INPUT) GPIO(EC_I2C_BATTERY_SDA, PIN(C, 2), GPIO_INPUT) GPIO(EC_I2C_SENSOR_SCL, PIN(F, 6), GPIO_INPUT | GPIO_SEL_1P8V) GPIO(EC_I2C_SENSOR_SDA, PIN(F, 7), GPIO_INPUT | GPIO_SEL_1P8V) -GPIO(EC_I2C_SUB_USB_C1_SCL, PIN(E, 0), GPIO_INPUT) -GPIO(EC_I2C_SUB_USB_C1_SDA, PIN(E, 7), GPIO_INPUT) GPIO(EC_I2C_USB_C0_SCL, PIN(A, 4), GPIO_INPUT) GPIO(EC_I2C_USB_C0_SDA, PIN(A, 5), GPIO_INPUT) @@ -83,12 +78,13 @@ GPIO(EC_I2C_USB_C0_SDA, PIN(A, 5), GPIO_INPUT) GPIO(EN_USB_C0_CC1_VCONN, PIN(H, 4), GPIO_OUT_LOW) GPIO(EN_USB_C0_CC2_VCONN, PIN(H, 6), GPIO_OUT_LOW) GPIO(EC_AP_USB_C0_HPD, PIN(L, 4), GPIO_OUT_LOW) -GPIO(EC_AP_USB_C1_HDMI_HPD, PIN(K, 7), GPIO_OUT_LOW) +/* TODO(b/257377036) PIN(K, 7) changed from EC_AP_USB_C1_HDMI_HPD to EC_RECOVERY_BUTTON_ODL */ GPIO(USB_C0_FRS, PIN(C, 4), GPIO_OUT_LOW) GPIO(HDMI_SEL_L, PIN(C, 6), GPIO_OUT_HIGH) GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW) /* Board rev 1, NC board rev 0 */ /* MKBP event synchronization */ +/* TODO(b/257833880) Check whether this pin is needed */ GPIO(EC_AP_MKBP_INT_L, PIN(L, 5), GPIO_ODR_HIGH) /* Misc pins which will run to the I/O board */ @@ -98,14 +94,14 @@ GPIO(EC_SUB_IO_2_1, PIN(F, 1), GPIO_INPUT) GPIO(EC_SUB_IO_2_2, PIN(L, 2), GPIO_INPUT) /* Misc */ -GPIO(EN_BL_OD, PIN(K, 4), GPIO_ODR_LOW) +/* TODO(b/257377036) PIN(K, 4) changed from EN_BL_OD to EC_RECOVERY_BUTTON_ODL */ GPIO(EC_ENTERING_RW, PIN(G, 0), GPIO_OUT_LOW) GPIO(CCD_MODE_ODL, PIN(H, 5), GPIO_ODR_HIGH) GPIO(EC_BATTERY_PRES_ODL, PIN(I, 4), GPIO_INPUT) -GPIO(PEN_DET_ODL, PIN(J, 1), GPIO_INPUT | GPIO_PULL_UP) -GPIO(EN_KB_BL, PIN(J, 3), GPIO_OUT_LOW) /* Currently unused */ +/* TODO(b/257377036) PIN(J, 1) changed from PEN_DET_ODL to EN_PPVAR_USBC_ADP_L */ GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW) + /* NC pins, enable internal pull-down to avoid floating state. */ GPIO(GPIOC0_NC, PIN(C, 0), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOC3_NC, PIN(C, 3), GPIO_INPUT | GPIO_PULL_DOWN) @@ -118,6 +114,7 @@ GPIO(GPIOJ4_NC, PIN(J, 4), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOJ5_NC, PIN(J, 5), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOJ6_NC, PIN(J, 6), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOM6_NC, PIN(M, 6), GPIO_INPUT | GPIO_PULL_DOWN) +/* TODO(b/257833880) add any new unused pins */ /* Alternate functions GPIO definitions */ /* UART */ @@ -135,4 +132,4 @@ ALTERNATE(PIN_MASK(L, BIT(0)), 0, MODULE_ADC, 0) /* ADC13: EC_SUB_ANALOG */ ALTERNATE(PIN_MASK(I, BIT(0) | BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC0: EC_VSNS_PP3300_A, ADC2: TEMP_SENSOR_1, ADC3: TEMP_SENSOR_2 */ /* PWM */ -ALTERNATE(PIN_MASK(A, BIT(0) | BIT(1) | BIT(2) | BIT(3)), 0, MODULE_PWM, 0) /* KB_BL_PWM, LED_[R,G,B]_ODL */ +ALTERNATE(PIN_MASK(A, BIT(1) | BIT(2) | BIT(3)), 0, MODULE_PWM, 0) /* LED_[R,G,B]_ODL */ diff --git a/board/dibbi/usb_pd_policy.c b/board/dibbi/usb_pd_policy.c index 40dc896050..ad930e1862 100644 --- a/board/dibbi/usb_pd_policy.c +++ b/board/dibbi/usb_pd_policy.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include "battery_smart.h" +#include "battery_smart.h" /* TODO(b/257377326) remove */ #include "charge_manager.h" #include "charger.h" #include "chipset.h" #include "common.h" #include "console.h" -#include "driver/charger/sm5803.h" +#include "driver/charger/sm5803.h" /* TODO(b/257377326) remove */ #include "driver/tcpm/tcpci.h" #include "usb_pd.h" -- cgit v1.2.1 From 7c7c12e53d64c6c9f88020e7257247d9c9c828df Mon Sep 17 00:00:00 2001 From: Andrew McRae Date: Thu, 27 Oct 2022 16:51:29 +1100 Subject: Reland "hibernate: Add hibernate support to ap power code" This is a reland of commit 16c8fce71986d50d9e10ea089d9d9352818129ad Reworked Kconfig handling. Original change's description: > hibernate: Add hibernate support to ap power code > > Add hibernate support to the AP power sequence code. > > The smart discharge system isn't supported yet. > > The system will hibernate after a delay when the AP is in G3 > and there is no external power connected. > > v2: add tests BUG=b:246643307 TEST=build and run on nivviks BRANCH=none Change-Id: I7f4e5633d05ca545e63ad9784a410284ef83e2b7 Signed-off-by: Andrew McRae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019012 Reviewed-by: Keith Short Code-Coverage: Zoss --- power/hibernate.c | 181 ++++++++++++++++++++++++++++++ util/config_allowed.txt | 2 - zephyr/CMakeLists.txt | 3 + zephyr/Kconfig.system | 36 +++++- zephyr/shim/include/config_chip.h | 10 ++ zephyr/test/ap_power/CMakeLists.txt | 2 + zephyr/test/ap_power/include/test_mocks.h | 21 ++++ zephyr/test/ap_power/prj.conf | 3 + zephyr/test/ap_power/src/board.c | 5 - zephyr/test/ap_power/src/hibdelay.c | 37 ++++++ zephyr/test/ap_power/src/hibernate.c | 41 +++++++ zephyr/test/ap_power/src/host_command.c | 28 +++++ zephyr/test/ap_power/src/test_mocks.c | 30 +++++ 13 files changed, 391 insertions(+), 8 deletions(-) create mode 100644 power/hibernate.c create mode 100644 zephyr/test/ap_power/include/test_mocks.h create mode 100644 zephyr/test/ap_power/src/hibdelay.c create mode 100644 zephyr/test/ap_power/src/hibernate.c create mode 100644 zephyr/test/ap_power/src/host_command.c create mode 100644 zephyr/test/ap_power/src/test_mocks.c diff --git a/power/hibernate.c b/power/hibernate.c new file mode 100644 index 0000000000..322adca3ea --- /dev/null +++ b/power/hibernate.c @@ -0,0 +1,181 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include +#include + +#include "console.h" +#include "extpower.h" +#include "hooks.h" +#include "host_command.h" +#include "system.h" +#include "util.h" + +LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL); + +/* + * Hibernate processing. + * + * When enabled, the system will be put into an extreme low + * power state after the AP is in G3 for a configurable period of time, + * and there is no external power connected (i.e on battery). + * + * The delay has a configurable default, and may be set dynamically + * via a host command, or an EC console command. A typical delay + * may be 1 hour (3600 seconds). + * + * AP events such as AP_POWER_HARD_OFF are listened for, and + * a timer is used to detect when the AP has been off for the + * selected delay time. If the AP is started again, the timer is canceled. + * Once the timer expires, the system_hibernate() function is called, + * and this will suspend the EC until a wake signal is received. + */ +static uint32_t hibernate_delay = CONFIG_HIBERNATE_DELAY_SEC; + +/* + * Return true if conditions are right for hibernation. + */ +static inline bool ready_to_hibernate(void) +{ + return ap_power_in_or_transitioning_to_state(AP_POWER_STATE_HARD_OFF) && + !extpower_is_present(); +} + +/* + * The AP has been off for the delay period, so hibernate the system, + * if ready. Called from system work queue. + */ +static void hibernate_handler(struct k_work *unused) +{ + if (ready_to_hibernate()) { + LOG_INF("System hibernating due to %d seconds AP off", + hibernate_delay); + system_hibernate(0, 0); + } +} + +K_WORK_DEFINE(hibernate_work, hibernate_handler); + +/* + * Hibernate timer handler. + * Called when timer has expired. + * Schedule hibernate_handler to run via system work queue. + */ +static void timer_handler(struct k_timer *timer) +{ + k_work_submit(&hibernate_work); +} + +K_TIMER_DEFINE(hibernate_timer, timer_handler, NULL); + +/* + * A change has been detected in either the AP state or the + * external power supply. + */ +static void change_detected(void) +{ + if (ready_to_hibernate()) { + /* + * AP is off, and there is no external power. + * Start the timer if it is not already running. + */ + if (k_timer_remaining_get(&hibernate_timer) == 0) { + k_timer_start(&hibernate_timer, + K_SECONDS(hibernate_delay), K_NO_WAIT); + } + + } else { + /* + * AP is either on, or external power is on. + * Either way, no hibernation is done. + * Make sure the timer is not running. + */ + k_timer_stop(&hibernate_timer); + } +} + +static void ap_change(struct ap_power_ev_callback *callback, + struct ap_power_ev_data data) +{ + change_detected(); +} + +/* + * Hook to listen for external power supply changes. + */ +DECLARE_HOOK(HOOK_AC_CHANGE, change_detected, HOOK_PRIO_DEFAULT); + +/* + * EC Console command to get/set the hibernation delay + */ +static int command_hibernation_delay(int argc, const char **argv) +{ + char *e; + uint32_t remaining; + + if (argc >= 2) { + uint32_t s = strtoi(argv[1], &e, 0); + + if (*e) + return EC_ERROR_PARAM1; + + hibernate_delay = s; + } + + /* Print the current setting */ + ccprintf("Hibernation delay: %d s\n", hibernate_delay); + remaining = k_timer_remaining_get(&hibernate_timer); + if (remaining == 0) { + ccprintf("Timer not running\n"); + } else { + ccprintf("Time remaining: %d s\n", remaining / 1000); + } + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(hibdelay, command_hibernation_delay, "[sec]", + "Set the delay before going into hibernation"); +/* + * Host command to set the hibernation delay + */ +static enum ec_status +host_command_hibernation_delay(struct host_cmd_handler_args *args) +{ + const struct ec_params_hibernation_delay *p = args->params; + struct ec_response_hibernation_delay *r = args->response; + + /* Only change the hibernation delay if seconds is non-zero. */ + if (p->seconds) + hibernate_delay = p->seconds; + + r->hibernate_delay = hibernate_delay; + /* + * It makes no sense to try and set these values since + * they are only valid when the AP is in G3 (so this + * host command will never be called at that point). + */ + r->time_g3 = 0; + r->time_remaining = 0; + + args->response_size = sizeof(struct ec_response_hibernation_delay); + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_HIBERNATION_DELAY, host_command_hibernation_delay, + EC_VER_MASK(0)); + +static int hibernate_init(const struct device *unused) +{ + static struct ap_power_ev_callback cb; + + ap_power_ev_init_callback(&cb, ap_change, + AP_POWER_INITIALIZED | AP_POWER_HARD_OFF | + AP_POWER_STARTUP); + ap_power_ev_add_callback(&cb); + return 0; +} + +SYS_INIT(hibernate_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/util/config_allowed.txt b/util/config_allowed.txt index 66109880ed..bdf8e0eca8 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -455,10 +455,8 @@ CONFIG_H2RAM_BASE CONFIG_H2RAM_HOST_LPC_IO_BASE CONFIG_H2RAM_SIZE CONFIG_HAS_TASK_PD_INT -CONFIG_HIBERNATE CONFIG_HIBERNATE_BATT_PCT CONFIG_HIBERNATE_BATT_SEC -CONFIG_HIBERNATE_DELAY_SEC CONFIG_HIBERNATE_PSL_COMPENSATE_RTC CONFIG_HIBERNATE_PSL_OUT_FLAGS CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 65f5c5b92d..ec88fa7e43 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -361,6 +361,9 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_SC7180 "${PLATFORM_EC}/power/qcom.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_SC7280 "${PLATFORM_EC}/power/qcom.c") +if (CONFIG_PLATFORM_EC_HIBERNATE AND CONFIG_AP_PWRSEQ) + zephyr_library_sources( "${PLATFORM_EC}/power/hibernate.c") +endif () zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC "${PLATFORM_EC}/common/panic_output.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SHA256_SW diff --git a/zephyr/Kconfig.system b/zephyr/Kconfig.system index 5467bc7422..ec0333ec35 100644 --- a/zephyr/Kconfig.system +++ b/zephyr/Kconfig.system @@ -18,16 +18,50 @@ config PLATFORM_EC_CONSOLE_CMD_SYSINFO Enable the sysinfo console command, which shows statistics about the current image copy running, reset flags, etc. +config PLATFORM_EC_HIBERNATE + bool + help + Enable system hibernation. + The type of hibernation supported must be selected. + +choice PLATFORM_EC_HIBERNATE_TYPE + prompt "Choose a hibernate type" + default PLATFORM_EC_HIBERNATE_PSL if DT_HAS_NUVOTON_NPCX_POWER_PSL_ENABLED && SOC_FAMILY_NPCX + default PLATFORM_EC_HIBERNATE_WAKE_PINS if !DT_HAS_NUVOTON_NPCX_POWER_PSL_ENABLED || !SOC_FAMILY_NPCX + help + Select the type of hibernation supported. Either + PLATFORM_EC_HIBERNATE_PSL (for power switch logic support) or + PLATFORM_EC_HIBERNATE_WAKE_PINS (using wake pins) are + supported. + config PLATFORM_EC_HIBERNATE_PSL bool "System hibernating with PSL (Power Switch Logic) mechanism" - default y depends on DT_HAS_NUVOTON_NPCX_POWER_PSL_ENABLED depends on SOC_FAMILY_NPCX + select PLATFORM_EC_HIBERNATE help Use PSL (Power Switch Logic) for hibernating. It turns off VCC power rail for ultra-low power consumption and uses PSL inputs rely on VSBY power rail to wake up ec and the whole system. +config PLATFORM_EC_HIBERNATE_WAKE_PINS + bool "System hibernating with wake-source pins" + select PLATFORM_EC_HIBERNATE + help + Use wake source pins for hibernating. It turns off VCC power + rail for ultra-low power consumption and uses a low power + power rail. Changes on wake source pins will wake up the EC. + +endchoice # PLATFORM_EC_HIBERNATE_TYPE + +config PLATFORM_EC_HIBERNATE_DELAY_SEC + int "Delay in seconds from AP power off to hibernate" + depends on PLATFORM_EC_HIBERNATE + default 3600 + help + This value is the delay in seconds from when the AP enters G3 + to when the system is hibernated. + config PLATFORM_EC_SYSTEM_PRE_INIT_PRIORITY int "System pre-initialization priority" default 20 diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index d2b5bbf577..7f56d9c342 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -2434,6 +2434,16 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #define CONFIG_HIBERNATE_PSL #endif +#ifdef CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC +#undef CONFIG_HIBERNATE_DELAY_SEC +#define CONFIG_HIBERNATE_DELAY_SEC CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC +#endif + +#undef CONFIG_HIBERNATE +#ifdef CONFIG_PLATFORM_EC_HIBERNATE +#define CONFIG_HIBERNATE +#endif + #undef CONFIG_BATTERY_DEVICE_CHEMISTRY #ifdef CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY #define CONFIG_BATTERY_DEVICE_CHEMISTRY \ diff --git a/zephyr/test/ap_power/CMakeLists.txt b/zephyr/test/ap_power/CMakeLists.txt index 7b44013961..4669dac07e 100644 --- a/zephyr/test/ap_power/CMakeLists.txt +++ b/zephyr/test/ap_power/CMakeLists.txt @@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") project(ap_power) +add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) + # Include the local test directory for shimmed_test_tasks.h zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") diff --git a/zephyr/test/ap_power/include/test_mocks.h b/zephyr/test/ap_power/include/test_mocks.h new file mode 100644 index 0000000000..8e9c80ad43 --- /dev/null +++ b/zephyr/test/ap_power/include/test_mocks.h @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __TEST_AP_POWER_TEST_MOCKS_H +#define __TEST_AP_POWER_TEST_MOCKS_H + +#include + +/* + * Mock declarations + */ + +/* Mocks for common/extpower_gpio.c */ +DECLARE_FAKE_VALUE_FUNC(int, extpower_is_present); + +/* Mocks for common/system.c */ +DECLARE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); + +#endif /* __TEST_AP_POWER_TEST_MOCKS_H */ diff --git a/zephyr/test/ap_power/prj.conf b/zephyr/test/ap_power/prj.conf index c72eace288..122b84e877 100644 --- a/zephyr/test/ap_power/prj.conf +++ b/zephyr/test/ap_power/prj.conf @@ -52,6 +52,9 @@ CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y CONFIG_PLATFORM_EC_HOSTCMD=y CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y +# Short delay for hibernate +CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC=20 + # These items are not required. CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_SWITCH=n diff --git a/zephyr/test/ap_power/src/board.c b/zephyr/test/ap_power/src/board.c index 294cb942c9..bada154bb3 100644 --- a/zephyr/test/ap_power/src/board.c +++ b/zephyr/test/ap_power/src/board.c @@ -102,8 +102,3 @@ bool board_ap_power_check_power_rails_enabled(void) { return true; } - -int extpower_is_present(void) -{ - return 0; -} diff --git a/zephyr/test/ap_power/src/hibdelay.c b/zephyr/test/ap_power/src/hibdelay.c new file mode 100644 index 0000000000..02442adec8 --- /dev/null +++ b/zephyr/test/ap_power/src/hibdelay.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "console.h" +#include "ec_commands.h" +#include "test_state.h" + +ZTEST_SUITE(console_cmd_hibdelay, ap_power_predicate_post_main, NULL, NULL, + NULL, NULL); + +ZTEST_USER(console_cmd_hibdelay, test_too_many_args) +{ + zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay 1 2"), NULL); +} + +ZTEST_USER(console_cmd_hibdelay, test_no_args) +{ + zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay"), NULL); +} + +ZTEST_USER(console_cmd_hibdelay, test_invalid_arg) +{ + int rv = shell_execute_cmd(get_ec_shell(), "hibdelay 3.4"); + + zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d", + EC_ERROR_PARAM1, rv); +} + +ZTEST_USER(console_cmd_hibdelay, test_valid_args) +{ + zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay 5"), NULL); +} diff --git a/zephyr/test/ap_power/src/hibernate.c b/zephyr/test/ap_power/src/hibernate.c new file mode 100644 index 0000000000..2309508f4b --- /dev/null +++ b/zephyr/test/ap_power/src/hibernate.c @@ -0,0 +1,41 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "hooks.h" + +#include "test_mocks.h" +#include "test_state.h" + +ZTEST(hibernate, test_g3_hibernate) +{ + extpower_is_present_fake.return_val = 0; + ap_power_ev_send_callbacks(AP_POWER_HARD_OFF); + k_sleep(K_SECONDS(30)); + zassert_equal(1, system_hibernate_fake.call_count); +} + +ZTEST(hibernate, test_ac_changed) +{ + extpower_is_present_fake.return_val = 1; + hook_notify(HOOK_AC_CHANGE); + k_sleep(K_SECONDS(30)); + zassert_equal(0, system_hibernate_fake.call_count); + extpower_is_present_fake.return_val = 0; + hook_notify(HOOK_AC_CHANGE); + k_sleep(K_SECONDS(30)); + zassert_equal(1, system_hibernate_fake.call_count); +} + +ZTEST_SUITE(hibernate, ap_power_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/ap_power/src/host_command.c b/zephyr/test/ap_power/src/host_command.c new file mode 100644 index 0000000000..4367f8fa44 --- /dev/null +++ b/zephyr/test/ap_power/src/host_command.c @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "ec_commands.h" +#include "host_command.h" +#include "test_state.h" + +ZTEST(host_cmd, test_hibernate_get) +{ + struct ec_response_hibernation_delay response; + struct ec_params_hibernation_delay params = { + .seconds = 0, + }; + + struct host_cmd_handler_args args = BUILD_HOST_COMMAND( + EC_CMD_HIBERNATION_DELAY, 0, response, params); + + zassert_ok(host_command_process(&args)); + params.seconds = 123; + zassert_ok(host_command_process(&args)); + zassert_equal(123, response.hibernate_delay, NULL); +} + +ZTEST_SUITE(host_cmd, ap_power_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/ap_power/src/test_mocks.c b/zephyr/test/ap_power/src/test_mocks.c new file mode 100644 index 0000000000..5dae36a6ab --- /dev/null +++ b/zephyr/test/ap_power/src/test_mocks.c @@ -0,0 +1,30 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "test_mocks.h" + +/* Mocks for common/extpower_gpio.c */ +DEFINE_FAKE_VALUE_FUNC(int, extpower_is_present); + +/* Mocks for common/system.c */ +DEFINE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); + +/** + * @brief Reset all the fakes before each test. + */ +static void fff_reset_rule_before(const struct ztest_unit_test *test, + void *data) +{ + ARG_UNUSED(test); + ARG_UNUSED(data); + + RESET_FAKE(extpower_is_present); + RESET_FAKE(system_hibernate); +} + +ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); -- cgit v1.2.1 From f8afc610193874aec05aab5b9cc2d2f829c4efe9 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 9 Nov 2022 14:41:26 -0800 Subject: guybrush: fix type-c port check Fix potential memory corruption in port check BUG=b:64477774 BRANCH=none TEST=none Signed-off-by: Boris Mittelberg Change-Id: Ib1a74f06d3299a1b46514f888dbb250831051d95 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4018210 Reviewed-by: Rob Barnes Code-Coverage: Zoss --- baseboard/guybrush/baseboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c index 5d36f5be9a..780aa28e74 100644 --- a/baseboard/guybrush/baseboard.c +++ b/baseboard/guybrush/baseboard.c @@ -581,7 +581,7 @@ static void reset_nct38xx_port(int port) GPIO_USB_C0_TCPC_RST_L : GPIO_USB_C1_TCPC_RST_L; - if (port < 0 || port > USBC_PORT_COUNT) { + if (port < 0 || port >= USBC_PORT_COUNT) { CPRINTSUSB("%s invalid port %d", __func__, port); return; } -- cgit v1.2.1 From e1986b2f8f74dbee9220480564f8ec5609958578 Mon Sep 17 00:00:00 2001 From: Wai-Hong Tam Date: Wed, 9 Nov 2022 16:13:51 -0800 Subject: Trogdor: Enable C1 PPC interrupt The C1 PPC interrupt is defined but not enabled on init. Should enable it. BUG=b:258532320 BRANCH=Trogdor TEST=Build all the affected boards Change-Id: I793a511783c7266897f3dc5f0988eb6ca16decc9 Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019344 Code-Coverage: Zoss Commit-Queue: Stephen Boyd Reviewed-by: Stephen Boyd --- board/coachz/board.c | 1 + board/gelarshie/board.c | 1 + board/homestar/board.c | 1 + board/kingoftown/usbc_config.c | 1 + board/lazor/usbc_config.c | 1 + board/marzipan/board.c | 1 + board/pazquel/board.c | 1 + board/trogdor/usbc_config.c | 1 + board/wormdingler/board.c | 1 + 9 files changed, 9 insertions(+) diff --git a/board/coachz/board.c b/board/coachz/board.c index 1e1ed2ab71..723078036a 100644 --- a/board/coachz/board.c +++ b/board/coachz/board.c @@ -513,6 +513,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); diff --git a/board/gelarshie/board.c b/board/gelarshie/board.c index 11346a3c7d..7ae2e06372 100644 --- a/board/gelarshie/board.c +++ b/board/gelarshie/board.c @@ -511,6 +511,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); diff --git a/board/homestar/board.c b/board/homestar/board.c index ab4b95b625..1964bc86eb 100644 --- a/board/homestar/board.c +++ b/board/homestar/board.c @@ -459,6 +459,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); diff --git a/board/kingoftown/usbc_config.c b/board/kingoftown/usbc_config.c index f0f17e93a9..5cd1f81818 100644 --- a/board/kingoftown/usbc_config.c +++ b/board/kingoftown/usbc_config.c @@ -225,6 +225,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); diff --git a/board/lazor/usbc_config.c b/board/lazor/usbc_config.c index 11cc649573..9b9504a44a 100644 --- a/board/lazor/usbc_config.c +++ b/board/lazor/usbc_config.c @@ -263,6 +263,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); diff --git a/board/marzipan/board.c b/board/marzipan/board.c index 125c39a826..94b7c444d5 100644 --- a/board/marzipan/board.c +++ b/board/marzipan/board.c @@ -496,6 +496,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); diff --git a/board/pazquel/board.c b/board/pazquel/board.c index 6ed03e90ad..8fdd4a5325 100644 --- a/board/pazquel/board.c +++ b/board/pazquel/board.c @@ -305,6 +305,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); diff --git a/board/trogdor/usbc_config.c b/board/trogdor/usbc_config.c index 39a54f659e..34c37edf1a 100644 --- a/board/trogdor/usbc_config.c +++ b/board/trogdor/usbc_config.c @@ -225,6 +225,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); diff --git a/board/wormdingler/board.c b/board/wormdingler/board.c index 3c4dfe4b3c..273c41d1a7 100644 --- a/board/wormdingler/board.c +++ b/board/wormdingler/board.c @@ -458,6 +458,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); -- cgit v1.2.1 From 9d1b3e82cb2af8201ccadec3b63fb279a85edff7 Mon Sep 17 00:00:00 2001 From: Wai-Hong Tam Date: Wed, 9 Nov 2022 16:19:18 -0800 Subject: Herobrine: Enable C1 PPC interrupt The C1 PPC interrupt is defined but not enabled on init. Should enable it. BUG=b:258532320 BRANCH=None TEST=Build all the affected boards Change-Id: Ie35b4538dbf914468eb6b58f5cfa8315ea682bf0 Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019345 Code-Coverage: Zoss Reviewed-by: Stephen Boyd Commit-Queue: Stephen Boyd --- board/herobrine/usbc_config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/board/herobrine/usbc_config.c b/board/herobrine/usbc_config.c index 98d1b70bac..18033e0b3c 100644 --- a/board/herobrine/usbc_config.c +++ b/board/herobrine/usbc_config.c @@ -177,6 +177,7 @@ void board_tcpc_init(void) /* Enable PPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL); /* Enable TCPC interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); -- cgit v1.2.1 From 8858f7d24a5023a1408d6194a6eec26b18d5c34a Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Tue, 8 Nov 2022 10:14:48 +0800 Subject: winterhold: Adjust tuning for C1 C1 requires a different setting for the equalization and flat gain register. BUG=b:254616597 BRANCH=none TEST=zmake build winterhold successfully LOW_COVERAGE_REASON=no unit test for skyrim board yet: b/247151116 Signed-off-by: Matt Wang Change-Id: Ibd0e8cdf769ff0f6404cc297b616221f14f8e445 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4011741 Reviewed-by: Diana Z Code-Coverage: Zoss Reviewed-by: Elthan Huang --- .../program/skyrim/src/winterhold/usb_mux_config.c | 83 ++++++++++++++++------ 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c b/zephyr/program/skyrim/src/winterhold/usb_mux_config.c index fdcf37e6b0..1eff945ed7 100644 --- a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c +++ b/zephyr/program/skyrim/src/winterhold/usb_mux_config.c @@ -56,6 +56,20 @@ int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) return anx7483_set_default_tuning(me, mux_state); } +int board_anx7483_c1_fg_defalut_tuning(const struct usb_mux *me) +{ + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_1_2DB)); + + return EC_SUCCESS; +} + int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) { bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; @@ -68,40 +82,65 @@ int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + /* + * Set the Flat Gain to default every time, to prevent DP only mode's + * Flat Gain change in the last plug. + */ + RETURN_ERROR(board_anx7483_c1_fg_defalut_tuning(me)); + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, ANX7483_EQ_SETTING_12_5DB)); RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, + ANX7483_FG_SETTING_0_5DB)); } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_8_4DB)); RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, + ANX7483_FG_SETTING_0_5DB)); } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_8_4DB)); RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, + ANX7483_FG_SETTING_0_5DB)); } - /* - * Those registers all need to be set no matter what state the mux is - * in it needs to be set. - */ - RETURN_ERROR( - anx7483_set_eq(me, ANX7483_PIN_URX1, ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR( - anx7483_set_eq(me, ANX7483_PIN_URX2, ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR( - anx7483_set_eq(me, ANX7483_PIN_UTX1, ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR( - anx7483_set_eq(me, ANX7483_PIN_UTX2, ANX7483_EQ_SETTING_8_4DB)); - - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_0_5DB)); - return EC_SUCCESS; } -- cgit v1.2.1 From 46ab9139420fa4f0eeaad49bb085e758f66a5103 Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Tue, 8 Nov 2022 16:32:31 +0800 Subject: usb_pe: add PE state index in the comment It's easier to reference if pd log level = 0. BUG=none TEST=zmake build -a BRANCH=none Change-Id: I64a95133f955d485d6ab9523949645b90eb330df Signed-off-by: Eric Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4015620 Reviewed-by: Diana Z Commit-Queue: Eric Yilun Lin Reviewed-by: Sam Hurst Tested-by: Eric Yilun Lin Code-Coverage: Zoss --- common/usbc/usb_pe_drp_sm.c | 158 ++++++++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index c6a61f1bd9..053fb96ff1 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -202,91 +202,91 @@ typedef int (*svdm_rsp_func)(int port, uint32_t *payload); /* List of all Policy Engine level states */ enum usb_pe_state { /* Super States */ - PE_PRS_FRS_SHARED, - PE_VDM_SEND_REQUEST, + PE_PRS_FRS_SHARED, /* pe-st0 */ + PE_VDM_SEND_REQUEST, /* pe-st1 */ /* Normal States */ - PE_SRC_STARTUP, - PE_SRC_DISCOVERY, - PE_SRC_SEND_CAPABILITIES, - PE_SRC_NEGOTIATE_CAPABILITY, - PE_SRC_TRANSITION_SUPPLY, - PE_SRC_READY, - PE_SRC_DISABLED, - PE_SRC_CAPABILITY_RESPONSE, - PE_SRC_HARD_RESET, - PE_SRC_HARD_RESET_RECEIVED, - PE_SRC_TRANSITION_TO_DEFAULT, - PE_SNK_STARTUP, - PE_SNK_DISCOVERY, - PE_SNK_WAIT_FOR_CAPABILITIES, - PE_SNK_EVALUATE_CAPABILITY, - PE_SNK_SELECT_CAPABILITY, - PE_SNK_READY, - PE_SNK_HARD_RESET, - PE_SNK_TRANSITION_TO_DEFAULT, - PE_SNK_GIVE_SINK_CAP, - PE_SNK_GET_SOURCE_CAP, - PE_SNK_TRANSITION_SINK, - PE_SEND_SOFT_RESET, - PE_SOFT_RESET, - PE_SEND_NOT_SUPPORTED, - PE_SRC_PING, - PE_DRS_EVALUATE_SWAP, - PE_DRS_CHANGE, - PE_DRS_SEND_SWAP, - PE_PRS_SRC_SNK_EVALUATE_SWAP, - PE_PRS_SRC_SNK_TRANSITION_TO_OFF, - PE_PRS_SRC_SNK_ASSERT_RD, - PE_PRS_SRC_SNK_WAIT_SOURCE_ON, - PE_PRS_SRC_SNK_SEND_SWAP, - PE_PRS_SNK_SRC_EVALUATE_SWAP, - PE_PRS_SNK_SRC_TRANSITION_TO_OFF, - PE_PRS_SNK_SRC_ASSERT_RP, - PE_PRS_SNK_SRC_SOURCE_ON, - PE_PRS_SNK_SRC_SEND_SWAP, - PE_VCS_EVALUATE_SWAP, - PE_VCS_SEND_SWAP, - PE_VCS_WAIT_FOR_VCONN_SWAP, - PE_VCS_TURN_ON_VCONN_SWAP, - PE_VCS_TURN_OFF_VCONN_SWAP, - PE_VCS_SEND_PS_RDY_SWAP, - PE_VCS_CBL_SEND_SOFT_RESET, - PE_VDM_IDENTITY_REQUEST_CBL, - PE_INIT_PORT_VDM_IDENTITY_REQUEST, - PE_INIT_VDM_SVIDS_REQUEST, - PE_INIT_VDM_MODES_REQUEST, - PE_VDM_REQUEST_DPM, - PE_VDM_RESPONSE, - PE_WAIT_FOR_ERROR_RECOVERY, - PE_BIST_TX, - PE_DEU_SEND_ENTER_USB, - PE_DR_GET_SINK_CAP, - PE_DR_SNK_GIVE_SOURCE_CAP, - PE_DR_SRC_GET_SOURCE_CAP, + PE_SRC_STARTUP, /* pe-st2 */ + PE_SRC_DISCOVERY, /* pe-st3 */ + PE_SRC_SEND_CAPABILITIES, /* pe-st4 */ + PE_SRC_NEGOTIATE_CAPABILITY, /* pe-st5 */ + PE_SRC_TRANSITION_SUPPLY, /* pe-st6 */ + PE_SRC_READY, /* pe-st7 */ + PE_SRC_DISABLED, /* pe-st8 */ + PE_SRC_CAPABILITY_RESPONSE, /* pe-st9 */ + PE_SRC_HARD_RESET, /* pe-st10 */ + PE_SRC_HARD_RESET_RECEIVED, /* pe-st11 */ + PE_SRC_TRANSITION_TO_DEFAULT, /* pe-st12 */ + PE_SNK_STARTUP, /* pe-st13 */ + PE_SNK_DISCOVERY, /* pe-st14 */ + PE_SNK_WAIT_FOR_CAPABILITIES, /* pe-st15 */ + PE_SNK_EVALUATE_CAPABILITY, /* pe-st16 */ + PE_SNK_SELECT_CAPABILITY, /* pe-st17 */ + PE_SNK_READY, /* pe-st18 */ + PE_SNK_HARD_RESET, /* pe-st19 */ + PE_SNK_TRANSITION_TO_DEFAULT, /* pe-st20 */ + PE_SNK_GIVE_SINK_CAP, /* pe-st21 */ + PE_SNK_GET_SOURCE_CAP, /* pe-st22 */ + PE_SNK_TRANSITION_SINK, /* pe-st23 */ + PE_SEND_SOFT_RESET, /* pe-st24 */ + PE_SOFT_RESET, /* pe-st25 */ + PE_SEND_NOT_SUPPORTED, /* pe-st26 */ + PE_SRC_PING, /* pe-st27 */ + PE_DRS_EVALUATE_SWAP, /* pe-st28 */ + PE_DRS_CHANGE, /* pe-st29 */ + PE_DRS_SEND_SWAP, /* pe-st30 */ + PE_PRS_SRC_SNK_EVALUATE_SWAP, /* pe-st31 */ + PE_PRS_SRC_SNK_TRANSITION_TO_OFF, /* pe-st32 */ + PE_PRS_SRC_SNK_ASSERT_RD, /* pe-st33 */ + PE_PRS_SRC_SNK_WAIT_SOURCE_ON, /* pe-st34 */ + PE_PRS_SRC_SNK_SEND_SWAP, /* pe-st35 */ + PE_PRS_SNK_SRC_EVALUATE_SWAP, /* pe-st36 */ + PE_PRS_SNK_SRC_TRANSITION_TO_OFF, /* pe-st37 */ + PE_PRS_SNK_SRC_ASSERT_RP, /* pe-st38 */ + PE_PRS_SNK_SRC_SOURCE_ON, /* pe-st39 */ + PE_PRS_SNK_SRC_SEND_SWAP, /* pe-st40 */ + PE_VCS_EVALUATE_SWAP, /* pe-st41 */ + PE_VCS_SEND_SWAP, /* pe-st42 */ + PE_VCS_WAIT_FOR_VCONN_SWAP, /* pe-st43 */ + PE_VCS_TURN_ON_VCONN_SWAP, /* pe-st44 */ + PE_VCS_TURN_OFF_VCONN_SWAP, /* pe-st45 */ + PE_VCS_SEND_PS_RDY_SWAP, /* pe-st46 */ + PE_VCS_CBL_SEND_SOFT_RESET, /* pe-st47 */ + PE_VDM_IDENTITY_REQUEST_CBL, /* pe-st48 */ + PE_INIT_PORT_VDM_IDENTITY_REQUEST, /* pe-st49 */ + PE_INIT_VDM_SVIDS_REQUEST, /* pe-st50 */ + PE_INIT_VDM_MODES_REQUEST, /* pe-st51 */ + PE_VDM_REQUEST_DPM, /* pe-st52 */ + PE_VDM_RESPONSE, /* pe-st53 */ + PE_WAIT_FOR_ERROR_RECOVERY, /* pe-st54 */ + PE_BIST_TX, /* pe-st55 */ + PE_DEU_SEND_ENTER_USB, /* pe-st56 */ + PE_DR_GET_SINK_CAP, /* pe-st57 */ + PE_DR_SNK_GIVE_SOURCE_CAP, /* pe-st58 */ + PE_DR_SRC_GET_SOURCE_CAP, /* pe-st59 */ /* PD3.0 only states below here*/ /* UFP Data Reset States */ - PE_UDR_SEND_DATA_RESET, - PE_UDR_DATA_RESET_RECEIVED, - PE_UDR_TURN_OFF_VCONN, - PE_UDR_SEND_PS_RDY, - PE_UDR_WAIT_FOR_DATA_RESET_COMPLETE, + PE_UDR_SEND_DATA_RESET, /* pe-st60 */ + PE_UDR_DATA_RESET_RECEIVED, /* pe-st61 */ + PE_UDR_TURN_OFF_VCONN, /* pe-st62 */ + PE_UDR_SEND_PS_RDY, /* pe-st63 */ + PE_UDR_WAIT_FOR_DATA_RESET_COMPLETE, /* pe-st64 */ /* DFP Data Reset States */ - PE_DDR_SEND_DATA_RESET, - PE_DDR_DATA_RESET_RECEIVED, - PE_DDR_WAIT_FOR_VCONN_OFF, - PE_DDR_PERFORM_DATA_RESET, - PE_FRS_SNK_SRC_START_AMS, - PE_GIVE_BATTERY_CAP, - PE_GIVE_BATTERY_STATUS, - PE_GIVE_STATUS, - PE_SEND_ALERT, - PE_ALERT_RECEIVED, - PE_SRC_CHUNK_RECEIVED, - PE_SNK_CHUNK_RECEIVED, - PE_VCS_FORCE_VCONN, - PE_GET_REVISION, + PE_DDR_SEND_DATA_RESET, /* pe-st65 */ + PE_DDR_DATA_RESET_RECEIVED, /* pe-st66 */ + PE_DDR_WAIT_FOR_VCONN_OFF, /* pe-st67 */ + PE_DDR_PERFORM_DATA_RESET, /* pe-st68 */ + PE_FRS_SNK_SRC_START_AMS, /* pe-st69 */ + PE_GIVE_BATTERY_CAP, /* pe-st70 */ + PE_GIVE_BATTERY_STATUS, /* pe-st71 */ + PE_GIVE_STATUS, /* pe-st72 */ + PE_SEND_ALERT, /* pe-st73 */ + PE_ALERT_RECEIVED, /* pe-st74 */ + PE_SRC_CHUNK_RECEIVED, /* pe-st75 */ + PE_SNK_CHUNK_RECEIVED, /* pe-st76 */ + PE_VCS_FORCE_VCONN, /* pe-st77 */ + PE_GET_REVISION, /* pe-st78 */ }; /* -- cgit v1.2.1 From c0bbf8879b5faed713de29537c83a8e29dabe545 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 9 Nov 2022 15:46:15 -0800 Subject: npcx: avoid invalid VW signal index Prevent possibility of array[-1] access BUG=b:64477774 BRANCH=none TEST=none Signed-off-by: Boris Mittelberg Change-Id: I130b7d3872f857dc6e8dabca3f07d0d919b7ce64 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4018487 Code-Coverage: Zoss Reviewed-by: caveh jalali --- chip/npcx/espi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chip/npcx/espi.c b/chip/npcx/espi.c index d64a22860d..4cf5b0e80d 100644 --- a/chip/npcx/espi.c +++ b/chip/npcx/espi.c @@ -274,6 +274,9 @@ void espi_wait_vw_not_dirty(enum espi_vw_signal signal, unsigned int timeout_us) uint64_t timeout; sig_idx = espi_vw_get_signal_index(signal); + /* Cannot find signal index */ + if (sig_idx < 0) + return; for (offset = 0; offset < ESPI_VWEVSM_NUM; offset++) { uint8_t vw_idx = VWEVSM_IDX_GET(NPCX_VWEVSM(offset)); -- cgit v1.2.1 From 862296cdc067817281f5634968b701616c8a1965 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 15:45:18 -0600 Subject: zephyr: tests: Test charger.c charger_get_vsys_voltage() Test charger_get_vsys_voltage in common/charger.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: Iedbe7b1a4c2ecb40497e2076f3a24ac0deee8883 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000833 Reviewed-by: Yuval Peress Code-Coverage: Zoss --- .../src/test_common_charger_mocked.c | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index 9df5b79dd1..df74ebfb4e 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -29,6 +29,7 @@ FAKE_VALUE_FUNC(int, is_sourcing_otg_power, int, int); FAKE_VALUE_FUNC(enum ec_error_list, get_actual_current, int, int *); FAKE_VALUE_FUNC(enum ec_error_list, get_actual_voltage, int, int *); FAKE_VALUE_FUNC(enum ec_error_list, set_voltage, int, int); +FAKE_VALUE_FUNC(enum ec_error_list, get_vsys_voltage, int, int, int *); struct common_charger_mocked_driver_fixture { /* The original driver pointer that gets restored after the tests */ @@ -225,6 +226,48 @@ ZTEST_F(common_charger_mocked_driver, test_charger_set_voltage) zassert_equal(2000, set_voltage_fake.arg1_history[0]); } +ZTEST(common_charger_mocked_driver, test_charger_get_vsys_voltage__invalid) +{ + /* Cannot do chgnum bounds checking because + * charger_get_valid_chgnum() will convert chgnum to 0 unless + * CONFIG_CHARGER_SINGLE_CHIP is turned off. + */ + + /* get_vsys_voltage is NULL */ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + charger_get_vsys_voltage(CHG_NUM, NULL)); +} + +/** + * @brief Custom fake for get_vsys_voltage that can write to the output param + */ +static enum ec_error_list get_vsys_voltage_custom_fake(int chgnum, int port, + int *voltage) +{ + ARG_UNUSED(chgnum); + ARG_UNUSED(port); + + *voltage = 2000; + + return EC_SUCCESS; +} + +ZTEST_F(common_charger_mocked_driver, test_charger_get_vsys_voltage) +{ + int vsys_voltage; + + fixture->mock_driver.get_vsys_voltage = get_vsys_voltage; + get_vsys_voltage_fake.custom_fake = get_vsys_voltage_custom_fake; + + zassert_equal(EC_SUCCESS, + charger_get_vsys_voltage(CHG_NUM, &vsys_voltage)); + + zassert_equal(1, get_vsys_voltage_fake.call_count); + zassert_equal(CHG_NUM, get_vsys_voltage_fake.arg0_history[0]); + zassert_equal(CHG_NUM, get_vsys_voltage_fake.arg1_history[0]); + zassert_equal(2000, vsys_voltage); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -255,6 +298,7 @@ static void reset(void *data) RESET_FAKE(get_actual_current); RESET_FAKE(get_actual_voltage); RESET_FAKE(set_voltage); + RESET_FAKE(get_vsys_voltage); } static void teardown(void *data) -- cgit v1.2.1 From dfae23a168ea19d4df21d4b1d7624954b5c6705a Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 17:24:52 -0600 Subject: charger: Bounds check chgnum in charger_enable_bypass_mode() This function is public and does not validate the chgnum parameter, which can cause out-of-bounds access to an array. Add an ASSERT to protect against this. Also convert the enable parameter to a bool. BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: I54d374d53e28210af014edbe24638bbead1ef295 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000834 Reviewed-by: Yuval Peress Reviewed-by: Daisuke Nojiri Code-Coverage: Zoss --- common/charger.c | 5 ++++- include/charger.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common/charger.c b/common/charger.c index db780d59cf..caabd547c0 100644 --- a/common/charger.c +++ b/common/charger.c @@ -6,6 +6,7 @@ */ #include "battery_smart.h" +#include "builtin/assert.h" #include "charge_state_v2.h" #include "charger.h" #include "common.h" @@ -495,8 +496,10 @@ enum ec_error_list charger_discharge_on_ac(int enable) return rv; } -enum ec_error_list charger_enable_bypass_mode(int chgnum, int enable) +enum ec_error_list charger_enable_bypass_mode(int chgnum, bool enable) { + ASSERT(chgnum >= 0 && chgnum < board_get_charger_chip_count()); + if (!chg_chips[chgnum].drv->enable_bypass_mode) return EC_ERROR_UNIMPLEMENTED; return chg_chips[chgnum].drv->enable_bypass_mode(chgnum, enable); diff --git a/include/charger.h b/include/charger.h index e4c10ec7a9..df3f3f65dd 100644 --- a/include/charger.h +++ b/include/charger.h @@ -393,7 +393,7 @@ enum ec_error_list charger_enable_linear_charge(int chgnum, bool enable); * @param enable: Whether to enable or disable bypass mode. * @return EC_SUCCESS on success, error otherwise. */ -enum ec_error_list charger_enable_bypass_mode(int chgnum, int enable); +enum ec_error_list charger_enable_bypass_mode(int chgnum, bool enable); /** * Get the charger configuration for the number of battery cells -- cgit v1.2.1 From 871f6b34054a07cd68c7cfec459db272d000b434 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 2 Nov 2022 21:08:25 -0600 Subject: zephyr: tests: Test charger.c charger_enable_bypass_mode() Test charger_enable_bypass_mode in common/charger.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: If3c4a7686d67573e20f8a6fd1eef8e44ba0811ee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4000835 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- .../common_charger/src/test_common_charger_mocked.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index df74ebfb4e..6cbf8360f8 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -30,6 +30,7 @@ FAKE_VALUE_FUNC(enum ec_error_list, get_actual_current, int, int *); FAKE_VALUE_FUNC(enum ec_error_list, get_actual_voltage, int, int *); FAKE_VALUE_FUNC(enum ec_error_list, set_voltage, int, int); FAKE_VALUE_FUNC(enum ec_error_list, get_vsys_voltage, int, int, int *); +FAKE_VALUE_FUNC(enum ec_error_list, enable_bypass_mode, int, bool); struct common_charger_mocked_driver_fixture { /* The original driver pointer that gets restored after the tests */ @@ -268,6 +269,24 @@ ZTEST_F(common_charger_mocked_driver, test_charger_get_vsys_voltage) zassert_equal(2000, vsys_voltage); } +ZTEST(common_charger_mocked_driver, test_charger_enable_bypass_mode__invalid) +{ + /* enable_bypass_mode is NULL */ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + charger_enable_bypass_mode(CHG_NUM, false)); +} + +ZTEST_F(common_charger_mocked_driver, test_charger_enable_bypass_mode) +{ + fixture->mock_driver.enable_bypass_mode = enable_bypass_mode; + enable_bypass_mode_fake.return_val = 123; + + zassert_equal(123, charger_enable_bypass_mode(CHG_NUM, true)); + + zassert_equal(1, enable_bypass_mode_fake.call_count); + zassert_true(enable_bypass_mode_fake.arg1_history[0]); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -299,6 +318,7 @@ static void reset(void *data) RESET_FAKE(get_actual_voltage); RESET_FAKE(set_voltage); RESET_FAKE(get_vsys_voltage); + RESET_FAKE(enable_bypass_mode); } static void teardown(void *data) -- cgit v1.2.1 From a7ac3c24ef9ea655be4f8fb1a59bcd9b2c460f29 Mon Sep 17 00:00:00 2001 From: Raymond Chung Date: Tue, 1 Nov 2022 14:45:42 +0800 Subject: gaelin: Enable the fan control Fan control with custom fan table. BUG=b:249000573 BRANCH=None TEST=Thermal team verified thermal policy is expected. Change-Id: Ifbd3d8ffbc8035e5b3075bf840beccd158e28e18 Signed-off-by: Raymond Chung Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3995727 Code-Coverage: Zoss Reviewed-by: Derek Huang --- board/gaelin/board.h | 7 ++- board/gaelin/build.mk | 1 + board/gaelin/fans.c | 12 ++--- board/gaelin/pwm.c | 4 +- board/gaelin/thermal.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 board/gaelin/thermal.c diff --git a/board/gaelin/board.h b/board/gaelin/board.h index f113c6cffd..8323c99599 100644 --- a/board/gaelin/board.h +++ b/board/gaelin/board.h @@ -136,11 +136,10 @@ /* ADC */ #define CONFIG_ADC -/* - * TODO(b/197478860): Enable the fan control. We need - * to check the sensor value and adjust the fan speed. - */ +/* Fan */ #define CONFIG_FANS FAN_CH_COUNT +#define RPM_DEVIATION 1 +#define CONFIG_CUSTOM_FAN_CONTROL /* Include math_util for bitmask_uint64 used in pd_timers */ #define CONFIG_MATH_UTIL diff --git a/board/gaelin/build.mk b/board/gaelin/build.mk index 3de758d1bd..6961fb3f60 100644 --- a/board/gaelin/build.mk +++ b/board/gaelin/build.mk @@ -19,4 +19,5 @@ board-y+=i2c.o board-y+=led.o board-y+=pwm.o board-y+=sensors.o +board-y+=thermal.o board-y+=usbc_config.o diff --git a/board/gaelin/fans.c b/board/gaelin/fans.c index 6828438a10..5f54e6e63c 100644 --- a/board/gaelin/fans.c +++ b/board/gaelin/fans.c @@ -30,16 +30,10 @@ static const struct fan_conf fan_conf_0 = { .enable_gpio = GPIO_EN_PP5000_FAN, }; -/* - * TOOD(b/197478860): need to update for real fan - * - * Prototype fan spins at about 7200 RPM at 100% PWM. - * Set minimum at around 30% PWM. - */ static const struct fan_rpm fan_rpm_0 = { - .rpm_min = 2200, - .rpm_start = 2200, - .rpm_max = 7200, + .rpm_min = 2350, + .rpm_start = 2350, + .rpm_max = 4100, }; const struct fan_t fans[FAN_CH_COUNT] = { diff --git a/board/gaelin/pwm.c b/board/gaelin/pwm.c index 3d4335f453..fe7e82894a 100644 --- a/board/gaelin/pwm.c +++ b/board/gaelin/pwm.c @@ -16,8 +16,8 @@ const struct pwm_t pwm_channels[] = { PWM_CONFIG_DSLEEP, .freq = 2000 }, [PWM_CH_FAN] = { .channel = 5, - .flags = PWM_CONFIG_OPEN_DRAIN | PWM_CONFIG_DSLEEP, - .freq = 1000 }, + .flags = PWM_CONFIG_OPEN_DRAIN, + .freq = 25000 }, [PWM_CH_LED_RED] = { .channel = 2, .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, .freq = 2000 }, diff --git a/board/gaelin/thermal.c b/board/gaelin/thermal.c new file mode 100644 index 0000000000..e15e0043e1 --- /dev/null +++ b/board/gaelin/thermal.c @@ -0,0 +1,140 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "chipset.h" +#include "common.h" +#include "console.h" +#include "fan.h" +#include "hooks.h" +#include "host_command.h" +#include "temp_sensor.h" +#include "thermal.h" +#include "util.h" + +/* Console output macros */ +#define CPUTS(outstr) cputs(CC_THERMAL, outstr) +#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ##args) + +struct fan_step { + /* + * Sensor 1~4 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int8_t on[TEMP_SENSOR_COUNT]; + /* + * Sensor 1~4 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int8_t off[TEMP_SENSOR_COUNT]; + /* Fan rpm */ + int16_t rpm[FAN_CH_COUNT]; +}; + +static const struct fan_step fan_table[] = { + { + /* level 0 */ + .on = { 65, -1, -1, -1 }, + .off = { 0, -1, -1, -1 }, + .rpm = { 2350 }, + }, + { + /* level 1 */ + .on = { 80, -1, -1, -1 }, + .off = { 60, -1, -1, -1 }, + .rpm = { 2350 }, + }, + { + /* level 2 */ + .on = { 87, -1, -1, -1 }, + .off = { 75, -1, -1, -1 }, + .rpm = { 3250 }, + }, + { + /* level 3 */ + .on = { 91, -1, -1, -1 }, + .off = { 82, -1, -1, -1 }, + .rpm = { 3750 }, + }, + { + /* level 4 */ + .on = { 100, -1, -1, -1 }, + .off = { 86, -1, -1, -1 }, + .rpm = { 4100 }, + }, +}; +const int num_fan_levels = ARRAY_SIZE(fan_table); + +int fan_table_to_rpm(int fan, int *temp, enum temp_sensor_id temp_sensor) +{ + /* current fan level */ + static int current_level; + /* previous fan level */ + static int prev_current_level; + /* previous sensor temperature */ + static int prev_temp[TEMP_SENSOR_COUNT]; + int i; + int new_rpm = 0; + + /* + * Compare the current and previous temperature, we have + * the three paths: + * 1. decreasing path. (check the release point) + * 2. increasing path. (check the trigger point) + * 3. invariant path. (return the current RPM) + */ + if (temp[temp_sensor] < prev_temp[temp_sensor]) { + for (i = current_level; i > 0; i--) { + if (temp[temp_sensor] < fan_table[i].off[temp_sensor]) + current_level = i - 1; + else + break; + } + } else if (temp[temp_sensor] > prev_temp[temp_sensor]) { + for (i = current_level; i < num_fan_levels; i++) { + if (temp[temp_sensor] > fan_table[i].on[temp_sensor]) + current_level = i + 1; + else + break; + } + } + + if (current_level < 0) + current_level = 0; + if (current_level >= num_fan_levels) + current_level = num_fan_levels - 1; + + if (current_level != prev_current_level) { + CPRINTS("temp: %d, prev_temp: %d", temp[temp_sensor], + prev_temp[temp_sensor]); + CPRINTS("current_level: %d", current_level); + } + + prev_temp[temp_sensor] = temp[temp_sensor]; + prev_current_level = current_level; + + switch (fan) { + case FAN_CH_0: + new_rpm = fan_table[current_level].rpm[FAN_CH_0]; + break; + default: + break; + } + + return new_rpm; +} + +void board_override_fan_control(int fan, int *temp) +{ + if (chipset_in_state(CHIPSET_STATE_ON)) { + fan_set_rpm_mode(FAN_CH(fan), 1); + fan_set_rpm_target(FAN_CH(fan), + fan_table_to_rpm(FAN_CH(fan), temp, + TEMP_SENSOR_1_CPU)); + } else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) { + /* Stop fan when enter S0ix */ + fan_set_rpm_mode(FAN_CH(fan), 1); + fan_set_rpm_target(FAN_CH(fan), 0); + } +} -- cgit v1.2.1 From cf2f344cb8da7c4819336851e7a9fd8806484aa9 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 11:31:15 +0000 Subject: zephyr: battery: drop redundant compatible entries Drop two compatible entries from bindings that are not used directly, bur just included in other bindings. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Ia2a4a53713652204f76eac2e63d53cc09191c7d5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999724 Code-Coverage: Zoss Reviewed-by: Yuval Peress --- zephyr/dts/bindings/battery/battery-fuel-gauge.yaml | 2 -- zephyr/dts/bindings/battery/battery-info.yaml | 2 -- 2 files changed, 4 deletions(-) diff --git a/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml b/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml index d2fed4bfa6..83bd825236 100644 --- a/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml +++ b/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml @@ -5,8 +5,6 @@ description: | Battery fuel gauge parameters -compatible: "battery-fuel-gauge" - properties: manuf_name: description: | diff --git a/zephyr/dts/bindings/battery/battery-info.yaml b/zephyr/dts/bindings/battery/battery-info.yaml index 54e81cedeb..c188616260 100644 --- a/zephyr/dts/bindings/battery/battery-info.yaml +++ b/zephyr/dts/bindings/battery/battery-info.yaml @@ -8,8 +8,6 @@ description: Current is in milliamperes Temperature is in Celsius degrees -compatible: "battery-info" - properties: voltage_max: description: | -- cgit v1.2.1 From 889c2f908721929818a47092e050ae544bcb1020 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 9 Nov 2022 14:04:42 -0700 Subject: zephyr: tests: Test various error cases in `common/charger.c` Add coverage for a bunch of different error cases where a parameter might be out of range or a driver function is unimplemented BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: If4c8145e857ce0118c218bfe80643aaa9d57022f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4017485 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss Commit-Queue: Jeremy Bettis --- .../src/test_common_charger_mocked.c | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index 6cbf8360f8..f156b3f539 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -10,6 +10,7 @@ #include #include "charger.h" +#include "charge_ramp.h" #include "test/drivers/charger_utils.h" #include "test/drivers/test_state.h" @@ -287,6 +288,90 @@ ZTEST_F(common_charger_mocked_driver, test_charger_enable_bypass_mode) zassert_true(enable_bypass_mode_fake.arg1_history[0]); } +ZTEST(common_charger_mocked_driver, test_charger_get_params__error_flags) +{ + /* When one of the parameters cannot be retrieved, a corresponding flag + * is set. Since all of the driver functions are unimplemented by + * default, this should cause all error flags to be set. + */ + + struct charger_params params; + + charger_get_params(¶ms); + + zassert_true(params.flags & CHG_FLAG_BAD_CURRENT); + zassert_true(params.flags & CHG_FLAG_BAD_VOLTAGE); + zassert_true(params.flags & CHG_FLAG_BAD_INPUT_CURRENT); + zassert_true(params.flags & CHG_FLAG_BAD_STATUS); + zassert_true(params.flags & CHG_FLAG_BAD_OPTION); +} + +ZTEST(common_charger_mocked_driver, + test_charger_get_input_current_limit__invalid) +{ + zassert_equal(EC_ERROR_INVAL, + charger_get_input_current_limit(-1, false)); + zassert_equal(EC_ERROR_INVAL, + charger_get_input_current_limit(INT_MAX, false)); +} + +ZTEST(common_charger_mocked_driver, + test_charger_get_input_current_limit__unimpl) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + charger_get_input_current_limit(CHG_NUM, false)); +} + +ZTEST(common_charger_mocked_driver, test_charger_get_input_current__invalid) +{ + zassert_equal(EC_ERROR_INVAL, charger_get_input_current(-1, NULL)); + zassert_equal(EC_ERROR_INVAL, charger_get_input_current(INT_MAX, NULL)); +} + +ZTEST(common_charger_mocked_driver, test_charger_get_input_current__unimpl) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + charger_get_input_current(CHG_NUM, NULL)); +} + +ZTEST(common_charger_mocked_driver, test_charger_manufacturer_id__unimpl) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_manufacturer_id(NULL)); +} + +ZTEST(common_charger_mocked_driver, test_charger_device_id__unimpl) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_device_id(NULL)); +} + +ZTEST(common_charger_mocked_driver, test_charger_get_option__unimpl) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_get_option(NULL)); +} + +ZTEST(common_charger_mocked_driver, test_charger_set_option__unimpl) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_set_option(0)); +} + +ZTEST(common_charger_mocked_driver, test_chg_ramp_is_stable__unimpl) +{ + /* Returns 0 if ramp_is_stable not implemented */ + zassert_false(chg_ramp_is_stable()); +} + +ZTEST(common_charger_mocked_driver, test_chg_ramp_is_detected__unimpl) +{ + /* Returns 0 if ramp_is_detected not implemented */ + zassert_false(chg_ramp_is_detected()); +} + +ZTEST(common_charger_mocked_driver, test_chg_ramp_get_current_limit__unimpl) +{ + /* Returns 0 if ramp_get_current_limit not implemented */ + zassert_false(chg_ramp_get_current_limit()); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; -- cgit v1.2.1 From 9099c1b88f5c50e4383d49a311a89ade5ff28c98 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 9 Nov 2022 16:50:14 -0700 Subject: zephyr: tests: Test additional error cases in `common/charger.c` Test some more error cases in the various `common/charger.c` functions. Add a special type of mock for board_get_charger_chip_count() so we can cover cases when a board has 0 chargers. BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: I532282bad49f3b7663c50331c22aa9e0f3ae26b4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4017486 Reviewed-by: Tomasz Michalec Code-Coverage: Zoss --- .../src/test_common_charger_mocked.c | 130 +++++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index f156b3f539..68a67519f7 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -33,6 +33,31 @@ FAKE_VALUE_FUNC(enum ec_error_list, set_voltage, int, int); FAKE_VALUE_FUNC(enum ec_error_list, get_vsys_voltage, int, int, int *); FAKE_VALUE_FUNC(enum ec_error_list, enable_bypass_mode, int, bool); +/** + * @brief If non-NULL, board_get_charger_chip_count returns the value this + * pointer points to. + */ +static uint8_t *fake_charger_count; + +/** + * @brief Override of definition from common/charger.c. Allows adjusting the + * number of chargers. This is not an FFF mock because FFF mock return values + * default to 0 until the test code gets a change to update it, which can cause + * a race condition as the EC initializes. This function has the correct + * count as soon as the program starts, which is CHARGER_NUM chargers. + * + * @return uint8_t Number of charger chips + */ +uint8_t board_get_charger_chip_count(void) +{ + if (fake_charger_count) { + return *fake_charger_count; + } + + /* Default value */ + return CHARGER_NUM; +} + struct common_charger_mocked_driver_fixture { /* The original driver pointer that gets restored after the tests */ const struct charger_drv *saved_driver_ptr; @@ -334,44 +359,147 @@ ZTEST(common_charger_mocked_driver, test_charger_get_input_current__unimpl) charger_get_input_current(CHG_NUM, NULL)); } +ZTEST(common_charger_mocked_driver, test_charger_manufacturer_id__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_equal(EC_ERROR_INVAL, charger_manufacturer_id(NULL)); +} + ZTEST(common_charger_mocked_driver, test_charger_manufacturer_id__unimpl) { zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_manufacturer_id(NULL)); } +ZTEST(common_charger_mocked_driver, test_charger_device_id__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_equal(EC_ERROR_INVAL, charger_device_id(NULL)); +} + ZTEST(common_charger_mocked_driver, test_charger_device_id__unimpl) { zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_device_id(NULL)); } +ZTEST(common_charger_mocked_driver, test_charger_get_option__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_equal(EC_ERROR_INVAL, charger_get_option(NULL)); +} + ZTEST(common_charger_mocked_driver, test_charger_get_option__unimpl) { zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_get_option(NULL)); } +ZTEST(common_charger_mocked_driver, test_charger_set_option__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_equal(EC_ERROR_INVAL, charger_set_option(0)); +} + ZTEST(common_charger_mocked_driver, test_charger_set_option__unimpl) { zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_set_option(0)); } +ZTEST(common_charger_mocked_driver, test_chg_ramp_is_stable__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_false(chg_ramp_is_stable()); +} + ZTEST(common_charger_mocked_driver, test_chg_ramp_is_stable__unimpl) { /* Returns 0 if ramp_is_stable not implemented */ zassert_false(chg_ramp_is_stable()); } +ZTEST(common_charger_mocked_driver, test_chg_ramp_is_detected__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_false(chg_ramp_is_detected()); +} + ZTEST(common_charger_mocked_driver, test_chg_ramp_is_detected__unimpl) { /* Returns 0 if ramp_is_detected not implemented */ zassert_false(chg_ramp_is_detected()); } +ZTEST(common_charger_mocked_driver, test_chg_ramp_get_current_limit__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_false(chg_ramp_get_current_limit()); +} + ZTEST(common_charger_mocked_driver, test_chg_ramp_get_current_limit__unimpl) { /* Returns 0 if ramp_get_current_limit not implemented */ zassert_false(chg_ramp_get_current_limit()); } +ZTEST(common_charger_mocked_driver, test_charger_post_init__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_equal(EC_ERROR_INVAL, charger_post_init()); +} + +ZTEST(common_charger_mocked_driver, test_charger_post_init__unimpl) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_post_init()); +} + +ZTEST(common_charger_mocked_driver, test_charger_get_info__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_is_null(charger_get_info()); +} + +ZTEST(common_charger_mocked_driver, test_charger_get_info__unimpl) +{ + zassert_is_null(charger_get_info()); +} + +ZTEST(common_charger_mocked_driver, test_charger_get_status__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_equal(EC_ERROR_INVAL, charger_get_status(NULL)); +} + +ZTEST(common_charger_mocked_driver, test_charger_set_mode__invalid) +{ + uint8_t zero = 0; + + fake_charger_count = &zero; + zassert_equal(EC_ERROR_INVAL, charger_set_mode(0)); +} + +ZTEST(common_charger_mocked_driver, test_charger_set_mode__unimpl) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_set_mode(0)); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -404,6 +532,8 @@ static void reset(void *data) RESET_FAKE(set_voltage); RESET_FAKE(get_vsys_voltage); RESET_FAKE(enable_bypass_mode); + + fake_charger_count = NULL; } static void teardown(void *data) -- cgit v1.2.1 From bbee2bafbfbb5df95a25ff56d76b3cacce084b66 Mon Sep 17 00:00:00 2001 From: Archana Patni Date: Thu, 10 Nov 2022 10:27:57 +0530 Subject: ap_pwrseq: reset sleep state after a full resume This sleep state should be reset only after a full resume. Clearing it after suspend can create a state mismatch between ec and AP when slp_s0 toggles and then goes back to sleep in certain cases. The S0->S0S0ix transition in the power state machine looks up the sleep state variable. If there is a transition from s0ix to S0 in EC due to a SLP S0 signal toggle without a full system wake, the transition back to s0ix will not happen since the sleep state variable for host will not reflect a suspended state due to the reset. This patch fixes this issue by resetting the state only after a full resume. BUG=b:246231274 BRANCH=none TEST=zmake build nivviks Tested using 'powerd_dbus_suspend' on AP and observed no issues in dozing stress test. Change-Id: I147986966e9420a740cb1064d6122e28f71cd8b6 Signed-off-by: Subramony Sesha Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019704 Tested-by: Andrew McRae Reviewed-by: Andrew McRae Code-Coverage: Andrew McRae Tested-by: Deepti Deshatty Commit-Queue: Andrew McRae --- zephyr/subsys/ap_pwrseq/power_host_sleep.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zephyr/subsys/ap_pwrseq/power_host_sleep.c b/zephyr/subsys/ap_pwrseq/power_host_sleep.c index 30025d21ea..bc38215921 100644 --- a/zephyr/subsys/ap_pwrseq/power_host_sleep.c +++ b/zephyr/subsys/ap_pwrseq/power_host_sleep.c @@ -174,10 +174,11 @@ void ap_power_sleep_notify_transition(enum ap_power_sleep_type check_state) ap_power_ev_send_callbacks(AP_POWER_SUSPEND); } else if (check_state == AP_POWER_SLEEP_RESUME) { ap_power_ev_send_callbacks(AP_POWER_RESUME); + /* + * Transition is done; reset sleep state after resume. + */ + ap_power_sleep_set_notify(AP_POWER_SLEEP_NONE); } - - /* Transition is done; reset sleep state. */ - ap_power_sleep_set_notify(AP_POWER_SLEEP_NONE); } #endif /* CONFIG_AP_PWRSEQ_S0IX */ -- cgit v1.2.1 From ffc3b48d95968c98b1b83fb2f6872cd962ed3766 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 9 Nov 2022 16:28:28 -0800 Subject: i2ctrace: add safety check Prevent NULL dereference coming from get_i2c_port BUG=b:64477774 BRANCH=none TEST=none Signed-off-by: Boris Mittelberg Change-Id: Ib430832e135a8f48cd3773acd2ce9894444f7efe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019346 Reviewed-by: caveh jalali Code-Coverage: Zoss --- common/i2c_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/i2c_trace.c b/common/i2c_trace.c index c7207698b7..e7dde79bc4 100644 --- a/common/i2c_trace.c +++ b/common/i2c_trace.c @@ -67,7 +67,7 @@ static int command_i2ctrace_list(void) i2c_port = get_i2c_port(trace_entries[i].port); ccprintf("%-2zd %d %-8s 0x%X", i, trace_entries[i].port, #ifndef CONFIG_ZEPHYR - i2c_port->name, + i2c_port ? i2c_port->name : "invalid", #else "", #endif /* CONFIG_ZEPHYR */ -- cgit v1.2.1 From 90a568daaad4cff9ba4cab69bd3ad7959be456aa Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Thu, 10 Nov 2022 17:02:52 +0000 Subject: Revert "zephyr: generic button config driver" This reverts commit a14b72ba413fde3a7c7ace3153ca45c551c17bdd. Reason for revert: Creating generic gpio debounce driver Original change's description: > zephyr: generic button config driver > > Generic button config driver for zephyr > > BUG=b:234728861 > BRANCH=none > TEST=./twister -T zephyr/test > > Signed-off-by: Al Semjonovs > Change-Id: I98e48cc030c19f0b4463df9658d58f2af56570cd > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3765459 > Reviewed-by: Sam Hurst > Code-Coverage: Zoss Bug: b:234728861 Change-Id: Idfb05f020c7e7c2feefb9ac01afc3ad902317962 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021009 Reviewed-by: Keith Short Reviewed-by: Fabio Baltieri Commit-Queue: Al Semjonovs Code-Coverage: Zoss Tested-by: Al Semjonovs --- zephyr/dts/bindings/button/cros-ec,button-cfg.yaml | 39 ----- zephyr/shim/include/button_config.h | 96 ----------- zephyr/shim/include/gpio/gpio.h | 14 -- zephyr/shim/src/CMakeLists.txt | 1 - zephyr/shim/src/button_config.c | 175 ------------------- zephyr/test/drivers/CMakeLists.txt | 1 - zephyr/test/drivers/Kconfig | 3 - zephyr/test/drivers/boards/native_posix.overlay | 27 +-- zephyr/test/drivers/button_config/CMakeLists.txt | 5 - .../test/drivers/button_config/src/button_config.c | 188 --------------------- zephyr/test/drivers/testcase.yaml | 3 - 11 files changed, 1 insertion(+), 551 deletions(-) delete mode 100644 zephyr/dts/bindings/button/cros-ec,button-cfg.yaml delete mode 100644 zephyr/shim/include/button_config.h delete mode 100644 zephyr/shim/src/button_config.c delete mode 100644 zephyr/test/drivers/button_config/CMakeLists.txt delete mode 100644 zephyr/test/drivers/button_config/src/button_config.c diff --git a/zephyr/dts/bindings/button/cros-ec,button-cfg.yaml b/zephyr/dts/bindings/button/cros-ec,button-cfg.yaml deleted file mode 100644 index f46a24432e..0000000000 --- a/zephyr/dts/bindings/button/cros-ec,button-cfg.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2022 The Chromium OS Authors. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -description: | - Button config. - - Name - - Type - - GPIO handle - - Debounce time (us) - - Flags - -compatible: "cros-ec,button-cfg" - -child-binding: - description: Button configuration - properties: - button_name: - type: string - required: true - description: Button name - button_type: - type: int - required: false - description: Keyboard button type - spec: - type: phandle - required: true - gpio_int: - type: phandle - required: false - debounce_us: - type: int - required: true - description: Debounce time in microseconds - flags: - type: int - required: true - description: The zephyr gpio interrupt config flags. diff --git a/zephyr/shim/include/button_config.h b/zephyr/shim/include/button_config.h deleted file mode 100644 index 5599ded1ea..0000000000 --- a/zephyr/shim/include/button_config.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __BUTTON_CONFIG_H -#define __BUTTON_CONFIG_H - -#include -#include - -#include "include/ec_commands.h" - -#define BUTTON_CFG_COMPAT cros_ec_button_cfg -#define DT_BUTTON_CFG_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(BUTTON_CFG_COMPAT) - -#define BUTTON_CFG_ENUM(val) DT_CAT(BUTTON_CFG_, val) -#define BUTTON_CFG_TYPE(node) \ - BUTTON_CFG_ENUM(DT_STRING_UPPER_TOKEN(node, button_name)), - -enum button_cfg_type { -#if DT_NODE_EXISTS(DT_BUTTON_CFG_NODE) - DT_FOREACH_CHILD(DT_BUTTON_CFG_NODE, BUTTON_CFG_TYPE) -#endif - BUTTON_CFG_ENUM(COUNT), -}; - -#define BUTTON_FLAG_ACTIVE_HIGH BIT(0) -#define BUTTON_FLAG_DISABLED BIT(1) /* Button disabled */ - -struct button_config_v2 { - const char *name; - enum keyboard_button_type type; - uint32_t debounce_us; - uint8_t button_flags; - enum gpio_signal gpio; - const struct gpio_dt_spec spec; - void (*gpio_int_handler)(enum gpio_signal); - gpio_flags_t gpio_int_flags; -}; - -/** - * @brief Get the button cfg - * - * @param type - * @return const struct button_config_v2* - */ -const struct button_config_v2 *button_cfg_get(enum button_cfg_type type); - -/** - * @brief Get button name - * - * @param type - * @return const char* - */ -const char *button_get_name(enum button_cfg_type type); - -/** - * @brief Get button debounce time in microseconds - * - * @param type - * @return int - */ -int button_get_debounce_us(enum button_cfg_type type); - -/** - * @brief Enable interrupt for button - * - * @param type - */ -int button_enable_interrupt(enum button_cfg_type type); - -/** - * @brief Disable interrupt for button - * - * @param type - */ -int button_disable_interrupt(enum button_cfg_type type); - -/** - * @brief Get the logical level of button press - * - * @param type - * @return int - */ -int button_is_pressed(enum button_cfg_type type); - -/** - * @brief Get the physical level of button press - * - * @param type - * @return int - */ -int button_is_pressed_raw(enum button_cfg_type type); - -#endif /* __BUTTON_CONFIG_H */ diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h index ea606324fa..7d41c0fa02 100644 --- a/zephyr/shim/include/gpio/gpio.h +++ b/zephyr/shim/include/gpio/gpio.h @@ -9,20 +9,6 @@ #include #include -/* - * dt_flags is a uint8_t type. However, for platform/ec - * the GPIO flags in the devicetree are expanded past 8 bits - * to support the INPUT/OUTPUT and PULLUP/PULLDOWN properties. - * Cast back to a gpio_dt_flags to compile, discarding the bits - * that are not supported by the Zephyr GPIO API. - */ -#define CROS_EC_GPIO_DT_SPEC_GET(node_id, prop) \ - { \ - .port = DEVICE_DT_GET(DT_GPIO_CTLR(node_id, prop)), \ - .pin = DT_GPIO_PIN(node_id, prop), \ - .dt_flags = (gpio_dt_flags_t)DT_GPIO_FLAGS(node_id, prop), \ - } - /* * Validate interrupt flags are valid for the Zephyr GPIO driver. */ diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index d5de268be5..5aa94b31ce 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -2,7 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -zephyr_library_sources(button_config.c) zephyr_library_sources(console.c) zephyr_library_sources(crc.c) zephyr_library_sources(gpio.c) diff --git a/zephyr/shim/src/button_config.c b/zephyr/shim/src/button_config.c deleted file mode 100644 index e38cc35ee6..0000000000 --- a/zephyr/shim/src/button_config.c +++ /dev/null @@ -1,175 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include -#include -#include -#include -#include - -#include "include/button.h" -#include "gpio/gpio.h" -#include "gpio/gpio_int.h" -#include "button_config.h" - -LOG_MODULE_REGISTER(button_cfg, LOG_LEVEL_ERR); - -/* LCOV_EXCL_START */ -#ifdef TEST_BUILD -test_mockable int stub_gpio_pin_get(const struct device *d, gpio_pin_t p) -{ - LOG_DBG("Calling %s\n", __func__); - return gpio_pin_get(d, p); -} -test_mockable int stub_gpio_pin_get_raw(const struct device *d, gpio_pin_t p) -{ - LOG_DBG("Calling %s\n", __func__); - return gpio_pin_get_raw(d, p); -} - -#define gpio_pin_get stub_gpio_pin_get -#define gpio_pin_get_raw stub_gpio_pin_get_raw -#endif -/* LCOV_EXCL_STOP */ - -#define BUTTON_HANDLER_DECLARE(node) \ - extern void DT_STRING_TOKEN(DT_PHANDLE(node, gpio_int), \ - handler)(enum gpio_signal); - -#define BUTTON_CFG_DEF(node) \ - { .name = DT_PROP(node, button_name), \ - .type = DT_PROP_OR(node, button_type, 0), \ - .gpio = GPIO_SIGNAL(DT_PHANDLE(node, spec)), \ - .spec = CROS_EC_GPIO_DT_SPEC_GET(DT_PHANDLE(node, spec), gpios), \ - .gpio_int_handler = \ - DT_STRING_TOKEN(DT_PHANDLE(node, gpio_int), handler), \ - .gpio_int_flags = DT_PROP(DT_PHANDLE(node, gpio_int), flags), \ - .debounce_us = DT_PROP(node, debounce_us), \ - .button_flags = DT_PROP(node, flags) }, - -#if DT_NODE_EXISTS(DT_BUTTON_CFG_NODE) - -DT_FOREACH_CHILD(DT_BUTTON_CFG_NODE, BUTTON_HANDLER_DECLARE) - -static const struct button_config_v2 button_configs[] = { DT_FOREACH_CHILD( - DT_BUTTON_CFG_NODE, BUTTON_CFG_DEF) }; - -static struct gpio_callback int_cb_data[BUTTON_CFG_COUNT]; - -static bool button_is_valid(enum button_cfg_type type) -{ - return (type >= 0 && type < BUTTON_CFG_COUNT); -} - -const struct button_config_v2 *button_cfg_get(enum button_cfg_type type) -{ - const struct button_config_v2 *cfg = NULL; - - if (button_is_valid(type)) { - cfg = &button_configs[type]; - } - - return cfg; -} - -const char *button_get_name(enum button_cfg_type type) -{ - const char *name = "NULL"; - const struct button_config_v2 *cfg = button_cfg_get(type); - - if (cfg) { - name = cfg->name; - } - - return name; -} - -int button_get_debounce_us(enum button_cfg_type type) -{ - int debounce_time = 0; - const struct button_config_v2 *cfg = button_cfg_get(type); - - if (cfg) { - debounce_time = cfg->debounce_us; - } - - return debounce_time; -} - -void button_cb_handler(const struct device *dev, struct gpio_callback *cbdata, - uint32_t pins) -{ - const struct button_config_v2 *cfg = - button_cfg_get(cbdata - &int_cb_data[0]); - - if (cfg) { - cfg->gpio_int_handler(cfg->gpio); - } -} - -int button_enable_interrupt(enum button_cfg_type type) -{ - int retval = EC_ERROR_INVAL; - const struct button_config_v2 *cfg = button_cfg_get(type); - struct gpio_callback *cb; - gpio_flags_t flags; - - if (cfg) { - if (cfg->gpio_int_handler) { - cb = &int_cb_data[type]; - gpio_init_callback(cb, button_cb_handler, - BIT(cfg->spec.pin)); - gpio_add_callback(cfg->spec.port, cb); - } - flags = (cfg->gpio_int_flags | GPIO_INT_ENABLE) & - ~GPIO_INT_DISABLE; - - retval = gpio_pin_interrupt_configure(cfg->spec.port, - cfg->spec.pin, flags); - } - - return retval; -} - -int button_disable_interrupt(enum button_cfg_type type) -{ - int retval = EC_ERROR_INVAL; - const struct button_config_v2 *cfg = button_cfg_get(type); - - if (cfg) { - retval = gpio_pin_interrupt_configure( - cfg->spec.port, cfg->spec.pin, GPIO_INT_DISABLE); - } - - return retval; -} - -static int is_pressed(enum button_cfg_type type, - int (*gpio_pin_get_fn)(const struct device *, gpio_pin_t)) -{ - int pressed = 0; - const struct button_config_v2 *cfg = button_cfg_get(type); - - if (cfg) { - pressed = gpio_pin_get_fn(cfg->spec.port, cfg->spec.pin); - if (pressed < 0) { - LOG_ERR("Cannot read %s (%d)", cfg->name, type); - pressed = 0; - } - } - - return pressed; -} - -int button_is_pressed(enum button_cfg_type type) -{ - return is_pressed(type, gpio_pin_get); -} - -int button_is_pressed_raw(enum button_cfg_type type) -{ - return is_pressed(type, gpio_pin_get_raw); -} - -#endif /* DT_NODE_EXISTS(DT_BUTTON_CFG_NODE) */ diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index ede215b5bf..b03e3e4edd 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -47,7 +47,6 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_COMMANDS host_cmd) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_SYSTEM system) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS locate_chip) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON button) -add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON_CONFIG button_config) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_CONSOLE console) get_target_property(TEST_SOURCES_NEW app SOURCES) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index a256c0b700..acd6b0b19a 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -20,9 +20,6 @@ config LINK_TEST_SUITE_AP_VDM_CONTROL config LINK_TEST_SUITE_BUTTON bool "Link tests for common/button.c" -config LINK_TEST_SUITE_BUTTON_CONFIG - bool "Link tests for common/button_config" - config LINK_TEST_SUITE_CHARGESPLASH bool "Link and test the chargesplash tests" diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index 56f857f17e..d3e1d740ae 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -178,7 +178,7 @@ /* GPIO_PULL_UP will cause this start asserted, * i.e. not pressed. */ - gpios = <&gpio0 25 (GPIO_INPUT_PULL_UP)>; + gpios = <&gpio0 25 (GPIO_INPUT | GPIO_PULL_UP)>; enum-name = "GPIO_POWER_BUTTON_L"; }; gpio_src_vph_pwr_pg: src_vph_pwr_pg { @@ -304,11 +304,6 @@ flags = ; handler = "power_signal_interrupt"; }; - int_power_button: power_button { - irq-pin = <&gpio_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; int_wp_l: wp_l { irq-pin = <&gpio_wp_l>; flags = ; @@ -987,26 +982,6 @@ buffer-size = <200>; }; - button-cfg { - compatible = "cros-ec,button-cfg"; - - btn_power_button_cfg: power_button_cfg { - button_name = "POWER_BUTTON"; - button_type = <0>; - spec = <&gpio_ec_pwr_btn_odl>; - gpio_int = <&int_power_button>; - debounce_us = <30000>; - flags = <0>; - }; - btn_test_button_cfg: test_button_cfg { - button_name = "TEST_BUTTON"; - button_type = <0>; - spec = <&gpio_test>; - gpio_int = <&int_gpio_test>; - debounce_us = <30000>; - flags = <0>; - }; - }; }; &espi0 { diff --git a/zephyr/test/drivers/button_config/CMakeLists.txt b/zephyr/test/drivers/button_config/CMakeLists.txt deleted file mode 100644 index fa28c76137..0000000000 --- a/zephyr/test/drivers/button_config/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -zephyr_library_sources(src/button_config.c) diff --git a/zephyr/test/drivers/button_config/src/button_config.c b/zephyr/test/drivers/button_config/src/button_config.c deleted file mode 100644 index 3584d9b069..0000000000 --- a/zephyr/test/drivers/button_config/src/button_config.c +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * @file - * @brief Tests for button_config.c - */ - -#include -#include -#include -#include - -#include "button.h" -#include "button_config.h" -#include "common.h" -#include "ec_tasks.h" -#include "hooks.h" -#include "test/drivers/stubs.h" -#include "test/drivers/test_state.h" - -LOG_MODULE_REGISTER(button_cfg_test, LOG_LEVEL_INF); - -int stub_button_state; -int stub_get_button_state(const struct device *d, gpio_pin_t p) -{ - ARG_UNUSED(d); - ARG_UNUSED(p); - return stub_button_state; -} - -FAKE_VALUE_FUNC(int, stub_gpio_pin_get, const struct device *, gpio_pin_t); -FAKE_VALUE_FUNC(int, stub_gpio_pin_get_raw, const struct device *, gpio_pin_t); - -#define BUTTON_CFG_LIST(FAKE) \ - { \ - FAKE(stub_gpio_pin_get); \ - FAKE(stub_gpio_pin_get_raw); \ - } - -static void test_button_cfg_reset(void) -{ - BUTTON_CFG_LIST(RESET_FAKE); - - FFF_RESET_HISTORY(); - - stub_button_state = 0; - stub_gpio_pin_get_fake.custom_fake = gpio_pin_get; - stub_gpio_pin_get_raw_fake.custom_fake = gpio_pin_get_raw; -} - -static void button_config_rule(const struct ztest_unit_test *test, void *data) -{ - ARG_UNUSED(test); - ARG_UNUSED(data); - - test_button_cfg_reset(); -} - -ZTEST_RULE(button_config_rule, button_config_rule, button_config_rule); - -/** - * Make sure mocks are setup before HOOK(HOOK_PRIO_INIT_POWER_BUTTON) runs - * otherwise unexpected calls to mocks above occur prevent default - * gpio_pin_get behavior - */ -DECLARE_HOOK(HOOK_INIT, test_button_cfg_reset, HOOK_PRIO_FIRST); - -/** - * @brief Test Suite: Verifies button_config functionality. - */ -ZTEST_SUITE(button_config, drivers_predicate_post_main, NULL, NULL, NULL, NULL); - -/** - * @brief TestPurpose: Verify button_config initialization. - * - */ -ZTEST(button_config, test_button_config) -{ - const struct button_config_v2 *button; - - for (int i = 0; i < BUTTON_CFG_COUNT; i++) { - button = button_cfg_get(i); - - LOG_INF("button[%d]= {%s, %d, %d, {%d, 0x%X}, %d, %d}\n", i, - button->name, button->type, button->gpio, - button->spec.pin, button->spec.dt_flags, - button->debounce_us, button->button_flags); - } - - button = button_cfg_get(BUTTON_CFG_POWER_BUTTON); - - zassert_equal(button->type, 0, NULL); - zassert_equal(button->gpio, GPIO_POWER_BUTTON_L, NULL); - zassert_equal(button->debounce_us, 30000, NULL); - zassert_equal(button->button_flags, 0, NULL); -} - -/** - * @brief TestPurpose: Verify button_config pressed raw. - * - */ -ZTEST(button_config, test_button_pressed) -{ - stub_gpio_pin_get_fake.custom_fake = stub_get_button_state; - - stub_button_state = 1; - zassert_equal(1, button_is_pressed(BUTTON_CFG_POWER_BUTTON)); - - stub_button_state = 0; - zassert_equal(0, button_is_pressed(BUTTON_CFG_POWER_BUTTON)); - - stub_button_state = -1; - zassert_equal(0, button_is_pressed(BUTTON_CFG_POWER_BUTTON)); -} - -/** - * @brief TestPurpose: Verify button_config pressed raw. - * - */ -ZTEST(button_config, test_button_pressed_raw) -{ - stub_gpio_pin_get_raw_fake.custom_fake = stub_get_button_state; - - stub_button_state = 1; - zassert_equal(1, button_is_pressed_raw(BUTTON_CFG_POWER_BUTTON)); - - stub_button_state = 0; - zassert_equal(0, button_is_pressed_raw(BUTTON_CFG_POWER_BUTTON)); - - stub_button_state = -1; - zassert_equal(0, button_is_pressed_raw(BUTTON_CFG_POWER_BUTTON)); -} - -/** - * @brief TestPurpose: Verify button name. - * - */ -ZTEST(button_config, test_button_name) -{ - const char *name; - - name = button_get_name(BUTTON_CFG_POWER_BUTTON); - zassert_ok(strcmp(name, "POWER_BUTTON"), NULL); - - name = button_get_name(BUTTON_CFG_COUNT); - zassert_ok(strcmp(name, "NULL"), NULL); -} - -/** - * @brief TestPurpose: Verify button debounce. - * - */ -ZTEST(button_config, test_button_debounce) -{ - const uint32_t debounce_time_us = 30000; - - zassert_equal(debounce_time_us, - button_get_debounce_us(BUTTON_CFG_POWER_BUTTON), NULL); - - zassert_equal(0, button_get_debounce_us(BUTTON_CFG_COUNT), NULL); -} - -/** - * @brief TestPurpose: Verify button interrupt. - * - */ -extern bool gpio_test_interrupt_triggered; -ZTEST(button_config, test_button_interrupt) -{ - const struct button_config_v2 *cfg; - - cfg = button_cfg_get(BUTTON_CFG_TEST_BUTTON); - - gpio_test_interrupt_triggered = false; - - zassert_ok(button_disable_interrupt(BUTTON_CFG_TEST_BUTTON), NULL); - gpio_pin_set_raw(cfg->spec.port, cfg->spec.pin, 0); - gpio_pin_set_raw(cfg->spec.port, cfg->spec.pin, 1); - zassert_equal(gpio_test_interrupt_triggered, false); - - zassert_ok(button_enable_interrupt(BUTTON_CFG_TEST_BUTTON), NULL); - gpio_pin_set_raw(cfg->spec.port, cfg->spec.pin, 0); - gpio_pin_set_raw(cfg->spec.port, cfg->spec.pin, 1); - zassert_equal(gpio_test_interrupt_triggered, true); -} diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index f364612897..fa668ba949 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -39,9 +39,6 @@ tests: - CONFIG_PLATFORM_EC_CMD_BUTTON=y - CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y - CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y - drivers.button_config: - extra_configs: - - CONFIG_LINK_TEST_SUITE_BUTTON_CONFIG=y drivers.common_cbi: extra_configs: - CONFIG_LINK_TEST_SUITE_COMMON_CBI=y -- cgit v1.2.1 From 0f4a7cc6ed75d88f4689431e8894f453a9dc0ad2 Mon Sep 17 00:00:00 2001 From: Diana Z Date: Thu, 10 Nov 2022 11:16:24 -0700 Subject: Skyrim: Add VIF for PD testing Add a VIF to reflect the current skyrim PD capabilities for testing. BRANCH=None BUG=b:254391638 TEST=load onto latest USB-IF VIF editor and confirm no errors are seen Signed-off-by: Diana Z Change-Id: I499f541e8c5f3c3e18d53521eca7398d95204478 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021470 Reviewed-by: Robert Zieba Commit-Queue: Robert Zieba Code-Coverage: Zoss --- zephyr/program/skyrim/skyrim_vif.xml | 346 +++++++++++++++++++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 zephyr/program/skyrim/skyrim_vif.xml diff --git a/zephyr/program/skyrim/skyrim_vif.xml b/zephyr/program/skyrim/skyrim_vif.xml new file mode 100644 index 0000000000..28d6f19049 --- /dev/null +++ b/zephyr/program/skyrim/skyrim_vif.xml @@ -0,0 +1,346 @@ + + + 3.22 + + USB-IF + VIF Editor + 3.4.2.0 + + Google + skyrim + FIX-ME + 65535 + Port Product + End Product + + + + + + + + + 0 + Type-C® + + + DRP + DRP + + Both + + + + + + + + + Revision 3 + + + + + + + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 22500 mW + Shared + CPower + 22500 mW + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 1500 mW + + + + 3A @ 5V + + + + + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + + + + + + 100000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 20000 mV + + + + Variable + 4750 mV + 20000 mV + 5000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505F + 0000 + + + + + + + 1 + Type-C® + + + DRP + DRP + + Both + + + + + + + + + Revision 3 + + + + + + + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 22500 mW + Shared + CPower + 22500 mW + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + 3A @ 5V + + + + + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + + + + + + 100000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 20000 mV + + + + Variable + 4750 mV + 20000 mV + 5000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505F + 0000 + + -- cgit v1.2.1 From 0b7798dc00bc821be3e0a84d5dd9fd23f27d644a Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 9 Nov 2022 17:01:37 -0800 Subject: pd console command: cflush fix Move the cflush from being unreachable to being executed BUG=b:64477774 BRANCH=none TEST='make -j buildall' pass Signed-off-by: Boris Mittelberg Change-Id: I4334448311b52fce935ead4a600bb6fa1969f77a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019348 Code-Coverage: Zoss Reviewed-by: caveh jalali --- common/usbc/usb_pd_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/usbc/usb_pd_console.c b/common/usbc/usb_pd_console.c index c7eb215572..50f8fa8eb9 100644 --- a/common/usbc/usb_pd_console.c +++ b/common/usbc/usb_pd_console.c @@ -146,8 +146,8 @@ static case PD_DRP_FORCE_SOURCE: ccprintf("force source\n"); break; - cflush(); } + cflush(); } else { if (!strcasecmp(argv[3], "on")) pd_set_dual_role(port, -- cgit v1.2.1 From 03618e96ace3e95563af9476399b8f1f13266935 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Thu, 10 Nov 2022 03:18:02 -0700 Subject: test: verify board_tcpc_post_init is called Add a stub for the board_tcpc_post_init() and use the wrapper to verify it gets called. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I5ce0749f5f689db8cd3b67bfead825a9a4f3cf02 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4020036 Commit-Queue: Al Semjonovs Code-Coverage: Zoss Reviewed-by: Al Semjonovs Reviewed-by: Clayton Whitelaw --- zephyr/test/drivers/rt9490/src/bc12.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/zephyr/test/drivers/rt9490/src/bc12.c b/zephyr/test/drivers/rt9490/src/bc12.c index eae2308c93..7e7d9c2678 100644 --- a/zephyr/test/drivers/rt9490/src/bc12.c +++ b/zephyr/test/drivers/rt9490/src/bc12.c @@ -17,11 +17,13 @@ #include "timer.h" #include "usb_charge.h" +FAKE_VALUE_FUNC(int, board_tcpc_post_init, int); + static const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(rt9490)); static const struct emul *tcpci_emul = EMUL_DT_GET(DT_NODELABEL(tcpci_emul)); static const int chgnum = CHARGER_SOLO; -void run_bc12_test(int reg_value, enum charge_supplier expected_result) +static void run_bc12_test(int reg_value, enum charge_supplier expected_result) { int port = 0; @@ -29,7 +31,19 @@ void run_bc12_test(int reg_value, enum charge_supplier expected_result) tcpci_emul_set_reg(tcpci_emul, TCPC_REG_POWER_STATUS, TCPC_REG_POWER_STATUS_VBUS_PRES | TCPC_REG_POWER_STATUS_VBUS_DET); - zassert_ok(tcpc_config[port].drv->init(port), NULL); + + /* This is the same as calling tcpc_config[port].drv->init(port) but + * also calls our board_tcpc_post_init_fake stub. During the init, the + * other tasks are also running and will at times also call the same + * function. So the verification just checks that the call count + * increased and that the first history element matches the port we + * provided. + */ + RESET_FAKE(board_tcpc_post_init); + zassert_ok(tcpm_init(port)); + zassert_true(board_tcpc_post_init_fake.call_count > 0); + zassert_equal(port, board_tcpc_post_init_fake.arg0_history[0]); + zassert_true(tcpc_config[port].drv->check_vbus_level(port, VBUS_PRESENT), NULL); -- cgit v1.2.1 From 74a8b26c76919744b930d2916d15258f7c5842f7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 13 Jan 2022 13:08:23 -0800 Subject: tree: Remove stm32/hwtimer.c stm32/hwtimer.c simulates a 32-bit timer with two 16-bit timers. The only boards still using this file were "discovery" and "twinkie". "twinkie" is an STM32F072B, which has support for 32-bit timers (TIM2 and TIM3). See Section 18 "General-purpose Timers": https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1-stm32f0x2-stm32f0x8-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf. "discovery" is an STM32L152RC, which is a "Category 3" product that has the 32-bit timer TIM5. See Section 17 "General-purpose Timers" and "Table 3. STM32L15xxx product categories": https://www.st.com/resource/en/reference_manual/cd00240193-stm32l100xx-stm32l151xx-stm32l152xx-and-stm32l162xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf. BRANCH=none BUG=b:214423235 TEST=make buildall -j Signed-off-by: Tom Hughes Change-Id: I41b3a54bbbbce5d0dfee178b6fa87ff492646ce1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3388064 Reviewed-by: Patryk Duda Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- board/discovery/board.h | 13 +- board/twinkie/board.h | 5 +- chip/stm32/config-stm32l15x.h | 15 +- chip/stm32/hwtimer.c | 481 ------------------------------------------ 4 files changed, 26 insertions(+), 488 deletions(-) delete mode 100644 chip/stm32/hwtimer.c diff --git a/board/discovery/board.h b/board/discovery/board.h index e348454af1..0abb329285 100644 --- a/board/discovery/board.h +++ b/board/discovery/board.h @@ -17,6 +17,8 @@ #define CONFIG_STREAM_USART2 #define CONFIG_CMD_USART_INFO +#define CONFIG_STM_HWTIMER32 + /* * Allow dangerous commands all the time, since we don't have a write protect * switch. @@ -25,9 +27,14 @@ #ifndef __ASSEMBLER__ -/* Timer selection */ -#define TIM_CLOCK_MSB 3 -#define TIM_CLOCK_LSB 4 +/* Timer selection + * + * "discovery" is an STM32L152RC, which is a "Category 3" product that + * has the 32-bit timer TIM5. See Section 17 "General-purpose Timers" and + * "Table 3. STM32L15xxx product categories": + * https://www.st.com/resource/en/reference_manual/cd00240193-stm32l100xx-stm32l151xx-stm32l152xx-and-stm32l162xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf + */ +#define TIM_CLOCK32 5 #include "gpio_signal.h" diff --git a/board/twinkie/board.h b/board/twinkie/board.h index b1379fb15b..96aff32051 100644 --- a/board/twinkie/board.h +++ b/board/twinkie/board.h @@ -79,8 +79,7 @@ void trace_packets(void); void set_trace_mode(int mode); /* Timer selection */ -#define TIM_CLOCK_MSB 3 -#define TIM_CLOCK_LSB 15 +#define TIM_CLOCK32 2 #define TIM_ADC 16 #include "gpio_signal.h" @@ -105,6 +104,8 @@ enum usb_strings { USB_STR_COUNT }; +#define CONFIG_STM_HWTIMER32 + /* Standard-current Rp */ #define PD_SRC_VNC PD_SRC_DEF_VNC_MV #define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV diff --git a/chip/stm32/config-stm32l15x.h b/chip/stm32/config-stm32l15x.h index ae069ed005..d35b3ccbcf 100644 --- a/chip/stm32/config-stm32l15x.h +++ b/chip/stm32/config-stm32l15x.h @@ -24,8 +24,19 @@ #define CONFIG_RAM_BASE 0x20000000 #define CONFIG_RAM_SIZE 0x00004000 -/* Number of IRQ vectors on the NVIC */ -#define CONFIG_IRQ_COUNT 45 +/* Number of IRQ vectors on the NVIC + * + * Section 10.1 "Nested vectored interrupt controller (NVIC)" states: + * 45 maskable interrupt channels in Cat.1 and Cat.2 devices (see Table 49) + * 54 maskable interrupt channels in Cat.3 devices (see Table 50) and 57 + * channels in Cat.4, Cat.5 and Cat.6 devices (see Table 51). + * + * The only STM32L15 that we support is the "discovery" board is a "Category + * 3" device. See Section 1.5 "Product Category definition". + * + * https://www.st.com/resource/en/reference_manual/cd00240193-stm32l100xx-stm32l151xx-stm32l152xx-and-stm32l162xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf + */ +#define CONFIG_IRQ_COUNT 54 /* Lots of RAM, so use bigger UART buffer */ #undef CONFIG_UART_TX_BUF_SIZE diff --git a/chip/stm32/hwtimer.c b/chip/stm32/hwtimer.c deleted file mode 100644 index 3521347f3f..0000000000 --- a/chip/stm32/hwtimer.c +++ /dev/null @@ -1,481 +0,0 @@ -/* Copyright 2012 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Hardware timers driver */ - -#include "builtin/assert.h" -#include "clock.h" -#include "clock-f.h" -#include "common.h" -#include "hooks.h" -#include "hwtimer.h" -#include "panic.h" -#include "registers.h" -#include "task.h" -#include "timer.h" -#include "watchdog.h" - -/* - * Trigger select mapping for secondary timer from primary timer. This is - * unfortunately not very straightforward; there's no tidy way to do this - * algorithmically. To avoid burning memory for a lookup table, use macros to - * compute the offset. This also has the benefit that compilation will fail if - * an unsupported primary/secondary pairing is used. - */ -#ifdef CHIP_FAMILY_STM32F0 -/* - * Secondary Primary - * 1 15 2 3 17 - * 2 1 15 3 14 - * 3 1 2 15 14 - * 15 2 3 16 17 - * -------------------- - * ts = 0 1 2 3 - */ -#define STM32_TIM_TS_SECONDARY_1_PRIMARY_15 0 -#define STM32_TIM_TS_SECONDARY_1_PRIMARY_2 1 -#define STM32_TIM_TS_SECONDARY_1_PRIMARY_3 2 -#define STM32_TIM_TS_SECONDARY_1_PRIMARY_17 3 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_1 0 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_15 1 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_3 2 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_14 3 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_1 0 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_2 1 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_15 2 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_14 3 -#define STM32_TIM_TS_SECONDARY_15_PRIMARY_2 0 -#define STM32_TIM_TS_SECONDARY_15_PRIMARY_3 1 -#define STM32_TIM_TS_SECONDARY_15_PRIMARY_16 2 -#define STM32_TIM_TS_SECONDARY_15_PRIMARY_17 3 -#elif defined(CHIP_FAMILY_STM32F3) -/* - * Secondary Primary - * 2 19 15 3 14 - * 3 19 2 5 14 - * 4 19 2 3 15 - * 5 2 3 4 15 - * 12 4 5 13 14 - * 19 2 3 15 16 - * --------------------- - * ts = 0 1 2 3 - */ -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_19 0 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_15 1 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_3 2 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_14 3 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_19 0 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_2 1 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_5 2 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_14 3 -#define STM32_TIM_TS_SECONDARY_4_PRIMARY_19 0 -#define STM32_TIM_TS_SECONDARY_4_PRIMARY_2 1 -#define STM32_TIM_TS_SECONDARY_4_PRIMARY_3 2 -#define STM32_TIM_TS_SECONDARY_4_PRIMARY_15 3 -#define STM32_TIM_TS_SECONDARY_5_PRIMARY_2 0 -#define STM32_TIM_TS_SECONDARY_5_PRIMARY_3 1 -#define STM32_TIM_TS_SECONDARY_5_PRIMARY_4 2 -#define STM32_TIM_TS_SECONDARY_5_PRIMARY_15 3 -#define STM32_TIM_TS_SECONDARY_12_PRIMARY_4 0 -#define STM32_TIM_TS_SECONDARY_12_PRIMARY_5 1 -#define STM32_TIM_TS_SECONDARY_12_PRIMARY_13 2 -#define STM32_TIM_TS_SECONDARY_12_PRIMARY_14 3 -#define STM32_TIM_TS_SECONDARY_19_PRIMARY_2 0 -#define STM32_TIM_TS_SECONDARY_19_PRIMARY_3 1 -#define STM32_TIM_TS_SECONDARY_19_PRIMARY_15 2 -#define STM32_TIM_TS_SECONDARY_19_PRIMARY_16 3 -#else /* !CHIP_FAMILY_STM32F0 && !CHIP_FAMILY_STM32F3 */ -/* - * Secondary Primary - * 1 15 2 3 4 (STM32F100 only) - * 2 9 10 3 4 - * 3 9 2 11 4 - * 4 10 2 3 9 - * 9 2 3 10 11 (STM32L15x only) - * -------------------- - * ts = 0 1 2 3 - */ -#define STM32_TIM_TS_SECONDARY_1_PRIMARY_15 0 -#define STM32_TIM_TS_SECONDARY_1_PRIMARY_2 1 -#define STM32_TIM_TS_SECONDARY_1_PRIMARY_3 2 -#define STM32_TIM_TS_SECONDARY_1_PRIMARY_4 3 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_9 0 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_10 1 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_3 2 -#define STM32_TIM_TS_SECONDARY_2_PRIMARY_4 3 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_9 0 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_2 1 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_11 2 -#define STM32_TIM_TS_SECONDARY_3_PRIMARY_4 3 -#define STM32_TIM_TS_SECONDARY_4_PRIMARY_10 0 -#define STM32_TIM_TS_SECONDARY_4_PRIMARY_2 1 -#define STM32_TIM_TS_SECONDARY_4_PRIMARY_3 2 -#define STM32_TIM_TS_SECONDARY_4_PRIMARY_9 3 -#define STM32_TIM_TS_SECONDARY_9_PRIMARY_2 0 -#define STM32_TIM_TS_SECONDARY_9_PRIMARY_3 1 -#define STM32_TIM_TS_SECONDARY_9_PRIMARY_10 2 -#define STM32_TIM_TS_SECONDARY_9_PRIMARY_11 3 -#endif /* !CHIP_FAMILY_STM32F0 */ -#define TSMAP(secondary, primary) \ - CONCAT4(STM32_TIM_TS_SECONDARY_, secondary, _PRIMARY_, primary) - -/* - * Timers are defined per board. This gives us flexibility to work around - * timers which are dedicated to board-specific PWM sources. - */ -#define IRQ_MSB IRQ_TIM(TIM_CLOCK_MSB) -#define IRQ_LSB IRQ_TIM(TIM_CLOCK_LSB) -#define IRQ_WD IRQ_TIM(TIM_WATCHDOG) - -/* TIM1 has fancy names for its IRQs; remap count-up IRQ for the macro above */ -#if defined TIM_WATCHDOG && (TIM_WATCHDOG == 1) -#define STM32_IRQ_TIM1 STM32_IRQ_TIM1_BRK_UP_TRG -#else /* !(TIM_WATCHDOG == 1) */ -#define STM32_IRQ_TIM1 STM32_IRQ_TIM1_CC -#endif /* !(TIM_WATCHDOG == 1) */ - -#define TIM_BASE(n) CONCAT3(STM32_TIM, n, _BASE) -#define TIM_WD_BASE TIM_BASE(TIM_WATCHDOG) - -static uint32_t last_deadline; - -void __hw_clock_event_set(uint32_t deadline) -{ - last_deadline = deadline; - - if ((deadline >> 16) > STM32_TIM_CNT(TIM_CLOCK_MSB)) { - /* first set a match on the MSB */ - STM32_TIM_CCR1(TIM_CLOCK_MSB) = deadline >> 16; - /* disable LSB match */ - STM32_TIM_DIER(TIM_CLOCK_LSB) &= ~2; - /* Clear the match flags */ - STM32_TIM_SR(TIM_CLOCK_MSB) = ~2; - STM32_TIM_SR(TIM_CLOCK_LSB) = ~2; - /* Set the match interrupt */ - STM32_TIM_DIER(TIM_CLOCK_MSB) |= 2; - } - /* - * In the unlikely case where the MSB has increased and matched - * the deadline MSB before we set the match interrupt, as the STM - * hardware timer won't trigger an interrupt, we fall back to the - * following LSB event code to set another interrupt. - */ - if ((deadline >> 16) == STM32_TIM_CNT(TIM_CLOCK_MSB)) { - /* we can set a match on the LSB only */ - STM32_TIM_CCR1(TIM_CLOCK_LSB) = deadline & 0xffff; - /* disable MSB match */ - STM32_TIM_DIER(TIM_CLOCK_MSB) &= ~2; - /* Clear the match flags */ - STM32_TIM_SR(TIM_CLOCK_MSB) = ~2; - STM32_TIM_SR(TIM_CLOCK_LSB) = ~2; - /* Set the match interrupt */ - STM32_TIM_DIER(TIM_CLOCK_LSB) |= 2; - } - /* - * If the LSB deadline is already in the past and won't trigger an - * interrupt, the common code in process_timers will deal with the - * expired timer and automatically set the next deadline, we don't need - * to do anything here. - */ -} - -uint32_t __hw_clock_event_get(void) -{ - return last_deadline; -} - -void __hw_clock_event_clear(void) -{ - /* Disable the match interrupts */ - STM32_TIM_DIER(TIM_CLOCK_LSB) &= ~2; - STM32_TIM_DIER(TIM_CLOCK_MSB) &= ~2; -} - -uint32_t __hw_clock_source_read(void) -{ - uint32_t hi; - uint32_t lo; - - /* Ensure the two half-words are coherent */ - do { - hi = STM32_TIM_CNT(TIM_CLOCK_MSB); - lo = STM32_TIM_CNT(TIM_CLOCK_LSB); - } while (hi != STM32_TIM_CNT(TIM_CLOCK_MSB)); - - return (hi << 16) | lo; -} - -void __hw_clock_source_set(uint32_t ts) -{ - ASSERT(!is_interrupt_enabled()); - - /* Stop counting (LSB first, then MSB) */ - STM32_TIM_CR1(TIM_CLOCK_LSB) &= ~1; - STM32_TIM_CR1(TIM_CLOCK_MSB) &= ~1; - - /* Set new value to counters */ - STM32_TIM_CNT(TIM_CLOCK_MSB) = ts >> 16; - STM32_TIM_CNT(TIM_CLOCK_LSB) = ts & 0xffff; - - /* - * Clear status. We may clear information other than timer overflow - * (eg. event timestamp was matched) but: - * - Bits other than overflow are unused (see __hw_clock_source_irq()) - * - After setting timestamp software will trigger timer interrupt using - * task_trigger_irq() (see force_time() in common/timer.c). - * process_timers() is called from timer interrupt, so if "match" bit - * was present in status (think: some task timers are expired) - * process_timers() will handle that correctly. - */ - STM32_TIM_SR(TIM_CLOCK_MSB) = 0; - STM32_TIM_SR(TIM_CLOCK_LSB) = 0; - - /* Start counting (MSB first, then LSB) */ - STM32_TIM_CR1(TIM_CLOCK_MSB) |= 1; - STM32_TIM_CR1(TIM_CLOCK_LSB) |= 1; -} - -static void __hw_clock_source_irq(void) -{ - uint32_t stat_tim_msb = STM32_TIM_SR(TIM_CLOCK_MSB); - - /* Clear status */ - STM32_TIM_SR(TIM_CLOCK_LSB) = 0; - STM32_TIM_SR(TIM_CLOCK_MSB) = 0; - - /* - * Find expired timers and set the new timer deadline - * signal overflow if the 16-bit MSB counter has overflowed. - */ - process_timers(stat_tim_msb & 0x01); -} -DECLARE_IRQ(IRQ_MSB, __hw_clock_source_irq, 1); -DECLARE_IRQ(IRQ_LSB, __hw_clock_source_irq, 1); - -void __hw_timer_enable_clock(int n, int enable) -{ - volatile uint32_t *reg; - uint32_t mask = 0; - - /* - * Mapping of timers to reg/mask is split into a few different ranges, - * some specific to individual chips. - */ -#if defined(CHIP_FAMILY_STM32F0) - if (n == 1) { - reg = &STM32_RCC_APB2ENR; - mask = STM32_RCC_PB2_TIM1; - } -#elif defined(CHIP_FAMILY_STM32L) || defined(CHIP_FAMILY_STM32F4) - if (n >= 9 && n <= 11) { - reg = &STM32_RCC_APB2ENR; - mask = STM32_RCC_PB2_TIM9 << (n - 9); - } -#endif - -#if defined(CHIP_FAMILY_STM32F0) - if (n >= 15 && n <= 17) { - reg = &STM32_RCC_APB2ENR; - mask = STM32_RCC_PB2_TIM15 << (n - 15); - } -#endif - -#if defined(CHIP_FAMILY_STM32F0) || defined(CHIP_FAMILY_STM32F3) - if (n == 14) { - reg = &STM32_RCC_APB1ENR; - mask = STM32_RCC_PB1_TIM14; - } -#endif - -#if defined(CHIP_FAMILY_STM32F3) - if (n == 12 || n == 13) { - reg = &STM32_RCC_APB1ENR; - mask = STM32_RCC_PB1_TIM12 << (n - 12); - } - if (n == 18) { - reg = &STM32_RCC_APB1ENR; - mask = STM32_RCC_PB1_TIM18; - } - if (n == 19) { - reg = &STM32_RCC_APB2ENR; - mask = STM32_RCC_PB2_TIM19; - } -#endif - - if (n >= 2 && n <= 7) { - reg = &STM32_RCC_APB1ENR; - mask = STM32_RCC_PB1_TIM2 << (n - 2); - } - - if (!mask) - return; - - if (enable) - *reg |= mask; - else - *reg &= ~mask; -} - -static void update_prescaler(void) -{ - /* - * Pre-scaler value : - * TIM_CLOCK_LSB is counting microseconds; - * TIM_CLOCK_MSB is counting every TIM_CLOCK_LSB overflow. - * - * This will take effect at the next update event (when the current - * prescaler counter ticks down, or if forced via EGR). - */ - STM32_TIM_PSC(TIM_CLOCK_MSB) = 0; - STM32_TIM_PSC(TIM_CLOCK_LSB) = (clock_get_timer_freq() / SECOND) - 1; -} -DECLARE_HOOK(HOOK_FREQ_CHANGE, update_prescaler, HOOK_PRIO_DEFAULT); - -int __hw_clock_source_init(uint32_t start_t) -{ - /* - * we use 2 chained 16-bit counters to emulate a 32-bit one : - * TIM_CLOCK_MSB is the MSB (Secondary) - * TIM_CLOCK_LSB is the LSB (Primary) - */ - - /* Enable TIM_CLOCK_MSB and TIM_CLOCK_LSB clocks */ - __hw_timer_enable_clock(TIM_CLOCK_MSB, 1); - __hw_timer_enable_clock(TIM_CLOCK_LSB, 1); - - /* Delay 1 APB clock cycle after the clock is enabled */ - clock_wait_bus_cycles(BUS_APB, 1); - - /* - * Timer configuration : Upcounter, counter disabled, update event only - * on overflow. - */ - STM32_TIM_CR1(TIM_CLOCK_MSB) = 0x0004; - STM32_TIM_CR1(TIM_CLOCK_LSB) = 0x0004; - /* - * TIM_CLOCK_LSB (primary mode) generates a periodic trigger signal on - * each UEV - */ - STM32_TIM_CR2(TIM_CLOCK_MSB) = 0x0000; - STM32_TIM_CR2(TIM_CLOCK_LSB) = 0x0020; - - STM32_TIM_SMCR(TIM_CLOCK_MSB) = - 0x0007 | (TSMAP(TIM_CLOCK_MSB, TIM_CLOCK_LSB) << 4); - STM32_TIM_SMCR(TIM_CLOCK_LSB) = 0x0000; - - /* Auto-reload value : 16-bit free-running counters */ - STM32_TIM_ARR(TIM_CLOCK_MSB) = 0xffff; - STM32_TIM_ARR(TIM_CLOCK_LSB) = 0xffff; - - /* Update prescaler */ - update_prescaler(); - - /* Reload the pre-scaler */ - STM32_TIM_EGR(TIM_CLOCK_MSB) = 0x0001; - STM32_TIM_EGR(TIM_CLOCK_LSB) = 0x0001; - - /* Set up the overflow interrupt on TIM_CLOCK_MSB */ - STM32_TIM_DIER(TIM_CLOCK_MSB) = 0x0001; - STM32_TIM_DIER(TIM_CLOCK_LSB) = 0x0000; - - /* Override the count with the start value */ - STM32_TIM_CNT(TIM_CLOCK_MSB) = start_t >> 16; - STM32_TIM_CNT(TIM_CLOCK_LSB) = start_t & 0xffff; - - /* Start counting */ - STM32_TIM_CR1(TIM_CLOCK_MSB) |= 1; - STM32_TIM_CR1(TIM_CLOCK_LSB) |= 1; - - /* Enable timer interrupts */ - task_enable_irq(IRQ_MSB); - task_enable_irq(IRQ_LSB); - - return IRQ_LSB; -} - -#ifdef CONFIG_WATCHDOG_HELP - -void __keep watchdog_check(uint32_t excep_lr, uint32_t excep_sp) -{ - struct timer_ctlr *timer = (struct timer_ctlr *)TIM_WD_BASE; - - /* clear status */ - timer->sr = 0; - - watchdog_trace(excep_lr, excep_sp); -} - -void IRQ_HANDLER(IRQ_WD)(void) __attribute__((naked)); -void IRQ_HANDLER(IRQ_WD)(void) -{ - /* Naked call so we can extract raw LR and SP */ - asm volatile("mov r0, lr\n" - "mov r1, sp\n" - /* Must push registers in pairs to keep 64-bit aligned - * stack for ARM EABI. */ - "push {r0, lr}\n" - "bl watchdog_check\n" - "pop {r0,pc}\n"); -} -const struct irq_priority __keep IRQ_PRIORITY(IRQ_WD) - __attribute__((section(".rodata.irqprio"))) = { - IRQ_WD, 0 - }; /* put the watchdog - at the highest - priority - */ - -void hwtimer_setup_watchdog(void) -{ - struct timer_ctlr *timer = (struct timer_ctlr *)TIM_WD_BASE; - - /* Enable clock */ - __hw_timer_enable_clock(TIM_WATCHDOG, 1); - - /* Delay 1 APB clock cycle after the clock is enabled */ - clock_wait_bus_cycles(BUS_APB, 1); - - /* - * Timer configuration : Down counter, counter disabled, update - * event only on overflow. - */ - timer->cr1 = 0x0014 | BIT(7); - - /* TIM (secondary mode) uses TIM_CLOCK_LSB as internal trigger */ - timer->smcr = 0x0007 | (TSMAP(TIM_WATCHDOG, TIM_CLOCK_LSB) << 4); - - /* - * The auto-reload value is based on the period between rollovers for - * TIM_CLOCK_LSB. Since TIM_CLOCK_LSB runs at 1MHz, it will overflow - * in 65.536ms. We divide our required watchdog period by this amount - * to obtain the number of times TIM_CLOCK_LSB can overflow before we - * generate an interrupt. - */ - timer->arr = timer->cnt = CONFIG_AUX_TIMER_PERIOD_MS * MSEC / BIT(16); - - /* count on every TIM_CLOCK_LSB overflow */ - timer->psc = 0; - - /* Reload the pre-scaler from arr when it goes below zero */ - timer->egr = 0x0000; - - /* setup the overflow interrupt */ - timer->dier = 0x0001; - - /* Start counting */ - timer->cr1 |= 1; - - /* Enable timer interrupts */ - task_enable_irq(IRQ_WD); -} - -void hwtimer_reset_watchdog(void) -{ - struct timer_ctlr *timer = (struct timer_ctlr *)TIM_WD_BASE; - - timer->cnt = timer->arr; -} - -#endif /* defined(CONFIG_WATCHDOG_HELP) */ -- cgit v1.2.1 From d51ac2581392e0c27304b2aac01dbcca5b572d64 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Thu, 10 Nov 2022 12:46:46 -0700 Subject: test: host command on main thread Verify that we can take over the main thread for the host command task. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: Ib11ee3a428778f733e9c8e2aef13056c8e1935d4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021476 Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/Kconfig | 3 + .../drivers/host_command_thread/CMakeLists.txt | 5 ++ zephyr/test/drivers/host_command_thread/src/main.c | 83 ++++++++++++++++++++++ zephyr/test/drivers/testcase.yaml | 3 + 5 files changed, 95 insertions(+) create mode 100644 zephyr/test/drivers/host_command_thread/CMakeLists.txt create mode 100644 zephyr/test/drivers/host_command_thread/src/main.c diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index b03e3e4edd..e5b39fde6b 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -48,6 +48,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_SYSTEM system) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS locate_chip) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON button) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_CONSOLE console) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_CMD_THREAD host_command_thread) get_target_property(TEST_SOURCES_NEW app SOURCES) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index acd6b0b19a..21f18db9ef 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -120,4 +120,7 @@ config LINK_TEST_SUITE_CONSOLE bool "Link and test the console tests" select UART_INTERRUPT_DRIVEN +config LINK_TEST_SUITE_HOST_CMD_THREAD + bool "Link and test the host command thread override tests" + source "Kconfig.zephyr" diff --git a/zephyr/test/drivers/host_command_thread/CMakeLists.txt b/zephyr/test/drivers/host_command_thread/CMakeLists.txt new file mode 100644 index 0000000000..9386414deb --- /dev/null +++ b/zephyr/test/drivers/host_command_thread/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +target_sources(app PRIVATE src/main.c) diff --git a/zephyr/test/drivers/host_command_thread/src/main.c b/zephyr/test/drivers/host_command_thread/src/main.c new file mode 100644 index 0000000000..633942258e --- /dev/null +++ b/zephyr/test/drivers/host_command_thread/src/main.c @@ -0,0 +1,83 @@ +/* Copyright 2022 The ChromiumOS Authors. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * @file main.c + * + * WARNING: + * Do not add tests to this binary. This test messes with the main thread and + * can only run a single test function. + */ +#include + +#include +#include + +#include "host_command.h" +#include "task.h" +#include "test/drivers/test_state.h" + +#define CUSTOM_COMMAND_ID 0x0088 + +/* Pointer to the main thread, defined in kernel/init.c */ +extern struct k_thread z_main_thread; + +/* 0 - did not run, 1 - true, -1 - false */ +static int last_check_main_thread_result; + +static enum ec_status check_main_thread(struct host_cmd_handler_args *args) +{ + last_check_main_thread_result = in_host_command_main() ? 1 : -1; + return EC_RES_SUCCESS; +} + +DECLARE_HOST_COMMAND(CUSTOM_COMMAND_ID, check_main_thread, EC_VER_MASK(0)); + +static void fake_main_thread(void *a, void *b, void *c) +{ + host_command_main(); +} + +K_THREAD_STACK_DEFINE(fake_main_thread_stack, 4000); + +ZTEST_SUITE(host_cmd_thread, drivers_predicate_post_main, NULL, NULL, NULL, + NULL); + +ZTEST(host_cmd_thread, test_takeover) +{ + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_SIMPLE(CUSTOM_COMMAND_ID, 0); + const char expected_thread_name[] = "HOSTCMD"; + struct k_thread fake_main_thread_data; + k_tid_t tid = k_thread_create( + &fake_main_thread_data, fake_main_thread_stack, + K_THREAD_STACK_SIZEOF(fake_main_thread_stack), fake_main_thread, + NULL, NULL, NULL, 1, 0, K_NO_WAIT); + + /* Wait for the thread to start */ + k_msleep(500); + + /* Get the name of the thread (must be done after the sleep) */ + const char *main_thread_name = k_thread_name_get(&z_main_thread); + + /* Verify that the thread is not the hostcmd thread */ + zassert_equal(EC_TASK_PRIORITY(EC_TASK_HOSTCMD_PRIO), + k_thread_priority_get(&z_main_thread)); + zassert_equal(strlen(expected_thread_name), strlen(main_thread_name)); + zassert_mem_equal(expected_thread_name, main_thread_name, + strlen(expected_thread_name)); + + /* Try running a host command */ + host_command_received(&args); + k_msleep(1000); + + /* Make sure that the host command ran, the result should be -1 because + * it's not the original main thread. + */ + zassert_equal(-1, last_check_main_thread_result); + + /* Kill the extra thread */ + k_thread_abort(tid); +} diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index fa668ba949..ed7c9b5635 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -206,3 +206,6 @@ tests: drivers.usbc_vconn_swap: extra_configs: - CONFIG_LINK_TEST_SUITE_USBC_VCONN_SWAP=y + drivers.host_cmd_thread: + extra_configs: + - CONFIG_LINK_TEST_SUITE_HOST_CMD_THREAD=y -- cgit v1.2.1 From 192e0921442bdacd7b15e8bbcf2a2f37ad876a7f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 13 Jan 2022 14:03:03 -0800 Subject: tree: Remove CONFIG_STM_HWTIMER32 CONFIG_STM_HWTIMER32 was used to choose between a 32-bit timer and 16-bit timer. The 16-bit timer code was removed in https://crrev.com/c/3388064, so we no longer need this config. Command used: git grep --name-only CONFIG_STM_HWTIMER |\ xargs sed -i '/CONFIG_STM_HWTIMER32/d' BRANCH=none BUG=b:214423235 TEST=make buildall -j Signed-off-by: Tom Hughes Change-Id: I89da8915cd5a467975cd8f90e734ea2b11f18cb3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3388065 Code-Coverage: Zoss Reviewed-by: Patryk Duda --- baseboard/honeybuns/baseboard.h | 1 - baseboard/kukui/baseboard.h | 1 - baseboard/nucleo-f412zg/base-board.h | 1 - baseboard/nucleo-h743zi/base-board.h | 1 - board/c2d2/board.h | 1 - board/chocodile_vpdmcu/board.h | 1 - board/coffeecake/board.h | 1 - board/dingdong/board.h | 1 - board/discovery-stm32f072/board.h | 1 - board/discovery/board.h | 2 -- board/elm/board.h | 1 - board/fluffy/board.h | 1 - board/fusb307bgevb/board.h | 1 - board/hammer/board.h | 1 - board/hatch_fp/board.h | 1 - board/hoho/board.h | 1 - board/hyperdebug/board.h | 1 - board/nocturne_fp/board.h | 1 - board/nucleo-f072rb/board.h | 1 - board/nucleo-f411re/board.h | 1 - board/nucleo-g431rb/board.h | 1 - board/oak/board.h | 1 - board/pdeval-stm32f072/board.h | 1 - board/plankton/board.h | 1 - board/polyberry/board.h | 1 - board/prism/board.h | 1 - board/rainier/board.h | 1 - board/scarlet/board.h | 1 - board/servo_micro/board.h | 1 - board/servo_v4/board.h | 1 - board/servo_v4p1/board.h | 1 - board/stm32f446e-eval/board.h | 1 - board/stm32l476g-eval/board.h | 1 - board/sweetberry/board.h | 1 - board/tigertail/board.h | 1 - board/twinkie/board.h | 2 -- chip/stm32/build.mk | 4 +--- include/config.h | 3 --- util/config_allowed.txt | 1 - 39 files changed, 1 insertion(+), 45 deletions(-) diff --git a/baseboard/honeybuns/baseboard.h b/baseboard/honeybuns/baseboard.h index 4dd218f57d..a2dc18ccdb 100644 --- a/baseboard/honeybuns/baseboard.h +++ b/baseboard/honeybuns/baseboard.h @@ -61,7 +61,6 @@ /* 48 MHz SYSCLK clock frequency */ #define CPU_CLOCK 48000000 -#define CONFIG_STM_HWTIMER32 #define TIM_CLOCK32 2 #define TIM_CLOCK_MSB 3 #define TIM_CLOCK_LSB 15 diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h index d1ba87702e..d2985faea5 100644 --- a/baseboard/kukui/baseboard.h +++ b/baseboard/kukui/baseboard.h @@ -274,7 +274,6 @@ #undef CONFIG_HIBERNATE #define CONFIG_SPI_CONTROLLER -#define CONFIG_STM_HWTIMER32 #define CONFIG_WATCHDOG_HELP #undef CONFIG_UART_CONSOLE #define CONFIG_UART_CONSOLE 1 diff --git a/baseboard/nucleo-f412zg/base-board.h b/baseboard/nucleo-f412zg/base-board.h index 0ce6c226e2..a7bca6067f 100644 --- a/baseboard/nucleo-f412zg/base-board.h +++ b/baseboard/nucleo-f412zg/base-board.h @@ -168,7 +168,6 @@ #define CONFIG_RNG #define CONFIG_SHA256 #define CONFIG_SHA256_UNROLLED -#define CONFIG_STM_HWTIMER32 #define CONFIG_WP_ACTIVE_HIGH #ifndef TEST_BUILD diff --git a/baseboard/nucleo-h743zi/base-board.h b/baseboard/nucleo-h743zi/base-board.h index eb4b8ac1fa..f86c6dc8d4 100644 --- a/baseboard/nucleo-h743zi/base-board.h +++ b/baseboard/nucleo-h743zi/base-board.h @@ -99,7 +99,6 @@ #define CONFIG_SHA256_UNROLLED #undef CONFIG_SHAREDLIB_SIZE #define CONFIG_SHAREDLIB_SIZE 0 -#define CONFIG_STM_HWTIMER32 #define CONFIG_WATCHDOG_HELP #define CONFIG_WP_ACTIVE_HIGH diff --git a/board/c2d2/board.h b/board/c2d2/board.h index 6b1ac69efd..c1b450f482 100644 --- a/board/c2d2/board.h +++ b/board/c2d2/board.h @@ -34,7 +34,6 @@ #undef CONFIG_UART_RX_DMA /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC /* USB Configuration */ diff --git a/board/chocodile_vpdmcu/board.h b/board/chocodile_vpdmcu/board.h index 596407628e..0e0ff70ab8 100644 --- a/board/chocodile_vpdmcu/board.h +++ b/board/chocodile_vpdmcu/board.h @@ -55,7 +55,6 @@ #undef CONFIG_LID_SWITCH #define CONFIG_LOW_POWER_IDLE #define CONFIG_LTO -#define CONFIG_STM_HWTIMER32 #undef CONFIG_TASK_PROFILING #undef CONFIG_UART_TX_BUF_SIZE #undef CONFIG_UART_TX_DMA diff --git a/board/coffeecake/board.h b/board/coffeecake/board.h index 966a5b2516..9c7a2643d0 100644 --- a/board/coffeecake/board.h +++ b/board/coffeecake/board.h @@ -18,7 +18,6 @@ #define CONFIG_UART_CONSOLE 1 /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_ADC #define CONFIG_BOARD_PRE_INIT #define CONFIG_CMD_CHARGER diff --git a/board/dingdong/board.h b/board/dingdong/board.h index c0372c9322..52c3b740e4 100644 --- a/board/dingdong/board.h +++ b/board/dingdong/board.h @@ -15,7 +15,6 @@ #define CONFIG_UART_CONSOLE 1 /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_ADC #define CONFIG_BOARD_PRE_INIT #define CONFIG_HW_CRC diff --git a/board/discovery-stm32f072/board.h b/board/discovery-stm32f072/board.h index d5db803b65..b112f14f9f 100644 --- a/board/discovery-stm32f072/board.h +++ b/board/discovery-stm32f072/board.h @@ -23,7 +23,6 @@ #define CONFIG_UART_CONSOLE 2 /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC /* USB Configuration */ diff --git a/board/discovery/board.h b/board/discovery/board.h index 0abb329285..a722408e81 100644 --- a/board/discovery/board.h +++ b/board/discovery/board.h @@ -17,8 +17,6 @@ #define CONFIG_STREAM_USART2 #define CONFIG_CMD_USART_INFO -#define CONFIG_STM_HWTIMER32 - /* * Allow dangerous commands all the time, since we don't have a write protect * switch. diff --git a/board/elm/board.h b/board/elm/board.h index 10cb6bb75d..2dc53dab75 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -73,7 +73,6 @@ #define CONFIG_USB_CHARGER #define CONFIG_SPI #define CONFIG_SPI_CONTROLLER -#define CONFIG_STM_HWTIMER32 #define CONFIG_VBOOT_HASH #undef CONFIG_WATCHDOG_HELP #define CONFIG_SWITCH diff --git a/board/fluffy/board.h b/board/fluffy/board.h index 1309c41901..604e67d9b8 100644 --- a/board/fluffy/board.h +++ b/board/fluffy/board.h @@ -38,7 +38,6 @@ #define USB_EP_COUNT 2 /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_ADC #define CONFIG_I2C diff --git a/board/fusb307bgevb/board.h b/board/fusb307bgevb/board.h index 5e45b346b7..8d2fdfcfed 100644 --- a/board/fusb307bgevb/board.h +++ b/board/fusb307bgevb/board.h @@ -29,7 +29,6 @@ #define CONFIG_UART_CONSOLE 2 /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC #define CONFIG_I2C #define CONFIG_I2C_CONTROLLER diff --git a/board/hammer/board.h b/board/hammer/board.h index bce7dc39f4..ac6131798b 100644 --- a/board/hammer/board.h +++ b/board/hammer/board.h @@ -83,7 +83,6 @@ #define CONFIG_LTO #define CONFIG_FORCE_CONSOLE_RESUME #define CONFIG_MATH_UTIL -#define CONFIG_STM_HWTIMER32 /* USB Configuration */ #define CONFIG_USB diff --git a/board/hatch_fp/board.h b/board/hatch_fp/board.h index d36a9228c1..9e900a126a 100644 --- a/board/hatch_fp/board.h +++ b/board/hatch_fp/board.h @@ -235,7 +235,6 @@ #define CONFIG_SHA256 #define CONFIG_SHA256_UNROLLED #define CONFIG_SPI -#define CONFIG_STM_HWTIMER32 #define CONFIG_WP_ACTIVE_HIGH #define CONFIG_PANIC_STRIP_GPR diff --git a/board/hoho/board.h b/board/hoho/board.h index 7768ab7293..f6421fdaf0 100644 --- a/board/hoho/board.h +++ b/board/hoho/board.h @@ -15,7 +15,6 @@ #define CONFIG_UART_CONSOLE 1 /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_ADC #define CONFIG_BOARD_PRE_INIT #define CONFIG_CMD_SPI_FLASH diff --git a/board/hyperdebug/board.h b/board/hyperdebug/board.h index 9d15311784..86c2c88ad0 100644 --- a/board/hyperdebug/board.h +++ b/board/hyperdebug/board.h @@ -36,7 +36,6 @@ #undef CONFIG_UART_RX_DMA /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC #undef CONFIG_PVD /* diff --git a/board/nocturne_fp/board.h b/board/nocturne_fp/board.h index e7d34445b0..d95df6101a 100644 --- a/board/nocturne_fp/board.h +++ b/board/nocturne_fp/board.h @@ -110,7 +110,6 @@ #define CONFIG_SHA256 #define CONFIG_SHA256_UNROLLED #define CONFIG_SPI -#define CONFIG_STM_HWTIMER32 #undef CONFIG_TASK_PROFILING #define CONFIG_WATCHDOG_HELP #define CONFIG_WP_ACTIVE_HIGH diff --git a/board/nucleo-f072rb/board.h b/board/nucleo-f072rb/board.h index d807209564..bd957d35db 100644 --- a/board/nucleo-f072rb/board.h +++ b/board/nucleo-f072rb/board.h @@ -16,7 +16,6 @@ #define CONFIG_UART_CONSOLE 2 /* Optional features */ -#define CONFIG_STM_HWTIMER32 #ifdef CTS_MODULE #undef STM32_IRQ_EXT2_3_PRIORITY diff --git a/board/nucleo-f411re/board.h b/board/nucleo-f411re/board.h index d4e299dcff..3b7d5f1bf1 100644 --- a/board/nucleo-f411re/board.h +++ b/board/nucleo-f411re/board.h @@ -19,7 +19,6 @@ /* Optional features */ #undef CONFIG_LID_SWITCH #undef CONFIG_HIBERNATE -#define CONFIG_STM_HWTIMER32 #define CONFIG_WATCHDOG_HELP #define CONFIG_TASK_PROFILING diff --git a/board/nucleo-g431rb/board.h b/board/nucleo-g431rb/board.h index 905b4ea110..e2df8d2547 100644 --- a/board/nucleo-g431rb/board.h +++ b/board/nucleo-g431rb/board.h @@ -12,7 +12,6 @@ #define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */ #define CPU_CLOCK 48000000 -#define CONFIG_STM_HWTIMER32 #define TIM_CLOCK32 2 #define TIM_CLOCK_MSB 3 #define TIM_CLOCK_LSB 15 diff --git a/board/oak/board.h b/board/oak/board.h index 6f5ed3fc87..6b40f812fd 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -105,7 +105,6 @@ #define CONFIG_USB_PD_VBUS_DETECT_TCPC #define CONFIG_SPI #define CONFIG_SPI_CONTROLLER -#define CONFIG_STM_HWTIMER32 #define CONFIG_VBOOT_HASH #undef CONFIG_WATCHDOG_HELP #define CONFIG_SWITCH diff --git a/board/pdeval-stm32f072/board.h b/board/pdeval-stm32f072/board.h index 4cb55573f4..6ba7923b8e 100644 --- a/board/pdeval-stm32f072/board.h +++ b/board/pdeval-stm32f072/board.h @@ -21,7 +21,6 @@ #define CONFIG_HW_CRC #define CONFIG_I2C #define CONFIG_I2C_CONTROLLER -#define CONFIG_STM_HWTIMER32 /* USB Power Delivery configuration */ #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_TCPMV1 diff --git a/board/plankton/board.h b/board/plankton/board.h index 224364269b..a17bd30c3c 100644 --- a/board/plankton/board.h +++ b/board/plankton/board.h @@ -16,7 +16,6 @@ #define CONFIG_UART_CONSOLE 2 /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_USB_POWER_DELIVERY #define CONFIG_USB_PD_TCPMV1 #define CONFIG_USB_PD_ALT_MODE diff --git a/board/polyberry/board.h b/board/polyberry/board.h index 41069f2722..1390bb996c 100644 --- a/board/polyberry/board.h +++ b/board/polyberry/board.h @@ -60,7 +60,6 @@ #undef CONFIG_WATCHDOG /* Optional features */ -#define CONFIG_STM_HWTIMER32 /* * Allow dangerous commands all the time, since we don't have a write protect diff --git a/board/prism/board.h b/board/prism/board.h index 5c3cabce53..42768de2e7 100644 --- a/board/prism/board.h +++ b/board/prism/board.h @@ -111,7 +111,6 @@ #define CONFIG_LTO #define CONFIG_FORCE_CONSOLE_RESUME #define CONFIG_MATH_UTIL -#define CONFIG_STM_HWTIMER32 /* USB Configuration */ #define CONFIG_USB diff --git a/board/rainier/board.h b/board/rainier/board.h index 463a1e4a05..745ebeaca8 100644 --- a/board/rainier/board.h +++ b/board/rainier/board.h @@ -22,7 +22,6 @@ #define CONFIG_POWER_COMMON #define CONFIG_SPI #define CONFIG_SPI_CONTROLLER -#define CONFIG_STM_HWTIMER32 /* Source RTCCLK from external 32.768kHz source on PC15/OSC32_IN. */ #define CONFIG_STM32_CLOCK_LSE #define CONFIG_SWITCH diff --git a/board/scarlet/board.h b/board/scarlet/board.h index 4691d74391..0f96e0208a 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -32,7 +32,6 @@ #define CONFIG_POWER_COMMON #define CONFIG_SPI #define CONFIG_SPI_CONTROLLER -#define CONFIG_STM_HWTIMER32 /* Source RTCCLK from external 32.768kHz source on PC15/OSC32_IN. */ #define CONFIG_STM32_CLOCK_LSE #define CONFIG_SWITCH diff --git a/board/servo_micro/board.h b/board/servo_micro/board.h index 801b67e07e..109a40409d 100644 --- a/board/servo_micro/board.h +++ b/board/servo_micro/board.h @@ -30,7 +30,6 @@ #undef CONFIG_UART_RX_DMA /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC #define CONFIG_PVD /* See 'Programmable voltage detector characteristics' in the STM32F072x8 diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h index 289c117989..c219f7c70a 100644 --- a/board/servo_v4/board.h +++ b/board/servo_v4/board.h @@ -35,7 +35,6 @@ #define CONFIG_CMD_USART_INFO /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC #define CONFIG_PVD /* See 'Programmable voltage detector characteristics' in the STM32F072x8 diff --git a/board/servo_v4p1/board.h b/board/servo_v4p1/board.h index b6c7915c6c..4debd67b49 100644 --- a/board/servo_v4p1/board.h +++ b/board/servo_v4p1/board.h @@ -97,7 +97,6 @@ #undef CONFIG_UART_RX_DMA /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC #define CONFIG_PVD /* diff --git a/board/stm32f446e-eval/board.h b/board/stm32f446e-eval/board.h index 4ae9117829..667483d81f 100644 --- a/board/stm32f446e-eval/board.h +++ b/board/stm32f446e-eval/board.h @@ -56,7 +56,6 @@ #undef CONFIG_WATCHDOG /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_DMA_HELP #define CONFIG_FLASH_CROS diff --git a/board/stm32l476g-eval/board.h b/board/stm32l476g-eval/board.h index 26ea530e4e..40c7fb0eca 100644 --- a/board/stm32l476g-eval/board.h +++ b/board/stm32l476g-eval/board.h @@ -33,7 +33,6 @@ #endif /* Optional features */ -#define CONFIG_STM_HWTIMER32 #ifdef CTS_MODULE_I2C #define CONFIG_I2C diff --git a/board/sweetberry/board.h b/board/sweetberry/board.h index 4387cd4094..4d945f5dc4 100644 --- a/board/sweetberry/board.h +++ b/board/sweetberry/board.h @@ -77,7 +77,6 @@ #undef CONFIG_WATCHDOG /* Optional features */ -#define CONFIG_STM_HWTIMER32 /* * Allow dangerous commands all the time, since we don't have a write protect diff --git a/board/tigertail/board.h b/board/tigertail/board.h index ea4d11db06..26e6af5985 100644 --- a/board/tigertail/board.h +++ b/board/tigertail/board.h @@ -24,7 +24,6 @@ #undef CONFIG_UART_RX_DMA /* Optional features */ -#define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC /* USB Configuration */ diff --git a/board/twinkie/board.h b/board/twinkie/board.h index 96aff32051..808053d146 100644 --- a/board/twinkie/board.h +++ b/board/twinkie/board.h @@ -104,8 +104,6 @@ enum usb_strings { USB_STR_COUNT }; -#define CONFIG_STM_HWTIMER32 - /* Standard-current Rp */ #define PD_SRC_VNC PD_SRC_DEF_VNC_MV #define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk index 1fc14a15fa..72984eec5f 100644 --- a/chip/stm32/build.mk +++ b/chip/stm32/build.mk @@ -33,8 +33,6 @@ CORE:=cortex-m CFLAGS_CPU+=-mcpu=cortex-m3 endif -# Select between 16-bit and 32-bit timer for clock source -TIMER_TYPE=$(if $(CONFIG_STM_HWTIMER32),32,) DMA_TYPE=$(if $(CHIP_FAMILY_STM32F4)$(CHIP_FAMILY_STM32H7),-stm32f4,) SPI_TYPE=$(if $(CHIP_FAMILY_STM32H7),-stm32h7,) @@ -48,7 +46,7 @@ chip-$(CONFIG_FPU)+=fpu.o chip-$(CONFIG_SPI)+=spi.o chip-$(CONFIG_SPI_CONTROLLER)+=spi_controller$(SPI_TYPE).o chip-$(CONFIG_COMMON_GPIO)+=gpio.o gpio-$(CHIP_FAMILY).o -chip-$(CONFIG_COMMON_TIMER)+=hwtimer$(TIMER_TYPE).o +chip-$(CONFIG_COMMON_TIMER)+=hwtimer32.o chip-$(CONFIG_I2C)+=i2c-$(CHIP_FAMILY).o chip-$(CONFIG_ITE_FLASH_SUPPORT)+=i2c_ite_flash_support.o chip-$(CONFIG_STREAM_USART)+=usart.o usart-$(CHIP_FAMILY).o diff --git a/include/config.h b/include/config.h index e7b3b76683..10de8f80bf 100644 --- a/include/config.h +++ b/include/config.h @@ -4001,9 +4001,6 @@ /* Default stack size to use for tasks, in bytes */ #undef CONFIG_STACK_SIZE -/* Use 32-bit timer for clock source on stm32. */ -#undef CONFIG_STM_HWTIMER32 - /* Compile charger detect for STM32 */ #undef CONFIG_STM32_CHARGER_DETECT diff --git a/util/config_allowed.txt b/util/config_allowed.txt index bdf8e0eca8..650bd50cce 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -820,7 +820,6 @@ CONFIG_STM32_CLOCK_HSE_HZ CONFIG_STM32_CLOCK_LSE CONFIG_STM32_EXTENDED_RESET_FLAGS CONFIG_STM32_SPI1_CONTROLLER -CONFIG_STM_HWTIMER32 CONFIG_STREAM_SIGNATURE CONFIG_STREAM_USART CONFIG_STREAM_USART1 -- cgit v1.2.1 From 9f93cd862f02642407086eb9e050c0456f747ab7 Mon Sep 17 00:00:00 2001 From: Leila Lin Date: Wed, 9 Nov 2022 09:46:14 +0800 Subject: frostflow: Setup typeC1 port mux Setup typeC1 port mux for frostflow project. C1 port will only use ps8818, remove anx7483's setting. BRANCH=None BUG=b:258153920 TEST=zmake build --coverage frostflow TEST=Verify typeC1 port can project LOW_COVERAGE_REASON=no unit tests for skyrim yet Signed-off-by: Leila Lin Change-Id: Ie67c0b8f400fb12e163dae6ca38330dc87e3dafd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4014347 Code-Coverage: Zoss Tested-by: LeilaCY Lin Reviewed-by: SamSP Liu Commit-Queue: LeilaCY Lin Reviewed-by: Diana Z --- zephyr/program/skyrim/frostflow.dts | 12 +---- .../program/skyrim/src/frostflow/usb_mux_config.c | 53 ---------------------- 2 files changed, 1 insertion(+), 64 deletions(-) diff --git a/zephyr/program/skyrim/frostflow.dts b/zephyr/program/skyrim/frostflow.dts index 1ed0b4cb2b..15767237a5 100644 --- a/zephyr/program/skyrim/frostflow.dts +++ b/zephyr/program/skyrim/frostflow.dts @@ -61,11 +61,6 @@ }; &i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - }; ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; status = "okay"; @@ -97,14 +92,9 @@ &usbc_port1 { ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + usb-mux-chain-1-ps8818 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; }; }; diff --git a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c b/zephyr/program/skyrim/src/frostflow/usb_mux_config.c index e641e0d649..0f95b24b1a 100644 --- a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c +++ b/zephyr/program/skyrim/src/frostflow/usb_mux_config.c @@ -56,59 +56,6 @@ int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) return anx7483_set_default_tuning(me, mux_state); } -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) { CPRINTSUSB("C1: PS8818 mux using default tuning"); -- cgit v1.2.1 From 468e5684c8838e424b786c6ad66fde5f0075a32c Mon Sep 17 00:00:00 2001 From: Leila Lin Date: Thu, 10 Nov 2022 17:31:34 +0800 Subject: frostflow: Setup typeC0 port mux Setup typeC0 port mux for frostflow project. C0 port has no retimer, remove anx7483's setting. BRANCH=None BUG=b:258287656 TEST=zmake build --coverage frostflow TEST=Verify typeC0 port can project LOW_COVERAGE_REASON=no unit tests for skyrim yet Signed-off-by: Leila Lin Change-Id: I30b4d1be112d0b244d0e15d3f28e80506f077469 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4020015 Code-Coverage: Zoss Reviewed-by: Diana Z Tested-by: LeilaCY Lin Reviewed-by: SamSP Liu Commit-Queue: LeilaCY Lin --- zephyr/program/skyrim/frostflow.dts | 14 +++++--------- zephyr/program/skyrim/prj_frostflow.conf | 2 -- zephyr/program/skyrim/src/frostflow/usb_mux_config.c | 14 +++----------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/zephyr/program/skyrim/frostflow.dts b/zephyr/program/skyrim/frostflow.dts index 15767237a5..ffc2fff237 100644 --- a/zephyr/program/skyrim/frostflow.dts +++ b/zephyr/program/skyrim/frostflow.dts @@ -52,14 +52,6 @@ }; }; -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - }; -}; - &i2c1_0 { ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; @@ -82,11 +74,15 @@ }; }; +&amd_fp6_port0 { + board-set = "board_c0_amd_fp6_mux_set"; +}; + &usbc_port0 { ppc = <&ppc_port0>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + usb-muxes = <&amd_fp6_port0>; }; }; diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf index d347d3e435..d72ac2b9c6 100644 --- a/zephyr/program/skyrim/prj_frostflow.conf +++ b/zephyr/program/skyrim/prj_frostflow.conf @@ -21,8 +21,6 @@ CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000 # Only Frostflow has the PCT2075 CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - # Keyboard CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y diff --git a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c b/zephyr/program/skyrim/src/frostflow/usb_mux_config.c index 0f95b24b1a..2ec1dda0be 100644 --- a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c +++ b/zephyr/program/skyrim/src/frostflow/usb_mux_config.c @@ -5,22 +5,14 @@ /* Frostflow board-specific USB-C mux configuration */ -#include - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" #include "ioexpander.h" -#include "usb_mux.h" #include "usbc/usb_muxes.h" #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) /* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * USB C0 (general) and C1 (just ps8815 DB) use IOEX pins to * indicate flipped polarity to a protection switch. */ static int ioex_set_flip(int port, mux_state_t mux_state) @@ -48,12 +40,12 @@ static int ioex_set_flip(int port, mux_state_t mux_state) return EC_SUCCESS; } -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +int board_c0_amd_fp6_mux_set(const struct usb_mux *me, mux_state_t mux_state) { /* Set the SBU polarity mux */ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - return anx7483_set_default_tuning(me, mux_state); + return EC_SUCCESS; } int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -- cgit v1.2.1 From d81db5fe71e650a998a82a6208f61339cee057ef Mon Sep 17 00:00:00 2001 From: FrankChu Date: Tue, 25 Oct 2022 15:56:09 +0800 Subject: marasov: Initial EC image Create the initial EC image for the marasov variant by copying the brya reference board EC files into a new directory named for the variant. (Auto-Generated by create_initial_ec_image.sh version 1.5.0). BUG=b:254365935 BRANCH=None TEST=make BOARD=marasov Signed-off-by: FrankChu Change-Id: I8aaabd471a9cc00fa3de10bbb2a73f37288a2571 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3996548 Code-Coverage: Zoss Reviewed-by: Kyle Lin Commit-Queue: Kyle Lin --- board/marasov/battery.c | 109 +++++++++ board/marasov/board.c | 57 +++++ board/marasov/board.h | 267 ++++++++++++++++++++ board/marasov/build.mk | 25 ++ board/marasov/charger.c | 90 +++++++ board/marasov/ec.tasklist | 32 +++ board/marasov/fans.c | 89 +++++++ board/marasov/fw_config.c | 46 ++++ board/marasov/fw_config.h | 54 ++++ board/marasov/generated-gpio.inc | 125 ++++++++++ board/marasov/gpio.inc | 43 ++++ board/marasov/i2c.c | 81 ++++++ board/marasov/keyboard.c | 25 ++ board/marasov/led.c | 90 +++++++ board/marasov/pwm.c | 71 ++++++ board/marasov/sensors.c | 392 +++++++++++++++++++++++++++++ board/marasov/usbc_config.c | 517 +++++++++++++++++++++++++++++++++++++++ board/marasov/usbc_config.h | 24 ++ board/marasov/vif_override.xml | 148 +++++++++++ util/build_with_clang.py | 1 + 20 files changed, 2286 insertions(+) create mode 100644 board/marasov/battery.c create mode 100644 board/marasov/board.c create mode 100644 board/marasov/board.h create mode 100644 board/marasov/build.mk create mode 100644 board/marasov/charger.c create mode 100644 board/marasov/ec.tasklist create mode 100644 board/marasov/fans.c create mode 100644 board/marasov/fw_config.c create mode 100644 board/marasov/fw_config.h create mode 100644 board/marasov/generated-gpio.inc create mode 100644 board/marasov/gpio.inc create mode 100644 board/marasov/i2c.c create mode 100644 board/marasov/keyboard.c create mode 100644 board/marasov/led.c create mode 100644 board/marasov/pwm.c create mode 100644 board/marasov/sensors.c create mode 100644 board/marasov/usbc_config.c create mode 100644 board/marasov/usbc_config.h create mode 100644 board/marasov/vif_override.xml diff --git a/board/marasov/battery.c b/board/marasov/battery.c new file mode 100644 index 0000000000..f80ed9e9e4 --- /dev/null +++ b/board/marasov/battery.c @@ -0,0 +1,109 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery pack vendor provided charging profile + */ + +#include "battery_fuel_gauge.h" +#include "cbi.h" +#include "common.h" +#include "compile_time_macros.h" +#include "gpio.h" +/* + * Battery info for all Brya battery types. Note that the fields + * start_charging_min/max and charging_min/max are not used for the charger. + * The effective temperature limits are given by discharging_min/max_c. + * + * Fuel Gauge (FG) parameters which are used for determining if the battery + * is connected, the appropriate ship mode (battery cutoff) command, and the + * charge/discharge FETs status. + * + * Ship mode (battery cutoff) requires 2 writes to the appropriate smart battery + * register. For some batteries, the charge/discharge FET bits are set when + * charging/discharging is active, in other types, these bits set mean that + * charging/discharging is disabled. Therefore, in addition to the mask for + * these bits, a disconnect value must be specified. Note that for TI fuel + * gauge, the charge/discharge FET status is found in Operation Status (0x54), + * but a read of Manufacturer Access (0x00) will return the lower 16 bits of + * Operation status which contains the FET status bits. + * + * The assumption for battery types supported is that the charge/discharge FET + * status can be read with a sb_read() command and therefore, only the register + * address, mask, and disconnect value need to be provided. + */ +const struct board_batt_params board_battery_info[] = { + /* POW-TECH GQA05 Battery Information */ + [BATTERY_POWER_TECH] = { + /* BQ40Z50 Fuel Gauge */ + .fuel_gauge = { + .manuf_name = "POW-TECH", + .device_name = "BATGQA05L22", + .ship_mode = { + .reg_addr = 0x00, + .reg_data = { 0x0010, 0x0010 }, + }, + .fet = { + .mfgacc_support = 1, + .reg_addr = 0x00, + .reg_mask = 0x2000, /* XDSG */ + .disconnect_val = 0x2000, + } + }, + .batt_info = { + .voltage_max = TARGET_WITH_MARGIN(13050, 5), + .voltage_normal = 11400, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 280, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 45, + .charging_min_c = 0, + .charging_max_c = 45, + .discharging_min_c = -10, + .discharging_max_c = 60, + }, + }, + /* LGC L17L3PB0 Battery Information */ + /* + * Battery info provided by ODM on b/143477210, comment #11 + */ + [BATTERY_LGC011] = { + .fuel_gauge = { + .manuf_name = "LGC", + .ship_mode = { + .reg_addr = 0x00, + .reg_data = { 0x0010, 0x0010 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x6000, + .disconnect_val = 0x6000, + } + }, + .batt_info = { + .voltage_max = TARGET_WITH_MARGIN(13200, 5), + .voltage_normal = 11550, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 45, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 75, + }, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); + +const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_POWER_TECH; + +enum battery_present battery_hw_present(void) +{ + enum gpio_signal batt_pres; + + batt_pres = GPIO_EC_BATT_PRES_ODL; + + /* The GPIO is low when the battery is physically present */ + return gpio_get_level(batt_pres) ? BP_NO : BP_YES; +} diff --git a/board/marasov/board.c b/board/marasov/board.c new file mode 100644 index 0000000000..58ed5f9f12 --- /dev/null +++ b/board/marasov/board.c @@ -0,0 +1,57 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "button.h" +#include "cbi.h" +#include "charge_ramp.h" +#include "charger.h" +#include "common.h" +#include "console.h" +#include "driver/accelgyro_lsm6dso.h" +#include "driver/accel_lis2dw12.h" +#include "driver/als_tcs3400.h" +#include "fw_config.h" +#include "gpio.h" +#include "gpio_signal.h" +#include "hooks.h" +#include "lid_switch.h" +#include "power_button.h" +#include "power.h" +#include "registers.h" +#include "switch.h" +#include "tablet_mode.h" +#include "throttle_ap.h" +#include "usbc_config.h" + +#include "gpio_list.h" /* Must come after other header files. */ + +/* Console output macros */ +#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) +#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) + +__override void board_cbi_init(void) +{ + config_usb_db_type(); +} + +/* Called on AP S3 -> S0 transition */ +static void board_chipset_resume(void) +{ + /* Allow keyboard backlight to be enabled */ + + if (IS_ENABLED(CONFIG_PWM_KBLIGHT)) + gpio_set_level(GPIO_EC_KB_BL_EN_L, 0); +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT); + +/* Called on AP S0 -> S3 transition */ +static void board_chipset_suspend(void) +{ + /* Turn off the keyboard backlight if it's on. */ + + if (IS_ENABLED(CONFIG_PWM_KBLIGHT)) + gpio_set_level(GPIO_EC_KB_BL_EN_L, 1); +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); diff --git a/board/marasov/board.h b/board/marasov/board.h new file mode 100644 index 0000000000..2f027deafc --- /dev/null +++ b/board/marasov/board.h @@ -0,0 +1,267 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Brya board configuration */ + +#ifndef __CROS_EC_BOARD_H +#define __CROS_EC_BOARD_H + +#include "compile_time_macros.h" + +/* + * Early brya boards are not set up for vivaldi + */ +#undef CONFIG_KEYBOARD_VIVALDI + +/* Baseboard features */ +#include "baseboard.h" + +/* + * This will happen automatically on NPCX9 ES2 and later. Do not remove + * until we can confirm all earlier chips are out of service. + */ +#define CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP + +#define CONFIG_MP2964 + +/* LED */ +#define CONFIG_LED_PWM +#define CONFIG_LED_PWM_COUNT 2 +#undef CONFIG_LED_PWM_NEAR_FULL_COLOR +#undef CONFIG_LED_PWM_SOC_ON_COLOR +#undef CONFIG_LED_PWM_SOC_SUSPEND_COLOR +#undef CONFIG_LED_PWM_LOW_BATT_COLOR +#define CONFIG_LED_PWM_NEAR_FULL_COLOR EC_LED_COLOR_WHITE +#define CONFIG_LED_PWM_SOC_ON_COLOR EC_LED_COLOR_WHITE +#define CONFIG_LED_PWM_SOC_SUSPEND_COLOR EC_LED_COLOR_WHITE +#define CONFIG_LED_PWM_LOW_BATT_COLOR EC_LED_COLOR_AMBER + +/* Sensors */ +#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */ +#define CONFIG_ACCEL_LSM6DSO_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) + +/* TCS3400 ALS */ +#define CONFIG_ALS +#define ALS_COUNT 1 +#define CONFIG_ALS_TCS3400 +#define CONFIG_ALS_TCS3400_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(CLEAR_ALS) + +/* Enable sensor fifo, must also define the _SIZE and _THRES */ +#define CONFIG_ACCEL_FIFO +/* FIFO size is in power of 2. */ +#define CONFIG_ACCEL_FIFO_SIZE 256 +/* Depends on how fast the AP boots and typical ODRs */ +#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3) + +/* Sensors without hardware interrupt are in forced mode */ +#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(CLEAR_ALS) + +/* Lid accel */ +#define CONFIG_LID_ANGLE +#define CONFIG_LID_ANGLE_UPDATE +#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL +#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL +#define CONFIG_ACCEL_LIS2DWL +#define CONFIG_ACCEL_LIS2DW12_INT_EVENT \ + TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL) + +/* Sensor console commands */ +#define CONFIG_CMD_ACCELS +#define CONFIG_CMD_ACCEL_INFO + +/* USB Type A Features */ +#define USB_PORT_COUNT 1 +#define CONFIG_USB_PORT_POWER_DUMB + +/* USB Type C and USB PD defines */ +#define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY + +#define CONFIG_IO_EXPANDER +#define CONFIG_IO_EXPANDER_NCT38XX +#define CONFIG_IO_EXPANDER_PORT_COUNT 2 + +#define CONFIG_USB_PD_FRS_PPC + +#define CONFIG_USB_PD_TCPM_PS8815 +#define CONFIG_USB_PD_TCPM_PS8815_FORCE_DID +#define CONFIG_USBC_RETIMER_INTEL_BB + +/* I2C speed console command */ +#define CONFIG_CMD_I2C_SPEED + +/* I2C control host command */ +#define CONFIG_HOSTCMD_I2C_CONTROL + +#define CONFIG_USBC_PPC_SYV682X +#define CONFIG_USBC_PPC_NX20P3483 + +/* TODO: b/177608416 - measure and check these values on brya */ +#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ +#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */ +#define PD_VCONN_SWAP_DELAY 5000 /* us */ + +/* + * Passive USB-C cables only support up to 60W. + */ +#define PD_OPERATING_POWER_MW 15000 +#define PD_MAX_POWER_MW 60000 +#define PD_MAX_CURRENT_MA 3000 +#define PD_MAX_VOLTAGE_MV 20000 + +/* + * Macros for GPIO signals used in common code that don't match the + * schematic names. Signal names in gpio.inc match the schematic and are + * then redefined here to so it's more clear which signal is being used for + * which purpose. + */ +#define GPIO_AC_PRESENT GPIO_ACOK_OD +#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL +#define GPIO_EC_INT_L GPIO_EC_PCH_INT_ODL +#define GPIO_ENABLE_BACKLIGHT GPIO_EC_EN_EDP_BL +#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW +#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV +#define GPIO_PACKET_MODE_EN GPIO_EC_GSC_PACKET_MODE +#define GPIO_PCH_PWRBTN_L GPIO_EC_PCH_PWR_BTN_ODL +#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L +#define GPIO_PCH_RTCRST GPIO_EC_PCH_RTCRST +#define GPIO_PCH_SLP_S0_L GPIO_SYS_SLP_S0IX_L +#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L +#define GPIO_TEMP_SENSOR_POWER GPIO_SEQ_EC_DSW_PWROK + +/* + * GPIO_EC_PCH_INT_ODL is used for MKBP events as well as a PCH wakeup + * signal. + */ +#define GPIO_PCH_WAKE_L GPIO_EC_PCH_INT_ODL +#define GPIO_PG_EC_ALL_SYS_PWRGD GPIO_SEQ_EC_ALL_SYS_PG +#define GPIO_PG_EC_DSW_PWROK GPIO_SEQ_EC_DSW_PWROK +#define GPIO_PG_EC_RSMRST_ODL GPIO_SEQ_EC_RSMRST_ODL +#define GPIO_POWER_BUTTON_L GPIO_GSC_EC_PWR_BTN_ODL +#define GPIO_SYS_RESET_L GPIO_SYS_RST_ODL +#define GPIO_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL +#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL +#define GPIO_WP_L GPIO_EC_WP_ODL + +/* System has back-lit keyboard */ +#define CONFIG_PWM_KBLIGHT + +/* I2C Bus Configuration */ + +#define I2C_PORT_SENSOR NPCX_I2C_PORT0_0 + +#define I2C_PORT_USB_C0_C2_TCPC NPCX_I2C_PORT1_0 +#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1 + +#define I2C_PORT_USB_C0_C2_PPC NPCX_I2C_PORT2_0 +#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1 + +#define I2C_PORT_USB_C0_C2_BC12 NPCX_I2C_PORT2_0 +#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT6_1 + +#define I2C_PORT_USB_C0_C2_MUX NPCX_I2C_PORT3_0 +#define I2C_PORT_USB_C1_MUX NPCX_I2C_PORT6_1 + +#define I2C_PORT_BATTERY NPCX_I2C_PORT5_0 +#define I2C_PORT_CHARGER NPCX_I2C_PORT7_0 +#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 +#define I2C_PORT_MP2964 NPCX_I2C_PORT7_0 + +#define I2C_ADDR_EEPROM_FLAGS 0x50 + +#define I2C_ADDR_MP2964_FLAGS 0x20 + +/* + * see b/174768555#comment22 + */ +#define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x56 +#define USBC_PORT_C2_BB_RETIMER_I2C_ADDR 0x57 + +/* Enabling Thunderbolt-compatible mode */ +#define CONFIG_USB_PD_TBT_COMPAT_MODE + +/* Enabling USB4 mode */ +#define CONFIG_USB_PD_USB4 +#define CONFIG_USB_PD_DATA_RESET_MSG + +/* Retimer */ +#define CONFIG_USBC_RETIMER_FW_UPDATE + +/* Thermal features */ +#define CONFIG_THERMISTOR +#define CONFIG_TEMP_SENSOR +#define CONFIG_TEMP_SENSOR_POWER +#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B + +#define CONFIG_FANS FAN_CH_COUNT + +/* Charger defines */ +#define CONFIG_CHARGER_BQ25720 +#define CONFIG_CHARGER_BQ25720_VSYS_TH2_CUSTOM +#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70 +#define CONFIG_CHARGE_RAMP_SW +#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10 +#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10 +#define CONFIG_CHARGER_BQ25710_PSYS_SENSING + +/* + * Older boards have a different ADC assignment. + */ + +#define CONFIG_ADC_CHANNELS_RUNTIME_CONFIG + +#ifndef __ASSEMBLER__ + +#include "gpio_signal.h" /* needed by registers.h */ +#include "registers.h" +#include "usbc_config.h" + +enum adc_channel { + ADC_TEMP_SENSOR_1_DDR_SOC, + ADC_TEMP_SENSOR_2_AMBIENT, + ADC_TEMP_SENSOR_3_CHARGER, + ADC_TEMP_SENSOR_4_WWAN, + ADC_CH_COUNT +}; + +enum temp_sensor_id { + TEMP_SENSOR_1_DDR_SOC, + TEMP_SENSOR_2_AMBIENT, + TEMP_SENSOR_3_CHARGER, + TEMP_SENSOR_4_WWAN, + TEMP_SENSOR_COUNT +}; + +enum sensor_id { + LID_ACCEL = 0, + BASE_ACCEL, + BASE_GYRO, + CLEAR_ALS, + RGB_ALS, + SENSOR_COUNT +}; + +enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT }; + +enum battery_type { BATTERY_POWER_TECH, BATTERY_LGC011, BATTERY_TYPE_COUNT }; + +enum pwm_channel { + PWM_CH_LED2 = 0, /* PWM0 (white charger) */ + PWM_CH_LED3, /* PWM1 (orange on DB) */ + PWM_CH_LED1, /* PWM2 (orange charger) */ + PWM_CH_KBLIGHT, /* PWM3 */ + PWM_CH_FAN, /* PWM5 */ + PWM_CH_LED4, /* PWM7 (white on DB) */ + PWM_CH_COUNT +}; + +enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT }; + +enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT }; + +#endif /* !__ASSEMBLER__ */ + +#endif /* __CROS_EC_BOARD_H */ diff --git a/board/marasov/build.mk b/board/marasov/build.mk new file mode 100644 index 0000000000..8b85854cf0 --- /dev/null +++ b/board/marasov/build.mk @@ -0,0 +1,25 @@ +# -*- makefile -*- +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Brya board specific files build +# + +CHIP:=npcx +CHIP_FAMILY:=npcx9 +CHIP_VARIANT:=npcx9m3f +BASEBOARD:=brya + +board-y= +board-y+=battery.o +board-y+=board.o +board-y+=charger.o +board-y+=fans.o +board-y+=fw_config.o +board-y+=i2c.o +board-y+=keyboard.o +board-y+=led.o +board-y+=pwm.o +board-y+=sensors.o +board-y+=usbc_config.o diff --git a/board/marasov/charger.c b/board/marasov/charger.c new file mode 100644 index 0000000000..e788aafdd0 --- /dev/null +++ b/board/marasov/charger.c @@ -0,0 +1,90 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" + +#include "charge_manager.h" +#include "charge_state_v2.h" +#include "charger.h" +#include "compile_time_macros.h" +#include "console.h" +#include "driver/charger/bq25710.h" +#include "usbc_ppc.h" +#include "usb_pd.h" +#include "util.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +#ifndef CONFIG_ZEPHYR +/* Charger Chip Configuration */ +const struct charger_config_t chg_chips[] = { + { + .i2c_port = I2C_PORT_CHARGER, + .i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS, + .drv = &bq25710_drv, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(chg_chips) == CHARGER_NUM); +#endif + +int board_set_active_charge_port(int port) +{ + int is_valid_port = board_is_usb_pd_port_present(port); + int i; + + if (port == CHARGE_PORT_NONE) { + CPRINTSUSB("Disabling all charger ports"); + + /* Disable all ports. */ + for (i = 0; i < ppc_cnt; i++) { + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (ppc_vbus_sink_enable(i, 0)) + CPRINTSUSB("Disabling C%d as sink failed.", i); + } + + return EC_SUCCESS; + } else if (!is_valid_port) { + return EC_ERROR_INVAL; + } + + /* Check if the port is sourcing VBUS. */ + if (ppc_is_sourcing_vbus(port)) { + CPRINTFUSB("Skip enable C%d", port); + return EC_ERROR_INVAL; + } + + CPRINTSUSB("New charge port: C%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < ppc_cnt; i++) { + if (i == port) + continue; + + if (ppc_vbus_sink_enable(i, 0)) + CPRINTSUSB("C%d: sink path disable failed.", i); + } + + /* Enable requested charge port. */ + if (ppc_vbus_sink_enable(port, 1)) { + CPRINTSUSB("C%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} + +__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); +} diff --git a/board/marasov/ec.tasklist b/board/marasov/ec.tasklist new file mode 100644 index 0000000000..73ccfb584a --- /dev/null +++ b/board/marasov/ec.tasklist @@ -0,0 +1,32 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * See CONFIG_TASK_LIST in config.h for details. + * + * USB_CHG_Px tasks must be contiguous (see USB_CHG_PORT_TO_TASK_ID(x)). + * PD_Cx tasks must be contiguous (see PD_PORT_TO_TASK_ID(x)) + */ + +#define CONFIG_TASK_LIST \ + TASK_ALWAYS(HOOKS, hook_task, NULL, HOOKS_TASK_STACK_SIZE) \ + TASK_ALWAYS(CHG_RAMP, chg_ramp_task, NULL, BASEBOARD_CHG_RAMP_TASK_STACK_SIZE) \ + TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \ + TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 0, TASK_STACK_SIZE) \ + TASK_ALWAYS(USB_CHG_P2, usb_charger_task, 0, TASK_STACK_SIZE) \ + TASK_ALWAYS(CHARGER, charger_task, NULL, BASEBOARD_CHARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_NOTEST(CHIPSET, chipset_task, NULL, BASEBOARD_CHIPSET_TASK_STACK_SIZE) \ + TASK_ALWAYS(USB_MUX, usb_mux_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(CONSOLE, console_task, NULL, CONSOLE_TASK_STACK_SIZE) \ + TASK_ALWAYS(POWERBTN, power_button_task, NULL, BASEBOARD_POWERBTN_TASK_STACK_SIZE) \ + TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_C0, pd_task, NULL, BASEBOARD_PD_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_C1, pd_task, NULL, BASEBOARD_PD_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_C2, pd_task, NULL, BASEBOARD_PD_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_INT_C0, pd_shared_alert_task, (BIT(2) | BIT(0)), BASEBOARD_PD_INT_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, BASEBOARD_PD_INT_TASK_STACK_SIZE) diff --git a/board/marasov/fans.c b/board/marasov/fans.c new file mode 100644 index 0000000000..158f4bf704 --- /dev/null +++ b/board/marasov/fans.c @@ -0,0 +1,89 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Physical fans. These are logically separate from pwm_channels. */ + +#include "common.h" +#include "compile_time_macros.h" +#include "console.h" +#include "fan_chip.h" +#include "fan.h" +#include "hooks.h" +#include "pwm.h" + +/* MFT channels. These are logically separate from pwm_channels. */ +const struct mft_t mft_channels[] = { + [MFT_CH_0] = { + .module = NPCX_MFT_MODULE_1, + .clk_src = TCKC_LFCLK, + .pwm_id = PWM_CH_FAN, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT); + +static const struct fan_conf fan_conf_0 = { + .flags = FAN_USE_RPM_MODE, + .ch = MFT_CH_0, /* Use MFT id to control fan */ + .pgood_gpio = -1, + .enable_gpio = GPIO_EN_PP5000_FAN, +}; + +/* + * TOOD(b/181271666): thermistor placement and calibration + * + * Prototype fan spins at about 4200 RPM at 100% PWM, this + * is specific to board ID 2 and might also apears in later + * boards as well. + */ +static const struct fan_rpm fan_rpm_0 = { + .rpm_min = 2200, + .rpm_start = 2200, + .rpm_max = 4200, +}; + +const struct fan_t fans[FAN_CH_COUNT] = { + [FAN_CH_0] = { + .conf = &fan_conf_0, + .rpm = &fan_rpm_0, + }, +}; + +#ifndef CONFIG_FANS + +/* + * TODO(b/181271666): use static fan speeds until fan and sensors are + * tuned. for now, use: + * + * AP off: 33% + * AP on: 100% + */ + +static void fan_slow(void) +{ + const int duty_pct = 33; + + ccprints("%s: speed %d%%", __func__, duty_pct); + + pwm_enable(PWM_CH_FAN, 1); + pwm_set_duty(PWM_CH_FAN, duty_pct); +} + +static void fan_max(void) +{ + const int duty_pct = 100; + + ccprints("%s: speed %d%%", __func__, duty_pct); + + pwm_enable(PWM_CH_FAN, 1); + pwm_set_duty(PWM_CH_FAN, duty_pct); +} + +DECLARE_HOOK(HOOK_INIT, fan_slow, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, fan_slow, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, fan_slow, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_RESET, fan_max, HOOK_PRIO_FIRST); +DECLARE_HOOK(HOOK_CHIPSET_RESUME, fan_max, HOOK_PRIO_DEFAULT); + +#endif /* CONFIG_FANS */ diff --git a/board/marasov/fw_config.c b/board/marasov/fw_config.c new file mode 100644 index 0000000000..375f5e965b --- /dev/null +++ b/board/marasov/fw_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "cbi.h" +#include "common.h" +#include "compile_time_macros.h" +#include "console.h" +#include "cros_board_info.h" +#include "fw_config.h" + +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) + +static union brya_cbi_fw_config fw_config; +BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t)); + +/* + * FW_CONFIG defaults for brya if the CBI.FW_CONFIG data is not + * initialized. + */ +static const union brya_cbi_fw_config fw_config_defaults = { + .usb_db = DB_USB3_PS8815, + .kb_bl = KEYBOARD_BACKLIGHT_ENABLED, +}; + +/**************************************************************************** + * Brya FW_CONFIG access + */ +void board_init_fw_config(void) +{ + if (cbi_get_fw_config(&fw_config.raw_value)) { + CPRINTS("CBI: Read FW_CONFIG failed, using board defaults"); + fw_config = fw_config_defaults; + } +} + +union brya_cbi_fw_config get_fw_config(void) +{ + return fw_config; +} + +enum ec_cfg_usb_db_type ec_cfg_usb_db_type(void) +{ + return fw_config.usb_db; +} diff --git a/board/marasov/fw_config.h b/board/marasov/fw_config.h new file mode 100644 index 0000000000..573d379972 --- /dev/null +++ b/board/marasov/fw_config.h @@ -0,0 +1,54 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __BOARD_BRYA_FW_CONFIG_H_ +#define __BOARD_BRYA_FW_CONFIG_H_ + +#include + +/**************************************************************************** + * CBI FW_CONFIG layout for Brya board. + * + * Source of truth is the project/brya/brya/config.star configuration file. + */ + +enum ec_cfg_usb_db_type { + DB_USB_ABSENT = 0, + DB_USB3_PS8815 = 1, + DB_USB_ABSENT2 = 15 +}; + +enum ec_cfg_keyboard_backlight_type { + KEYBOARD_BACKLIGHT_DISABLED = 0, + KEYBOARD_BACKLIGHT_ENABLED = 1 +}; + +union brya_cbi_fw_config { + struct { + enum ec_cfg_usb_db_type usb_db : 4; + uint32_t sd_db : 2; + uint32_t lte_db : 1; + enum ec_cfg_keyboard_backlight_type kb_bl : 1; + uint32_t audio : 3; + uint32_t reserved_1 : 21; + }; + uint32_t raw_value; +}; + +/** + * Read the cached FW_CONFIG. Guaranteed to have valid values. + * + * @return the FW_CONFIG for the board. + */ +union brya_cbi_fw_config get_fw_config(void); + +/** + * Get the USB daughter board type from FW_CONFIG. + * + * @return the USB daughter board type. + */ +enum ec_cfg_usb_db_type ec_cfg_usb_db_type(void); + +#endif /* __BOARD_BRYA_FW_CONFIG_H_ */ diff --git a/board/marasov/generated-gpio.inc b/board/marasov/generated-gpio.inc new file mode 100644 index 0000000000..f4772188a5 --- /dev/null +++ b/board/marasov/generated-gpio.inc @@ -0,0 +1,125 @@ +/* + * This file was auto-generated. + */ + +/* INTERRUPT GPIOs: */ +GPIO_INT(ACOK_OD, PIN(0, 0), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, extpower_interrupt) +GPIO_INT(EC_ACCEL_INT_R_L, PIN(8, 1), GPIO_SEL_1P8V | GPIO_INT_FALLING, lis2dw12_interrupt) +GPIO_INT(EC_ALS_RGB_INT_R_L, PIN(D, 4), GPIO_INT_FALLING, tcs3400_interrupt) +GPIO_INT(EC_IMU_INT_R_L, PIN(5, 6), GPIO_SEL_1P8V | GPIO_INT_FALLING, lsm6dso_interrupt) +GPIO_INT(EC_PROCHOT_IN_L, PIN(F, 0), GPIO_INT_BOTH, throttle_ap_prochot_input_interrupt) +GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) +GPIO_INT(EC_VOLUP_BTN_ODL, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) +GPIO_INT(EC_WP_ODL, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) +GPIO_INT(GSC_EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH | GPIO_HIB_WAKE_LOW, power_button_interrupt) +GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, lid_interrupt) +GPIO_INT(SEQ_EC_ALL_SYS_PG, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(SEQ_EC_DSW_PWROK, PIN(C, 7), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(SEQ_EC_RSMRST_ODL, PIN(E, 2), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(SLP_S3_L, PIN(A, 5), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(SLP_SUS_L, PIN(F, 1), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(SYS_SLP_S0IX_L, PIN(D, 5), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(TABLET_MODE_L, PIN(9, 5), GPIO_INT_BOTH, gmr_tablet_switch_isr) +GPIO_INT(USB_C0_BC12_INT_ODL, PIN(C, 6), GPIO_INT_FALLING, bc12_interrupt) +GPIO_INT(USB_C0_C2_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event) +GPIO_INT(USB_C0_PPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, ppc_interrupt) +GPIO_INT(USB_C0_RT_INT_ODL, PIN(B, 1), GPIO_INT_FALLING, retimer_interrupt) +GPIO_INT(USB_C1_BC12_INT_ODL, PIN(5, 0), GPIO_INT_FALLING, bc12_interrupt) +GPIO_INT(USB_C1_PPC_INT_ODL, PIN(F, 5), GPIO_INT_FALLING, ppc_interrupt) +GPIO_INT(USB_C1_TCPC_INT_ODL, PIN(A, 2), GPIO_INT_FALLING, tcpc_alert_event) +GPIO_INT(USB_C2_BC12_INT_ODL, PIN(8, 3), GPIO_INT_FALLING, bc12_interrupt) +GPIO_INT(USB_C2_PPC_INT_ODL, PIN(7, 0), GPIO_INT_FALLING, ppc_interrupt) +GPIO_INT(USB_C2_RT_INT_ODL, PIN(4, 1), GPIO_INT_FALLING, retimer_interrupt) + +/* USED GPIOs: */ +GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_INPUT) +GPIO(CHARGER_VAP_OTG_EN, PIN(7, 3), GPIO_OUT_LOW) +GPIO(CPU_C10_GATE_L, PIN(6, 7), GPIO_INPUT) +GPIO(EC_BATT_PRES_ODL, PIN(A, 3), GPIO_INPUT) +GPIO(EC_ENTERING_RW, PIN(0, 3), GPIO_OUT_LOW) +GPIO(EC_EN_EDP_BL, PIN(D, 3), GPIO_OUT_HIGH) +GPIO(EC_GSC_PACKET_MODE, PIN(7, 5), GPIO_OUT_LOW) +GPIO(EC_I2C_BAT_SCL, PIN(3, 3), GPIO_INPUT) +GPIO(EC_I2C_BAT_SDA, PIN(3, 6), GPIO_INPUT) +GPIO(EC_I2C_MISC_SCL_R, PIN(B, 3), GPIO_INPUT) +GPIO(EC_I2C_MISC_SDA_R, PIN(B, 2), GPIO_INPUT) +GPIO(EC_I2C_SENSOR_SCL, PIN(B, 5), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_SENSOR_SDA, PIN(B, 4), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_USB_C0_C2_PPC_BC_SCL, PIN(9, 2), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_C2_PPC_BC_SDA, PIN(9, 1), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_C2_RT_SCL, PIN(D, 1), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_C2_RT_SDA, PIN(D, 0), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_C2_TCPC_SCL, PIN(9, 0), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_C2_TCPC_SDA, PIN(8, 7), GPIO_INPUT) +GPIO(EC_I2C_USB_C1_MIX_SCL, PIN(E, 4), GPIO_INPUT) +GPIO(EC_I2C_USB_C1_MIX_SDA, PIN(E, 3), GPIO_INPUT) +GPIO(EC_I2C_USB_C1_TCPC_SCL, PIN(F, 3), GPIO_INPUT) +GPIO(EC_I2C_USB_C1_TCPC_SDA, PIN(F, 2), GPIO_INPUT) +GPIO(EC_KB_BL_EN_L, PIN(8, 6), GPIO_OUT_HIGH) +GPIO(EC_PCHHOT_ODL, PIN(7, 4), GPIO_INPUT) +GPIO(EC_PCH_INT_ODL, PIN(B, 0), GPIO_ODR_HIGH) +GPIO(EC_PCH_PWR_BTN_ODL, PIN(C, 1), GPIO_ODR_HIGH) +GPIO(EC_PCH_RSMRST_L, PIN(A, 6), GPIO_OUT_LOW) +GPIO(EC_PCH_RTCRST, PIN(7, 6), GPIO_OUT_LOW) +GPIO(EC_PCH_SYS_PWROK, PIN(3, 7), GPIO_OUT_LOW) +GPIO(EC_PCH_WAKE_R_ODL, PIN(C, 0), GPIO_ODR_HIGH) +GPIO(EC_PROCHOT_ODL, PIN(6, 3), GPIO_ODR_HIGH) +GPIO(EN_PP5000_FAN, PIN(6, 1), GPIO_OUT_HIGH) +GPIO(EN_PP5000_USBA_R, PIN(D, 7), GPIO_OUT_LOW) +GPIO(EN_S5_RAILS, PIN(B, 6), GPIO_OUT_LOW) +GPIO(IMVP9_VRRDY_OD, PIN(4, 3), GPIO_INPUT) +GPIO(PCH_PWROK, PIN(7, 2), GPIO_OUT_LOW) +GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH) +GPIO(USB_C0_C2_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW) +GPIO(USB_C1_FRS_EN, PIN(9, 4), GPIO_OUT_LOW) +GPIO(USB_C1_RST_ODL, PIN(9, 6), GPIO_ODR_LOW) +GPIO(USB_C1_RT_INT_ODL, PIN(A, 0), GPIO_INPUT) +GPIO(USB_C1_RT_RST_R_ODL, PIN(0, 2), GPIO_ODR_LOW) +GPIO(VCCST_PWRGD_OD, PIN(A, 4), GPIO_ODR_LOW) + +/* UART alternate functions */ +ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* GPIO64/CR_SIN1, GPO65/CR_SOUT1/FLPRG1_L */ + +/* I2C alternate functions */ +ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* GPIO33/I2C5_SCL0/CTS_L, GPIO36/RTS_L/I2C5_SDA0 */ +ALTERNATE(PIN_MASK(8, 0x80), 0, MODULE_I2C, 0) /* GPIO87/I2C1_SDA0 */ +ALTERNATE(PIN_MASK(9, 0x07), 0, MODULE_I2C, 0) /* GPIO92/I2C2_SCL0, GPIO91/I2C2_SDA0, GPIO90/I2C1_SCL0 */ +ALTERNATE(PIN_MASK(B, 0x0c), 0, MODULE_I2C, 0) /* GPIOB3/I2C7_SCL0/DCD_L, GPIOB2/I2C7_SDA0/DSR_L */ +ALTERNATE(PIN_MASK(B, 0x30), 0, MODULE_I2C, GPIO_SEL_1P8V) /* GPIOB5/I2C0_SCL0, GPIOB4/I2C0_SDA0 */ +ALTERNATE(PIN_MASK(D, 0x03), 0, MODULE_I2C, 0) /* GPIOD1/I2C3_SCL0, GPIOD0/I2C3_SDA0 */ +ALTERNATE(PIN_MASK(E, 0x18), 0, MODULE_I2C, 0) /* GPIOE4/I2C6_SCL1/I3C_SCL, GPIOE3/I2C6_SDA1/I3C_SDA */ +ALTERNATE(PIN_MASK(F, 0x0c), 0, MODULE_I2C, 0) /* GPIOF3/I2C4_SCL1, GPIOF2/I2C4_SDA1 */ + +/* PWM alternate functions */ +ALTERNATE(PIN_MASK(4, 0x01), 0, MODULE_PWM, 0) /* GPIO40/TA1 */ +ALTERNATE(PIN_MASK(6, 0x01), 0, MODULE_PWM, 0) /* GPIO60/PWM7 */ +ALTERNATE(PIN_MASK(8, 0x01), 0, MODULE_PWM, 0) /* GPIO80/PWM3 */ +ALTERNATE(PIN_MASK(B, 0x80), 0, MODULE_PWM, 0) /* GPIOB7/PWM5 */ +ALTERNATE(PIN_MASK(C, 0x1c), 0, MODULE_PWM, 0) /* GPIOC4/PWM2, GPIOC3/PWM0, GPIOC2/PWM1/I2C6_SCL0 */ + +/* ADC alternate functions */ +ALTERNATE(PIN_MASK(3, 0x10), 0, MODULE_ADC, 0) /* GPIO34/PS2_DAT2/ADC6 */ +ALTERNATE(PIN_MASK(4, 0x34), 0, MODULE_ADC, 0) /* GPIO42/ADC3/RI_L, GPIO45/ADC0, GPIO44/ADC1 */ +ALTERNATE(PIN_MASK(E, 0x02), 0, MODULE_ADC, 0) /* GPIOE1/ADC7 */ + +/* KB alternate functions */ +ALTERNATE(PIN_MASK(0, 0xf0), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO10&P80_CLK/GPIO07, KSO11&P80_DAT/GPIO06, KSO12/GPIO05, KSO13/GPIO04 */ +ALTERNATE(PIN_MASK(1, 0x7f), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO06/GPO13/GP_SEL_L, KSO07/GPO12/JEN_L, KSO03/GPIO16/JTAG_TDO0_SWO, KSO04/GPIO15/XNOR, KSO05/GPIO14, KSO08/GPIO11/CR_SOUT1, KSO09/GPIO10/CR_SIN1 */ +ALTERNATE(PIN_MASK(2, 0xfc), 0, MODULE_KB, GPIO_INPUT | GPIO_PULL_UP) /* KSI2/GPIO27/TRACEDATA1, KSI3/GPIO26/TRACEDATA0, KSI4/GPIO25/TRACECLK/GP_SCLK, KSI5/GPIO24/GP_MISO, KSI6/GPIO23/S_SBUB, KSI7/GPIO22/S_SBUA */ +ALTERNATE(PIN_MASK(2, 0x03), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO00/GPIO21/JTAG_TCK_SWCLK, KSO01/GPIO20/JTAG_TMS_SWIO */ +ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KB, GPIO_INPUT | GPIO_PULL_UP) /* KSI0/GPIO31/TRACEDATA3/GP_MOSI, KSI1/GPIO30/TRACEDATA2/GP_CS_L */ +ALTERNATE(PIN_MASK(8, 0x04), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO14/GPIO82 */ + +/* PMU alternate functions */ +ALTERNATE(PIN_MASK(0, 0x01), 0, MODULE_PMU, GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH) /* PSL_IN2_L&GPI00/GPIO00 */ +ALTERNATE(PIN_MASK(0, 0x02), 0, MODULE_PMU, GPIO_INT_BOTH | GPIO_HIB_WAKE_LOW) /* GPIO01/PSL_IN3_L&GPI01 */ +ALTERNATE(PIN_MASK(D, 0x04), 0, MODULE_PMU, GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH) /* PSL_IN1_L&GPID2/GPIOD2 */ + +/* Unused Pins */ +UNUSED(PIN(D, 6)) /* GPOD6/CR_SOUT3/SHDF_ESPI_L */ +UNUSED(PIN(3, 2)) /* GPO32/TRIS_L */ +UNUSED(PIN(3, 5)) /* GPO35/CR_SOUT4/TEST_L */ +UNUSED(PIN(6, 6)) /* GPIO66 */ +UNUSED(PIN(5, 7)) /* GPIO57/SER_IRQ/ESPI_ALERT_L */ + +/* Pre-configured PSL balls: J8 K6 */ diff --git a/board/marasov/gpio.inc b/board/marasov/gpio.inc new file mode 100644 index 0000000000..723f258a20 --- /dev/null +++ b/board/marasov/gpio.inc @@ -0,0 +1,43 @@ +/* -*- mode:c -*- + * + * Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#define MODULE_KB MODULE_KEYBOARD_SCAN + +/* + * Generated-gpio.inc is produced using a Brya specific tool that + * parses the GPIO definitions derived from the board schematics and + * EC pinout descriptions derived form the chip datasheets to generate + * the Chrome EC GPIO pinout definitions. Due to the confidential + * nature of schematics and datasheets, they are not provided here. + * + * Variants that do not auto-generate their GPIO definitions should + * combine the Brya gpio.inc and generated-gpio.inc into their + * gpio.inc and customize as appropriate. + */ + +#include "generated-gpio.inc" + +/* + * The NPCX keyboard driver does not use named GPIOs to access + * keyboard scan pins, so we do not list them in *gpio.inc. However, when + * KEYBOARD_COL2_INVERTED is defined, this name is required. + */ +GPIO(EC_KSO_02_INV, PIN(1, 7), GPIO_OUT_LOW) + +/* IO expander configuration */ + +/* GPIO02_P2 to PU */ +/* GPIO03_P2 to PU */ +IOEX(USB_C0_OC_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 4), GPIO_ODR_HIGH) +IOEX(USB_C0_FRS_EN, EXPIN(IOEX_C0_NCT38XX, 0, 6), GPIO_OUT_LOW) +IOEX(USB_C0_RT_RST_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 7), GPIO_ODR_LOW) + +IOEX(USB_C2_RT_RST_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 2), GPIO_ODR_LOW) +IOEX(USB_C1_OC_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 3), GPIO_ODR_HIGH) +IOEX(USB_C2_OC_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 4), GPIO_ODR_HIGH) +IOEX(USB_C2_FRS_EN, EXPIN(IOEX_C2_NCT38XX, 0, 6), GPIO_OUT_LOW) +/* GPIO07_P2 to PU */ diff --git a/board/marasov/i2c.c b/board/marasov/i2c.c new file mode 100644 index 0000000000..dbb8df7369 --- /dev/null +++ b/board/marasov/i2c.c @@ -0,0 +1,81 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "compile_time_macros.h" +#include "console.h" +#include "hooks.h" +#include "i2c.h" + +/* I2C port map configuration */ +const struct i2c_port_t i2c_ports[] = { + { + /* I2C0 */ + .name = "sensor", + .port = I2C_PORT_SENSOR, + .kbps = 400, + .scl = GPIO_EC_I2C_SENSOR_SCL, + .sda = GPIO_EC_I2C_SENSOR_SDA, + }, + { + /* I2C1 */ + .name = "tcpc0,2", + .port = I2C_PORT_USB_C0_C2_TCPC, + .kbps = 1000, + .scl = GPIO_EC_I2C_USB_C0_C2_TCPC_SCL, + .sda = GPIO_EC_I2C_USB_C0_C2_TCPC_SDA, + }, + { + /* I2C2 */ + .name = "ppc0,2", + .port = I2C_PORT_USB_C0_C2_PPC, + .kbps = 1000, + .scl = GPIO_EC_I2C_USB_C0_C2_PPC_BC_SCL, + .sda = GPIO_EC_I2C_USB_C0_C2_PPC_BC_SDA, + }, + { + /* I2C3 */ + .name = "retimer0,2", + .port = I2C_PORT_USB_C0_C2_MUX, + .kbps = 1000, + .scl = GPIO_EC_I2C_USB_C0_C2_RT_SCL, + .sda = GPIO_EC_I2C_USB_C0_C2_RT_SDA, + }, + { + /* I2C4 C1 TCPC */ + .name = "tcpc1", + .port = I2C_PORT_USB_C1_TCPC, + .kbps = 1000, + .scl = GPIO_EC_I2C_USB_C1_TCPC_SCL, + .sda = GPIO_EC_I2C_USB_C1_TCPC_SDA, + .flags = I2C_PORT_FLAG_DYNAMIC_SPEED, + }, + { + /* I2C5 */ + .name = "battery", + .port = I2C_PORT_BATTERY, + .kbps = 100, + .scl = GPIO_EC_I2C_BAT_SCL, + .sda = GPIO_EC_I2C_BAT_SDA, + }, + { + /* I2C6 */ + .name = "ppc1", + .port = I2C_PORT_USB_C1_PPC, + .kbps = 1000, + .scl = GPIO_EC_I2C_USB_C1_MIX_SCL, + .sda = GPIO_EC_I2C_USB_C1_MIX_SDA, + .flags = I2C_PORT_FLAG_DYNAMIC_SPEED, + }, + { + /* I2C7 */ + .name = "eeprom", + .port = I2C_PORT_EEPROM, + .kbps = 400, + .scl = GPIO_EC_I2C_MISC_SCL_R, + .sda = GPIO_EC_I2C_MISC_SDA_R, + }, +}; +const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); diff --git a/board/marasov/keyboard.c b/board/marasov/keyboard.c new file mode 100644 index 0000000000..936aeb290b --- /dev/null +++ b/board/marasov/keyboard.c @@ -0,0 +1,25 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" + +#include "keyboard_scan.h" +#include "timer.h" + +/* Keyboard scan setting */ +__override struct keyboard_scan_config keyscan_config = { + /* Increase from 50 us, because KSO_02 passes through the H1. */ + .output_settle_us = 80, + /* Other values should be the same as the default configuration. */ + .debounce_down_us = 9 * MSEC, + .debounce_up_us = 30 * MSEC, + .scan_period_us = 3 * MSEC, + .min_post_scan_delay_us = 1000, + .poll_timeout_us = 100 * MSEC, + .actual_key_mask = { + 0x14, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff, + 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */ + }, +}; diff --git a/board/marasov/led.c b/board/marasov/led.c new file mode 100644 index 0000000000..5d57a704aa --- /dev/null +++ b/board/marasov/led.c @@ -0,0 +1,90 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Brya specific PWM LED settings: there are 2 LEDs on each side of the board, + * each one can be controlled separately. The LED colors are white or amber, + * and the default behavior is tied to the charging process: both sides are + * amber while charging the battery and white when the battery is charged. + */ + +#include + +#include "common.h" +#include "compile_time_macros.h" +#include "ec_commands.h" +#include "led_pwm.h" +#include "pwm.h" +#include "util.h" + +const enum ec_led_id supported_led_ids[] = { + EC_LED_ID_LEFT_LED, + EC_LED_ID_RIGHT_LED, +}; + +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +/* + * We only have a white and an amber LED, so setting any other color results in + * both LEDs being off. Cap at 50% to save power. + */ +struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = { + /* Amber, White */ + [EC_LED_COLOR_RED] = { 0, 0 }, [EC_LED_COLOR_GREEN] = { 0, 0 }, + [EC_LED_COLOR_BLUE] = { 0, 0 }, [EC_LED_COLOR_YELLOW] = { 0, 0 }, + [EC_LED_COLOR_WHITE] = { 0, 50 }, [EC_LED_COLOR_AMBER] = { 50, 0 }, +}; + +/* Two logical LEDs with amber and white channels. */ +struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { + { + .ch0 = PWM_CH_LED1, + .ch1 = PWM_CH_LED2, + .ch2 = PWM_LED_NO_CHANNEL, + .enable = &pwm_enable, + .set_duty = &pwm_set_duty, + }, + { + .ch0 = PWM_CH_LED3, + .ch1 = PWM_CH_LED4, + .ch2 = PWM_LED_NO_CHANNEL, + .enable = &pwm_enable, + .set_duty = &pwm_set_duty, + }, +}; + +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) +{ + memset(brightness_range, '\0', + sizeof(*brightness_range) * EC_LED_COLOR_COUNT); + brightness_range[EC_LED_COLOR_AMBER] = 100; + brightness_range[EC_LED_COLOR_WHITE] = 100; +} + +int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) +{ + enum pwm_led_id pwm_id; + + /* Convert ec_led_id to pwm_led_id. */ + switch (led_id) { + case EC_LED_ID_LEFT_LED: + pwm_id = PWM_LED0; + break; + case EC_LED_ID_RIGHT_LED: + pwm_id = PWM_LED1; + break; + default: + return EC_ERROR_UNKNOWN; + } + + if (brightness[EC_LED_COLOR_WHITE]) + set_pwm_led_color(pwm_id, EC_LED_COLOR_WHITE); + else if (brightness[EC_LED_COLOR_AMBER]) + set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER); + else + /* Otherwise, the "color" is "off". */ + set_pwm_led_color(pwm_id, -1); + + return EC_SUCCESS; +} diff --git a/board/marasov/pwm.c b/board/marasov/pwm.c new file mode 100644 index 0000000000..3657549182 --- /dev/null +++ b/board/marasov/pwm.c @@ -0,0 +1,71 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" + +#include "compile_time_macros.h" +#include "hooks.h" +#include "pwm.h" +#include "pwm_chip.h" + +const struct pwm_t pwm_channels[] = { + [PWM_CH_LED2] = { + .channel = 0, + .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, + .freq = 4800, + }, + [PWM_CH_LED3] = { + .channel = 1, + .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, + .freq = 4800, + }, + [PWM_CH_LED1] = { + .channel = 2, + .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, + .freq = 4800, + }, + [PWM_CH_KBLIGHT] = { + .channel = 3, + .flags = 0, + /* + * Set PWM frequency to multiple of 50 Hz and 60 Hz to prevent + * flicker. Higher frequencies consume similar average power to + * lower PWM frequencies, but higher frequencies record a much + * lower maximum power. + */ + .freq = 12000, + }, + [PWM_CH_FAN] = { + .channel = 5, + .flags = PWM_CONFIG_OPEN_DRAIN, + .freq = 25000, + }, + [PWM_CH_LED4] = { + .channel = 7, + .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, + .freq = 4800, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); + +static void board_pwm_init(void) +{ + /* + * Turn off all the LEDs. + * Turn on the fan at 100%. + */ + pwm_enable(PWM_CH_LED1, 1); + pwm_set_duty(PWM_CH_LED1, 0); + pwm_enable(PWM_CH_LED2, 1); + pwm_set_duty(PWM_CH_LED2, 0); + pwm_enable(PWM_CH_LED3, 1); + pwm_set_duty(PWM_CH_LED3, 0); + pwm_enable(PWM_CH_LED4, 1); + pwm_set_duty(PWM_CH_LED4, 0); + + pwm_enable(PWM_CH_KBLIGHT, 1); + pwm_set_duty(PWM_CH_KBLIGHT, 50); +} +DECLARE_HOOK(HOOK_INIT, board_pwm_init, HOOK_PRIO_DEFAULT); diff --git a/board/marasov/sensors.c b/board/marasov/sensors.c new file mode 100644 index 0000000000..10c580de5d --- /dev/null +++ b/board/marasov/sensors.c @@ -0,0 +1,392 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "accelgyro.h" +#include "adc.h" +#include "driver/accel_lis2dw12.h" +#include "driver/accelgyro_lsm6dso.h" +#include "driver/als_tcs3400_public.h" +#include "gpio.h" +#include "hooks.h" +#include "motion_sense.h" +#include "temp_sensor.h" +#include "thermal.h" +#include "temp_sensor/thermistor.h" + +/* ADC configuration */ +struct adc_t adc_channels[] = { + [ADC_TEMP_SENSOR_1_DDR_SOC] = { + .name = "TEMP_DDR_SOC", + .input_ch = NPCX_ADC_CH0, + .factor_mul = ADC_MAX_VOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + }, + [ADC_TEMP_SENSOR_2_AMBIENT] = { + .name = "TEMP_AMBIENT", + .input_ch = NPCX_ADC_CH1, + .factor_mul = ADC_MAX_VOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + }, + [ADC_TEMP_SENSOR_3_CHARGER] = { + .name = "TEMP_CHARGER", + .input_ch = NPCX_ADC_CH6, + .factor_mul = ADC_MAX_VOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + }, + [ADC_TEMP_SENSOR_4_WWAN] = { + .name = "TEMP_WWAN", + .input_ch = NPCX_ADC_CH7, + .factor_mul = ADC_MAX_VOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); + +K_MUTEX_DEFINE(g_lid_accel_mutex); +K_MUTEX_DEFINE(g_base_accel_mutex); +static struct stprivate_data g_lis2dw12_data; +static struct lsm6dso_data lsm6dso_data; + +/* TODO(b/184779333): calibrate the orientation matrix on later board stage */ +static const mat33_fp_t lid_standard_ref = { { 0, FLOAT_TO_FP(1), 0 }, + { FLOAT_TO_FP(1), 0, 0 }, + { 0, 0, FLOAT_TO_FP(-1) } }; + +/* TODO(b/184779743): verify orientation matrix */ +static const mat33_fp_t base_standard_ref = { { FLOAT_TO_FP(1), 0, 0 }, + { 0, FLOAT_TO_FP(-1), 0 }, + { 0, 0, FLOAT_TO_FP(-1) } }; + +/* TCS3400 private data */ +static struct als_drv_data_t g_tcs3400_data = { + .als_cal.scale = 1, + .als_cal.uscale = 0, + .als_cal.offset = 0, + .als_cal.channel_scale = { + .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kc from VPD */ + .cover_scale = ALS_CHANNEL_SCALE(1.0), /* CT */ + }, +}; + +/* + * TODO: b/184702900 need to calibrate ALS/RGB sensor. At default settings, + * shining phone flashlight on sensor pegs all readings at 0xFFFF. + */ +static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = { + .calibration.rgb_cal[X] = { + .offset = 0, + .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(1.0), + .scale = { + .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kr */ + .cover_scale = ALS_CHANNEL_SCALE(1.0) + } + }, + .calibration.rgb_cal[Y] = { + .offset = 0, + .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(1.0), + .scale = { + .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kg */ + .cover_scale = ALS_CHANNEL_SCALE(1.0) + }, + }, + .calibration.rgb_cal[Z] = { + .offset = 0, + .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), + .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(1.0), + .scale = { + .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kb */ + .cover_scale = ALS_CHANNEL_SCALE(1.0) + } + }, + .calibration.irt = INT_TO_FP(1), + .saturation.again = TCS_DEFAULT_AGAIN, + .saturation.atime = TCS_DEFAULT_ATIME, +}; + +struct motion_sensor_t motion_sensors[] = { + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LIS2DW12, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &lis2dw12_drv, + .mutex = &g_lid_accel_mutex, + .drv_data = &g_lis2dw12_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = LIS2DW12_ADDR0, + .rot_standard_ref = &lid_standard_ref, /* identity matrix */ + .default_range = 2, /* g */ + .min_frequency = LIS2DW12_ODR_MIN_VAL, + .max_frequency = LIS2DW12_ODR_MAX_VAL, + .config = { + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + /* Sensor on for lid angle detection */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + }, + }, + }, + + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSO, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dso_drv, + .mutex = &g_base_accel_mutex, + .drv_data = LSM6DSO_ST_DATA(lsm6dso_data, + MOTIONSENSE_TYPE_ACCEL), + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS, + .rot_standard_ref = &base_standard_ref, + .default_range = 4, /* g */ + .min_frequency = LSM6DSO_ODR_MIN_VAL, + .max_frequency = LSM6DSO_ODR_MAX_VAL, + .config = { + [SENSOR_CONFIG_EC_S0] = { + .odr = 13000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + [SENSOR_CONFIG_EC_S3] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + }, + }, + + [BASE_GYRO] = { + .name = "Base Gyro", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_LSM6DSO, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_BASE, + .drv = &lsm6dso_drv, + .mutex = &g_base_accel_mutex, + .drv_data = LSM6DSO_ST_DATA(lsm6dso_data, + MOTIONSENSE_TYPE_GYRO), + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS, + .default_range = 1000 | ROUND_UP_FLAG, /* dps */ + .rot_standard_ref = &base_standard_ref, + .min_frequency = LSM6DSO_ODR_MIN_VAL, + .max_frequency = LSM6DSO_ODR_MAX_VAL, + }, + + [CLEAR_ALS] = { + .name = "Clear Light", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_TCS3400, + .type = MOTIONSENSE_TYPE_LIGHT, + .location = MOTIONSENSE_LOC_CAMERA, + .drv = &tcs3400_drv, + .drv_data = &g_tcs3400_data, + .port = I2C_PORT_SENSOR, + .i2c_spi_addr_flags = TCS3400_I2C_ADDR_FLAGS, + .rot_standard_ref = NULL, + .default_range = 0x10000, /* scale = 1x, uscale = 0 */ + .min_frequency = TCS3400_LIGHT_MIN_FREQ, + .max_frequency = TCS3400_LIGHT_MAX_FREQ, + .config = { + /* Run ALS sensor in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 1000, + }, + }, + }, + + [RGB_ALS] = { + /* + * RGB channels read by CLEAR_ALS and so the i2c port and + * address do not need to be defined for RGB_ALS. + */ + .name = "RGB Light", + .active_mask = SENSOR_ACTIVE_S0_S3, + .chip = MOTIONSENSE_CHIP_TCS3400, + .type = MOTIONSENSE_TYPE_LIGHT_RGB, + .location = MOTIONSENSE_LOC_CAMERA, + .drv = &tcs3400_rgb_drv, + .drv_data = &g_tcs3400_rgb_data, + .rot_standard_ref = NULL, + .default_range = 0x10000, /* scale = 1x, uscale = 0 */ + }, +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */ +const struct motion_sensor_t *motion_als_sensors[] = { + &motion_sensors[CLEAR_ALS], +}; +BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT); + +static void baseboard_sensors_init(void) +{ + /* Enable gpio interrupt for lid accel sensor */ + gpio_enable_interrupt(GPIO_EC_ACCEL_INT_R_L); + /* Enable interrupt for the TCS3400 color light sensor */ + gpio_enable_interrupt(GPIO_EC_ALS_RGB_INT_R_L); + /* Enable gpio interrupt for base accelgyro sensor */ + gpio_enable_interrupt(GPIO_EC_IMU_INT_R_L); +} +DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_INIT_I2C + 1); + +/* Temperature sensor configuration */ +const struct temp_sensor_t temp_sensors[] = { + [TEMP_SENSOR_1_DDR_SOC] = { + .name = "DDR and SOC", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_1_DDR_SOC, + }, + [TEMP_SENSOR_2_AMBIENT] = { + .name = "Ambient", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_2_AMBIENT, + }, + [TEMP_SENSOR_3_CHARGER] = { + .name = "Charger", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_3_CHARGER, + }, + [TEMP_SENSOR_4_WWAN] = { + .name = "WWAN", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_4_WWAN, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); + +/* + * TODO(b/180681346): update for Alder Lake/brya + * + * Alder Lake specifies 100 C as maximum TDP temperature. THRMTRIP# occurs at + * 130 C. However, sensor is located next to DDR, so we need to use the lower + * DDR temperature limit (85 C) + */ +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_CPU \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(90), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \ + }, \ + .temp_fan_off = C_TO_K(35), \ + .temp_fan_max = C_TO_K(60), \ + } +__maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU; + +/* + * TODO(b/180681346): update for Alder Lake/brya + * + * Inductor limits - used for both charger and PP3300 regulator + * + * Need to use the lower of the charger IC, PP3300 regulator, and the inductors + * + * Charger max recommended temperature 100C, max absolute temperature 125C + * PP3300 regulator: operating range -40 C to 145 C + * + * Inductors: limit of 125c + * PCB: limit is 80c + */ +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_AMBIENT \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(90), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \ + }, \ + .temp_fan_off = C_TO_K(35), \ + .temp_fan_max = C_TO_K(60), \ + } +__maybe_unused static const struct ec_thermal_config thermal_ambient = + THERMAL_AMBIENT; + +/* + * Inductor limits - used for both charger and PP3300 regulator + * + * Need to use the lower of the charger IC, PP3300 regulator, and the inductors + * + * Charger max recommended temperature 125C, max absolute temperature 150C + * PP3300 regulator: operating range -40 C to 125 C + * + * Inductors: limit of 125c + * PCB: limit is 80c + */ +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_CHARGER \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(120), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(90), \ + }, \ + .temp_fan_off = C_TO_K(35), \ + .temp_fan_max = C_TO_K(65), \ + } +__maybe_unused static const struct ec_thermal_config thermal_charger = + THERMAL_CHARGER; + +/* + * TODO(b/180681346): update for brya WWAN module + */ +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_WWAN \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(130), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(130), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(100), \ + }, \ + .temp_fan_off = C_TO_K(35), \ + .temp_fan_max = C_TO_K(60), \ + } +__maybe_unused static const struct ec_thermal_config thermal_wwan = + THERMAL_WWAN; + +struct ec_thermal_config thermal_params[] = { + [TEMP_SENSOR_1_DDR_SOC] = THERMAL_CPU, + [TEMP_SENSOR_2_AMBIENT] = THERMAL_AMBIENT, + [TEMP_SENSOR_3_CHARGER] = THERMAL_CHARGER, + [TEMP_SENSOR_4_WWAN] = THERMAL_WWAN, +}; +BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); diff --git a/board/marasov/usbc_config.c b/board/marasov/usbc_config.c new file mode 100644 index 0000000000..7c080f4188 --- /dev/null +++ b/board/marasov/usbc_config.c @@ -0,0 +1,517 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "cbi.h" +#include "charger.h" +#include "charge_ramp.h" +#include "common.h" +#include "compile_time_macros.h" +#include "console.h" +#include "driver/bc12/pi3usb9201_public.h" +#include "driver/ppc/nx20p348x.h" +#include "driver/ppc/syv682x_public.h" +#include "driver/retimer/bb_retimer_public.h" +#include "driver/tcpm/nct38xx.h" +#include "driver/tcpm/ps8xxx_public.h" +#include "driver/tcpm/tcpci.h" +#include "ec_commands.h" +#include "fw_config.h" +#include "gpio.h" +#include "gpio_signal.h" +#include "hooks.h" +#include "ioexpander.h" +#include "system.h" +#include "task.h" +#include "task_id.h" +#include "timer.h" +#include "usbc_config.h" +#include "usbc_ppc.h" +#include "usb_charge.h" +#include "usb_mux.h" +#include "usb_pd.h" +#include "usb_pd_tcpm.h" + +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) + +#ifdef CONFIG_ZEPHYR +enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT }; +#endif /* CONFIG_ZEPHYR */ + +#ifndef CONFIG_ZEPHYR +/* USBC TCPC configuration */ +const struct tcpc_config_t tcpc_config[] = { + [USBC_PORT_C0] = { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C0_C2_TCPC, + .addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS, + }, + .drv = &nct38xx_tcpm_drv, + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_NO_DEBUG_ACC_CONTROL, + }, + [USBC_PORT_C1] = { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1_TCPC, + .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, + }, + .drv = &ps8xxx_tcpm_drv, + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS, + }, + [USBC_PORT_C2] = { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C0_C2_TCPC, + .addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS, + }, + .drv = &nct38xx_tcpm_drv, + .flags = TCPC_FLAGS_TCPCI_REV2_0, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT); +BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT); +#endif /* !CONFIG_ZEPHYR */ + +/******************************************************************************/ +/* USB-A charging control */ + +#ifndef CONFIG_ZEPHYR +const int usb_port_enable[USB_PORT_COUNT] = { + GPIO_EN_PP5000_USBA_R, +}; +#endif +BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT); + +/******************************************************************************/ + +#ifndef CONFIG_ZEPHYR +/* USBC PPC configuration */ +struct ppc_config_t ppc_chips[] = { + [USBC_PORT_C0] = { + .i2c_port = I2C_PORT_USB_C0_C2_PPC, + .i2c_addr_flags = SYV682X_ADDR0_FLAGS, + .frs_en = IOEX_USB_C0_FRS_EN, + .drv = &syv682x_drv, + }, + [USBC_PORT_C1] = { + /* Compatible with Silicon Mitus SM5360A */ + .i2c_port = I2C_PORT_USB_C1_PPC, + .i2c_addr_flags = NX20P3483_ADDR2_FLAGS, + .drv = &nx20p348x_drv, + }, + [USBC_PORT_C2] = { + .i2c_port = I2C_PORT_USB_C0_C2_PPC, + .i2c_addr_flags = SYV682X_ADDR2_FLAGS, + .frs_en = IOEX_USB_C2_FRS_EN, + .drv = &syv682x_drv, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT); + +unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); + +/* USBC mux configuration - Alder Lake includes internal mux */ +static const struct usb_mux_chain usbc0_tcss_usb_mux = { + .mux = + &(const struct usb_mux){ + .usb_port = USBC_PORT_C0, + .driver = &virtual_usb_mux_driver, + .hpd_update = &virtual_hpd_update, + }, +}; +static const struct usb_mux_chain usbc2_tcss_usb_mux = { + .mux = + &(const struct usb_mux){ + .usb_port = USBC_PORT_C2, + .driver = &virtual_usb_mux_driver, + .hpd_update = &virtual_hpd_update, + }, +}; + +/* + * USB3 DB mux configuration - the top level mux still needs to be set + * to the virtual_usb_mux_driver so the AP gets notified of mux changes + * and updates the TCSS configuration on state changes. + */ +static const struct usb_mux_chain usbc1_usb3_db_retimer = { + .mux = + &(const struct usb_mux){ + .usb_port = USBC_PORT_C1, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, + }, +}; + +const struct usb_mux_chain usb_muxes[] = { + [USBC_PORT_C0] = { + .mux = &(const struct usb_mux) { + .usb_port = USBC_PORT_C0, + .flags = USB_MUX_FLAG_CAN_IDLE, + .driver = &bb_usb_retimer, + .hpd_update = bb_retimer_hpd_update, + .i2c_port = I2C_PORT_USB_C0_C2_MUX, + .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR, + }, + .next = &usbc0_tcss_usb_mux, + }, + [USBC_PORT_C1] = { + .mux = &(const struct usb_mux) { + /* PS8815 DB */ + .usb_port = USBC_PORT_C1, + .driver = &virtual_usb_mux_driver, + .hpd_update = &virtual_hpd_update, + }, + .next = &usbc1_usb3_db_retimer, + }, + [USBC_PORT_C2] = { + .mux = &(const struct usb_mux) { + .usb_port = USBC_PORT_C2, + .flags = USB_MUX_FLAG_CAN_IDLE, + .driver = &bb_usb_retimer, + .hpd_update = bb_retimer_hpd_update, + .i2c_port = I2C_PORT_USB_C0_C2_MUX, + .i2c_addr_flags = USBC_PORT_C2_BB_RETIMER_I2C_ADDR, + }, + .next = &usbc2_tcss_usb_mux, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT); + +/* BC1.2 charger detect configuration */ +const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { + [USBC_PORT_C0] = { + .i2c_port = I2C_PORT_USB_C0_C2_BC12, + .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, + }, + [USBC_PORT_C1] = { + .i2c_port = I2C_PORT_USB_C1_BC12, + .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, + }, + [USBC_PORT_C2] = { + .i2c_port = I2C_PORT_USB_C0_C2_BC12, + .i2c_addr_flags = PI3USB9201_I2C_ADDR_1_FLAGS, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT); + +/* + * USB C0 and C2 uses burnside bridge chips and have their reset + * controlled by their respective TCPC chips acting as GPIO expanders. + * + * ioex_init() is normally called before we take the TCPCs out of + * reset, so we need to start in disabled mode, then explicitly + * call ioex_init(). + */ + +struct ioexpander_config_t ioex_config[] = { + [IOEX_C0_NCT38XX] = { + .i2c_host_port = I2C_PORT_USB_C0_C2_TCPC, + .i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS, + .drv = &nct38xx_ioexpander_drv, + .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED, + }, + [IOEX_C2_NCT38XX] = { + .i2c_host_port = I2C_PORT_USB_C0_C2_TCPC, + .i2c_addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS, + .drv = &nct38xx_ioexpander_drv, + .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT); +#endif /* !CONFIG_ZEPHYR */ + +#ifdef CONFIG_CHARGE_RAMP_SW + +/* + * TODO(b/181508008): tune this threshold + */ + +#define BC12_MIN_VOLTAGE 4400 + +/** + * Return true if VBUS is too low + */ +int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) +{ + int voltage; + + if (charger_get_vbus_voltage(port, &voltage)) + voltage = 0; + + if (voltage == 0) { + CPRINTS("%s: must be disconnected", __func__); + return 1; + } + + if (voltage < BC12_MIN_VOLTAGE) { + CPRINTS("%s: port %d: vbus %d lower than %d", __func__, port, + voltage, BC12_MIN_VOLTAGE); + return 1; + } + + return 0; +} + +#endif /* CONFIG_CHARGE_RAMP_SW */ + +void config_usb_db_type(void) +{ + enum ec_cfg_usb_db_type db_type = ec_cfg_usb_db_type(); + + /* + * TODO(b/180434685): implement multiple DB types + */ + + CPRINTS("Configured USB DB type number is %d", db_type); +} + +__override int bb_retimer_power_enable(const struct usb_mux *me, bool enable) +{ + enum ioex_signal rst_signal; + + if (me->usb_port == USBC_PORT_C0) { +/* TODO: explore how to handle board id in zephyr*/ +#ifndef CONFIG_ZEPHYR + rst_signal = IOEX_USB_C0_RT_RST_ODL; +#else + /* On Zephyr use bb_controls generated from DTS */ + rst_signal = bb_controls[me->usb_port].retimer_rst_gpio; +#endif /* !CONFIG_ZEPHYR */ + } else if (me->usb_port == USBC_PORT_C2) { +/* TODO: explore how to handle board id in zephyr*/ +#ifndef CONFIG_ZEPHYR + rst_signal = IOEX_USB_C2_RT_RST_ODL; +#else + /* On Zephyr use bb_controls generated from DTS */ + rst_signal = bb_controls[me->usb_port].retimer_rst_gpio; +#endif /* !CONFIG_ZEPHYR */ + } else { + return EC_ERROR_INVAL; + } + + /* + * We do not have a load switch for the burnside bridge chips, + * so we only need to sequence reset. + */ + + if (enable) { + /* + * Tpw, minimum time from VCC to RESET_N de-assertion is 100us. + * For boards that don't provide a load switch control, the + * retimer_init() function ensures power is up before calling + * this function. + */ + ioex_set_level(rst_signal, 1); + /* + * Allow 1ms time for the retimer to power up lc_domain + * which powers I2C controller within retimer + */ + msleep(1); + } else { + ioex_set_level(rst_signal, 0); + msleep(1); + } + return EC_SUCCESS; +} + +void board_reset_pd_mcu(void) +{ + enum gpio_signal tcpc_rst; + +#ifndef CONFIG_ZEPHYR + tcpc_rst = GPIO_USB_C0_C2_TCPC_RST_ODL; +#else + tcpc_rst = GPIO_UNIMPLEMENTED; +#endif /* !CONFIG_ZEPHYR */ + + /* + * TODO(b/179648104): figure out correct timing + */ + + gpio_set_level(tcpc_rst, 0); + if (ec_cfg_usb_db_type() != DB_USB_ABSENT) { + gpio_set_level(GPIO_USB_C1_RST_ODL, 0); + gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 0); + } + + /* + * delay for power-on to reset-off and min. assertion time + */ + + msleep(20); + + gpio_set_level(tcpc_rst, 1); + if (ec_cfg_usb_db_type() != DB_USB_ABSENT) { + gpio_set_level(GPIO_USB_C1_RST_ODL, 1); + gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 1); + } + + /* wait for chips to come up */ + + msleep(50); +} + +static void board_tcpc_init(void) +{ + /* Don't reset TCPCs after initial reset */ + if (!system_jumped_late()) + board_reset_pd_mcu(); + + /* + * These IO expander pins are implemented using the + * C0/C2 TCPC, so they must be set up after the TCPC has + * been taken out of reset. + */ +#ifndef CONFIG_ZEPHYR + ioex_init(IOEX_C0_NCT38XX); + ioex_init(IOEX_C2_NCT38XX); +#else + gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_port1))); + gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_port2))); +#endif + + /* Enable PPC interrupts. */ + gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C2_PPC_INT_ODL); + + /* Enable TCPC interrupts. */ + gpio_enable_interrupt(GPIO_USB_C0_C2_TCPC_INT_ODL); + +#ifndef CONFIG_ZEPHYR + /* Enable BC1.2 interrupts. */ + gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C2_BC12_INT_ODL); +#endif /* !CONFIG_ZEPHYR */ + + if (ec_cfg_usb_db_type() != DB_USB_ABSENT) { + gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL); +#ifndef CONFIG_ZEPHYR + gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_ODL); +#endif /* !CONFIG_ZEPHYR */ + } +} +DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_CHIPSET); + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + + if (gpio_get_level(GPIO_USB_C0_C2_TCPC_INT_ODL) == 0) + status |= PD_STATUS_TCPC_ALERT_0 | PD_STATUS_TCPC_ALERT_2; + + if ((ec_cfg_usb_db_type() != DB_USB_ABSENT) && + gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL) == 0) + status |= PD_STATUS_TCPC_ALERT_1; + + return status; +} + +int ppc_get_alert_status(int port) +{ + if (port == USBC_PORT_C0) + return gpio_get_level(GPIO_USB_C0_PPC_INT_ODL) == 0; + else if ((port == USBC_PORT_C1) && + (ec_cfg_usb_db_type() != DB_USB_ABSENT)) + return gpio_get_level(GPIO_USB_C1_PPC_INT_ODL) == 0; + else if (port == USBC_PORT_C2) + return gpio_get_level(GPIO_USB_C2_PPC_INT_ODL) == 0; + return 0; +} + +void tcpc_alert_event(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_C2_TCPC_INT_ODL: + schedule_deferred_pd_interrupt(USBC_PORT_C0); + break; + case GPIO_USB_C1_TCPC_INT_ODL: + if (ec_cfg_usb_db_type() == DB_USB_ABSENT) + break; + schedule_deferred_pd_interrupt(USBC_PORT_C1); + break; + default: + break; + } +} + +void bc12_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_BC12_INT_ODL: + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + break; + case GPIO_USB_C1_BC12_INT_ODL: + if (ec_cfg_usb_db_type() == DB_USB_ABSENT) + break; + usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); + break; + case GPIO_USB_C2_BC12_INT_ODL: + usb_charger_task_set_event(2, USB_CHG_EVENT_BC12); + break; + default: + break; + } +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + syv682x_interrupt(USBC_PORT_C0); + break; + case GPIO_USB_C1_PPC_INT_ODL: + switch (ec_cfg_usb_db_type()) { + case DB_USB_ABSENT: + case DB_USB_ABSENT2: + break; + case DB_USB3_PS8815: + nx20p348x_interrupt(USBC_PORT_C1); + break; + } + break; + case GPIO_USB_C2_PPC_INT_ODL: + syv682x_interrupt(USBC_PORT_C2); + break; + default: + break; + } +} + +void retimer_interrupt(enum gpio_signal signal) +{ + /* + * TODO(b/179513527): add USB-C support + */ +} + +__override bool board_is_dts_port(int port) +{ + return port == USBC_PORT_C0; +} + +__override bool board_is_tbt_usb4_port(int port) +{ + if (port == USBC_PORT_C0 || port == USBC_PORT_C2) + return true; + + return false; +} + +__override enum tbt_compat_cable_speed board_get_max_tbt_speed(int port) +{ + if (!board_is_tbt_usb4_port(port)) + return TBT_SS_RES_0; + + return TBT_SS_TBT_GEN3; +} diff --git a/board/marasov/usbc_config.h b/board/marasov/usbc_config.h new file mode 100644 index 0000000000..06b9b992fe --- /dev/null +++ b/board/marasov/usbc_config.h @@ -0,0 +1,24 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Brya board-specific USB-C configuration */ + +#ifndef __CROS_EC_USBC_CONFIG_H +#define __CROS_EC_USBC_CONFIG_H + +#ifndef CONFIG_ZEPHYR +#define CONFIG_USB_PD_PORT_MAX_COUNT 3 +#endif + +enum usbc_port { + USBC_PORT_C0 = 0, + USBC_PORT_C1, + USBC_PORT_C2, + USBC_PORT_COUNT +}; + +void config_usb_db_type(void); + +#endif /* __CROS_EC_USBC_CONFIG_H */ diff --git a/board/marasov/vif_override.xml b/board/marasov/vif_override.xml new file mode 100644 index 0000000000..6ade5d2f92 --- /dev/null +++ b/board/marasov/vif_override.xml @@ -0,0 +1,148 @@ + + + 2 + 0 + + + + + + + + 8087 + + + + + + TBT3 Compatible + + + + 8087 + 8086 + 9A1B + + + + + + Gen 3 (40Gb) + + + + USB 3.2 Gen 2x2 + + + + + + + + + + + + + 3A @ 5V + + + + 50 msec + 3600 mA + + + + + PDUSB Peripheral + PDUSB Host + + + + + + + + + + + HBR3 + 4 Lanes + + + + + + + + USB 3.2 Gen 2x1 + + + + + + + + + + + + + 3A @ 5V + + + + 50 msec + 3600 mA + + + + + PSD + PDUSB Host + + + + + Gen 3 (40Gb) + + USB 3.2 Gen 2x2 + + + + + + + + + + + + + 3A @ 5V + + + + 50 msec + 3600 mA + + + + + PDUSB Peripheral + PDUSB Host + + + + + + + + + + + HBR3 + 4 Lanes + + + diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 9b1cbca944..850abc57f4 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -158,6 +158,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "lux", "madoo", "magolor", + "marasov", "marzipan", "meep", "metaknight", -- cgit v1.2.1 From 3f2554177bd70e760a722f8f252a267b4f097ba7 Mon Sep 17 00:00:00 2001 From: alvishsu Date: Thu, 13 Oct 2022 18:09:27 +0800 Subject: rt9490: disable special TA detection ChromeOS doesn't support any non-standard TA other than SDP/CDP/DCP, so disable this feature to make behavior consistent. BUG=b:249226376 TEST=zmake BRANCH=corsola Change-Id: I86bffc94f8ef36b5119f471618955ab77ea16bf2 Signed-off-by: Ting Shen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3949344 Reviewed-by: Eric Yilun Lin Code-Coverage: Zoss Commit-Queue: Ting Shen Tested-by: Ting Shen Code-Coverage: Eric Yilun Lin --- driver/charger/rt9490.c | 4 ++++ driver/charger/rt9490.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/driver/charger/rt9490.c b/driver/charger/rt9490.c index 8bf418a065..c0bf873e43 100644 --- a/driver/charger/rt9490.c +++ b/driver/charger/rt9490.c @@ -359,6 +359,10 @@ static int rt9490_init_setting(int chgnum) RT9490_EN_FON_PP_BAT_TRACK); RETURN_ERROR(rt9490_enable_hidden_mode(chgnum, false)); + /* Disable non-standard TA detection */ + RETURN_ERROR(rt9490_clr_bit(chgnum, RT9490_REG_ADD_CTRL2, + RT9490_SPEC_TA_EN)); + return EC_SUCCESS; } diff --git a/driver/charger/rt9490.h b/driver/charger/rt9490.h index ea1d6cfcfb..135c3271be 100644 --- a/driver/charger/rt9490.h +++ b/driver/charger/rt9490.h @@ -248,6 +248,9 @@ struct rt9490_init_setting { /* ADD CTRL1 */ #define RT9490_PWM_1MHZ_EN BIT(4) +/* ADD CTRL2 */ +#define RT9490_SPEC_TA_EN BIT(2) + /* HD_ADD_CTRL 2 */ #define RT9490_EN_FON_PP_BAT_TRACK BIT(5) -- cgit v1.2.1 From 22fa1edea9cc654f3e2b3ec1c513c2ab55b28a76 Mon Sep 17 00:00:00 2001 From: Raymond Chung Date: Fri, 11 Nov 2022 10:03:53 +0800 Subject: gaelin: Initial TCPC configuration 1. Initial motherboard Type-C configurations. 1-a. TCPC config to PS8815. 1-b. PPC config to SM5360A. 2. Remove WPC/Qi charger configuration. 3. Remove NFC configuration. BUG=b:249000573, b:241738261 BRANCH=None TEST=make -j BOARD=gaelin Change-Id: Ic72c2e0414c764605fda24c3c6bd2572eee3076f Signed-off-by: Raymond Chung Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022844 Code-Coverage: Zoss Reviewed-by: Derek Huang Commit-Queue: Derek Huang --- board/gaelin/board.c | 50 +------- board/gaelin/board.h | 54 ++------- board/gaelin/ec.tasklist | 5 +- board/gaelin/gpio.inc | 65 +++------- board/gaelin/i2c.c | 52 +++----- board/gaelin/usbc_config.c | 289 ++++++++++++--------------------------------- board/gaelin/usbc_config.h | 9 +- 7 files changed, 118 insertions(+), 406 deletions(-) diff --git a/board/gaelin/board.c b/board/gaelin/board.c index 6fad328a76..7228c9e2f2 100644 --- a/board/gaelin/board.c +++ b/board/gaelin/board.c @@ -17,7 +17,6 @@ #include "gpio_signal.h" #include "power_button.h" #include "hooks.h" -#include "peripheral_charger.h" #include "power.h" #include "switch.h" #include "throttle_ap.h" @@ -41,33 +40,6 @@ const int usb_port_enable[USB_PORT_COUNT] = { }; BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT); -extern struct pchg_drv cps8100_drv; -struct pchg pchgs[] = { - [0] = { - .cfg = &(const struct pchg_config) { - .drv = &cps8100_drv, - .i2c_port = I2C_PORT_QI, - .irq_pin = GPIO_QI_INT_ODL, - .full_percent = 96, - .block_size = 128, - }, - .policy = { - [PCHG_CHIPSET_STATE_ON] = &pchg_policy_on, - [PCHG_CHIPSET_STATE_SUSPEND] = &pchg_policy_suspend, - }, - .events = QUEUE_NULL(PCHG_EVENT_QUEUE_SIZE, enum pchg_event), - }, -}; -const int pchg_count = ARRAY_SIZE(pchgs); - -__override void board_pchg_power_on(int port, bool on) -{ - if (port == 0) - gpio_set_level(GPIO_EC_QI_PWR, on); - else - CPRINTS("%s: Invalid port=%d", __func__, port); -} - /******************************************************************************/ int board_set_active_charge_port(int port) @@ -118,7 +90,6 @@ int board_set_active_charge_port(int port) switch (port) { case CHARGE_PORT_TYPEC0: case CHARGE_PORT_TYPEC1: - case CHARGE_PORT_TYPEC2: gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 1); break; case CHARGE_PORT_BARRELJACK: @@ -293,6 +264,7 @@ void board_overcurrent_event(int port, int is_overcurrented) usbc_overcurrent = is_overcurrented; update_5v_usage(); } + /* * Power monitoring and management. * @@ -336,7 +308,6 @@ void board_overcurrent_event(int port, int is_overcurrented) #define THROT_TYPE_A_REAR BIT(1) #define THROT_TYPE_C0 BIT(2) #define THROT_TYPE_C1 BIT(3) -#define THROT_TYPE_C2 BIT(4) #define THROT_PROCHOT BIT(5) /* @@ -470,16 +441,6 @@ static void power_monitor(void) if (!(current_state & THROT_TYPE_C1)) gap += POWER_GAIN_TYPE_C; } - /* - * If the type-C port is sourcing power, - * check whether it should be throttled. - */ - if (ppc_is_sourcing_vbus(2) && gap <= 0) { - new_state |= THROT_TYPE_C2; - headroom_5v_z1 += PWR_Z1_C_HIGH - PWR_Z1_C_LOW; - if (!(current_state & THROT_TYPE_C2)) - gap += POWER_GAIN_TYPE_C; - } /* * As a last resort, turn on PROCHOT to * throttle the CPU. @@ -570,15 +531,6 @@ static void power_monitor(void) tcpm_select_rp_value(1, rp); pd_update_contract(1); } - if (diff & THROT_TYPE_C2) { - enum tcpc_rp_value rp = (new_state & THROT_TYPE_C2) ? - TYPEC_RP_1A5 : - TYPEC_RP_3A0; - - ppc_set_vbus_source_current_limit(2, rp); - tcpm_select_rp_value(2, rp); - pd_update_contract(2); - } if (diff & THROT_TYPE_A_REAR) { int typea_bc = (new_state & THROT_TYPE_A_REAR) ? 1 : 0; diff --git a/board/gaelin/board.h b/board/gaelin/board.h index 8323c99599..2ce5008bd7 100644 --- a/board/gaelin/board.h +++ b/board/gaelin/board.h @@ -16,7 +16,7 @@ #define CONFIG_MP2964 /* Barrel Jack */ -#define DEDICATED_CHARGE_PORT 3 +#define DEDICATED_CHARGE_PORT 2 /* HDMI CEC */ #define CONFIG_CEC @@ -31,19 +31,9 @@ /* USB Type C and USB PD defines */ #define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY -#define CONFIG_IO_EXPANDER -#define CONFIG_IO_EXPANDER_NCT38XX -#define CONFIG_IO_EXPANDER_PORT_COUNT 2 - #define CONFIG_USB_PD_PPC -#define CONFIG_USB_PD_TCPM_RT1715 -#define CONFIG_USBC_RETIMER_INTEL_BB - -#define CONFIG_USBC_RETIMER_KB800X -#define CONFIG_KB800X_CUSTOM_XBAR -#define CONFIG_USBC_PPC_SYV682X -#undef CONFIG_SYV682X_HV_ILIM -#define CONFIG_SYV682X_HV_ILIM SYV682X_HV_ILIM_5_50 +#define CONFIG_USB_PD_TCPM_PS8815 +#define CONFIG_USBC_PPC_NX20P3483 /* Compatible with Silicon Mitus SM5360A */ /* TODO: b/177608416 - measure and check these values on brya */ #define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ @@ -92,22 +82,15 @@ #define GPIO_RECOVERY_L_2 GPIO_GSC_EC_RECOVERY_BTN_OD /* I2C Bus Configuration */ - -#define I2C_PORT_DP_REDRIVER NPCX_I2C_PORT0_0 - -#define I2C_PORT_USB_C0_C2_TCPC NPCX_I2C_PORT1_0 +#define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0 #define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1 -#define I2C_PORT_USB_C0_C2_PPC NPCX_I2C_PORT2_0 -#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1 - -#define I2C_PORT_USB_C0_C2_BC12 NPCX_I2C_PORT2_0 -#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT6_1 +#define I2C_PORT_USB_C0_PPC NPCX_I2C_PORT2_0 +#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT3_0 -#define I2C_PORT_USB_C0_C2_MUX NPCX_I2C_PORT3_0 -#define I2C_PORT_USB_C1_MUX NPCX_I2C_PORT6_1 +#define I2C_PORT_USB_C0_BC12 NPCX_I2C_PORT2_0 +#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT3_0 -#define I2C_PORT_QI NPCX_I2C_PORT5_0 #define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 #define I2C_PORT_MP2964 NPCX_I2C_PORT7_0 @@ -115,18 +98,6 @@ #define I2C_ADDR_MP2964_FLAGS 0x20 -#define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x58 -#define USBC_PORT_C2_BB_RETIMER_I2C_ADDR 0x59 - -/* Enabling Thunderbolt-compatible mode */ -#define CONFIG_USB_PD_TBT_COMPAT_MODE - -/* Enabling USB4 mode */ -#define CONFIG_USB_PD_USB4 - -/* Retimer */ -#define CONFIG_USBC_RETIMER_FW_UPDATE - /* Thermal features */ #define CONFIG_THERMISTOR #define CONFIG_TEMP_SENSOR @@ -144,12 +115,6 @@ /* Include math_util for bitmask_uint64 used in pd_timers */ #define CONFIG_MATH_UTIL -/* WPC/Qi charger */ -#ifdef SECTION_IS_RW -#define CONFIG_PERIPHERAL_CHARGER -#define CONFIG_CPS8100 -#endif - #ifndef __ASSEMBLER__ #include "gpio_signal.h" /* needed by registers.h */ @@ -159,7 +124,6 @@ enum charge_port { CHARGE_PORT_TYPEC0, CHARGE_PORT_TYPEC1, - CHARGE_PORT_TYPEC2, CHARGE_PORT_BARRELJACK, CHARGE_PORT_ENUM_COUNT }; @@ -182,8 +146,6 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; -enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT }; - enum pwm_channel { PWM_CH_LED_GREEN, /* PWM0 */ PWM_CH_FAN, /* PWM5 */ diff --git a/board/gaelin/ec.tasklist b/board/gaelin/ec.tasklist index d16fc35f52..4a40f332e8 100644 --- a/board/gaelin/ec.tasklist +++ b/board/gaelin/ec.tasklist @@ -12,10 +12,8 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS_RW(PCHG, pchg_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 0, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P2, usb_charger_task, 0, TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(USB_MUX, usb_mux_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ @@ -23,7 +21,6 @@ TASK_ALWAYS(POWERBTN, power_button_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(PD_C0, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(PD_C1, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C2, pd_task, NULL, VENTI_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_INT_C0, pd_shared_alert_task, (BIT(2) | BIT(0)), LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CEC, cec_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/board/gaelin/gpio.inc b/board/gaelin/gpio.inc index 51cf0010c6..c39d048e8d 100644 --- a/board/gaelin/gpio.inc +++ b/board/gaelin/gpio.inc @@ -18,15 +18,11 @@ GPIO_INT(SLP_S3_L, PIN(A, 5), GPIO_INT_BOTH, power_signal_inte GPIO_INT(SLP_SUS_L, PIN(F, 1), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(SYS_SLP_S0IX_L, PIN(D, 5), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(USB_C0_BC12_INT_ODL, PIN(C, 6), GPIO_INT_FALLING, bc12_interrupt) -GPIO_INT(USB_C0_C2_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event) +GPIO_INT(USB_C0_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event) GPIO_INT(USB_C0_PPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, ppc_interrupt) -GPIO_INT(USB_C0_RT_INT_ODL, PIN(B, 1), GPIO_INT_FALLING, retimer_interrupt) GPIO_INT(USB_C1_BC12_INT_ODL, PIN(5, 0), GPIO_INT_FALLING, bc12_interrupt) GPIO_INT(USB_C1_PPC_INT_ODL, PIN(F, 5), GPIO_INT_FALLING, ppc_interrupt) GPIO_INT(USB_C1_TCPC_INT_ODL, PIN(A, 2), GPIO_INT_FALLING, tcpc_alert_event) -GPIO_INT(USB_C2_BC12_INT_ODL, PIN(8, 3), GPIO_INT_FALLING, bc12_interrupt) -GPIO_INT(USB_C2_PPC_INT_ODL, PIN(7, 0), GPIO_INT_FALLING, ppc_interrupt) -GPIO_INT(USB_C2_RT_INT_ODL, PIN(4, 1), GPIO_INT_FALLING, retimer_interrupt) GPIO_INT(BJ_ADP_PRESENT_ODL, PIN(8, 2), GPIO_INT_BOTH | GPIO_PULL_UP, adp_connect_interrupt) GPIO_INT(EC_RECOVERY_BTN_OD, PIN(2, 3), GPIO_INT_BOTH, button_interrupt) GPIO_INT(HDMI_CONN_OC_ODL, PIN(2, 4), GPIO_INPUT | GPIO_INT_BOTH, port_ocp_interrupt) @@ -34,11 +30,6 @@ GPIO_INT(USB_A0_OC_ODL, PIN(3, 1), GPIO_INPUT | GPIO_PULL_UP | GPIO GPIO_INT(USB_A1_OC_ODL, PIN(3, 0), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt) GPIO_INT(USB_A2_OC_ODL, PIN(2, 7), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt) GPIO_INT(USB_A3_OC_ODL, PIN(2, 6), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt) -#ifdef SECTION_IS_RW -GPIO_INT(QI_INT_ODL, PIN(9, 6), GPIO_INT_FALLING, pchg_irq) -#else -UNIMPLEMENTED(QI_INT_ODL) -#endif /* CCD */ GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_INPUT) @@ -79,17 +70,6 @@ GPIO(CPU_C10_GATE_L, PIN(6, 7), GPIO_INPUT) GPIO(EC_PCH_PWR_BTN_ODL, PIN(C, 1), GPIO_ODR_HIGH) GPIO(GSC_EC_RECOVERY_BTN_OD, PIN(2, 2), GPIO_INPUT) -/* NFC */ -/* TODO(b/194068530): Enable NFC */ -GPIO(NFC_COIL_ACT_L, PIN(D, 4), GPIO_INPUT) -GPIO(NFC_LOW_POWER_MODE, PIN(9, 5), GPIO_OUT_HIGH) -GPIO(NFC_CARD_DET_L, PIN(A, 3), GPIO_INPUT) -GPIO(EN_NFC_BUZZER, PIN(0, 5), GPIO_OUT_LOW) - -/* Wireless Charger */ -GPIO(EC_QI_PWR, PIN(D, 2), GPIO_OUT_LOW) -GPIO(QI_RESET_L, PIN(9, 3), GPIO_OUT_HIGH) - /* HDMI CEC */ /* TODO(b/197474873): Enable HDMI CEC */ GPIO(HDMI_CEC_IN, PIN(4, 0), GPIO_INPUT) @@ -97,20 +77,14 @@ GPIO(HDMI_CEC_OUT, PIN(D, 3), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) GPIO(HDMI_CEC_PULL_UP, PIN(C, 2), GPIO_OUT_HIGH) /* I2C SCL/SDA */ -GPIO(EC_I2C_QI_SCL, PIN(3, 3), GPIO_INPUT) -GPIO(EC_I2C_QI_SDA, PIN(3, 6), GPIO_INPUT) GPIO(EC_I2C_MISC_SCL_R, PIN(B, 3), GPIO_INPUT) GPIO(EC_I2C_MISC_SDA_R, PIN(B, 2), GPIO_INPUT) -GPIO(EC_I2C_DP_SCL, PIN(B, 5), GPIO_INPUT) -GPIO(EC_I2C_DP_SDA, PIN(B, 4), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_PPC_SCL, PIN(9, 2), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_PPC_SDA, PIN(9, 1), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_RT_SCL, PIN(D, 1), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_RT_SDA, PIN(D, 0), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_TCPC_SCL, PIN(9, 0), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_TCPC_SDA, PIN(8, 7), GPIO_INPUT) -GPIO(EC_I2C_USB_C1_MIX_SCL, PIN(E, 4), GPIO_INPUT) -GPIO(EC_I2C_USB_C1_MIX_SDA, PIN(E, 3), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_PPC_BC_SCL, PIN(9, 2), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_PPC_BC_SDA, PIN(9, 1), GPIO_INPUT) +GPIO(EC_I2C_USB_C1_PPC_BC_SCL, PIN(D, 1), GPIO_INPUT) +GPIO(EC_I2C_USB_C1_PPC_BC_SDA, PIN(D, 0), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_TCPC_SCL, PIN(9, 0), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_TCPC_SDA, PIN(8, 7), GPIO_INPUT) GPIO(EC_I2C_USB_C1_TCPC_SCL, PIN(F, 3), GPIO_INPUT) GPIO(EC_I2C_USB_C1_TCPC_SDA, PIN(F, 2), GPIO_INPUT) @@ -132,32 +106,23 @@ GPIO(LED_GREEN_L, PIN(C, 3), GPIO_OUT_LOW) GPIO(LED_RED_L, PIN(C, 4), GPIO_OUT_LOW) /* USBC */ -GPIO(USB_C0_C2_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW) +GPIO(USB_C0_FRS_EN, PIN(9, 7), GPIO_OUT_LOW) +GPIO(USB_C0_RT_RST_L, PIN(A, 7), GPIO_OUT_HIGH) GPIO(USB_C1_FRS_EN, PIN(9, 4), GPIO_OUT_LOW) -GPIO(USB_C1_RT_INT_ODL, PIN(A, 0), GPIO_INPUT) -GPIO(USB_C1_RT_RST_R_L, PIN(0, 2), GPIO_OUT_LOW) +GPIO(USB_C1_RT_RST_L, PIN(0, 2), GPIO_OUT_HIGH) /* GPIO02_P2 to PU */ /* GPIO03_P2 to PU */ -IOEX(USB_C0_OC_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 4), GPIO_ODR_HIGH) -IOEX(USB_C0_FRS_EN, EXPIN(IOEX_C0_NCT38XX, 0, 6), GPIO_LOW) -IOEX(USB_C0_RT_RST_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 7), GPIO_ODR_LOW) - -IOEX(USB_C2_RT_RST_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 2), GPIO_ODR_LOW) -IOEX(USB_C1_OC_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 3), GPIO_ODR_HIGH) -IOEX(USB_C2_OC_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 4), GPIO_ODR_HIGH) -IOEX(USB_C2_FRS_EN, EXPIN(IOEX_C2_NCT38XX, 0, 6), GPIO_LOW) /* GPIO07_P2 to PU */ /* UART alternate functions */ ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* GPIO64/CR_SIN1, GPO65/CR_SOUT1/FLPRG1_L */ /* I2C alternate functions */ -ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* GPIO33/I2C5_SCL0/CTS_L, GPIO36/RTS_L/I2C5_SDA0 */ +ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* GPIO36/RTS_L/I2C5_SDA0, GPIO33/I2C5_SCL0/CTS_L */ ALTERNATE(PIN_MASK(8, 0x80), 0, MODULE_I2C, 0) /* GPIO87/I2C1_SDA0 */ ALTERNATE(PIN_MASK(9, 0x07), 0, MODULE_I2C, 0) /* GPIO92/I2C2_SCL0, GPIO91/I2C2_SDA0, GPIO90/I2C1_SCL0 */ ALTERNATE(PIN_MASK(B, 0x0c), 0, MODULE_I2C, 0) /* GPIOB3/I2C7_SCL0/DCD_L, GPIOB2/I2C7_SDA0/DSR_L */ -ALTERNATE(PIN_MASK(B, 0x30), 0, MODULE_I2C, 0) /* GPIOB5/I2C0_SCL0, GPIOB4/I2C0_SDA0 */ ALTERNATE(PIN_MASK(D, 0x03), 0, MODULE_I2C, 0) /* GPIOD1/I2C3_SCL0, GPIOD0/I2C3_SDA0 */ ALTERNATE(PIN_MASK(E, 0x18), 0, MODULE_I2C, 0) /* GPIOE4/I2C6_SCL1/I3C_SCL, GPIOE3/I2C6_SDA1/I3C_SDA */ ALTERNATE(PIN_MASK(F, 0x0c), 0, MODULE_I2C, 0) /* GPIOF3/I2C4_SCL1, GPIOF2/I2C4_SDA1 */ @@ -179,9 +144,15 @@ UNUSED(PIN(3, 5)) /* GPO35/CR_SOUT4/TEST_L */ UNUSED(PIN(6, 6)) /* GPIO66 */ UNUSED(PIN(8, 1)) /* GPIO81/PECI_DATA */ UNUSED(PIN(5, 6)) /* GPIO56/CLKRUN# */ -UNUSED(PIN(9, 7)) /* GPIO97 */ UNUSED(PIN(8, 6)) /* GPIO86/TXD/CR_SOUT2 */ UNUSED(PIN(1, 3)) /* KSO06/GPO13/GP_SEL# */ UNUSED(PIN(1, 2)) /* KSO07/GPO12/JEN# */ UNUSED(PIN(0, 6)) /* KSO11/GPIO06/P80_CLK */ UNUSED(PIN(0, 4)) /* KSO13/GPIO04 */ +UNUSED(PIN(B, 4)) /* GPIOB4/I2C0_SDA0 */ +UNUSED(PIN(0, 5)) /* KSO12/GPIO05 */ +UNUSED(PIN(B, 5)) /* GPIOB5/I2C0_SCL0 */ +UNUSED(PIN(8, 3)) /* KSO15/GPIO83 */ +UNUSED(PIN(B, 1)) /* KSO17/GPIOB1/CR_SIN4 */ +UNUSED(PIN(7, 0)) /* GPIO70/PS2_DAT0 */ +UNUSED(PIN(A, 3)) /* SPIP_MOSI/GPIOA3 */ diff --git a/board/gaelin/i2c.c b/board/gaelin/i2c.c index 0a0b6b69a6..b3bd2023c5 100644 --- a/board/gaelin/i2c.c +++ b/board/gaelin/i2c.c @@ -10,62 +10,38 @@ /* I2C port map configuration */ const struct i2c_port_t i2c_ports[] = { - { - /* I2C0 */ - .name = "dp_redriver", - .port = I2C_PORT_DP_REDRIVER, - .kbps = 400, - .scl = GPIO_EC_I2C_DP_SCL, - .sda = GPIO_EC_I2C_DP_SDA, - }, { /* I2C1 */ - .name = "tcpc0,2", - .port = I2C_PORT_USB_C0_C2_TCPC, + .name = "tcpc0", + .port = I2C_PORT_USB_C0_TCPC, .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C0_C2_TCPC_SCL, - .sda = GPIO_EC_I2C_USB_C0_C2_TCPC_SDA, + .scl = GPIO_EC_I2C_USB_C0_TCPC_SCL, + .sda = GPIO_EC_I2C_USB_C0_TCPC_SDA, }, { /* I2C2 */ - .name = "ppc0,2", - .port = I2C_PORT_USB_C0_C2_PPC, + .name = "ppc0", + .port = I2C_PORT_USB_C0_PPC, .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C0_C2_PPC_SCL, - .sda = GPIO_EC_I2C_USB_C0_C2_PPC_SDA, + .scl = GPIO_EC_I2C_USB_C0_PPC_BC_SCL, + .sda = GPIO_EC_I2C_USB_C0_PPC_BC_SDA, }, { /* I2C3 */ - .name = "retimer0,2", - .port = I2C_PORT_USB_C0_C2_MUX, + .name = "ppc1", + .port = I2C_PORT_USB_C1_PPC, .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C0_C2_RT_SCL, - .sda = GPIO_EC_I2C_USB_C0_C2_RT_SDA, + .scl = GPIO_EC_I2C_USB_C1_PPC_BC_SCL, + .sda = GPIO_EC_I2C_USB_C1_PPC_BC_SDA, }, { - /* I2C4 C1 TCPC */ + /* I2C4 */ .name = "tcpc1", .port = I2C_PORT_USB_C1_TCPC, - .kbps = 400, + .kbps = 1000, .scl = GPIO_EC_I2C_USB_C1_TCPC_SCL, .sda = GPIO_EC_I2C_USB_C1_TCPC_SDA, }, - { - /* I2C5 */ - .name = "wireless_charger", - .port = I2C_PORT_QI, - .kbps = 400, - .scl = GPIO_EC_I2C_QI_SCL, - .sda = GPIO_EC_I2C_QI_SDA, - }, - { - /* I2C6 */ - .name = "ppc1", - .port = I2C_PORT_USB_C1_PPC, - .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C1_MIX_SCL, - .sda = GPIO_EC_I2C_USB_C1_MIX_SDA, - }, { /* I2C7 */ .name = "eeprom", diff --git a/board/gaelin/usbc_config.c b/board/gaelin/usbc_config.c index 806ff2c4ee..98595fc607 100644 --- a/board/gaelin/usbc_config.c +++ b/board/gaelin/usbc_config.c @@ -10,17 +10,13 @@ #include "compile_time_macros.h" #include "console.h" #include "driver/bc12/pi3usb9201_public.h" -#include "driver/ppc/syv682x_public.h" -#include "driver/retimer/bb_retimer_public.h" -#include "driver/retimer/kb800x.h" -#include "driver/tcpm/nct38xx.h" -#include "driver/tcpm/rt1715.h" +#include "driver/ppc/nx20p348x.h" +#include "driver/tcpm/ps8xxx_public.h" #include "driver/tcpm/tcpci.h" #include "ec_commands.h" #include "gpio.h" #include "gpio_signal.h" #include "hooks.h" -#include "ioexpander.h" #include "system.h" #include "task.h" #include "task_id.h" @@ -40,29 +36,22 @@ const struct tcpc_config_t tcpc_config[] = { [USBC_PORT_C0] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { - .port = I2C_PORT_USB_C0_C2_TCPC, - .addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS, + .port = I2C_PORT_USB_C0_TCPC, + .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, }, - .drv = &nct38xx_tcpm_drv, + .drv = &ps8xxx_tcpm_drv, .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_NO_DEBUG_ACC_CONTROL, + TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V, }, [USBC_PORT_C1] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = RT1715_I2C_ADDR_FLAGS, + .addr_flags = PS8XXX_I2C_ADDR2_FLAGS, }, - .drv = &rt1715_tcpm_drv, - }, - [USBC_PORT_C2] = { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_C2_TCPC, - .addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS, - }, - .drv = &nct38xx_tcpm_drv, - .flags = TCPC_FLAGS_TCPCI_REV2_0, + .drv = &ps8xxx_tcpm_drv, + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V, }, }; BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT); @@ -71,19 +60,16 @@ BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT); /* USBC PPC configuration */ struct ppc_config_t ppc_chips[] = { [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_USB_C0_C2_PPC, - .i2c_addr_flags = SYV682X_ADDR0_FLAGS, - .drv = &syv682x_drv, + /* Compatible with Silicon Mitus SM5360A */ + .i2c_port = I2C_PORT_USB_C0_PPC, + .i2c_addr_flags = NX20P3483_ADDR2_FLAGS, + .drv = &nx20p348x_drv, }, [USBC_PORT_C1] = { + /* Compatible with Silicon Mitus SM5360A */ .i2c_port = I2C_PORT_USB_C1_PPC, - .i2c_addr_flags = SYV682X_ADDR0_FLAGS, - .drv = &syv682x_drv, - }, - [USBC_PORT_C2] = { - .i2c_port = I2C_PORT_USB_C0_C2_PPC, - .i2c_addr_flags = SYV682X_ADDR2_FLAGS, - .drv = &syv682x_drv, + .i2c_addr_flags = NX20P3483_ADDR3_FLAGS, + .drv = &nx20p348x_drv, }, }; BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT); @@ -95,200 +81,100 @@ static const struct usb_mux_chain usbc0_tcss_usb_mux = { .mux = &(const struct usb_mux){ .usb_port = USBC_PORT_C0, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, }, }; static const struct usb_mux_chain usbc1_tcss_usb_mux = { .mux = &(const struct usb_mux){ .usb_port = USBC_PORT_C1, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, + .driver = &tcpci_tcpm_usb_mux_driver, + .hpd_update = &ps8xxx_tcpc_update_hpd_status, }, }; -static const struct usb_mux_chain usbc2_tcss_usb_mux = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C2, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, - }, -}; - -struct kb800x_control_t kb800x_control[] = { - [USBC_PORT_C0] = { - }, - [USBC_PORT_C1] = { - .retimer_rst_gpio = GPIO_USB_C1_RT_RST_R_L, - .ss_lanes = { - [KB800X_A0] = KB800X_TX0, [KB800X_A1] = KB800X_RX0, - [KB800X_B0] = KB800X_RX1, [KB800X_B1] = KB800X_TX1, - [KB800X_C0] = KB800X_RX0, [KB800X_C1] = KB800X_TX0, - [KB800X_D0] = KB800X_TX1, [KB800X_D1] = KB800X_RX1, - } - }, - [USBC_PORT_C2] = { - }, -}; -BUILD_ASSERT(ARRAY_SIZE(kb800x_control) == USBC_PORT_COUNT); const struct usb_mux_chain usb_muxes[] = { [USBC_PORT_C0] = { .mux = &(const struct usb_mux) { .usb_port = USBC_PORT_C0, - .driver = &bb_usb_retimer, - .hpd_update = bb_retimer_hpd_update, - .i2c_port = I2C_PORT_USB_C0_C2_MUX, - .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR, + .driver = &virtual_usb_mux_driver, + .hpd_update = &virtual_hpd_update, }, .next = &usbc0_tcss_usb_mux, }, [USBC_PORT_C1] = { .mux = &(const struct usb_mux) { .usb_port = USBC_PORT_C1, - .driver = &kb800x_usb_mux_driver, - .i2c_port = I2C_PORT_USB_C1_MUX, - .i2c_addr_flags = KB800X_I2C_ADDR0_FLAGS, + .driver = &virtual_usb_mux_driver, + .hpd_update = &virtual_hpd_update, }, .next = &usbc1_tcss_usb_mux, }, - [USBC_PORT_C2] = { - .mux = &(const struct usb_mux) { - .usb_port = USBC_PORT_C2, - .driver = &bb_usb_retimer, - .hpd_update = bb_retimer_hpd_update, - .i2c_port = I2C_PORT_USB_C0_C2_MUX, - .i2c_addr_flags = USBC_PORT_C2_BB_RETIMER_I2C_ADDR, - }, - .next = &usbc2_tcss_usb_mux, - }, }; BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT); /* BC1.2 charger detect configuration */ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_USB_C0_C2_BC12, + .i2c_port = I2C_PORT_USB_C0_BC12, .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, }, [USBC_PORT_C1] = { .i2c_port = I2C_PORT_USB_C1_BC12, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, - }, - [USBC_PORT_C2] = { - .i2c_port = I2C_PORT_USB_C0_C2_BC12, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_1_FLAGS, + .i2c_addr_flags = PI3USB9201_I2C_ADDR_2_FLAGS, }, }; BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT); -/* - * USB C0 and C2 uses burnside bridge chips and have their reset - * controlled by their respective TCPC chips acting as GPIO expanders. - * - * ioex_init() is normally called before we take the TCPCs out of - * reset, so we need to start in disabled mode, then explicitly - * call ioex_init(). - */ - -struct ioexpander_config_t ioex_config[] = { - [IOEX_C0_NCT38XX] = { - .i2c_host_port = I2C_PORT_USB_C0_C2_TCPC, - .i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS, - .drv = &nct38xx_ioexpander_drv, - .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED, - }, - [IOEX_C2_NCT38XX] = { - .i2c_host_port = I2C_PORT_USB_C0_C2_TCPC, - .i2c_addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS, - .drv = &nct38xx_ioexpander_drv, - .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED, - }, -}; -BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT); - -__override int bb_retimer_power_enable(const struct usb_mux *me, bool enable) +static void ps8815_reset(int port) { - enum ioex_signal rst_signal; - - if (me->usb_port == USBC_PORT_C0) { - rst_signal = IOEX_USB_C0_RT_RST_ODL; - } else if (me->usb_port == USBC_PORT_C2) { - rst_signal = IOEX_USB_C2_RT_RST_ODL; + int val; + int i2c_port; + uint16_t i2c_addr_flags; + enum gpio_signal ps8xxx_rst_odl; + + if (port == USBC_PORT_C0) { + ps8xxx_rst_odl = GPIO_USB_C0_RT_RST_L; + i2c_port = I2C_PORT_USB_C0_TCPC; + i2c_addr_flags = PS8XXX_I2C_ADDR1_FLAGS; + } else if (port == USBC_PORT_C1) { + ps8xxx_rst_odl = GPIO_USB_C1_RT_RST_L; + i2c_port = I2C_PORT_USB_C1_TCPC; + i2c_addr_flags = PS8XXX_I2C_ADDR2_FLAGS; } else { - return EC_ERROR_INVAL; + return; } - /* - * We do not have a load switch for the burnside bridge chips, - * so we only need to sequence reset. - */ + gpio_set_level(ps8xxx_rst_odl, 0); + msleep(GENERIC_MAX(PS8XXX_RESET_DELAY_MS, PS8815_PWR_H_RST_H_DELAY_MS)); + gpio_set_level(ps8xxx_rst_odl, 1); + msleep(PS8815_FW_INIT_DELAY_MS); - if (enable) { - /* - * Tpw, minimum time from VCC to RESET_N de-assertion is 100us. - * For boards that don't provide a load switch control, the - * retimer_init() function ensures power is up before calling - * this function. - */ - ioex_set_level(rst_signal, 1); - /* - * Allow 1ms time for the retimer to power up lc_domain - * which powers I2C controller within retimer - */ - msleep(1); - } else { - ioex_set_level(rst_signal, 0); - msleep(1); + CPRINTS("[C%d] %s: patching ps8815 registers", port, __func__); + + if (i2c_read8(i2c_port, i2c_addr_flags, 0x0f, &val) == EC_SUCCESS) + CPRINTS("ps8815: reg 0x0f was %02x", val); + else { + CPRINTS("delay 10ms to make sure ps8815 is waken from idle"); + msleep(10); } - return EC_SUCCESS; -} -__override int bb_retimer_reset(const struct usb_mux *me) -{ - /* - * TODO(b/193402306, b/195375738): Remove this once transition to - * QS Silicon is complete - */ - bb_retimer_power_enable(me, false); - msleep(5); - bb_retimer_power_enable(me, true); - msleep(25); + if (i2c_write8(i2c_port, i2c_addr_flags, 0x0f, 0x31) == EC_SUCCESS) + CPRINTS("ps8815: reg 0x0f set to 0x31"); - return EC_SUCCESS; + if (i2c_read8(i2c_port, i2c_addr_flags, 0x0f, &val) == EC_SUCCESS) + CPRINTS("ps8815: reg 0x0f now %02x", val); } void board_reset_pd_mcu(void) { - enum gpio_signal tcpc_rst; - - tcpc_rst = GPIO_USB_C0_C2_TCPC_RST_ODL; - - /* - * TODO(b/179648104): figure out correct timing - */ - - gpio_set_level(tcpc_rst, 0); - gpio_set_level(GPIO_USB_C1_RT_RST_R_L, 0); - - /* - * delay for power-on to reset-off and min. assertion time - */ - - msleep(20); - - gpio_set_level(tcpc_rst, 1); - gpio_set_level(GPIO_USB_C1_RT_RST_R_L, 1); - - /* wait for chips to come up */ - - msleep(50); -} - -static void enable_ioex(int ioex) -{ - ioex_init(ioex); + ps8815_reset(USBC_PORT_C0); + usb_mux_hpd_update(USBC_PORT_C0, USB_PD_MUX_HPD_LVL_DEASSERTED | + USB_PD_MUX_HPD_IRQ_DEASSERTED); + ps8815_reset(USBC_PORT_C1); + usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED | + USB_PD_MUX_HPD_IRQ_DEASSERTED); } static void board_tcpc_init(void) @@ -296,25 +182,19 @@ static void board_tcpc_init(void) /* Don't reset TCPCs after initial reset */ if (!system_jumped_late()) { board_reset_pd_mcu(); - - /* - * These IO expander pins are implemented using the - * C0/C2 TCPC, so they must be set up after the TCPC has - * been taken out of reset. - */ - enable_ioex(IOEX_C0_NCT38XX); - enable_ioex(IOEX_C2_NCT38XX); } /* Enable PPC interrupts. */ gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_ODL); - gpio_enable_interrupt(GPIO_USB_C2_PPC_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL); /* Enable TCPC interrupts. */ - gpio_enable_interrupt(GPIO_USB_C0_C2_TCPC_INT_ODL); - - gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL); gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL); + + /* Enable BC1.2 interrupts. */ + gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_ODL); } DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_CHIPSET); @@ -322,8 +202,8 @@ uint16_t tcpc_get_alert_status(void) { uint16_t status = 0; - if (gpio_get_level(GPIO_USB_C0_C2_TCPC_INT_ODL) == 0) - status |= PD_STATUS_TCPC_ALERT_0 | PD_STATUS_TCPC_ALERT_2; + if (gpio_get_level(GPIO_USB_C0_TCPC_INT_ODL) == 0) + status |= PD_STATUS_TCPC_ALERT_0; if (gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL) == 0) status |= PD_STATUS_TCPC_ALERT_1; @@ -337,15 +217,13 @@ int ppc_get_alert_status(int port) return gpio_get_level(GPIO_USB_C0_PPC_INT_ODL) == 0; else if (port == USBC_PORT_C1) return gpio_get_level(GPIO_USB_C1_PPC_INT_ODL) == 0; - else if (port == USBC_PORT_C2) - return gpio_get_level(GPIO_USB_C2_PPC_INT_ODL) == 0; return 0; } void tcpc_alert_event(enum gpio_signal signal) { switch (signal) { - case GPIO_USB_C0_C2_TCPC_INT_ODL: + case GPIO_USB_C0_TCPC_INT_ODL: schedule_deferred_pd_interrupt(USBC_PORT_C0); break; case GPIO_USB_C1_TCPC_INT_ODL: @@ -365,9 +243,6 @@ void bc12_interrupt(enum gpio_signal signal) case GPIO_USB_C1_BC12_INT_ODL: usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); break; - case GPIO_USB_C2_BC12_INT_ODL: - usb_charger_task_set_event(2, USB_CHG_EVENT_BC12); - break; default: break; } @@ -377,13 +252,10 @@ void ppc_interrupt(enum gpio_signal signal) { switch (signal) { case GPIO_USB_C0_PPC_INT_ODL: - syv682x_interrupt(USBC_PORT_C0); + nx20p348x_interrupt(USBC_PORT_C0); break; case GPIO_USB_C1_PPC_INT_ODL: - syv682x_interrupt(USBC_PORT_C1); - break; - case GPIO_USB_C2_PPC_INT_ODL: - syv682x_interrupt(USBC_PORT_C2); + nx20p348x_interrupt(USBC_PORT_C1); break; default: break; @@ -401,16 +273,3 @@ __override bool board_is_dts_port(int port) { return port == USBC_PORT_C0; } - -__override bool board_is_tbt_usb4_port(int port) -{ - return true; -} - -__override enum tbt_compat_cable_speed board_get_max_tbt_speed(int port) -{ - if (!board_is_tbt_usb4_port(port)) - return TBT_SS_RES_0; - - return TBT_SS_TBT_GEN3; -} diff --git a/board/gaelin/usbc_config.h b/board/gaelin/usbc_config.h index 5e7beae21a..219ad9a745 100644 --- a/board/gaelin/usbc_config.h +++ b/board/gaelin/usbc_config.h @@ -8,13 +8,8 @@ #ifndef __CROS_EC_USBC_CONFIG_H #define __CROS_EC_USBC_CONFIG_H -#define CONFIG_USB_PD_PORT_MAX_COUNT 3 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 -enum usbc_port { - USBC_PORT_C0 = 0, - USBC_PORT_C1, - USBC_PORT_C2, - USBC_PORT_COUNT -}; +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; #endif /* __CROS_EC_USBC_CONFIG_H */ -- cgit v1.2.1 From 829b707486770d97c524ef39cd85d5543bfb7bac Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 11 Nov 2022 12:05:51 +0000 Subject: zephyr: shim: use device specific 1.8V GPIO flags The generic GPIO_VOLTAGE_1P8 flag is deprecated and has been removed upstream in favor of device specific flags, which right now have been defined to use the same bit, but that may change in the future. In the EC firmware we share chunks of dts files on boards with different architectures, so we still need a common flag that can be redefined to the platform specific one. This patch supports the change by: - redefine GPIO_VOLTAGE_1P8 for the devicetree files, but set it for the specific architecture being built, this is done using the platform dts files - redefine GPIO_VOLTAGE_1P8 for the source code depending on what GPIO controller is used (which would not work if we had to use it on port expanders, but that may never be a problem) - define an entry for native_posix for the unit test to use - undefine the legacy GPIO_SEL_1P8V entry if not supported BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Cq-Depend: chromium:4023593 Change-Id: Ife34ecc23fb1e18b13a7bcdbe378b0a182c50249 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023445 Code-Coverage: Zoss Reviewed-by: Keith Short --- common/gpio_commands.c | 5 ++++- include/gpio.h | 12 ++++++++++++ zephyr/boards/arm/npcx7/npcx7.dts | 3 +++ zephyr/boards/arm/npcx9/npcx9.dtsi | 3 +++ zephyr/boards/riscv/it8xxx2/it8xxx2.dts | 3 +++ zephyr/dts/board-overlays/native_posix.dts | 3 +++ zephyr/dts/it8xxx2_emul.dts | 3 +++ zephyr/include/dt-bindings/native-posix-gpio.h | 12 ++++++++++++ zephyr/shim/src/gpio.c | 5 +++++ 9 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 zephyr/include/dt-bindings/native-posix-gpio.h diff --git a/common/gpio_commands.c b/common/gpio_commands.c index d6257ea61d..06e0203090 100644 --- a/common/gpio_commands.c +++ b/common/gpio_commands.c @@ -91,7 +91,10 @@ __maybe_unused static const struct gpio_flag_description gpio_descriptions[] = { { GPIO_INPUT, "I" }, { GPIO_OUTPUT, "O" }, { GPIO_LOW, "L" }, { GPIO_HIGH, "H" }, { GPIO_OPEN_DRAIN, "ODR" }, { GPIO_PULL_UP, "PU" }, - { GPIO_PULL_DOWN, "PD" }, { GPIO_SEL_1P8V, "1P8" }, + { GPIO_PULL_DOWN, "PD" }, +#ifdef GPIO_SEL_1P8V + { GPIO_SEL_1P8V, "1P8" }, +#endif #ifndef CONFIG_ZEPHYR { GPIO_ANALOG, "A" }, { GPIO_ALTERNATE, "ALT" }, { GPIO_LOCKED, "LCK" } diff --git a/include/gpio.h b/include/gpio.h index 54464d1bfb..f6729c7830 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -21,6 +21,9 @@ */ #ifdef CONFIG_ZEPHYR #include +#include +#include +#include /* * Some flag definitions are duplicated by our private devicetree binding @@ -79,7 +82,16 @@ /* GPIO_INT_DSLEEP not supported by Zephyr */ /* GPIO_INT_SHARED not supported by Zephyr */ +#if DT_HAS_COMPAT_STATUS_OKAY(nuvoton_npcx_gpio) +#define GPIO_VOLTAGE_1P8 NPCX_GPIO_VOLTAGE_1P8 #define GPIO_SEL_1P8V GPIO_VOLTAGE_1P8 +#elif DT_HAS_COMPAT_STATUS_OKAY(ite_it8xxx2_gpio) +#define GPIO_VOLTAGE_1P8 IT8XXX2_GPIO_VOLTAGE_1P8 +#define GPIO_SEL_1P8V GPIO_VOLTAGE_1P8 +#elif DT_HAS_COMPAT_STATUS_OKAY(zephyr_gpio_emul) +#define GPIO_VOLTAGE_1P8 NATIVE_POSIX_GPIO_VOLTAGE_1P8 +#define GPIO_SEL_1P8V GPIO_VOLTAGE_1P8 +#endif /* GPIO_ALTERNATE not supported by Zephyr */ /* GPIO_LOCKED not supported by Zephyr */ /* GPIO_HIB_WAKE_HIGH not supported by Zephyr */ diff --git a/zephyr/boards/arm/npcx7/npcx7.dts b/zephyr/boards/arm/npcx7/npcx7.dts index c1e548c62b..a4f0646001 100644 --- a/zephyr/boards/arm/npcx7/npcx7.dts +++ b/zephyr/boards/arm/npcx7/npcx7.dts @@ -7,9 +7,12 @@ #include #include +#include #include #include +#define GPIO_VOLTAGE_1P8 NPCX_GPIO_VOLTAGE_1P8 + / { model = "NPCX7"; diff --git a/zephyr/boards/arm/npcx9/npcx9.dtsi b/zephyr/boards/arm/npcx9/npcx9.dtsi index 38901af696..113cecc173 100644 --- a/zephyr/boards/arm/npcx9/npcx9.dtsi +++ b/zephyr/boards/arm/npcx9/npcx9.dtsi @@ -4,8 +4,11 @@ */ #include +#include #include +#define GPIO_VOLTAGE_1P8 NPCX_GPIO_VOLTAGE_1P8 + / { model = "NPCX9"; diff --git a/zephyr/boards/riscv/it8xxx2/it8xxx2.dts b/zephyr/boards/riscv/it8xxx2/it8xxx2.dts index 640efd1433..a7cc336cb4 100644 --- a/zephyr/boards/riscv/it8xxx2/it8xxx2.dts +++ b/zephyr/boards/riscv/it8xxx2/it8xxx2.dts @@ -6,9 +6,12 @@ /dts-v1/; #include +#include #include #include +#define GPIO_VOLTAGE_1P8 IT8XXX2_GPIO_VOLTAGE_1P8 + / { model = "Google IT8XXX2 Baseboard"; diff --git a/zephyr/dts/board-overlays/native_posix.dts b/zephyr/dts/board-overlays/native_posix.dts index 44a034d73b..c8bfe02539 100644 --- a/zephyr/dts/board-overlays/native_posix.dts +++ b/zephyr/dts/board-overlays/native_posix.dts @@ -4,6 +4,9 @@ */ #include +#include + +#define GPIO_VOLTAGE_1P8 NATIVE_POSIX_GPIO_VOLTAGE_1P8 / { named-gpios { diff --git a/zephyr/dts/it8xxx2_emul.dts b/zephyr/dts/it8xxx2_emul.dts index b22251b67b..d88d743ebd 100644 --- a/zephyr/dts/it8xxx2_emul.dts +++ b/zephyr/dts/it8xxx2_emul.dts @@ -8,6 +8,9 @@ */ #include +#include + +#define GPIO_VOLTAGE_1P8 NATIVE_POSIX_GPIO_VOLTAGE_1P8 / { gpioa: gpio@f01601 { diff --git a/zephyr/include/dt-bindings/native-posix-gpio.h b/zephyr/include/dt-bindings/native-posix-gpio.h new file mode 100644 index 0000000000..c0b8077e3d --- /dev/null +++ b/zephyr/include/dt-bindings/native-posix-gpio.h @@ -0,0 +1,12 @@ +/* + * Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef DT_BINDINGS_NATIVE_POSIX_GPIO_H_ +#define DT_BINDINGS_NATIVE_POSIX_GPIO_H_ + +/** Used for testing, bits 8-15 for specific SoC flags. */ +#define NATIVE_POSIX_GPIO_VOLTAGE_1P8 (1 << 8) + +#endif /* DT_BINDINGS_NATIVE_POSIX_GPIO_H_ */ diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c index 528569980d..c21a46c365 100644 --- a/zephyr/shim/src/gpio.c +++ b/zephyr/shim/src/gpio.c @@ -166,6 +166,11 @@ int gpio_or_ioex_get_level(int signal, int *value) return EC_SUCCESS; } +/* Don't define any 1.8V bit if not supported. */ +#ifndef GPIO_VOLTAGE_1P8 +#define GPIO_VOLTAGE_1P8 0 +#endif + /* GPIO flags which are the same in Zephyr and this codebase */ #define GPIO_CONVERSION_SAME_BITS \ (GPIO_OPEN_DRAIN | GPIO_PULL_UP | GPIO_PULL_DOWN | GPIO_VOLTAGE_1P8 | \ -- cgit v1.2.1 From 65bed7c6f418827aade0d3edecf178d251a3c377 Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Thu, 10 Nov 2022 00:27:23 +0000 Subject: test: Add rng_benchmark test BRANCH=none BUG=b:246836252 TEST=./test/run_device_tests.py --board bloonchipper -t rng_benchmark TEST=./test/run_device_tests.py --board dartmonkey -t rng_benchmark Signed-off-by: Andrea Grandi Change-Id: Ib1a2a4b0fc8e3d55022e94727417c38e5e94359b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019773 Reviewed-by: Bobby Casey Code-Coverage: Zoss Reviewed-by: Tom Hughes --- board/hatch_fp/build.mk | 1 + board/nocturne_fp/build.mk | 1 + board/nucleo-dartmonkey/build.mk | 1 + board/nucleo-f412zg/build.mk | 1 + board/nucleo-h743zi/build.mk | 1 + test/build.mk | 1 + test/rng_benchmark.cc | 81 ++++++++++++++++++++++++++++++++++++++++ test/rng_benchmark.tasklist | 9 +++++ test/run_device_tests.py | 1 + 9 files changed, 97 insertions(+) create mode 100644 test/rng_benchmark.cc create mode 100644 test/rng_benchmark.tasklist diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk index 541ac5f198..894c907ab9 100644 --- a/board/hatch_fp/build.mk +++ b/board/hatch_fp/build.mk @@ -49,6 +49,7 @@ test-list-y=\ pingpong \ printf \ queue \ + rng_benchmark \ rollback \ rollback_entropy \ rsa3 \ diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk index 1d8e9174f7..2bc59c1f13 100644 --- a/board/nocturne_fp/build.mk +++ b/board/nocturne_fp/build.mk @@ -49,6 +49,7 @@ test-list-y=\ pingpong \ printf \ queue \ + rng_benchmark \ rollback \ rollback_entropy \ rsa3 \ diff --git a/board/nucleo-dartmonkey/build.mk b/board/nucleo-dartmonkey/build.mk index 809db95260..b544490fc9 100644 --- a/board/nucleo-dartmonkey/build.mk +++ b/board/nucleo-dartmonkey/build.mk @@ -28,6 +28,7 @@ test-list-y=\ pingpong \ printf \ queue \ + rng_benchmark \ rollback \ rollback_entropy \ rsa3 \ diff --git a/board/nucleo-f412zg/build.mk b/board/nucleo-f412zg/build.mk index 37402b7e68..d923a7a40f 100644 --- a/board/nucleo-f412zg/build.mk +++ b/board/nucleo-f412zg/build.mk @@ -25,6 +25,7 @@ test-list-y=\ pingpong \ printf \ queue \ + rng_benchmark \ rollback \ rollback_entropy \ rsa3 \ diff --git a/board/nucleo-h743zi/build.mk b/board/nucleo-h743zi/build.mk index 3a59c5d47d..ad04a68918 100644 --- a/board/nucleo-h743zi/build.mk +++ b/board/nucleo-h743zi/build.mk @@ -25,6 +25,7 @@ test-list-y=\ pingpong \ printf \ queue \ + rng_benchmark \ rollback \ rollback_entropy \ rsa3 \ diff --git a/test/build.mk b/test/build.mk index 384ad60a59..30908d309e 100644 --- a/test/build.mk +++ b/test/build.mk @@ -237,6 +237,7 @@ power_button-y=power_button.o powerdemo-y=powerdemo.o printf-y=printf.o queue-y=queue.o +rng_benchmark-y=rng_benchmark.o rollback-y=rollback.o rollback_entropy-y=rollback_entropy.o rollback_secret-y=rollback_secret.o diff --git a/test/rng_benchmark.cc b/test/rng_benchmark.cc new file mode 100644 index 0000000000..2e47b8ea27 --- /dev/null +++ b/test/rng_benchmark.cc @@ -0,0 +1,81 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Measure performance of the hardware True Random Number Generator (TRNG) + * compared to the std::rand(). + */ + +#include "benchmark.h" + +#include "console.h" +#include +#include +#include + +extern "C" { +#include "test_util.h" +#include "trng.h" +} + +test_static int test_rng() +{ + constexpr int num_iterations = 100; + Benchmark benchmark({ .num_iterations = num_iterations }); + std::array trng_out; + std::array rand_out; + + // Try the hardware true random number generator + trng_out.fill(0); + + trng_init(); + auto result = benchmark.run("trng", [&trng_out]() { + static int i = 0; + trng_out[i++] = trng_rand(); + }); + trng_exit(); + + TEST_ASSERT(result.has_value()); + for (int i = 0; i < trng_out.size() - 1; ++i) { + TEST_NE(trng_out[i], trng_out[i + 1], "%d"); + cflush(); + } + + // Repeat the test by turning the TNRG on and off at each iteration + trng_out.fill(0); + result = benchmark.run("trng_on_off", [&trng_out]() { + trng_init(); + static int i = 0; + trng_out[i++] = trng_rand(); + trng_exit(); + }); + + TEST_ASSERT(result.has_value()); + for (int i = 0; i < trng_out.size() - 1; ++i) { + TEST_NE(trng_out[i], trng_out[i + 1], "%d"); + cflush(); + } + + // Repeat the test using std::rand() for comparison + rand_out.fill(0); + result = benchmark.run("std::rand", [&rand_out]() { + static int i = 0; + rand_out[i++] = std::rand(); + }); + + TEST_ASSERT(result.has_value()); + for (int i = 0; i < rand_out.size() - 1; ++i) { + TEST_NE(rand_out[i], rand_out[i + 1], "%d"); + cflush(); + } + + benchmark.print_results(); + return EC_SUCCESS; +} + +void run_test(int argc, const char **argv) +{ + test_reset(); + RUN_TEST(test_rng); + test_print_result(); +} \ No newline at end of file diff --git a/test/rng_benchmark.tasklist b/test/rng_benchmark.tasklist new file mode 100644 index 0000000000..19615b9ea8 --- /dev/null +++ b/test/rng_benchmark.tasklist @@ -0,0 +1,9 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * See CONFIG_TASK_LIST in config.h for details. + */ +#define CONFIG_TEST_TASK_LIST \ No newline at end of file diff --git a/test/run_device_tests.py b/test/run_device_tests.py index 0b5a291b6c..fcf9a99651 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -257,6 +257,7 @@ class AllTests: TestConfig(test_name="pingpong"), TestConfig(test_name="printf"), TestConfig(test_name="queue"), + TestConfig(test_name="rng_benchmark"), TestConfig( config_name="rollback_region0", test_name="rollback", -- cgit v1.2.1 From 024bd337a7b4b1b06bb9b8a24f59e1da1a337ea8 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 9 Nov 2022 17:13:16 -0700 Subject: zephyr: tests: Test four function in `common/charger.c` Test the happy paths of: * `charger_set_vsys_compensation()` * `charger_is_icl_reached()` * `charger_enable_linear_charge()` * `charger_get_battery_cells()` BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: Ia85dbe93eb2bb5528d4832c0dbdef09fe3882797 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4017487 Reviewed-by: Simon Glass Code-Coverage: Zoss --- .../src/test_common_charger_mocked.c | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index 68a67519f7..4ee485f5c0 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -32,6 +32,11 @@ FAKE_VALUE_FUNC(enum ec_error_list, get_actual_voltage, int, int *); FAKE_VALUE_FUNC(enum ec_error_list, set_voltage, int, int); FAKE_VALUE_FUNC(enum ec_error_list, get_vsys_voltage, int, int, int *); FAKE_VALUE_FUNC(enum ec_error_list, enable_bypass_mode, int, bool); +FAKE_VALUE_FUNC(enum ec_error_list, set_vsys_compensation, int, + struct ocpc_data *, int, int); +FAKE_VALUE_FUNC(enum ec_error_list, is_icl_reached, int, bool *); +FAKE_VALUE_FUNC(enum ec_error_list, enable_linear_charge, int, bool); +FAKE_VALUE_FUNC(enum ec_error_list, get_battery_cells, int, int *); /** * @brief If non-NULL, board_get_charger_chip_count returns the value this @@ -500,6 +505,46 @@ ZTEST(common_charger_mocked_driver, test_charger_set_mode__unimpl) zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_set_mode(0)); } +ZTEST_F(common_charger_mocked_driver, test_charger_set_vsys_compensation) +{ + fixture->mock_driver.set_vsys_compensation = set_vsys_compensation; + set_vsys_compensation_fake.return_val = 123; + + zassert_equal(123, charger_set_vsys_compensation(CHG_NUM, NULL, 0, 0)); + + zassert_equal(1, set_vsys_compensation_fake.call_count); +} + +ZTEST_F(common_charger_mocked_driver, test_charger_is_icl_reached) +{ + fixture->mock_driver.is_icl_reached = is_icl_reached; + is_icl_reached_fake.return_val = 123; + + zassert_equal(123, charger_is_icl_reached(CHG_NUM, NULL)); + + zassert_equal(1, is_icl_reached_fake.call_count); +} + +ZTEST_F(common_charger_mocked_driver, test_charger_enable_linear_charge) +{ + fixture->mock_driver.enable_linear_charge = enable_linear_charge; + enable_linear_charge_fake.return_val = 123; + + zassert_equal(123, charger_enable_linear_charge(CHG_NUM, 0)); + + zassert_equal(1, enable_linear_charge_fake.call_count); +} + +ZTEST_F(common_charger_mocked_driver, test_charger_get_battery_cells) +{ + fixture->mock_driver.get_battery_cells = get_battery_cells; + get_battery_cells_fake.return_val = 123; + + zassert_equal(123, charger_get_battery_cells(CHG_NUM, NULL)); + + zassert_equal(1, get_battery_cells_fake.call_count); +} + static void *setup(void) { static struct common_charger_mocked_driver_fixture f; @@ -532,6 +577,10 @@ static void reset(void *data) RESET_FAKE(set_voltage); RESET_FAKE(get_vsys_voltage); RESET_FAKE(enable_bypass_mode); + RESET_FAKE(set_vsys_compensation); + RESET_FAKE(is_icl_reached); + RESET_FAKE(enable_linear_charge); + RESET_FAKE(get_battery_cells); fake_charger_count = NULL; } -- cgit v1.2.1 From 9345f25c6586e8066669278dc4bfe1cc3db442f8 Mon Sep 17 00:00:00 2001 From: Yu-An Chen Date: Fri, 11 Nov 2022 14:48:18 +0800 Subject: herobrine: Support remove USB-A Disable USB-A related init function if board doesn't have USB-A BUG=b:238571776 BRANCH=none TEST=zmake build evoker Signed-off-by: Yu-An Chen Change-Id: I6ce2193431d040c59ca5466a42be22c877596152 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022555 Commit-Queue: Bob Moragues Reviewed-by: Bob Moragues Code-Coverage: Zoss Reviewed-by: Wai-Hong Tam Commit-Queue: Wai-Hong Tam --- zephyr/program/herobrine/src/usbc_config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zephyr/program/herobrine/src/usbc_config.c b/zephyr/program/herobrine/src/usbc_config.c index aea175e1fb..1c0ab8205b 100644 --- a/zephyr/program/herobrine/src/usbc_config.c +++ b/zephyr/program/herobrine/src/usbc_config.c @@ -50,6 +50,7 @@ void tcpc_alert_event(enum gpio_signal signal) schedule_deferred_pd_interrupt(port); } +#ifdef CONFIG_PLATFORM_EC_USBA static void usba_oc_deferred(void) { /* Use next number after all USB-C ports to indicate the USB-A port */ @@ -63,6 +64,7 @@ void usba_oc_interrupt(enum gpio_signal signal) { hook_call_deferred(&usba_oc_deferred_data, 0); } +#endif void ppc_interrupt(enum gpio_signal signal) { @@ -118,6 +120,7 @@ enum ec_status charger_profile_override_set_param(uint32_t param, return EC_RES_INVALID_PARAM; } +#ifdef CONFIG_PLATFORM_EC_USBA /* Initialize board USC-C things */ static void board_init_usbc(void) { @@ -125,6 +128,7 @@ static void board_init_usbc(void) gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc)); } DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT); +#endif void board_tcpc_init(void) { -- cgit v1.2.1 From 84ca1269ae0ad439141badd30c2b0e0d6e6d7783 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 10 Nov 2022 10:53:19 -0700 Subject: emul_bb_retimer: Rename compatible string Rename the compatible string for the BB retimer emulator to match the real driver. Also removed unneeded devicetree properties from the emulator devicetree node. BUG=b:239457738 BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I312129f5ffab9ba39394a3a2655d7ce3def5f9f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023765 Code-Coverage: Zoss Reviewed-by: Yuval Peress Reviewed-by: Abe Levkoy --- zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml | 30 ---------------------- zephyr/emul/emul_bb_retimer.c | 9 +++---- zephyr/test/drivers/boards/native_posix.overlay | 6 ++--- 3 files changed, 6 insertions(+), 39 deletions(-) delete mode 100644 zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml diff --git a/zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml b/zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml deleted file mode 100644 index 11dd5f5218..0000000000 --- a/zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: Zephyr BB retimer Emulator - -compatible: "cros,bb-retimer-emul" - -include: base.yaml - -properties: - vendor: - type: string - required: true - enum: - - BB_RETIMER_VENDOR_ID_1 - - BB_RETIMER_VENDOR_ID_2 - description: Vendor ID used by device that is emulated. - - error-on-ro-write: - type: boolean - description: - Flag indicating if error should be generated when read only register - is being written. - - error-on-reserved-bit-write: - type: boolean - description: - Flag indicating if error should be generated when reserved bit - is being written. diff --git a/zephyr/emul/emul_bb_retimer.c b/zephyr/emul/emul_bb_retimer.c index 266fd1a340..0536f19de6 100644 --- a/zephyr/emul/emul_bb_retimer.c +++ b/zephyr/emul/emul_bb_retimer.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_bb_retimer_emul +#define DT_DRV_COMPAT intel_jhl8040r #define LOG_LEVEL CONFIG_I2C_LOG_LEVEL #include @@ -309,10 +309,9 @@ static int bb_emul_init(const struct emul *emul, const struct device *parent) #define BB_RETIMER_EMUL(n) \ static struct bb_emul_data bb_emul_data_##n = { \ - .vendor_id = DT_STRING_TOKEN(DT_DRV_INST(n), vendor), \ - .error_on_ro_write = DT_INST_PROP(n, error_on_ro_write),\ - .error_on_rsvd_write = DT_INST_PROP(n, \ - error_on_reserved_bit_write), \ + .vendor_id = BB_RETIMER_VENDOR_ID_1, \ + .error_on_ro_write = true, \ + .error_on_rsvd_write = true, \ .common = { \ .start_write = NULL, \ .write_byte = bb_emul_write_byte, \ diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index d3e1d740ae..4458df9703 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -812,11 +812,9 @@ }; usb_c1_bb_retimer_emul: bbretimer@42 { - compatible = "cros,bb-retimer-emul"; + compatible = "intel,jhl8040r"; reg = <0x42>; - vendor = "BB_RETIMER_VENDOR_ID_1"; - error-on-ro-write; - error-on-reserved-bit-write; + reset-pin = <&usb_c1_rt_rst_odl>; }; ps8xxx_emul: ps8xxx_emul@b { -- cgit v1.2.1 From 6acfadf0df547a86b1dfddb3f5487d606774be6a Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 10 Nov 2022 15:19:52 -0700 Subject: usb_mux shim: Set a default flags value The flags property is marked as not required, set the default flag field to 0 if not specified in the devicetree. BUG=none BRANCH=none TEST=twister TEST=zmake compare-builds Signed-off-by: Keith Short Change-Id: Ibb4590645aa901bc874acb721fd0bbbb7671f409 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023766 Reviewed-by: Yuval Peress Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- zephyr/shim/include/usbc/usb_muxes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/shim/include/usbc/usb_muxes.h b/zephyr/shim/include/usbc/usb_muxes.h index f94aed488d..132ce77e91 100644 --- a/zephyr/shim/include/usbc/usb_muxes.h +++ b/zephyr/shim/include/usbc/usb_muxes.h @@ -177,14 +177,14 @@ * @brief Set struct usb_mux fields common for all USB muxes and alter flags * * @param mux_id USB mux node ID - * @param flags_mask Mask for bits that should be igonred in flags property + * @param flags_mask Mask for bits that should be ignored in flags property * @param flags_val Value that should be used instead for masked bits */ #define USB_MUX_COMMON_FIELDS_WITH_FLAGS(mux_id, flags_mask, flags_val) \ .usb_port = USB_MUX_PORT(mux_id), \ .board_init = USB_MUX_CALLBACK_OR_NULL(mux_id, board_init), \ .board_set = USB_MUX_CALLBACK_OR_NULL(mux_id, board_set), \ - .flags = (DT_PROP(mux_id, flags) & ~(flags_mask)) | (flags_val) + .flags = (DT_PROP_OR(mux_id, flags, 0) & ~(flags_mask)) | (flags_val) /** * @brief Set struct usb_mux fields common for all USB muxes -- cgit v1.2.1 From 50ca1e0aa37d48ea42e96591a0dc41abd5526b5a Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 10 Nov 2022 15:15:59 -0700 Subject: test: usb_mux: use devicetrees Update the tests to use the "cros-ec,usb-mux-chain" to specify the USB muxes under test instead of hard coding via stubs. BUG=b:239457738 BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I5a5acaf0b3815558454d4ec886e1058e4ccf36ea Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023767 Reviewed-by: Abe Levkoy Code-Coverage: Zoss Reviewed-by: Yuval Peress --- zephyr/test/drivers/boards/native_posix.overlay | 24 +++++++++ .../drivers/common/include/test/drivers/stubs.h | 4 -- zephyr/test/drivers/common/src/stubs.c | 62 ---------------------- .../drivers/default/boards/native_posix.overlay | 34 ++++++++++++ zephyr/test/drivers/default/src/tcpci.c | 10 ++-- zephyr/test/drivers/default/src/usb_mux.c | 35 +++++++++--- zephyr/test/drivers/prj.conf | 1 + zephyr/test/drivers/testcase.yaml | 3 ++ .../usbc_svdm_dfp_only/boards/native_posix.overlay | 23 ++++++++ zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf | 1 + zephyr/test/vboot_efs2/boards/native_posix.overlay | 9 ++++ zephyr/test/vboot_efs2/src/main.c | 11 ---- 12 files changed, 131 insertions(+), 86 deletions(-) create mode 100644 zephyr/test/drivers/default/boards/native_posix.overlay create mode 100644 zephyr/test/drivers/usbc_svdm_dfp_only/boards/native_posix.overlay diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index 4458df9703..e8c0667cb3 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -60,6 +60,19 @@ chg = <&isl923x_emul>; tcpc = <&tcpci_emul>; ppc = <&sn5s330_emul>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&tcpci_mux_c0 + &virtual_mux_c0>; + }; + }; + port0-muxes { + tcpci_mux_c0: tcpci-mux-c0 { + compatible = "cros-ec,usbc-mux-tcpci"; + }; + virtual_mux_c0: virtual-mux-c0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; }; port1@1 { @@ -67,6 +80,16 @@ reg = <1>; tcpc = <&ps8xxx_emul>; ppc = <&syv682x_emul>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&usb_c1_bb_retimer_emul + &virtual_mux_c1>; + }; + }; + port1-muxes { + virtual_mux_c1: virtual-mux-c1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; }; }; @@ -815,6 +838,7 @@ compatible = "intel,jhl8040r"; reg = <0x42>; reset-pin = <&usb_c1_rt_rst_odl>; + ls-en-pin = <&usb_c1_ls_en>; }; ps8xxx_emul: ps8xxx_emul@b { diff --git a/zephyr/test/drivers/common/include/test/drivers/stubs.h b/zephyr/test/drivers/common/include/test/drivers/stubs.h index 98f3fa1d15..8a739fa866 100644 --- a/zephyr/test/drivers/common/include/test/drivers/stubs.h +++ b/zephyr/test/drivers/common/include/test/drivers/stubs.h @@ -11,10 +11,6 @@ enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; -/* Structure used by usb_mux test. It is part of usb_muxes chain. */ -extern struct usb_mux usbc1_virtual_usb_mux; -extern struct usb_mux usbc0_mux0; - /** * @brief Set product ID that should be returned by board_get_ps8xxx_product_id * diff --git a/zephyr/test/drivers/common/src/stubs.c b/zephyr/test/drivers/common/src/stubs.c index d07683017f..98b5d5bc3c 100644 --- a/zephyr/test/drivers/common/src/stubs.c +++ b/zephyr/test/drivers/common/src/stubs.c @@ -148,68 +148,6 @@ int board_is_sourcing_vbus(int port) return ppc_is_sourcing_vbus(port); } -/* TODO(b/239457738): Move to dts */ -struct usb_mux_chain usbc0_virtual_usb_mux_chain = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C0, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, - }, -}; - -struct usb_mux usbc1_virtual_usb_mux = { - .usb_port = USBC_PORT_C1, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, -}; - -struct usb_mux_chain usbc1_virtual_usb_mux_chain = { - .mux = &usbc1_virtual_usb_mux, -}; - -struct usb_mux usbc0_mux0 = { - .usb_port = USBC_PORT_C0, - .driver = &tcpci_tcpm_usb_mux_driver, - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)), -}; - -struct usb_mux_chain usb_muxes[] = { - [USBC_PORT_C0] = { - .mux = &usbc0_mux0, - .next = &usbc0_virtual_usb_mux_chain, - }, - [USBC_PORT_C1] = { -#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB - .mux = &(const struct usb_mux){ - .usb_port = USBC_PORT_C1, - .driver = &bb_usb_retimer, - .hpd_update = bb_retimer_hpd_update, - .i2c_port = I2C_PORT_USB_C1, - .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL( - usb_c1_bb_retimer_emul)), - }, - .next = &usbc1_virtual_usb_mux_chain, -#endif - }, -}; -BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT); - -#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB -struct bb_usb_control bb_controls[] = { - [USBC_PORT_C0] = { - /* USB-C port 0 doesn't have a retimer */ - }, - [USBC_PORT_C1] = { - .usb_ls_en_gpio = GPIO_SIGNAL(DT_NODELABEL(usb_c1_ls_en)), - .retimer_rst_gpio = - GPIO_SIGNAL(DT_NODELABEL(usb_c1_rt_rst_odl)), - }, -}; -BUILD_ASSERT(ARRAY_SIZE(bb_controls) == USBC_PORT_COUNT); -#endif - void pd_power_supply_reset(int port) { } diff --git a/zephyr/test/drivers/default/boards/native_posix.overlay b/zephyr/test/drivers/default/boards/native_posix.overlay new file mode 100644 index 0000000000..a5e73e5653 --- /dev/null +++ b/zephyr/test/drivers/default/boards/native_posix.overlay @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../../boards/native_posix.overlay" + +/* + * The TCPCI test verfies the mux behavior in two configurations: + * flags = USB_MUX_FLAG_NOT_TCPC; + * flags = 0; + * + * When USB_MUX_FLAG_NOT_TCPC is set, the TCPCI mux driver must initialize + * the I2C bus and address from the devicetree. + * + * The TCPCI mux doesn't have it's owm emulator and sends it's I2C transactions + * through the normal TCPCI driver, which then connects to the TCPCI emulator. + * + * Use 2 compaible strings here so that the same I2C device node gets setup for + * both the emulator and the TPCI mux. + */ +&tcpci_emul { + compatible = "cros,tcpci-generic-emul", "cros-ec,usbc-mux-tcpci"; +}; + +/ { + usbc { + port0@0 { + usb-mux-chain-0 { + usb-muxes = <&tcpci_emul &virtual_mux_c0>; + }; + }; + }; +}; diff --git a/zephyr/test/drivers/default/src/tcpci.c b/zephyr/test/drivers/default/src/tcpci.c index db0ad076ab..de2437eb96 100644 --- a/zephyr/test/drivers/default/src/tcpci.c +++ b/zephyr/test/drivers/default/src/tcpci.c @@ -22,6 +22,9 @@ #define TCPCI_EMUL_NODE DT_NODELABEL(tcpci_emul) +/* Convenience pointer directly to the TCPCI mux under test */ +static struct usb_mux *tcpci_usb_mux; + /** Test TCPCI init and vbus level */ ZTEST(tcpci, test_generic_tcpci_init) { @@ -288,13 +291,13 @@ ZTEST(tcpci, test_generic_tcpci_debug_accessory) /* Setup TCPCI usb mux to behave as it is used only for usb mux */ static void set_usb_mux_not_tcpc(void) { - usbc0_mux0.flags = USB_MUX_FLAG_NOT_TCPC; + tcpci_usb_mux->flags = USB_MUX_FLAG_NOT_TCPC; } /* Setup TCPCI usb mux to behave as it is used for usb mux and TCPC */ static void set_usb_mux_tcpc(void) { - usbc0_mux0.flags = 0; + tcpci_usb_mux->flags = 0; } /** Test TCPCI mux init */ @@ -531,7 +534,6 @@ void validate_mux_read_write16(const struct usb_mux *tcpci_usb_mux) /** Test usb_mux read/write APIs */ ZTEST(tcpci, test_usb_mux_read_write) { - struct usb_mux *tcpci_usb_mux = &usbc0_mux0; const int flags_restore = tcpci_usb_mux->flags; /* Configure mux read/writes for TCPC APIs */ @@ -552,6 +554,8 @@ static void *tcpci_setup(void) &tcpci_tcpm_usb_mux_driver, "Invalid config of usb_muxes in test/drivers/src/stubs.c"); + tcpci_usb_mux = (struct usb_mux *)usb_muxes[USBC_PORT_C0].mux; + return NULL; } diff --git a/zephyr/test/drivers/default/src/usb_mux.c b/zephyr/test/drivers/default/src/usb_mux.c index 62d39e28d4..4aea56962e 100644 --- a/zephyr/test/drivers/default/src/usb_mux.c +++ b/zephyr/test/drivers/default/src/usb_mux.c @@ -29,7 +29,8 @@ #include "test/drivers/utils.h" /** Copy of original usb_muxes[USB_PORT_C1] */ -struct usb_mux_chain usb_mux_c1; +static struct usb_mux_chain usb_mux_c1; +static struct usb_mux *usbc1_virtual_usb_mux; /** Number of usb mux proxies in chain */ #define NUM_OF_PROXY 3 @@ -344,6 +345,26 @@ struct usb_mux_chain proxy_chain_0 = { .next = &proxy_chain_1, }; +static void find_virtual_mux(void) +{ + const struct usb_mux_chain *mux_chain; + + mux_chain = &usb_muxes[1]; + usbc1_virtual_usb_mux = NULL; + while (mux_chain) { + if (mux_chain->mux && + mux_chain->mux->driver == &virtual_usb_mux_driver) { + usbc1_virtual_usb_mux = + (struct usb_mux *)mux_chain->mux; + break; + } + mux_chain = mux_chain->next; + } + + __ASSERT(usbc1_virtual_usb_mux, + "USB-C port 1 must contain a virtual mux"); +} + /** Setup first 3 usb muxes of port 1 with proxy */ static void setup_usb_mux_proxy_chain(void) { @@ -693,13 +714,13 @@ ZTEST(usb_uninit_mux, test_usb_mux_hpd_update) mux_state_t exp_mode, mode, virt_mode; /* Get current state of virtual usb mux and set mock */ - usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &virt_mode); + usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &virt_mode); /* Test no hpd level and no irq */ exp_mode = virt_mode; usb_mux_hpd_update(USBC_PORT_C1, exp_mode); /* Check if virtual usb mux mode is updated correctly */ - usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &mode); + usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &mode); zassert_equal(exp_mode, mode, "virtual mux mode is 0x%x (!= 0x%x)", mode, exp_mode); CHECK_PROXY_FAKE_CALL_CNT(proxy_init, NUM_OF_PROXY); @@ -711,7 +732,7 @@ ZTEST(usb_uninit_mux, test_usb_mux_hpd_update) exp_mode = virt_mode | USB_PD_MUX_HPD_LVL | USB_PD_MUX_HPD_IRQ; usb_mux_hpd_update(USBC_PORT_C1, exp_mode); /* Check if virtual usb mux mode is updated correctly */ - usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &mode); + usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &mode); zassert_equal(exp_mode, mode, "virtual mux mode is 0x%x (!= 0x%x)", mode, exp_mode); CHECK_PROXY_FAKE_CALL_CNT(proxy_init, 0); @@ -723,7 +744,7 @@ ZTEST(usb_uninit_mux, test_usb_mux_hpd_update) exp_mode = virt_mode | USB_PD_MUX_HPD_IRQ; usb_mux_hpd_update(USBC_PORT_C1, exp_mode); /* Check if virtual usb mux mode is updated correctly */ - usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &mode); + usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &mode); zassert_equal(exp_mode, mode, "virtual mux mode is 0x%x (!= 0x%x)", mode, exp_mode); CHECK_PROXY_FAKE_CALL_CNT(proxy_init, 0); @@ -735,7 +756,7 @@ ZTEST(usb_uninit_mux, test_usb_mux_hpd_update) exp_mode = virt_mode | USB_PD_MUX_HPD_LVL; usb_mux_hpd_update(USBC_PORT_C1, exp_mode); /* Check if virtual usb mux mode is updated correctly */ - usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &mode); + usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &mode); zassert_equal(exp_mode, mode, "virtual mux mode is 0x%x (!= 0x%x)", mode, exp_mode); CHECK_PROXY_FAKE_CALL_CNT(proxy_init, 0); @@ -916,6 +937,7 @@ ZTEST(usb_init_mux, test_usb_mux_typec_command) void usb_uninit_mux_before(void *state) { ARG_UNUSED(state); + find_virtual_mux(); setup_usb_mux_proxy_chain(); set_test_runner_tid(); @@ -935,6 +957,7 @@ void usb_uninit_mux_after(void *state) void usb_init_mux_before(void *state) { ARG_UNUSED(state); + find_virtual_mux(); setup_usb_mux_proxy_chain(); set_test_runner_tid(); diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 3e3f9db02c..3169051bed 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -98,6 +98,7 @@ CONFIG_PLATFORM_EC_USB_PD_REV30=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_HOSTCMD=y CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=y +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y CONFIG_PLATFORM_EC_TEMP_SENSOR=y diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index ed7c9b5635..d8a2dc838a 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -4,6 +4,7 @@ tests: drivers.default: timeout: 240 extra_args: CONF_FILE="prj.conf;default/prj.conf" + DTC_OVERLAY_FILE="default/boards/native_posix.overlay" extra_configs: - CONFIG_LINK_TEST_SUITE_DEFAULT=y - CONFIG_LINK_TEST_SUITE_USB_MALFUNCTION_SINK=y @@ -13,6 +14,7 @@ tests: drivers.default.mock_power: timeout: 240 extra_args: CONF_FILE="prj.conf;default/prj.conf" + DTC_OVERLAY_FILE="default/boards/native_posix.overlay" extra_configs: - CONFIG_LINK_TEST_SUITE_DEFAULT=y - CONFIG_LINK_TEST_SUITE_USB_MALFUNCTION_SINK=y @@ -198,6 +200,7 @@ tests: - CONFIG_LINK_TEST_SUITE_USBC_PPC=y drivers.usbc_svdm_dfp_only: extra_args: CONF_FILE="prj.conf;usbc_svdm_dfp_only/prj.conf" + DTC_OVERLAY_FILE="usbc_svdm_dfp_only/boards/native_posix.overlay" extra_configs: - CONFIG_LINK_TEST_SUITE_USBC_SVDM_DFP_ONLY=y drivers.usbc_tbt_mode: diff --git a/zephyr/test/drivers/usbc_svdm_dfp_only/boards/native_posix.overlay b/zephyr/test/drivers/usbc_svdm_dfp_only/boards/native_posix.overlay new file mode 100644 index 0000000000..0e428e271a --- /dev/null +++ b/zephyr/test/drivers/usbc_svdm_dfp_only/boards/native_posix.overlay @@ -0,0 +1,23 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../../boards/native_posix.overlay" + +/* + * The SVDM DFP only tests explicitly do not support USB4/TBT which + * automatically get turned on if the Burnside Bridge retimer is used. + * Remove this device from the devicetree. + */ + /delete-node/ &usb_c1_bb_retimer_emul; + + / { + usbc { + port1@1 { + usb-mux-chain-1 { + usb-muxes = <&virtual_mux_c1>; + }; + }; + }; +}; diff --git a/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf b/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf index 96c16cbd01..fefe9471ca 100644 --- a/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf +++ b/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf @@ -3,6 +3,7 @@ # found in the LICENSE file. +CONFIG_EMUL_BB_RETIMER=n CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=n CONFIG_PLATFORM_EC_USB_PD_USB4=n CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n diff --git a/zephyr/test/vboot_efs2/boards/native_posix.overlay b/zephyr/test/vboot_efs2/boards/native_posix.overlay index ced94c28b1..d6b008c69d 100644 --- a/zephyr/test/vboot_efs2/boards/native_posix.overlay +++ b/zephyr/test/vboot_efs2/boards/native_posix.overlay @@ -61,6 +61,15 @@ reg = <0>; chg = <&isl923x_emul>; tcpc = <&tcpci_emul>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&tcpci_mux_c0>; + }; + }; + port0-muxes { + tcpci_mux_c0: tcpci-mux-c0 { + compatible = "cros-ec,usbc-mux-tcpci"; + }; }; }; i2c2: i2c@500 { diff --git a/zephyr/test/vboot_efs2/src/main.c b/zephyr/test/vboot_efs2/src/main.c index 1558fb75f0..f757030489 100644 --- a/zephyr/test/vboot_efs2/src/main.c +++ b/zephyr/test/vboot_efs2/src/main.c @@ -401,17 +401,6 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { }, }; -struct usb_mux_chain usb_muxes[] = { - [USBC_PORT_C0] = { - .mux = &(struct usb_mux) { - .usb_port = USBC_PORT_C0, - .driver = &tcpci_tcpm_usb_mux_driver, - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)), - }, - }, -}; - /* USBC PPC configuration */ struct ppc_config_t ppc_chips[] = { [USBC_PORT_C0] = { -- cgit v1.2.1 From 0c4651353f9db8cbaeb80680baceedba62d6010b Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 11 Nov 2022 08:04:29 -0700 Subject: emul_pi3usb9201: Rename compatible string Rename the compatible string for the PI3USB9201 emulator to match the real driver. Also move all bc12 setup into the devicetree for tests. BUG=b:218331557 BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: Iaf15fadf20b070033a474d395ae330b4f84e4f18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023768 Code-Coverage: Zoss Reviewed-by: Yuval Peress Reviewed-by: Abe Levkoy --- zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml | 9 --------- zephyr/emul/emul_pi3usb9201.c | 2 +- zephyr/test/drivers/boards/native_posix.overlay | 11 +++++++++-- zephyr/test/drivers/common/src/stubs.c | 13 ------------- zephyr/test/drivers/default/src/bc12.c | 2 +- zephyr/test/vboot_efs2/boards/native_posix.overlay | 5 +++++ zephyr/test/vboot_efs2/prj.conf | 2 ++ zephyr/test/vboot_efs2/src/main.c | 8 -------- 8 files changed, 18 insertions(+), 34 deletions(-) delete mode 100644 zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml diff --git a/zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml b/zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml deleted file mode 100644 index 1f26a62f73..0000000000 --- a/zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: Zephyr pi3usb9201 Emulator - -compatible: "zephyr,pi3usb9201-emul" - -include: base.yaml diff --git a/zephyr/emul/emul_pi3usb9201.c b/zephyr/emul/emul_pi3usb9201.c index 3b1193d9b1..8073313d69 100644 --- a/zephyr/emul/emul_pi3usb9201.c +++ b/zephyr/emul/emul_pi3usb9201.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT zephyr_pi3usb9201_emul +#define DT_DRV_COMPAT pericom_pi3usb9201 #include #include diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index e8c0667cb3..5489c36d00 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -57,6 +57,7 @@ port0@0 { compatible = "named-usbc-port"; reg = <0>; + bc12 = <&pi3usb9201_emul0>; chg = <&isl923x_emul>; tcpc = <&tcpci_emul>; ppc = <&sn5s330_emul>; @@ -78,6 +79,7 @@ port1@1 { compatible = "named-usbc-port"; reg = <1>; + bc12 = <&pi3usb9201_emul1>; tcpc = <&ps8xxx_emul>; ppc = <&syv682x_emul>; usb-mux-chain-1 { @@ -800,8 +802,8 @@ #size-cells = <0>; reg = <0x500 4>; - pi3usb9201_emul: pi3usb9201@5f { - compatible = "zephyr,pi3usb9201-emul"; + pi3usb9201_emul0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; reg = <0x5f>; }; @@ -827,6 +829,11 @@ #size-cells = <0>; reg = <0x600 4>; + pi3usb9201_emul1: pi3usb9201@5d { + compatible = "pericom,pi3usb9201"; + reg = <0x5d>; + }; + syv682x_emul: syv682x@41 { compatible = "zephyr,syv682x-emul"; reg = <0x41>; diff --git a/zephyr/test/drivers/common/src/stubs.c b/zephyr/test/drivers/common/src/stubs.c index 98b5d5bc3c..f16064c14d 100644 --- a/zephyr/test/drivers/common/src/stubs.c +++ b/zephyr/test/drivers/common/src/stubs.c @@ -40,19 +40,6 @@ LOG_MODULE_REGISTER(stubs); * device tree. */ -/* BC1.2 charger detect configuration */ -const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { - [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, - }, - [USBC_PORT_C1] = { - .i2c_port = I2C_PORT_USB_C1, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_1_FLAGS, - }, -}; -BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT); - int board_set_active_charge_port(int port) { int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); diff --git a/zephyr/test/drivers/default/src/bc12.c b/zephyr/test/drivers/default/src/bc12.c index db1819ec4c..2207cd9676 100644 --- a/zephyr/test/drivers/default/src/bc12.c +++ b/zephyr/test/drivers/default/src/bc12.c @@ -21,7 +21,7 @@ #include LOG_MODULE_REGISTER(test_drivers_bc12, LOG_LEVEL_DBG); -#define EMUL_NODE DT_NODELABEL(pi3usb9201_emul) +#define EMUL_NODE DT_NODELABEL(pi3usb9201_emul0) /* Control_1 register bit definitions */ #define PI3USB9201_REG_CTRL_1_INT_MASK BIT(0) diff --git a/zephyr/test/vboot_efs2/boards/native_posix.overlay b/zephyr/test/vboot_efs2/boards/native_posix.overlay index d6b008c69d..fa6d46e135 100644 --- a/zephyr/test/vboot_efs2/boards/native_posix.overlay +++ b/zephyr/test/vboot_efs2/boards/native_posix.overlay @@ -59,6 +59,7 @@ port0@0 { compatible = "named-usbc-port"; reg = <0>; + bc12 = <&pi3usb9201_emul>; chg = <&isl923x_emul>; tcpc = <&tcpci_emul>; usb-mux-chain-1 { @@ -80,6 +81,10 @@ #size-cells = <0>; reg = <0x500 4>; + pi3usb9201_emul: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + reg = <0x5f>; + }; tcpci_emul: tcpci_emul@82 { compatible = "cros,tcpci-generic-emul"; status = "okay"; diff --git a/zephyr/test/vboot_efs2/prj.conf b/zephyr/test/vboot_efs2/prj.conf index 172f5ca886..4858e0602d 100644 --- a/zephyr/test/vboot_efs2/prj.conf +++ b/zephyr/test/vboot_efs2/prj.conf @@ -4,6 +4,7 @@ CONFIG_ADC_EMUL=y CONFIG_CROS_EC=y +CONFIG_EMUL_BC12_DETECT_PI3USB9201=y CONFIG_EMUL_CROS_FLASH=y CONFIG_EMUL_SMART_BATTERY=y CONFIG_EMUL_TCPCI=y @@ -15,6 +16,7 @@ CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=y CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_CHARGER_ISL9238=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 diff --git a/zephyr/test/vboot_efs2/src/main.c b/zephyr/test/vboot_efs2/src/main.c index f757030489..3a4da9cd6e 100644 --- a/zephyr/test/vboot_efs2/src/main.c +++ b/zephyr/test/vboot_efs2/src/main.c @@ -393,14 +393,6 @@ int pd_set_power_supply_ready(int port) enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_COUNT }; -/* BC1.2 charger detect configuration */ -const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { - [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, - }, -}; - /* USBC PPC configuration */ struct ppc_config_t ppc_chips[] = { [USBC_PORT_C0] = { -- cgit v1.2.1 From 0ff770e0004a73b7e15ef5c185efd97abd23242b Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 11 Nov 2022 09:04:09 -0700 Subject: pi3usb9201 shim: Remove unneeded guard All boards and tests now define the BC1.1 devices in the devictree. Remove an obsolete guard. BUG=none BRANCH=none TEST=twister TEST=zmake compare-builds Signed-off-by: Keith Short Change-Id: If28f1932bb7b1febccc07475f759867a45c01299 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023769 Code-Coverage: Zoss Reviewed-by: Yuval Peress Reviewed-by: Abe Levkoy --- zephyr/shim/src/bc12_pi3usb9201.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/zephyr/shim/src/bc12_pi3usb9201.c b/zephyr/shim/src/bc12_pi3usb9201.c index 25d1962ff2..cd79e8d4bd 100644 --- a/zephyr/shim/src/bc12_pi3usb9201.c +++ b/zephyr/shim/src/bc12_pi3usb9201.c @@ -15,11 +15,6 @@ #include "usbc/utils.h" #include "i2c/i2c.h" -#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) - -BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) > 0, - "No compatible BC1.2 instance found"); - #define USBC_PORT_BC12(usbc_id, bc12_id) \ [USBC_PORT_NEW(usbc_id)] = { \ .i2c_port = I2C_PORT_BY_DEV(bc12_id), \ @@ -56,5 +51,3 @@ void usb1_evt(enum gpio_signal signal) usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); } #endif - -#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ -- cgit v1.2.1 From 66fde0857de39aa1002bf5676aa675101953ae20 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Thu, 10 Nov 2022 13:07:07 -0800 Subject: keyboard_scan: initialize variable Avoid possible uninitialized use of poll_deadline. BUG=b:64477774 BRANCH=none TEST=make -j buildall Signed-off-by: Boris Mittelberg Change-Id: I92cd4bd59764c3620869262674a862d633db9dc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021134 Code-Coverage: Zoss Reviewed-by: caveh jalali Reviewed-by: Daisuke Nojiri --- common/keyboard_scan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index bd820ae881..617ae3fc02 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -913,6 +913,7 @@ void keyboard_scan_task(void *u) uint32_t local_disable_scanning = 0; print_state(debounced_state, "init state"); + poll_deadline.val = 0; keyboard_raw_task_start(); -- cgit v1.2.1 From ea53fb7419b02820cb76bfaba6566d1641f11a18 Mon Sep 17 00:00:00 2001 From: Tang Qijun Date: Fri, 11 Nov 2022 11:45:59 +0800 Subject: zombie: correct battery configuration Correct battery parameters for zombie board. BRANCH=none BUG=b:258074497 TEST=1)Battery is detecting fine at EC bootup 2)Battery normal charge to full 3)Battery cutoff is working as expected Signed-off-by: Tang Qijun Change-Id: Ia0156343da5f5aff3dcbdcbc71382e67f096a0b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022846 Reviewed-by: Wai-Hong Tam Commit-Queue: Bob Moragues Reviewed-by: Bob Moragues Code-Coverage: Zoss --- zephyr/dts/bindings/battery/battery-smart.yaml | 1 + zephyr/dts/bindings/battery/ganfeng,sg20.yaml | 53 +++++++++++++++++++++++++ zephyr/program/herobrine/zombie/project.overlay | 7 +--- 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 zephyr/dts/bindings/battery/ganfeng,sg20.yaml diff --git a/zephyr/dts/bindings/battery/battery-smart.yaml b/zephyr/dts/bindings/battery/battery-smart.yaml index 1d0c9786eb..5992226291 100644 --- a/zephyr/dts/bindings/battery/battery-smart.yaml +++ b/zephyr/dts/bindings/battery/battery-smart.yaml @@ -28,6 +28,7 @@ properties: - "dynapack,cosmx_gh02047xl" - "dynapack,c140254" - "ganfeng,7c01" + - "ganfeng,sg20" - "getac,bq40z50-R3-S3" - "getac,bq40z50-R3-S2" - "lgc,ac17a8m" diff --git a/zephyr/dts/bindings/battery/ganfeng,sg20.yaml b/zephyr/dts/bindings/battery/ganfeng,sg20.yaml new file mode 100644 index 0000000000..6e8f558b00 --- /dev/null +++ b/zephyr/dts/bindings/battery/ganfeng,sg20.yaml @@ -0,0 +1,53 @@ +description: "Ganfeng SG20" +compatible: "ganfeng,sg20" + +include: battery-smart.yaml + +properties: + enum-name: + type: string + default: "ganfeng,sg20" + + # Fuel gauge + manuf_name: + default: "Ganfeng" + device_name: + default: "SG20" + ship_mode_reg_addr: + default: 0x00 + ship_mode_reg_data: + default: [ 0x0010, 0x0010 ] + fet_mfgacc_support: + default: 0 + fet_reg_addr: + default: 0x43 + fet_reg_mask: + default: 0x0001 + fet_disconnect_val: + default: 0x0000 + fet_cfet_mask: + default: 0x0002 + fet_cfet_off_val: + default: 0x0000 + + # Battery info + voltage_max: + default: 8700 + voltage_normal: + default: 7600 + voltage_min: + default: 6000 + precharge_current: + default: 256 + start_charging_min_c: + default: 0 + start_charging_max_c: + default: 50 + charging_min_c: + default: 0 + charging_max_c: + default: 60 + discharging_min_c: + default: -20 + discharging_max_c: + default: 60 diff --git a/zephyr/program/herobrine/zombie/project.overlay b/zephyr/program/herobrine/zombie/project.overlay index a1a3113132..e5b530dc5f 100644 --- a/zephyr/program/herobrine/zombie/project.overlay +++ b/zephyr/program/herobrine/zombie/project.overlay @@ -23,11 +23,8 @@ /* battery overrides */ / { batteries { - default_battery: ap19a5k { - compatible = "panasonic,ap19a5k", "battery-smart"; - }; - ap19a8k { - compatible = "lgc,ap19a8k", "battery-smart"; + default_battery: sg20 { + compatible = "ganfeng,sg20", "battery-smart"; }; }; }; -- cgit v1.2.1 From d793d0f1ca01cac4c6d673b7657f64b59fc3d7da Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Thu, 10 Nov 2022 14:04:20 -0700 Subject: tasks: catch errors Add missing error handling. BRANCH=none BUG=none TEST=twister -s zephyr/test/drivers/drivers.default Signed-off-by: Yuval Peress Change-Id: Ia48d2b243c20bfe64fe1329a59378a4c85da4fc5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4020771 Code-Coverage: Zoss Reviewed-by: Simon Glass --- zephyr/shim/src/tasks.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index 35d4ab7c42..ba43e8ac66 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -105,7 +105,7 @@ atomic_t *task_get_event_bitmap(task_id_t cros_task_id) data = task_get_base_data(cros_task_id); - return &data->event_mask; + return data == NULL ? NULL : &data->event_mask; } void task_set_event(task_id_t cros_task_id, uint32_t event) @@ -114,8 +114,10 @@ void task_set_event(task_id_t cros_task_id, uint32_t event) data = task_get_base_data(cros_task_id); - atomic_or(&data->event_mask, event); - k_poll_signal_raise(&data->new_event, 0); + if (data != NULL) { + atomic_or(&data->event_mask, event); + k_poll_signal_raise(&data->new_event, 0); + } } uint32_t task_wait_event(int timeout_us) @@ -124,6 +126,8 @@ uint32_t task_wait_event(int timeout_us) data = task_get_base_data(task_get_current()); + __ASSERT_NO_MSG(data != NULL); + const k_timeout_t timeout = (timeout_us == -1) ? K_FOREVER : K_USEC(timeout_us); const int64_t tick_deadline = -- cgit v1.2.1 From bf78094e1fb2ce447c58bba391435145756f4717 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Fri, 11 Nov 2022 12:25:00 -0700 Subject: test: add coverage for shim/src/tasks.c Add missing coverage for error cases and shell command. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I0efa2cde8a48aafa54308813b99972c7b97d64e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024064 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/shim/src/tasks.c | 24 ++++----- zephyr/test/drivers/default/CMakeLists.txt | 1 + zephyr/test/drivers/default/prj.conf | 1 + zephyr/test/drivers/default/src/task.c | 84 ++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 12 deletions(-) create mode 100644 zephyr/test/drivers/default/src/task.c diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index ba43e8ac66..a03cf4daa8 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -156,12 +156,12 @@ uint32_t task_wait_event(int timeout_us) if (events == 0) { const int64_t ticks_left = tick_deadline - k_uptime_ticks(); + events |= TASK_EVENT_TIMER; + if (ticks_left > 0) { return task_wait_event( k_ticks_to_us_near64(ticks_left)); } - - events |= TASK_EVENT_TIMER; } return events; @@ -313,18 +313,26 @@ int task_start_called(void) { return tasks_started; } - +/* + * TODO(b/190203712): Implement this + * LCOV_EXCL_START + */ void task_disable_task(task_id_t tskid) { - /* TODO(b/190203712): Implement this */ } +/* LCOV_EXCL_STOP */ +/* + * This function cannot be tested since it is architecture specific. + * LCOV_EXCL_START + */ void task_clear_pending_irq(int irq) { #if CONFIG_ITE_IT8XXX2_INTC ite_intc_isr_clear(irq); #endif } +/* LCOV_EXCL_STOP */ void task_enable_irq(int irq) { @@ -343,11 +351,3 @@ inline bool in_deferred_context(void) */ return (k_current_get() == &k_sys_work_q.thread); } - -#if IS_ENABLED(CONFIG_KERNEL_SHELL) && IS_ENABLED(CONFIG_THREAD_MONITOR) -static int taskinfo(const struct shell *shell, size_t argc, char **argv) -{ - return shell_execute_cmd(shell, "kernel threads"); -} -SHELL_CMD_REGISTER(taskinfo, NULL, "Threads statistics", taskinfo); -#endif diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt index 8f79160878..445ee50e37 100644 --- a/zephyr/test/drivers/default/CMakeLists.txt +++ b/zephyr/test/drivers/default/CMakeLists.txt @@ -82,6 +82,7 @@ target_sources(app PRIVATE src/smart.c src/stm_mems_common.c src/tablet_mode.c + src/task.c src/tcpci.c src/tcpci_test_common.c src/tcs3400.c diff --git a/zephyr/test/drivers/default/prj.conf b/zephyr/test/drivers/default/prj.conf index 9c112a6ced..c544afd4e7 100644 --- a/zephyr/test/drivers/default/prj.conf +++ b/zephyr/test/drivers/default/prj.conf @@ -9,5 +9,6 @@ CONFIG_PLATFORM_EC_LED_DT=y CONFIG_PLATFORM_EC_RTC=y CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CONSOLE_CHANNEL=y +CONFIG_TASK_HOSTCMD_THREAD_MAIN=y CONFIG_SYSTEM_FAKE=y diff --git a/zephyr/test/drivers/default/src/task.c b/zephyr/test/drivers/default/src/task.c new file mode 100644 index 0000000000..1f29a4f2f2 --- /dev/null +++ b/zephyr/test/drivers/default/src/task.c @@ -0,0 +1,84 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "task.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include "timer.h" + +struct tasks_fixture { + timestamp_t fake_time; +}; + +static void *setup(void) +{ + static struct tasks_fixture fixture; + + return &fixture; +} + +static void before(void *f) +{ + struct tasks_fixture *fixture = f; + + fixture->fake_time.val = 0; +} + +static void after(void *f) +{ + ARG_UNUSED(f); + + get_time_mock = NULL; +} + +ZTEST_SUITE(tasks, drivers_predicate_post_main, setup, before, after, NULL); + +ZTEST(tasks, test_enable_irq) +{ + arch_irq_disable(0); + task_enable_irq(0); + zassert_true(arch_irq_is_enabled(0)); +} + +ZTEST(tasks, test_interrupt_context) +{ + zassert_false(in_interrupt_context()); +} + +ZTEST_F(tasks, test_timer_arm_before_now) +{ + timestamp_t deadline = { + .val = 5, + }; + + fixture->fake_time.val = 15; + get_time_mock = &fixture->fake_time; + + zassert_ok(timer_arm(deadline, TASK_ID_MOTIONSENSE)); + zassert_equal(*task_get_event_bitmap(TASK_ID_MOTIONSENSE) & + TASK_EVENT_TIMER, + TASK_EVENT_TIMER); +} + +ZTEST_F(tasks, test_timer_arm_busy) +{ + timestamp_t deadline = { + .val = UINT64_C(5000000), + }; + + fixture->fake_time.val = 0; + get_time_mock = &fixture->fake_time; + + zassert_ok(timer_arm(deadline, TASK_ID_MOTIONSENSE)); + zassert_equal(EC_ERROR_BUSY, timer_arm(deadline, TASK_ID_MOTIONSENSE)); +} + +ZTEST(tasks, test_get_event_bitmap_invalid_tid) +{ + zassert_is_null( + task_get_event_bitmap(TASK_ID_COUNT + EXTRA_TASK_COUNT)); +} -- cgit v1.2.1 From 957fc0e658d763bcff8f275701198bb3037baaab Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 13:33:00 -0800 Subject: board/servo_v4: Free up more flash space BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=servo_v4 Signed-off-by: Tom Hughes Change-Id: I719bd93e1aaadd1591cf49c07ac65e6815de94bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024563 Reviewed-by: Brian Nemec Code-Coverage: Zoss --- board/servo_v4/board.h | 2 ++ util/build_with_clang.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h index c219f7c70a..1c7d90eab4 100644 --- a/board/servo_v4/board.h +++ b/board/servo_v4/board.h @@ -96,6 +96,8 @@ #undef CONFIG_CMD_FLASHINFO #undef CONFIG_CMD_FLASH_WP #undef CONFIG_CMD_GETTIME +#undef CONFIG_CMD_I2C_SCAN +#undef CONFIG_CMD_I2C_XFER #undef CONFIG_CMD_MEM #undef CONFIG_CMD_SHMEM #undef CONFIG_CMD_SYSLOCK diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 850abc57f4..fc254e7398 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -67,6 +67,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "rainier", "scarlet", "servo_micro", + "servo_v4", "servo_v4p1", "staff", "star", @@ -287,7 +288,6 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ "kukui", # overflows flash "makomo", # overflows flash "oak", # overflows flash - "servo_v4", # overflows flash "stern", # overflows flash "willow", # overflows flash # Boards that use CHIP:=mchp -- cgit v1.2.1 From ade196a8a5a7de2695040b9e23fbc729b3eafbdc Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 2 Nov 2022 11:26:19 +0000 Subject: zephyr: config: drop redundant CONFIG_ADC_SHELL config entries ADC_SHELL already defaults to "n", no need to set it explicitly. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I657f11a7ef27e724312915ec2fefe97a3ba1d552 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3999722 Reviewed-by: Sam Hurst Code-Coverage: Zoss --- zephyr/boards/arm/mec1727/mec1727_defconfig | 3 --- zephyr/boards/arm/npcx7/npcx7_defconfig | 3 --- zephyr/boards/arm/npcx9/npcx9m3f_defconfig | 3 --- zephyr/boards/arm/npcx9/npcx9m7f_defconfig | 3 --- zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig | 3 --- zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig | 3 --- zephyr/boards/riscv/it8xxx2/it81202bx_defconfig | 3 --- zephyr/boards/riscv/it8xxx2/it81302bx_defconfig | 3 --- zephyr/program/herobrine/program.conf | 3 --- zephyr/program/trogdor/lazor/prj.conf | 3 --- 10 files changed, 30 deletions(-) diff --git a/zephyr/boards/arm/mec1727/mec1727_defconfig b/zephyr/boards/arm/mec1727/mec1727_defconfig index fa67548e06..b99bd0a487 100644 --- a/zephyr/boards/arm/mec1727/mec1727_defconfig +++ b/zephyr/boards/arm/mec1727/mec1727_defconfig @@ -12,9 +12,6 @@ CONFIG_RTOS_TIMER=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768 CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768 -# ADC -CONFIG_ADC_SHELL=n - # Serial Drivers CONFIG_SERIAL=y CONFIG_UART_INTERRUPT_DRIVEN=y diff --git a/zephyr/boards/arm/npcx7/npcx7_defconfig b/zephyr/boards/arm/npcx7/npcx7_defconfig index c982644fa0..f84f44f9e3 100644 --- a/zephyr/boards/arm/npcx7/npcx7_defconfig +++ b/zephyr/boards/arm/npcx7/npcx7_defconfig @@ -12,9 +12,6 @@ CONFIG_BOARD_NPCX7=y CONFIG_SERIAL=y CONFIG_UART_INTERRUPT_DRIVEN=y -# ADC -CONFIG_ADC_SHELL=n - # Enable console CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y diff --git a/zephyr/boards/arm/npcx9/npcx9m3f_defconfig b/zephyr/boards/arm/npcx9/npcx9m3f_defconfig index 8202cf3e12..8238d10e03 100644 --- a/zephyr/boards/arm/npcx9/npcx9m3f_defconfig +++ b/zephyr/boards/arm/npcx9/npcx9m3f_defconfig @@ -9,9 +9,6 @@ CONFIG_SOC_NPCX9M3F=y # Platform Configuration CONFIG_BOARD_NPCX9=y -# ADC -CONFIG_ADC_SHELL=n - # Serial Drivers CONFIG_SERIAL=y CONFIG_UART_INTERRUPT_DRIVEN=y diff --git a/zephyr/boards/arm/npcx9/npcx9m7f_defconfig b/zephyr/boards/arm/npcx9/npcx9m7f_defconfig index 4deeccb897..1cb02182da 100644 --- a/zephyr/boards/arm/npcx9/npcx9m7f_defconfig +++ b/zephyr/boards/arm/npcx9/npcx9m7f_defconfig @@ -9,9 +9,6 @@ CONFIG_SOC_NPCX9M7F=y # Platform Configuration CONFIG_BOARD_NPCX9=y -# ADC -CONFIG_ADC_SHELL=n - # Serial Drivers CONFIG_SERIAL=y CONFIG_UART_INTERRUPT_DRIVEN=y diff --git a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig index b5d098fcb2..5e0228ac26 100644 --- a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig @@ -40,9 +40,6 @@ CONFIG_WATCHDOG=y # I2C CONFIG_I2C=y -# ADC -CONFIG_ADC_SHELL=n - # PWM CONFIG_PWM=y CONFIG_PWM_SHELL=n diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig index db990a38bb..369c88e3cb 100644 --- a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig @@ -40,9 +40,6 @@ CONFIG_WATCHDOG=y # I2C CONFIG_I2C=y -# ADC -CONFIG_ADC_SHELL=n - # PWM CONFIG_PWM=y CONFIG_PWM_SHELL=n diff --git a/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig b/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig index 8831b3310d..82a8a0f63f 100644 --- a/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig +++ b/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig @@ -10,9 +10,6 @@ CONFIG_SOC_IT81202_BX=y # Platform Configuration CONFIG_BOARD_IT8XXX2=y -# ADC -CONFIG_ADC_SHELL=n - # Power Management CONFIG_PM=y CONFIG_PM_DEVICE=y diff --git a/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig b/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig index a989662991..6cfac9eeb5 100644 --- a/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig +++ b/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig @@ -10,9 +10,6 @@ CONFIG_SOC_IT81302_BX=y # Platform Configuration CONFIG_BOARD_IT8XXX2=y -# ADC -CONFIG_ADC_SHELL=n - # Power Management CONFIG_PM=y CONFIG_PM_DEVICE=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 8ffd46d565..79e956aa51 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -63,9 +63,6 @@ CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CMD_BUTTON=y -# ADC -CONFIG_ADC_SHELL=n - # Battery CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 934be6e303..2e0569b22b 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -62,9 +62,6 @@ CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CMD_BUTTON=y -# ADC -CONFIG_ADC_SHELL=n - # Battery CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y -- cgit v1.2.1 From 31223f411e8b554dfcfd8d84251943bc7697c44b Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 11 Nov 2022 09:44:08 +0000 Subject: zephyr: rename mediatek signal list to add the vendor prefix Compatibles should be prefixed by vendor name, not model number. Fixes the warning: node '/power-signal-list' compatible 'mt8186,power-signal-list' has unknown vendor prefix 'mt8186' BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I706964a0cb29e1a2eda47f422721064111f4f11b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023444 Reviewed-by: Yuval Peress Code-Coverage: Zoss --- .../mediatek,mt8186-power-signal-list.yaml | 20 ++++++++++++++++++++ .../mediatek,mt8192-power-signal-list.yaml | 19 +++++++++++++++++++ .../cros_pwr_signal/mt8186,power-signal-list.yaml | 20 -------------------- .../cros_pwr_signal/mt8192,power-signal-list.yaml | 19 ------------------- zephyr/program/corsola/power_signal.dts | 2 +- 5 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8186-power-signal-list.yaml create mode 100644 zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8192-power-signal-list.yaml delete mode 100644 zephyr/dts/bindings/cros_pwr_signal/mt8186,power-signal-list.yaml delete mode 100644 zephyr/dts/bindings/cros_pwr_signal/mt8192,power-signal-list.yaml diff --git a/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8186-power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8186-power-signal-list.yaml new file mode 100644 index 0000000000..5f0e75f717 --- /dev/null +++ b/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8186-power-signal-list.yaml @@ -0,0 +1,20 @@ +# Copyright 2021 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +description: MediaTek MT8186, Power Signal List +compatible: "mediatek,mt8186-power-signal-list" + +include: power-signal-list.yaml + +properties: + power-signals-required: + default: 4 + +child-binding: + properties: + power-enum-name: + enum: + - AP_IN_RST + - AP_IN_S3 + - AP_WDT_ASSERTED + - AP_WARM_RST_REQ diff --git a/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8192-power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8192-power-signal-list.yaml new file mode 100644 index 0000000000..8bbd1207eb --- /dev/null +++ b/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8192-power-signal-list.yaml @@ -0,0 +1,19 @@ +# Copyright 2021 Google LLC +# SPDX-License-Identifier: Apache-2.0 + +description: MediaTek, Power Signal List +compatible: "mediatek,mt8192-power-signal-list" + +include: power-signal-list.yaml + +properties: + power-signals-required: + default: 3 + +child-binding: + properties: + power-enum-name: + enum: + - AP_IN_S3_L + - AP_WDT_ASSERTED + - PMIC_PWR_GOOD diff --git a/zephyr/dts/bindings/cros_pwr_signal/mt8186,power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mt8186,power-signal-list.yaml deleted file mode 100644 index 6e9af9ccef..0000000000 --- a/zephyr/dts/bindings/cros_pwr_signal/mt8186,power-signal-list.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2021 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -description: MediaTek MT8186, Power Signal List -compatible: "mt8186,power-signal-list" - -include: power-signal-list.yaml - -properties: - power-signals-required: - default: 4 - -child-binding: - properties: - power-enum-name: - enum: - - AP_IN_RST - - AP_IN_S3 - - AP_WDT_ASSERTED - - AP_WARM_RST_REQ diff --git a/zephyr/dts/bindings/cros_pwr_signal/mt8192,power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mt8192,power-signal-list.yaml deleted file mode 100644 index b1dedb76c8..0000000000 --- a/zephyr/dts/bindings/cros_pwr_signal/mt8192,power-signal-list.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2021 Google LLC -# SPDX-License-Identifier: Apache-2.0 - -description: MediaTek, Power Signal List -compatible: "mt8192,power-signal-list" - -include: power-signal-list.yaml - -properties: - power-signals-required: - default: 3 - -child-binding: - properties: - power-enum-name: - enum: - - AP_IN_S3_L - - AP_WDT_ASSERTED - - PMIC_PWR_GOOD diff --git a/zephyr/program/corsola/power_signal.dts b/zephyr/program/corsola/power_signal.dts index 181d7cf96e..5037bac228 100644 --- a/zephyr/program/corsola/power_signal.dts +++ b/zephyr/program/corsola/power_signal.dts @@ -5,7 +5,7 @@ / { power_signal_list: power-signal-list { - compatible = "mt8186,power-signal-list"; + compatible = "mediatek,mt8186-power-signal-list"; ap_in_rst { power-enum-name = "AP_IN_RST"; power-gpio-pin = <&ap_sysrst_odl_r>; -- cgit v1.2.1 From 62eb3b6338ba083d156ea63a32748996eab0741d Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 11 Nov 2022 15:13:10 +0000 Subject: zephyr: Kconfig: enable PLATFORM_EC_I2C automatically Enable PLATFORM_EC_I2C automatically based on the presence of the named-i2c-node, select I2C automatically as well, drop all the now redundant config options and safety checks. Note that the DT_PATH check is not exactly equivalent to the DT_HAS_NAMED_I2C_PORTS_ENABLED dependency, will address that in a followup patch. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I38e9725e63a02caae8f5efb1224262ee0430efb2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023447 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/Kconfig.i2c | 5 ++++- zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig | 3 --- zephyr/program/brya/prj.conf | 3 --- zephyr/program/corsola/prj.conf | 3 --- zephyr/program/herobrine/program.conf | 1 - zephyr/program/intelrvp/prj.conf | 3 --- zephyr/program/it8xxx2_evb/prj.conf | 3 --- zephyr/program/minimal/prj.conf | 2 +- zephyr/program/nissa/program.conf | 3 --- zephyr/program/rex/prj.conf | 1 - zephyr/program/skyrim/prj.conf | 3 --- zephyr/program/trogdor/lazor/prj.conf | 3 --- zephyr/shim/src/i2c.c | 7 ------- zephyr/test/drivers/prj.conf | 1 - zephyr/test/i2c/prj.conf | 1 - zephyr/test/i2c_dts/prj.conf | 1 - zephyr/test/kingler/prj.conf | 1 - zephyr/test/krabby/prj.conf | 1 - zephyr/test/vboot_efs2/prj.conf | 1 - 19 files changed, 5 insertions(+), 41 deletions(-) diff --git a/zephyr/Kconfig.i2c b/zephyr/Kconfig.i2c index 0187409b31..9fa1d274aa 100644 --- a/zephyr/Kconfig.i2c +++ b/zephyr/Kconfig.i2c @@ -3,7 +3,10 @@ # found in the LICENSE file. config PLATFORM_EC_I2C - def_bool I2C + bool "EC I2C Support" + default y + depends on DT_HAS_NAMED_I2C_PORTS_ENABLED + select I2C help Enable compilation of the EC i2c module. Once enabled, it will be possible to make calls using the old platform/ec i2c APIs defined diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig index 369c88e3cb..c39b9997f4 100644 --- a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig @@ -37,9 +37,6 @@ CONFIG_CLOCK_CONTROL=y # WATCHDOG configuration CONFIG_WATCHDOG=y -# I2C -CONFIG_I2C=y - # PWM CONFIG_PWM=y CONFIG_PWM_SHELL=n diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 1678eb29d2..1accab9770 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -37,9 +37,6 @@ CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150 -# I2C -CONFIG_I2C=y - # Power Sequencing CONFIG_PLATFORM_EC_POWERSEQ=y CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=y diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf index ea72d0890f..95fdf7b903 100644 --- a/zephyr/program/corsola/prj.conf +++ b/zephyr/program/corsola/prj.conf @@ -32,9 +32,6 @@ CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y -# I2C -CONFIG_I2C=y - # Keyboard CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 79e956aa51..baff6ef280 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -15,7 +15,6 @@ CONFIG_KERNEL_SHELL=y CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y # I2C options -CONFIG_I2C=y CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y diff --git a/zephyr/program/intelrvp/prj.conf b/zephyr/program/intelrvp/prj.conf index 46e332d91c..97b44e476d 100644 --- a/zephyr/program/intelrvp/prj.conf +++ b/zephyr/program/intelrvp/prj.conf @@ -33,9 +33,6 @@ CONFIG_PLATFORM_EC_USB_VID=0x18d1 CONFIG_PLATFORM_EC_USB_PID=0x8086 CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y -# I2C -CONFIG_I2C=y - # eSPI CONFIG_ESPI=y CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y diff --git a/zephyr/program/it8xxx2_evb/prj.conf b/zephyr/program/it8xxx2_evb/prj.conf index 5d561eb4e4..1e1cac492b 100644 --- a/zephyr/program/it8xxx2_evb/prj.conf +++ b/zephyr/program/it8xxx2_evb/prj.conf @@ -19,9 +19,6 @@ CONFIG_LOG=y # Fan CONFIG_SENSOR=y -# I2C -CONFIG_I2C=y - # PWM CONFIG_PWM=y CONFIG_PWM_SHELL=n diff --git a/zephyr/program/minimal/prj.conf b/zephyr/program/minimal/prj.conf index db7cac0cef..bacb4fe288 100644 --- a/zephyr/program/minimal/prj.conf +++ b/zephyr/program/minimal/prj.conf @@ -9,10 +9,10 @@ CONFIG_SYSCON=y # Disable default features we don't want in a minimal example. CONFIG_ADC=n -CONFIG_I2C=n CONFIG_PWM=n CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_KEYBOARD=n CONFIG_PLATFORM_EC_POWER_BUTTON=n CONFIG_PLATFORM_EC_SWITCH=n CONFIG_PLATFORM_EC_VBOOT_EFS2=n +CONFIG_PLATFORM_EC_I2C=n diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index dad804a8ee..b26ea75246 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -53,9 +53,6 @@ CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y CONFIG_AP_PWRSEQ_S0IX=y CONFIG_AP_PWRSEQ_S0IX_ERROR_RECOVERY=y -# I2C -CONFIG_I2C=y - # Keyboard support CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y CONFIG_PLATFORM_EC_KEYBOARD=y diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 6be79dca70..53446f353b 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -52,7 +52,6 @@ CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y CONFIG_AP_PWRSEQ_S0IX=y # I2C -CONFIG_I2C=y CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y # PWM diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 874f823010..202ddd90a9 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -27,9 +27,6 @@ CONFIG_PLATFORM_EC_PORT80=y # Power button CONFIG_PLATFORM_EC_POWER_BUTTON=y -# I2C -CONFIG_I2C=y - # CBI CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 2e0569b22b..323fb1ca00 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -21,9 +21,6 @@ CONFIG_PLATFORM_EC_LID_SWITCH=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=y CONFIG_PLATFORM_EC_POWER_BUTTON=y -# I2C -CONFIG_I2C=y - # LED CONFIG_PLATFORM_EC_LED_DT=y diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c index 0074327826..0a9fc41397 100644 --- a/zephyr/shim/src/i2c.c +++ b/zephyr/shim/src/i2c.c @@ -10,13 +10,6 @@ #include "i2c.h" #include "i2c/i2c.h" -/* - * The named-i2c-ports node is required by the I2C shim - */ -#if !DT_NODE_EXISTS(DT_PATH(named_i2c_ports)) -#error I2C shim requires the named-i2c-ports node to be defined. -#endif - /* * Initialize device bindings in i2c_devices. * This macro should be called from within DT_FOREACH_CHILD. diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 3169051bed..f796adfbe1 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -45,7 +45,6 @@ CONFIG_CROS_EC=y CONFIG_SHIMMED_TASKS=y CONFIG_EMUL=y CONFIG_LOG=y -CONFIG_I2C=y CONFIG_I2C_EMUL=y CONFIG_GPIO=y CONFIG_GPIO_EMUL=y diff --git a/zephyr/test/i2c/prj.conf b/zephyr/test/i2c/prj.conf index ee6c43f51a..b81e088ceb 100644 --- a/zephyr/test/i2c/prj.conf +++ b/zephyr/test/i2c/prj.conf @@ -6,7 +6,6 @@ CONFIG_ZTEST=y CONFIG_LOG=y CONFIG_EMUL=y -CONFIG_I2C=y CONFIG_I2C_EMUL=y CONFIG_BMI160=y CONFIG_EMUL_BMI160=y diff --git a/zephyr/test/i2c_dts/prj.conf b/zephyr/test/i2c_dts/prj.conf index 6c008faf64..37e0b443a4 100644 --- a/zephyr/test/i2c_dts/prj.conf +++ b/zephyr/test/i2c_dts/prj.conf @@ -7,7 +7,6 @@ CONFIG_ZTEST_NEW_API=y CONFIG_LOG=y CONFIG_EMUL=y -CONFIG_I2C=y CONFIG_I2C_EMUL=y CONFIG_BMI160=y CONFIG_EMUL_BMI160=y diff --git a/zephyr/test/kingler/prj.conf b/zephyr/test/kingler/prj.conf index 76f4434bc6..a5249f0776 100644 --- a/zephyr/test/kingler/prj.conf +++ b/zephyr/test/kingler/prj.conf @@ -18,7 +18,6 @@ CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y CONFIG_PLATFORM_EC_TABLET_MODE=y CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_I2C=y CONFIG_I2C_NPCX=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y diff --git a/zephyr/test/krabby/prj.conf b/zephyr/test/krabby/prj.conf index c83242059d..fd41778593 100644 --- a/zephyr/test/krabby/prj.conf +++ b/zephyr/test/krabby/prj.conf @@ -14,7 +14,6 @@ CONFIG_EMUL_RT9490=y CONFIG_EMUL_SMART_BATTERY=y CONFIG_EMUL_TCPCI=y CONFIG_EMUL_TUSB1064=y -CONFIG_I2C=y CONFIG_I2C_EMUL=y CONFIG_PLATFORM_EC=y diff --git a/zephyr/test/vboot_efs2/prj.conf b/zephyr/test/vboot_efs2/prj.conf index 4858e0602d..45d18428bd 100644 --- a/zephyr/test/vboot_efs2/prj.conf +++ b/zephyr/test/vboot_efs2/prj.conf @@ -9,7 +9,6 @@ CONFIG_EMUL_CROS_FLASH=y CONFIG_EMUL_SMART_BATTERY=y CONFIG_EMUL_TCPCI=y CONFIG_FLASH=y -CONFIG_I2C=y CONFIG_I2C_EMUL=y CONFIG_PLATFORM_EC=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -- cgit v1.2.1 From 8260703ba889dfde312eaf0eca8f48c9d4273440 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 11 Nov 2022 15:31:32 +0000 Subject: zephyr: Kconfig: drop explicit CONFIG_EEPROM_AT24=y It's already automatically selected when necessary, no need to do it explicitly. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I6ec980ef4d69bb9388d4268d7b0cb6fba349aafd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023448 Code-Coverage: Zoss Reviewed-by: Wai-Hong Tam --- zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/prj.conf | 1 - zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 1 - zephyr/program/intelrvp/adlrvp/prj.conf | 1 - zephyr/program/intelrvp/mtlrvp/prj.conf | 1 - zephyr/program/nissa/program.conf | 1 - zephyr/program/rex/prj.conf | 1 - zephyr/program/skyrim/prj.conf | 1 - zephyr/test/drivers/prj.conf | 1 - zephyr/test/kingler/prj.conf | 1 - 10 files changed, 10 deletions(-) diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 1accab9770..08298d635c 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -27,7 +27,6 @@ CONFIG_ARM_MPU=y # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf index 95fdf7b903..5b0997bf73 100644 --- a/zephyr/program/corsola/prj.conf +++ b/zephyr/program/corsola/prj.conf @@ -28,7 +28,6 @@ CONFIG_SHELL_TAB_AUTOCOMPLETION=y # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf index d18e9c14b0..dee4b425b0 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf @@ -53,7 +53,6 @@ CONFIG_PLATFORM_EC_THROTTLE_AP=n ## ADL RVP # CBI CONFIG_EEPROM=n -CONFIG_EEPROM_AT24=n CONFIG_EEPROM_SHELL=n # LED diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index b0b8b7ead2..13e832d7a8 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -17,7 +17,6 @@ CONFIG_PLATFORM_EC_USB_CHARGER=n # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n # Charger diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index 1dc120933e..28e8298658 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -14,7 +14,6 @@ CONFIG_PLATFORM_EC_BATTERY_V2=y # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index b26ea75246..d036141f8d 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -80,7 +80,6 @@ CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY=y # CBI EEPROM support CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 53446f353b..0b396ef498 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -68,7 +68,6 @@ CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y # CBI EEPROM support CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 202ddd90a9..dec5a152a8 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -29,7 +29,6 @@ CONFIG_PLATFORM_EC_POWER_BUTTON=y # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index f796adfbe1..1e6d57fe45 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -50,7 +50,6 @@ CONFIG_GPIO=y CONFIG_GPIO_EMUL=y CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY=49 CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SIMULATOR=n CONFIG_EMUL_EEPROM_AT2X=y CONFIG_EMUL_SMART_BATTERY=y diff --git a/zephyr/test/kingler/prj.conf b/zephyr/test/kingler/prj.conf index a5249f0776..769710651a 100644 --- a/zephyr/test/kingler/prj.conf +++ b/zephyr/test/kingler/prj.conf @@ -22,7 +22,6 @@ CONFIG_I2C_NPCX=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y CONFIG_EEPROM_SIMULATOR=n CONFIG_EMUL_EEPROM_AT2X=y CONFIG_EEPROM_SHELL=n -- cgit v1.2.1 From 5cf490d59c3d0a2ab0ac82b963888de4035a68ef Mon Sep 17 00:00:00 2001 From: Dawid Niedzwiecki Date: Thu, 10 Nov 2022 08:37:19 +0000 Subject: zephyr: tests: add pct2075 emulator Add PCT2075 temperature sensor emulator. The PCT2075 doesn't support the OS pin. The emulator helps with testing code that is touched only by i2c temperature sensors. BUG=b:244474857 BRANCH=main TEST=twister -T zephyr/test/drivers Signed-off-by: Dawid Niedzwiecki Change-Id: Iaefed4ffd50b17b59da89361abeded28456751ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4020414 Commit-Queue: Keith Short Tested-by: Dawid Niedzwiecki Code-Coverage: Zoss Reviewed-by: Keith Short --- include/driver/temp_sensor/pct2075.h | 1 + zephyr/emul/CMakeLists.txt | 1 + zephyr/emul/Kconfig | 7 ++ zephyr/emul/emul_pct2075.c | 107 ++++++++++++++++++++++++ zephyr/include/emul/emul_pct2075.h | 31 +++++++ zephyr/shim/src/temp_sensors.c | 2 + zephyr/test/drivers/boards/native_posix.overlay | 10 +++ zephyr/test/drivers/default/src/temp_sensor.c | 93 ++++++++++++++++++++ zephyr/test/drivers/default/src/thermistor.c | 32 ++++++- zephyr/test/drivers/prj.conf | 2 + 10 files changed, 285 insertions(+), 1 deletion(-) create mode 100644 zephyr/emul/emul_pct2075.c create mode 100644 zephyr/include/emul/emul_pct2075.h diff --git a/include/driver/temp_sensor/pct2075.h b/include/driver/temp_sensor/pct2075.h index e79ac0e97a..77fae67712 100644 --- a/include/driver/temp_sensor/pct2075.h +++ b/include/driver/temp_sensor/pct2075.h @@ -21,6 +21,7 @@ #define PCT2075_REG_CONF 0x01 #define PCT2075_REG_THYST 0x02 #define PCT2075_REG_TOS 0x03 +#define PCT2075_REG_TIDLE 0x04 /* * I2C port and address information for all the board PCT2075 sensors should be diff --git a/zephyr/emul/CMakeLists.txt b/zephyr/emul/CMakeLists.txt index 377be11792..3d268dde80 100644 --- a/zephyr/emul/CMakeLists.txt +++ b/zephyr/emul/CMakeLists.txt @@ -26,5 +26,6 @@ zephyr_library_sources_ifdef(CONFIG_EMUL_CROS_FLASH emul_flash.c) zephyr_library_sources_ifdef(CONFIG_EMUL_RTC emul_rtc.c) zephyr_library_sources_ifdef(CONFIG_EMUL_RT9490 emul_rt9490.c) zephyr_library_sources_ifdef(CONFIG_PWM_MOCK pwm_mock.c) +zephyr_library_sources_ifdef(CONFIG_EMUL_PCT2075 emul_pct2075.c) cros_ec_library_include_directories_ifdef(CONFIG_EMUL_CROS_FLASH include) diff --git a/zephyr/emul/Kconfig b/zephyr/emul/Kconfig index e445e30154..94bc4ecc0d 100644 --- a/zephyr/emul/Kconfig +++ b/zephyr/emul/Kconfig @@ -106,6 +106,13 @@ config PWM_MOCK Enable the PWM mock. This driver is a pure mock and does nothing by default. +config EMUL_PCT2075 + bool "PCT2075 emulator" + select EMUL_COMMON_I2C + help + Enable the PCT2075 temperature sensor emulator. It uses emulated I2C bus. + Emulator API is available in zephyr/include/emul/emul_pct2075.h. + rsource "Kconfig.ln9310" rsource "Kconfig.lis2dw12" rsource "Kconfig.i2c_mock" diff --git a/zephyr/emul/emul_pct2075.c b/zephyr/emul/emul_pct2075.c new file mode 100644 index 0000000000..f820fbd30a --- /dev/null +++ b/zephyr/emul/emul_pct2075.c @@ -0,0 +1,107 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "driver/temp_sensor/pct2075.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" +#include "emul/emul_pct2075.h" +#include "util.h" + +/* NOTE: The emulator doesn't support OS pin */ + +#define DT_DRV_COMPAT nxp_pct2075 + +#define PCT2075_TEMP_MAX_MC 127000 +#define PCT2075_TEMP_MIN_MC -55000 +#define PCT2075_RESOLUTION_MC 125 + +static const uint16_t default_values[PCT2075_REG_NUMBER] = { + [PCT2075_REG_TEMP] = 0x00, [PCT2075_REG_CONF] = 0x00, + [PCT2075_REG_THYST] = 0x4b00, [PCT2075_REG_TOS] = 0x5000, + [PCT2075_REG_TIDLE] = 0x00, +}; + +void pct2075_emul_reset_regs(const struct emul *emul) +{ + struct pct2075_data *data = (struct pct2075_data *)emul->data; + + memcpy(data->regs, default_values, PCT2075_REG_NUMBER + 1); +} + +int pct2075_emul_set_temp(const struct emul *emul, int mk) +{ + struct pct2075_data *data = (struct pct2075_data *)emul->data; + int mc = MILLI_KELVIN_TO_MILLI_CELSIUS(mk); + int reg; + + if (!IN_RANGE(mc, PCT2075_TEMP_MIN_MC, PCT2075_TEMP_MAX_MC)) { + return -1; + } + + /* Divide by the sensor resolution to get register value */ + reg = mc / PCT2075_RESOLUTION_MC; + + /* Use 11 most significant bits. */ + data->regs[PCT2075_REG_TEMP] = reg << 5; + + return 0; +} + +int pct2075_emul_read_byte(const struct emul *target, int reg, uint8_t *val, + int bytes) +{ + struct pct2075_data *data = (struct pct2075_data *)target->data; + + if (!IN_RANGE(reg, 0, PCT2075_REG_NUMBER - 1)) { + return -1; + } + + if (bytes == 0) { + *val = data->regs[reg] >> 8; + } else if (bytes == 1) { + *val = data->regs[reg] & 0x00FF; + } else { + /* Support up to 2 bytes read */ + return -1; + } + + return 0; +} + +static int pct2075_emul_init(const struct emul *emul, + const struct device *parent) +{ + struct pct2075_data *data = (struct pct2075_data *)emul->data; + struct i2c_common_emul_data *common_data = &data->common; + + i2c_common_emul_init(common_data); + + pct2075_emul_reset_regs(emul); + + return 0; +} + +#define INIT_PCT2075_EMUL(n) \ + static struct i2c_common_emul_cfg common_cfg_##n; \ + static struct pct2075_data pct2075_data_##n; \ + static struct i2c_common_emul_cfg common_cfg_##n = { \ + .dev_label = DT_NODE_FULL_NAME(DT_DRV_INST(n)), \ + .data = &pct2075_data_##n.common, \ + .addr = DT_INST_REG_ADDR(n) \ + }; \ + static struct pct2075_data pct2075_data_##n = { \ + .common = { \ + .cfg = &common_cfg_##n, \ + .read_byte = pct2075_emul_read_byte, \ + }, \ + }; \ + EMUL_DT_INST_DEFINE(n, pct2075_emul_init, &pct2075_data_##n, \ + &common_cfg_##n, &i2c_common_emul_api) + +DT_INST_FOREACH_STATUS_OKAY(INIT_PCT2075_EMUL) + +DT_INST_FOREACH_STATUS_OKAY(EMUL_STUB_DEVICE); diff --git a/zephyr/include/emul/emul_pct2075.h b/zephyr/include/emul/emul_pct2075.h new file mode 100644 index 0000000000..0c62942a20 --- /dev/null +++ b/zephyr/include/emul/emul_pct2075.h @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef EMUL_PCT2075_H +#define EMUL_PCT2075_H + +#include +#include "emul/emul_common_i2c.h" + +#define PCT2075_REG_NUMBER 5 + +struct pct2075_data { + struct i2c_common_emul_data common; + uint16_t regs[PCT2075_REG_NUMBER]; +}; + +/** + * @brief Set the temperature measurement for the sensor. + * + * @param emul Pointer to emulator + * @param mk Temperature to set in mili-kalvin. The temperature + * should me in range of 328150 to 400150, with 150 resolution. + * + * @return 0 on success + * @return negative on error + */ +int pct2075_emul_set_temp(const struct emul *emul, int mk); + +#endif diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c index 371d7d7fc9..c8f2047c94 100644 --- a/zephyr/shim/src/temp_sensors.c +++ b/zephyr/shim/src/temp_sensors.c @@ -235,6 +235,8 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = { const struct temp_sensor_t temp_sensors[] = { DT_FOREACH_CHILD_SEP( TEMP_SENSORS_NODEID, TEMP_SENSOR_ENTRY, (, )) }; +BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); + int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr) { const struct temp_sensor_t *sensor; diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index 5489c36d00..e244cb39f1 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -522,6 +522,11 @@ power-good-pin = <&gpio_ec_pg_pin_temp>; sensor = <&temp_fan>; }; + named_pct2075: soc { + status = "okay"; + power-good-pin = <&gpio_ec_pg_pin_temp>; + sensor = <&pct2075_emul>; + }; }; /* @@ -856,6 +861,11 @@ p1-i2c-addr = <0x9>; gpio-i2c-addr = <0x1a>; }; + + pct2075_emul: pct2075@48 { + compatible = "nxp,pct2075"; + reg = <0x48>; + }; }; clock: clock { diff --git a/zephyr/test/drivers/default/src/temp_sensor.c b/zephyr/test/drivers/default/src/temp_sensor.c index 61441a0229..f387302d73 100644 --- a/zephyr/test/drivers/default/src/temp_sensor.c +++ b/zephyr/test/drivers/default/src/temp_sensor.c @@ -9,13 +9,18 @@ #include #include #include +#include #include #include "common.h" +#include "driver/temp_sensor/pct2075.h" +#include "emul/emul_pct2075.h" +#include "math_util.h" #include "temp_sensor.h" #include "temp_sensor/temp_sensor.h" #include "test/drivers/test_state.h" +#include "timer.h" #define GPIO_PG_EC_DSW_PWROK_PATH DT_PATH(named_gpios, pg_ec_dsw_pwrok) #define GPIO_PG_EC_DSW_PWROK_PORT DT_GPIO_PIN(GPIO_PG_EC_DSW_PWROK_PATH, gpios) @@ -110,6 +115,11 @@ ZTEST_USER(temp_sensor, test_temp_sensor_pg_pin) named_temp_pp3300_regulator)), &temp), NULL); + zassert_equal( + EC_ERROR_NOT_POWERED, + temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(named_pct2075)), + &temp), + NULL); /* power ADC */ zassert_ok(gpio_emul_input_set(gpio_dev, GPIO_EC_PG_PIN_TEMP_PORT, 1), @@ -179,12 +189,92 @@ ZTEST_USER(temp_sensor, test_temp_sensor_read) } } +/** Test if temp_sensor_read() returns temperature on success for PCT2075 */ +ZTEST_USER(temp_sensor, test_temp_sensor_pct2075) +{ + int temp; + const struct emul *dev = EMUL_DT_GET(DT_NODELABEL(pct2075_emul)); + int mk[] = { + MILLI_CELSIUS_TO_MILLI_KELVIN(127000), + MILLI_CELSIUS_TO_MILLI_KELVIN(126850), + MILLI_CELSIUS_TO_MILLI_KELVIN(125), + MILLI_CELSIUS_TO_MILLI_KELVIN(0), + MILLI_CELSIUS_TO_MILLI_KELVIN(-125), + MILLI_CELSIUS_TO_MILLI_KELVIN(-54875), + MILLI_CELSIUS_TO_MILLI_KELVIN(-55000), + }; + + for (int i = 0; i < ARRAY_SIZE(mk); i++) { + pct2075_emul_set_temp(dev, mk[i]); + /* Highly dependent on current implementation. The sensor + * update temperature in the 1 second periodic hook, so + * we need to wait for it. + */ + msleep(1100); + zassert_equal(EC_SUCCESS, + temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL( + named_pct2075)), + &temp)); + zassert_equal(MILLI_KELVIN_TO_KELVIN(mk[i]), temp); + } +} + +/** Test if temperature is not updated on I2C read fail. + * The test highly dependent on current implementation - temp_sensor_read + * doesn't return an error on the i2c read fail, which can/should be changed + * in the future. + */ +ZTEST_USER(temp_sensor, test_temp_sensor_pct2075_fail) +{ + const struct emul *dev = EMUL_DT_GET(DT_NODELABEL(pct2075_emul)); + struct pct2075_data *data = (struct pct2075_data *)dev->data; + int mk1 = 373000, mk2 = 273000; + int temp; + + /* Set initial temperature */ + pct2075_emul_set_temp(dev, mk1); + msleep(1100); + + zassert_equal(EC_SUCCESS, temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL( + named_pct2075)), + &temp)); + /* Make sure the temperature is read correctly */ + zassert_equal(MILLI_KELVIN_TO_KELVIN(mk1), temp); + + /* Set I2C fail on the temperature register */ + i2c_common_emul_set_read_fail_reg(&data->common, PCT2075_REG_TEMP); + pct2075_emul_set_temp(dev, mk2); + /* Wait for potential update */ + msleep(1100); + + /* Make sure the temperature is not changed */ + zassert_equal(EC_SUCCESS, temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL( + named_pct2075)), + &temp)); + zassert_equal(MILLI_KELVIN_TO_KELVIN(mk1), temp); + + /* Restore I2C */ + i2c_common_emul_set_read_fail_reg(&data->common, + I2C_COMMON_EMUL_NO_FAIL_REG); + /* Wait for update */ + msleep(1100); + /* Make sure the temperature is updated */ + zassert_equal(EC_SUCCESS, temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL( + named_pct2075)), + &temp)); + zassert_equal(MILLI_KELVIN_TO_KELVIN(mk2), temp); +} + static void *temp_sensor_setup(void) { const struct device *dev = DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_PG_EC_DSW_PWROK_PATH, gpios)); const struct device *dev_pin = DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_EC_PG_PIN_TEMP_PATH, gpios)); + const struct emul *pct2075_dev = + EMUL_DT_GET(DT_NODELABEL(pct2075_emul)); + struct pct2075_data *pct2075_data = + (struct pct2075_data *)pct2075_dev->data; zassert_not_null(dev, NULL); /* Before tests make sure that power pins are set. */ @@ -193,6 +283,9 @@ static void *temp_sensor_setup(void) zassert_ok(gpio_emul_input_set(dev_pin, GPIO_EC_PG_PIN_TEMP_PORT, 1), NULL); + i2c_common_emul_set_read_fail_reg(&pct2075_data->common, + I2C_COMMON_EMUL_NO_FAIL_REG); + return NULL; } diff --git a/zephyr/test/drivers/default/src/thermistor.c b/zephyr/test/drivers/default/src/thermistor.c index 417b482d99..9e41307618 100644 --- a/zephyr/test/drivers/default/src/thermistor.c +++ b/zephyr/test/drivers/default/src/thermistor.c @@ -58,6 +58,10 @@ ZTEST_USER(thermistor, test_thermistor_power_pin) sensor_idx++) { const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx]; + /* Skip for sensors that are not thermistors */ + if (sensor->zephyr_info->thermistor == NULL) + continue; + zassert_ok(adc_emul_const_value_set(adc_dev, sensor->idx, A_VALID_VOLTAGE), "adc_emul_value_func_set() failed on %s", @@ -72,6 +76,10 @@ ZTEST_USER(thermistor, test_thermistor_power_pin) sensor_idx++) { const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx]; + /* Skip for sensors that are not thermistors */ + if (sensor->zephyr_info->thermistor == NULL) + continue; + zassert_equal(EC_ERROR_NOT_POWERED, sensor->zephyr_info->read(sensor, &temp), "%s failed", sensor->name); @@ -85,6 +93,10 @@ ZTEST_USER(thermistor, test_thermistor_power_pin) sensor_idx++) { const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx]; + /* Skip for sensors that are not thermistors */ + if (sensor->zephyr_info->thermistor == NULL) + continue; + zassert_equal(EC_SUCCESS, sensor->zephyr_info->read(sensor, &temp), "%s failed", sensor->name); @@ -113,6 +125,10 @@ ZTEST_USER(thermistor, test_thermistor_adc_read_error) sensor_idx++) { const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx]; + /* Skip for sensors that are not thermistors */ + if (sensor->zephyr_info->thermistor == NULL) + continue; + zassert_ok(adc_emul_value_func_set(adc_dev, sensor->idx, adc_error_func, NULL), "adc_emul_value_func_set() failed on %s", @@ -123,6 +139,10 @@ ZTEST_USER(thermistor, test_thermistor_adc_read_error) sensor_idx++) { const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx]; + /* Skip for sensors that are not thermistors */ + if (sensor->zephyr_info->thermistor == NULL) + continue; + zassert_equal(EC_ERROR_UNKNOWN, sensor->zephyr_info->read(sensor, &temp), "%s failed", sensor->name); @@ -265,10 +285,16 @@ ZTEST_USER(thermistor, test_thermistors_adc_temperature_conversion) const static int reference_res_arr[] = { DT_FOREACH_STATUS_OKAY( THERMISTOR_COMPAT, GET_THERMISTOR_REF_RES) }; - for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE; sensor_idx++) + for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE; + sensor_idx++) { + /* Skip for sensors that are not thermistors */ + if (temp_sensors[sensor_idx].zephyr_info->thermistor == NULL) + continue; + do_thermistor_test(&temp_sensors[sensor_idx], reference_mv_arr[sensor_idx], reference_res_arr[sensor_idx]); + } } ZTEST_USER(thermistor, test_device_nodes_enabled) @@ -312,6 +338,10 @@ static void thermistor_cleanup(void *state) for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE; sensor_idx++) { + /* Skip for sensors that are not thermistors */ + if (temp_sensors[sensor_idx].zephyr_info->thermistor == NULL) + continue; + /* Setup ADC to return 27*C (300K) which is reasonable value */ adc_emul_const_value_set( adc_dev, temp_sensors[sensor_idx].idx, diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 1e6d57fe45..68a13a1f9d 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -65,6 +65,7 @@ CONFIG_EMUL_PS8XXX=y CONFIG_EMUL_RTC=y CONFIG_EMUL_TCPCI_PARTNER_DRP=y CONFIG_EMUL_TCPCI_PARTNER_FAULTY_EXT=y +CONFIG_EMUL_PCT2075=y CONFIG_PLATFORM_EC_CHARGE_MANAGER=y CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y CONFIG_PLATFORM_EC_CHARGESPLASH=y @@ -128,6 +129,7 @@ CONFIG_PLATFORM_EC_USB_PD_CLEAR_HARD_RESET_STATUS=y CONFIG_PLATFORM_EC_CONSOLE_CMD_WAITMS=y CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y +CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y CONFIG_ESPI=y CONFIG_ESPI_EMUL=y -- cgit v1.2.1 From 51e14ac413c280ccbbd840bfb9669142c7622ed7 Mon Sep 17 00:00:00 2001 From: Dawid Niedzwiecki Date: Thu, 3 Nov 2022 15:21:23 +0100 Subject: zephyr: move periodic temp read hook to shim layer Some of the temperature sensor drivers declare periodic one second hook to update cached temperature measurement. Declare common hook and call the update function for every sensor. The change allows better manageing of the update calls, e.g. checking power-good pin. BUG=b:244474857 BRANCH=main TEST=skyrim doesn't spam "Recover Bus failed" in G3 Signed-off-by: Dawid Niedzwiecki Change-Id: Ibdfe63e20c726efb738deaa23444f7d6dd87b5e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3909669 Reviewed-by: Diana Z Code-Coverage: Zoss Commit-Queue: Keith Short Reviewed-by: Keith Short Tested-by: Dawid Niedzwiecki --- driver/temp_sensor/pct2075.c | 13 ++++++ driver/temp_sensor/tmp112.c | 13 ++++++ include/driver/temp_sensor/pct2075.h | 4 ++ include/driver/temp_sensor/tmp112.h | 4 ++ zephyr/shim/include/temp_sensor/temp_sensor.h | 1 + zephyr/shim/src/temp_sensors.c | 67 ++++++++++++++++++++------- 6 files changed, 84 insertions(+), 18 deletions(-) diff --git a/driver/temp_sensor/pct2075.c b/driver/temp_sensor/pct2075.c index 9c7b7190e9..de951ca6b1 100644 --- a/driver/temp_sensor/pct2075.c +++ b/driver/temp_sensor/pct2075.c @@ -76,6 +76,7 @@ int pct2075_get_val_mk(int idx, int *temp_mk_ptr) return EC_SUCCESS; } +#ifndef CONFIG_ZEPHYR static void pct2075_poll(void) { int s; @@ -87,6 +88,18 @@ static void pct2075_poll(void) } } DECLARE_HOOK(HOOK_SECOND, pct2075_poll, HOOK_PRIO_TEMP_SENSOR); +#else +void pct2075_update_temperature(int idx) +{ + int temp_reg = 0; + + if (idx >= PCT2075_COUNT) + return; + + if (get_reg_temp(idx, &temp_reg) == EC_SUCCESS) + temp_mk_local[idx] = pct2075_reg_to_mk(temp_reg); +} +#endif /* CONFIG_ZEPHYR */ void pct2075_init(void) { diff --git a/driver/temp_sensor/tmp112.c b/driver/temp_sensor/tmp112.c index f7f28159aa..1af8679421 100644 --- a/driver/temp_sensor/tmp112.c +++ b/driver/temp_sensor/tmp112.c @@ -92,6 +92,7 @@ int tmp112_get_val_mk(int idx, int *temp_mk_ptr) return EC_SUCCESS; } +#ifndef CONFIG_ZEPHYR static void tmp112_poll(void) { int s; @@ -103,6 +104,18 @@ static void tmp112_poll(void) } } DECLARE_HOOK(HOOK_SECOND, tmp112_poll, HOOK_PRIO_TEMP_SENSOR); +#else +static void tmp112_update_temperature(int idx) +{ + int temp_reg = 0; + + if (idx >= TMP112_COUNT) + return; + + if (get_reg_temp(idx, &temp_reg) == EC_SUCCESS) + temp_mk_local[idx] = tmp112_reg_to_mk(temp_reg); +} +#endif /* CONFIG_ZEPHYR */ void tmp112_init(void) { diff --git a/include/driver/temp_sensor/pct2075.h b/include/driver/temp_sensor/pct2075.h index 77fae67712..2d374bb2ba 100644 --- a/include/driver/temp_sensor/pct2075.h +++ b/include/driver/temp_sensor/pct2075.h @@ -68,4 +68,8 @@ int pct2075_get_val_mk(int idx, int *temp_mk_ptr); */ void pct2075_init(void); +#ifdef CONFIG_ZEPHYR +void pct2075_update_temperature(int idx); +#endif /* CONFIG_ZEPHYR */ + #endif /* __CROS_EC_PCT2075_H */ diff --git a/include/driver/temp_sensor/tmp112.h b/include/driver/temp_sensor/tmp112.h index 56d55d9133..3c9a0a004b 100644 --- a/include/driver/temp_sensor/tmp112.h +++ b/include/driver/temp_sensor/tmp112.h @@ -63,4 +63,8 @@ int tmp112_get_val_mk(int idx, int *temp_mk_ptr); */ void tmp112_init(void); +#ifdef CONFIG_ZEPHYR +void tmp112_update_temperature(int idx); +#endif /* CONFIG_ZEPHYR */ + #endif /* __CROS_EC_TMP112_H */ diff --git a/zephyr/shim/include/temp_sensor/temp_sensor.h b/zephyr/shim/include/temp_sensor/temp_sensor.h index 9be18987eb..a6cdfb5524 100644 --- a/zephyr/shim/include/temp_sensor/temp_sensor.h +++ b/zephyr/shim/include/temp_sensor/temp_sensor.h @@ -143,6 +143,7 @@ enum tmp112_sensor { struct zephyr_temp_sensor { /* Read sensor value in K into temp_ptr; return non-zero if error. */ int (*read)(const struct temp_sensor_t *sensor, int *temp_ptr); + void (*update_temperature)(int idx); const struct thermistor_info *thermistor; #if ANY_INST_HAS_POWER_GOOD_PIN const struct device *power_good_dev; diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c index c8f2047c94..ae3a367252 100644 --- a/zephyr/shim/src/temp_sensors.c +++ b/zephyr/shim/src/temp_sensors.c @@ -6,6 +6,7 @@ #include "adc.h" #include "charger/chg_rt9490.h" #include "driver/charger/rt9490.h" +#include "hooks.h" #include "temp_sensor.h" #include "temp_sensor/pct2075.h" #include "temp_sensor/sb_tsi.h" @@ -79,6 +80,7 @@ static int thermistor_get_temp(const struct temp_sensor_t *sensor, .read = &thermistor_get_temp, \ .thermistor = GET_THERMISTOR_INFO( \ DT_PHANDLE(sensor_id, thermistor)), \ + .update_temperature = NULL, \ FILL_POWER_GOOD(named_id) }) #define TEMP_THERMISTOR(named_id, sensor_id) \ @@ -110,10 +112,12 @@ __maybe_unused static int pct2075_get_temp(const struct temp_sensor_t *sensor, (DT_REG_ADDR(node_id) | I2C_FLAG_BIG_ENDIAN), \ }, -#define GET_ZEPHYR_TEMP_SENSOR_PCT2075(named_id) \ - (&(const struct zephyr_temp_sensor){ .read = &pct2075_get_temp, \ - .thermistor = NULL, \ - FILL_POWER_GOOD(named_id) }) +#define GET_ZEPHYR_TEMP_SENSOR_PCT2075(named_id) \ + (&(const struct zephyr_temp_sensor){ \ + .read = &pct2075_get_temp, \ + .thermistor = NULL, \ + .update_temperature = pct2075_update_temperature, \ + FILL_POWER_GOOD(named_id) }) #define TEMP_PCT2075(named_id, sensor_id) \ [TEMP_SENSOR_ID(named_id)] = { \ @@ -144,9 +148,10 @@ __maybe_unused static int sb_tsi_get_temp(const struct temp_sensor_t *sensor, #endif /* SB_TSI_COMPAT */ -#define GET_ZEPHYR_TEMP_SENSOR_SB_TSI(named_id) \ - (&(const struct zephyr_temp_sensor){ .read = &sb_tsi_get_temp, \ - .thermistor = NULL, \ +#define GET_ZEPHYR_TEMP_SENSOR_SB_TSI(named_id) \ + (&(const struct zephyr_temp_sensor){ .read = &sb_tsi_get_temp, \ + .thermistor = NULL, \ + .update_temperature = NULL, \ FILL_POWER_GOOD(named_id) }) #define TEMP_SB_TSI(named_id, sensor_id) \ @@ -174,10 +179,12 @@ __maybe_unused static int tmp112_get_temp(const struct temp_sensor_t *sensor, .i2c_addr_flags = DT_REG_ADDR(node_id), \ }, -#define GET_ZEPHYR_TEMP_SENSOR_TMP112(named_id) \ - (&(const struct zephyr_temp_sensor){ .read = &tmp112_get_temp, \ - .thermistor = NULL, \ - FILL_POWER_GOOD(named_id) }) +#define GET_ZEPHYR_TEMP_SENSOR_TMP112(named_id) \ + (&(const struct zephyr_temp_sensor){ \ + .read = &tmp112_get_temp, \ + .thermistor = NULL, \ + .update_temperature = tmp112_update_temperature, \ + FILL_POWER_GOOD(named_id) }) #define TEMP_TMP112(named_id, sensor_id) \ [TEMP_SENSOR_ID(named_id)] = { \ @@ -204,6 +211,7 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = { .read = &rt9490_get_thermistor_val, \ .thermistor = GET_THERMISTOR_INFO( \ DT_PHANDLE(sensor_id, thermistor)), \ + .update_temperature = NULL, \ FILL_POWER_GOOD(named_id) }) #define TEMP_RT9490(named_id, sensor_id) \ @@ -237,6 +245,18 @@ const struct temp_sensor_t temp_sensors[] = { DT_FOREACH_CHILD_SEP( BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); +static bool temp_sensor_check_power(const struct temp_sensor_t *sensor) +{ +#if ANY_INST_HAS_POWER_GOOD_PIN + if (sensor->zephyr_info->power_good_dev) { + if (!gpio_pin_get(sensor->zephyr_info->power_good_dev, + sensor->zephyr_info->power_good_pin)) + return false; + } +#endif + return true; +} + int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr) { const struct temp_sensor_t *sensor; @@ -245,15 +265,26 @@ int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr) return EC_ERROR_INVAL; sensor = temp_sensors + id; -#if ANY_INST_HAS_POWER_GOOD_PIN - if (sensor->zephyr_info->power_good_dev) { - if (!gpio_pin_get(sensor->zephyr_info->power_good_dev, - sensor->zephyr_info->power_good_pin)) - return EC_ERROR_NOT_POWERED; - } -#endif + if (!temp_sensor_check_power(sensor)) + return EC_ERROR_NOT_POWERED; return sensor->zephyr_info->read(sensor, temp_ptr); } +void temp_sensors_update(void) +{ + for (int i = 0; i < TEMP_SENSOR_COUNT; i++) { + const struct temp_sensor_t *sensor = temp_sensors + i; + + if (!sensor->zephyr_info->update_temperature) + continue; + + if (!temp_sensor_check_power(sensor)) + continue; + + sensor->zephyr_info->update_temperature(sensor->idx); + } +} +DECLARE_HOOK(HOOK_SECOND, temp_sensors_update, HOOK_PRIO_TEMP_SENSOR); + #endif /* DT_HAS_COMPAT_STATUS_OKAY(TEMP_SENSORS_COMPAT) */ -- cgit v1.2.1 From 179bac9981993903db96e14464cb92ef7ce4cfe6 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 11 Nov 2022 15:43:53 +0000 Subject: zephyr: Kconfig: default EEPROM_SHELL to n Pretty much every project disables it explicitly, presumably to save flash. Flip the default to 'n' for the the whole project, delete all the explicit options. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Ia55c2d1625ff2a571a41947db25b0041bc055da0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023449 Code-Coverage: Zoss Reviewed-by: Al Semjonovs --- zephyr/Kconfig.defaults | 3 +++ zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/prj.conf | 1 - zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 1 - zephyr/program/intelrvp/adlrvp/prj.conf | 1 - zephyr/program/intelrvp/mtlrvp/prj.conf | 1 - zephyr/program/nissa/program.conf | 1 - zephyr/program/rex/prj.conf | 1 - zephyr/program/skyrim/prj.conf | 1 - zephyr/test/kingler/prj.conf | 1 - 10 files changed, 3 insertions(+), 9 deletions(-) diff --git a/zephyr/Kconfig.defaults b/zephyr/Kconfig.defaults index 8f82d1c3dc..dd980600fa 100644 --- a/zephyr/Kconfig.defaults +++ b/zephyr/Kconfig.defaults @@ -37,4 +37,7 @@ config SHELL_THREAD_PRIORITY config EXTRA_EXCEPTION_INFO default y if ARCH_HAS_EXTRA_EXCEPTION_INFO +config EEPROM_SHELL + default n + orsource "Kconfig.defaults-$(ARCH)" diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 08298d635c..4a9d09ecf4 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -27,7 +27,6 @@ CONFIG_ARM_MPU=y # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y # eSPI diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf index 5b0997bf73..cb4ed7a3ef 100644 --- a/zephyr/program/corsola/prj.conf +++ b/zephyr/program/corsola/prj.conf @@ -28,7 +28,6 @@ CONFIG_SHELL_TAB_AUTOCOMPLETION=y # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y # Keyboard diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf index dee4b425b0..bca7262642 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf @@ -53,7 +53,6 @@ CONFIG_PLATFORM_EC_THROTTLE_AP=n ## ADL RVP # CBI CONFIG_EEPROM=n -CONFIG_EEPROM_SHELL=n # LED CONFIG_PLATFORM_EC_LED_COMMON=n diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index 13e832d7a8..bec08a6101 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -17,7 +17,6 @@ CONFIG_PLATFORM_EC_USB_CHARGER=n # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_SHELL=n # Charger CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index 28e8298658..ffa083fb00 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -14,7 +14,6 @@ CONFIG_PLATFORM_EC_BATTERY_V2=y # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index d036141f8d..a3cbe768e4 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -80,7 +80,6 @@ CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY=y # CBI EEPROM support CONFIG_EEPROM=y -CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y # PWM support diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 0b396ef498..992e197136 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -68,7 +68,6 @@ CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y # CBI EEPROM support CONFIG_EEPROM=y -CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index dec5a152a8..4ae8c011d7 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -29,7 +29,6 @@ CONFIG_PLATFORM_EC_POWER_BUTTON=y # CBI CONFIG_EEPROM=y -CONFIG_EEPROM_SHELL=n CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y # Temperature Sensors diff --git a/zephyr/test/kingler/prj.conf b/zephyr/test/kingler/prj.conf index 769710651a..c8ef8e4304 100644 --- a/zephyr/test/kingler/prj.conf +++ b/zephyr/test/kingler/prj.conf @@ -24,4 +24,3 @@ CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y CONFIG_EEPROM=y CONFIG_EEPROM_SIMULATOR=n CONFIG_EMUL_EEPROM_AT2X=y -CONFIG_EEPROM_SHELL=n -- cgit v1.2.1 From 920814f8c6a1e879ae32e05733541176cb8cd116 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 11 Nov 2022 16:01:48 +0000 Subject: zephyr: prj.conf: drop explicit CONFIG_GPIO_NCT38XX=y These are not needed, they are set automatically when a corresponding device is enabled in the devicetree. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I460c45076991b744cb55f797587ae089ad60d8c9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023450 Reviewed-by: Sam Hurst Code-Coverage: Zoss --- zephyr/program/brya/prj.conf | 3 --- zephyr/program/intelrvp/mtlrvp/prj.conf | 1 - zephyr/program/rex/prj.conf | 3 --- zephyr/program/skyrim/prj.conf | 3 --- 4 files changed, 10 deletions(-) diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 4a9d09ecf4..5e1fe1dc25 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -169,9 +169,6 @@ CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR=5 CONFIG_PWM=y CONFIG_PWM_SHELL=n -#IOEX -CONFIG_GPIO_NCT38XX=y - # TODO(b/188605676): bring these features up CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index ffa083fb00..c4b96eb11b 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -31,7 +31,6 @@ CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y # IOEX CONFIG_PLATFORM_EC_IOEX_CCGXXF=y CONFIG_GPIO_PCA95XX=y -CONFIG_GPIO_NCT38XX=y CONFIG_PLATFORM_EC_IOEX_IT8801=y #Keyboard from I/O expander diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 992e197136..c9bb1b8de2 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -117,9 +117,6 @@ CONFIG_PLATFORM_EC_USB_PD_USB4=y CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y CONFIG_PLATFORM_EC_USB_PID=0x504D -# IOEX -CONFIG_GPIO_NCT38XX=y - # BC 1.2 CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 4ae8c011d7..8e01b03c83 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -114,9 +114,6 @@ CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y # Give ourselves enough task space to use i2ctrace CONFIG_TASK_PD_STACK_SIZE=1280 -# IOEX -CONFIG_GPIO_NCT38XX=y - # Motion sense CONFIG_PLATFORM_EC_MOTIONSENSE=y CONFIG_PLATFORM_EC_ACCEL_FIFO=y -- cgit v1.2.1 From 28ea7337f0f2d0e0d63398d17c31b42b75ef162a Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 11 Nov 2022 16:08:01 +0000 Subject: zephyr: prj.conf: drop explicit CONFIG_GPIO_PCA95xx=y These are not needed, they are set automatically when a corresponding device is enabled in the devicetree. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I74d81e02a99267ad75a6e089b9f255d9306f4d2c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023451 Reviewed-by: Keith Short Code-Coverage: Zoss --- zephyr/program/intelrvp/adlrvp/prj.conf | 1 - zephyr/program/intelrvp/mtlrvp/prj.conf | 1 - 2 files changed, 2 deletions(-) diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index bec08a6101..c2d4425d73 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -62,7 +62,6 @@ CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y # IOEX CONFIG_PLATFORM_EC_IOEX_PCA9675=y -CONFIG_GPIO_PCA95XX=y # 7-Segment Display CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index c4b96eb11b..de1b8e71a5 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -30,7 +30,6 @@ CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y # IOEX CONFIG_PLATFORM_EC_IOEX_CCGXXF=y -CONFIG_GPIO_PCA95XX=y CONFIG_PLATFORM_EC_IOEX_IT8801=y #Keyboard from I/O expander -- cgit v1.2.1 From 4d2ab5dff72ff1f1d0322915450809723336c552 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Fri, 11 Nov 2022 16:18:20 +0000 Subject: zephyr: prj.conf: drop explicit CONFIG_TACH_NPCX=y These are not needed, they are set automatically when a corresponding device is enabled in the devicetree. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I79f63504723fb911e834eb2ed509580b69079744 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023452 Reviewed-by: Tristan Honscheid Code-Coverage: Zoss --- zephyr/program/brya/prj.conf | 3 --- zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf | 3 --- zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf | 3 --- zephyr/program/nissa/npcx_program.conf | 1 - zephyr/program/rex/prj.conf | 3 --- zephyr/program/skyrim/prj.conf | 3 --- 6 files changed, 16 deletions(-) diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 5e1fe1dc25..afb3469055 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -71,9 +71,6 @@ CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y CONFIG_PLATFORM_EC_ALS_TCS3400=y -# Fan -CONFIG_TACH_NPCX=y - # Temperature sensors CONFIG_PLATFORM_EC_TEMP_SENSOR=y CONFIG_PLATFORM_EC_THERMISTOR=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf index e6063b953c..f279e669ad 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf @@ -9,9 +9,6 @@ CONFIG_SYSCON=y # Charger CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y -# FAN -CONFIG_TACH_NPCX=y - # PWM CONFIG_PWM=y CONFIG_PWM_SHELL=n diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf index 162c6c24dc..585b0fcc11 100644 --- a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf @@ -10,8 +10,5 @@ CONFIG_SYSCON=y CONFIG_PWM=y CONFIG_PWM_SHELL=n -# Fan -CONFIG_TACH_NPCX=y - #RTC CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/program/nissa/npcx_program.conf b/zephyr/program/nissa/npcx_program.conf index 4995f0e809..83ee245a8d 100644 --- a/zephyr/program/nissa/npcx_program.conf +++ b/zephyr/program/nissa/npcx_program.conf @@ -7,7 +7,6 @@ CONFIG_CROS_SYSTEM_NPCX=y CONFIG_SOC_SERIES_NPCX9=y CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y CONFIG_SYSCON=y -CONFIG_TACH_NPCX=y CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=256 # Common sensor drivers diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index c9bb1b8de2..227a415095 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -57,9 +57,6 @@ CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y # PWM CONFIG_PWM=y -# Fan -CONFIG_TACH_NPCX=y - # Temperature sensors CONFIG_SENSOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 8e01b03c83..3d9b650b43 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -49,9 +49,6 @@ CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y CONFIG_SENSOR=y CONFIG_SENSOR_SHELL=n -# Fan -CONFIG_TACH_NPCX=y - # Lid switch CONFIG_PLATFORM_EC_LID_ANGLE=y CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -- cgit v1.2.1 From fb129db3e4b209beb30dac5c699ebe4d9fea5bfa Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 09:56:43 -0800 Subject: board/[kappa|terrador]: Fix compilation error When building with clang, it fails: board/kappa/led.c:132:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] default: ^ board/terrador/board.c:304:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough] default: ^ BRANCH=none BUG=b:253644823 TEST=CC=clang make BOARD=terrador TEST=CC=clang make BOARD=kappa Signed-off-by: Tom Hughes Change-Id: I2d343d5fd99c958194af09ec51d9800a15b170f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024037 Code-Coverage: Zoss Reviewed-by: Peter Marheine --- board/kappa/led.c | 1 + board/terrador/board.c | 1 + 2 files changed, 2 insertions(+) diff --git a/board/kappa/led.c b/board/kappa/led.c index 1dc86013d7..d9ecb33da0 100644 --- a/board/kappa/led.c +++ b/board/kappa/led.c @@ -129,6 +129,7 @@ static void led_set_battery(void) case PWR_STATE_FORCED_IDLE: led_set_color_battery((battery_ticks & 0x2) ? LED_AMBER : LED_OFF); + break; default: /* Other states don't alter LED behavior */ break; diff --git a/board/terrador/board.c b/board/terrador/board.c index 8426216e79..3724c9d2d0 100644 --- a/board/terrador/board.c +++ b/board/terrador/board.c @@ -301,6 +301,7 @@ void ppc_interrupt(enum gpio_signal signal) break; case GPIO_USB_C1_PPC_INT_ODL: syv682x_interrupt(USBC_PORT_C1); + break; default: break; } -- cgit v1.2.1 From 58639e4e45ecc051d8a7e0b0ed35079dc6f3f57e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 16:26:42 -0800 Subject: board/adlrvpp_mchp1521: Free up more flash space BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=adlrvpp_mchp1521 Signed-off-by: Tom Hughes Change-Id: Ie8f3b6cbcea758352ab38591d26d831d77b1084d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024569 Reviewed-by: Peter Marheine Code-Coverage: Zoss --- board/adlrvpp_mchp1521/board.h | 3 +++ util/build_with_clang.py | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/board/adlrvpp_mchp1521/board.h b/board/adlrvpp_mchp1521/board.h index bcd46acf25..645bfc0598 100644 --- a/board/adlrvpp_mchp1521/board.h +++ b/board/adlrvpp_mchp1521/board.h @@ -140,6 +140,9 @@ /* Use internal silicon 32KHz oscillator */ #undef CONFIG_CLOCK_SRC_EXTERNAL +/* Free up flash space. */ +#undef CONFIG_CONSOLE_CMDHELP + #ifndef __ASSEMBLER__ enum adlrvp_i2c_channel { diff --git a/util/build_with_clang.py b/util/build_with_clang.py index fc254e7398..85fad1ec5e 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -78,6 +78,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "zinger", # Boards that use CHIP:=mchp # git grep --name-only 'CHIP:=mchp' | sed 's#board/\(.*\)/build.mk#"\1",#' + "adlrvpp_mchp1521", "adlrvpp_mchp1727", "mchpevb1", "reef_mchp", @@ -290,9 +291,6 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ "oak", # overflows flash "stern", # overflows flash "willow", # overflows flash - # Boards that use CHIP:=mchp - # git grep --name-only 'CHIP:=mchp' | sed 's#board/\(.*\)/build.mk#"\1",#' - "adlrvpp_mchp1521", # overflows flash # Boards that use CHIP:=npcx "garg", # overflows flash "gelarshie", # overflows flash -- cgit v1.2.1 From 2a4220494a8711f9f7e921b1513fcfae436fbed7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 16:50:21 -0800 Subject: board/oak: Free up more flash space BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=oak Signed-off-by: Tom Hughes Change-Id: I234151d4b77bc27e9293a64fa02433370f0c7654 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024570 Code-Coverage: Zoss Reviewed-by: Paul Fagerburg --- board/oak/board.h | 1 + util/build_with_clang.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/board/oak/board.h b/board/oak/board.h index 6b40f812fd..e40e16bccf 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -14,6 +14,7 @@ /* Free up some flash space */ #define CONFIG_DEBUG_ASSERT_BRIEF #define CONFIG_USB_PD_DEBUG_LEVEL 0 +#undef CONFIG_CONSOLE_CMDHELP #define CONFIG_LTO diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 85fad1ec5e..11c540c77d 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -61,6 +61,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "minimuffin", "moonball", "nucleo-f072rb", + "oak", "pdeval-stm32f072", "plankton", "prism", @@ -288,7 +289,6 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ "krane", # overflows flash "kukui", # overflows flash "makomo", # overflows flash - "oak", # overflows flash "stern", # overflows flash "willow", # overflows flash # Boards that use CHIP:=npcx -- cgit v1.2.1 From b4de9e1b973f932538ff3e12d05a9d0bb90b59cc Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 09:55:39 -0800 Subject: baseboard/kukui: Free up additional flash space BRANCH=none BUG=b:172020503, b:256193799 TEST=make buildall Signed-off-by: Tom Hughes Change-Id: I746815d69bbdab3dd95ba69f47d4c1f7494fe642 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024040 Reviewed-by: Eric Yilun Lin Code-Coverage: Zoss --- baseboard/kukui/baseboard.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h index d2985faea5..9afc726861 100644 --- a/baseboard/kukui/baseboard.h +++ b/baseboard/kukui/baseboard.h @@ -286,6 +286,7 @@ #define CONFIG_USB_PD_VBUS_DETECT_TCPC /* Modules we want to exclude */ +#undef CONFIG_ACCEL_SPOOF_MODE #undef CONFIG_CMD_ACCELSPOOF #undef CONFIG_CMD_BATTFAKE #undef CONFIG_CMD_FLASH @@ -310,14 +311,19 @@ #undef CONFIG_CMD_CRASH #undef CONFIG_CMD_HCDEBUG #undef CONFIG_CMD_IDLE_STATS +#undef CONFIG_CMD_KEYBOARD #undef CONFIG_CMD_MFALLOW #undef CONFIG_CMD_MMAPINFO +#undef CONFIG_CMD_PD +#undef CONFIG_CMD_POWER_AP #undef CONFIG_CMD_PWR_AVG #undef CONFIG_CMD_REGULATOR #undef CONFIG_CMD_RW #undef CONFIG_CMD_SLEEPMASK #undef CONFIG_CMD_SLEEPMASK_SET +#undef CONFIG_CMD_SYSINFO #undef CONFIG_CMD_TYPEC +#undef CONFIG_CMD_WAITMS #undef CONFIG_HOSTCMD_FLASHPD #undef CONFIG_HOSTCMD_RWHASHPD -- cgit v1.2.1 From 4d7c3314bc52fc9534cf124927296f037236e370 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 13:21:02 -0800 Subject: board/waddledoo: Free up flash space BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=waddledoo Signed-off-by: Tom Hughes Change-Id: I8b088e83c95c3874c461c3efe34345399f5074c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024562 Reviewed-by: Diana Z Code-Coverage: Zoss --- board/waddledoo/board.h | 4 +++- util/build_with_clang.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/board/waddledoo/board.h b/board/waddledoo/board.h index 727f1bdb33..c13dbe37c9 100644 --- a/board/waddledoo/board.h +++ b/board/waddledoo/board.h @@ -18,10 +18,12 @@ #define CONFIG_SYSTEM_UNLOCKED /* Save some flash space */ +#undef CONFIG_ACCEL_SPOOF_MODE #define CONFIG_CHIP_INIT_ROM_REGION #undef CONFIG_CONSOLE_CMDHELP +#undef CONFIG_CONSOLE_HISTORY #define CONFIG_DEBUG_ASSERT_BRIEF -#define CONFIG_USB_PD_DEBUG_LEVEL 2 +#define CONFIG_USB_PD_DEBUG_LEVEL 0 /* EC console commands */ #define CONFIG_CMD_CHARGER_DUMP diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 11c540c77d..55f3b54d6c 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -210,6 +210,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "voxel", "voxel_ecmodeentry", "voxel_npcx797fc", + "waddledoo", "waddledoo2", "whiskers", "woomax", @@ -298,7 +299,6 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ "nocturne", # overflows flash "terrador", # overflows flash "volteer", # overflows flash - "waddledoo", # overflows flash ] # TODO(b/201311714): NDS32 is not supported by LLVM. -- cgit v1.2.1 From 5011f4a3fb0937fc393e28b0af30150b62adae78 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 11 Nov 2022 13:23:15 -0700 Subject: cq: Exclude zephyr/main/arch/posix from coverage The code in zephyr/main/arch/posix is essentially test code, since the posix arch is only used for tests. There have been intermittent coverage changes in zephyr/main/arch/posix/posix_core.c BRANCH=None BUG=None TEST=None Signed-off-by: Jeremy Bettis Change-Id: Ib52ad05f81f709f0d95b840095fd2e12798dc9f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4020817 Auto-Submit: Jeremy Bettis Reviewed-by: Aaron Massey Commit-Queue: Aaron Massey Tested-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/firmware_builder.py | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py index 7973a9d74c..edcbfc58ef 100755 --- a/zephyr/firmware_builder.py +++ b/zephyr/firmware_builder.py @@ -390,6 +390,7 @@ def test(opts): zephyr_dir / "emul/**", zephyr_dir / "mock/**", third_party / "zephyr/main/subsys/emul/**", + third_party / "zephyr/main/arch/posix/**", # Exclude all files ending in _test.[ch] or _emul.[ch] "**/*_test.c", "**/*_test.h", -- cgit v1.2.1 From f9d615394061964989e92dc6ed0f5124a9f4d2f1 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Fri, 11 Nov 2022 12:15:13 -0700 Subject: test: pi3usb9201 driver shim Verify that the shim layer of the pi3usb9201 handles GPIO callbacks. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I19f7d48f3f2d7e066e952caa35b857d564535d47 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4018195 Code-Coverage: Zoss Reviewed-by: Abe Levkoy Reviewed-by: Keith Short Commit-Queue: Keith Short --- zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/Kconfig | 3 + zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt | 5 + zephyr/test/drivers/bc12_pi3usb9201/src/main.c | 119 +++++++++++++++++++++ zephyr/test/drivers/boards/native_posix.overlay | 20 +++- zephyr/test/drivers/testcase.yaml | 3 + 6 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt create mode 100644 zephyr/test/drivers/bc12_pi3usb9201/src/main.c diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index e5b39fde6b..dd8ab61b59 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -49,6 +49,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS locate_chip) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON button) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_CONSOLE console) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_CMD_THREAD host_command_thread) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_PI3USB9201 bc12_pi3usb9201) get_target_property(TEST_SOURCES_NEW app SOURCES) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index 21f18db9ef..496bfd2ac0 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -123,4 +123,7 @@ config LINK_TEST_SUITE_CONSOLE config LINK_TEST_SUITE_HOST_CMD_THREAD bool "Link and test the host command thread override tests" +config LINK_TEST_SUITE_PI3USB9201 + bool "Link and test the pi3usb9201 tests" + source "Kconfig.zephyr" diff --git a/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt b/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt new file mode 100644 index 0000000000..842a514e16 --- /dev/null +++ b/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +#Use of this source code is governed by a BSD-style license that can be +#found in the LICENSE file. + +target_sources(app PRIVATE src/main.c) diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/main.c b/zephyr/test/drivers/bc12_pi3usb9201/src/main.c new file mode 100644 index 0000000000..b2c69c712a --- /dev/null +++ b/zephyr/test/drivers/bc12_pi3usb9201/src/main.c @@ -0,0 +1,119 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include + +#include "gpio_signal.h" +#include "task.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include "usb_charge.h" + +/* Get reference to externally linked handlers (defined in DTS) */ +#define USBC0_GPIO_PATH DT_PATH(named_gpios, usb_c0_bc12_int_l) +#define USBC0_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC0_GPIO_PATH, gpios)) +#define USBC0_GPIO_PORT DT_GPIO_PIN(USBC0_GPIO_PATH, gpios) + +#define USBC1_GPIO_PATH DT_PATH(named_gpios, usb_c1_bc12_int_l) +#define USBC1_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC1_GPIO_PATH, gpios)) +#define USBC1_GPIO_PORT DT_GPIO_PIN(USBC1_GPIO_PATH, gpios) + +static void toggle_gpio(const struct device *dev, gpio_pin_t pin) +{ + static const int values[] = { 1, 0, 1 }; + + for (int i = 0; i < ARRAY_SIZE(values); ++i) { + gpio_emul_input_set(dev, pin, values[i]); + } +} + +FAKE_VOID_FUNC(usb_charger_task_event, int, uint32_t); + +struct pi3usb9201_fixture { + const struct bc12_drv *drv[2]; + struct bc12_drv mock_drv; +}; + +static void *setup(void) +{ + static struct pi3usb9201_fixture fixture; + + fixture.mock_drv.usb_charger_task_event = usb_charger_task_event; + + return &fixture; +} + +static void before(void *f) +{ + struct pi3usb9201_fixture *fixture = f; + + fixture->drv[0] = bc12_ports[0].drv; + fixture->drv[1] = bc12_ports[1].drv; + + RESET_FAKE(usb_charger_task_event); + test_set_chipset_to_s0(); +} + +static void after(void *f) +{ + struct pi3usb9201_fixture *fixture = f; + + bc12_ports[0].drv = fixture->drv[0]; + bc12_ports[1].drv = fixture->drv[1]; +} + +ZTEST_SUITE(pi3usb9201, drivers_predicate_post_main, setup, before, after, + NULL); + +ZTEST_F(pi3usb9201, test_usb0_evt) +{ + /* Set up the driver to use the mock */ + bc12_ports[0].drv = &fixture->mock_drv; + + /* Trigger the event and verify that port0 was added to the task event + * bitmap + */ + toggle_gpio(USBC0_GPIO_DEV, USBC0_GPIO_PORT); + zassert_true(*task_get_event_bitmap(TASK_ID_USB_CHG) & BIT(0)); + + /* Give the task a bit of time to process the events */ + task_wake(TASK_ID_USB_CHG); + k_msleep(500); + + /* Ensure that the callback was made (it should be the first, but others + * may exist). + */ + zassert_true(usb_charger_task_event_fake.call_count > 0); + zassert_equal(0, usb_charger_task_event_fake.arg0_history[0]); + zassert_equal(USB_CHG_EVENT_BC12, + usb_charger_task_event_fake.arg1_history[0]); +} + +ZTEST_F(pi3usb9201, test_usb1_evt) +{ + /* Set up the driver to use the mock */ + bc12_ports[1].drv = &fixture->mock_drv; + + /* Trigger the event and verify that port1 was added to the task event + * bitmap + */ + toggle_gpio(USBC1_GPIO_DEV, USBC1_GPIO_PORT); + zassert_true(*task_get_event_bitmap(TASK_ID_USB_CHG) & BIT(1)); + + /* Give the task a bit of time to process the events */ + task_wake(TASK_ID_USB_CHG); + k_msleep(500); + + /* Ensure that the callback was made (it should be the first, but others + * may exist). + */ + zassert_true(usb_charger_task_event_fake.call_count > 0); + zassert_equal(1, usb_charger_task_event_fake.arg0_history[0]); + zassert_equal(USB_CHG_EVENT_BC12, + usb_charger_task_event_fake.arg1_history[0]); +} diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index e244cb39f1..ddf493e35d 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -266,6 +266,12 @@ gpio_ec_cbi_wp: ec_cbi_wp { gpios = <&gpio1 9 GPIO_OUTPUT>; }; + gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l { + gpios = <&gpio1 10 GPIO_INPUT>; + }; + gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { + gpios = <&gpio1 11 GPIO_INPUT>; + }; }; gpio1: gpio@101 { @@ -278,7 +284,7 @@ low-level; gpio-controller; #gpio-cells = <2>; - ngpios = <10>; + ngpios = <12>; }; gpio-interrupts { @@ -334,6 +340,16 @@ flags = ; handler = "switch_interrupt"; }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_l>; + flags = ; + handler = "usb0_evt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_l>; + flags = ; + handler = "usb1_evt"; + }; }; named-i2c-ports { @@ -810,6 +826,7 @@ pi3usb9201_emul0: pi3usb9201@5f { compatible = "pericom,pi3usb9201"; reg = <0x5f>; + irq = <&int_usb_c0_bc12>; }; sn5s330_emul: sn5s330@40 { @@ -837,6 +854,7 @@ pi3usb9201_emul1: pi3usb9201@5d { compatible = "pericom,pi3usb9201"; reg = <0x5d>; + irq = <&int_usb_c1_bc12>; }; syv682x_emul: syv682x@41 { diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index d8a2dc838a..8a68a2af23 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -212,3 +212,6 @@ tests: drivers.host_cmd_thread: extra_configs: - CONFIG_LINK_TEST_SUITE_HOST_CMD_THREAD=y + drivers.pi3usb9201: + extra_configs: + - CONFIG_LINK_TEST_SUITE_PI3USB9201=y -- cgit v1.2.1 From ad9884a51b42b5ac3013132fced17b9e1835edd9 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 14 Nov 2022 11:14:53 -0800 Subject: util: add support for LR and PC in crash reports Some crash reports (E.G: Coral) contain LR and PC valid registers. This CL uses them, when available, to process the PC symbol. BUG=b:259112884 TEST=crash_analyzer.py lite -m coral_113.map -f dumps_coral/ It correctly found the PC for the crashes. BRANCH=none Change-Id: I9d02a090bb4bf37dc18128cdec75e52fecb81fde Signed-off-by: ricardoq@chromium.org Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022249 Code-Coverage: Zoss Reviewed-by: Aseda Aboagye --- util/crash_analyzer.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/util/crash_analyzer.py b/util/crash_analyzer.py index c2e07face2..552ed9c46c 100755 --- a/util/crash_analyzer.py +++ b/util/crash_analyzer.py @@ -124,7 +124,18 @@ def cm0_parse(match) -> dict: regs["ipsr"] = values[22] regs["cause"] = get_crash_cause(values[6]) # r4 - regs["symbol"] = get_symbol(values[7]) # r5 + # Heuristics: try link register, then PC, then what is believed to be PC. + # When analyzing watchdogs, we try to be as close as possible to the caller + # function that caused the watchdog. + # That's why we prioritize LR (return address) over PC. + if regs["lr"] != -1: + regs["symbol"] = get_symbol(regs["lr"]) + elif regs["pc"] != -1: + regs["symbol"] = get_symbol(regs["pc"]) + else: + # Otherwise, if both LR and PC are empty, most probably + # PC is in R5. + regs["symbol"] = get_symbol(values[7]) # r5 return regs -- cgit v1.2.1 From e0c1fdf11777e198a4f08461eadcb3c8b09c50a6 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 12:37:54 -0700 Subject: ec: IWYU Add some missing includes There are a few headers here that don't include the stdint or stdbool headers, but use the int or bool types defined there. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: Idbf7e4d0c5182821fbc9fe9fb60690b12701bf75 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022252 Commit-Queue: Simon Glass Auto-Submit: Jeremy Bettis Reviewed-by: Simon Glass Tested-by: Jeremy Bettis Code-Coverage: Zoss --- include/crc8.h | 2 ++ include/driver/temp_sensor/thermistor.h | 2 ++ include/event_log.h | 2 ++ zephyr/program/herobrine/include/board_chipset.h | 2 ++ zephyr/test/ap_power/include/test_mocks.h | 2 ++ zephyr/test/ap_power/include/test_state.h | 2 ++ zephyr/test/drivers/common/include/test/drivers/test_mocks.h | 2 ++ zephyr/test/drivers/common/include/test/drivers/test_state.h | 2 ++ 8 files changed, 16 insertions(+) diff --git a/include/crc8.h b/include/crc8.h index c20314311e..ca1a98eb43 100644 --- a/include/crc8.h +++ b/include/crc8.h @@ -7,6 +7,8 @@ #ifndef __CROS_EC_CRC8_H #define __CROS_EC_CRC8_H +#include + /** * crc8 * Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. A table-based diff --git a/include/driver/temp_sensor/thermistor.h b/include/driver/temp_sensor/thermistor.h index 46b7763747..3e220b2505 100644 --- a/include/driver/temp_sensor/thermistor.h +++ b/include/driver/temp_sensor/thermistor.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_TEMP_SENSOR_THERMISTOR_H #define __CROS_EC_TEMP_SENSOR_THERMISTOR_H +#include + struct thermistor_data_pair { uint8_t mv; /* Scaled voltage level at ADC (in mV) */ uint8_t temp; /* Temperature in Celsius */ diff --git a/include/event_log.h b/include/event_log.h index bd3b88510b..5438a34414 100644 --- a/include/event_log.h +++ b/include/event_log.h @@ -6,6 +6,8 @@ #ifndef __CROS_EC_EVENT_LOG_H #define __CROS_EC_EVENT_LOG_H +#include + struct event_log_entry { uint32_t timestamp; /* relative timestamp in milliseconds */ uint8_t type; /* event type, caller-defined */ diff --git a/zephyr/program/herobrine/include/board_chipset.h b/zephyr/program/herobrine/include/board_chipset.h index 81c0dd1a40..000bc06654 100644 --- a/zephyr/program/herobrine/include/board_chipset.h +++ b/zephyr/program/herobrine/include/board_chipset.h @@ -6,6 +6,8 @@ #ifndef __CROS_EC_HEROBRINE_BOARD_CHIPSET_H #define __CROS_EC_HEROBRINE_BOARD_CHIPSET_H +#include "common.h" + __test_only void reset_pp5000_inited(void); #endif /* __CROS_EC_HEROBRINE_BOARD_CHIPSET_H */ diff --git a/zephyr/test/ap_power/include/test_mocks.h b/zephyr/test/ap_power/include/test_mocks.h index 8e9c80ad43..05e1d823e0 100644 --- a/zephyr/test/ap_power/include/test_mocks.h +++ b/zephyr/test/ap_power/include/test_mocks.h @@ -6,6 +6,8 @@ #ifndef __TEST_AP_POWER_TEST_MOCKS_H #define __TEST_AP_POWER_TEST_MOCKS_H +#include + #include /* diff --git a/zephyr/test/ap_power/include/test_state.h b/zephyr/test/ap_power/include/test_state.h index cb91f2b7c7..2a7fbe822d 100644 --- a/zephyr/test/ap_power/include/test_state.h +++ b/zephyr/test/ap_power/include/test_state.h @@ -6,6 +6,8 @@ #ifndef ZEPHYR_TEST_AP_POWER_INCLUDE_TEST_STATE_H_ #define ZEPHYR_TEST_AP_POWER_INCLUDE_TEST_STATE_H_ +#include + struct test_state { bool ec_app_main_run; }; diff --git a/zephyr/test/drivers/common/include/test/drivers/test_mocks.h b/zephyr/test/drivers/common/include/test/drivers/test_mocks.h index 25217dfffe..da5ac02697 100644 --- a/zephyr/test/drivers/common/include/test/drivers/test_mocks.h +++ b/zephyr/test/drivers/common/include/test/drivers/test_mocks.h @@ -6,6 +6,8 @@ #ifndef __TEST_DRIVERS_TEST_MOCKS_H #define __TEST_DRIVERS_TEST_MOCKS_H +#include + #include /* diff --git a/zephyr/test/drivers/common/include/test/drivers/test_state.h b/zephyr/test/drivers/common/include/test/drivers/test_state.h index 98cf4a283e..b4496c6af9 100644 --- a/zephyr/test/drivers/common/include/test/drivers/test_state.h +++ b/zephyr/test/drivers/common/include/test/drivers/test_state.h @@ -6,6 +6,8 @@ #ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_ #define ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_ +#include + #ifdef __cplusplus extern "C" { #endif -- cgit v1.2.1 From fb5608cc9342c8e31a5f44ca980ae6324f5ce43a Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Sun, 13 Nov 2022 22:53:37 -0700 Subject: gpio: optimize the gpio_set_flags_by_mask loop Make use of __builtin_ctz in order to loop through 'flags' instead of checking each bit one by one. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: If202aa650326f52927effca9bd2f685bcb869ff0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025331 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/shim/src/gpio.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c index c21a46c365..08f6d48742 100644 --- a/zephyr/shim/src/gpio.c +++ b/zephyr/shim/src/gpio.c @@ -339,12 +339,17 @@ void gpio_set_flags(enum gpio_signal signal, int flags) void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags) { - int pin; + const gpio_flags_t zephyr_flags = convert_to_zephyr_flags(flags); - for (pin = 0; pin < 8; pin++) - if (mask & BIT(pin)) - gpio_configure_port_pin(port, pin, - convert_to_zephyr_flags(flags)); + /* Using __builtin_ctz here will guarantee that this loop is as + * performant as the underlying architecture allows it to be. + */ + while (mask != 0) { + int pin = __builtin_ctz(mask); + + gpio_configure_port_pin(port, pin, zephyr_flags); + mask &= ~BIT(pin); + } } int signal_is_gpio(int signal) -- cgit v1.2.1 From f9edd2d91acd4517fdb90ea3d81d03f5c13d1e51 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Mon, 14 Nov 2022 10:46:14 -0700 Subject: test: cover missing accessors and init in gpio shim Add tests for the following: - init with custom unused pins handler that fails - calls to gpio_or_ioex_get_level() which wrap gpio_get_level() - calls to gpio_reset_port which resets the entire struct device * - calls to setting the GPIO flags using a mask. Note, tests needed to move to 'pre_main' since they now mess with initialization. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: Ia08bc4a810874eeaf9fff0075e83ef689550d9dd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026563 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/shim/src/gpio.c | 8 ++- zephyr/test/drivers/boards/native_posix.overlay | 1 + .../common/include/test/drivers/test_mocks.h | 4 ++ zephyr/test/drivers/common/src/test_mocks.c | 6 ++ zephyr/test/drivers/default/src/gpio.c | 71 +++++++++++++++++++++- 5 files changed, 87 insertions(+), 3 deletions(-) diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c index 08f6d48742..d3aff5acb6 100644 --- a/zephyr/shim/src/gpio.c +++ b/zephyr/shim/src/gpio.c @@ -255,7 +255,10 @@ const struct gpio_dt_spec *gpio_get_dt_spec(enum gpio_signal signal) return &configs[signal].spec; } -static int init_gpios(const struct device *unused) +/* Allow access to this function in tests so we can run it multiple times + * without having to create a new binary for each run. + */ +test_export_static int init_gpios(const struct device *unused) { gpio_flags_t flags; bool is_sys_jumped = system_jumped_to_this_image(); @@ -322,9 +325,10 @@ void gpio_reset(enum gpio_signal signal) void gpio_reset_port(const struct device *port) { for (size_t i = 0; i < ARRAY_SIZE(configs); ++i) { - if (port == configs[i].spec.port) + if (port == configs[i].spec.port) { gpio_pin_configure_dt(&configs[i].spec, configs[i].init_flags); + } } } diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index ddf493e35d..f56eec97c6 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -212,6 +212,7 @@ }; gpio_test: test { gpios = <&gpio0 27 (GPIO_INPUT | GPIO_OUTPUT)>; + enum-name = "GPIO_TEST"; }; ec_batt_pres_odl { gpios = <&gpio0 28 GPIO_INPUT>; diff --git a/zephyr/test/drivers/common/include/test/drivers/test_mocks.h b/zephyr/test/drivers/common/include/test/drivers/test_mocks.h index da5ac02697..6644de8d88 100644 --- a/zephyr/test/drivers/common/include/test/drivers/test_mocks.h +++ b/zephyr/test/drivers/common/include/test/drivers/test_mocks.h @@ -118,4 +118,8 @@ DECLARE_FAKE_VOID_FUNC(assert_post_action, const char *, unsigned int); /* Mocks for common/lid_angle.c */ DECLARE_FAKE_VOID_FUNC(lid_angle_peripheral_enable, int); +/* Mocks for gpio.h */ +DECLARE_FAKE_VALUE_FUNC(int, gpio_config_unused_pins); +DECLARE_FAKE_VALUE_FUNC(int, gpio_configure_port_pin, int, int, int); + #endif /* __TEST_DRIVERS_TEST_MOCKS_H */ diff --git a/zephyr/test/drivers/common/src/test_mocks.c b/zephyr/test/drivers/common/src/test_mocks.c index ab6c65313d..76f66662cb 100644 --- a/zephyr/test/drivers/common/src/test_mocks.c +++ b/zephyr/test/drivers/common/src/test_mocks.c @@ -22,6 +22,10 @@ DEFINE_FAKE_VOID_FUNC(assert_post_action, const char *, unsigned int); /* Mocks for common/lid_angle.c */ DEFINE_FAKE_VOID_FUNC(lid_angle_peripheral_enable, int); +/* Mocks for gpio.h */ +DEFINE_FAKE_VALUE_FUNC(int, gpio_config_unused_pins); +DEFINE_FAKE_VALUE_FUNC(int, gpio_configure_port_pin, int, int, int); + /** * @brief Reset all the fakes before each test. */ @@ -40,6 +44,8 @@ static void fff_reset_rule_before(const struct ztest_unit_test *test, RESET_FAKE(software_panic); RESET_FAKE(assert_post_action); RESET_FAKE(lid_angle_peripheral_enable); + RESET_FAKE(gpio_config_unused_pins); + RESET_FAKE(gpio_configure_port_pin); } ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL); diff --git a/zephyr/test/drivers/default/src/gpio.c b/zephyr/test/drivers/default/src/gpio.c index 3dd62aaa05..9950edd84c 100644 --- a/zephyr/test/drivers/default/src/gpio.c +++ b/zephyr/test/drivers/default/src/gpio.c @@ -22,9 +22,14 @@ #include "gpio/gpio_int.h" #include "test/drivers/stubs.h" #include "util.h" +#include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" extern bool gpio_test_interrupt_triggered; + +/* Function signature for shim/src/gpio.c test_export_static */ +int init_gpios(const struct device *unused); + /** * @brief TestPurpose: Verify Zephyr to EC GPIO bitmask conversion. * @@ -135,14 +140,22 @@ ZTEST(gpio, test_legacy_gpio_get_set_level) { enum gpio_signal signal = GPIO_SIGNAL(DT_NODELABEL(gpio_test)); int level; + /* Test invalid signal */ gpio_set_level(GPIO_COUNT, 0); zassert_equal(0, gpio_get_level(GPIO_COUNT), "Expected level==0"); + /* Test valid signal */ gpio_set_level(signal, 0); + zassert_ok(gpio_or_ioex_get_level(signal, &level)); zassert_equal(0, gpio_get_level(signal), "Expected level==0"); + zassert_equal(0, level); + gpio_set_level(signal, 1); + zassert_ok(gpio_or_ioex_get_level(signal, &level)); zassert_equal(1, gpio_get_level(signal), "Expected level==1"); + zassert_equal(1, level); + level = gpio_get_ternary(signal); gpio_set_level_verbose(CC_CHIPSET, signal, 0); zassert_equal(0, gpio_get_level(signal), "Expected level==0"); @@ -369,6 +382,62 @@ ZTEST(gpio, test_gpio_reset) flags); } +ZTEST(gpio, test_gpio_reset_port) +{ + const struct device *port = + DEVICE_DT_GET(DT_GPIO_CTLR(DT_NODELABEL(gpio_test), gpios)); + enum gpio_signal signal = GPIO_SIGNAL(DT_NODELABEL(gpio_test)); + gpio_flags_t flags; + gpio_flags_t flags_at_start[GPIO_COUNT]; + + /* Snapshot of GPIO flags before testing */ + for (int i = 0; i < GPIO_COUNT; i++) + flags_at_start[i] = gpio_helper_get_flags(i); + + /* Test reset on invalid signal */ + gpio_reset_port(NULL); + + /* Verify flags didn't change */ + for (int i = 0; i < GPIO_COUNT; i++) { + flags = gpio_helper_get_flags(i); + zassert_equal(flags_at_start[i], flags, + "%s[%d] flags_at_start=0x%x, flags=0x%x", + gpio_get_name(i), i, flags_at_start[i], flags); + } + + /* Test reset on valid signal */ + gpio_set_flags(signal, GPIO_OUTPUT); + flags = gpio_helper_get_flags(signal); + zassert_equal(flags, GPIO_OUTPUT, "Flags set 0x%x", flags); + + gpio_reset_port(port); + + flags = gpio_helper_get_flags(signal); + zassert_equal(flags, gpio_get_default_flags(signal), "Flags set 0x%x", + flags); + + for (int i = 0; i < GPIO_COUNT; ++i) { + gpio_set_flags(i, flags_at_start[i]); + } +} + +ZTEST(gpio, test_gpio_set_flags_by_mask) +{ + gpio_set_flags_by_mask(0, BIT(27), GPIO_OUTPUT); + zassert_equal(gpio_configure_port_pin_fake.call_count, 1); + zassert_equal(gpio_configure_port_pin_fake.arg0_val, 0); + zassert_equal(gpio_configure_port_pin_fake.arg1_val, 27); + zassert_equal(gpio_configure_port_pin_fake.arg2_val, + convert_to_zephyr_flags(GPIO_OUTPUT)); +} + +ZTEST(gpio, test_init_gpios_fail_on_unused_pins_custom_func) +{ + gpio_config_unused_pins_fake.return_val = -1; + + zassert_equal(-1, init_gpios(NULL)); +} + /** * @brief TestPurpose: Verify GPIO enable/disable interrupt. * @@ -418,4 +487,4 @@ static void gpio_before(void *state) /** * @brief Test Suite: Verifies GPIO functionality. */ -ZTEST_SUITE(gpio, drivers_predicate_post_main, NULL, gpio_before, NULL, NULL); +ZTEST_SUITE(gpio, drivers_predicate_pre_main, NULL, gpio_before, NULL, NULL); -- cgit v1.2.1 From b6716df9c14ad71f3b49b7e05d20bce5c851850b Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Sun, 13 Nov 2022 23:28:45 -0700 Subject: test: switchcap power off delay Add 1ms power off delay to the switchcap and verify all the tests still pass. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I5649e0b2559b3ae542ee6e4718361a326055c5c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025332 Reviewed-by: Tomasz Michalec Code-Coverage: Zoss --- zephyr/test/qcom_power/boards/native_posix.overlay | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/test/qcom_power/boards/native_posix.overlay b/zephyr/test/qcom_power/boards/native_posix.overlay index 802721f430..be0db668ea 100644 --- a/zephyr/test/qcom_power/boards/native_posix.overlay +++ b/zephyr/test/qcom_power/boards/native_posix.overlay @@ -143,6 +143,7 @@ compatible = "switchcap-gpio"; enable-pin = <&gpio_switchcap_on>; power-good-pin = <&gpio_switchcap_pg>; + poff-delay-ms = <1>; }; }; -- cgit v1.2.1 From 9e7107aeb41834a2d40f845f5644cf9c48fc3d1e Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Mon, 14 Nov 2022 01:25:29 -0700 Subject: test: system shim Add tests for all error conditions that can be emulated at runtime for system.c's shim layer. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: Id90dbe0c046e379f5bee5fe958a58e0928cfd157 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025333 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- zephyr/shim/src/system.c | 2 +- zephyr/test/system_shim/CMakeLists.txt | 15 +- .../test/system_shim/boards/native_posix.overlay | 5 +- zephyr/test/system_shim/default.overlay | 12 + zephyr/test/system_shim/include/fakes.h | 29 ++ zephyr/test/system_shim/prj.conf | 12 + zephyr/test/system_shim/src/no_chosen.c | 24 ++ zephyr/test/system_shim/src/suite.c | 50 ++++ zephyr/test/system_shim/src/test_system.c | 298 +++++++++++++++++++++ zephyr/test/system_shim/test_system.c | 257 ------------------ zephyr/test/system_shim/testcase.yaml | 15 +- 11 files changed, 444 insertions(+), 275 deletions(-) create mode 100644 zephyr/test/system_shim/default.overlay create mode 100644 zephyr/test/system_shim/include/fakes.h create mode 100644 zephyr/test/system_shim/src/no_chosen.c create mode 100644 zephyr/test/system_shim/src/suite.c create mode 100644 zephyr/test/system_shim/src/test_system.c delete mode 100644 zephyr/test/system_shim/test_system.c diff --git a/zephyr/shim/src/system.c b/zephyr/shim/src/system.c index 53e651ec03..99f4f4c3e1 100644 --- a/zephyr/shim/src/system.c +++ b/zephyr/shim/src/system.c @@ -342,7 +342,7 @@ static int check_reset_cause(void) return 0; } -static int system_preinitialize(const struct device *unused) +test_export_static int system_preinitialize(const struct device *unused) { ARG_UNUSED(unused); diff --git a/zephyr/test/system_shim/CMakeLists.txt b/zephyr/test/system_shim/CMakeLists.txt index 5db9cb285d..92b55a47e6 100644 --- a/zephyr/test/system_shim/CMakeLists.txt +++ b/zephyr/test/system_shim/CMakeLists.txt @@ -9,5 +9,16 @@ project(system_shim_test) # Include FFF fakes add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) -target_sources(app PRIVATE test_system.c - ${PLATFORM_EC}/zephyr/shim/src/system.c) +target_sources(app + PRIVATE + src/suite.c + ${PLATFORM_EC}/zephyr/shim/src/system.c +) +target_include_directories(app PRIVATE include) + +dt_has_chosen(has_bbram PROPERTY "cros-ec,bbram") +if(has_bbram) + target_sources(app PRIVATE src/test_system.c) +else() + target_sources(app PRIVATE src/no_chosen.c) +endif() diff --git a/zephyr/test/system_shim/boards/native_posix.overlay b/zephyr/test/system_shim/boards/native_posix.overlay index 0bcda0f513..b08ea4bf7a 100644 --- a/zephyr/test/system_shim/boards/native_posix.overlay +++ b/zephyr/test/system_shim/boards/native_posix.overlay @@ -6,9 +6,6 @@ #include / { - chosen { - cros-ec,bbram = &bbram; - }; bbram: test-bbram-dev { compatible = "zephyr,bbram-emul"; @@ -33,7 +30,7 @@ offset = <0x07>; size = <0x05>; }; - scratchpad { + scratchpad: scratchpad { offset = <0x0c>; size = <0x04>; }; diff --git a/zephyr/test/system_shim/default.overlay b/zephyr/test/system_shim/default.overlay new file mode 100644 index 0000000000..13ceee9c19 --- /dev/null +++ b/zephyr/test/system_shim/default.overlay @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "boards/native_posix.overlay" + +/ { + chosen { + cros-ec,bbram = &bbram; + }; +}; diff --git a/zephyr/test/system_shim/include/fakes.h b/zephyr/test/system_shim/include/fakes.h new file mode 100644 index 0000000000..80da06a313 --- /dev/null +++ b/zephyr/test/system_shim/include/fakes.h @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_SYSTEM_SHIM_INCLUDE_FAKES_H_ +#define ZEPHYR_TEST_SYSTEM_SHIM_INCLUDE_FAKES_H_ + +#include + +DECLARE_FAKE_VALUE_FUNC(int, cros_system_native_posix_get_reset_cause, + const struct device *); +DECLARE_FAKE_VALUE_FUNC(uint64_t, cros_system_native_posix_deep_sleep_ticks, + const struct device *); +DECLARE_FAKE_VALUE_FUNC(int, cros_system_native_posix_hibernate, + const struct device *, uint32_t, uint32_t); +DECLARE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_vendor, + const struct device *); +DECLARE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_name, + const struct device *); +DECLARE_FAKE_VALUE_FUNC(const char *, + cros_system_native_posix_get_chip_revision, + const struct device *); +DECLARE_FAKE_VALUE_FUNC(int, cros_system_native_posix_soc_reset, + const struct device *); +DECLARE_FAKE_VOID_FUNC(watchdog_reload); +DECLARE_FAKE_VOID_FUNC(board_hibernate); + +#endif /* ZEPHYR_TEST_SYSTEM_SHIM_INCLUDE_FAKES_H_ */ diff --git a/zephyr/test/system_shim/prj.conf b/zephyr/test/system_shim/prj.conf index fa7bd9fc04..98e133f5ff 100644 --- a/zephyr/test/system_shim/prj.conf +++ b/zephyr/test/system_shim/prj.conf @@ -9,3 +9,15 @@ CONFIG_CROS_EC=y CONFIG_LOG=y CONFIG_BBRAM=y CONFIG_BBRAM_EMUL=y + +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y + +# Make console work +CONFIG_SERIAL=y +CONFIG_SHELL_BACKEND_DUMMY=y +CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=1000 +CONFIG_SHELL_BACKEND_SERIAL=n + +# Make cros_system driver work +CONFIG_PM=y +CONFIG_CROS_SYSTEM_NATIVE_POSIX=y diff --git a/zephyr/test/system_shim/src/no_chosen.c b/zephyr/test/system_shim/src/no_chosen.c new file mode 100644 index 0000000000..55504691d1 --- /dev/null +++ b/zephyr/test/system_shim/src/no_chosen.c @@ -0,0 +1,24 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "fakes.h" +#include "system.h" + +ZTEST(system, test_fail_get_bbram_no_device) +{ + zassert_equal(EC_ERROR_INVAL, system_get_bbram(0, NULL)); +} + +ZTEST(system, test_fail_set_scratchpad) +{ + zassert_equal(-EC_ERROR_INVAL, system_set_scratchpad(0)); +} + +ZTEST(system, test_fail_get_scratchpad) +{ + zassert_equal(-EC_ERROR_INVAL, system_get_scratchpad(NULL)); +} diff --git a/zephyr/test/system_shim/src/suite.c b/zephyr/test/system_shim/src/suite.c new file mode 100644 index 0000000000..0d825ad9d7 --- /dev/null +++ b/zephyr/test/system_shim/src/suite.c @@ -0,0 +1,50 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include + +#include "fakes.h" + +DEFINE_FAKE_VALUE_FUNC(int, cros_system_native_posix_get_reset_cause, + const struct device *); +DEFINE_FAKE_VALUE_FUNC(uint64_t, cros_system_native_posix_deep_sleep_ticks, + const struct device *); +DEFINE_FAKE_VALUE_FUNC(int, cros_system_native_posix_hibernate, + const struct device *, uint32_t, uint32_t); +DEFINE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_vendor, + const struct device *); +DEFINE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_name, + const struct device *); +DEFINE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_revision, + const struct device *); +DEFINE_FAKE_VALUE_FUNC(int, cros_system_native_posix_soc_reset, + const struct device *); +DEFINE_FAKE_VOID_FUNC(watchdog_reload); +DEFINE_FAKE_VOID_FUNC(board_hibernate); + +static void system_before_after(void *test_data) +{ + const struct device *bbram_dev = + DEVICE_DT_GET_OR_NULL(DT_CHOSEN(cros_ec_bbram)); + + RESET_FAKE(cros_system_native_posix_get_reset_cause); + RESET_FAKE(cros_system_native_posix_deep_sleep_ticks); + RESET_FAKE(cros_system_native_posix_hibernate); + RESET_FAKE(cros_system_native_posix_get_chip_vendor); + RESET_FAKE(cros_system_native_posix_get_chip_name); + RESET_FAKE(cros_system_native_posix_get_chip_revision); + RESET_FAKE(cros_system_native_posix_soc_reset); + RESET_FAKE(watchdog_reload); + RESET_FAKE(board_hibernate); + + if (bbram_dev != NULL) { + bbram_emul_set_invalid(bbram_dev, false); + } +} + +ZTEST_SUITE(system, NULL, NULL, system_before_after, system_before_after, NULL); diff --git a/zephyr/test/system_shim/src/test_system.c b/zephyr/test/system_shim/src/test_system.c new file mode 100644 index 0000000000..e6e7077540 --- /dev/null +++ b/zephyr/test/system_shim/src/test_system.c @@ -0,0 +1,298 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "drivers/cros_system.h" +#include "fakes.h" +#include "system.h" + +LOG_MODULE_REGISTER(test); + +#define BBRAM_REGION_OFF(name) \ + DT_PROP(DT_PATH(named_bbram_regions, name), offset) +#define BBRAM_REGION_SIZE(name) \ + DT_PROP(DT_PATH(named_bbram_regions, name), size) + +static char mock_data[64] = + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@"; + +int system_preinitialize(const struct device *unused); + +ZTEST(system, test_invalid_bbram_index) +{ + zassert_equal(EC_ERROR_INVAL, + system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT + 1, NULL)); +} + +ZTEST(system, test_bbram_get) +{ + const struct device *const bbram_dev = + DEVICE_DT_GET(DT_CHOSEN(cros_ec_bbram)); + uint8_t output[10]; + int rc; + + /* Write expected data to read back */ + rc = bbram_write(bbram_dev, 0, ARRAY_SIZE(mock_data), mock_data); + zassert_ok(rc); + + rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD0, output); + zassert_ok(rc); + zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd0), + BBRAM_REGION_SIZE(pd0), NULL); + + rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD1, output); + zassert_ok(rc); + zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd1), + BBRAM_REGION_SIZE(pd1), NULL); + + rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD2, output); + zassert_ok(rc); + zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd2), + BBRAM_REGION_SIZE(pd2), NULL); + + rc = system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT, output); + zassert_ok(rc); + zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(try_slot), + BBRAM_REGION_SIZE(try_slot), NULL); +} + +ZTEST(system, test_save_read_chip_reset_flags) +{ + uint32_t arbitrary_flags = 0x1234; + + chip_save_reset_flags(0); + chip_save_reset_flags(arbitrary_flags); + zassert_equal(chip_read_reset_flags(), arbitrary_flags); +} + +ZTEST(system, test_system_set_get_scratchpad) +{ + /* Arbitrary values */ + uint32_t scratch_set = 0x1234; + uint32_t scratch_read; + + system_set_scratchpad(scratch_set); + system_get_scratchpad(&scratch_read); + zassert_equal(scratch_read, scratch_set); +} + +ZTEST(system, test_system_get_scratchpad_fail) +{ + const struct device *bbram_dev = + DEVICE_DT_GET(DT_CHOSEN(cros_ec_bbram)); + + zassert_ok(bbram_emul_set_invalid(bbram_dev, true)); + zassert_equal(-EC_ERROR_INVAL, system_get_scratchpad(NULL)); +} + +static jmp_buf jmp_hibernate; + +static int _test_cros_system_native_posix_hibernate(const struct device *dev, + uint32_t seconds, + uint32_t microseconds) +{ + longjmp(jmp_hibernate, 1); + + return 0; +} + +ZTEST(system, test_system_hibernate) +{ + /* + * Due to setjmp usage, this test provides no coverage, but does + * actually cover the code. This is due to a bug in LCOV. + */ + const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); + int ret = setjmp(jmp_hibernate); + /* Validate 0th and last bit preserved*/ + uint32_t secs = BIT(31) + 1; + uint32_t msecs = BIT(31) + 3; + + zassert_not_null(sys_dev); + + cros_system_native_posix_hibernate_fake.custom_fake = + _test_cros_system_native_posix_hibernate; + + if (ret == 0) { + system_hibernate(secs, msecs); + } + + zassert_not_equal(ret, 0); + + zassert_equal(cros_system_native_posix_hibernate_fake.call_count, 1); + zassert_equal(cros_system_native_posix_hibernate_fake.arg0_val, + sys_dev); + zassert_equal(cros_system_native_posix_hibernate_fake.arg1_val, secs); + zassert_equal(cros_system_native_posix_hibernate_fake.arg2_val, msecs); + zassert_equal(board_hibernate_fake.call_count, 1); +} + +ZTEST(system, test_system_hibernate__failure) +{ + const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); + /* Validate 0th and last bit preserved*/ + uint32_t secs = BIT(31) + 1; + uint32_t msecs = BIT(31) + 3; + + zassert_not_null(sys_dev); + + cros_system_native_posix_hibernate_fake.return_val = -1; + + system_hibernate(secs, msecs); + + zassert_equal(cros_system_native_posix_hibernate_fake.call_count, 1); + zassert_equal(cros_system_native_posix_hibernate_fake.arg0_val, + sys_dev); + zassert_equal(cros_system_native_posix_hibernate_fake.arg1_val, secs); + zassert_equal(cros_system_native_posix_hibernate_fake.arg2_val, msecs); +} + +ZTEST(system, test_system_get_chip_values) +{ + const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); + + zassert_not_null(sys_dev); + + /* Vendor */ + cros_system_native_posix_get_chip_vendor_fake.return_val = "a"; + zassert_mem_equal(system_get_chip_vendor(), "a", sizeof("a")); + zassert_equal(cros_system_native_posix_get_chip_vendor_fake.call_count, + 1); + zassert_equal(cros_system_native_posix_get_chip_vendor_fake.arg0_val, + sys_dev); + + /* Name */ + cros_system_native_posix_get_chip_name_fake.return_val = "b"; + zassert_mem_equal(system_get_chip_name(), "b", sizeof("b")); + zassert_equal(cros_system_native_posix_get_chip_name_fake.call_count, + 1); + zassert_equal(cros_system_native_posix_get_chip_name_fake.arg0_val, + sys_dev); + + /* Revision */ + cros_system_native_posix_get_chip_revision_fake.return_val = "c"; + zassert_mem_equal(system_get_chip_revision(), "c", sizeof("c")); + zassert_equal( + cros_system_native_posix_get_chip_revision_fake.call_count, 1); + zassert_equal(cros_system_native_posix_get_chip_revision_fake.arg0_val, + sys_dev); +} + +static int _test_cros_system_native_posix_soc_reset(const struct device *dev) +{ + printf("called from soc reset"); + longjmp(jmp_hibernate, 1); + + return 0; +} + +ZTEST(system, test_system_reset) +{ + /* + * Despite using setjmp this test consistently covers the code under + * test. Context: https://github.com/llvm/llvm-project/issues/50119 + */ + const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); + int ret = setjmp(jmp_hibernate); + uint32_t arbitrary_flags_w_reset_wait_ext = 0x1234 | + SYSTEM_RESET_WAIT_EXT; + uint32_t encoded_arbitrary_flags_w_reset_wait_ext; + + system_encode_save_flags(arbitrary_flags_w_reset_wait_ext, + &encoded_arbitrary_flags_w_reset_wait_ext); + + zassert_not_null(sys_dev); + + cros_system_native_posix_soc_reset_fake.custom_fake = + _test_cros_system_native_posix_soc_reset; + + if (ret == 0) { + system_reset(arbitrary_flags_w_reset_wait_ext); + } + + zassert_not_null(sys_dev); + + zassert_equal(chip_read_reset_flags(), + encoded_arbitrary_flags_w_reset_wait_ext); + + zassert_equal(watchdog_reload_fake.call_count, 1000); + zassert_equal(cros_system_native_posix_soc_reset_fake.call_count, 1); + zassert_equal(cros_system_native_posix_soc_reset_fake.arg0_val, + sys_dev); +} + +ZTEST_USER(system, test_system_console_cmd__idlestats) +{ + const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); + const struct shell *shell_zephyr = get_ec_shell(); + const char *outbuffer; + size_t buffer_size; + + zassert_not_null(sys_dev); + + shell_backend_dummy_clear_output(shell_zephyr); + + k_sleep(K_SECONDS(1)); + zassert_ok(shell_execute_cmd(shell_zephyr, "idlestats"), NULL); + + /* Weakly verify contents */ + outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size); + zassert_not_equal(buffer_size, 0); + zassert_not_null(strstr(outbuffer, "Time spent in deep-sleep:")); + zassert_not_null(strstr(outbuffer, "Total time on:")); + + zassert_equal(cros_system_native_posix_deep_sleep_ticks_fake.call_count, + 1); +} + +ZTEST(system, test_init_invalid_reset_cause) +{ + cros_system_native_posix_get_reset_cause_fake.return_val = -1; + zassert_equal(-1, system_preinitialize(NULL)); +} + +ZTEST(system, test_init_cause_vcc1_rst_pin) +{ + cros_system_native_posix_get_reset_cause_fake.return_val = VCC1_RST_PIN; + chip_save_reset_flags(0); + system_clear_reset_flags(0xffffffff); + + zassert_ok(system_preinitialize(NULL)); + zassert_equal(EC_RESET_FLAG_RESET_PIN, system_get_reset_flags()); + + chip_save_reset_flags(EC_RESET_FLAG_INITIAL_PWR); + zassert_ok(system_preinitialize(NULL)); + zassert_equal(EC_RESET_FLAG_RESET_PIN | EC_RESET_FLAG_POWER_ON | + EC_RESET_FLAG_POWER_ON, + system_get_reset_flags()); +} + +ZTEST(system, test_init_cause_debug_rst) +{ + cros_system_native_posix_get_reset_cause_fake.return_val = DEBUG_RST; + chip_save_reset_flags(0); + system_clear_reset_flags(0xffffffff); + + zassert_ok(system_preinitialize(NULL)); + zassert_equal(EC_RESET_FLAG_SOFT, system_get_reset_flags()); +} + +ZTEST(system, test_init_cause_watchdog_rst) +{ + cros_system_native_posix_get_reset_cause_fake.return_val = WATCHDOG_RST; + chip_save_reset_flags(0); + system_clear_reset_flags(0xffffffff); + + zassert_ok(system_preinitialize(NULL)); + zassert_equal(EC_RESET_FLAG_WATCHDOG, system_get_reset_flags()); +} diff --git a/zephyr/test/system_shim/test_system.c b/zephyr/test/system_shim/test_system.c deleted file mode 100644 index 3bf43d6669..0000000000 --- a/zephyr/test/system_shim/test_system.c +++ /dev/null @@ -1,257 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "system.h" - -LOG_MODULE_REGISTER(test); - -#define BBRAM_REGION_OFF(name) \ - DT_PROP(DT_PATH(named_bbram_regions, name), offset) -#define BBRAM_REGION_SIZE(name) \ - DT_PROP(DT_PATH(named_bbram_regions, name), size) - -static char mock_data[64] = - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@"; - -FAKE_VALUE_FUNC(uint64_t, cros_system_native_posix_deep_sleep_ticks, - const struct device *); -FAKE_VALUE_FUNC(int, cros_system_native_posix_hibernate, const struct device *, - uint32_t, uint32_t); -FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_vendor, - const struct device *); -FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_name, - const struct device *); -FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_revision, - const struct device *); -FAKE_VALUE_FUNC(int, cros_system_native_posix_soc_reset, const struct device *); -FAKE_VOID_FUNC(watchdog_reload); - -static void system_before_after(void *test_data) -{ - RESET_FAKE(cros_system_native_posix_deep_sleep_ticks); - RESET_FAKE(cros_system_native_posix_hibernate); -} - -ZTEST_SUITE(system, NULL, NULL, system_before_after, system_before_after, NULL); - -ZTEST(system, test_bbram_get) -{ - const struct device *const bbram_dev = - DEVICE_DT_GET(DT_CHOSEN(cros_ec_bbram)); - uint8_t output[10]; - int rc; - - /* Write expected data to read back */ - rc = bbram_write(bbram_dev, 0, ARRAY_SIZE(mock_data), mock_data); - zassert_ok(rc); - - rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD0, output); - zassert_ok(rc); - zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd0), - BBRAM_REGION_SIZE(pd0), NULL); - - rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD1, output); - zassert_ok(rc); - zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd1), - BBRAM_REGION_SIZE(pd1), NULL); - - rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD2, output); - zassert_ok(rc); - zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd2), - BBRAM_REGION_SIZE(pd2), NULL); - - rc = system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT, output); - zassert_ok(rc); - zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(try_slot), - BBRAM_REGION_SIZE(try_slot), NULL); -} - -ZTEST(system, test_save_read_chip_reset_flags) -{ - uint32_t arbitrary_flags = 0x1234; - - chip_save_reset_flags(0); - chip_save_reset_flags(arbitrary_flags); - zassert_equal(chip_read_reset_flags(), arbitrary_flags); -} - -ZTEST(system, test_system_set_get_scratchpad) -{ - /* Arbitrary values */ - uint32_t scratch_set = 0x1234; - uint32_t scratch_read; - - system_set_scratchpad(scratch_set); - system_get_scratchpad(&scratch_read); - zassert_equal(scratch_read, scratch_set); -} - -static jmp_buf jmp_hibernate; - -static int _test_cros_system_native_posix_hibernate(const struct device *dev, - uint32_t seconds, - uint32_t microseconds) -{ - longjmp(jmp_hibernate, 1); - - return 0; -} - -ZTEST(system, test_system_hibernate) -{ - /* - * Due to setjmp usage, this test provides no coverage, but does - * actually cover the code. This is due to a bug in LCOV. - */ - const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); - int ret = setjmp(jmp_hibernate); - /* Validate 0th and last bit preserved*/ - uint32_t secs = BIT(31) + 1; - uint32_t msecs = BIT(31) + 3; - - zassert_not_null(sys_dev); - - cros_system_native_posix_hibernate_fake.custom_fake = - _test_cros_system_native_posix_hibernate; - - if (ret == 0) { - system_hibernate(secs, msecs); - } - - zassert_not_equal(ret, 0); - - zassert_equal(cros_system_native_posix_hibernate_fake.call_count, 1); - zassert_equal(cros_system_native_posix_hibernate_fake.arg0_val, - sys_dev); - zassert_equal(cros_system_native_posix_hibernate_fake.arg1_val, secs); - zassert_equal(cros_system_native_posix_hibernate_fake.arg2_val, msecs); -} - -ZTEST(system, test_system_hibernate__failure) -{ - const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); - /* Validate 0th and last bit preserved*/ - uint32_t secs = BIT(31) + 1; - uint32_t msecs = BIT(31) + 3; - - zassert_not_null(sys_dev); - - cros_system_native_posix_hibernate_fake.return_val = -1; - - system_hibernate(secs, msecs); - - zassert_equal(cros_system_native_posix_hibernate_fake.call_count, 1); - zassert_equal(cros_system_native_posix_hibernate_fake.arg0_val, - sys_dev); - zassert_equal(cros_system_native_posix_hibernate_fake.arg1_val, secs); - zassert_equal(cros_system_native_posix_hibernate_fake.arg2_val, msecs); -} - -ZTEST(system, test_system_get_chip_values) -{ - const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); - - zassert_not_null(sys_dev); - - /* Vendor */ - cros_system_native_posix_get_chip_vendor_fake.return_val = "a"; - zassert_mem_equal(system_get_chip_vendor(), "a", sizeof("a")); - zassert_equal(cros_system_native_posix_get_chip_vendor_fake.call_count, - 1); - zassert_equal(cros_system_native_posix_get_chip_vendor_fake.arg0_val, - sys_dev); - - /* Name */ - cros_system_native_posix_get_chip_name_fake.return_val = "b"; - zassert_mem_equal(system_get_chip_name(), "b", sizeof("b")); - zassert_equal(cros_system_native_posix_get_chip_name_fake.call_count, - 1); - zassert_equal(cros_system_native_posix_get_chip_name_fake.arg0_val, - sys_dev); - - /* Revision */ - cros_system_native_posix_get_chip_revision_fake.return_val = "c"; - zassert_mem_equal(system_get_chip_revision(), "c", sizeof("c")); - zassert_equal( - cros_system_native_posix_get_chip_revision_fake.call_count, 1); - zassert_equal(cros_system_native_posix_get_chip_revision_fake.arg0_val, - sys_dev); -} - -static int _test_cros_system_native_posix_soc_reset(const struct device *dev) -{ - printf("called from soc reset"); - longjmp(jmp_hibernate, 1); - - return 0; -} - -ZTEST(system, test_system_reset) -{ - /* - * Despite using setjmp this test consistently covers the code under - * test. Context: https://github.com/llvm/llvm-project/issues/50119 - */ - const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); - int ret = setjmp(jmp_hibernate); - uint32_t arbitrary_flags_w_reset_wait_ext = 0x1234 | - SYSTEM_RESET_WAIT_EXT; - uint32_t encoded_arbitrary_flags_w_reset_wait_ext; - - system_encode_save_flags(arbitrary_flags_w_reset_wait_ext, - &encoded_arbitrary_flags_w_reset_wait_ext); - - zassert_not_null(sys_dev); - - cros_system_native_posix_soc_reset_fake.custom_fake = - _test_cros_system_native_posix_soc_reset; - - if (ret == 0) { - system_reset(arbitrary_flags_w_reset_wait_ext); - } - - zassert_not_null(sys_dev); - - zassert_equal(chip_read_reset_flags(), - encoded_arbitrary_flags_w_reset_wait_ext); - - zassert_equal(watchdog_reload_fake.call_count, 1000); - zassert_equal(cros_system_native_posix_soc_reset_fake.call_count, 1); - zassert_equal(cros_system_native_posix_soc_reset_fake.arg0_val, - sys_dev); -} - -ZTEST_USER(system, test_system_console_cmd__idlestats) -{ - const struct device *sys_dev = device_get_binding("CROS_SYSTEM"); - const struct shell *shell_zephyr = get_ec_shell(); - const char *outbuffer; - size_t buffer_size; - - zassert_not_null(sys_dev); - - shell_backend_dummy_clear_output(shell_zephyr); - - k_sleep(K_SECONDS(1)); - zassert_ok(shell_execute_cmd(shell_zephyr, "idlestats"), NULL); - - /* Weakly verify contents */ - outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size); - zassert_not_equal(buffer_size, 0); - zassert_not_null(strstr(outbuffer, "Time spent in deep-sleep:")); - zassert_not_null(strstr(outbuffer, "Total time on:")); - - zassert_equal(cros_system_native_posix_deep_sleep_ticks_fake.call_count, - 1); -} diff --git a/zephyr/test/system_shim/testcase.yaml b/zephyr/test/system_shim/testcase.yaml index 3374c7f5f3..29b5fa55c0 100644 --- a/zephyr/test/system_shim/testcase.yaml +++ b/zephyr/test/system_shim/testcase.yaml @@ -1,15 +1,8 @@ common: platform_allow: native_posix + tags: + system tests: system_shim.default: - tags: - system - extra_configs: - # Make console work - - CONFIG_SERIAL=y - - CONFIG_SHELL_BACKEND_DUMMY=y - - CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=1000 - - CONFIG_SHELL_BACKEND_SERIAL=n - # Make cros_system driver work - - CONFIG_PM=y - - CONFIG_CROS_SYSTEM_NATIVE_POSIX=y + extra_args: DTC_OVERLAY_FILE="./default.overlay" + system_shim.no_chosen: {} -- cgit v1.2.1 From 425d70135bec0590518292cb1fdf83012c57986e Mon Sep 17 00:00:00 2001 From: Yu-An Chen Date: Fri, 11 Nov 2022 15:06:38 +0800 Subject: evoker: Remove USB-A port Evoker doesn't have USB-A. In here remove it. BUG=b:238571776 BRANCH=none TEST=check gpioget doesn't have USB-A related gpio name Signed-off-by: Yu-An Chen Change-Id: I940d2d191683d14d748e014c2d2069aa02dd4d82 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022556 Reviewed-by: Wai-Hong Tam Code-Coverage: Zoss Commit-Queue: Wai-Hong Tam Reviewed-by: Bob Moragues --- zephyr/program/herobrine/evoker/gpio.dtsi | 18 +++--------------- zephyr/program/herobrine/evoker/project.conf | 5 ++++- zephyr/program/herobrine/evoker/project.overlay | 7 +++++++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/zephyr/program/herobrine/evoker/gpio.dtsi b/zephyr/program/herobrine/evoker/gpio.dtsi index bb693158fa..63225917c6 100644 --- a/zephyr/program/herobrine/evoker/gpio.dtsi +++ b/zephyr/program/herobrine/evoker/gpio.dtsi @@ -34,9 +34,6 @@ gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l { gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>; }; - gpio_usb_a0_oc_odl: usb_a0_oc_odl { - gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>; - }; gpio_chg_acok_od: chg_acok_od { gpios = <&gpiod 2 GPIO_INPUT>; enum-name = "GPIO_AC_PRESENT"; @@ -159,13 +156,6 @@ gpio_dp_hot_plug_det_r: dp_hot_plug_det_r { gpios = <&gpio9 5 GPIO_OUTPUT_LOW>; }; - gpio_en_usb_a_5v: en_usb_a_5v { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_USB_A_5V"; - }; - usb_a_cdp_ilim_en_l { - gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; - }; gpio_usb_c0_frs_en: usb_c0_frs_en { gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; enum-name = "GPIO_USB_C0_FRS_EN"; @@ -238,11 +228,6 @@ }; }; - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&gpio_en_usb_a_5v>; - }; - gpio_id_sku: sku { compatible = "cros-ec,gpio-id"; bits = < @@ -288,6 +273,9 @@ <&gpioa 7 0>, <&gpio5 0 0>, <&gpio8 1 0>, + <&gpiof 0 0>, + <&gpio7 5 0>, + <&gpiof 4 0>, <&gpiob 7 0>; }; }; diff --git a/zephyr/program/herobrine/evoker/project.conf b/zephyr/program/herobrine/evoker/project.conf index b4a5fce160..c2fecd48b5 100644 --- a/zephyr/program/herobrine/evoker/project.conf +++ b/zephyr/program/herobrine/evoker/project.conf @@ -13,4 +13,7 @@ CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y # ISL9238C disable the CMOUT latch function. CONFIG_PLATFORM_EC_ISL9238C_DISABLE_CMOUT_LATCH=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y \ No newline at end of file +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y + +# Disable USB-A +CONFIG_PLATFORM_EC_USBA=n diff --git a/zephyr/program/herobrine/evoker/project.overlay b/zephyr/program/herobrine/evoker/project.overlay index 04f6b2443d..61d3129f70 100644 --- a/zephyr/program/herobrine/evoker/project.overlay +++ b/zephyr/program/herobrine/evoker/project.overlay @@ -50,3 +50,10 @@ reg = <0x40>; }; }; + +/* interrupts overrides */ +/ { + gpio-interrupts { + /delete-node/ usb_a0_oc; + }; +}; -- cgit v1.2.1 From 9d21e1334139db03bc68a560bf1814bc5ac4bcde Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 14:51:41 -0700 Subject: ec: IWYU Add some missing includes Add headers for types that are used in these headers. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: I184a7d31e8cb7e14391f0c610296884d7d124600 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024015 Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Code-Coverage: Zoss Commit-Queue: Simon Glass Reviewed-by: Simon Glass --- include/fan.h | 2 ++ include/hwtimer.h | 2 ++ zephyr/shim/include/gpio/gpio.h | 1 + 3 files changed, 5 insertions(+) diff --git a/include/fan.h b/include/fan.h index cefb4c0dba..7c64f4e31b 100644 --- a/include/fan.h +++ b/include/fan.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_FAN_H #define __CROS_EC_FAN_H +#include "config.h" + #include #ifdef CONFIG_ZEPHYR diff --git a/include/hwtimer.h b/include/hwtimer.h index 093a44cad1..9058563e7a 100644 --- a/include/hwtimer.h +++ b/include/hwtimer.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_HWTIMER_H #define __CROS_EC_HWTIMER_H +#include + /** * Programs when the next timer should fire an interrupt. * diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h index 7d41c0fa02..fbe57729fe 100644 --- a/zephyr/shim/include/gpio/gpio.h +++ b/zephyr/shim/include/gpio/gpio.h @@ -8,6 +8,7 @@ #include #include +#include /* * Validate interrupt flags are valid for the Zephyr GPIO driver. -- cgit v1.2.1 From 8b3da602888d0013db6fb38617d707f89c0565f9 Mon Sep 17 00:00:00 2001 From: Li Feng Date: Thu, 3 Nov 2022 09:59:18 -0700 Subject: chip/ish: fix system shutdown in D0i3 ISH should set PMC LTR(Latency Tolerance Reporting) for DMA operation. Without doing this, we observed system shutdown during D0i3. This CL set LTR to 2ms before DMA operation and set LTR to a large number after DMA operation is completed to enable SOC to go into the lowest possible power state. BUG=b:234136500 BRANCH=none TEST=on Nirwen platform, ISH enter D0i3 host loading case, and also stitching to coreboot case; S0i3 is hit and no shutdown. Signed-off-by: Leifu Zhao Signed-off-by: Li Feng Change-Id: Ib0fe907470774998dda29a40197d6c18ad6372f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4003320 Code-Coverage: Haribalaraman Ramasubramanian Reviewed-by: Kyoung Kim Reviewed-by: Haribalaraman Ramasubramanian Commit-Queue: Kangheui Won Tested-by: Haribalaraman Ramasubramanian Code-Coverage: Zoss Reviewed-by: Kangheui Won --- chip/ish/aontaskfw/ish_aontask.c | 71 ++++++++++++++++++++++++++++++++++++++++ chip/ish/dma.c | 40 ---------------------- chip/ish/ish_dma.h | 41 +++++++++++++++++++++++ chip/ish/registers.h | 54 ++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 40 deletions(-) diff --git a/chip/ish/aontaskfw/ish_aontask.c b/chip/ish/aontaskfw/ish_aontask.c index d167f3f5df..58d62d1891 100644 --- a/chip/ish/aontaskfw/ish_aontask.c +++ b/chip/ish/aontaskfw/ish_aontask.c @@ -91,6 +91,56 @@ static void handle_reset(enum ish_pm_state pm_state); +#if defined(CHIP_VARIANT_ISH5P4) +static void sb_upstream_write_raw_base(uint32_t addr, uint32_t attr, + uint32_t data, uint32_t sairs, + uint8_t addr48, uint16_t addr_hi) +{ + uint32_t eflags; + uint32_t addr_hi_32; + + addr_hi_32 = addr_hi | (1 << 31); + + eflags = interrupt_lock(); + + PMU_VNN_REQ = (1 << VNN_ID_SIDEBAND); + while (!(PMU_VNN_REQ_ACK & PMU_VNN_REQ_ACK_STATUS)) + continue; + + if (dma_poll(SBEP_REG_UP_MSG_STATUS_ADDR, 0, UP_STATUS_BUSY_MASK) == + DMA_RC_OK) { + SBEP_REG_UP_MSG_REQ_ADDR_LOW = addr; + + if (addr48) { + SBEP_REG_UP_MSG_REQ_ADDR_HIGH = addr_hi_32; + } else { + SBEP_REG_UP_MSG_REQ_ADDR_HIGH = 0; + } + + SBEP_REG_UP_MSG_REQ_ATTR = attr; + SBEP_REG_UP_MSG_REQ_DATA = data; + SBEP_REG_UP_MSG_REQ_EH = sairs; + SBEP_REG_UP_MSG_COMMAND = SBEP_CMD_WRITE; + + dma_poll(SBEP_REG_UP_MSG_STATUS_ADDR, 0, UP_STATUS_BUSY_MASK); + dma_poll(SBEP_REG_UP_MSG_STATUS_ADDR, UP_STATUS_MSG_SENT_MASK, + UP_STATUS_MSG_SENT_MASK); + SBEP_REG_UP_MSG_STATUS = UP_STATUS_MSG_SENT_CLR; + } + + PMU_VNN_REQ = (1 << VNN_ID_SIDEBAND); + interrupt_unlock(eflags); +} + +static void sb_upstream_write_raw(uint32_t addr, uint32_t attr, uint32_t data, + uint32_t sairs) +{ + addr = addr & 0x0000FFFF; + + sb_upstream_write_raw_base(addr, attr, data, sairs, 0, 0); +} +#endif + /* ISR for PMU wakeup interrupt */ static void pmu_wakeup_isr(void) { @@ -670,6 +720,13 @@ static void handle_d0i3(void) aon_share.pg_exit = 0; } +#if defined(CHIP_VARIANT_ISH5P4) + /* Set PMC LTR to 2ms before DMA copy */ + if (IS_ENABLED(CONFIG_ISH_NEW_PM)) + sb_upstream_write_raw(0, LTR_CMD_ATTR, LTR_CMD_DATA_2MS, + SBEP_PMC_SAIRS_VAL); +#endif + /* store main FW 's context to IMR DDR from main SRAM */ ret = store_main_fw(); @@ -680,6 +737,13 @@ static void handle_d0i3(void) /* power off main SRAM */ sram_power(0); +#if defined(CHIP_VARIANT_ISH5P4) + /* Set LTR to a large number after DMA copy done */ + if (IS_ENABLED(CONFIG_ISH_NEW_PM)) + sb_upstream_write_raw(0, LTR_CMD_ATTR, LTR_CMD_DATA_INFINITE, + SBEP_PMC_SAIRS_VAL); +#endif + set_vnnred_aoncg(); if (IS_ENABLED(CONFIG_ISH_IPAPG) && is_ipapg_allowed()) { @@ -712,6 +776,13 @@ static void handle_d0i3(void) aon_share.uma_msb); } +#if defined(CHIP_VARIANT_ISH5P4) + /* Set PMC LTR to 2ms before DMA copy */ + if (IS_ENABLED(CONFIG_ISH_NEW_PM)) + sb_upstream_write_raw(0, LTR_CMD_ATTR, LTR_CMD_DATA_2MS, + SBEP_PMC_SAIRS_VAL); +#endif + /* restore main FW 's context to main SRAM from IMR DDR */ ret = restore_main_fw(); diff --git a/chip/ish/dma.c b/chip/ish/dma.c index 48a27a0463..e2f1aba8ed 100644 --- a/chip/ish/dma.c +++ b/chip/ish/dma.c @@ -13,28 +13,6 @@ static int dma_init_called; /* If ish_dma_init is called */ -static int dma_poll(uint32_t addr, uint32_t expected, uint32_t mask) -{ - int retval = -1; - uint32_t counter = 0; - - /* - * The timeout is approximately 2.2 seconds according to - * value of UINT32_MAX, 120MHZ ISH clock frequency and - * instruction count which is around 4. - */ - while (counter < (UINT32_MAX / 64)) { - /* test condition */ - if ((REG32(addr) & mask) == expected) { - retval = DMA_RC_OK; - break; - } - counter++; - } - - return retval; -} - void ish_dma_ocp_timeout_disable(void) { if (!IS_ENABLED(CONFIG_ISH_NEW_PM)) { @@ -44,24 +22,6 @@ void ish_dma_ocp_timeout_disable(void) } } -static inline uint32_t interrupt_lock(void) -{ - uint32_t eflags = 0; - __asm__ volatile("pushfl;" /* save eflag value */ - "popl %0;" - "cli;" - : "=r"(eflags)); /* shut off interrupts */ - return eflags; -} - -static inline void interrupt_unlock(uint32_t eflags) -{ - __asm__ volatile("pushl %0;" /* restore elfag values */ - "popfl;" - : - : "r"(eflags)); -} - void dma_configure_psize(void) { /* Give chan0 512 bytes for high performance, and chan1 128 bytes. */ diff --git a/chip/ish/ish_dma.h b/chip/ish/ish_dma.h index fb9c4f4f06..89d6cb7342 100644 --- a/chip/ish/ish_dma.h +++ b/chip/ish/ish_dma.h @@ -27,6 +27,47 @@ #define PAGE_SIZE 4096 +static inline uint32_t interrupt_lock(void) +{ + uint32_t eflags = 0; + + __asm__ volatile("pushfl;" /* save eflag value */ + "popl %0;" + "cli;" + : "=r"(eflags)); /* shut off interrupts */ + return eflags; +} + +static inline void interrupt_unlock(uint32_t eflags) +{ + __asm__ volatile("pushl %0;" /* restore elfag values */ + "popfl;" + : + : "r"(eflags)); +} + +static inline int dma_poll(uint32_t addr, uint32_t expected, uint32_t mask) +{ + int retval = -1; + uint32_t counter = 0; + + /* + * The timeout is approximately 2.2 seconds according to + * value of UINT32_MAX, 120MHZ ISH clock frequency and + * instruction count which is around 4. + */ + while (counter < (UINT32_MAX / 64)) { + /* test condition */ + if ((REG32(addr) & mask) == expected) { + retval = DMA_RC_OK; + break; + } + counter++; + } + + return retval; +} + /** * SRAM: ISH local static ram * UMA: Protected system DRAM region dedicated for ISH diff --git a/chip/ish/registers.h b/chip/ish/registers.h index ba83b7bef8..7fe5d2c5ab 100644 --- a/chip/ish/registers.h +++ b/chip/ish/registers.h @@ -136,6 +136,59 @@ enum ish_i2c_port { #define SB_CLK_GATE_EN_TRUNK_CLK_GATE BIT(1) #endif +#define SBEP_REG_UP_MSG_STATUS_ADDR (ISH_SBEP_BASE + 0x0040) +#define SBEP_REG_UP_MSG_STATUS REG32(ISH_SBEP_BASE + 0x0040) +#define SBEP_REG_UP_MSG_COMMAND REG32(ISH_SBEP_BASE + 0x0044) +#define SBEP_REG_UP_MSG_REQ_ADDR_LOW REG32(ISH_SBEP_BASE + 0x0048) +#define SBEP_REG_UP_MSG_REQ_ADDR_HIGH REG32(ISH_SBEP_BASE + 0x004C) +#define SBEP_REG_UP_MSG_REQ_DATA REG32(ISH_SBEP_BASE + 0x0050) +#define SBEP_REG_UP_MSG_REQ_ATTR REG32(ISH_SBEP_BASE + 0x0054) +#define SBEP_REG_UP_MSG_REQ_EH REG32(ISH_SBEP_BASE + 0x0058) + +#define UP_STATUS_BUSY_MASK 0x01 +#define UP_STATUS_MSG_SENT_MASK 0x02 +#define UP_STATUS_MSG_SENT_CLR 0x02 + +#define SBEP_CMD_ACTION 0x1 +#define SBEP_CMD_TYPE_WRITE 0x0 +#define SBEP_CMD_TYPE_READ 0x1 +#define SBEP_CMD_POSTED 0x1 +#define SBEP_CMD_NON_POSTED 0x0 +#define SBEP_CMD_INT_ENABLED 0x1 +#define SBEP_CMD_ACTION_OFF 0 +#define SBEP_CMD_TYPE_OFF 1 +#define SBEP_CMD_POSTED_OFF 2 +#define SBEP_CMD_INT_OFF 3 + +#define SBEP_CMD_WRITE \ + ((SBEP_CMD_ACTION << SBEP_CMD_ACTION_OFF) | \ + (SBEP_CMD_TYPE_WRITE << SBEP_CMD_TYPE_OFF) | \ + (SBEP_CMD_POSTED << SBEP_CMD_POSTED_OFF) | \ + (SBEP_CMD_INT_ENABLED << SBEP_CMD_INT_OFF)) + +#define SBEP_ATTR_LTR_OPCODE 0x43 +#define SBEP_ATTR_PMC_DEST_ID 0xCC +#define SBEP_ATTR_DEST_ID_OFF 0 +#define SBEP_ATTR_OPCODE_OFF 8 +#define SBEP_ATTR_WRITE_ALL_BYTES 0xF +#define SBEP_ATTR_BYTE_ENABLE_OFF 16 +#define LTR_CMD_ATTR \ + ((SBEP_ATTR_PMC_DEST_ID << SBEP_ATTR_DEST_ID_OFF) | \ + (SBEP_ATTR_LTR_OPCODE << SBEP_ATTR_OPCODE_OFF) | \ + (SBEP_ATTR_WRITE_ALL_BYTES << SBEP_ATTR_BYTE_ENABLE_OFF)) +#define LTR_CMD_DATA_2MS 0x90029002 +#define LTR_CMD_DATA_INFINITE 0 + +#define SBEP_SAIRS_ROOT_SPACE_PMC 0 + +#define SBEP_SAIRS_EH_PRESENT 1 +#define SBEP_SAIRS_ROOT_SPACE_OFF 16 +#define SBEP_SAIRS_EH_PRESENT_OFF 31 + +#define SBEP_PMC_SAIRS_VAL \ + ((SBEP_SAIRS_ROOT_SPACE_PMC << SBEP_SAIRS_ROOT_SPACE_OFF) | \ + (SBEP_SAIRS_EH_PRESENT << SBEP_SAIRS_EH_PRESENT_OFF)) + /* APIC interrupt vectors */ #define ISH_TS_VECTOR 0x20 /* Task switch vector */ #define LAPIC_LVT_ERROR_VECTOR 0x21 /* Clears IOAPIC/LAPIC sync errors */ @@ -269,6 +322,7 @@ enum ish_i2c_port { #define VNN_ID_DMA0 4 #define VNN_ID_DMA(chan) (VNN_ID_DMA0 + chan) +#define VNN_ID_SIDEBAND 21 /* OCP registers */ #define OCP_IOSF2OCP_BRIDGE (ISH_OCP_BASE + 0x9400) -- cgit v1.2.1 From 69df9b5b230ce025b6e6f87d4f5551d0a845d2ad Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 11:00:39 -0800 Subject: board/gelarshie: Free up more flash space BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=gelarshie Signed-off-by: Tom Hughes Change-Id: Ib483bc193fea2737a1c1add0695327b014727e89 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024038 Reviewed-by: Edward Hill Code-Coverage: Zoss --- board/gelarshie/board.h | 1 + util/build_with_clang.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/board/gelarshie/board.h b/board/gelarshie/board.h index 7e27c7a62f..34e5d47f0c 100644 --- a/board/gelarshie/board.h +++ b/board/gelarshie/board.h @@ -35,6 +35,7 @@ #undef CONFIG_CMD_ACCEL_FIFO #undef CONFIG_CMD_ACCEL_INFO #undef CONFIG_CMD_TASK_RESET +#undef CONFIG_CONSOLE_CMDHELP /* Battery */ #define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION" diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 55f3b54d6c..d3e9faf3f1 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -135,6 +135,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "fleex", "foob", "gaelin", + "gelarshie", "genesis", "gimble", "grunt", @@ -294,7 +295,6 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ "willow", # overflows flash # Boards that use CHIP:=npcx "garg", # overflows flash - "gelarshie", # overflows flash "mushu", # overflows flash "nocturne", # overflows flash "terrador", # overflows flash -- cgit v1.2.1 From ded807b0e86401cdb9c054881a84142145e18f16 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 10 Nov 2022 16:41:42 -0800 Subject: board/nocturne: Enable LTO BRANCH=none BUG=b:172020503 TEST=make BOARD=nocturne Signed-off-by: Tom Hughes Change-Id: I19b0c772380336cdcd8b9d219386df21f859a7a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021113 Reviewed-by: Edward Hill Reviewed-by: Daisuke Nojiri Code-Coverage: Zoss --- board/nocturne/board.h | 2 ++ util/build_with_clang.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/board/nocturne/board.h b/board/nocturne/board.h index 279016ec98..1b2280a6e9 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H +#define CONFIG_LTO + /* * By default, enable all console messages excepted HC, ACPI and event: * The sensor stack is generating a lot of activity. diff --git a/util/build_with_clang.py b/util/build_with_clang.py index d3e9faf3f1..085dcde8c2 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -175,6 +175,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "nautilus", "nightfury", "nipperkin", + "nocturne", "npcx7_evb", "npcx9_evb", "npcx_evb", @@ -296,7 +297,6 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ # Boards that use CHIP:=npcx "garg", # overflows flash "mushu", # overflows flash - "nocturne", # overflows flash "terrador", # overflows flash "volteer", # overflows flash ] -- cgit v1.2.1 From da42c4a3dbcbb51b228d2085a4b5896afbc57fd0 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 10 Nov 2022 16:11:01 -0800 Subject: core/cortex-m0: Use EC's builtins over compiler-rt When examining code size, it appears that the builtins in compiler-rt (especially for division) are larger than the ones in the EC source code: armv7m-cros-eabi-readelf -s ./build/servo_v4p1/RW/ec.RW.elf | sort -k3 -n -r __udivsi3: 418 bytes __aeabi_uidiv: 418 bytes Compiling with clang before this change: RO: 15560 bytes in flash and 864 bytes in RAM still available on servo_v4p1 RW: 848 bytes in flash and 7144 bytes in RAM still available on servo_v4p1 After this change: RO: 16456 bytes in flash and 864 bytes in RAM still available on servo_v4p1 RW: 1232 bytes in flash and 7144 bytes in RAM still available on servo_v4p1 BRANCH=none BUG=b:256193799 TEST=make buildall Signed-off-by: Tom Hughes Change-Id: I21eab7fba10795e7821be79d141002a009d396a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021114 Code-Coverage: Zoss Reviewed-by: Diana Z --- core/cortex-m0/build.mk | 14 ++++++++++---- core/cortex-m0/config_core.h | 5 ++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/core/cortex-m0/build.mk b/core/cortex-m0/build.mk index 7de8956a4d..f3cce27eea 100644 --- a/core/cortex-m0/build.mk +++ b/core/cortex-m0/build.mk @@ -6,6 +6,14 @@ # Cortex-M0 core OS files build # +# When set to 1, exclusively use builtins from compiler-rt. +# When set to 0, use EC's builtins. +USE_LLVM_COMPILER_RT:=0 + +ifeq ($(USE_LLVM_COMPILER_RT),1) +CFLAGS_CPU+=-DUSE_LLVM_COMPILER_RT +endif + # CPU specific compilation flags CFLAGS_CPU+=-mthumb ifeq ($(cc-name),clang) @@ -24,14 +32,12 @@ LDFLAGS_EXTRA+=-flto endif core-y=cpu.o debug.o init.o thumb_case.o mula.o -# When using clang, we get these as builtins from compiler-rt. -ifneq ($(cc-name),clang) +ifeq ($(USE_LLVM_COMPILER_RT),0) core-y+=div.o lmul.o ldivmod.o uldivmod.o endif core-y+=vecttable.o -# When using clang, we get these as builtins from compiler-rt. -ifneq ($(cc-name),clang) +ifeq ($(USE_LLVM_COMPILER_RT),0) core-y+=__builtin.o endif core-$(CONFIG_COMMON_PANIC_OUTPUT)+=panic.o diff --git a/core/cortex-m0/config_core.h b/core/cortex-m0/config_core.h index 9ef52f848a..63e6da8972 100644 --- a/core/cortex-m0/config_core.h +++ b/core/cortex-m0/config_core.h @@ -12,12 +12,11 @@ /* * Emulate the CLZ/CTZ instructions since the CPU core is lacking support. - * When building with clang, we rely on compiler_rt to provide this support. */ -#ifndef __clang__ +#ifndef USE_LLVM_COMPILER_RT #define CONFIG_SOFTWARE_CLZ #define CONFIG_SOFTWARE_CTZ -#endif /* __clang__ */ +#endif /* USE_LLVM_COMPILER_RT */ #define CONFIG_ASSEMBLY_MULA32 -- cgit v1.2.1 From 34c2f4848f64615fd4c70fb22aaa66025f6b3666 Mon Sep 17 00:00:00 2001 From: Michael5 Chen1 Date: Fri, 11 Nov 2022 14:24:36 +0800 Subject: marasov: Remove ALS and Tablet function Depend on design, no support ALS and tablet mode. 1. Remove ALS and Tablet function 2. Remove volume button BUG=b:258756919 BRANCH=brya TEST=make BOARD=marasov Signed-off-by: Michael5 Chen1 Change-Id: Idb74f4ebaf162e8ee3c0e67c4c587f2017377225 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022387 Code-Coverage: Zoss Commit-Queue: Kyle Lin Reviewed-by: Kyle Lin Reviewed-by: Jeffrey Lin --- board/marasov/board.h | 47 +-------- board/marasov/ec.tasklist | 1 - board/marasov/generated-gpio.inc | 12 +-- board/marasov/sensors.c | 205 --------------------------------------- 4 files changed, 10 insertions(+), 255 deletions(-) diff --git a/board/marasov/board.h b/board/marasov/board.h index 2f027deafc..67e3ecd8c9 100644 --- a/board/marasov/board.h +++ b/board/marasov/board.h @@ -38,40 +38,10 @@ #define CONFIG_LED_PWM_SOC_SUSPEND_COLOR EC_LED_COLOR_WHITE #define CONFIG_LED_PWM_LOW_BATT_COLOR EC_LED_COLOR_AMBER -/* Sensors */ -#define CONFIG_ACCELGYRO_LSM6DSO /* Base accel */ -#define CONFIG_ACCEL_LSM6DSO_INT_EVENT \ - TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) - -/* TCS3400 ALS */ -#define CONFIG_ALS -#define ALS_COUNT 1 -#define CONFIG_ALS_TCS3400 -#define CONFIG_ALS_TCS3400_INT_EVENT \ - TASK_EVENT_MOTION_SENSOR_INTERRUPT(CLEAR_ALS) - -/* Enable sensor fifo, must also define the _SIZE and _THRES */ -#define CONFIG_ACCEL_FIFO -/* FIFO size is in power of 2. */ -#define CONFIG_ACCEL_FIFO_SIZE 256 -/* Depends on how fast the AP boots and typical ODRs */ -#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3) - -/* Sensors without hardware interrupt are in forced mode */ -#define CONFIG_ACCEL_FORCE_MODE_MASK BIT(CLEAR_ALS) - -/* Lid accel */ -#define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_UPDATE -#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL -#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL -#define CONFIG_ACCEL_LIS2DWL -#define CONFIG_ACCEL_LIS2DW12_INT_EVENT \ - TASK_EVENT_MOTION_SENSOR_INTERRUPT(LID_ACCEL) - -/* Sensor console commands */ -#define CONFIG_CMD_ACCELS -#define CONFIG_CMD_ACCEL_INFO +#undef CONFIG_TABLET_MODE +#undef CONFIG_TABLET_MODE_SWITCH +#undef CONFIG_GMR_TABLET_MODE +#undef CONFIG_VOLUME_BUTTONS /* USB Type A Features */ #define USB_PORT_COUNT 1 @@ -235,15 +205,6 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; -enum sensor_id { - LID_ACCEL = 0, - BASE_ACCEL, - BASE_GYRO, - CLEAR_ALS, - RGB_ALS, - SENSOR_COUNT -}; - enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT }; enum battery_type { BATTERY_POWER_TECH, BATTERY_LGC011, BATTERY_TYPE_COUNT }; diff --git a/board/marasov/ec.tasklist b/board/marasov/ec.tasklist index 73ccfb584a..e3087d1d5f 100644 --- a/board/marasov/ec.tasklist +++ b/board/marasov/ec.tasklist @@ -17,7 +17,6 @@ TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 0, TASK_STACK_SIZE) \ TASK_ALWAYS(USB_CHG_P2, usb_charger_task, 0, TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, BASEBOARD_CHARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, BASEBOARD_CHIPSET_TASK_STACK_SIZE) \ TASK_ALWAYS(USB_MUX, usb_mux_task, NULL, VENTI_TASK_STACK_SIZE) \ diff --git a/board/marasov/generated-gpio.inc b/board/marasov/generated-gpio.inc index f4772188a5..eacb89a804 100644 --- a/board/marasov/generated-gpio.inc +++ b/board/marasov/generated-gpio.inc @@ -4,12 +4,7 @@ /* INTERRUPT GPIOs: */ GPIO_INT(ACOK_OD, PIN(0, 0), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, extpower_interrupt) -GPIO_INT(EC_ACCEL_INT_R_L, PIN(8, 1), GPIO_SEL_1P8V | GPIO_INT_FALLING, lis2dw12_interrupt) -GPIO_INT(EC_ALS_RGB_INT_R_L, PIN(D, 4), GPIO_INT_FALLING, tcs3400_interrupt) -GPIO_INT(EC_IMU_INT_R_L, PIN(5, 6), GPIO_SEL_1P8V | GPIO_INT_FALLING, lsm6dso_interrupt) GPIO_INT(EC_PROCHOT_IN_L, PIN(F, 0), GPIO_INT_BOTH, throttle_ap_prochot_input_interrupt) -GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) -GPIO_INT(EC_VOLUP_BTN_ODL, PIN(9, 7), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) GPIO_INT(EC_WP_ODL, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) GPIO_INT(GSC_EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH | GPIO_HIB_WAKE_LOW, power_button_interrupt) GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, lid_interrupt) @@ -19,7 +14,6 @@ GPIO_INT(SEQ_EC_RSMRST_ODL, PIN(E, 2), GPIO_INT_BOTH, power_signal_ GPIO_INT(SLP_S3_L, PIN(A, 5), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(SLP_SUS_L, PIN(F, 1), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(SYS_SLP_S0IX_L, PIN(D, 5), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(TABLET_MODE_L, PIN(9, 5), GPIO_INT_BOTH, gmr_tablet_switch_isr) GPIO_INT(USB_C0_BC12_INT_ODL, PIN(C, 6), GPIO_INT_FALLING, bc12_interrupt) GPIO_INT(USB_C0_C2_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event) GPIO_INT(USB_C0_PPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, ppc_interrupt) @@ -121,5 +115,11 @@ UNUSED(PIN(3, 2)) /* GPO32/TRIS_L */ UNUSED(PIN(3, 5)) /* GPO35/CR_SOUT4/TEST_L */ UNUSED(PIN(6, 6)) /* GPIO66 */ UNUSED(PIN(5, 7)) /* GPIO57/SER_IRQ/ESPI_ALERT_L */ +UNUSED(PIN(9, 5)) /* GPIO95 */ +UNUSED(PIN(8, 1)) /* GPIO81 */ +UNUSED(PIN(5, 6)) /* GPIO56 */ +UNUSED(PIN(D, 4)) /* GPIOD4 */ +UNUSED(PIN(9, 3)) /* GPIO93 */ +UNUSED(PIN(9, 7)) /* GPIO97 */ /* Pre-configured PSL balls: J8 K6 */ diff --git a/board/marasov/sensors.c b/board/marasov/sensors.c index 10c580de5d..2a25141639 100644 --- a/board/marasov/sensors.c +++ b/board/marasov/sensors.c @@ -4,14 +4,9 @@ */ #include "common.h" -#include "accelgyro.h" #include "adc.h" -#include "driver/accel_lis2dw12.h" -#include "driver/accelgyro_lsm6dso.h" -#include "driver/als_tcs3400_public.h" #include "gpio.h" #include "hooks.h" -#include "motion_sense.h" #include "temp_sensor.h" #include "thermal.h" #include "temp_sensor/thermistor.h" @@ -49,206 +44,6 @@ struct adc_t adc_channels[] = { }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); -K_MUTEX_DEFINE(g_lid_accel_mutex); -K_MUTEX_DEFINE(g_base_accel_mutex); -static struct stprivate_data g_lis2dw12_data; -static struct lsm6dso_data lsm6dso_data; - -/* TODO(b/184779333): calibrate the orientation matrix on later board stage */ -static const mat33_fp_t lid_standard_ref = { { 0, FLOAT_TO_FP(1), 0 }, - { FLOAT_TO_FP(1), 0, 0 }, - { 0, 0, FLOAT_TO_FP(-1) } }; - -/* TODO(b/184779743): verify orientation matrix */ -static const mat33_fp_t base_standard_ref = { { FLOAT_TO_FP(1), 0, 0 }, - { 0, FLOAT_TO_FP(-1), 0 }, - { 0, 0, FLOAT_TO_FP(-1) } }; - -/* TCS3400 private data */ -static struct als_drv_data_t g_tcs3400_data = { - .als_cal.scale = 1, - .als_cal.uscale = 0, - .als_cal.offset = 0, - .als_cal.channel_scale = { - .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kc from VPD */ - .cover_scale = ALS_CHANNEL_SCALE(1.0), /* CT */ - }, -}; - -/* - * TODO: b/184702900 need to calibrate ALS/RGB sensor. At default settings, - * shining phone flashlight on sensor pegs all readings at 0xFFFF. - */ -static struct tcs3400_rgb_drv_data_t g_tcs3400_rgb_data = { - .calibration.rgb_cal[X] = { - .offset = 0, - .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(1.0), - .scale = { - .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kr */ - .cover_scale = ALS_CHANNEL_SCALE(1.0) - } - }, - .calibration.rgb_cal[Y] = { - .offset = 0, - .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(1.0), - .scale = { - .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kg */ - .cover_scale = ALS_CHANNEL_SCALE(1.0) - }, - }, - .calibration.rgb_cal[Z] = { - .offset = 0, - .coeff[TCS_RED_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_GREEN_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_BLUE_COEFF_IDX] = FLOAT_TO_FP(0), - .coeff[TCS_CLEAR_COEFF_IDX] = FLOAT_TO_FP(1.0), - .scale = { - .k_channel_scale = ALS_CHANNEL_SCALE(1.0), /* kb */ - .cover_scale = ALS_CHANNEL_SCALE(1.0) - } - }, - .calibration.irt = INT_TO_FP(1), - .saturation.again = TCS_DEFAULT_AGAIN, - .saturation.atime = TCS_DEFAULT_ATIME, -}; - -struct motion_sensor_t motion_sensors[] = { - [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LIS2DW12, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &lis2dw12_drv, - .mutex = &g_lid_accel_mutex, - .drv_data = &g_lis2dw12_data, - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LIS2DW12_ADDR0, - .rot_standard_ref = &lid_standard_ref, /* identity matrix */ - .default_range = 2, /* g */ - .min_frequency = LIS2DW12_ODR_MIN_VAL, - .max_frequency = LIS2DW12_ODR_MAX_VAL, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - }, - /* Sensor on for lid angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - }, - }, - }, - - [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSO, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dso_drv, - .mutex = &g_base_accel_mutex, - .drv_data = LSM6DSO_ST_DATA(lsm6dso_data, - MOTIONSENSE_TYPE_ACCEL), - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS, - .rot_standard_ref = &base_standard_ref, - .default_range = 4, /* g */ - .min_frequency = LSM6DSO_ODR_MIN_VAL, - .max_frequency = LSM6DSO_ODR_MAX_VAL, - .config = { - [SENSOR_CONFIG_EC_S0] = { - .odr = 13000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, - }, - - [BASE_GYRO] = { - .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSO, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &lsm6dso_drv, - .mutex = &g_base_accel_mutex, - .drv_data = LSM6DSO_ST_DATA(lsm6dso_data, - MOTIONSENSE_TYPE_GYRO), - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = LSM6DSO_ADDR0_FLAGS, - .default_range = 1000 | ROUND_UP_FLAG, /* dps */ - .rot_standard_ref = &base_standard_ref, - .min_frequency = LSM6DSO_ODR_MIN_VAL, - .max_frequency = LSM6DSO_ODR_MAX_VAL, - }, - - [CLEAR_ALS] = { - .name = "Clear Light", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_TCS3400, - .type = MOTIONSENSE_TYPE_LIGHT, - .location = MOTIONSENSE_LOC_CAMERA, - .drv = &tcs3400_drv, - .drv_data = &g_tcs3400_data, - .port = I2C_PORT_SENSOR, - .i2c_spi_addr_flags = TCS3400_I2C_ADDR_FLAGS, - .rot_standard_ref = NULL, - .default_range = 0x10000, /* scale = 1x, uscale = 0 */ - .min_frequency = TCS3400_LIGHT_MIN_FREQ, - .max_frequency = TCS3400_LIGHT_MAX_FREQ, - .config = { - /* Run ALS sensor in S0 */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 1000, - }, - }, - }, - - [RGB_ALS] = { - /* - * RGB channels read by CLEAR_ALS and so the i2c port and - * address do not need to be defined for RGB_ALS. - */ - .name = "RGB Light", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_TCS3400, - .type = MOTIONSENSE_TYPE_LIGHT_RGB, - .location = MOTIONSENSE_LOC_CAMERA, - .drv = &tcs3400_rgb_drv, - .drv_data = &g_tcs3400_rgb_data, - .rot_standard_ref = NULL, - .default_range = 0x10000, /* scale = 1x, uscale = 0 */ - }, -}; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - -/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */ -const struct motion_sensor_t *motion_als_sensors[] = { - &motion_sensors[CLEAR_ALS], -}; -BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT); - -static void baseboard_sensors_init(void) -{ - /* Enable gpio interrupt for lid accel sensor */ - gpio_enable_interrupt(GPIO_EC_ACCEL_INT_R_L); - /* Enable interrupt for the TCS3400 color light sensor */ - gpio_enable_interrupt(GPIO_EC_ALS_RGB_INT_R_L); - /* Enable gpio interrupt for base accelgyro sensor */ - gpio_enable_interrupt(GPIO_EC_IMU_INT_R_L); -} -DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_INIT_I2C + 1); - /* Temperature sensor configuration */ const struct temp_sensor_t temp_sensors[] = { [TEMP_SENSOR_1_DDR_SOC] = { -- cgit v1.2.1 From c4c6efecf1c8787befe7eb0aaaec59ff0f115e76 Mon Sep 17 00:00:00 2001 From: Andrew McRae Date: Wed, 9 Nov 2022 16:32:52 +1100 Subject: update_release_branch: Add support for Zephyr based boards Add support for Zephyr based projects: - Add srcbase option for source directory base (requires SDK) - Add multiple repo handling - Use appropriate defaults for Zephyr - Use correct branch name and remote branch names - Skip repo if no changes (cmsis doesn't change much) BUG=b:257145337 TEST=Run with nissa firmware branch BRANCH=none Signed-off-by: Andrew McRae Change-Id: I7070afd2dca11b9afe0891900d1f209b749b3525 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4015604 Reviewed-by: Aseda Aboagye Code-Coverage: Zoss --- util/update_release_branch.py | 338 +++++++++++++++++++++++++++--------------- 1 file changed, 222 insertions(+), 116 deletions(-) diff --git a/util/update_release_branch.py b/util/update_release_branch.py index 0a871724fe..591c833ea1 100755 --- a/util/update_release_branch.py +++ b/util/update_release_branch.py @@ -137,6 +137,8 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths): A tuple containing the arguments passed to the git log command and stdout. """ + if not relevant_paths: + return "", "" if fmt: cmd = [ "git", @@ -159,6 +161,128 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths): return "".join(proc.args), proc.stdout +def merge_repo( + base, cros_main, cmd_checkout, strategy, cmd, prunelist, relevant_paths +): + """Merge changes from ToT into this repo's branch. + + For this repo, merge the changes from ToT to the branch set + in the merge command. + + Args: + base: String indicating the Source directory of repo. + cros_main: String indicating the origin branch name + cmd_checkout: String list containing the checkout command to use. + strategy: String list containing the merge strategy, + cmd: String containing the command line + prunelist: String list containing the files to remove. + relevant_paths: String containing all the relevant paths for this + particular baseboard or board. + """ + # Change directory to the repo being merged + print('Starting merge in "%s"' % base) + print('Checkout command: "%s"' % " ".join(cmd_checkout)) + os.chdir(base) + # Check if we are already in merge process + result = subprocess.run( + ["git", "rev-parse", "--quiet", "--verify", "MERGE_HEAD"], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + check=False, + ) + + if result.returncode: + # Let's perform the merge + print("Updating remote...") + subprocess.run(["git", "remote", "update"], check=True) + subprocess.run(cmd_checkout, check=True) + cmd_merge = [ + "git", + "merge", + "--no-ff", + "--no-commit", + cros_main, + "-s", + ] + cmd_merge.extend(strategy) + print('Merge command: "%s"' % " ".join(cmd_merge)) + try: + subprocess.run(cmd_merge, check=True) + except: + # We've likely encountered a merge conflict due to new OWNERS file + # modifications. If we're removing the owners, we'll delete them. + if prunelist: + # Find the unmerged files + unmerged = ( + subprocess.run( + ["git", "diff", "--name-only", "--diff-filter=U"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ) + .stdout.rstrip() + .split() + ) + + # Prune OWNERS files + for file in unmerged: + if file in prunelist: + subprocess.run(["git", "rm", file], check=False) + unmerged.remove(file) + + print("Removed non-root OWNERS files.") + if unmerged: + print( + "Unmerged files still exist! You need to manually resolve this." + ) + print("\n".join(unmerged)) + sys.exit(1) + else: + raise + else: + print( + "We have already started merge process.", + "Attempt to generate commit.", + ) + # Check whether any commit is needed. + changes = subprocess.run( + ["git", "status", "--porcelain"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ).stdout.rstrip() + if not changes: + print("No changes have been found, skipping commit.") + return + + print("Generating commit message...") + branch = subprocess.run( + ["git", "rev-parse", "--abbrev-ref", "HEAD"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ).stdout.rstrip() + head = subprocess.run( + ["git", "rev-parse", "--short", "HEAD"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ).stdout.rstrip() + merge_head = subprocess.run( + ["git", "rev-parse", "--short", "MERGE_HEAD"], + stdout=subprocess.PIPE, + encoding="utf-8", + check=True, + ).stdout.rstrip() + + print("Typing as fast as I can...") + commit_msg = git_commit_msg( + cros_main, branch, head, merge_head, relevant_paths, cmd + ) + subprocess.run(["git", "commit", "--signoff", "-m", commit_msg], check=True) + subprocess.run(["git", "commit", "--amend"], check=True) + + def main(argv): """Generates a merge commit from ToT to a desired release branch. @@ -186,7 +310,11 @@ def main(argv): parser.add_argument("--baseboard") parser.add_argument("--board") parser.add_argument( - "release_branch", help=("The name of the target release" " branch") + "release_branch", + help=( + "The name of the target release branch, " + "without the trailing '-main'." + ), ) parser.add_argument( "--remote_prefix", @@ -196,6 +324,11 @@ def main(argv): ), default="cros", ) + parser.add_argument( + "--srcbase", + help=("The base directory where the src tree exists."), + default="/mnt/host/source/", + ) parser.add_argument( "--relevant_paths_file", help=( @@ -213,7 +346,7 @@ def main(argv): parser.add_argument( "--strategy_option", "-X", - help=("The strategy option for the chosen merge " "strategy"), + help=("The strategy option for the chosen merge strategy"), ) parser.add_argument( "--remove_owners", @@ -221,6 +354,12 @@ def main(argv): action=("store_true"), help=("Remove non-root OWNERS level files if present"), ) + parser.add_argument( + "--zephyr", + "-z", + action=("store_true"), + help=("If set, treat the board as a Zephyr based program"), + ) opts = parser.parse_args(argv[1:]) @@ -228,17 +367,24 @@ def main(argv): board_dir = "" if opts.baseboard: + # If a zephyr board, no baseboard allowed + if opts.zephyr: + raise Exception("--baseboard not allowed for Zephyr boards") # Dereference symlinks so "git log" works as expected. baseboard_dir = os.path.relpath("baseboard/" + opts.baseboard) baseboard_dir = os.path.relpath(os.path.realpath(baseboard_dir)) boards = get_relevant_boards(opts.baseboard) elif opts.board: - board_dir = os.path.relpath("board/" + opts.board) + if opts.zephyr: + board_dir = os.path.relpath("zephyr/program/" + opts.board) + else: + board_dir = os.path.relpath("board/" + opts.board) board_dir = os.path.relpath(os.path.realpath(board_dir)) boards = [opts.board] else: - boards = [] + # With no board or baseboard, not sure whether this should proceed + raise Exception("no board or baseboard specified") print("Gathering relevant paths...") relevant_paths = [] @@ -247,10 +393,12 @@ def main(argv): elif opts.board: relevant_paths.append(board_dir) - for board in boards: - relevant_paths.append("board/" + board) + if not opts.zephyr: + for board in boards: + relevant_paths.append("board/" + board) # Check for the existence of a file that has other paths of interest. + # Also check for 'relevant-paths.txt' in the board directory if opts.relevant_paths_file and os.path.exists(opts.relevant_paths_file): with open(opts.relevant_paths_file, "r") as relevant_paths_file: for line in relevant_paths_file: @@ -260,17 +408,9 @@ def main(argv): relevant_paths.append("util/getversion.sh") relevant_paths = " ".join(relevant_paths) - # Check if we are already in merge process - result = subprocess.run( - ["git", "rev-parse", "--quiet", "--verify", "MERGE_HEAD"], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - check=False, - ) - # Prune OWNERS files if desired + prunelist = [] if opts.remove_owners: - prunelist = [] for root, dirs, files in os.walk("."): for name in dirs: if "build" in name: @@ -291,112 +431,78 @@ def main(argv): for path in prunelist: print(" " + path) - if result.returncode: - # Let's perform the merge - print("Updating remote...") - subprocess.run(["git", "remote", "update"], check=True) - subprocess.run( - [ - "git", - "checkout", - "-B", - opts.release_branch, - opts.remote_prefix + "/" + opts.release_branch, - ], - check=True, - ) - print("Attempting git merge...") - if opts.merge_strategy == "recursive" and not opts.strategy_option: - opts.strategy_option = "theirs" - print( - 'Using "%s" merge strategy' % opts.merge_strategy, - ( - "with strategy option '%s'" % opts.strategy_option - if opts.strategy_option - else "" - ), - ) - cros_main = opts.remote_prefix + "/" + "main" - arglist = [ + # Create the merge and checkout commands to use. + cmd_checkout = [ + "git", + "checkout", + "-B", + opts.release_branch, + opts.remote_prefix + "/" + opts.release_branch, + ] + if opts.merge_strategy == "recursive" and not opts.strategy_option: + opts.strategy_option = "theirs" + print( + 'Using "%s" merge strategy' % opts.merge_strategy, + ( + "with strategy option '%s'" % opts.strategy_option + if opts.strategy_option + else "" + ), + ) + cros_main = opts.remote_prefix + "/" + "main" + strategy = [ + opts.merge_strategy, + ] + if opts.strategy_option: + strategy.append("-X" + opts.strategy_option) + cmd = " ".join(argv) + + # Merge each of the repos + merge_repo( + os.path.join(opts.srcbase, "src/platform/ec"), + cros_main, + cmd_checkout, + strategy, + cmd, + prunelist, + relevant_paths, + ) + if opts.zephyr: + # Strip off any trailing -main or -master from branch name + if opts.release_branch.endswith("-main"): + opts.release_branch = opts.release_branch[:-5] + if opts.release_branch.endswith("-master"): + opts.release_branch = opts.release_branch[:-7] + cmd_checkout = [ "git", - "merge", - "--no-ff", - "--no-commit", - cros_main, - "-s", - opts.merge_strategy, + "checkout", + "-B", + opts.release_branch, + opts.remote_prefix + "/" + opts.release_branch, ] - if opts.strategy_option: - arglist.append("-X" + opts.strategy_option) - try: - subprocess.run(arglist, check=True) - except: - # We've likely encountered a merge conflict due to new OWNERS file - # modifications. If we're removing the owners, we'll delete them. - if opts.remove_owners and prunelist: - # Find the unmerged files - unmerged = ( - subprocess.run( - ["git", "diff", "--name-only", "--diff-filter=U"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ) - .stdout.rstrip() - .split() - ) - - # Prune OWNERS files - for file in unmerged: - if file in prunelist: - subprocess.run(["git", "rm", file], check=False) - unmerged.remove(file) - - print("Removed non-root OWNERS files.") - if unmerged: - print( - "Unmerged files still exist! You need to manually resolve this." - ) - print("\n".join(unmerged)) - sys.exit(1) - else: - raise - else: - print( - "We have already started merge process.", - "Attempt to generate commit.", + merge_repo( + os.path.join(opts.srcbase, "src/third_party/zephyr/main"), + cros_main, + cmd_checkout, + strategy, + cmd, + [], + [], + ) + # cmsis repo has different remote + cros_main = opts.remote_prefix + "/" + "chromeos-main" + merge_repo( + os.path.join(opts.srcbase, "src/third_party/zephyr/cmsis"), + cros_main, + cmd_checkout, + strategy, + cmd, + [], + [], ) - - print("Generating commit message...") - branch = subprocess.run( - ["git", "rev-parse", "--abbrev-ref", "HEAD"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ).stdout.rstrip() - head = subprocess.run( - ["git", "rev-parse", "--short", "HEAD"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ).stdout.rstrip() - merge_head = subprocess.run( - ["git", "rev-parse", "--short", "MERGE_HEAD"], - stdout=subprocess.PIPE, - encoding="utf-8", - check=True, - ).stdout.rstrip() - - cmd = " ".join(argv) - print("Typing as fast as I can...") - commit_msg = git_commit_msg( - cros_main, branch, head, merge_head, relevant_paths, cmd - ) - subprocess.run(["git", "commit", "--signoff", "-m", commit_msg], check=True) - subprocess.run(["git", "commit", "--amend"], check=True) print( ( - "Finished! **Please review the commit to see if it's to your " + "Finished! **Please review the commit(s) to see if they're to your " "liking.**" ) ) -- cgit v1.2.1 From dee200cbf6ec74e3723aca93816b0f82147d50fd Mon Sep 17 00:00:00 2001 From: Liam Flaherty Date: Mon, 14 Nov 2022 16:47:19 +1100 Subject: dibbi: Update power and recovery buttons Update the config of power and recovery buttons from waddledee reference to support dibbi. BUG=b:257377036 BRANCH=dedede TEST=make -j BOARD=dedede Signed-off-by: Liam Flaherty Change-Id: If66a570eca4b78db11e3177f1090ca7fb8b8634d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025387 Code-Coverage: Zoss Reviewed-by: Adam Mills Reviewed-by: Sam McNally --- board/dibbi/board.h | 10 +++++++++- board/dibbi/gpio.inc | 8 +++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/board/dibbi/board.h b/board/dibbi/board.h index 8a11b01996..166b9d6fbf 100644 --- a/board/dibbi/board.h +++ b/board/dibbi/board.h @@ -72,12 +72,15 @@ #undef GPIO_ENABLE_BACKLIGHT /* Buttons */ +#define CONFIG_DEDICATED_RECOVERY_BUTTON +#define CONFIG_DEDICATED_RECOVERY_BUTTON_2 +#define CONFIG_POWER_BUTTON #define CONFIG_POWER_BUTTON_IGNORE_LID +#define CONFIG_POWER_BUTTON_X86 /* Unused features - Misc */ #undef CONFIG_VOLUME_BUTTONS #undef CONFIG_LID_SWITCH - #undef CONFIG_TABLET_MODE #undef CONFIG_TABLET_MODE_SWITCH #undef CONFIG_GMR_TABLET_MODE @@ -86,6 +89,11 @@ /* Unused GPIOs */ #undef GPIO_USB_C1_DP_HPD +/* Pin renaming */ +#define GPIO_RECOVERY_L GPIO_EC_RECOVERY_BTN_ODL +#define GPIO_RECOVERY_L_2 GPIO_H1_EC_RECOVERY_BTN_ODL +#define GPIO_POWER_BUTTON_L GPIO_H1_EC_PWR_BTN_ODL + #ifndef __ASSEMBLER__ #include "gpio_signal.h" diff --git a/board/dibbi/gpio.inc b/board/dibbi/gpio.inc index 9f98e2171b..313eda46c9 100644 --- a/board/dibbi/gpio.inc +++ b/board/dibbi/gpio.inc @@ -38,6 +38,10 @@ GPIO_INT(USB_C0_CCSBU_OVP_ODL, PIN(K, 6), GPIO_INT_FALLING | GPIO_PULL_UP, c0_cc /* TODO(b/257833880) PIN(I, 7) changed from VOLUP_BTN_ODL to EN_USB_C0_VBUS */ /* TODO(b/257377326) PIN(J, 0) changed from BASE_SIXAXIS_INT_L to EN_PVAR_BJ_ADP_L */ GPIO_INT(EC_WP_OD, PIN(A, 6), GPIO_INT_BOTH, switch_interrupt) +/* Directly connected recovery button */ +GPIO_INT(EC_RECOVERY_BTN_ODL, PIN(K, 7), GPIO_INT_BOTH, button_interrupt) +/* Recovery button input from H1 */ +GPIO_INT(H1_EC_RECOVERY_BTN_ODL, PIN(K, 4), GPIO_INT_BOTH, button_interrupt) /* Power sequence GPIOs */ GPIO(EC_AP_RTCRST, PIN(K, 2), GPIO_OUT_LOW) @@ -78,7 +82,6 @@ GPIO(EC_I2C_USB_C0_SDA, PIN(A, 5), GPIO_INPUT) GPIO(EN_USB_C0_CC1_VCONN, PIN(H, 4), GPIO_OUT_LOW) GPIO(EN_USB_C0_CC2_VCONN, PIN(H, 6), GPIO_OUT_LOW) GPIO(EC_AP_USB_C0_HPD, PIN(L, 4), GPIO_OUT_LOW) -/* TODO(b/257377036) PIN(K, 7) changed from EC_AP_USB_C1_HDMI_HPD to EC_RECOVERY_BUTTON_ODL */ GPIO(USB_C0_FRS, PIN(C, 4), GPIO_OUT_LOW) GPIO(HDMI_SEL_L, PIN(C, 6), GPIO_OUT_HIGH) GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW) /* Board rev 1, NC board rev 0 */ @@ -94,11 +97,10 @@ GPIO(EC_SUB_IO_2_1, PIN(F, 1), GPIO_INPUT) GPIO(EC_SUB_IO_2_2, PIN(L, 2), GPIO_INPUT) /* Misc */ -/* TODO(b/257377036) PIN(K, 4) changed from EN_BL_OD to EC_RECOVERY_BUTTON_ODL */ GPIO(EC_ENTERING_RW, PIN(G, 0), GPIO_OUT_LOW) GPIO(CCD_MODE_ODL, PIN(H, 5), GPIO_ODR_HIGH) GPIO(EC_BATTERY_PRES_ODL, PIN(I, 4), GPIO_INPUT) -/* TODO(b/257377036) PIN(J, 1) changed from PEN_DET_ODL to EN_PPVAR_USBC_ADP_L */ +/* TODO(b/257377326) PIN(J, 1) changed from PEN_DET_ODL to EN_PPVAR_USBC_ADP_L */ GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW) -- cgit v1.2.1 From 63ec16038cd533f3d7cb8d889a50bd47a682bf55 Mon Sep 17 00:00:00 2001 From: Deepti Deshatty Date: Thu, 10 Nov 2022 16:07:10 +0530 Subject: craask: resolve power leakage following nivviks. Resolve power leakage following nivviks. CL : 3788018 BUG=b:258613461 TEST=zmake build craask BRANCH=none Change-Id: I41bef1259990985820db6543fa342144f912d174 Signed-off-by: Deepti Deshatty Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4020016 Reviewed-by: Andrew McRae Code-Coverage: Zoss Reviewed-by: Poornima Tom --- zephyr/program/nissa/craask/overlay.dtsi | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/zephyr/program/nissa/craask/overlay.dtsi b/zephyr/program/nissa/craask/overlay.dtsi index 3aa95ea7fc..cbfda0263e 100644 --- a/zephyr/program/nissa/craask/overlay.dtsi +++ b/zephyr/program/nissa/craask/overlay.dtsi @@ -251,6 +251,31 @@ compatible = "cros-ec,kblight-pwm"; pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>; }; + + /* + * Declare unused GPIOs so that they are shut down + * and use minimal power + */ + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio3 2 0>, + <&gpio3 3 0>, + <&gpio3 5 0>, + <&gpio3 6 0>, + <&gpio5 7 0>, + <&gpio6 0 0>, + <&gpio6 3 0>, + <&gpio6 6 0>, + <&gpio7 3 0>, + <&gpio8 3 0>, + <&gpio8 6 0>, + <&gpiob 1 0>, + <&gpiob 7 0>, + <&gpioc 7 0>, + <&gpiof 2 0>, + <&gpiof 3 0>; + }; }; &thermistor_3V3_51K1_47K_4050B { @@ -352,3 +377,13 @@ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; pinctrl-names = "default"; }; + +/* + * Declare GPIOs that have leakage current caused by board issues here. NPCX ec + * will disable their input buffers before entering deep sleep and restore them + * after waking up automatically for better power consumption. + */ +&power_leakage_io { + leak-gpios = <&gpioa 4 0 + &gpiof 1 0>; +}; -- cgit v1.2.1 From 56d3176ac2fdf244ab38f4488c6b51443683def3 Mon Sep 17 00:00:00 2001 From: Raymond Chung Date: Mon, 14 Nov 2022 11:33:10 +0800 Subject: gaelin: Initial scaler configuration This change adds gpio and I2C settings for scaler. BUG=b:249000573, b:254063356 BRANCH=None TEST=make -j BOARD=gaelin Change-Id: If95e0b5529a46fae445343d53206ec65655f292c Signed-off-by: Raymond Chung Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025482 Reviewed-by: Derek Huang Code-Coverage: Zoss --- board/gaelin/board.h | 4 ++++ board/gaelin/gpio.inc | 22 ++++++++++++++++------ board/gaelin/i2c.c | 8 ++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/board/gaelin/board.h b/board/gaelin/board.h index 2ce5008bd7..166f0f1432 100644 --- a/board/gaelin/board.h +++ b/board/gaelin/board.h @@ -82,6 +82,8 @@ #define GPIO_RECOVERY_L_2 GPIO_GSC_EC_RECOVERY_BTN_OD /* I2C Bus Configuration */ +#define I2C_PORT_SCALER NPCX_I2C_PORT5_0 + #define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0 #define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1 @@ -98,6 +100,8 @@ #define I2C_ADDR_MP2964_FLAGS 0x20 +#define I2C_ADDR_SCALER_FLAGS 0x58 + /* Thermal features */ #define CONFIG_THERMISTOR #define CONFIG_TEMP_SENSOR diff --git a/board/gaelin/gpio.inc b/board/gaelin/gpio.inc index c39d048e8d..fcd39ad8bc 100644 --- a/board/gaelin/gpio.inc +++ b/board/gaelin/gpio.inc @@ -45,8 +45,19 @@ GPIO(EN_PP5000_FAN, PIN(6, 1), GPIO_OUT_HIGH) GPIO(ANALOG_PPVAR_PWR_IN_IMON_EC, PIN(4, 2), GPIO_INPUT) /* Display */ -GPIO(DP_CONN_OC_ODL, PIN(2, 5), GPIO_INPUT) - +GPIO(EC_OVERRIDE_SCLR_EN, PIN(D, 4), GPIO_OUT_HIGH) +GPIO(EC_12VSC_EN, PIN(D, 2), GPIO_OUT_LOW) +GPIO(OSD_STS, PIN(4, 1), GPIO_INPUT) +GPIO(DISP_MODE, PIN(A, 0), GPIO_INPUT) +GPIO(PANEL_PWR_STS, PIN(9, 5), GPIO_INPUT) +GPIO(EN_SCLR_RAILS, PIN(0, 4), GPIO_INPUT) +GPIO(HDMI_5V_IN, PIN(9, 3), GPIO_INPUT) +GPIO(HDMI0_CABLE_DET, PIN(9, 6), GPIO_INPUT) +GPIO(WP_EC, PIN(C, 3), GPIO_INPUT) +GPIO(OSD_INT, PIN(0, 5), GPIO_INPUT) + +/* Audio */ +GPIO(EC_AMP_SD, PIN(5, 6), GPIO_OUT_LOW) /* BarrelJack */ GPIO(EN_PPVAR_BJ_ADP_L, PIN(0, 7), GPIO_OUT_LOW) @@ -77,6 +88,8 @@ GPIO(HDMI_CEC_OUT, PIN(D, 3), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) GPIO(HDMI_CEC_PULL_UP, PIN(C, 2), GPIO_OUT_HIGH) /* I2C SCL/SDA */ +GPIO(SMSCALER_CLK, PIN(3, 3), GPIO_INPUT) +GPIO(SMSCALER_DATA, PIN(3, 6), GPIO_INPUT) GPIO(EC_I2C_MISC_SCL_R, PIN(B, 3), GPIO_INPUT) GPIO(EC_I2C_MISC_SDA_R, PIN(B, 2), GPIO_INPUT) GPIO(EC_I2C_USB_C0_PPC_BC_SCL, PIN(9, 2), GPIO_INPUT) @@ -102,7 +115,6 @@ GPIO(USB_A_OC_SOC_L, PIN(8, 0), GPIO_OUT_HIGH) /* LED */ /* TODO(b/197471359): LED implementation */ -GPIO(LED_GREEN_L, PIN(C, 3), GPIO_OUT_LOW) GPIO(LED_RED_L, PIN(C, 4), GPIO_OUT_LOW) /* USBC */ @@ -143,14 +155,12 @@ UNUSED(PIN(3, 2)) /* GPO32/TRIS_L */ UNUSED(PIN(3, 5)) /* GPO35/CR_SOUT4/TEST_L */ UNUSED(PIN(6, 6)) /* GPIO66 */ UNUSED(PIN(8, 1)) /* GPIO81/PECI_DATA */ -UNUSED(PIN(5, 6)) /* GPIO56/CLKRUN# */ UNUSED(PIN(8, 6)) /* GPIO86/TXD/CR_SOUT2 */ UNUSED(PIN(1, 3)) /* KSO06/GPO13/GP_SEL# */ UNUSED(PIN(1, 2)) /* KSO07/GPO12/JEN# */ UNUSED(PIN(0, 6)) /* KSO11/GPIO06/P80_CLK */ -UNUSED(PIN(0, 4)) /* KSO13/GPIO04 */ UNUSED(PIN(B, 4)) /* GPIOB4/I2C0_SDA0 */ -UNUSED(PIN(0, 5)) /* KSO12/GPIO05 */ +UNUSED(PIN(2, 5)) /* KSI4/GPIO25/TRACECLK/GP_SCLK */ UNUSED(PIN(B, 5)) /* GPIOB5/I2C0_SCL0 */ UNUSED(PIN(8, 3)) /* KSO15/GPIO83 */ UNUSED(PIN(B, 1)) /* KSO17/GPIOB1/CR_SIN4 */ diff --git a/board/gaelin/i2c.c b/board/gaelin/i2c.c index b3bd2023c5..f9bfa11657 100644 --- a/board/gaelin/i2c.c +++ b/board/gaelin/i2c.c @@ -42,6 +42,14 @@ const struct i2c_port_t i2c_ports[] = { .scl = GPIO_EC_I2C_USB_C1_TCPC_SCL, .sda = GPIO_EC_I2C_USB_C1_TCPC_SDA, }, + { + /* I2C5 */ + .name = "scaler", + .port = I2C_PORT_SCALER, + .kbps = 400, + .scl = GPIO_SMSCALER_CLK, + .sda = GPIO_SMSCALER_DATA, + }, { /* I2C7 */ .name = "eeprom", -- cgit v1.2.1 From 9bee67504df027376ffdfee5ebbb0ec5b55745b7 Mon Sep 17 00:00:00 2001 From: Yu-An Chen Date: Tue, 15 Nov 2022 13:39:13 +0800 Subject: evoker: Update LED config Add br-color key to enable ectool led command can control LED color BUG=b:243477929 BRANCH=none TEST=manual check ectool led command working Signed-off-by: Yu-An Chen Change-Id: I4dc46cdef96e5e26acbc8ae384f51455394149f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022400 Code-Coverage: Zoss Reviewed-by: Sam Hurst Commit-Queue: Sam Hurst --- zephyr/program/herobrine/evoker/led_pins.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zephyr/program/herobrine/evoker/led_pins.dtsi b/zephyr/program/herobrine/evoker/led_pins.dtsi index ff2dc0e36c..7bbbea04d2 100644 --- a/zephyr/program/herobrine/evoker/led_pins.dtsi +++ b/zephyr/program/herobrine/evoker/led_pins.dtsi @@ -16,6 +16,7 @@ color_power_white: color-power-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_POWER_LED"; + br-color = "EC_LED_COLOR_WHITE"; led-pins = <&gpio_ec_chg_led_w_c1 1>; }; @@ -30,6 +31,7 @@ color_battery_amber: color-battery-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; led-pins = <&gpio_ec_chg_led_y_c0 1>, <&gpio_ec_chg_led_w_c0 0>, <&gpio_ec_chg_led_r_c0 0>; @@ -38,6 +40,7 @@ color_battery_white: color-battery-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; led-pins = <&gpio_ec_chg_led_y_c0 0>, <&gpio_ec_chg_led_w_c0 1>, <&gpio_ec_chg_led_r_c0 0>; @@ -46,6 +49,7 @@ color_battery_red: color-battery-red { led-color = "LED_RED"; led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_RED"; led-pins = <&gpio_ec_chg_led_y_c0 0>, <&gpio_ec_chg_led_w_c0 0>, <&gpio_ec_chg_led_r_c0 1>; -- cgit v1.2.1 From 9a8aa751b99cfead9ce29654d97318d3b2531741 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 4 Nov 2022 15:41:03 -0700 Subject: util: Add libec support libec needs a file descriptor for running commands. This comm_get_fd() API will allow us to use libec in ectool. Also add the necessary compile and link flags to use libec. BRANCH=none BUG=b:144959033 TEST=make buildall Signed-off-by: Tom Hughes Change-Id: I746e0ac6b9dc30d920bbda87e581a695d83fd300 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4009404 Reviewed-by: Bobby Casey Reviewed-by: Andrea Grandi Code-Coverage: Zoss --- Makefile.toolchain | 5 +++++ util/comm-dev.cc | 5 +++++ util/comm-host.h | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/Makefile.toolchain b/Makefile.toolchain index 181888ed8c..80896e3e40 100644 --- a/Makefile.toolchain +++ b/Makefile.toolchain @@ -229,6 +229,9 @@ LIBFTDIUSB_HOST_LDLIBS:=$(shell $(HOST_PKG_CONFIG) --libs lib${LIBFTDI_NAME} l LIBFTDIUSB_BUILD_CFLAGS:=$(shell $(BUILD_PKG_CONFIG) --cflags lib${LIBFTDI_NAME} libusb-1.0) LIBFTDIUSB_BUILD_LDLIBS:=$(shell $(BUILD_PKG_CONFIG) --libs lib${LIBFTDI_NAME} libusb-1.0) +LIBEC_HOST_CFLAGS:=$(shell $(HOST_PKG_CONFIG) --cflags libec) +LIBEC_HOST_LDLIBS:=$(shell $(HOST_PKG_CONFIG) --libs libec) + ifeq ($(TEST_FUZZ),y) LIBPROTOBUF_CFLAGS:=$(shell $(PKG_CONFIG) --cflags protobuf) LIBPROTOBUF_LDLIBS:=$(shell $(PKG_CONFIG) --libs protobuf) @@ -247,6 +250,7 @@ HOST_CFLAGS=$(HOST_CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) \ HOST_CFLAGS+=$(LIBFTDIUSB_HOST_CFLAGS) HOST_CFLAGS+=-DCHROMIUM_EC=$(EMPTY) HOST_CXXFLAGS=$(HOST_CFLAGS) -Wno-c99-designator +HOST_CXXFLAGS+=$(LIBEC_HOST_CFLAGS) ifneq (${SYSROOT},) LDFLAGS_EXTRA+=--sysroot=${SYSROOT} endif @@ -266,6 +270,7 @@ HOST_LDFLAGS=$(LIBFTDIUSB_HOST_LDLIBS) ifneq (${HOST_SYSROOT},) HOST_LDFLAGS+=--sysroot=${HOST_SYSROOT} endif +HOST_LDFLAGS+=$(LIBEC_HOST_LDLIBS) HOST_TEST_LDFLAGS=-Wl,-T core/host/host_exe.lds -lrt -pthread -rdynamic -lm\ -fuse-ld=bfd -no-pie \ $(if $(TEST_COVERAGE), --coverage,) \ diff --git a/util/comm-dev.cc b/util/comm-dev.cc index f6467492f9..bbb79a448c 100644 --- a/util/comm-dev.cc +++ b/util/comm-dev.cc @@ -292,3 +292,8 @@ int comm_init_dev(const char *device_name) return 0; } + +int comm_get_fd() +{ + return fd; +} diff --git a/util/comm-host.h b/util/comm-host.h index 907df3df96..0f07bb48f3 100644 --- a/util/comm-host.h +++ b/util/comm-host.h @@ -52,6 +52,14 @@ int comm_init_alt(int interfaces, const char *device_name, int i2c_bus); */ int comm_init_dev(const char *device_name); +/** + * Get the file descriptor associated with the dev interface. comm_init_dev + * must be called first in order for the file descriptor to be valid. + * + * @return file descriptor + */ +int comm_get_fd(void); + /** * Initialize input & output buffers * -- cgit v1.2.1 From 8d761517dcba7874655cabe06ffaf2fc761abbc0 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Thu, 10 Nov 2022 16:36:34 -0800 Subject: cortex-m mpu: illegal shift fix Shifting left by 32 is undefined behavior. An AND operation with mask of 0xffffffff is meaningless, so just avoid it. BUG=b:64477774 BRANCH=none TEST=none Signed-off-by: Boris Mittelberg Change-Id: Ibcb3359f453345caee01936c074a9c0ae5aff7dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021135 Tested-by: Peter Marheine Reviewed-by: Peter Marheine Code-Coverage: Zoss --- core/cortex-m/include/mpu_private.h | 1 + core/cortex-m/mpu.c | 16 ++++++++++++++-- test/mpu.c | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/core/cortex-m/include/mpu_private.h b/core/cortex-m/include/mpu_private.h index eca474e14d..eb9de4c395 100644 --- a/core/cortex-m/include/mpu_private.h +++ b/core/cortex-m/include/mpu_private.h @@ -21,5 +21,6 @@ int mpu_update_region(uint8_t region, uint32_t addr, uint8_t size_bit, int mpu_config_region(uint8_t region, uint32_t addr, uint32_t size, uint16_t attr, uint8_t enable); struct mpu_rw_regions mpu_get_rw_regions(void); +uint32_t align_down_to_bits(uint32_t addr, uint8_t addr_bits); #endif /* __CROS_EC_MPU_PRIVATE_H */ diff --git a/core/cortex-m/mpu.c b/core/cortex-m/mpu.c index c0793180dc..db03936dfa 100644 --- a/core/cortex-m/mpu.c +++ b/core/cortex-m/mpu.c @@ -94,6 +94,17 @@ int mpu_update_region(uint8_t region, uint32_t addr, uint8_t size_bit, return EC_SUCCESS; } +/* + * Align address to a maximum of 31 bits + */ +uint32_t align_down_to_bits(uint32_t addr, uint8_t addr_bits) +{ + if (addr_bits < 32) + return addr & ~((1u << addr_bits) - 1); + else + return addr; +} + /* * Greedily configure the largest possible part of the given region from the * base address. @@ -140,7 +151,7 @@ static int mpu_config_region_greedy(uint8_t region, uint32_t addr, * disabling if it is not completely contained in the requested * range. */ - subregion_base = addr & ~((1 << natural_alignment) - 1); + subregion_base = align_down_to_bits(addr, natural_alignment); subregion_size = 1 << (natural_alignment - 3); *consumed = 0; for (sr_idx = 0; sr_idx < 8; sr_idx++) { @@ -159,7 +170,8 @@ static int mpu_config_region_greedy(uint8_t region, uint32_t addr, *consumed = 1 << natural_alignment; } - return mpu_update_region(region, addr & ~((1 << natural_alignment) - 1), + return mpu_update_region(region, + align_down_to_bits(addr, natural_alignment), natural_alignment, attr, enable, subregion_disable); } diff --git a/test/mpu.c b/test/mpu.c index 2193c0c617..957111b901 100644 --- a/test/mpu.c +++ b/test/mpu.c @@ -3,6 +3,14 @@ * found in the LICENSE file. */ +/* This test file meant to be executed on a real device. Example: + * 1. make tests BOARD=bloonchipper + * 2. servod --board=bloonchipper + * 3. flash_ec --board bloonchipper --image build/bloonchipper/test-mpu.bin + * 4. Open console via dut-control raw_fpmcu_console_uart_pty + * 5. runtest on console + */ + #include #include "mpu.h" #include "mpu_private.h" @@ -172,6 +180,19 @@ test_static int test_mpu_get_rw_regions(void) return EC_SUCCESS; } +test_static int test_align_down_to_bits(void) +{ + uint32_t addr = 0x87654321; + + TEST_EQ(align_down_to_bits(addr, 0), addr, "%d"); + TEST_EQ(align_down_to_bits(addr, 1), 0x87654320, "%d"); + TEST_EQ(align_down_to_bits(addr, 30), 0x80000000, "%d"); + TEST_EQ(align_down_to_bits(addr, 31), 0x80000000, "%d"); + TEST_EQ(align_down_to_bits(addr, 32), addr, "%d"); + TEST_EQ(align_down_to_bits(addr, 33), addr, "%d"); + return EC_SUCCESS; +} + void run_test(int argc, const char **argv) { enum ec_image cur_image = system_get_image_copy(); @@ -211,6 +232,8 @@ void run_test(int argc, const char **argv) RUN_TEST(reset_mpu); RUN_TEST(test_mpu_get_rw_regions); RUN_TEST(reset_mpu); + RUN_TEST(test_align_down_to_bits); + RUN_TEST(reset_mpu); /* This test must be last because it generates a panic */ RUN_TEST(test_mpu_update_region_valid_region); RUN_TEST(reset_mpu); -- cgit v1.2.1 From b1768ba9ad0099b32dc927ce7a0a5132489f6520 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Sat, 29 Sep 2018 07:09:33 -0700 Subject: nocturne: Enable FPU In preparation for magnetometer support, add FPU support. BUG=b:110143516 BRANCH=nocturne TEST=compile Change-Id: I45ab514b45715f1796800669f7e79bfa36f3ae79 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1252447 Reviewed-by: Aseda Aboagye Code-Coverage: Zoss --- board/nocturne/board.h | 1 + 1 file changed, 1 insertion(+) diff --git a/board/nocturne/board.h b/board/nocturne/board.h index 1b2280a6e9..9f54c1a51d 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -33,6 +33,7 @@ #define CONFIG_ADC #define CONFIG_BACKLIGHT_LID #define CONFIG_HOST_INTERFACE_ESPI +#define CONFIG_FPU #define CONFIG_I2C #define CONFIG_I2C_BUS_MAY_BE_UNPOWERED #define CONFIG_I2C_CONTROLLER -- cgit v1.2.1 From 7f8001fa029426f091dfc71a7d6a6def70aab931 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 11:45:19 -0700 Subject: util: Allow passing files to check_clang_format For example to reformat all of the files in zephyr/test run: ./util/check_clang_format.py --fix zephyr/test BRANCH=None BUG=b:247100970 TEST=./util/check_clang_format.py --fix zephyr/test Signed-off-by: Jeremy Bettis Change-Id: Ic812ad08ff2955b77ea95c2a870934d45ee74e07 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022251 Reviewed-by: Tristan Honscheid Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Commit-Queue: Jeremy Bettis --- util/check_clang_format.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/check_clang_format.py b/util/check_clang_format.py index df98bb0eda..9fbfa9b868 100755 --- a/util/check_clang_format.py +++ b/util/check_clang_format.py @@ -27,6 +27,11 @@ def main(argv=None): action="store_true", help="Fix any formatting errors automatically.", ) + parser.add_argument( + "file", + nargs="*", + help="File or directory to clang-format.", + ) opts = parser.parse_args(argv) logging.info("Validating all code is formatted with clang-format.") @@ -34,7 +39,7 @@ def main(argv=None): all_files = [ ec_dir / path for path in subprocess.run( - ["git", "ls-files", "-z"], + ["git", "ls-files", "-z"] + opts.file, check=True, cwd=ec_dir, stdout=subprocess.PIPE, -- cgit v1.2.1 From fa094b5db8c7aa5df81c6be73dab7be577417458 Mon Sep 17 00:00:00 2001 From: Li Feng Date: Tue, 1 Nov 2022 17:34:40 -0700 Subject: rex: fix i2c scan device names typo BUG=none BRANCH=none TEST=build and run on Rex, the device names are correct. Signed-off-by: Li Feng Change-Id: I293390160b0be117ea5e35edb13214f06178d7df Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3997583 Reviewed-by: Scott Collyer Code-Coverage: Zoss --- zephyr/program/rex/rex.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/program/rex/rex.dts b/zephyr/program/rex/rex.dts index 2d7e1b89ba..801ba537a0 100644 --- a/zephyr/program/rex/rex.dts +++ b/zephyr/program/rex/rex.dts @@ -192,7 +192,7 @@ }; &i2c4_1 { - label = "I2_USB_C1_TCPC"; + label = "I2C_USB_C1_TCPC"; clock-frequency = ; pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; @@ -210,7 +210,7 @@ }; &i2c5_0 { - label = "I2C__BATTERY"; + label = "I2C_BATTERY"; clock-frequency = ; pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; -- cgit v1.2.1 From 246e04cd38a1b9cb47881306892cde1e5253d31b Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 12:38:56 -0700 Subject: zephyr/test: Sort header files Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: I2428eea11e18ee4bed6bc366fd69d4254d936c10 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022253 Reviewed-by: Abe Levkoy Tested-by: Jeremy Bettis Commit-Queue: Abe Levkoy Commit-Queue: Jeremy Bettis Auto-Submit: Jeremy Bettis Code-Coverage: Zoss --- zephyr/test/ap_power/src/ap_pwrseq.c | 13 +++++---- zephyr/test/ap_power/src/board.c | 2 +- zephyr/test/ap_power/src/console_command.c | 6 ++-- zephyr/test/ap_power/src/events.c | 14 ++++----- zephyr/test/ap_power/src/hibdelay.c | 6 ++-- zephyr/test/ap_power/src/hibernate.c | 12 ++++---- zephyr/test/ap_power/src/host_command.c | 4 +-- zephyr/test/ap_power/src/main.c | 5 ++-- zephyr/test/ap_power/src/signals.c | 20 ++++++------- zephyr/test/ap_power/src/test_mocks.c | 4 +-- zephyr/test/crc/main.c | 4 +-- zephyr/test/drivers/anx7447/src/low_power_mode.c | 6 ++-- .../drivers/ap_mux_control/src/ap_mux_control.c | 6 ++-- .../drivers/ap_vdm_control/src/ap_vdm_control.c | 13 +++++---- zephyr/test/drivers/button/src/main.c | 10 +++---- .../test/drivers/chargesplash/src/chargesplash.c | 19 ++++++------ .../drivers/common/include/test/drivers/stubs.h | 3 +- .../drivers/common/include/test/drivers/utils.h | 15 +++++----- zephyr/test/drivers/common/src/main.c | 5 ++-- zephyr/test/drivers/common/src/stubs.c | 6 ++-- zephyr/test/drivers/common/src/test_mocks.c | 4 +-- zephyr/test/drivers/common/src/test_rules.c | 4 +-- zephyr/test/drivers/common/src/utils.c | 16 +++++----- .../test/drivers/common_cbi/src/test_common_cbi.c | 8 ++--- .../common_cbi_gpio/src/test_common_cbi_gpio.c | 4 +-- .../common_charger/src/test_charge_state_v2.c | 4 +-- .../common_charger/src/test_common_charger.c | 8 ++--- .../src/test_common_charger_mocked.c | 11 +++---- zephyr/test/drivers/console/src/shell.c | 8 ++--- zephyr/test/drivers/default/src/battery.c | 10 +++---- zephyr/test/drivers/default/src/bb_retimer.c | 17 +++++------ zephyr/test/drivers/default/src/bc12.c | 16 +++++----- zephyr/test/drivers/default/src/bma2x2.c | 13 ++++----- zephyr/test/drivers/default/src/bmi160.c | 15 +++++----- zephyr/test/drivers/default/src/bmi260.c | 15 +++++----- zephyr/test/drivers/default/src/bmi_common.c | 8 ++--- zephyr/test/drivers/default/src/charge_manager.c | 4 +-- .../default/src/charge_state_prevent_power_on.c | 4 +-- zephyr/test/drivers/default/src/console.c | 12 ++++---- .../drivers/default/src/console_cmd/accelinfo.c | 6 ++-- .../drivers/default/src/console_cmd/accelinit.c | 8 ++--- .../drivers/default/src/console_cmd/accelrange.c | 8 ++--- .../drivers/default/src/console_cmd/accelrate.c | 6 ++-- .../drivers/default/src/console_cmd/accelread.c | 8 ++--- .../drivers/default/src/console_cmd/accelres.c | 8 ++--- .../drivers/default/src/console_cmd/accelspoof.c | 6 ++-- zephyr/test/drivers/default/src/console_cmd/adc.c | 6 ++-- .../test/drivers/default/src/console_cmd/battery.c | 8 ++--- .../test/drivers/default/src/console_cmd/button.c | 6 ++-- zephyr/test/drivers/default/src/console_cmd/cbi.c | 6 ++-- .../default/src/console_cmd/charge_manager.c | 6 ++-- .../drivers/default/src/console_cmd/charge_state.c | 6 ++-- .../test/drivers/default/src/console_cmd/chargen.c | 17 ++++++----- .../test/drivers/default/src/console_cmd/charger.c | 6 ++-- .../test/drivers/default/src/console_cmd/crash.c | 6 ++-- .../test/drivers/default/src/console_cmd/cutoff.c | 6 ++-- .../drivers/default/src/console_cmd/ec_features.c | 6 ++-- zephyr/test/drivers/default/src/console_cmd/gpio.c | 6 ++-- .../test/drivers/default/src/console_cmd/hcdebug.c | 6 ++-- .../drivers/default/src/console_cmd/hibdelay.c | 6 ++-- .../drivers/default/src/console_cmd/hostevent.c | 6 ++-- .../drivers/default/src/console_cmd/i2c_portmap.c | 6 ++-- zephyr/test/drivers/default/src/console_cmd/md.c | 6 ++-- .../drivers/default/src/console_cmd/panic_output.c | 6 ++-- .../test/drivers/default/src/console_cmd/port80.c | 11 ++++--- .../drivers/default/src/console_cmd/power_button.c | 1 + .../drivers/default/src/console_cmd/powerindebug.c | 6 ++-- .../test/drivers/default/src/console_cmd/pwr_avg.c | 10 +++---- zephyr/test/drivers/default/src/console_cmd/rtc.c | 4 +-- zephyr/test/drivers/default/src/console_cmd/rw.c | 6 ++-- .../drivers/default/src/console_cmd/shared_mem.c | 6 ++-- .../drivers/default/src/console_cmd/sleepmask.c | 10 +++---- .../drivers/default/src/console_cmd/sleeptimeout.c | 6 ++-- .../test/drivers/default/src/console_cmd/switch.c | 6 ++-- .../test/drivers/default/src/console_cmd/sysinfo.c | 12 ++++---- .../drivers/default/src/console_cmd/tcpci_dump.c | 6 ++-- .../default/src/console_cmd/usb_pd_console.c | 6 ++-- .../drivers/default/src/console_cmd/vboot_hash.c | 13 +++++---- .../test/drivers/default/src/console_cmd/version.c | 10 +++---- .../test/drivers/default/src/console_cmd/waitms.c | 7 +++-- zephyr/test/drivers/default/src/cros_cbi.c | 6 ++-- zephyr/test/drivers/default/src/espi.c | 11 +++---- zephyr/test/drivers/default/src/flash.c | 14 ++++----- zephyr/test/drivers/default/src/gpio.c | 15 +++++----- zephyr/test/drivers/default/src/i2c.c | 6 ++-- zephyr/test/drivers/default/src/i2c_passthru.c | 6 ++-- .../drivers/default/src/integration/usbc/usb.c | 10 +++---- .../src/integration/usbc/usb_20v_3a_pd_charger.c | 4 +-- .../src/integration/usbc/usb_5v_3a_pd_sink.c | 7 +++-- .../src/integration/usbc/usb_5v_3a_pd_source.c | 10 +++---- .../src/integration/usbc/usb_attach_src_snk.c | 16 +++++----- .../src/integration/usbc/usb_pd_bist_shared.c | 4 +-- .../default/src/integration/usbc/usb_pd_ctrl_msg.c | 7 +++-- .../default/src/integration/usbc/usb_pd_rev3.c | 8 ++--- zephyr/test/drivers/default/src/isl923x.c | 10 +++---- zephyr/test/drivers/default/src/led.c | 11 ++++--- zephyr/test/drivers/default/src/lid_angle.c | 4 +-- zephyr/test/drivers/default/src/lid_switch.c | 15 +++++----- zephyr/test/drivers/default/src/lis2dw12.c | 5 ++-- zephyr/test/drivers/default/src/ln9310.c | 16 +++++----- zephyr/test/drivers/default/src/locate_chip.c | 10 +++---- .../default/src/motion_sense/motion_sense.c | 4 +-- zephyr/test/drivers/default/src/panic.c | 11 ++++--- zephyr/test/drivers/default/src/panic_output.c | 4 +-- zephyr/test/drivers/default/src/port80.c | 11 ++++--- zephyr/test/drivers/default/src/power_common.c | 29 +++++++++--------- zephyr/test/drivers/default/src/ppc_sn5s330.c | 16 +++++----- zephyr/test/drivers/default/src/ppc_syv682x.c | 20 ++++++------- zephyr/test/drivers/default/src/ps8xxx.c | 17 +++++------ zephyr/test/drivers/default/src/smart.c | 17 +++++------ zephyr/test/drivers/default/src/stm_mems_common.c | 11 +++---- zephyr/test/drivers/default/src/tablet_mode.c | 10 +++---- zephyr/test/drivers/default/src/task.c | 4 +-- zephyr/test/drivers/default/src/tcpci.c | 13 ++++----- .../test/drivers/default/src/tcpci_test_common.c | 7 ++--- zephyr/test/drivers/default/src/tcs3400.c | 13 ++++----- zephyr/test/drivers/default/src/temp_sensor.c | 20 ++++++------- zephyr/test/drivers/default/src/thermistor.c | 15 +++++----- zephyr/test/drivers/default/src/uart_hostcmd.c | 8 ++--- zephyr/test/drivers/default/src/usb_mux.c | 23 +++++++-------- zephyr/test/drivers/default/src/util.c | 8 ++--- zephyr/test/drivers/default/src/vboot_hash.c | 9 +++--- zephyr/test/drivers/default/src/virtual_battery.c | 6 ++-- zephyr/test/drivers/default/src/vstore.c | 15 +++++----- zephyr/test/drivers/default/src/watchdog.c | 17 +++++------ zephyr/test/drivers/dps/src/dps.c | 4 +-- zephyr/test/drivers/host_cmd/src/adc.c | 8 ++--- zephyr/test/drivers/host_cmd/src/battery_cut_off.c | 6 ++-- .../drivers/host_cmd/src/battery_display_soc.c | 4 +-- zephyr/test/drivers/host_cmd/src/battery_v2.c | 4 +-- zephyr/test/drivers/host_cmd/src/charge_manager.c | 4 +-- .../test/drivers/host_cmd/src/get_cmd_versions.c | 4 +-- zephyr/test/drivers/host_cmd/src/get_panic_info.c | 4 +-- .../test/drivers/host_cmd/src/get_pd_port_caps.c | 6 ++-- zephyr/test/drivers/host_cmd/src/host_command.c | 4 +-- .../host_cmd/src/host_command_test_protocol.c | 4 +-- .../drivers/host_cmd/src/host_event_commands.c | 3 +- .../host_cmd/src/host_event_commands_deprecated.c | 3 +- .../host_cmd/src/host_request_expected_size.c | 4 +-- zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c | 3 +- zephyr/test/drivers/host_cmd/src/motion_sense.c | 8 ++--- zephyr/test/drivers/host_cmd/src/pd_chip_info.c | 6 ++-- zephyr/test/drivers/host_cmd/src/pd_control.c | 8 ++--- zephyr/test/drivers/host_cmd/src/pd_log.c | 6 ++-- zephyr/test/drivers/host_cmd/src/tablet_mode.c | 10 +++---- zephyr/test/drivers/host_cmd/src/usb_pd_control.c | 6 ++-- zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c | 6 ++-- zephyr/test/drivers/host_command_thread/src/main.c | 8 ++--- .../i2c_controller/include/basic_i2c_device_emul.h | 4 +-- .../i2c_controller/src/basic_i2c_device_emul.c | 7 +++-- .../drivers/i2c_controller/src/i2c_controller.c | 8 ++--- zephyr/test/drivers/isl923x/src/charge_ramp_hw.c | 4 +-- .../drivers/isl923x/src/console_cmd_amon_bmon.c | 10 +++---- .../drivers/keyboard_scan/src/keyboard_backlight.c | 13 +++++---- .../test/drivers/keyboard_scan/src/keyboard_scan.c | 20 +++++++------ .../keyboard_scan/src/keyboard_test_utils.c | 3 +- zephyr/test/drivers/keyboard_scan/src/mkbp_event.c | 15 +++++----- zephyr/test/drivers/keyboard_scan/src/mkbp_info.c | 9 +++--- zephyr/test/drivers/led_driver/src/led.c | 3 +- zephyr/test/drivers/led_driver/src/led_common.c | 6 ++-- zephyr/test/drivers/locate_chip/src/locate_chip.c | 6 ++-- zephyr/test/drivers/mkbp/src/mkbp_fifo.c | 12 ++++---- .../power_host_sleep/src/test_power_host_sleep.c | 8 ++--- zephyr/test/drivers/rt9490/src/bc12.c | 8 ++--- zephyr/test/drivers/rt9490/src/charger.c | 4 +-- .../drivers/shim_gpio_id/src/test_shim_gpio_id.c | 4 +-- .../drivers/shim_pwm_hc/src/test_shim_pwm_hc.c | 12 ++++---- zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c | 10 +++---- zephyr/test/drivers/system/src/system.c | 10 +++---- .../drivers/system/src/system_board_version_cbi.c | 8 ++--- .../system/src/system_board_version_default.c | 4 +-- .../system/src/system_not_board_ap_set_sku_id.c | 4 +-- zephyr/test/drivers/timer/src/timer.c | 8 ++--- zephyr/test/drivers/usb_common/src/suite.c | 4 +-- zephyr/test/drivers/usb_common/src/usb_common.c | 11 +++---- .../test/drivers/usb_common/src/usb_pd_discharge.c | 8 ++--- zephyr/test/drivers/usb_common/src/usb_pd_flags.c | 6 ++-- .../src/usb_malfunction_sink.c | 13 +++++---- .../usb_port_power_dumb/src/usb_port_power_dumb.c | 15 +++++----- .../src/usb_retimer_fw_update.c | 4 +-- .../test/drivers/usbc_alt_mode/src/usbc_alt_mode.c | 15 +++++----- .../src/usbc_alt_mode__require_ap_mode_entry.c | 6 ++-- .../src/usbc_alt_mode_ec_mode_entry.c | 10 +++---- .../drivers/usbc_console_pd/src/usbc_console_pd.c | 17 ++++++----- zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c | 8 ++--- zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c | 10 +++---- .../usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c | 8 ++--- .../test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c | 15 +++++----- .../drivers/usbc_vconn_swap/src/usbc_vconn_swap.c | 15 +++++----- zephyr/test/ec_app/src/main.c | 8 ++--- zephyr/test/herobrine/src/board_chipset.c | 6 ++-- zephyr/test/hooks/hooks.c | 7 +++-- zephyr/test/i2c/src/main.c | 8 ++--- zephyr/test/kingler/src/alt_sensor.c | 8 ++--- zephyr/test/kingler/src/ccd.c | 10 +++---- zephyr/test/kingler/src/clamshell.c | 8 ++--- zephyr/test/kingler/src/db_detect_hdmi.c | 10 +++---- zephyr/test/kingler/src/db_detect_none.c | 11 +++---- zephyr/test/kingler/src/db_detect_typec.c | 8 ++--- zephyr/test/kingler/src/fakes.c | 3 +- zephyr/test/kingler/src/tablet.c | 8 ++--- zephyr/test/krabby/src/charger_workaround.c | 10 +++---- zephyr/test/krabby/src/stubs.c | 2 +- zephyr/test/krabby/src/temp_tentacruel.c | 14 ++++----- zephyr/test/krabby/src/usb_mux_init.c | 8 ++--- zephyr/test/math/src/fixed_point_int_sqrtf.c | 4 +-- zephyr/test/math/src/mask.c | 7 +++-- zephyr/test/math/src/math_util.c | 6 ++-- zephyr/test/math/src/vector.c | 4 +-- zephyr/test/qcom_power/src/main.c | 34 +++++++++++----------- zephyr/test/rex/src/usb_pd_policy.c | 8 ++--- zephyr/test/system_common/src/build_info.c | 6 ++-- zephyr/test/system_common/src/get_version.c | 6 ++-- zephyr/test/system_common/src/reboot.c | 6 ++-- zephyr/test/system_common/src/system_is_locked.c | 4 +-- zephyr/test/system_shim/src/test_system.c | 9 +++--- zephyr/test/tasks/main.c | 9 +++--- zephyr/test/test_utils/tasks_fakes.c | 5 ++-- zephyr/test/vboot_efs2/src/main.c | 2 +- 219 files changed, 948 insertions(+), 927 deletions(-) diff --git a/zephyr/test/ap_power/src/ap_pwrseq.c b/zephyr/test/ap_power/src/ap_pwrseq.c index d7a4042ca3..6c2fd4fd7f 100644 --- a/zephyr/test/ap_power/src/ap_pwrseq.c +++ b/zephyr/test/ap_power/src/ap_pwrseq.c @@ -3,19 +3,20 @@ * found in the LICENSE file. */ +#include "ap_power/ap_power.h" +#include "ap_power/ap_power_interface.h" +#include "chipset.h" +#include "emul/emul_power_signals.h" +#include "test_state.h" + #include #include #include -#include #include +#include #include -#include "ap_power/ap_power.h" #include -#include "ap_power/ap_power_interface.h" -#include "chipset.h" -#include "emul/emul_power_signals.h" -#include "test_state.h" static struct ap_power_ev_callback test_cb; static int power_resume_count; diff --git a/zephyr/test/ap_power/src/board.c b/zephyr/test/ap_power/src/board.c index bada154bb3..f08ccf9ef7 100644 --- a/zephyr/test/ap_power/src/board.c +++ b/zephyr/test/ap_power/src/board.c @@ -6,8 +6,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/zephyr/test/ap_power/src/console_command.c b/zephyr/test/ap_power/src/console_command.c index 9d38e773c7..7789a13919 100644 --- a/zephyr/test/ap_power/src/console_command.c +++ b/zephyr/test/ap_power/src/console_command.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test_state.h" +#include +#include + ZTEST_USER(console_cmd_debug_mode, test_debug_mode_default) { zassert_ok(shell_execute_cmd(get_ec_shell(), "debug_mode"), diff --git a/zephyr/test/ap_power/src/events.c b/zephyr/test/ap_power/src/events.c index b5dfdec50f..2528d356f6 100644 --- a/zephyr/test/ap_power/src/events.c +++ b/zephyr/test/ap_power/src/events.c @@ -8,20 +8,18 @@ * @brief Unit Tests for AP power events */ -#include +#include "ap_power/ap_power.h" +#include "ap_power/ap_power_events.h" +#include "hooks.h" +#include "test_state.h" +#include #include #include -#include #include +#include #include -#include "ap_power/ap_power.h" -#include "ap_power/ap_power_events.h" - -#include "hooks.h" -#include "test_state.h" - /* * Structure passed to event listeners. */ diff --git a/zephyr/test/ap_power/src/hibdelay.c b/zephyr/test/ap_power/src/hibdelay.c index 02442adec8..11fac953ea 100644 --- a/zephyr/test/ap_power/src/hibdelay.c +++ b/zephyr/test/ap_power/src/hibdelay.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test_state.h" +#include +#include + ZTEST_SUITE(console_cmd_hibdelay, ap_power_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/ap_power/src/hibernate.c b/zephyr/test/ap_power/src/hibernate.c index 2309508f4b..23030bdcb3 100644 --- a/zephyr/test/ap_power/src/hibernate.c +++ b/zephyr/test/ap_power/src/hibernate.c @@ -3,21 +3,19 @@ * found in the LICENSE file. */ -#include +#include "hooks.h" +#include "test_mocks.h" +#include "test_state.h" -#include +#include #include +#include #include #include #include #include -#include "hooks.h" - -#include "test_mocks.h" -#include "test_state.h" - ZTEST(hibernate, test_g3_hibernate) { extpower_is_present_fake.return_val = 0; diff --git a/zephyr/test/ap_power/src/host_command.c b/zephyr/test/ap_power/src/host_command.c index 4367f8fa44..f0b3b0d732 100644 --- a/zephyr/test/ap_power/src/host_command.c +++ b/zephyr/test/ap_power/src/host_command.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "ec_commands.h" #include "host_command.h" #include "test_state.h" +#include + ZTEST(host_cmd, test_hibernate_get) { struct ec_response_hibernation_delay response; diff --git a/zephyr/test/ap_power/src/main.c b/zephyr/test/ap_power/src/main.c index d653b51164..9ed34eee4a 100644 --- a/zephyr/test/ap_power/src/main.c +++ b/zephyr/test/ap_power/src/main.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -#include -#include #include "ec_app_main.h" #include "test_state.h" +#include +#include + bool ap_power_predicate_pre_main(const void *state) { return ((struct test_state *)state)->ec_app_main_run == false; diff --git a/zephyr/test/ap_power/src/signals.c b/zephyr/test/ap_power/src/signals.c index e8bc6e426c..4eae187564 100644 --- a/zephyr/test/ap_power/src/signals.c +++ b/zephyr/test/ap_power/src/signals.c @@ -8,24 +8,22 @@ * @brief Unit Tests for power signals API */ -#include - -#include -#include -#include -#include -#include -#include - -#include "power_signals.h" - #include "ec_tasks.h" #include "emul/emul_stub_device.h" #include "gpio.h" #include "gpio/gpio.h" #include "gpio/gpio_int.h" +#include "power_signals.h" #include "test_state.h" +#include +#include +#include +#include +#include +#include +#include + extern bool gpio_test_interrupt_triggered; static const struct device *emul_port; diff --git a/zephyr/test/ap_power/src/test_mocks.c b/zephyr/test/ap_power/src/test_mocks.c index 5dae36a6ab..9eb8834ff5 100644 --- a/zephyr/test/ap_power/src/test_mocks.c +++ b/zephyr/test/ap_power/src/test_mocks.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ +#include "test_mocks.h" + #include #include -#include "test_mocks.h" - /* Mocks for common/extpower_gpio.c */ DEFINE_FAKE_VALUE_FUNC(int, extpower_is_present); diff --git a/zephyr/test/crc/main.c b/zephyr/test/crc/main.c index 0b13970d83..f9da78bfde 100644 --- a/zephyr/test/crc/main.c +++ b/zephyr/test/crc/main.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ +#include "crc8.h" + #include #include -#include "crc8.h" - ZTEST_SUITE(crc_driver, NULL, NULL, NULL, NULL, NULL); ZTEST(crc_driver, test_crc8_known_data) diff --git a/zephyr/test/drivers/anx7447/src/low_power_mode.c b/zephyr/test/drivers/anx7447/src/low_power_mode.c index 67c095b64d..cbcea1955c 100644 --- a/zephyr/test/drivers/anx7447/src/low_power_mode.c +++ b/zephyr/test/drivers/anx7447/src/low_power_mode.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "emul/tcpc/emul_tcpci.h" #include "tcpm/anx7447_public.h" #include "tcpm/tcpci.h" @@ -13,6 +10,9 @@ #include "test/drivers/test_state.h" #include "usb_pd.h" +#include +#include + #define ANX7447_NODE DT_NODELABEL(anx7447_emul) static const int tcpm_anx7447_port = USBC_PORT_C0; diff --git a/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c b/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c index 632b8e6aea..993c6e680c 100644 --- a/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c +++ b/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - -#include "usb_mux.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include "usb_mux.h" + +#include static void ap_mux_control_before(void *data) { diff --git a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c index 10a5faf6b9..fe7dab88f4 100644 --- a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c +++ b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c @@ -3,18 +3,19 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" -#include "usb_mux.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include "usb_mux.h" #include "usb_pd_vdo.h" +#include + +#include +#include +#include + #define TEST_PORT USBC_PORT_C0 struct ap_vdm_control_fixture { diff --git a/zephyr/test/drivers/button/src/main.c b/zephyr/test/drivers/button/src/main.c index c26a62dfa1..08874d8032 100644 --- a/zephyr/test/drivers/button/src/main.c +++ b/zephyr/test/drivers/button/src/main.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "button.h" #include "console.h" #include "hooks.h" @@ -16,6 +11,11 @@ #include "test/drivers/test_state.h" #include "timer.h" +#include +#include +#include +#include + /* * TODO (b/b/253284635) Timeouts here don't quite align with the button press * duration. This is caused by an issue with the Zephyr scheduling for delayed diff --git a/zephyr/test/drivers/chargesplash/src/chargesplash.c b/zephyr/test/drivers/chargesplash/src/chargesplash.c index 08ba5377a0..27b3678bd8 100644 --- a/zephyr/test/drivers/chargesplash/src/chargesplash.c +++ b/zephyr/test/drivers/chargesplash/src/chargesplash.c @@ -3,14 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include -#include - #include "chipset.h" #include "config.h" #include "ec_commands.h" @@ -18,9 +10,18 @@ #include "hooks.h" #include "host_command.h" #include "lid_switch.h" -#include "timer.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include "timer.h" + +#include + +#include +#include +#include +#include +#include +#include /* Do a chargesplash host cmd */ static enum ec_status diff --git a/zephyr/test/drivers/common/include/test/drivers/stubs.h b/zephyr/test/drivers/common/include/test/drivers/stubs.h index 8a739fa866..63718649f8 100644 --- a/zephyr/test/drivers/common/include/test/drivers/stubs.h +++ b/zephyr/test/drivers/common/include/test/drivers/stubs.h @@ -6,9 +6,10 @@ #ifndef __TEST_DRIVERS_STUBS_H #define __TEST_DRIVERS_STUBS_H -#include #include "power.h" +#include + enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; /** diff --git a/zephyr/test/drivers/common/include/test/drivers/utils.h b/zephyr/test/drivers/common/include/test/drivers/utils.h index 1a6799bd0d..d2e0b06a5d 100644 --- a/zephyr/test/drivers/common/include/test/drivers/utils.h +++ b/zephyr/test/drivers/common/include/test/drivers/utils.h @@ -6,20 +6,21 @@ #ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_ #define ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_ -#include -#include -#include -#include -#include - #include "charger.h" -#include "lpc.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "extpower.h" #include "host_command.h" +#include "lpc.h" #include "power.h" #include "usbc/utils.h" +#include +#include + +#include +#include +#include + /** * @brief Helper macro for EMUL_GET_USBC_BINDING. If @p usbc_id has the same * port number as @p port, then struct emul* for @p chip phandle is diff --git a/zephyr/test/drivers/common/src/main.c b/zephyr/test/drivers/common/src/main.c index 1c8497ab3f..dab681b936 100644 --- a/zephyr/test/drivers/common/src/main.c +++ b/zephyr/test/drivers/common/src/main.c @@ -3,12 +3,13 @@ * found in the LICENSE file. */ -#include -#include #include "ec_app_main.h" #include "hooks.h" #include "test/drivers/test_state.h" +#include +#include + /** * @brief Semaphore that signals when hooks have completed */ diff --git a/zephyr/test/drivers/common/src/stubs.c b/zephyr/test/drivers/common/src/stubs.c index f16064c14d..3cddc5cdfe 100644 --- a/zephyr/test/drivers/common/src/stubs.c +++ b/zephyr/test/drivers/common/src/stubs.c @@ -7,11 +7,11 @@ #include "battery_fuel_gauge.h" #include "bc12/pi3usb9201_public.h" #include "charge_ramp.h" +#include "charge_state_v2.h" #include "charger.h" #include "charger/isl923x_public.h" #include "charger/isl9241_public.h" #include "config.h" -#include #include "gpio/gpio_int.h" #include "hooks.h" #include "i2c/i2c.h" @@ -19,14 +19,14 @@ #include "ppc/sn5s330_public.h" #include "ppc/syv682x_public.h" #include "retimer/bb_retimer_public.h" -#include "test/drivers/stubs.h" #include "tcpm/ps8xxx_public.h" #include "tcpm/tcpci.h" +#include "test/drivers/stubs.h" #include "usb_mux.h" #include "usb_pd_tcpm.h" #include "usbc_ppc.h" -#include "charge_state_v2.h" +#include #include LOG_MODULE_REGISTER(stubs); diff --git a/zephyr/test/drivers/common/src/test_mocks.c b/zephyr/test/drivers/common/src/test_mocks.c index 76f66662cb..21cd4c0c1b 100644 --- a/zephyr/test/drivers/common/src/test_mocks.c +++ b/zephyr/test/drivers/common/src/test_mocks.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include - #include "test/drivers/test_mocks.h" +#include + /* Mocks for common/init_rom.c */ DEFINE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int); DEFINE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int); diff --git a/zephyr/test/drivers/common/src/test_rules.c b/zephyr/test/drivers/common/src/test_rules.c index e1b1d59480..42195b25d7 100644 --- a/zephyr/test/drivers/common/src/test_rules.c +++ b/zephyr/test/drivers/common/src/test_rules.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "emul/tcpc/emul_tcpci.h" #include "motion_sense_fifo.h" #include "test/drivers/stubs.h" #include "test/drivers/utils.h" #include "usb_pd_tcpm.h" +#include + static void motion_sense_fifo_reset_before(const struct ztest_unit_test *test, void *data) { diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c index 646db0d27b..14da1331aa 100644 --- a/zephyr/test/drivers/common/src/utils.c +++ b/zephyr/test/drivers/common/src/utils.c @@ -3,30 +3,30 @@ * found in the LICENSE file. */ -#include -#include -#include /* nocheck */ -#include -#include -#include - #include "acpi.h" #include "battery.h" #include "battery_smart.h" #include "charge_state.h" #include "chipset.h" -#include "lpc.h" #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" #include "emul/emul_stub_device.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "hooks.h" +#include "lpc.h" #include "power.h" #include "task.h" #include "tcpm/tcpci.h" #include "test/drivers/stubs.h" #include "test/drivers/utils.h" +#include +#include +#include +#include /* nocheck */ +#include +#include + #define BATTERY_NODE DT_NODELABEL(battery) #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) #define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) diff --git a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c index fcd5624e09..bf8da93a9e 100644 --- a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c +++ b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "cros_board_info.h" #include "host_command.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include +#include +#include + #define WP_L_GPIO_PATH DT_PATH(named_gpios, wp_l) #define CBI_EEPROM_DEV DEVICE_DT_GET(DT_NODELABEL(cbi_eeprom)) diff --git a/zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c b/zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c index 4af62a3d8b..8e8e4f6a8b 100644 --- a/zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c +++ b/zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "cros_board_info.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include + FAKE_VALUE_FUNC(int, system_get_board_version); FAKE_VALUE_FUNC(int, cbi_set_board_info, enum cbi_data_tag, const uint8_t *, uint8_t); diff --git a/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c index c4c0838dc5..d6504b92f9 100644 --- a/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c +++ b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charge_state_v2.h" #include "math_util.h" #include "test/drivers/test_state.h" +#include + int battery_outside_charging_temperature(void); struct charge_state_v2_fixture { diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger.c b/zephyr/test/drivers/common_charger/src/test_common_charger.c index ca9469c032..eb7d6f1f08 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "charge_ramp.h" #include "driver/charger/isl923x_public.h" #include "ec_commands.h" @@ -15,6 +11,10 @@ #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include +#include +#include + /* Tested wrt isl923x without RAA489000 */ /* Only single charger-chip configured for the drivers overlay */ diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c index 4ee485f5c0..c353b7b6c5 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c @@ -3,17 +3,18 @@ * found in the LICENSE file. */ +#include "charge_ramp.h" +#include "charger.h" +#include "test/drivers/charger_utils.h" +#include "test/drivers/test_state.h" + #include + #include #include #include #include -#include "charger.h" -#include "charge_ramp.h" -#include "test/drivers/charger_utils.h" -#include "test/drivers/test_state.h" - /* This test suite only works if the chg_chips array is not const. */ BUILD_ASSERT(IS_ENABLED(CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG), "chg_chips array cannot be const."); diff --git a/zephyr/test/drivers/console/src/shell.c b/zephyr/test/drivers/console/src/shell.c index 7345ed2da8..c7a85b8f32 100644 --- a/zephyr/test/drivers/console/src/shell.c +++ b/zephyr/test/drivers/console/src/shell.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ +#include "console.h" +#include "test/drivers/test_state.h" +#include "uart.h" + #include #include #include #include -#include "console.h" -#include "uart.h" -#include "test/drivers/test_state.h" - void uart_callback(const struct device *dev, void *user_data); void bypass_cb(const struct shell *shell, uint8_t *data, size_t len); diff --git a/zephyr/test/drivers/default/src/battery.c b/zephyr/test/drivers/default/src/battery.c index 2e06725af5..5e57537a28 100644 --- a/zephyr/test/drivers/default/src/battery.c +++ b/zephyr/test/drivers/default/src/battery.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "battery.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include + #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) #define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) diff --git a/zephyr/test/drivers/default/src/bb_retimer.c b/zephyr/test/drivers/default/src/bb_retimer.c index 5cfedc789e..78d483817a 100644 --- a/zephyr/test/drivers/default/src/bb_retimer.c +++ b/zephyr/test/drivers/default/src/bb_retimer.c @@ -3,25 +3,24 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - +#include "chipset.h" #include "common.h" +#include "driver/retimer/bb_retimer.h" #include "ec_tasks.h" #include "emul/emul_bb_retimer.h" #include "emul/emul_common_i2c.h" #include "hooks.h" #include "i2c.h" #include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include "usb_prl_sm.h" #include "usb_tc_sm.h" -#include "chipset.h" -#include "driver/retimer/bb_retimer.h" -#include "test/drivers/test_state.h" -#include "test/drivers/utils.h" +#include +#include +#include +#include #define GPIO_USB_C1_LS_EN_PATH DT_PATH(named_gpios, usb_c1_ls_en) #define GPIO_USB_C1_LS_EN_PORT DT_GPIO_PIN(GPIO_USB_C1_LS_EN_PATH, gpios) diff --git a/zephyr/test/drivers/default/src/bc12.c b/zephyr/test/drivers/default/src/bc12.c index 2207cd9676..5d143dcbdb 100644 --- a/zephyr/test/drivers/default/src/bc12.c +++ b/zephyr/test/drivers/default/src/bc12.c @@ -3,22 +3,20 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - -#include "emul/emul_pi3usb9201.h" - -#include "timer.h" -#include "usb_charge.h" #include "battery.h" +#include "emul/emul_pi3usb9201.h" #include "extpower.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include "timer.h" +#include "usb_charge.h" +#include +#include +#include #include +#include LOG_MODULE_REGISTER(test_drivers_bc12, LOG_LEVEL_DBG); #define EMUL_NODE DT_NODELABEL(pi3usb9201_emul0) diff --git a/zephyr/test/drivers/default/src/bma2x2.c b/zephyr/test/drivers/default/src/bma2x2.c index ce6665790d..b66fc9d056 100644 --- a/zephyr/test/drivers/default/src/bma2x2.c +++ b/zephyr/test/drivers/default/src/bma2x2.c @@ -3,19 +3,18 @@ * found in the LICENSE file. */ -#include -#include - +#include "accelgyro.h" #include "common.h" -#include "i2c.h" +#include "driver/accel_bma2x2.h" #include "emul/emul_bma255.h" #include "emul/emul_common_i2c.h" - -#include "accelgyro.h" +#include "i2c.h" #include "motion_sense.h" -#include "driver/accel_bma2x2.h" #include "test/drivers/test_state.h" +#include +#include + /** How accurate comparision of vectors should be. */ #define V_EPS 8 diff --git a/zephyr/test/drivers/default/src/bmi160.c b/zephyr/test/drivers/default/src/bmi160.c index edce38057b..257040b6dd 100644 --- a/zephyr/test/drivers/default/src/bmi160.c +++ b/zephyr/test/drivers/default/src/bmi160.c @@ -3,20 +3,19 @@ * found in the LICENSE file. */ -#include -#include - #include "common.h" -#include "i2c.h" +#include "driver/accelgyro_bmi160.h" +#include "driver/accelgyro_bmi_common.h" #include "emul/emul_bmi.h" #include "emul/emul_common_i2c.h" -#include "test/drivers/test_mocks.h" - +#include "i2c.h" #include "motion_sense_fifo.h" -#include "driver/accelgyro_bmi160.h" -#include "driver/accelgyro_bmi_common.h" +#include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include +#include + #define BMI_NODE DT_NODELABEL(accel_bmi160) #define BMI_ACC_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi160_accel)) #define BMI_GYR_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi160_gyro)) diff --git a/zephyr/test/drivers/default/src/bmi260.c b/zephyr/test/drivers/default/src/bmi260.c index 5e44d1c499..1bc45b3883 100644 --- a/zephyr/test/drivers/default/src/bmi260.c +++ b/zephyr/test/drivers/default/src/bmi260.c @@ -3,21 +3,20 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "common.h" -#include "i2c.h" +#include "driver/accelgyro_bmi260.h" +#include "driver/accelgyro_bmi_common.h" #include "emul/emul_bmi.h" #include "emul/emul_common_i2c.h" - +#include "i2c.h" #include "motion_sense_fifo.h" -#include "driver/accelgyro_bmi260.h" -#include "driver/accelgyro_bmi_common.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include +#include +#include + #define BMI_NODE DT_NODELABEL(accel_bmi260) #define BMI_ACC_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi260_accel)) #define BMI_GYR_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi260_gyro)) diff --git a/zephyr/test/drivers/default/src/bmi_common.c b/zephyr/test/drivers/default/src/bmi_common.c index 302c59d27e..bdd3999d65 100644 --- a/zephyr/test/drivers/default/src/bmi_common.c +++ b/zephyr/test/drivers/default/src/bmi_common.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "accelgyro_bmi_common.h" -#include "i2c.h" #include "emul/emul_bmi.h" #include "emul/emul_common_i2c.h" +#include "i2c.h" #include "test/drivers/test_state.h" +#include +#include + #define BMI_NODE DT_NODELABEL(accel_bmi160) #define BMI_ACC_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi160_accel)) diff --git a/zephyr/test/drivers/default/src/charge_manager.c b/zephyr/test/drivers/default/src/charge_manager.c index 2729816a76..d5affff95e 100644 --- a/zephyr/test/drivers/default/src/charge_manager.c +++ b/zephyr/test/drivers/default/src/charge_manager.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "charge_manager.h" #include "ec_commands.h" #include "test/drivers/test_state.h" +#include + ZTEST_SUITE(charge_manager, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c b/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c index 83890ee6a1..ce47ff8042 100644 --- a/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c +++ b/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "charge_state.h" #include "charge_state_v2.h" #include "test/drivers/test_state.h" +#include + /* Test external variable defined in charge_state_v2 */ extern int charge_prevent_power_on_automatic_power_on; diff --git a/zephyr/test/drivers/default/src/console.c b/zephyr/test/drivers/default/src/console.c index 9e6c55c198..c5148baf76 100644 --- a/zephyr/test/drivers/default/src/console.c +++ b/zephyr/test/drivers/default/src/console.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "builtin/stdio.h" -#include "test/drivers/test_state.h" #include "console.h" -#include "uart.h" #include "ec_commands.h" +#include "test/drivers/test_state.h" +#include "uart.h" + +#include +#include +#include ZTEST_USER(console, test_printf_overflow) { diff --git a/zephyr/test/drivers/default/src/console_cmd/accelinfo.c b/zephyr/test/drivers/default/src/console_cmd/accelinfo.c index 39556fab43..aac63c01b7 100644 --- a/zephyr/test/drivers/default/src/console_cmd/accelinfo.c +++ b/zephyr/test/drivers/default/src/console_cmd/accelinfo.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "config.h" #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "timer.h" +#include +#include + static void console_cmd_accelinfo_after(void *fixture) { ARG_UNUSED(fixture); diff --git a/zephyr/test/drivers/default/src/console_cmd/accelinit.c b/zephyr/test/drivers/default/src/console_cmd/accelinit.c index e722409298..2633c05f58 100644 --- a/zephyr/test/drivers/default/src/console_cmd/accelinit.c +++ b/zephyr/test/drivers/default/src/console_cmd/accelinit.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "accelgyro.h" #include "console.h" #include "motion_sense.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include + FAKE_VALUE_FUNC(int, mock_init, struct motion_sensor_t *); struct console_cmd_accelinit_fixture { diff --git a/zephyr/test/drivers/default/src/console_cmd/accelrange.c b/zephyr/test/drivers/default/src/console_cmd/accelrange.c index 57e81eada4..04ec7e6004 100644 --- a/zephyr/test/drivers/default/src/console_cmd/accelrange.c +++ b/zephyr/test/drivers/default/src/console_cmd/accelrange.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "console.h" #include "driver/accel_bma2x2.h" #include "ec_commands.h" @@ -16,6 +12,10 @@ #include "motion_sense.h" #include "test/drivers/test_state.h" +#include +#include +#include + #define EMUL_NODE DT_NODELABEL(bma_emul) #define BMA_ORD DT_DEP_ORD(EMUL_LABEL) diff --git a/zephyr/test/drivers/default/src/console_cmd/accelrate.c b/zephyr/test/drivers/default/src/console_cmd/accelrate.c index ca5bcf338a..3a5b2cd9bf 100644 --- a/zephyr/test/drivers/default/src/console_cmd/accelrate.c +++ b/zephyr/test/drivers/default/src/console_cmd/accelrate.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "motion_sense.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + static int original_sensor_0_s0_config_odr; static void *console_cmd_accelrate_setup(void) diff --git a/zephyr/test/drivers/default/src/console_cmd/accelread.c b/zephyr/test/drivers/default/src/console_cmd/accelread.c index 4a129badc1..e622faf58f 100644 --- a/zephyr/test/drivers/default/src/console_cmd/accelread.c +++ b/zephyr/test/drivers/default/src/console_cmd/accelread.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "accelgyro.h" #include "console.h" #include "ec_commands.h" @@ -14,6 +10,10 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include + FAKE_VALUE_FUNC(int, mock_read, const struct motion_sensor_t *, int *); FAKE_VALUE_FUNC(int, mock_set_data_rate, const struct motion_sensor_t *, int, int); diff --git a/zephyr/test/drivers/default/src/console_cmd/accelres.c b/zephyr/test/drivers/default/src/console_cmd/accelres.c index 38bd4ed697..21c0075b0f 100644 --- a/zephyr/test/drivers/default/src/console_cmd/accelres.c +++ b/zephyr/test/drivers/default/src/console_cmd/accelres.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "accelgyro.h" #include "console.h" #include "driver/accel_bma2x2.h" @@ -14,6 +10,10 @@ #include "motion_sense.h" #include "test/drivers/test_state.h" +#include +#include +#include + FAKE_VALUE_FUNC(int, set_resolution, const struct motion_sensor_t *, int, int); struct console_cmd_accelres_fixture { diff --git a/zephyr/test/drivers/default/src/console_cmd/accelspoof.c b/zephyr/test/drivers/default/src/console_cmd/accelspoof.c index 50f8c1e650..fe11525531 100644 --- a/zephyr/test/drivers/default/src/console_cmd/accelspoof.c +++ b/zephyr/test/drivers/default/src/console_cmd/accelspoof.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "motion_sense.h" #include "test/drivers/test_state.h" +#include +#include + static void console_cmd_accelspoof_after(void *fixture) { ARG_UNUSED(fixture); diff --git a/zephyr/test/drivers/default/src/console_cmd/adc.c b/zephyr/test/drivers/default/src/console_cmd/adc.c index 85dfda939a..b366db36f6 100644 --- a/zephyr/test/drivers/default/src/console_cmd/adc.c +++ b/zephyr/test/drivers/default/src/console_cmd/adc.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + /* Default adc command, lists out channels */ ZTEST_USER(console_cmd_adc, test_adc_noname) { diff --git a/zephyr/test/drivers/default/src/console_cmd/battery.c b/zephyr/test/drivers/default/src/console_cmd/battery.c index 9c3e21fcf1..f5fa78d684 100644 --- a/zephyr/test/drivers/default/src/console_cmd/battery.c +++ b/zephyr/test/drivers/default/src/console_cmd/battery.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "battery_smart.h" #include "console.h" #include "ec_commands.h" @@ -15,6 +11,10 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include + struct console_cmd_battery_fixture { const struct emul *emul; struct i2c_common_emul_data *i2c_emul; diff --git a/zephyr/test/drivers/default/src/console_cmd/button.c b/zephyr/test/drivers/default/src/console_cmd/button.c index 9272b2ce2d..0df137e90b 100644 --- a/zephyr/test/drivers/default/src/console_cmd/button.c +++ b/zephyr/test/drivers/default/src/console_cmd/button.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_USER(console_cmd_button, test_button_no_arg) { int rv; diff --git a/zephyr/test/drivers/default/src/console_cmd/cbi.c b/zephyr/test/drivers/default/src/console_cmd/cbi.c index 495ffd7e4c..297431657e 100644 --- a/zephyr/test/drivers/default/src/console_cmd/cbi.c +++ b/zephyr/test/drivers/default/src/console_cmd/cbi.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "test/drivers/test_state.h" +#include +#include + static void set_wp(bool value) { const struct gpio_dt_spec *wp = GPIO_DT_FROM_NODELABEL(gpio_wp_l); diff --git a/zephyr/test/drivers/default/src/console_cmd/charge_manager.c b/zephyr/test/drivers/default/src/console_cmd/charge_manager.c index 12b2b174f4..698db8b316 100644 --- a/zephyr/test/drivers/default/src/console_cmd/charge_manager.c +++ b/zephyr/test/drivers/default/src/console_cmd/charge_manager.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "charge_manager.h" #include "console.h" #include "emul/emul_isl923x.h" @@ -15,6 +12,9 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + struct console_cmd_charge_manager_fixture { struct tcpci_partner_data sink_5v_3a; struct tcpci_snk_emul_data sink_ext; diff --git a/zephyr/test/drivers/default/src/console_cmd/charge_state.c b/zephyr/test/drivers/default/src/console_cmd/charge_state.c index 70b18beb9b..8cfd11324f 100644 --- a/zephyr/test/drivers/default/src/console_cmd/charge_state.c +++ b/zephyr/test/drivers/default/src/console_cmd/charge_state.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "charge_state.h" #include "charge_state_v2.h" #include "console.h" @@ -13,6 +10,9 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_USER(console_cmd_charge_state, test_idle_too_few_args) { int rv; diff --git a/zephyr/test/drivers/default/src/console_cmd/chargen.c b/zephyr/test/drivers/default/src/console_cmd/chargen.c index 649a1b0b1f..473ad78abb 100644 --- a/zephyr/test/drivers/default/src/console_cmd/chargen.c +++ b/zephyr/test/drivers/default/src/console_cmd/chargen.c @@ -3,17 +3,18 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include - #include "console.h" -#include "uart.h" +#include "system.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" -#include "system.h" +#include "uart.h" + +#include + +#include +#include +#include +#include const char expected_output[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" diff --git a/zephyr/test/drivers/default/src/console_cmd/charger.c b/zephyr/test/drivers/default/src/console_cmd/charger.c index 63cc0a3118..420ef67fe4 100644 --- a/zephyr/test/drivers/default/src/console_cmd/charger.c +++ b/zephyr/test/drivers/default/src/console_cmd/charger.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "dptf.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + /* Tests which need no fixture */ ZTEST_USER(console_cmd_charger, test_default_dump) { diff --git a/zephyr/test/drivers/default/src/console_cmd/crash.c b/zephyr/test/drivers/default/src/console_cmd/crash.c index bc0b5d0254..4218aa74d6 100644 --- a/zephyr/test/drivers/default/src/console_cmd/crash.c +++ b/zephyr/test/drivers/default/src/console_cmd/crash.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "builtin/assert.h" #include "console.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST_SUITE(console_cmd_crash, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/cutoff.c b/zephyr/test/drivers/default/src/console_cmd/cutoff.c index e17f8745bd..2b5a9c67d2 100644 --- a/zephyr/test/drivers/default/src/console_cmd/cutoff.c +++ b/zephyr/test/drivers/default/src/console_cmd/cutoff.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "battery.h" #include "console.h" #include "ec_commands.h" @@ -13,6 +10,9 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + static void console_cmd_cutoff_after(void *unused) { ARG_UNUSED(unused); diff --git a/zephyr/test/drivers/default/src/console_cmd/ec_features.c b/zephyr/test/drivers/default/src/console_cmd/ec_features.c index 3e355af988..48e6eec819 100644 --- a/zephyr/test/drivers/default/src/console_cmd/ec_features.c +++ b/zephyr/test/drivers/default/src/console_cmd/ec_features.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "builtin/stdio.h" #include "console.h" #include "host_command.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_SUITE(console_cmd_ec_features, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/gpio.c b/zephyr/test/drivers/default/src/console_cmd/gpio.c index 164f272e27..c4b83b8ab4 100644 --- a/zephyr/test/drivers/default/src/console_cmd/gpio.c +++ b/zephyr/test/drivers/default/src/console_cmd/gpio.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_USER(console_cmd_gpio, test_read_invoke_success) { zassert_ok(shell_execute_cmd(get_ec_shell(), "gpioget test"), NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/hcdebug.c b/zephyr/test/drivers/default/src/console_cmd/hcdebug.c index 71adb02690..68dc6c72be 100644 --- a/zephyr/test/drivers/default/src/console_cmd/hcdebug.c +++ b/zephyr/test/drivers/default/src/console_cmd/hcdebug.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" +#include +#include + static void console_cmd_hcdebug_after(void *fixture) { ARG_UNUSED(fixture); diff --git a/zephyr/test/drivers/default/src/console_cmd/hibdelay.c b/zephyr/test/drivers/default/src/console_cmd/hibdelay.c index c72a2bf66a..8275ece94d 100644 --- a/zephyr/test/drivers/default/src/console_cmd/hibdelay.c +++ b/zephyr/test/drivers/default/src/console_cmd/hibdelay.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST_SUITE(console_cmd_hibdelay, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/hostevent.c b/zephyr/test/drivers/default/src/console_cmd/hostevent.c index acb8b890e4..85717e88d1 100644 --- a/zephyr/test/drivers/default/src/console_cmd/hostevent.c +++ b/zephyr/test/drivers/default/src/console_cmd/hostevent.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "include/lpc.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + #ifdef CONFIG_HOST_EVENT64 #define HOSTEVENT_PRINT_FORMAT "016" PRIx64 #else diff --git a/zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c b/zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c index 4b2ec548a2..7651127218 100644 --- a/zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c +++ b/zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST_SUITE(console_cmd_i2c_portmap, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/md.c b/zephyr/test/drivers/default/src/console_cmd/md.c index 138dbccf98..0db049a635 100644 --- a/zephyr/test/drivers/default/src/console_cmd/md.c +++ b/zephyr/test/drivers/default/src/console_cmd/md.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST_SUITE(console_cmd_md, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/panic_output.c b/zephyr/test/drivers/default/src/console_cmd/panic_output.c index 7cc809e835..0d98ec6d08 100644 --- a/zephyr/test/drivers/default/src/console_cmd/panic_output.c +++ b/zephyr/test/drivers/default/src/console_cmd/panic_output.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "panic.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + /* Test panicinfo when a panic hasn't occurred */ ZTEST_USER(console_cmd_panic_output, test_panicinfo) { diff --git a/zephyr/test/drivers/default/src/console_cmd/port80.c b/zephyr/test/drivers/default/src/console_cmd/port80.c index 792895eb27..1d7eb2ad03 100644 --- a/zephyr/test/drivers/default/src/console_cmd/port80.c +++ b/zephyr/test/drivers/default/src/console_cmd/port80.c @@ -8,18 +8,17 @@ * @brief Unit Tests for ESPI port 80 console command */ -#include -#include -#include -#include - #include "console.h" #include "ec_commands.h" #include "port80.h" - #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include +#include + /** * @brief TestPurpose: Verify port 80 console commands * diff --git a/zephyr/test/drivers/default/src/console_cmd/power_button.c b/zephyr/test/drivers/default/src/console_cmd/power_button.c index 92d0aeaf78..d9900e8667 100644 --- a/zephyr/test/drivers/default/src/console_cmd/power_button.c +++ b/zephyr/test/drivers/default/src/console_cmd/power_button.c @@ -4,6 +4,7 @@ */ #include + #include ZTEST_SUITE(console_cmd_power_button, NULL, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/powerindebug.c b/zephyr/test/drivers/default/src/console_cmd/powerindebug.c index 9f52a9b569..946960ea86 100644 --- a/zephyr/test/drivers/default/src/console_cmd/powerindebug.c +++ b/zephyr/test/drivers/default/src/console_cmd/powerindebug.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_USER(console_cmd_powerindebug, test_no_params) { zassert_ok(shell_execute_cmd(get_ec_shell(), "powerindebug"), diff --git a/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c b/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c index 737fff14d7..3e00b5e432 100644 --- a/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c +++ b/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c @@ -3,17 +3,17 @@ * found in the LICENSE file. */ +#include "battery.h" +#include "console.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" + #include #include #include /* nocheck */ #include -#include "battery.h" -#include "console.h" -#include "test/drivers/test_state.h" -#include "test/drivers/utils.h" - ZTEST_SUITE(console_cmd_pwr_avg, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/rtc.c b/zephyr/test/drivers/default/src/console_cmd/rtc.c index 80530129af..974d3709b7 100644 --- a/zephyr/test/drivers/default/src/console_cmd/rtc.c +++ b/zephyr/test/drivers/default/src/console_cmd/rtc.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "console.h" #include "ec_commands.h" #include "system.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include + ZTEST_USER(console_cmd_rtc, test_rtc_no_arg) { char expected_buffer[32]; diff --git a/zephyr/test/drivers/default/src/console_cmd/rw.c b/zephyr/test/drivers/default/src/console_cmd/rw.c index a25bf5f07c..1560254f92 100644 --- a/zephyr/test/drivers/default/src/console_cmd/rw.c +++ b/zephyr/test/drivers/default/src/console_cmd/rw.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST_SUITE(console_cmd_rw, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/shared_mem.c b/zephyr/test/drivers/default/src/console_cmd/shared_mem.c index e7b9396509..ed796124e4 100644 --- a/zephyr/test/drivers/default/src/console_cmd/shared_mem.c +++ b/zephyr/test/drivers/default/src/console_cmd/shared_mem.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "shared_mem.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_SUITE(console_cmd_shared_mem, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/sleepmask.c b/zephyr/test/drivers/default/src/console_cmd/sleepmask.c index 6ae017dc66..40d174e6af 100644 --- a/zephyr/test/drivers/default/src/console_cmd/sleepmask.c +++ b/zephyr/test/drivers/default/src/console_cmd/sleepmask.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "console.h" +#include "system.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" -#include "system.h" + +#include +#include +#include ZTEST_USER(console_cmd_sleepmask, test_no_args) { diff --git a/zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c b/zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c index d802eb5948..3bd8a39f3f 100644 --- a/zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c +++ b/zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_USER(console_cmd_sleeptimeout, test_no_params) { zassert_ok(shell_execute_cmd(get_ec_shell(), "sleeptimeout"), diff --git a/zephyr/test/drivers/default/src/console_cmd/switch.c b/zephyr/test/drivers/default/src/console_cmd/switch.c index 7d1f63172f..f533ebe7b9 100644 --- a/zephyr/test/drivers/default/src/console_cmd/switch.c +++ b/zephyr/test/drivers/default/src/console_cmd/switch.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_SUITE(console_cmd_switch, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/console_cmd/sysinfo.c b/zephyr/test/drivers/default/src/console_cmd/sysinfo.c index 3aeef6510c..ba14e9158f 100644 --- a/zephyr/test/drivers/default/src/console_cmd/sysinfo.c +++ b/zephyr/test/drivers/default/src/console_cmd/sysinfo.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "console.h" +#include "system.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" -#include "system.h" + +#include +#include +#include +#include ZTEST_USER(console_cmd_sysinfo, test_no_args) { diff --git a/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c b/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c index 88379a78bd..fc8533280b 100644 --- a/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c +++ b/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_USER(console_cmd_tcpci_dump, test_no_params) { int rv = shell_execute_cmd(get_ec_shell(), "tcpci_dump"); diff --git a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c index a63e2de496..8e40f9ec2a 100644 --- a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c +++ b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" @@ -14,6 +11,9 @@ #include "usb_pd_dpm_sm.h" #include "usb_prl_sm.h" +#include +#include + static void console_cmd_usb_pd_after(void *fixture) { ARG_UNUSED(fixture); diff --git a/zephyr/test/drivers/default/src/console_cmd/vboot_hash.c b/zephyr/test/drivers/default/src/console_cmd/vboot_hash.c index b475f344c8..bdc9dddc66 100644 --- a/zephyr/test/drivers/default/src/console_cmd/vboot_hash.c +++ b/zephyr/test/drivers/default/src/console_cmd/vboot_hash.c @@ -2,12 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include -#include -#include -#include - #include "console.h" #include "flash.h" #include "printf.h" @@ -16,6 +10,13 @@ #include "test/drivers/test_state.h" #include "vboot_hash.h" +#include + +#include +#include +#include +#include + #define CUSTOM_HASH_LENGTH (32) struct console_cmd_hash_fixture { diff --git a/zephyr/test/drivers/default/src/console_cmd/version.c b/zephyr/test/drivers/default/src/console_cmd/version.c index 932cc51449..e3606b5d0e 100644 --- a/zephyr/test/drivers/default/src/console_cmd/version.c +++ b/zephyr/test/drivers/default/src/console_cmd/version.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "console.h" +#include "system.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" -#include "system.h" + +#include +#include +#include ZTEST_USER(console_cmd_version, test_no_args) { diff --git a/zephyr/test/drivers/default/src/console_cmd/waitms.c b/zephyr/test/drivers/default/src/console_cmd/waitms.c index 0d03ee7414..703e233568 100644 --- a/zephyr/test/drivers/default/src/console_cmd/waitms.c +++ b/zephyr/test/drivers/default/src/console_cmd/waitms.c @@ -3,13 +3,14 @@ * found in the LICENSE file. */ +#include "console.h" +#include "timer.h" + #include + #include #include -#include "console.h" -#include "timer.h" - static void test_int(int ms) { char cmd[32]; diff --git a/zephyr/test/drivers/default/src/cros_cbi.c b/zephyr/test/drivers/default/src/cros_cbi.c index e92765cb52..2669abe21e 100644 --- a/zephyr/test/drivers/default/src/cros_cbi.c +++ b/zephyr/test/drivers/default/src/cros_cbi.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "cros_cbi.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST(cros_cbi, test_check_match) { int value; diff --git a/zephyr/test/drivers/default/src/espi.c b/zephyr/test/drivers/default/src/espi.c index 413d42b4c1..e526980ef1 100644 --- a/zephyr/test/drivers/default/src/espi.c +++ b/zephyr/test/drivers/default/src/espi.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" #include "gpio.h" #include "host_command.h" @@ -16,6 +11,12 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include + +#include +#include +#include + #define PORT 0 #define AC_OK_OD_GPIO_NAME "acok_od" diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c index 8f8208415e..29ea381893 100644 --- a/zephyr/test/drivers/default/src/flash.c +++ b/zephyr/test/drivers/default/src/flash.c @@ -3,13 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include - #include "ec_commands.h" #include "emul/emul_flash.h" #include "flash.h" @@ -17,6 +10,13 @@ #include "system.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include +#include +#include + #define WP_L_GPIO_PATH DT_PATH(named_gpios, wp_l) static int gpio_wp_l_set(int value) diff --git a/zephyr/test/drivers/default/src/gpio.c b/zephyr/test/drivers/default/src/gpio.c index 9950edd84c..7304324532 100644 --- a/zephyr/test/drivers/default/src/gpio.c +++ b/zephyr/test/drivers/default/src/gpio.c @@ -8,22 +8,21 @@ * @brief Unit Tests for GPIO. */ -#include - -#include -#include -#include -#include - #include "common.h" #include "ec_tasks.h" #include "gpio.h" #include "gpio/gpio.h" #include "gpio/gpio_int.h" #include "test/drivers/stubs.h" -#include "util.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include "util.h" + +#include +#include +#include +#include +#include extern bool gpio_test_interrupt_triggered; diff --git a/zephyr/test/drivers/default/src/i2c.c b/zephyr/test/drivers/default/src/i2c.c index caced4aedf..a1fa2451f5 100644 --- a/zephyr/test/drivers/default/src/i2c.c +++ b/zephyr/test/drivers/default/src/i2c.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "ec_commands.h" #include "host_command.h" #include "i2c.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST_USER(i2c, test_i2c_set_speed_success) { struct ec_response_i2c_control response; diff --git a/zephyr/test/drivers/default/src/i2c_passthru.c b/zephyr/test/drivers/default/src/i2c_passthru.c index 67e1317876..421d4bb69c 100644 --- a/zephyr/test/drivers/default/src/i2c_passthru.c +++ b/zephyr/test/drivers/default/src/i2c_passthru.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "driver/ln9310.h" #include "ec_commands.h" #include "host_command.h" #include "i2c.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST_USER(i2c_passthru, test_read_without_write) { uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) + diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb.c b/zephyr/test/drivers/default/src/integration/usbc/usb.c index 9fc8f66505..31c8887bf1 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb.c @@ -3,14 +3,10 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "battery_smart.h" +#include "driver/tcpm/ps8xxx_public.h" #include "ec_commands.h" #include "ec_tasks.h" -#include "driver/tcpm/ps8xxx_public.h" #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" #include "emul/tcpc/emul_ps8xxx.h" @@ -27,6 +23,10 @@ #include "test/usb_pe.h" #include "usb_tc_sm.h" +#include +#include +#include + #define BATTERY_NODE DT_NODELABEL(battery) #define GPIO_AC_OK_PATH DT_PATH(named_gpios, acok_od) diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c b/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c index d5c975894e..10ade25222 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "battery_smart.h" #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" @@ -13,6 +11,8 @@ #include "test/drivers/utils.h" #include "usb_pd.h" +#include + #define BATTERY_NODE DT_NODELABEL(battery) struct usb_attach_20v_3a_pd_charger_fixture { diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c index c29762063c..218ef9550e 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "battery_smart.h" #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" @@ -16,6 +13,10 @@ #include "timer.h" #include "usb_pd.h" +#include + +#include + struct usb_attach_5v_3a_pd_sink_fixture { struct tcpci_partner_data sink_5v_3a; struct tcpci_snk_emul_data snk_ext; diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c index c2b603e6ad..325b8aee8c 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "battery.h" #include "battery_smart.h" #include "dps.h" @@ -20,6 +15,11 @@ #include "test/drivers/utils.h" #include "usb_pd.h" +#include +#include +#include +#include + #define BATTERY_NODE DT_NODELABEL(battery) #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c b/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c index bcc94fe869..401a89cb11 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c @@ -3,24 +3,24 @@ * found in the LICENSE file. */ -#include -#include -#include - +#include "driver/tcpm/ps8xxx_public.h" #include "ec_commands.h" #include "ec_tasks.h" -#include "driver/tcpm/ps8xxx_public.h" #include "emul/emul_isl923x.h" #include "emul/tcpc/emul_ps8xxx.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "host_command.h" -#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" -#include "test/usb_pe.h" -#include "test/drivers/utils.h" +#include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include "test/usb_pe.h" + +#include +#include +#include #define SNK_PORT USBC_PORT_C0 #define SRC_PORT USBC_PORT_C1 diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c index 56cbee7ad0..36a417d22c 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" @@ -15,6 +13,8 @@ #include "usb_pd.h" #include "util.h" +#include + struct usb_pd_bist_shared_fixture { struct tcpci_partner_data sink_5v_500ma; struct tcpci_snk_emul_data snk_ext_500ma; diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c index 87b559dd7c..1d3da4921f 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "common.h" #include "ec_tasks.h" #include "emul/emul_isl923x.h" @@ -17,6 +14,10 @@ #include "test/usb_pe.h" #include "usb_pd.h" +#include + +#include + #define TEST_USB_PORT 0 BUILD_ASSERT(TEST_USB_PORT == USBC_PORT_C0); diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c index 2eff9996f2..781a0cc06a 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "battery.h" #include "battery_smart.h" #include "chipset.h" @@ -21,6 +17,10 @@ #include "usb_pd.h" #include "util.h" +#include +#include +#include + struct usb_attach_5v_3a_pd_source_rev3_fixture { struct tcpci_partner_data source_5v_3a; struct tcpci_src_emul_data src_ext; diff --git a/zephyr/test/drivers/default/src/isl923x.c b/zephyr/test/drivers/default/src/isl923x.c index e17dbbe797..72aad72cd9 100644 --- a/zephyr/test/drivers/default/src/isl923x.c +++ b/zephyr/test/drivers/default/src/isl923x.c @@ -3,21 +3,21 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "battery.h" #include "battery_smart.h" -#include "test/drivers/charger_utils.h" #include "driver/charger/isl923x.h" #include "driver/charger/isl923x_public.h" #include "emul/emul_common_i2c.h" #include "emul/emul_isl923x.h" #include "system.h" +#include "test/drivers/charger_utils.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include +#include +#include + BUILD_ASSERT(CONFIG_CHARGER_SENSE_RESISTOR == 10 || CONFIG_CHARGER_SENSE_RESISTOR == 5); diff --git a/zephyr/test/drivers/default/src/led.c b/zephyr/test/drivers/default/src/led.c index e89a3d8b66..3f727599b4 100644 --- a/zephyr/test/drivers/default/src/led.c +++ b/zephyr/test/drivers/default/src/led.c @@ -3,12 +3,6 @@ * found in the LICENSE file. */ -#include -#include - -#include -#include - #include "ec_commands.h" #include "led.h" #include "led_common.h" @@ -16,6 +10,11 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include +#include + ZTEST_SUITE(pwm_led_driver, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/lid_angle.c b/zephyr/test/drivers/default/src/lid_angle.c index 568057d95a..3611e176d4 100644 --- a/zephyr/test/drivers/default/src/lid_angle.c +++ b/zephyr/test/drivers/default/src/lid_angle.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - #include "ec_commands.h" #include "lid_angle.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include + #define LID_ANGLE_MIN_LARGE_ANGLE 0 #define LID_ANGLE_MAX_LARGE_ANGLE 360 diff --git a/zephyr/test/drivers/default/src/lid_switch.c b/zephyr/test/drivers/default/src/lid_switch.c index a0920234b3..2fe7daa85a 100644 --- a/zephyr/test/drivers/default/src/lid_switch.c +++ b/zephyr/test/drivers/default/src/lid_switch.c @@ -3,18 +3,19 @@ * found in the LICENSE file. */ -#include +#include "ec_commands.h" +#include "host_command.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" + #include #include #include -#include #include -#include +#include -#include "test/drivers/test_state.h" -#include "test/drivers/utils.h" -#include "ec_commands.h" -#include "host_command.h" +#include +#include #define LID_GPIO_PATH DT_PATH(named_gpios, lid_open_ec) #define LID_GPIO_PIN DT_GPIO_PIN(LID_GPIO_PATH, gpios) diff --git a/zephyr/test/drivers/default/src/lis2dw12.c b/zephyr/test/drivers/default/src/lis2dw12.c index 8f5e30e559..4cacf725ba 100644 --- a/zephyr/test/drivers/default/src/lis2dw12.c +++ b/zephyr/test/drivers/default/src/lis2dw12.c @@ -3,13 +3,14 @@ * found in the LICENSE file. */ -#include -#include #include "driver/accel_lis2dw12.h" #include "emul/emul_common_i2c.h" #include "emul/emul_lis2dw12.h" #include "test/drivers/test_state.h" +#include +#include + #define LIS2DW12_NODELABEL DT_NODELABEL(ms_lis2dw12_accel) #define LIS2DW12_SENSOR_ID SENSOR_ID(LIS2DW12_NODELABEL) #define LIS2DW12_EMUL_NODE DT_NODELABEL(lis2dw12_emul) diff --git a/zephyr/test/drivers/default/src/ln9310.c b/zephyr/test/drivers/default/src/ln9310.c index 414c62287c..509d6831ec 100644 --- a/zephyr/test/drivers/default/src/ln9310.c +++ b/zephyr/test/drivers/default/src/ln9310.c @@ -3,17 +3,17 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include - #include "driver/ln9310.h" -#include "emul/emul_ln9310.h" #include "emul/emul_common_i2c.h" -#include "timer.h" +#include "emul/emul_ln9310.h" #include "test/drivers/test_state.h" +#include "timer.h" + +#include +#include +#include +#include +#include /* * TODO(b/201420132): Implement approach for tests to immediately schedule work diff --git a/zephyr/test/drivers/default/src/locate_chip.c b/zephyr/test/drivers/default/src/locate_chip.c index 6842543971..c54031c5df 100644 --- a/zephyr/test/drivers/default/src/locate_chip.c +++ b/zephyr/test/drivers/default/src/locate_chip.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ +#include "host_command.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" + #include -#include #include +#include #include -#include "test/drivers/test_state.h" -#include "test/drivers/utils.h" -#include "host_command.h" - /** * @brief TestPurpose: test the TCPC locate valid case. */ diff --git a/zephyr/test/drivers/default/src/motion_sense/motion_sense.c b/zephyr/test/drivers/default/src/motion_sense/motion_sense.c index 42ee056874..c3f03e4ade 100644 --- a/zephyr/test/drivers/default/src/motion_sense/motion_sense.c +++ b/zephyr/test/drivers/default/src/motion_sense/motion_sense.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "motion_sense.h" #include "test/drivers/test_state.h" +#include + ZTEST_SUITE(motion_sense, drivers_predicate_post_main, NULL, NULL, NULL, NULL); ZTEST_USER(motion_sense, ec_motion_sensor_fill_values) diff --git a/zephyr/test/drivers/default/src/panic.c b/zephyr/test/drivers/default/src/panic.c index 7dcb18e4cf..a2addc786d 100644 --- a/zephyr/test/drivers/default/src/panic.c +++ b/zephyr/test/drivers/default/src/panic.c @@ -8,18 +8,17 @@ * @brief Unit Tests for panic. */ -#include - -#include -#include -#include - #include "common.h" #include "ec_tasks.h" #include "panic.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include + struct panic_test_fixture { struct panic_data saved_pdata; }; diff --git a/zephyr/test/drivers/default/src/panic_output.c b/zephyr/test/drivers/default/src/panic_output.c index 210c862901..f815744d8c 100644 --- a/zephyr/test/drivers/default/src/panic_output.c +++ b/zephyr/test/drivers/default/src/panic_output.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "panic.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include + ZTEST_SUITE(panic_output, drivers_predicate_post_main, NULL, NULL, NULL, NULL); ZTEST(panic_output, test_panic_printf) diff --git a/zephyr/test/drivers/default/src/port80.c b/zephyr/test/drivers/default/src/port80.c index 8563c2e478..6bde1392c7 100644 --- a/zephyr/test/drivers/default/src/port80.c +++ b/zephyr/test/drivers/default/src/port80.c @@ -8,19 +8,18 @@ * @brief Unit Tests for ESPI port 80 writes */ -#include -#include -#include -#include - #include "console.h" #include "ec_commands.h" #include "host_command.h" #include "port80.h" - #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include +#include + /* * Flush any existing writes. */ diff --git a/zephyr/test/drivers/default/src/power_common.c b/zephyr/test/drivers/default/src/power_common.c index f96fed9f05..6e18204188 100644 --- a/zephyr/test/drivers/default/src/power_common.c +++ b/zephyr/test/drivers/default/src/power_common.c @@ -3,31 +3,30 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include -#include - +#include "battery.h" +#include "battery_smart.h" #include "chipset.h" #include "common.h" +#include "ec_tasks.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_smart_battery.h" #include "extpower.h" #include "hooks.h" #include "host_command.h" #include "power.h" -#include "test/drivers/stubs.h" #include "task.h" -#include "ec_tasks.h" +#include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" -#include "emul/emul_common_i2c.h" -#include "emul/emul_smart_battery.h" +#include -#include "battery.h" -#include "battery_smart.h" -#include "test/drivers/utils.h" +#include +#include +#include +#include +#include +#include #define BATTERY_NODE DT_NODELABEL(battery) diff --git a/zephyr/test/drivers/default/src/ppc_sn5s330.c b/zephyr/test/drivers/default/src/ppc_sn5s330.c index eb595939fc..664d9fed36 100644 --- a/zephyr/test/drivers/default/src/ppc_sn5s330.c +++ b/zephyr/test/drivers/default/src/ppc_sn5s330.c @@ -3,20 +3,20 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include - #include "driver/ppc/sn5s330.h" #include "driver/ppc/sn5s330_public.h" #include "emul/emul_common_i2c.h" #include "emul/emul_sn5s330.h" -#include "usbc_ppc.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include "usbc_ppc.h" + +#include +#include +#include +#include +#include +#include /** This must match the index of the sn5s330 in ppc_chips[] */ #define SN5S330_PORT 0 diff --git a/zephyr/test/drivers/default/src/ppc_syv682x.c b/zephyr/test/drivers/default/src/ppc_syv682x.c index 648510da07..6e1602804e 100644 --- a/zephyr/test/drivers/default/src/ppc_syv682x.c +++ b/zephyr/test/drivers/default/src/ppc_syv682x.c @@ -3,24 +3,24 @@ * found in the LICENSE file. */ +#include "emul/emul_common_i2c.h" +#include "emul/emul_syv682x.h" +#include "syv682x.h" +#include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include "timer.h" +#include "usbc_ppc.h" + #include #include -#include #include +#include #include #include #include #include -#include "emul/emul_common_i2c.h" -#include "emul/emul_syv682x.h" -#include "test/drivers/stubs.h" -#include "syv682x.h" -#include "timer.h" -#include "test/drivers/test_state.h" -#include "test/drivers/utils.h" -#include "usbc_ppc.h" - #define SYV682X_NODE DT_NODELABEL(syv682x_emul) #define GPIO_USB_C1_FRS_EN_PATH DT_PATH(named_gpios, usb_c1_frs_en) diff --git a/zephyr/test/drivers/default/src/ps8xxx.c b/zephyr/test/drivers/default/src/ps8xxx.c index 6fb1658c06..cb0ac7d2d5 100644 --- a/zephyr/test/drivers/default/src/ps8xxx.c +++ b/zephyr/test/drivers/default/src/ps8xxx.c @@ -3,22 +3,21 @@ * found in the LICENSE file. */ -#include -#include - #include "common.h" +#include "driver/tcpm/ps8xxx.h" +#include "driver/tcpm/ps8xxx_public.h" #include "emul/emul_common_i2c.h" -#include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_ps8xxx.h" -#include "timer.h" +#include "emul/tcpc/emul_tcpci.h" #include "i2c.h" +#include "tcpm/tcpci.h" #include "test/drivers/stubs.h" #include "test/drivers/tcpci_test_common.h" - -#include "tcpm/tcpci.h" -#include "driver/tcpm/ps8xxx.h" -#include "driver/tcpm/ps8xxx_public.h" #include "test/drivers/test_state.h" +#include "timer.h" + +#include +#include #define PS8XXX_EMUL_NODE DT_NODELABEL(ps8xxx_emul) diff --git a/zephyr/test/drivers/default/src/smart.c b/zephyr/test/drivers/default/src/smart.c index 9db292ac96..a26d84b93c 100644 --- a/zephyr/test/drivers/default/src/smart.c +++ b/zephyr/test/drivers/default/src/smart.c @@ -3,21 +3,20 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - +#include "battery.h" +#include "battery_smart.h" #include "common.h" #include "console.h" -#include "i2c.h" #include "emul/emul_common_i2c.h" #include "emul/emul_smart_battery.h" - -#include "battery.h" -#include "battery_smart.h" +#include "i2c.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include + #define BATTERY_NODE DT_NODELABEL(battery) /** Test all simple getters */ diff --git a/zephyr/test/drivers/default/src/stm_mems_common.c b/zephyr/test/drivers/default/src/stm_mems_common.c index f7c59105b0..09f1cf8506 100644 --- a/zephyr/test/drivers/default/src/stm_mems_common.c +++ b/zephyr/test/drivers/default/src/stm_mems_common.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "common.h" #include "driver/stm_mems_common.h" #include "emul/emul_common_i2c.h" @@ -15,6 +10,12 @@ #include "i2c/i2c.h" #include "test/drivers/test_state.h" +#include + +#include +#include +#include + #define MOCK_EMUL EMUL_DT_GET(DT_NODELABEL(i2c_mock)) #define COMMON_DATA emul_i2c_mock_get_i2c_common_data(MOCK_EMUL) diff --git a/zephyr/test/drivers/default/src/tablet_mode.c b/zephyr/test/drivers/default/src/tablet_mode.c index d600d26072..c947663239 100644 --- a/zephyr/test/drivers/default/src/tablet_mode.c +++ b/zephyr/test/drivers/default/src/tablet_mode.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "console.h" #include "tablet_mode.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include +#include + static void tabletmode_before(void *state) { ARG_UNUSED(state); diff --git a/zephyr/test/drivers/default/src/task.c b/zephyr/test/drivers/default/src/task.c index 1f29a4f2f2..4c4087c5a1 100644 --- a/zephyr/test/drivers/default/src/task.c +++ b/zephyr/test/drivers/default/src/task.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - #include "task.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" #include "timer.h" +#include + struct tasks_fixture { timestamp_t fake_time; }; diff --git a/zephyr/test/drivers/default/src/tcpci.c b/zephyr/test/drivers/default/src/tcpci.c index de2437eb96..f648b43a96 100644 --- a/zephyr/test/drivers/default/src/tcpci.c +++ b/zephyr/test/drivers/default/src/tcpci.c @@ -3,23 +3,22 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "common.h" #include "ec_tasks.h" #include "emul/emul_common_i2c.h" #include "emul/tcpc/emul_tcpci.h" #include "hooks.h" #include "i2c.h" +#include "tcpm/tcpci.h" #include "test/drivers/stubs.h" #include "test/drivers/tcpci_test_common.h" - -#include "tcpm/tcpci.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include + #define TCPCI_EMUL_NODE DT_NODELABEL(tcpci_emul) /* Convenience pointer directly to the TCPCI mux under test */ diff --git a/zephyr/test/drivers/default/src/tcpci_test_common.c b/zephyr/test/drivers/default/src/tcpci_test_common.c index 473fbe0f20..06f03d4834 100644 --- a/zephyr/test/drivers/default/src/tcpci_test_common.c +++ b/zephyr/test/drivers/default/src/tcpci_test_common.c @@ -3,15 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "common.h" #include "emul/emul_common_i2c.h" #include "emul/tcpc/emul_tcpci.h" +#include "tcpm/tcpci.h" #include "test/drivers/tcpci_test_common.h" -#include "tcpm/tcpci.h" +#include +#include /** Check TCPC register value */ void check_tcpci_reg_f(const struct emul *emul, int reg, uint16_t exp_val, diff --git a/zephyr/test/drivers/default/src/tcs3400.c b/zephyr/test/drivers/default/src/tcs3400.c index 045451169e..dba8dc5c56 100644 --- a/zephyr/test/drivers/default/src/tcs3400.c +++ b/zephyr/test/drivers/default/src/tcs3400.c @@ -3,19 +3,18 @@ * found in the LICENSE file. */ -#include -#include - #include "common.h" -#include "i2c.h" -#include "emul/emul_tcs3400.h" +#include "driver/als_tcs3400.h" #include "emul/emul_common_i2c.h" - +#include "emul/emul_tcs3400.h" +#include "i2c.h" #include "motion_sense.h" #include "motion_sense_fifo.h" -#include "driver/als_tcs3400.h" #include "test/drivers/test_state.h" +#include +#include + #define TCS_NODE DT_NODELABEL(tcs_emul) #define TCS_CLR_SENSOR_ID SENSOR_ID(DT_NODELABEL(tcs3400_clear)) #define TCS_RGB_SENSOR_ID SENSOR_ID(DT_NODELABEL(tcs3400_rgb)) diff --git a/zephyr/test/drivers/default/src/temp_sensor.c b/zephyr/test/drivers/default/src/temp_sensor.c index f387302d73..83d9aa3812 100644 --- a/zephyr/test/drivers/default/src/temp_sensor.c +++ b/zephyr/test/drivers/default/src/temp_sensor.c @@ -3,16 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include -#include - -#include - #include "common.h" #include "driver/temp_sensor/pct2075.h" #include "emul/emul_pct2075.h" @@ -22,6 +12,16 @@ #include "test/drivers/test_state.h" #include "timer.h" +#include + +#include +#include +#include +#include +#include +#include +#include + #define GPIO_PG_EC_DSW_PWROK_PATH DT_PATH(named_gpios, pg_ec_dsw_pwrok) #define GPIO_PG_EC_DSW_PWROK_PORT DT_GPIO_PIN(GPIO_PG_EC_DSW_PWROK_PATH, gpios) diff --git a/zephyr/test/drivers/default/src/thermistor.c b/zephyr/test/drivers/default/src/thermistor.c index 9e41307618..edbe7acad5 100644 --- a/zephyr/test/drivers/default/src/thermistor.c +++ b/zephyr/test/drivers/default/src/thermistor.c @@ -3,18 +3,19 @@ * found in the LICENSE file. */ -#include -#include +#include "../driver/temp_sensor/thermistor.h" +#include "common.h" +#include "temp_sensor/temp_sensor.h" +#include "test/drivers/test_state.h" + #include #include #include #include -#include +#include +#include -#include "common.h" -#include "../driver/temp_sensor/thermistor.h" -#include "temp_sensor/temp_sensor.h" -#include "test/drivers/test_state.h" +#include #define GPIO_PG_EC_DSW_PWROK_PATH DT_PATH(named_gpios, pg_ec_dsw_pwrok) #define GPIO_PG_EC_DSW_PWROK_PORT DT_GPIO_PIN(GPIO_PG_EC_DSW_PWROK_PATH, gpios) diff --git a/zephyr/test/drivers/default/src/uart_hostcmd.c b/zephyr/test/drivers/default/src/uart_hostcmd.c index 5e1e200fa9..907dba929f 100644 --- a/zephyr/test/drivers/default/src/uart_hostcmd.c +++ b/zephyr/test/drivers/default/src/uart_hostcmd.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "host_command.h" -#include "uart.h" #include "test/drivers/test_state.h" +#include "uart.h" + +#include +#include /** Messages used in test */ static const char msg1[] = "test"; diff --git a/zephyr/test/drivers/default/src/usb_mux.c b/zephyr/test/drivers/default/src/usb_mux.c index 4aea56962e..0e89cf2398 100644 --- a/zephyr/test/drivers/default/src/usb_mux.c +++ b/zephyr/test/drivers/default/src/usb_mux.c @@ -3,30 +3,29 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include - #include "common.h" #include "ec_commands.h" #include "ec_tasks.h" -#include #include "hooks.h" #include "host_command.h" #include "i2c.h" -#include "test/drivers/stubs.h" #include "task.h" #include "tcpm/ps8xxx_public.h" #include "tcpm/tcpci.h" +#include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include "usb_mux.h" #include "usb_prl_sm.h" #include "usb_tc_sm.h" -#include "usb_mux.h" -#include "test/drivers/test_state.h" -#include "test/drivers/utils.h" +#include +#include +#include +#include +#include +#include +#include /** Copy of original usb_muxes[USB_PORT_C1] */ static struct usb_mux_chain usb_mux_c1; diff --git a/zephyr/test/drivers/default/src/util.c b/zephyr/test/drivers/default/src/util.c index 32f989bb0f..342ce9b971 100644 --- a/zephyr/test/drivers/default/src/util.c +++ b/zephyr/test/drivers/default/src/util.c @@ -2,11 +2,11 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include - -#include "util.h" #include "test/drivers/test_state.h" +#include "util.h" + +#include +#include ZTEST(util, reverse) { diff --git a/zephyr/test/drivers/default/src/vboot_hash.c b/zephyr/test/drivers/default/src/vboot_hash.c index 04f535a89c..61d4260a23 100644 --- a/zephyr/test/drivers/default/src/vboot_hash.c +++ b/zephyr/test/drivers/default/src/vboot_hash.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "ec_commands.h" #include "host_command.h" #include "test/drivers/test_state.h" +#include +#include + +#include + ZTEST_USER(vboot_hash, test_hostcmd_abort) { struct ec_response_vboot_hash response; diff --git a/zephyr/test/drivers/default/src/virtual_battery.c b/zephyr/test/drivers/default/src/virtual_battery.c index 87c031e723..ee3eab217c 100644 --- a/zephyr/test/drivers/default/src/virtual_battery.c +++ b/zephyr/test/drivers/default/src/virtual_battery.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "battery.h" #include "battery_smart.h" #include "ec_commands.h" @@ -13,6 +10,9 @@ #include "host_command.h" #include "test/drivers/test_state.h" +#include +#include + void copy_memmap_string(uint8_t *dest, int offset, int len); /* The param buffer has at most 2 msg's (write + read) and 1 byte write len. */ diff --git a/zephyr/test/drivers/default/src/vstore.c b/zephyr/test/drivers/default/src/vstore.c index b4264aaeb3..923d14ff00 100644 --- a/zephyr/test/drivers/default/src/vstore.c +++ b/zephyr/test/drivers/default/src/vstore.c @@ -3,19 +3,20 @@ * found in the LICENSE file. */ +#include "ec_commands.h" +#include "host_command.h" +#include "system.h" +#include "system_fake.h" +#include "test/drivers/test_state.h" +#include "vstore.h" + #include -#include #include #include #include -#include "ec_commands.h" -#include "host_command.h" -#include "system.h" -#include "system_fake.h" -#include "vstore.h" -#include "test/drivers/test_state.h" +#include ZTEST_SUITE(vstore, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/default/src/watchdog.c b/zephyr/test/drivers/default/src/watchdog.c index 958aa3eaaa..a82800a6de 100644 --- a/zephyr/test/drivers/default/src/watchdog.c +++ b/zephyr/test/drivers/default/src/watchdog.c @@ -8,20 +8,19 @@ * @brief Unit Tests for watchdog. */ -#include -#include - -#include -#include -#include - #include "common.h" #include "ec_tasks.h" -#include #include "hooks.h" #include "test/drivers/stubs.h" -#include "watchdog.h" #include "test/drivers/test_state.h" +#include "watchdog.h" + +#include +#include +#include +#include +#include +#include #define wdt DEVICE_DT_GET(DT_CHOSEN(cros_ec_watchdog)) diff --git a/zephyr/test/drivers/dps/src/dps.c b/zephyr/test/drivers/dps/src/dps.c index 88fd81a709..a573da670b 100644 --- a/zephyr/test/drivers/dps/src/dps.c +++ b/zephyr/test/drivers/dps/src/dps.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "builtin/stdio.h" #include "console.h" #include "dps.h" #include "test/drivers/test_state.h" #include "timer.h" +#include + struct dps_fixture { struct dps_config_t saved_config; int saved_debug_level; diff --git a/zephyr/test/drivers/host_cmd/src/adc.c b/zephyr/test/drivers/host_cmd/src/adc.c index 6b2bef1165..f283ef17d5 100644 --- a/zephyr/test/drivers/host_cmd/src/adc.c +++ b/zephyr/test/drivers/host_cmd/src/adc.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "adc.h" #include "host_command.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include + FAKE_VALUE_FUNC(int, adc_read_channel, enum adc_channel); ZTEST(hc_adc, normal_path) diff --git a/zephyr/test/drivers/host_cmd/src/battery_cut_off.c b/zephyr/test/drivers/host_cmd/src/battery_cut_off.c index ed9d96481d..019362f3c8 100644 --- a/zephyr/test/drivers/host_cmd/src/battery_cut_off.c +++ b/zephyr/test/drivers/host_cmd/src/battery_cut_off.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "battery.h" #include "emul/emul_common_i2c.h" #include "emul/emul_smart_battery.h" @@ -14,6 +11,9 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + struct host_cmd_battery_cut_off_fixture { const struct emul *emul; struct i2c_common_emul_data *i2c_emul; diff --git a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c index 029551a49b..6af3d35043 100644 --- a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c +++ b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charge_state.h" #include "host_command.h" #include "test/drivers/test_state.h" +#include + ZTEST_USER(battery_display_soc, happy_path) { const uint32_t full_charge_as_tenths = diff --git a/zephyr/test/drivers/host_cmd/src/battery_v2.c b/zephyr/test/drivers/host_cmd/src/battery_v2.c index 3e0ac969f9..a6fab89b8c 100644 --- a/zephyr/test/drivers/host_cmd/src/battery_v2.c +++ b/zephyr/test/drivers/host_cmd/src/battery_v2.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "ec_commands.h" #include "host_command.h" #include "test/drivers/test_state.h" +#include + ZTEST(host_cmd_battery_v2, test_get_static__invalid_index) { struct ec_response_battery_static_info response; diff --git a/zephyr/test/drivers/host_cmd/src/charge_manager.c b/zephyr/test/drivers/host_cmd/src/charge_manager.c index 50a476dd99..6bbf7a3ae3 100644 --- a/zephyr/test/drivers/host_cmd/src/charge_manager.c +++ b/zephyr/test/drivers/host_cmd/src/charge_manager.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "charge_manager.h" #include "host_command.h" #include "test/drivers/test_state.h" +#include + ZTEST_USER(charge_manager, test_port_count) { struct ec_response_charge_port_count response = { 0 }; diff --git a/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c b/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c index b935b69e46..0fa7ab3770 100644 --- a/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c +++ b/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charge_state.h" #include "host_command.h" #include "test/drivers/test_state.h" +#include + ZTEST_USER(hc_get_cmd_versions, test_v0__both_versions) { struct ec_params_get_cmd_versions params = { diff --git a/zephyr/test/drivers/host_cmd/src/get_panic_info.c b/zephyr/test/drivers/host_cmd/src/get_panic_info.c index bdb19d9a98..85d5fdd6f2 100644 --- a/zephyr/test/drivers/host_cmd/src/get_panic_info.c +++ b/zephyr/test/drivers/host_cmd/src/get_panic_info.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "host_command.h" #include "panic.h" #include "test/drivers/test_state.h" +#include + struct host_cmd_get_panic_info_fixture { struct panic_data saved_pdata; }; diff --git a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c index 721fbcd8f9..2d9410232d 100644 --- a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c +++ b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + ZTEST_USER(host_cmd_get_pd_port_caps, test_good_index) { struct ec_params_get_pd_port_caps params = { .port = 0 }; diff --git a/zephyr/test/drivers/host_cmd/src/host_command.c b/zephyr/test/drivers/host_cmd/src/host_command.c index 49e41acc89..a9f0fcb941 100644 --- a/zephyr/test/drivers/host_cmd/src/host_command.c +++ b/zephyr/test/drivers/host_cmd/src/host_command.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "ec_commands.h" #include "host_command.h" #include "test/drivers/test_state.h" +#include + ZTEST(host_cmd_host_commands, get_command_versions__v1) { struct ec_response_get_cmd_versions response; diff --git a/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c b/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c index 9d29aeb7de..f4bf956e9b 100644 --- a/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c +++ b/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "host_command.h" #include "test/drivers/test_state.h" +#include + ZTEST_USER(hc_test_protocol, test_echo_max_buffer_size) { struct ec_params_test_protocol params = { diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands.c b/zephyr/test/drivers/host_cmd/src/host_event_commands.c index c2f7e72045..8e7fff0fe2 100644 --- a/zephyr/test/drivers/host_cmd/src/host_event_commands.c +++ b/zephyr/test/drivers/host_cmd/src/host_event_commands.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -#include #include "include/lpc.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include + struct host_cmd_host_event_commands_fixture { struct host_events_ctx ctx; }; diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c index 6d0a386d6e..3c72bb5f51 100644 --- a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c +++ b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c @@ -5,11 +5,12 @@ /* Tests for deprecated EC_CMD_HOST_EVENT_* commands */ -#include #include "include/lpc.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include + #define HOST_EVENT_TEST_MASK_VAL EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) static void diff --git a/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c b/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c index 30ff8c11b2..19fdd9ea4a 100644 --- a/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c +++ b/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "host_command.h" #include "test/drivers/test_state.h" +#include + ZTEST(host_request_expected_size, test_mismatched_host_request_version) { const struct ec_host_request request = { diff --git a/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c b/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c index 4c74a48ab4..e77230cfaf 100644 --- a/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c +++ b/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -#include #include "include/keyboard_mkbp.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include + struct keyboard_mkbp_commands_fixture { struct ec_mkbp_config config; }; diff --git a/zephyr/test/drivers/host_cmd/src/motion_sense.c b/zephyr/test/drivers/host_cmd/src/motion_sense.c index 1b35eb637c..919baf7219 100644 --- a/zephyr/test/drivers/host_cmd/src/motion_sense.c +++ b/zephyr/test/drivers/host_cmd/src/motion_sense.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "atomic.h" #include "console.h" #include "driver/accel_bma2x2.h" @@ -17,6 +13,10 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include + FAKE_VALUE_FUNC(int, mock_set_range, struct motion_sensor_t *, int, int); FAKE_VALUE_FUNC(int, mock_set_offset, const struct motion_sensor_t *, const int16_t *, int16_t); diff --git a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c index 54c8786548..c04e74810a 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c +++ b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + #define TEST_PORT USBC_PORT_C0 #define BAD_PORT 65 diff --git a/zephyr/test/drivers/host_cmd/src/pd_control.c b/zephyr/test/drivers/host_cmd/src/pd_control.c index 97624fdb34..a881a8e0ea 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_control.c +++ b/zephyr/test/drivers/host_cmd/src/pd_control.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "console.h" #include "ec_commands.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include + #define TEST_PORT USBC_PORT_C0 #define BAD_PORT 82 diff --git a/zephyr/test/drivers/host_cmd/src/pd_log.c b/zephyr/test/drivers/host_cmd/src/pd_log.c index a6022d8bb1..6b5ffc197d 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_log.c +++ b/zephyr/test/drivers/host_cmd/src/pd_log.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "event_log.h" #include "host_command.h" #include "test/drivers/test_state.h" #include "usb_pd.h" +#include +#include + /** * @brief This is the maximum size of a single log entry. * diff --git a/zephyr/test/drivers/host_cmd/src/tablet_mode.c b/zephyr/test/drivers/host_cmd/src/tablet_mode.c index cb65899c4f..a84faa035f 100644 --- a/zephyr/test/drivers/host_cmd/src/tablet_mode.c +++ b/zephyr/test/drivers/host_cmd/src/tablet_mode.c @@ -3,17 +3,17 @@ * found in the LICENSE file. */ -#include -#include - +#include "emul/emul_common_i2c.h" +#include "emul/emul_smart_battery.h" #include "hooks.h" #include "host_command.h" #include "tablet_mode.h" -#include "emul/emul_common_i2c.h" -#include "emul/emul_smart_battery.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + struct host_cmd_tablet_mode_fixture { const struct emul *emul; struct i2c_common_emul_data *i2c_emul; diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c index 8947fdca8c..f926c2b7ca 100644 --- a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c +++ b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "ec_commands.h" #include "emul/emul_isl923x.h" @@ -16,6 +13,9 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include + #define TEST_PORT USBC_PORT_C0 #define BAD_PORT 42 diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c index 3afc90760a..d95461f274 100644 --- a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c +++ b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "ec_commands.h" #include "host_command.h" #include "test/drivers/test_state.h" #include "usb_pd.h" +#include +#include + ZTEST_USER(usb_pd_host_cmd, test_hc_pd_host_event_status) { struct ec_response_host_event_status response; diff --git a/zephyr/test/drivers/host_command_thread/src/main.c b/zephyr/test/drivers/host_command_thread/src/main.c index 633942258e..d1df1ffed2 100644 --- a/zephyr/test/drivers/host_command_thread/src/main.c +++ b/zephyr/test/drivers/host_command_thread/src/main.c @@ -10,15 +10,15 @@ * Do not add tests to this binary. This test messes with the main thread and * can only run a single test function. */ +#include "host_command.h" +#include "task.h" +#include "test/drivers/test_state.h" + #include #include #include -#include "host_command.h" -#include "task.h" -#include "test/drivers/test_state.h" - #define CUSTOM_COMMAND_ID 0x0088 /* Pointer to the main thread, defined in kernel/init.c */ diff --git a/zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h b/zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h index c60c455dfa..c235d64825 100644 --- a/zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h +++ b/zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include - #include "emul/emul_common_i2c.h" +#include + #define BASIC_I2C_DEV_EXT_ACCESS_REG 0xFF /** diff --git a/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c b/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c index 1b7810ad84..8d00d5d3ba 100644 --- a/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c +++ b/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c @@ -2,13 +2,14 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include - #include "basic_i2c_device_emul.h" #include "emul/emul_common_i2c.h" #include "emul/emul_stub_device.h" +#include + +#include + #define DT_DRV_COMPAT basic_i2c_device void basic_i2c_device_reset(const struct emul *emul) diff --git a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c index 0beb773297..4c00043e11 100644 --- a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c +++ b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c @@ -2,15 +2,15 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ +#include "basic_i2c_device_emul.h" +#include "i2c.h" +#include "test/drivers/test_state.h" + #include #include #include #include -#include "basic_i2c_device_emul.h" -#include "i2c.h" -#include "test/drivers/test_state.h" - struct i2c_controller_fixture { int port; int addr; diff --git a/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c b/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c index f27791949e..a4e326bcec 100644 --- a/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c +++ b/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "driver/charger/isl923x.h" #include "driver/charger/isl923x_public.h" #include "emul/emul_common_i2c.h" @@ -12,6 +10,8 @@ #include "test/drivers/charger_utils.h" #include "test/drivers/test_state.h" +#include + #define CHARGER_NUM get_charger_num(&isl923x_drv) #define ISL923X_EMUL EMUL_DT_GET(DT_NODELABEL(isl923x_emul)) diff --git a/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c b/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c index f8cd76d524..8eef7ea748 100644 --- a/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c +++ b/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "adc.h" #include "console.h" #include "driver/charger/isl923x.h" @@ -19,6 +14,11 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include +#include + #define ADC_DEVICE_NODE DT_NODELABEL(adc0) #define CHARGER_NUM get_charger_num(&isl923x_drv) #define ISL923X_EMUL EMUL_DT_GET(DT_NODELABEL(isl923x_emul)) diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c index 5b7cbfb2c7..6ced5c81bd 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c @@ -3,18 +3,19 @@ * found in the LICENSE file. */ +#include "console.h" +#include "host_command.h" +#include "keyboard_backlight.h" +#include "test/drivers/test_state.h" + #include #include -#include + #include #include +#include #include -#include "console.h" -#include "host_command.h" -#include "keyboard_backlight.h" -#include "test/drivers/test_state.h" - /** * @brief Send host command to set the backlight percentage * diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c index beaabd718d..91b69562b1 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c @@ -2,15 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include -#include -#include - #include "console.h" #include "host_command.h" #include "keyboard_scan.h" @@ -18,6 +9,17 @@ #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include + +#include +#include +#include +#include +#include +#include + +#include + ZTEST(keyboard_scan, test_boot_key) { const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(cros_kb_raw)); diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c index e20ece362b..4141028408 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include +#include + const static struct device *dev = DEVICE_DT_GET(DT_NODELABEL(cros_kb_raw)); int emulate_keystate(int row, int col, int pressed) diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c index 26a962d5fc..b45f7b20ef 100644 --- a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c +++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c @@ -2,13 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include - #include "console.h" #include "host_command.h" #include "mkbp_event.h" @@ -16,6 +9,14 @@ #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include +#include + +#include + /** * @brief FFF fake that will be registered as a callback to monitor the EC->AP * interrupt pin. Implements `gpio_callback_handler_t`. diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c index 0e2a476f12..6fd1b0f975 100644 --- a/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c +++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c @@ -2,10 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include -#include - #include "console.h" #include "host_command.h" #include "keyboard_scan.h" @@ -14,6 +10,11 @@ #include "mkbp_input_devices.h" #include "test/drivers/test_state.h" +#include +#include + +#include + ZTEST(mkbp_info, host_command_mkbp_info__keyboard_info) { /* Get the number of keyboard rows and columns */ diff --git a/zephyr/test/drivers/led_driver/src/led.c b/zephyr/test/drivers/led_driver/src/led.c index 4e4023beb4..135f2eab01 100644 --- a/zephyr/test/drivers/led_driver/src/led.c +++ b/zephyr/test/drivers/led_driver/src/led.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include #include "ec_commands.h" #include "gpio.h" #include "include/power.h" @@ -12,6 +11,8 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include + #define VERIFY_LED_COLOR(color, led_id) \ { \ const struct led_pins_node_t *pin_node = \ diff --git a/zephyr/test/drivers/led_driver/src/led_common.c b/zephyr/test/drivers/led_driver/src/led_common.c index e11a1f1952..2b113499a0 100644 --- a/zephyr/test/drivers/led_driver/src/led_common.c +++ b/zephyr/test/drivers/led_driver/src/led_common.c @@ -2,13 +2,13 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include - #include "host_command.h" #include "led_common.h" #include "test/drivers/test_state.h" +#include +#include + ZTEST(led_common, host_command__query) { /* Gets the brightness range for an LED */ diff --git a/zephyr/test/drivers/locate_chip/src/locate_chip.c b/zephyr/test/drivers/locate_chip/src/locate_chip.c index 5e4fd078d7..881b17a54c 100644 --- a/zephyr/test/drivers/locate_chip/src/locate_chip.c +++ b/zephyr/test/drivers/locate_chip/src/locate_chip.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include - -#include "test/drivers/test_state.h" #include "host_command.h" +#include "test/drivers/test_state.h" + +#include ZTEST_SUITE(locate_chip, drivers_predicate_post_main, NULL, NULL, NULL, NULL); diff --git a/zephyr/test/drivers/mkbp/src/mkbp_fifo.c b/zephyr/test/drivers/mkbp/src/mkbp_fifo.c index b80febbec9..5d59dababd 100644 --- a/zephyr/test/drivers/mkbp/src/mkbp_fifo.c +++ b/zephyr/test/drivers/mkbp/src/mkbp_fifo.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include - #include "keyboard_config.h" #include "mkbp_fifo.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include +#include + /* Tests for Matrix Keyboard Protocol (MKBP) */ /* Largest event size that we support */ diff --git a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c index a76400a98a..521b4c735b 100644 --- a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c +++ b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "ec_commands.h" #include "hooks.h" #include "host_command.h" @@ -15,6 +11,10 @@ #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include +#include +#include + #define ARBITRARY_SLEEP_TRANSITIONS 1 /* diff --git a/zephyr/test/drivers/rt9490/src/bc12.c b/zephyr/test/drivers/rt9490/src/bc12.c index 7e7d9c2678..b32d50768e 100644 --- a/zephyr/test/drivers/rt9490/src/bc12.c +++ b/zephyr/test/drivers/rt9490/src/bc12.c @@ -3,11 +3,8 @@ * found in the LICENSE file. */ -#include -#include - -#include "charger.h" #include "charge_manager.h" +#include "charger.h" #include "driver/charger/rt9490.h" #include "driver/tcpm/tcpci.h" #include "emul/emul_rt9490.h" @@ -17,6 +14,9 @@ #include "timer.h" #include "usb_charge.h" +#include +#include + FAKE_VALUE_FUNC(int, board_tcpc_post_init, int); static const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(rt9490)); diff --git a/zephyr/test/drivers/rt9490/src/charger.c b/zephyr/test/drivers/rt9490/src/charger.c index f0d3510b89..2d892f9432 100644 --- a/zephyr/test/drivers/rt9490/src/charger.c +++ b/zephyr/test/drivers/rt9490/src/charger.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "battery_smart.h" #include "charger.h" #include "driver/charger/rt9490.h" #include "emul/emul_rt9490.h" #include "i2c.h" +#include + static const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(rt9490)); static const int chgnum = CHARGER_SOLO; diff --git a/zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c b/zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c index 035d0c1b48..5e9381c2a5 100644 --- a/zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c +++ b/zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "system.h" #include "test/drivers/test_state.h" #include "util.h" +#include + /* * TODO(b/254924012): Test alternative GPIO when emulated gpio tristate is * supported upstream. diff --git a/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c b/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c index b30ae6db6c..ddc406e58c 100644 --- a/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c +++ b/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c @@ -3,12 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include - #include "drivers/cros_displight.h" #include "ec_commands.h" #include "host_command.h" @@ -16,6 +10,12 @@ #include "pwm.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include +#include + ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__kblight) { struct ec_params_pwm_set_duty p = { diff --git a/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c b/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c index b3d2dfa465..6f4f9a43e2 100644 --- a/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c +++ b/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c @@ -3,17 +3,17 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" #include "host_command.h" #include "lpc.h" #include "system.h" #include "test/drivers/test_state.h" +#include +#include +#include +#include + ZTEST_USER(rtc_shim, test_hc_rtc_set_get_value) { struct ec_params_rtc set_value; diff --git a/zephyr/test/drivers/system/src/system.c b/zephyr/test/drivers/system/src/system.c index 4e3009ceab..b615dfc2df 100644 --- a/zephyr/test/drivers/system/src/system.c +++ b/zephyr/test/drivers/system/src/system.c @@ -3,19 +3,19 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "ec_commands.h" #include "host_command.h" +#include "mock/power.h" #include "panic.h" #include "system.h" #include "test/drivers/stubs.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" -#include "mock/power.h" + +#include +#include +#include FAKE_VALUE_FUNC(int, system_run_image_copy_with_flags, enum ec_image, int); FAKE_VOID_FUNC(system_disable_jump); diff --git a/zephyr/test/drivers/system/src/system_board_version_cbi.c b/zephyr/test/drivers/system/src/system_board_version_cbi.c index d076716e23..cd4e40eef2 100644 --- a/zephyr/test/drivers/system/src/system_board_version_cbi.c +++ b/zephyr/test/drivers/system/src/system_board_version_cbi.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "ec_commands.h" #include "host_command.h" #include "system.h" -#include "test/drivers/test_state.h" #include "test/drivers/test_mocks.h" +#include "test/drivers/test_state.h" + +#include +#include FAKE_VALUE_FUNC(int, cbi_get_board_version, uint32_t *); diff --git a/zephyr/test/drivers/system/src/system_board_version_default.c b/zephyr/test/drivers/system/src/system_board_version_default.c index bcd28cc3de..0ef11a8c39 100644 --- a/zephyr/test/drivers/system/src/system_board_version_default.c +++ b/zephyr/test/drivers/system/src/system_board_version_default.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "ec_commands.h" #include "host_command.h" +#include + ZTEST_USER(system, test_hostcmd_board_version) { struct ec_response_board_version response; diff --git a/zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c b/zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c index 8f71531bb8..2d4e60fdcb 100644 --- a/zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c +++ b/zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ +#include "system.h" + #include #include -#include "system.h" - /* Tests for !CONFIG_HOST_CMD_AP_SET_SKUID */ #define DEFAULT_BOARD_PROVIDED_SKU_ID 0 diff --git a/zephyr/test/drivers/timer/src/timer.c b/zephyr/test/drivers/timer/src/timer.c index d94eb7811e..5cbdae1ea8 100644 --- a/zephyr/test/drivers/timer/src/timer.c +++ b/zephyr/test/drivers/timer/src/timer.c @@ -2,15 +2,15 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include -#include - #include "console.h" #include "host_command.h" #include "test/drivers/test_state.h" #include "timer.h" +#include +#include +#include + BUILD_ASSERT(IS_ENABLED(CONFIG_HWTIMER_64BIT), "Tests expect the 64-bit HW timer"); diff --git a/zephyr/test/drivers/usb_common/src/suite.c b/zephyr/test/drivers/usb_common/src/suite.c index 56f3434d4c..36d3031881 100644 --- a/zephyr/test/drivers/usb_common/src/suite.c +++ b/zephyr/test/drivers/usb_common/src/suite.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ +#include "suite.h" + #include #include -#include "suite.h" - DEFINE_FAKE_VALUE_FUNC(int, board_vbus_source_enabled, int); DEFINE_FAKE_VALUE_FUNC(int, ppc_discharge_vbus, int, int); diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c index c9b951fc49..f286a4ffc9 100644 --- a/zephyr/test/drivers/usb_common/src/usb_common.c +++ b/zephyr/test/drivers/usb_common/src/usb_common.c @@ -3,17 +3,18 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" #include "suite.h" #include "timer.h" #include "usb_common.h" #include "usb_pd.h" +#include + +#include +#include +#include + #define TEST_PORT 0 ZTEST_USER(usb_common, test_get_typec_current_limit_detached) diff --git a/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c b/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c index e691d8e76b..847840e3e5 100644 --- a/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c +++ b/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "suite.h" #include "usb_pd.h" #include "usb_pd_flags.h" +#include +#include +#include + #define TEST_PORT 0 ZTEST_USER(usb_common, test_pd_set_vbus_discharge) diff --git a/zephyr/test/drivers/usb_common/src/usb_pd_flags.c b/zephyr/test/drivers/usb_common/src/usb_pd_flags.c index 8fe73bd141..05765da7b8 100644 --- a/zephyr/test/drivers/usb_common/src/usb_pd_flags.c +++ b/zephyr/test/drivers/usb_common/src/usb_pd_flags.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "usb_pd.h" #include "usb_pd_flags.h" +#include +#include + ZTEST_USER(usb_common, test_usb_pd_charger_otg) { set_usb_pd_charger_otg(USB_PD_CHARGER_OTG_ENABLED); diff --git a/zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c b/zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c index 1a78d73c7b..fd6cab7bad 100644 --- a/zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c +++ b/zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c @@ -3,22 +3,23 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "battery_smart.h" #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" #include "emul/tcpc/emul_tcpci_partner_faulty_ext.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "tcpm/tcpci.h" +#include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" -#include "test/drivers/stubs.h" +#include "timer.h" #include "usb_pd.h" #include "usb_tc_sm.h" -#include "timer.h" + +#include + +#include +#include /* USB-C port used to connect port partner in this testsuite */ #define TEST_PORT 0 diff --git a/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c b/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c index 2cb331b387..7594a6158e 100644 --- a/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c +++ b/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c @@ -3,19 +3,20 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include - #include "console.h" #include "gpio.h" #include "host_command.h" #include "test/drivers/test_state.h" #include "usb_charge.h" +#include +#include + +#include +#include +#include +#include + /* Expecting at least one port */ BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) >= 1); BUILD_ASSERT(USB_PORT_COUNT >= 1); diff --git a/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c b/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c index 82f67aad23..21a471f22a 100644 --- a/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c +++ b/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" #include "usb_common.h" #include "usb_pd.h" +#include + #define BB_RETIMER_NODE DT_NODELABEL(usb_c1_bb_retimer_emul) #define TEST_PORT USBC_PORT_C1 diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c index cbdd861585..24ee58bd01 100644 --- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c +++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" #include "ec_tasks.h" #include "emul/emul_isl923x.h" @@ -16,12 +11,18 @@ #include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "host_command.h" -#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" -#include "test/drivers/utils.h" +#include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include "test_usbc_alt_mode.h" +#include + +#include +#include +#include + #define TEST_PORT 0 /* Arbitrary */ diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c index 9d34bc7917..597aac4179 100644 --- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c +++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "test/drivers/utils.h" #include "test_usbc_alt_mode.h" +#include +#include + /* Tests that require CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY enabled */ ZTEST_F(usbc_alt_mode, verify_displayport_mode_reentry) diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c index 26db31318d..ef56332f55 100644 --- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c +++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c @@ -3,17 +3,17 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "mock/power.h" #include "test/drivers/utils.h" #include "test_usbc_alt_mode.h" +#include +#include +#include +#include + /* Tests that require CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY disabled */ diff --git a/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c b/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c index 9c87b9a4a2..37908ce1e4 100644 --- a/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c +++ b/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c @@ -3,12 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include - #include "console.h" #include "ec_commands.h" #include "ec_tasks.h" @@ -18,12 +12,19 @@ #include "emul/tcpc/emul_tcpci_partner_drp.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "host_command.h" -#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" -#include "test/drivers/utils.h" +#include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include "usb_pd.h" +#include + +#include +#include +#include +#include + #define TEST_PORT 0 struct common_fixture { diff --git a/zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c b/zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c index f269c1e81f..a7828eb878 100644 --- a/zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c +++ b/zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ +#include "test/drivers/test_state.h" +#include "timer.h" +#include "usbc_ocp.h" + #include #include #include -#include "usbc_ocp.h" -#include "test/drivers/test_state.h" -#include "timer.h" - /* Tests for USBC OCP (Overcurrent Protection) Common Code */ #define TEST_PORT 0 diff --git a/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c b/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c index 70bf887968..c0cd438511 100644 --- a/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c +++ b/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "console.h" #include "test/drivers/test_state.h" #include "timer.h" #include "usbc_ppc.h" +#include +#include +#include +#include + /* Tests for USBC PPC Common Code */ ZTEST(usbc_ppc, test_ppc_dump__no_args) diff --git a/zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c b/zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c index 33bc767407..5e55042d33 100644 --- a/zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c +++ b/zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c @@ -9,15 +9,15 @@ * The tests correspond to TEST.PD.PVDM.SRC.1 Discovery Process and Enter Mode * as defined by the USB Power Delivery Compliance Test Specification. */ -#include -#include - -#include "usb_pd.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" +#include "usb_pd.h" + +#include +#include struct usbc_svdm_dfp_only_fixture { const struct emul *tcpci_emul; diff --git a/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c b/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c index 912d8fa644..2fc895bb27 100644 --- a/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c +++ b/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" #include "ec_tasks.h" #include "emul/emul_isl923x.h" @@ -15,12 +10,18 @@ #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "host_command.h" -#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" -#include "test/drivers/utils.h" +#include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include "usb_pd_vdo.h" +#include + +#include +#include +#include + #define TEST_PORT USBC_PORT_C0 /* Remove polarity for any mux checks */ #define USB_MUX_CHECK_MASK ~USB_PD_MUX_POLARITY_INVERTED diff --git a/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c b/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c index beaafd6880..bc1eb6cd0d 100644 --- a/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c +++ b/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" #include "ec_tasks.h" #include "emul/emul_isl923x.h" @@ -17,10 +12,16 @@ #include "emul/tcpc/emul_tcpci_partner_drp.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "host_command.h" -#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" -#include "test/drivers/utils.h" +#include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" + +#include + +#include +#include +#include #define TEST_PORT 0 diff --git a/zephyr/test/ec_app/src/main.c b/zephyr/test/ec_app/src/main.c index b106754d47..3c317d2a08 100644 --- a/zephyr/test/ec_app/src/main.c +++ b/zephyr/test/ec_app/src/main.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "ec_app_main.h" #include "hooks.h" #include "task.h" +#include +#include +#include + #ifdef CONFIG_CMD_AP_RESET_LOG ZTEST(ec_app_tests, test_init_reset_log) { diff --git a/zephyr/test/herobrine/src/board_chipset.c b/zephyr/test/herobrine/src/board_chipset.c index 87a8414804..1463547012 100644 --- a/zephyr/test/herobrine/src/board_chipset.c +++ b/zephyr/test/herobrine/src/board_chipset.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ +#include "board_chipset.h" +#include "hooks.h" + #include #include -#include "hooks.h" -#include "board_chipset.h" - static int battery_soc_abs_value = 50; int battery_state_of_charge_abs(int *percent) diff --git a/zephyr/test/hooks/hooks.c b/zephyr/test/hooks/hooks.c index 7d784aa65f..bc2840eae5 100644 --- a/zephyr/test/hooks/hooks.c +++ b/zephyr/test/hooks/hooks.c @@ -3,12 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "ap_power/ap_power.h" #include "hooks.h" +#include + +#include + static bool h1_called; static bool h2_called; static bool h3_called; diff --git a/zephyr/test/i2c/src/main.c b/zephyr/test/i2c/src/main.c index 364353f06d..eb4724d5a7 100644 --- a/zephyr/test/i2c/src/main.c +++ b/zephyr/test/i2c/src/main.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "common.h" -#include "i2c/i2c.h" #include "i2c.h" +#include "i2c/i2c.h" + +#include +#include /* Unused: required for shimming i2c. */ void watchdog_reload(void) diff --git a/zephyr/test/kingler/src/alt_sensor.c b/zephyr/test/kingler/src/alt_sensor.c index 0304656f4a..7cd0ceddfa 100644 --- a/zephyr/test/kingler/src/alt_sensor.c +++ b/zephyr/test/kingler/src/alt_sensor.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include "zephyr/kernel.h" -#include -#include - #include "cros_board_info.h" #include "cros_cbi.h" #include "gpio_signal.h" #include "hooks.h" +#include "zephyr/kernel.h" + +#include +#include /* SSFC field defined in zephyr/program/corsola/cbi_steelix.dts */ #define SSFC_BASE_MAIN_SENSOR (0x1) diff --git a/zephyr/test/kingler/src/ccd.c b/zephyr/test/kingler/src/ccd.c index 1b46631dc6..eb375fcfe7 100644 --- a/zephyr/test/kingler/src/ccd.c +++ b/zephyr/test/kingler/src/ccd.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include "zephyr/kernel.h" +#include "gpio/gpio_int.h" +#include "gpio_signal.h" +#include "hooks.h" + #include #include +#include #include -#include "gpio_signal.h" -#include "gpio/gpio_int.h" -#include "hooks.h" - FAKE_VOID_FUNC(typec_set_sbu, int, bool); /* fake definitions to pass build */ FAKE_VOID_FUNC(bmi3xx_interrupt, enum gpio_signal); diff --git a/zephyr/test/kingler/src/clamshell.c b/zephyr/test/kingler/src/clamshell.c index 88595cc114..9871db1ca0 100644 --- a/zephyr/test/kingler/src/clamshell.c +++ b/zephyr/test/kingler/src/clamshell.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include "zephyr/kernel.h" -#include -#include - #include "cros_board_info.h" #include "cros_cbi.h" #include "gpio_signal.h" #include "hooks.h" #include "tablet_mode.h" +#include "zephyr/kernel.h" + +#include +#include static void *clamshell_setup(void) { diff --git a/zephyr/test/kingler/src/db_detect_hdmi.c b/zephyr/test/kingler/src/db_detect_hdmi.c index df29e613d6..04a65269ad 100644 --- a/zephyr/test/kingler/src/db_detect_hdmi.c +++ b/zephyr/test/kingler/src/db_detect_hdmi.c @@ -3,17 +3,17 @@ * found in the LICENSE file. */ -#include "zephyr/kernel.h" -#include -#include -#include - #include "baseboard_usbc_config.h" #include "ec_commands.h" #include "gpio_signal.h" #include "hooks.h" #include "usb_mux.h" #include "variant_db_detection.h" +#include "zephyr/kernel.h" + +#include +#include +#include FAKE_VALUE_FUNC(int, corsola_is_dp_muxable, int); FAKE_VOID_FUNC(svdm_set_hpd_gpio, int, int); diff --git a/zephyr/test/kingler/src/db_detect_none.c b/zephyr/test/kingler/src/db_detect_none.c index 9f37db04af..1bf9c05701 100644 --- a/zephyr/test/kingler/src/db_detect_none.c +++ b/zephyr/test/kingler/src/db_detect_none.c @@ -3,17 +3,18 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "cros_board_info.h" #include "cros_cbi.h" #include "gpio_signal.h" #include "hooks.h" #include "variant_db_detection.h" +#include + +#include +#include +#include + static void *db_detection_setup(void) { const struct device *wp_gpio = diff --git a/zephyr/test/kingler/src/db_detect_typec.c b/zephyr/test/kingler/src/db_detect_typec.c index 53716fe552..6662f485bc 100644 --- a/zephyr/test/kingler/src/db_detect_typec.c +++ b/zephyr/test/kingler/src/db_detect_typec.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include "zephyr/kernel.h" -#include -#include - #include "gpio_signal.h" #include "hooks.h" #include "variant_db_detection.h" +#include "zephyr/kernel.h" + +#include +#include static void *db_detection_setup(void) { diff --git a/zephyr/test/kingler/src/fakes.c b/zephyr/test/kingler/src/fakes.c index 9b3194f18a..f5a3c30b0b 100644 --- a/zephyr/test/kingler/src/fakes.c +++ b/zephyr/test/kingler/src/fakes.c @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "gpio_signal.h" +#include + FAKE_VOID_FUNC(power_button_interrupt, enum gpio_signal); FAKE_VOID_FUNC(button_interrupt, enum gpio_signal); FAKE_VOID_FUNC(lid_interrupt, enum gpio_signal); diff --git a/zephyr/test/kingler/src/tablet.c b/zephyr/test/kingler/src/tablet.c index 68be2b2b68..a2355e2b9d 100644 --- a/zephyr/test/kingler/src/tablet.c +++ b/zephyr/test/kingler/src/tablet.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include "zephyr/kernel.h" -#include -#include - #include "cros_board_info.h" #include "cros_cbi.h" #include "gpio_signal.h" #include "hooks.h" #include "tablet_mode.h" +#include "zephyr/kernel.h" + +#include +#include static void *tablet_setup(void) { diff --git a/zephyr/test/krabby/src/charger_workaround.c b/zephyr/test/krabby/src/charger_workaround.c index afd3fe5f0c..5582fe5c64 100644 --- a/zephyr/test/krabby/src/charger_workaround.c +++ b/zephyr/test/krabby/src/charger_workaround.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "charger.h" #include "driver/charger/rt9490.h" #include "emul/emul_rt9490.h" @@ -15,6 +10,11 @@ #include "i2c.h" #include "system.h" +#include +#include +#include +#include + FAKE_VALUE_FUNC(int, board_get_version); const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(charger)); diff --git a/zephyr/test/krabby/src/stubs.c b/zephyr/test/krabby/src/stubs.c index 7731aad43f..1e955fa8f0 100644 --- a/zephyr/test/krabby/src/stubs.c +++ b/zephyr/test/krabby/src/stubs.c @@ -4,9 +4,9 @@ */ #include "adc.h" -#include "usbc_ppc.h" #include "charge_ramp.h" #include "charge_state.h" +#include "usbc_ppc.h" int board_set_active_charge_port(int port) { diff --git a/zephyr/test/krabby/src/temp_tentacruel.c b/zephyr/test/krabby/src/temp_tentacruel.c index 49d8a23ddf..1eaefad988 100644 --- a/zephyr/test/krabby/src/temp_tentacruel.c +++ b/zephyr/test/krabby/src/temp_tentacruel.c @@ -3,20 +3,20 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - -#include "charger.h" #include "charge_state.h" +#include "charger.h" #include "charger_profile_override.h" #include "common.h" #include "config.h" #include "hooks.h" -#include "util.h" #include "temp_sensor.h" #include "temp_sensor/temp_sensor.h" +#include "util.h" + +#include +#include +#include +#include #define ADC_DEVICE_NODE DT_NODELABEL(adc0) #define CHARGER_TEMP TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)) diff --git a/zephyr/test/krabby/src/usb_mux_init.c b/zephyr/test/krabby/src/usb_mux_init.c index 665f1c7b7e..8d1e4e81eb 100644 --- a/zephyr/test/krabby/src/usb_mux_init.c +++ b/zephyr/test/krabby/src/usb_mux_init.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "driver/usb_mux/tusb1064.h" #include "emul/emul_tusb1064.h" #include "usb_mux.h" #include "usbc/usb_muxes.h" +#include +#include +#include + const static struct emul *emul = EMUL_DT_GET(DT_NODELABEL(tusb1064_mux_1)); const static int tusb1064_port = USB_MUX_PORT(DT_NODELABEL(tusb1064_mux_1)); diff --git a/zephyr/test/math/src/fixed_point_int_sqrtf.c b/zephyr/test/math/src/fixed_point_int_sqrtf.c index a76567b9d7..4403980a96 100644 --- a/zephyr/test/math/src/fixed_point_int_sqrtf.c +++ b/zephyr/test/math/src/fixed_point_int_sqrtf.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "math.h" #include "math_util.h" +#include + ZTEST_USER(math, int_sqrtf_negative) { zassert_equal(int_sqrtf(-100), 0); diff --git a/zephyr/test/math/src/mask.c b/zephyr/test/math/src/mask.c index c38b756eda..c986834eb8 100644 --- a/zephyr/test/math/src/mask.c +++ b/zephyr/test/math/src/mask.c @@ -3,12 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "math.h" #include "math_util.h" +#include + +#include + ZTEST_USER(math, bitmask_uint64) { zassert_equal(bitmask_uint64(-1), 0); diff --git a/zephyr/test/math/src/math_util.c b/zephyr/test/math/src/math_util.c index a3f26d3fea..184dd2b999 100644 --- a/zephyr/test/math/src/math_util.c +++ b/zephyr/test/math/src/math_util.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - +#include "builtin/stdio.h" #include "common.h" #include "math.h" #include "math_util.h" -#include "builtin/stdio.h" + +#include ZTEST_USER(math, arc_cos__x_below_range) { diff --git a/zephyr/test/math/src/vector.c b/zephyr/test/math/src/vector.c index 87dad3a78d..e588be52af 100644 --- a/zephyr/test/math/src/vector.c +++ b/zephyr/test/math/src/vector.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "math.h" #include "math_util.h" +#include + ZTEST_USER(math, cosine_of_angle_diff__zero_magnitude_vector) { intv3_t v0 = { 0, 0, 0 }; diff --git a/zephyr/test/qcom_power/src/main.c b/zephyr/test/qcom_power/src/main.c index 33288af05f..8de3f051d6 100644 --- a/zephyr/test/qcom_power/src/main.c +++ b/zephyr/test/qcom_power/src/main.c @@ -3,27 +3,27 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "gpio_signal.h" -#include "power/qcom.h" -#include "ec_app_main.h" -#include "power.h" #include "console.h" -#include "task.h" +#include "ec_app_main.h" +#include "gpio.h" +#include "gpio_signal.h" #include "hooks.h" #include "host_command.h" #include "lid_switch.h" -#include "gpio.h" +#include "power.h" +#include "power/qcom.h" +#include "task.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include /* For simplicity, enforce that all the gpios are on the same controller. */ #define GPIO_DEVICE \ diff --git a/zephyr/test/rex/src/usb_pd_policy.c b/zephyr/test/rex/src/usb_pd_policy.c index f6a5ce4ee7..3f7406bdad 100644 --- a/zephyr/test/rex/src/usb_pd_policy.c +++ b/zephyr/test/rex/src/usb_pd_policy.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include - #include "charge_manager.h" #include "chipset.h" #include "ec_commands.h" -#include "usb_pd.h" #include "usb_charge.h" +#include "usb_pd.h" #include "usbc_ppc.h" +#include +#include + DECLARE_FAKE_VALUE_FUNC(int, chipset_in_state, int); DEFINE_FAKE_VALUE_FUNC(int, chipset_in_state, int); DECLARE_FAKE_VALUE_FUNC(int, ppc_vbus_source_enable, int, int); diff --git a/zephyr/test/system_common/src/build_info.c b/zephyr/test/system_common/src/build_info.c index 7983c1f0a4..1057a3c013 100644 --- a/zephyr/test/system_common/src/build_info.c +++ b/zephyr/test/system_common/src/build_info.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ +#include "host_command.h" +#include "system.h" + #include #include #include #include -#include "host_command.h" -#include "system.h" - ZTEST_SUITE(host_cmd_get_build_info, NULL, NULL, NULL, NULL, NULL); FAKE_VALUE_FUNC(const char *, system_get_build_info); diff --git a/zephyr/test/system_common/src/get_version.c b/zephyr/test/system_common/src/get_version.c index 87a41bad58..a5e4fd5365 100644 --- a/zephyr/test/system_common/src/get_version.c +++ b/zephyr/test/system_common/src/get_version.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ +#include "host_command.h" +#include "system.h" + #include #include #include #include -#include "host_command.h" -#include "system.h" - ZTEST_SUITE(host_cmd_get_version, NULL, NULL, NULL, NULL, NULL); __override const char *system_get_version(enum ec_image copy) diff --git a/zephyr/test/system_common/src/reboot.c b/zephyr/test/system_common/src/reboot.c index 759b93d89f..18b5f0fd38 100644 --- a/zephyr/test/system_common/src/reboot.c +++ b/zephyr/test/system_common/src/reboot.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ +#include "host_command.h" +#include "system.h" + #include #include #include #include -#include "host_command.h" -#include "system.h" - FAKE_VOID_FUNC(system_reset, int); FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t); diff --git a/zephyr/test/system_common/src/system_is_locked.c b/zephyr/test/system_common/src/system_is_locked.c index 2ea9f3038b..d880e4e117 100644 --- a/zephyr/test/system_common/src/system_is_locked.c +++ b/zephyr/test/system_common/src/system_is_locked.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ +#include "system.h" + #include #include #include -#include "system.h" - ZTEST_USER(system_is_locked, test_syslock_console_cmd) { /* diff --git a/zephyr/test/system_shim/src/test_system.c b/zephyr/test/system_shim/src/test_system.c index e6e7077540..56031a4b67 100644 --- a/zephyr/test/system_shim/src/test_system.c +++ b/zephyr/test/system_shim/src/test_system.c @@ -3,7 +3,12 @@ * found in the LICENSE file. */ +#include "drivers/cros_system.h" +#include "fakes.h" +#include "system.h" + #include + #include #include #include @@ -12,10 +17,6 @@ #include #include -#include "drivers/cros_system.h" -#include "fakes.h" -#include "system.h" - LOG_MODULE_REGISTER(test); #define BBRAM_REGION_OFF(name) \ diff --git a/zephyr/test/tasks/main.c b/zephyr/test/tasks/main.c index 8bfe9eb602..bbf752c656 100644 --- a/zephyr/test/tasks/main.c +++ b/zephyr/test/tasks/main.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "ec_tasks.h" #include "task.h" #include "timer.h" +#include + +#include +#include + /* Second for platform/ec task API (in microseconds). */ #define TASK_SEC(s) (s * 1000 * 1000) diff --git a/zephyr/test/test_utils/tasks_fakes.c b/zephyr/test/test_utils/tasks_fakes.c index b4068afa21..d688c6cc24 100644 --- a/zephyr/test/test_utils/tasks_fakes.c +++ b/zephyr/test/test_utils/tasks_fakes.c @@ -3,10 +3,11 @@ * found in the LICENSE file. */ -#include -#include #include "task_id.h" +#include +#include + /* * The fakes below are needed to satisfy the final link, but are never * actually called at runtime. Exclude from the coverage report to avoid diff --git a/zephyr/test/vboot_efs2/src/main.c b/zephyr/test/vboot_efs2/src/main.c index 3a4da9cd6e..f79d2dcf78 100644 --- a/zephyr/test/vboot_efs2/src/main.c +++ b/zephyr/test/vboot_efs2/src/main.c @@ -14,8 +14,8 @@ #include "usb_mux.h" #include "usbc_ppc.h" #include "vboot.h" - #include "zephyr/devicetree.h" + #include #include -- cgit v1.2.1 From 88740eef03d6e2d82b414af120ebd644e142b7d3 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 14:19:26 -0700 Subject: zephyr/drivers: Sort header files Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: Ib3a3eae34bfd45ae5d38b450608a56e528d731f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024017 Reviewed-by: Tristan Honscheid Commit-Queue: Tristan Honscheid Code-Coverage: Zoss Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Commit-Queue: Jeremy Bettis --- zephyr/drivers/cros_displight/cros_displight.c | 7 ++++--- zephyr/drivers/cros_flash/cros_flash_it8xxx2.c | 13 +++++++------ zephyr/drivers/cros_flash/cros_flash_npcx.c | 13 +++++++------ zephyr/drivers/cros_flash/cros_flash_xec.c | 13 +++++++------ zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c | 17 +++++++++-------- zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c | 19 ++++++++++--------- zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c | 17 +++++++++-------- zephyr/drivers/cros_kblight/pwm_kblight.c | 8 ++++---- zephyr/drivers/cros_rtc/cros_rtc_npcx.c | 15 ++++++++------- zephyr/drivers/cros_rtc/cros_rtc_xec.c | 13 +++++++------ zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c | 11 ++++++----- zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c | 11 ++++++----- zephyr/drivers/cros_shi/cros_shi_it8xxx2.c | 18 ++++++++++-------- zephyr/drivers/cros_shi/cros_shi_npcx.c | 20 +++++++++++--------- zephyr/drivers/cros_system/cros_system_it8xxx2.c | 11 ++++++----- .../drivers/cros_system/cros_system_native_posix.c | 6 +++--- zephyr/drivers/cros_system/cros_system_npcx.c | 17 +++++++++-------- zephyr/drivers/cros_system/cros_system_xec.c | 15 ++++++++------- 18 files changed, 131 insertions(+), 113 deletions(-) diff --git a/zephyr/drivers/cros_displight/cros_displight.c b/zephyr/drivers/cros_displight/cros_displight.c index 98d1dd0823..998c2a4407 100644 --- a/zephyr/drivers/cros_displight/cros_displight.c +++ b/zephyr/drivers/cros_displight/cros_displight.c @@ -5,13 +5,14 @@ #define DT_DRV_COMPAT cros_ec_displight +#include "common.h" +#include "util.h" + #include -#include #include #include -#include "common.h" -#include "util.h" +#include LOG_MODULE_REGISTER(displight, LOG_LEVEL_ERR); diff --git a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c index 4838c5d583..79ef0c36b2 100644 --- a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c +++ b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c @@ -5,17 +5,18 @@ #define DT_DRV_COMPAT ite_it8xxx2_cros_flash -#include -#include -#include -#include -#include - #include "flash.h" #include "host_command.h" #include "system.h" #include "watchdog.h" +#include +#include +#include + +#include +#include + LOG_MODULE_REGISTER(cros_flash, LOG_LEVEL_ERR); /* Device data */ diff --git a/zephyr/drivers/cros_flash/cros_flash_npcx.c b/zephyr/drivers/cros_flash/cros_flash_npcx.c index 032bb5906c..e49067ad1a 100644 --- a/zephyr/drivers/cros_flash/cros_flash_npcx.c +++ b/zephyr/drivers/cros_flash/cros_flash_npcx.c @@ -5,18 +5,19 @@ #define DT_DRV_COMPAT nuvoton_npcx_cros_flash -#include +#include "../drivers/flash/spi_nor.h" +#include "flash.h" +#include "spi_flash_reg.h" +#include "write_protect.h" + #include #include #include #include #include -#include -#include "flash.h" -#include "spi_flash_reg.h" -#include "write_protect.h" -#include "../drivers/flash/spi_nor.h" +#include +#include LOG_MODULE_REGISTER(cros_flash, LOG_LEVEL_ERR); diff --git a/zephyr/drivers/cros_flash/cros_flash_xec.c b/zephyr/drivers/cros_flash/cros_flash_xec.c index 2b92eae25b..610a79c971 100644 --- a/zephyr/drivers/cros_flash/cros_flash_xec.c +++ b/zephyr/drivers/cros_flash/cros_flash_xec.c @@ -5,18 +5,19 @@ #define DT_DRV_COMPAT microchip_xec_cros_flash -#include +#include "../drivers/flash/spi_nor.h" +#include "flash.h" +#include "spi_flash_reg.h" +#include "write_protect.h" + #include #include #include #include #include -#include -#include "flash.h" -#include "spi_flash_reg.h" -#include "write_protect.h" -#include "../drivers/flash/spi_nor.h" +#include +#include LOG_MODULE_REGISTER(cros_flash, LOG_LEVEL_ERR); diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c index fdbc8ee30d..f824d1d90c 100644 --- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c +++ b/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c @@ -5,22 +5,23 @@ #define DT_DRV_COMPAT ite_it8xxx2_cros_kb_raw +#include "ec_tasks.h" +#include "keyboard_raw.h" +#include "task.h" + #include -#include + #include #include #include #include #include +#include + +#include #include -#include #include - -#include "ec_tasks.h" -#include "keyboard_raw.h" -#include "task.h" - -#include +#include LOG_MODULE_REGISTER(cros_kb_raw, LOG_LEVEL_ERR); #define KEYBOARD_KSI_PIN_COUNT IT8XXX2_DT_INST_WUCCTRL_LEN(0) diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c index 1d1f2b4918..6c61568016 100644 --- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c +++ b/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c @@ -5,21 +5,22 @@ #define DT_DRV_COMPAT nuvoton_npcx_cros_kb_raw -#include -#include -#include -#include -#include -#include -#include -#include - #include "ec_tasks.h" #include "keyboard_raw.h" #include "soc_miwu.h" #include "task.h" +#include + +#include +#include +#include +#include #include + +#include +#include +#include LOG_MODULE_REGISTER(cros_kb_raw, LOG_LEVEL_ERR); #ifdef CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c index 797377f84f..30ffd7ca85 100644 --- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c +++ b/zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c @@ -5,19 +5,20 @@ #define DT_DRV_COMPAT microchip_xec_cros_kb_raw -#include -#include -#include -#include -#include -#include -#include - #include "ec_tasks.h" #include "keyboard_raw.h" #include "task.h" +#include + +#include +#include +#include #include + +#include +#include +#include LOG_MODULE_REGISTER(cros_kb_raw, LOG_LEVEL_ERR); #ifdef CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED diff --git a/zephyr/drivers/cros_kblight/pwm_kblight.c b/zephyr/drivers/cros_kblight/pwm_kblight.c index 59b4ef20ef..ea6004412e 100644 --- a/zephyr/drivers/cros_kblight/pwm_kblight.c +++ b/zephyr/drivers/cros_kblight/pwm_kblight.c @@ -5,14 +5,14 @@ #define DT_DRV_COMPAT cros_ec_kblight_pwm -#include -#include -#include - #include "common.h" #include "keyboard_backlight.h" #include "util.h" +#include +#include +#include + LOG_MODULE_REGISTER(kblight, LOG_LEVEL_ERR); BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, diff --git a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c index 3312ad899f..6b8e21de27 100644 --- a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c +++ b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c @@ -6,18 +6,19 @@ #define DT_DRV_COMPAT nuvoton_npcx_cros_mtc -#include -#include -#include -#include -#include -#include - #include "ec_tasks.h" #include "soc_miwu.h" #include "task.h" +#include + +#include +#include #include + +#include +#include +#include LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR); #define NPCX_MTC_TTC_LOAD_DELAY_US 250 /* Delay after writing TTC */ diff --git a/zephyr/drivers/cros_rtc/cros_rtc_xec.c b/zephyr/drivers/cros_rtc/cros_rtc_xec.c index c543aab6af..f42560e107 100644 --- a/zephyr/drivers/cros_rtc/cros_rtc_xec.c +++ b/zephyr/drivers/cros_rtc/cros_rtc_xec.c @@ -5,17 +5,18 @@ #define DT_DRV_COMPAT microchip_xec_cros_rtc +#include "ec_tasks.h" +#include "task.h" + #include -#include + #include #include +#include + +#include #include #include - -#include "ec_tasks.h" -#include "task.h" - -#include LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR); /* Driver config */ diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c index c5580eaeef..34c2cbe0a7 100644 --- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c +++ b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c @@ -5,18 +5,19 @@ #define DT_DRV_COMPAT nxp_rtc_pcf85063a +#include "nxp_rtc_pcf85063a.h" + #include + #include -#include #include #include #include +#include + +#include #include #include - -#include "nxp_rtc_pcf85063a.h" - -#include LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR); /* Driver config */ diff --git a/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c b/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c index 7a9a11fd41..f6d3a7c292 100644 --- a/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c +++ b/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c @@ -5,18 +5,19 @@ #define DT_DRV_COMPAT renesas_rtc_idt1337ag +#include "renesas_rtc_idt1337ag.h" + #include + #include -#include #include #include #include +#include + +#include #include #include - -#include "renesas_rtc_idt1337ag.h" - -#include LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR); /* Driver config */ diff --git a/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c b/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c index ee6ce3f7a4..15b5daf85b 100644 --- a/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c +++ b/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c @@ -5,20 +5,22 @@ #define DT_DRV_COMPAT ite_it8xxx2_cros_shi -#include +#include "chipset.h" +#include "console.h" +#include "gpio/gpio_int.h" +#include "host_command.h" + #include + +#include +#include +#include #include #include #include + #include #include -#include -#include - -#include "chipset.h" -#include "console.h" -#include "gpio/gpio_int.h" -#include "host_command.h" /* Console output macros */ #define CPRINTS(format, args...) cprints(CC_SPI, format, ##args) diff --git a/zephyr/drivers/cros_shi/cros_shi_npcx.c b/zephyr/drivers/cros_shi/cros_shi_npcx.c index ce3279288b..79bc79db2e 100644 --- a/zephyr/drivers/cros_shi/cros_shi_npcx.c +++ b/zephyr/drivers/cros_shi/cros_shi_npcx.c @@ -5,22 +5,24 @@ #define DT_DRV_COMPAT nuvoton_npcx_cros_shi -#include +#include "host_command.h" +#include "soc_miwu.h" +#include "system.h" + #include -#include + +#include #include -#include -#include #include -#include +#include +#include #include +#include + +#include #include #include -#include "host_command.h" -#include "soc_miwu.h" -#include "system.h" - #ifdef CONFIG_CROS_SHI_NPCX_DEBUG #define DEBUG_CPRINTS(format, args...) cprints(CC_SPI, format, ##args) #define DEBUG_CPRINTF(format, args...) cprintf(CC_SPI, format, ##args) diff --git a/zephyr/drivers/cros_system/cros_system_it8xxx2.c b/zephyr/drivers/cros_system/cros_system_it8xxx2.c index 8c63886808..a78b5c929c 100644 --- a/zephyr/drivers/cros_system/cros_system_it8xxx2.c +++ b/zephyr/drivers/cros_system/cros_system_it8xxx2.c @@ -5,17 +5,18 @@ #define DT_DRV_COMPAT ite_it8xxx2_gctrl +#include "drivers/cros_system.h" +#include "gpio/gpio_int.h" +#include "system.h" +#include "util.h" + #include #include #include + #include #include -#include "drivers/cros_system.h" -#include "gpio/gpio_int.h" -#include "system.h" -#include "util.h" - LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR); #define GCTRL_IT8XXX2_REG_BASE \ diff --git a/zephyr/drivers/cros_system/cros_system_native_posix.c b/zephyr/drivers/cros_system/cros_system_native_posix.c index fab9c4d033..59fdb39972 100644 --- a/zephyr/drivers/cros_system/cros_system_native_posix.c +++ b/zephyr/drivers/cros_system/cros_system_native_posix.c @@ -6,12 +6,12 @@ /* LCOV_EXCL_START */ /* This is test code, so it should be excluded from coverage */ -#include -#include - #include "common.h" #include "drivers/cros_system.h" +#include +#include + LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR); /* Driver config stub */ diff --git a/zephyr/drivers/cros_system/cros_system_npcx.c b/zephyr/drivers/cros_system/cros_system_npcx.c index 4ab21ca549..4fc1f1f977 100644 --- a/zephyr/drivers/cros_system/cros_system_npcx.c +++ b/zephyr/drivers/cros_system/cros_system_npcx.c @@ -3,21 +3,22 @@ * found in the LICENSE file. */ +#include "drivers/cros_system.h" +#include "gpio/gpio_int.h" +#include "rom_chip.h" +#include "soc_gpio.h" +#include "soc_miwu.h" +#include "system.h" + #include #include #include #include #include -#include -#include #include -#include "drivers/cros_system.h" -#include "gpio/gpio_int.h" -#include "rom_chip.h" -#include "soc_gpio.h" -#include "soc_miwu.h" -#include "system.h" +#include +#include LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR); diff --git a/zephyr/drivers/cros_system/cros_system_xec.c b/zephyr/drivers/cros_system/cros_system_xec.c index a3cf9aea22..f91b4630fc 100644 --- a/zephyr/drivers/cros_system/cros_system_xec.c +++ b/zephyr/drivers/cros_system/cros_system_xec.c @@ -3,18 +3,19 @@ * found in the LICENSE file. */ +#include "gpio/gpio_int.h" +#include "system.h" +#include "system_chip.h" + #include -#include +#include #include #include -#include -#include #include -#include "system.h" -#include "system_chip.h" -#include -#include "gpio/gpio_int.h" +#include +#include +#include LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR); -- cgit v1.2.1 From 3544fe4470dab4c759c48215ce1fddee241cd08e Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 12:45:07 -0700 Subject: zephyr/test: Fix copyright header Remove . after Authors. BRANCH=None BUG=None TEST=None Signed-off-by: Jeremy Bettis Change-Id: Idf999fee80d3b5aba69875e9541a8019322e7e2c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022254 Reviewed-by: Al Semjonovs Commit-Queue: Jeremy Bettis Code-Coverage: Zoss Tested-by: Jeremy Bettis --- zephyr/test/drivers/host_command_thread/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/test/drivers/host_command_thread/src/main.c b/zephyr/test/drivers/host_command_thread/src/main.c index d1df1ffed2..8b315dd950 100644 --- a/zephyr/test/drivers/host_command_thread/src/main.c +++ b/zephyr/test/drivers/host_command_thread/src/main.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -- cgit v1.2.1 From 0069615e6ae4edfa37340af158e10da01e4e0c97 Mon Sep 17 00:00:00 2001 From: Andrew McRae Date: Tue, 15 Nov 2022 17:18:22 +1100 Subject: update_release_branch: Fix commit message and Zephyr OWNERS Allow the relevant commits portion of the commit message to be optional (not used for the zephyr main/cmsis repos). Also prune any top level Zephyr OWNERS file changes to avoid conflicts with expected modified branch OWNERS file. BUG=b:257145337 TEST=Run for nissa firmware branch BRANCH=none Signed-off-by: Andrew McRae Change-Id: Ic38ff025d7d57a8f2439d535bebd55a5be12935c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022998 Code-Coverage: Zoss Reviewed-by: Aseda Aboagye --- util/update_release_branch.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/util/update_release_branch.py b/util/update_release_branch.py index 591c833ea1..939d572dc4 100755 --- a/util/update_release_branch.py +++ b/util/update_release_branch.py @@ -42,11 +42,11 @@ def git_commit_msg(cros_main, branch, head, merge_head, rel_paths, cmd): A String containing the git commit message with the exception of the Signed-Off-By field and Change-ID field. """ - relevant_commits_cmd, relevant_commits = get_relevant_commits( + relevant_commits_cmd, relevant_commits, relevant_hdr = get_relevant_commits( head, merge_head, "--oneline", rel_paths ) - _, relevant_bugs = get_relevant_commits(head, merge_head, "", rel_paths) + _, relevant_bugs, _ = get_relevant_commits(head, merge_head, "", rel_paths) relevant_bugs = set(re.findall("BUG=(.*)", relevant_bugs)) # Filter out "none" from set of bugs filtered = [] @@ -65,7 +65,7 @@ Merge remote-tracking branch {CROS_MAIN} into {BRANCH} Generated by: {COMMAND_LINE} -Relevant changes: +{RELEVANT_COMMITS_HEADER} {RELEVANT_COMMITS_CMD} @@ -93,6 +93,7 @@ Force-Relevant-Builds: all BRANCH=branch, RELEVANT_COMMITS_CMD=relevant_commits_cmd, RELEVANT_COMMITS=relevant_commits, + RELEVANT_COMMITS_HEADER=relevant_hdr, BUG_FIELD=bug_field, COMMAND_LINE=cmd, ) @@ -135,10 +136,10 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths): Returns: A tuple containing the arguments passed to the git log command and - stdout. + stdout, and the header for the message """ if not relevant_paths: - return "", "" + return "", "", "" if fmt: cmd = [ "git", @@ -158,7 +159,7 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths): proc = subprocess.run( cmd, stdout=subprocess.PIPE, encoding="utf-8", check=True, shell=True ) - return "".join(proc.args), proc.stdout + return "".join(proc.args), proc.stdout, "Relevant changes:" def merge_repo( @@ -208,7 +209,7 @@ def merge_repo( print('Merge command: "%s"' % " ".join(cmd_merge)) try: subprocess.run(cmd_merge, check=True) - except: + except subprocess.CalledProcessError: # We've likely encountered a merge conflict due to new OWNERS file # modifications. If we're removing the owners, we'll delete them. if prunelist: @@ -480,13 +481,18 @@ def main(argv): opts.release_branch, opts.remote_prefix + "/" + opts.release_branch, ] + prunelist = [] + if opts.remove_owners: + # Remove the top level OWNERS file from the list + # to avoid any conflict with the modified branch file. + prunelist.append("OWNERS") merge_repo( os.path.join(opts.srcbase, "src/third_party/zephyr/main"), cros_main, cmd_checkout, strategy, cmd, - [], + prunelist, [], ) # cmsis repo has different remote @@ -497,7 +503,7 @@ def main(argv): cmd_checkout, strategy, cmd, - [], + prunelist, [], ) print( -- cgit v1.2.1 From d504c8cf98d76c501b0979b98954540ef4ae581b Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 14:53:57 -0700 Subject: zephyr/drivers: Fix copyright header BRANCH=None BUG=None TEST=None Signed-off-by: Jeremy Bettis Change-Id: I7b59c1a4322786ff09df37932b4d38dc92a457d9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024020 Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Code-Coverage: Zoss Commit-Queue: Aaron Massey Reviewed-by: Aaron Massey --- zephyr/drivers/cros_rtc/cros_rtc_npcx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c index 6b8e21de27..a248357cfe 100644 --- a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c +++ b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c @@ -1,7 +1,6 @@ -/* - * Copyright 2021 Google LLC - * - * SPDX-License-Identifier: Apache-2.0 +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. */ #define DT_DRV_COMPAT nuvoton_npcx_cros_mtc -- cgit v1.2.1 From 495bc21060631797a9ac93bc0327b1152e0748b4 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Fri, 11 Nov 2022 14:21:24 -0700 Subject: zephyr: test: Add test for get_ap_reset_stats() in common/chipset.c Add tests for get_ap_reset_stats() as well as some test-only helper functions in chipset.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: Iaf990727cef1e9ef4e7155ee25e423731908952c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4027084 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- common/chipset.c | 18 +++++++++ include/chipset.h | 16 ++++++++ zephyr/test/drivers/default/CMakeLists.txt | 1 + zephyr/test/drivers/default/src/chipset.c | 59 ++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 zephyr/test/drivers/default/src/chipset.c diff --git a/common/chipset.c b/common/chipset.c index 55964e4ba9..5a699bfe25 100644 --- a/common/chipset.c +++ b/common/chipset.c @@ -134,3 +134,21 @@ enum chipset_shutdown_reason chipset_get_shutdown_reason(void) } #endif /* !CONFIG_AP_RESET_LOG */ + +#ifdef TEST_BUILD +uint32_t test_chipset_get_ap_resets_since_ec_boot(void) +{ + uint32_t count; + + mutex_lock(&reset_log_mutex); + count = ap_resets_since_ec_boot; + mutex_unlock(&reset_log_mutex); + + return count; +} + +void test_chipset_corrupt_reset_log_checksum(void) +{ + reset_log_checksum = ~reset_log_checksum; +} +#endif /* TEST_BUILD */ diff --git a/include/chipset.h b/include/chipset.h index fd7455f9f7..ead2a9680e 100644 --- a/include/chipset.h +++ b/include/chipset.h @@ -299,4 +299,20 @@ static inline enum chipset_shutdown_reason chipset_get_shutdown_reason(void) #endif /* !CONFIG_CMD_AP_RESET_LOG */ +#ifdef TEST_BUILD +/** + * @brief Gets the number of AP resets since the EC booted. Takes the reset log + * mutex for thread safety. + * + * @return uint32_t AP reset count + */ +uint32_t test_chipset_get_ap_resets_since_ec_boot(void); + +/** + * @brief Corrupts the stored reset log checksum, which forces init_reset_log() + * to wipe the log and fully reset. + */ +void test_chipset_corrupt_reset_log_checksum(void); +#endif /* TEST_BUILD */ + #endif /* __CROS_EC_CHIPSET_H */ diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt index 445ee50e37..16b9aad4b6 100644 --- a/zephyr/test/drivers/default/CMakeLists.txt +++ b/zephyr/test/drivers/default/CMakeLists.txt @@ -8,6 +8,7 @@ target_sources(app PRIVATE src/bmi260.c src/charge_manager.c src/charge_state_prevent_power_on.c + src/chipset.c src/console.c src/console_cmd/adc.c src/console_cmd/battery.c diff --git a/zephyr/test/drivers/default/src/chipset.c b/zephyr/test/drivers/default/src/chipset.c new file mode 100644 index 0000000000..83dba6c768 --- /dev/null +++ b/zephyr/test/drivers/default/src/chipset.c @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "chipset.h" + +#include "test/drivers/test_state.h" + +ZTEST(chipset, test_get_ap_reset_stats__bad_pointers) +{ + zassert_equal(EC_ERROR_INVAL, get_ap_reset_stats(NULL, 0, NULL)); +} + +ZTEST(chipset, test_get_ap_reset_stats__happy_path) +{ + struct ap_reset_log_entry reset_log_entries[4]; + uint32_t actual_reset_count, reset_count; + + memset(reset_log_entries, 0, sizeof(reset_log_entries)); + + /* Report two AP resets */ + report_ap_reset(CHIPSET_RESET_AP_WATCHDOG); + report_ap_reset(CHIPSET_RESET_HANG_REBOOT); + + zassert_equal(EC_SUCCESS, + get_ap_reset_stats(reset_log_entries, + ARRAY_SIZE(reset_log_entries), + &reset_count)); + + /* Check the reset causes. The reset entry log is not a FIFO, so we get + * the last two empty slots followed by the two we triggered above. + */ + zassert_equal(0, reset_log_entries[0].reset_cause); + zassert_equal(0, reset_log_entries[1].reset_cause); + zassert_equal(CHIPSET_RESET_AP_WATCHDOG, + reset_log_entries[2].reset_cause); + zassert_equal(CHIPSET_RESET_HANG_REBOOT, + reset_log_entries[3].reset_cause); + + /* Check reset count */ + actual_reset_count = test_chipset_get_ap_resets_since_ec_boot(); + zassert_equal(actual_reset_count, reset_count, + "Found %d resets, expected %d", reset_count, + actual_reset_count); +} + +static void reset(void *arg) +{ + ARG_UNUSED(arg); + + test_chipset_corrupt_reset_log_checksum(); + init_reset_log(); +} + +ZTEST_SUITE(chipset, drivers_predicate_post_main, NULL, reset, reset, NULL); -- cgit v1.2.1 From f6227a7e5aa850057eee9e1ca48857db42c557af Mon Sep 17 00:00:00 2001 From: Wai-Hong Tam Date: Tue, 15 Nov 2022 13:33:47 -0800 Subject: lazor: Fix the typos of GPIO names Typos of mixing port-0 and port-1 names. BRANCH=none BUG=none TEST=Build the Lazor Zephyr image LOW_COVERAGE_REASON=Simple 2-line fix. No unit test of this file yet. Change-Id: I934fcf38d5c721c52ed6eeb3147b181cf54bd604 Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025837 Reviewed-by: Sam Hurst Commit-Queue: Sam Hurst Code-Coverage: Zoss --- zephyr/program/trogdor/lazor/src/usbc_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/program/trogdor/lazor/src/usbc_config.c b/zephyr/program/trogdor/lazor/src/usbc_config.c index f6bfdfb186..2e40223c4c 100644 --- a/zephyr/program/trogdor/lazor/src/usbc_config.c +++ b/zephyr/program/trogdor/lazor/src/usbc_config.c @@ -197,7 +197,7 @@ void board_tcpc_init(void) /* Enable TCPC interrupts */ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); - gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc)); /* * Initialize HPD to low; after sysjump SOC needs to see @@ -326,7 +326,7 @@ uint16_t tcpc_get_alert_status(void) if (gpio_pin_get_dt( GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l))) status |= PD_STATUS_TCPC_ALERT_0; - if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_int_odl))) if (gpio_pin_get_dt( GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l))) status |= PD_STATUS_TCPC_ALERT_1; -- cgit v1.2.1 From 336ff871bbb314f415fb5bd0e9deb4234f1efd96 Mon Sep 17 00:00:00 2001 From: Michael5 Chen1 Date: Mon, 14 Nov 2022 09:38:26 +0800 Subject: marasov: Implement the EC LED code Implement the EC LED code dependent on spec. BUG=b:259006557 BRANCH=brya TEST=make BOARD=marasov Signed-off-by: Michael5 Chen1 Change-Id: I57b857b6a509105eb8360957d14c5330ab6035fb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022612 Reviewed-by: Kyle Lin Code-Coverage: Zoss Commit-Queue: Kyle Lin --- board/marasov/board.h | 16 +---- board/marasov/generated-gpio.inc | 6 +- board/marasov/led.c | 143 +++++++++++++++++++++------------------ board/marasov/pwm.c | 33 --------- 4 files changed, 83 insertions(+), 115 deletions(-) diff --git a/board/marasov/board.h b/board/marasov/board.h index 67e3ecd8c9..32b65e830a 100644 --- a/board/marasov/board.h +++ b/board/marasov/board.h @@ -27,16 +27,8 @@ #define CONFIG_MP2964 /* LED */ -#define CONFIG_LED_PWM -#define CONFIG_LED_PWM_COUNT 2 -#undef CONFIG_LED_PWM_NEAR_FULL_COLOR -#undef CONFIG_LED_PWM_SOC_ON_COLOR -#undef CONFIG_LED_PWM_SOC_SUSPEND_COLOR -#undef CONFIG_LED_PWM_LOW_BATT_COLOR -#define CONFIG_LED_PWM_NEAR_FULL_COLOR EC_LED_COLOR_WHITE -#define CONFIG_LED_PWM_SOC_ON_COLOR EC_LED_COLOR_WHITE -#define CONFIG_LED_PWM_SOC_SUSPEND_COLOR EC_LED_COLOR_WHITE -#define CONFIG_LED_PWM_LOW_BATT_COLOR EC_LED_COLOR_AMBER +#define CONFIG_LED_ONOFF_STATES +#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10 #undef CONFIG_TABLET_MODE #undef CONFIG_TABLET_MODE_SWITCH @@ -210,12 +202,8 @@ enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT }; enum battery_type { BATTERY_POWER_TECH, BATTERY_LGC011, BATTERY_TYPE_COUNT }; enum pwm_channel { - PWM_CH_LED2 = 0, /* PWM0 (white charger) */ - PWM_CH_LED3, /* PWM1 (orange on DB) */ - PWM_CH_LED1, /* PWM2 (orange charger) */ PWM_CH_KBLIGHT, /* PWM3 */ PWM_CH_FAN, /* PWM5 */ - PWM_CH_LED4, /* PWM7 (white on DB) */ PWM_CH_COUNT }; diff --git a/board/marasov/generated-gpio.inc b/board/marasov/generated-gpio.inc index eacb89a804..c71d7dd273 100644 --- a/board/marasov/generated-gpio.inc +++ b/board/marasov/generated-gpio.inc @@ -70,6 +70,8 @@ GPIO(USB_C1_RST_ODL, PIN(9, 6), GPIO_ODR_LOW) GPIO(USB_C1_RT_INT_ODL, PIN(A, 0), GPIO_INPUT) GPIO(USB_C1_RT_RST_R_ODL, PIN(0, 2), GPIO_ODR_LOW) GPIO(VCCST_PWRGD_OD, PIN(A, 4), GPIO_ODR_LOW) +GPIO(PWR_LED_W_ODL, PIN(6, 0), GPIO_OUT_HIGH) +GPIO(PWR_LED_A_ODL, PIN(C, 2), GPIO_OUT_HIGH) /* UART alternate functions */ ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* GPIO64/CR_SIN1, GPO65/CR_SOUT1/FLPRG1_L */ @@ -86,10 +88,8 @@ ALTERNATE(PIN_MASK(F, 0x0c), 0, MODULE_I2C, 0) /* GPIOF3/I2C4_SCL1 /* PWM alternate functions */ ALTERNATE(PIN_MASK(4, 0x01), 0, MODULE_PWM, 0) /* GPIO40/TA1 */ -ALTERNATE(PIN_MASK(6, 0x01), 0, MODULE_PWM, 0) /* GPIO60/PWM7 */ ALTERNATE(PIN_MASK(8, 0x01), 0, MODULE_PWM, 0) /* GPIO80/PWM3 */ ALTERNATE(PIN_MASK(B, 0x80), 0, MODULE_PWM, 0) /* GPIOB7/PWM5 */ -ALTERNATE(PIN_MASK(C, 0x1c), 0, MODULE_PWM, 0) /* GPIOC4/PWM2, GPIOC3/PWM0, GPIOC2/PWM1/I2C6_SCL0 */ /* ADC alternate functions */ ALTERNATE(PIN_MASK(3, 0x10), 0, MODULE_ADC, 0) /* GPIO34/PS2_DAT2/ADC6 */ @@ -121,5 +121,7 @@ UNUSED(PIN(5, 6)) /* GPIO56 */ UNUSED(PIN(D, 4)) /* GPIOD4 */ UNUSED(PIN(9, 3)) /* GPIO93 */ UNUSED(PIN(9, 7)) /* GPIO97 */ +UNUSED(PIN(C, 3)) /* GPIOC3 */ +UNUSED(PIN(C, 4)) /* GPIOC4 */ /* Pre-configured PSL balls: J8 K6 */ diff --git a/board/marasov/led.c b/board/marasov/led.c index 5d57a704aa..74005005cb 100644 --- a/board/marasov/led.c +++ b/board/marasov/led.c @@ -3,88 +3,99 @@ * found in the LICENSE file. */ -/* Brya specific PWM LED settings: there are 2 LEDs on each side of the board, - * each one can be controlled separately. The LED colors are white or amber, - * and the default behavior is tied to the charging process: both sides are - * amber while charging the battery and white when the battery is charged. - */ +#include "chipset.h" +#include "ec_commands.h" +#include "gpio.h" +#include "led_common.h" +#include "led_onoff_states.h" -#include +#define LED_OFF_LVL 1 +#define LED_ON_LVL 0 -#include "common.h" -#include "compile_time_macros.h" -#include "ec_commands.h" -#include "led_pwm.h" -#include "pwm.h" -#include "util.h" +__override const int led_charge_lvl_1; +__override const int led_charge_lvl_2 = 95; + +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_WHITE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_WHITE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 3 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S3] = { { EC_LED_COLOR_WHITE, + 1 * LED_ONE_SEC }, + { LED_OFF, 3 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_WHITE, + 2 * LED_ONE_SEC }, + { EC_LED_COLOR_AMBER, + 2 * LED_ONE_SEC } }, + }; const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_LEFT_LED, - EC_LED_ID_RIGHT_LED, + EC_LED_ID_BATTERY_LED, }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); -/* - * We only have a white and an amber LED, so setting any other color results in - * both LEDs being off. Cap at 50% to save power. - */ -struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = { - /* Amber, White */ - [EC_LED_COLOR_RED] = { 0, 0 }, [EC_LED_COLOR_GREEN] = { 0, 0 }, - [EC_LED_COLOR_BLUE] = { 0, 0 }, [EC_LED_COLOR_YELLOW] = { 0, 0 }, - [EC_LED_COLOR_WHITE] = { 0, 50 }, [EC_LED_COLOR_AMBER] = { 50, 0 }, -}; - -/* Two logical LEDs with amber and white channels. */ -struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { - { - .ch0 = PWM_CH_LED1, - .ch1 = PWM_CH_LED2, - .ch2 = PWM_LED_NO_CHANNEL, - .enable = &pwm_enable, - .set_duty = &pwm_set_duty, - }, - { - .ch0 = PWM_CH_LED3, - .ch1 = PWM_CH_LED4, - .ch2 = PWM_LED_NO_CHANNEL, - .enable = &pwm_enable, - .set_duty = &pwm_set_duty, - }, -}; +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_WHITE: + gpio_set_level(GPIO_PWR_LED_A_ODL, LED_OFF_LVL); + gpio_set_level(GPIO_PWR_LED_W_ODL, LED_ON_LVL); + break; + case EC_LED_COLOR_AMBER: + gpio_set_level(GPIO_PWR_LED_A_ODL, LED_ON_LVL); + gpio_set_level(GPIO_PWR_LED_W_ODL, LED_OFF_LVL); + break; + default: /* LED_OFF and other unsupported colors */ + gpio_set_level(GPIO_PWR_LED_W_ODL, LED_OFF_LVL); + gpio_set_level(GPIO_PWR_LED_A_ODL, LED_OFF_LVL); + break; + } +} void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { - memset(brightness_range, '\0', - sizeof(*brightness_range) * EC_LED_COLOR_COUNT); - brightness_range[EC_LED_COLOR_AMBER] = 100; - brightness_range[EC_LED_COLOR_WHITE] = 100; + if (led_id == EC_LED_ID_BATTERY_LED) { + brightness_range[EC_LED_COLOR_WHITE] = 1; + brightness_range[EC_LED_COLOR_AMBER] = 1; + } } int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { - enum pwm_led_id pwm_id; - - /* Convert ec_led_id to pwm_led_id. */ - switch (led_id) { - case EC_LED_ID_LEFT_LED: - pwm_id = PWM_LED0; - break; - case EC_LED_ID_RIGHT_LED: - pwm_id = PWM_LED1; - break; - default: - return EC_ERROR_UNKNOWN; + if (led_id == EC_LED_ID_BATTERY_LED) { + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_battery(EC_LED_COLOR_WHITE); + else if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(EC_LED_COLOR_AMBER); + else + led_set_color_battery(LED_OFF); } - if (brightness[EC_LED_COLOR_WHITE]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_WHITE); - else if (brightness[EC_LED_COLOR_AMBER]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER); - else - /* Otherwise, the "color" is "off". */ - set_pwm_led_color(pwm_id, -1); - return EC_SUCCESS; } + +__override enum led_states board_led_get_state(enum led_states desired_state) +{ + if (desired_state == STATE_BATTERY_ERROR) { + if (chipset_in_state(CHIPSET_STATE_ON)) + return desired_state; + else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) + return STATE_DISCHARGE_S3; + else + return STATE_DISCHARGE_S5; + } + return desired_state; +} diff --git a/board/marasov/pwm.c b/board/marasov/pwm.c index 3657549182..f693a6e27f 100644 --- a/board/marasov/pwm.c +++ b/board/marasov/pwm.c @@ -11,21 +11,6 @@ #include "pwm_chip.h" const struct pwm_t pwm_channels[] = { - [PWM_CH_LED2] = { - .channel = 0, - .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - .freq = 4800, - }, - [PWM_CH_LED3] = { - .channel = 1, - .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - .freq = 4800, - }, - [PWM_CH_LED1] = { - .channel = 2, - .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - .freq = 4800, - }, [PWM_CH_KBLIGHT] = { .channel = 3, .flags = 0, @@ -42,29 +27,11 @@ const struct pwm_t pwm_channels[] = { .flags = PWM_CONFIG_OPEN_DRAIN, .freq = 25000, }, - [PWM_CH_LED4] = { - .channel = 7, - .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - .freq = 4800, - }, }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); static void board_pwm_init(void) { - /* - * Turn off all the LEDs. - * Turn on the fan at 100%. - */ - pwm_enable(PWM_CH_LED1, 1); - pwm_set_duty(PWM_CH_LED1, 0); - pwm_enable(PWM_CH_LED2, 1); - pwm_set_duty(PWM_CH_LED2, 0); - pwm_enable(PWM_CH_LED3, 1); - pwm_set_duty(PWM_CH_LED3, 0); - pwm_enable(PWM_CH_LED4, 1); - pwm_set_duty(PWM_CH_LED4, 0); - pwm_enable(PWM_CH_KBLIGHT, 1); pwm_set_duty(PWM_CH_KBLIGHT, 50); } -- cgit v1.2.1 From b10d22eaaa4d5b6be9fb4380f8962bade50669f6 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 14:19:37 -0700 Subject: zephyr/fake: Sort header files Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: I3768ee96a681f8bffa18a23611d35efc1c458a7b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024018 Commit-Queue: Yuval Peress Code-Coverage: Zoss Tested-by: Jeremy Bettis Reviewed-by: Yuval Peress Auto-Submit: Jeremy Bettis --- zephyr/fake/include/system_fake.h | 4 ++-- zephyr/fake/system_fake.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zephyr/fake/include/system_fake.h b/zephyr/fake/include/system_fake.h index b80624e289..805e3ae44b 100644 --- a/zephyr/fake/include/system_fake.h +++ b/zephyr/fake/include/system_fake.h @@ -6,10 +6,10 @@ #ifndef ZEPHYR_FAKE_SYSTEM_FAKE_H #define ZEPHYR_FAKE_SYSTEM_FAKE_H -#include - #include "ec_commands.h" +#include + /** * @brief Set the current image copy. */ diff --git a/zephyr/fake/system_fake.c b/zephyr/fake/system_fake.c index 75beb62b23..402559a885 100644 --- a/zephyr/fake/system_fake.c +++ b/zephyr/fake/system_fake.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "system.h" #include "system_fake.h" +#include + static enum ec_image shrspi_image_copy = EC_IMAGE_RO; /* setjmp environment to use for reboot (NULL if none) */ -- cgit v1.2.1 From ced7b670199fbab446eb4b5e27afb47203e20d51 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 15 Nov 2022 13:39:12 -0700 Subject: util: Log command at debug level You can run util/check_clang_format --debug to see the command that is run. BRANCH=None BUG=None TEST=util/check_clang_format --debug Signed-off-by: Jeremy Bettis Change-Id: If99ccfc700928ab6ce10802e869e170878853351 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026666 Tested-by: Jeremy Bettis Reviewed-by: Yuval Peress Commit-Queue: Yuval Peress Code-Coverage: Zoss Auto-Submit: Jeremy Bettis --- util/check_clang_format.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/check_clang_format.py b/util/check_clang_format.py index 9fbfa9b868..783cce9e33 100755 --- a/util/check_clang_format.py +++ b/util/check_clang_format.py @@ -12,6 +12,7 @@ the pre-upload checks. import logging import pathlib +import shlex import subprocess import sys from typing import List @@ -61,6 +62,7 @@ def main(argv=None): if path.name.endswith(".c") or path.name.endswith(".h"): cmd.append(path) + logging.debug("Running %s", " ".join(shlex.quote(str(x)) for x in cmd)) result = subprocess.run( cmd, check=False, -- cgit v1.2.1 From 1d3a7723f310fd32a64e2ba59f3ab41d7f6c9042 Mon Sep 17 00:00:00 2001 From: johnwc_yeh Date: Tue, 15 Nov 2022 15:59:47 +0800 Subject: Xivu: modify target current setting When device at USB-C port happen short, the RAA489000 charger IC have current limit function with OTG UVP function. The target current needs to be adjusted, and set 0x92 to 3.3A (0x68) for better protection. BUG=b:259013588 BRANCH=none TEST=zmake build xivu Signed-off-by: johnwc_yeh Change-Id: I72e05f257a7d6b78c354f912c7bbb9c7e9d3fccf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4027783 Code-Coverage: Andrew McRae Reviewed-by: SamSP Liu Reviewed-by: Peter Marheine Tested-by: Andrew McRae Commit-Queue: Andrew McRae --- zephyr/program/nissa/xivu/src/usbc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/zephyr/program/nissa/xivu/src/usbc.c b/zephyr/program/nissa/xivu/src/usbc.c index c4ba75f741..aab4f85438 100644 --- a/zephyr/program/nissa/xivu/src/usbc.c +++ b/zephyr/program/nissa/xivu/src/usbc.c @@ -163,12 +163,26 @@ void pd_power_supply_reset(int port) pd_send_host_event(PD_EVENT_POWER_CHANGE); } +/* VBUS_CURRENT_TARGET */ +#define RAA489000_VBUS_CURRENT_TARGET_3_3A 0x68 /* 3.3A */ + __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { + int rv; + if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) return; - raa489000_set_output_current(port, rp); + int selected_cur = rp == TYPEC_RP_3A0 ? + RAA489000_VBUS_CURRENT_TARGET_3_3A : + RAA489000_VBUS_CURRENT_TARGET_1_5A; + + rv = tcpc_write16(port, RAA489000_VBUS_CURRENT_TARGET, selected_cur); + + if (rv != EC_SUCCESS) { + LOG_WRN("Failed to set source ilimit on port %d to %d: %d", + port, selected_cur, rv); + } } int pd_set_power_supply_ready(int port) -- cgit v1.2.1 From 5165e73a987491d048c3bf47fccbb68bba41d435 Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Tue, 8 Nov 2022 14:45:08 +0800 Subject: corsola: zephyr project organization Firstly, renames the .dts, .conf and places to the project folder. For the components excluding battery and led, rename them by the rule: - kingler -> npcx - krabby -> ite - prj.conf -> program.conf - prj_npcx|ite.conf -> npcx|ite_program.conf - move prj_*.conf to $project/project.conf - rename .dts to .dtsi - move consolidate project dts to $project/project.overlay There will be following CLs for the next step organizing. - clean up krabby family dtsi sharing - add CMakeLists.txt for projects reference: go/zephyr-projects BUG=b:254097516 TEST=zmake compare-binaries -a BRANCH=corsola Change-Id: Ia4d9fe8750300185922f7e013fbdb4bf08265de2 Signed-off-by: Eric Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022563 Auto-Submit: Eric Yilun Lin Tested-by: Eric Yilun Lin Code-Coverage: Zoss Reviewed-by: Ting Shen Commit-Queue: Ting Shen --- zephyr/program/corsola/BUILD.py | 115 +--------- zephyr/program/corsola/adc_kingler.dts | 46 ---- zephyr/program/corsola/adc_krabby.dts | 38 --- zephyr/program/corsola/adc_magikarp.dts | 63 ----- zephyr/program/corsola/adc_magikarp.dtsi | 63 +++++ zephyr/program/corsola/adc_tentacruel.dts | 72 ------ zephyr/program/corsola/adc_tentacruel.dtsi | 72 ++++++ zephyr/program/corsola/battery_kingler.dts | 15 -- zephyr/program/corsola/battery_kingler.dtsi | 15 ++ zephyr/program/corsola/battery_krabby.dts | 12 - zephyr/program/corsola/battery_krabby.dtsi | 12 + zephyr/program/corsola/battery_magikarp.dts | 12 - zephyr/program/corsola/battery_magikarp.dtsi | 12 + zephyr/program/corsola/battery_steelix.dts | 24 -- zephyr/program/corsola/battery_steelix.dtsi | 24 ++ zephyr/program/corsola/battery_tentacruel.dts | 12 - zephyr/program/corsola/battery_tentacruel.dtsi | 12 + zephyr/program/corsola/cbi_magikarp.dts | 36 --- zephyr/program/corsola/cbi_magikarp.dtsi | 36 +++ zephyr/program/corsola/cbi_steelix.dts | 95 -------- zephyr/program/corsola/cbi_steelix.dtsi | 95 ++++++++ zephyr/program/corsola/cbi_tentacruel.dts | 36 --- zephyr/program/corsola/cbi_tentacruel.dtsi | 36 +++ zephyr/program/corsola/common.dts | 25 -- zephyr/program/corsola/common.dtsi | 25 ++ .../corsola/default_gpio_pinctrl_kingler.dts | 44 ---- zephyr/program/corsola/gpio_kingler.dts | 249 -------------------- zephyr/program/corsola/gpio_krabby.dts | 231 ------------------- zephyr/program/corsola/gpio_magikarp.dts | 237 ------------------- zephyr/program/corsola/gpio_magikarp.dtsi | 237 +++++++++++++++++++ zephyr/program/corsola/gpio_steelix.dts | 255 --------------------- zephyr/program/corsola/gpio_steelix.dtsi | 255 +++++++++++++++++++++ zephyr/program/corsola/gpio_tentacruel.dts | 235 ------------------- zephyr/program/corsola/gpio_tentacruel.dtsi | 235 +++++++++++++++++++ zephyr/program/corsola/host_interface_npcx.dts | 12 - zephyr/program/corsola/i2c_kingler.dts | 169 -------------- zephyr/program/corsola/i2c_krabby.dts | 22 -- zephyr/program/corsola/i2c_krabby.dtsi | 22 ++ zephyr/program/corsola/i2c_magikarp.dts | 36 --- zephyr/program/corsola/i2c_magikarp.dtsi | 36 +++ zephyr/program/corsola/i2c_tentacruel.dts | 38 --- zephyr/program/corsola/i2c_tentacruel.dtsi | 38 +++ zephyr/program/corsola/interrupts_kingler.dts | 114 --------- zephyr/program/corsola/interrupts_krabby.dts | 110 --------- zephyr/program/corsola/interrupts_magikarp.dts | 115 ---------- zephyr/program/corsola/interrupts_magikarp.dtsi | 115 ++++++++++ zephyr/program/corsola/interrupts_steelix.dts | 10 - zephyr/program/corsola/interrupts_steelix.dtsi | 10 + zephyr/program/corsola/interrupts_tentacruel.dts | 115 ---------- zephyr/program/corsola/interrupts_tentacruel.dtsi | 115 ++++++++++ zephyr/program/corsola/ite_adc.dtsi | 38 +++ zephyr/program/corsola/ite_gpio.dtsi | 231 +++++++++++++++++++ zephyr/program/corsola/ite_interrupts.dtsi | 110 +++++++++ zephyr/program/corsola/ite_keyboard.dtsi | 28 +++ zephyr/program/corsola/ite_motionsense.dtsi | 146 ++++++++++++ zephyr/program/corsola/ite_program.conf | 89 +++++++ zephyr/program/corsola/ite_usbc.dtsi | 59 +++++ zephyr/program/corsola/keyboard_krabby.dts | 28 --- zephyr/program/corsola/keyboard_steelix.dts | 29 --- zephyr/program/corsola/keyboard_steelix.dtsi | 29 +++ zephyr/program/corsola/kingler/project.conf | 12 + zephyr/program/corsola/kingler/project.overlay | 21 ++ zephyr/program/corsola/krabby/project.conf | 9 + zephyr/program/corsola/krabby/project.overlay | 19 ++ zephyr/program/corsola/led_kingler.dts | 71 ------ zephyr/program/corsola/led_kingler.dtsi | 71 ++++++ zephyr/program/corsola/led_krabby.dts | 5 - zephyr/program/corsola/led_krabby.dtsi | 5 + zephyr/program/corsola/led_magikarp.dts | 136 ----------- zephyr/program/corsola/led_magikarp.dtsi | 136 +++++++++++ zephyr/program/corsola/led_steelix.dts | 55 ----- zephyr/program/corsola/led_steelix.dtsi | 55 +++++ zephyr/program/corsola/led_tentacruel.dts | 118 ---------- zephyr/program/corsola/led_tentacruel.dtsi | 118 ++++++++++ zephyr/program/corsola/magikarp/project.conf | 27 +++ zephyr/program/corsola/magikarp/project.overlay | 20 ++ zephyr/program/corsola/motionsense_kingler.dts | 150 ------------ zephyr/program/corsola/motionsense_krabby.dts | 146 ------------ zephyr/program/corsola/motionsense_magikarp.dts | 199 ---------------- zephyr/program/corsola/motionsense_magikarp.dtsi | 199 ++++++++++++++++ zephyr/program/corsola/motionsense_steelix.dts | 133 ----------- zephyr/program/corsola/motionsense_steelix.dtsi | 133 +++++++++++ zephyr/program/corsola/motionsense_tentacruel.dts | 199 ---------------- zephyr/program/corsola/motionsense_tentacruel.dtsi | 199 ++++++++++++++++ zephyr/program/corsola/npcx_adc.dtsi | 46 ++++ .../program/corsola/npcx_default_gpio_pinctrl.dtsi | 44 ++++ zephyr/program/corsola/npcx_gpio.dtsi | 249 ++++++++++++++++++++ zephyr/program/corsola/npcx_host_interface.dtsi | 12 + zephyr/program/corsola/npcx_i2c.dtsi | 169 ++++++++++++++ zephyr/program/corsola/npcx_interrupts.dtsi | 114 +++++++++ zephyr/program/corsola/npcx_keyboard.dts | 32 --- zephyr/program/corsola/npcx_keyboard.dtsi | 32 +++ zephyr/program/corsola/npcx_motionsense.dtsi | 150 ++++++++++++ zephyr/program/corsola/npcx_program.conf | 88 +++++++ zephyr/program/corsola/npcx_usbc.dtsi | 56 +++++ zephyr/program/corsola/power_signal.dts | 26 --- zephyr/program/corsola/power_signal.dtsi | 26 +++ zephyr/program/corsola/prj.conf | 94 -------- zephyr/program/corsola/prj_it81202_base.conf | 89 ------- zephyr/program/corsola/prj_kingler.conf | 12 - zephyr/program/corsola/prj_krabby.conf | 9 - zephyr/program/corsola/prj_magikarp.conf | 27 --- zephyr/program/corsola/prj_npcx993_base.conf | 88 ------- zephyr/program/corsola/prj_steelix.conf | 34 --- zephyr/program/corsola/prj_tentacruel.conf | 26 --- zephyr/program/corsola/program.conf | 94 ++++++++ zephyr/program/corsola/steelix/project.conf | 34 +++ zephyr/program/corsola/steelix/project.overlay | 26 +++ zephyr/program/corsola/tentacruel/project.conf | 26 +++ zephyr/program/corsola/tentacruel/project.overlay | 21 ++ zephyr/program/corsola/thermistor_tentacruel.dts | 140 ----------- zephyr/program/corsola/thermistor_tentacruel.dtsi | 140 +++++++++++ zephyr/program/corsola/usba.dts | 11 - zephyr/program/corsola/usba.dtsi | 11 + zephyr/program/corsola/usba_steelix.dts | 10 - zephyr/program/corsola/usba_steelix.dtsi | 10 + zephyr/program/corsola/usbc_kingler.dts | 56 ----- zephyr/program/corsola/usbc_krabby.dts | 59 ----- zephyr/program/corsola/usbc_magikarp.dts | 59 ----- zephyr/program/corsola/usbc_magikarp.dtsi | 59 +++++ zephyr/program/corsola/usbc_tentacruel.dts | 60 ----- zephyr/program/corsola/usbc_tentacruel.dtsi | 60 +++++ zephyr/test/kingler/testcase.yaml | 14 +- zephyr/test/krabby/testcase.yaml | 4 +- 124 files changed, 4705 insertions(+), 4693 deletions(-) delete mode 100644 zephyr/program/corsola/adc_kingler.dts delete mode 100644 zephyr/program/corsola/adc_krabby.dts delete mode 100644 zephyr/program/corsola/adc_magikarp.dts create mode 100644 zephyr/program/corsola/adc_magikarp.dtsi delete mode 100644 zephyr/program/corsola/adc_tentacruel.dts create mode 100644 zephyr/program/corsola/adc_tentacruel.dtsi delete mode 100644 zephyr/program/corsola/battery_kingler.dts create mode 100644 zephyr/program/corsola/battery_kingler.dtsi delete mode 100644 zephyr/program/corsola/battery_krabby.dts create mode 100644 zephyr/program/corsola/battery_krabby.dtsi delete mode 100644 zephyr/program/corsola/battery_magikarp.dts create mode 100644 zephyr/program/corsola/battery_magikarp.dtsi delete mode 100644 zephyr/program/corsola/battery_steelix.dts create mode 100644 zephyr/program/corsola/battery_steelix.dtsi delete mode 100644 zephyr/program/corsola/battery_tentacruel.dts create mode 100644 zephyr/program/corsola/battery_tentacruel.dtsi delete mode 100644 zephyr/program/corsola/cbi_magikarp.dts create mode 100644 zephyr/program/corsola/cbi_magikarp.dtsi delete mode 100644 zephyr/program/corsola/cbi_steelix.dts create mode 100644 zephyr/program/corsola/cbi_steelix.dtsi delete mode 100644 zephyr/program/corsola/cbi_tentacruel.dts create mode 100644 zephyr/program/corsola/cbi_tentacruel.dtsi delete mode 100644 zephyr/program/corsola/common.dts create mode 100644 zephyr/program/corsola/common.dtsi delete mode 100644 zephyr/program/corsola/default_gpio_pinctrl_kingler.dts delete mode 100644 zephyr/program/corsola/gpio_kingler.dts delete mode 100644 zephyr/program/corsola/gpio_krabby.dts delete mode 100644 zephyr/program/corsola/gpio_magikarp.dts create mode 100644 zephyr/program/corsola/gpio_magikarp.dtsi delete mode 100644 zephyr/program/corsola/gpio_steelix.dts create mode 100644 zephyr/program/corsola/gpio_steelix.dtsi delete mode 100644 zephyr/program/corsola/gpio_tentacruel.dts create mode 100644 zephyr/program/corsola/gpio_tentacruel.dtsi delete mode 100644 zephyr/program/corsola/host_interface_npcx.dts delete mode 100644 zephyr/program/corsola/i2c_kingler.dts delete mode 100644 zephyr/program/corsola/i2c_krabby.dts create mode 100644 zephyr/program/corsola/i2c_krabby.dtsi delete mode 100644 zephyr/program/corsola/i2c_magikarp.dts create mode 100644 zephyr/program/corsola/i2c_magikarp.dtsi delete mode 100644 zephyr/program/corsola/i2c_tentacruel.dts create mode 100644 zephyr/program/corsola/i2c_tentacruel.dtsi delete mode 100644 zephyr/program/corsola/interrupts_kingler.dts delete mode 100644 zephyr/program/corsola/interrupts_krabby.dts delete mode 100644 zephyr/program/corsola/interrupts_magikarp.dts create mode 100644 zephyr/program/corsola/interrupts_magikarp.dtsi delete mode 100644 zephyr/program/corsola/interrupts_steelix.dts create mode 100644 zephyr/program/corsola/interrupts_steelix.dtsi delete mode 100644 zephyr/program/corsola/interrupts_tentacruel.dts create mode 100644 zephyr/program/corsola/interrupts_tentacruel.dtsi create mode 100644 zephyr/program/corsola/ite_adc.dtsi create mode 100644 zephyr/program/corsola/ite_gpio.dtsi create mode 100644 zephyr/program/corsola/ite_interrupts.dtsi create mode 100644 zephyr/program/corsola/ite_keyboard.dtsi create mode 100644 zephyr/program/corsola/ite_motionsense.dtsi create mode 100644 zephyr/program/corsola/ite_program.conf create mode 100644 zephyr/program/corsola/ite_usbc.dtsi delete mode 100644 zephyr/program/corsola/keyboard_krabby.dts delete mode 100644 zephyr/program/corsola/keyboard_steelix.dts create mode 100644 zephyr/program/corsola/keyboard_steelix.dtsi create mode 100644 zephyr/program/corsola/kingler/project.conf create mode 100644 zephyr/program/corsola/kingler/project.overlay create mode 100644 zephyr/program/corsola/krabby/project.conf create mode 100644 zephyr/program/corsola/krabby/project.overlay delete mode 100644 zephyr/program/corsola/led_kingler.dts create mode 100644 zephyr/program/corsola/led_kingler.dtsi delete mode 100644 zephyr/program/corsola/led_krabby.dts create mode 100644 zephyr/program/corsola/led_krabby.dtsi delete mode 100644 zephyr/program/corsola/led_magikarp.dts create mode 100644 zephyr/program/corsola/led_magikarp.dtsi delete mode 100644 zephyr/program/corsola/led_steelix.dts create mode 100644 zephyr/program/corsola/led_steelix.dtsi delete mode 100644 zephyr/program/corsola/led_tentacruel.dts create mode 100644 zephyr/program/corsola/led_tentacruel.dtsi create mode 100644 zephyr/program/corsola/magikarp/project.conf create mode 100644 zephyr/program/corsola/magikarp/project.overlay delete mode 100644 zephyr/program/corsola/motionsense_kingler.dts delete mode 100644 zephyr/program/corsola/motionsense_krabby.dts delete mode 100644 zephyr/program/corsola/motionsense_magikarp.dts create mode 100644 zephyr/program/corsola/motionsense_magikarp.dtsi delete mode 100644 zephyr/program/corsola/motionsense_steelix.dts create mode 100644 zephyr/program/corsola/motionsense_steelix.dtsi delete mode 100644 zephyr/program/corsola/motionsense_tentacruel.dts create mode 100644 zephyr/program/corsola/motionsense_tentacruel.dtsi create mode 100644 zephyr/program/corsola/npcx_adc.dtsi create mode 100644 zephyr/program/corsola/npcx_default_gpio_pinctrl.dtsi create mode 100644 zephyr/program/corsola/npcx_gpio.dtsi create mode 100644 zephyr/program/corsola/npcx_host_interface.dtsi create mode 100644 zephyr/program/corsola/npcx_i2c.dtsi create mode 100644 zephyr/program/corsola/npcx_interrupts.dtsi delete mode 100644 zephyr/program/corsola/npcx_keyboard.dts create mode 100644 zephyr/program/corsola/npcx_keyboard.dtsi create mode 100644 zephyr/program/corsola/npcx_motionsense.dtsi create mode 100644 zephyr/program/corsola/npcx_program.conf create mode 100644 zephyr/program/corsola/npcx_usbc.dtsi delete mode 100644 zephyr/program/corsola/power_signal.dts create mode 100644 zephyr/program/corsola/power_signal.dtsi delete mode 100644 zephyr/program/corsola/prj.conf delete mode 100644 zephyr/program/corsola/prj_it81202_base.conf delete mode 100644 zephyr/program/corsola/prj_kingler.conf delete mode 100644 zephyr/program/corsola/prj_krabby.conf delete mode 100644 zephyr/program/corsola/prj_magikarp.conf delete mode 100644 zephyr/program/corsola/prj_npcx993_base.conf delete mode 100644 zephyr/program/corsola/prj_steelix.conf delete mode 100644 zephyr/program/corsola/prj_tentacruel.conf create mode 100644 zephyr/program/corsola/program.conf create mode 100644 zephyr/program/corsola/steelix/project.conf create mode 100644 zephyr/program/corsola/steelix/project.overlay create mode 100644 zephyr/program/corsola/tentacruel/project.conf create mode 100644 zephyr/program/corsola/tentacruel/project.overlay delete mode 100644 zephyr/program/corsola/thermistor_tentacruel.dts create mode 100644 zephyr/program/corsola/thermistor_tentacruel.dtsi delete mode 100644 zephyr/program/corsola/usba.dts create mode 100644 zephyr/program/corsola/usba.dtsi delete mode 100644 zephyr/program/corsola/usba_steelix.dts create mode 100644 zephyr/program/corsola/usba_steelix.dtsi delete mode 100644 zephyr/program/corsola/usbc_kingler.dts delete mode 100644 zephyr/program/corsola/usbc_krabby.dts delete mode 100644 zephyr/program/corsola/usbc_magikarp.dts create mode 100644 zephyr/program/corsola/usbc_magikarp.dtsi delete mode 100644 zephyr/program/corsola/usbc_tentacruel.dts create mode 100644 zephyr/program/corsola/usbc_tentacruel.dtsi diff --git a/zephyr/program/corsola/BUILD.py b/zephyr/program/corsola/BUILD.py index 91bd8ab062..3b22dbe0ad 100644 --- a/zephyr/program/corsola/BUILD.py +++ b/zephyr/program/corsola/BUILD.py @@ -10,133 +10,38 @@ def register_corsola_project( project_name, chip="it81202bx", - extra_dts_overlays=(), - extra_kconfig_files=(), ): """Register a variant of corsola.""" register_func = register_binman_project if chip.startswith("npcx"): register_func = register_npcx_project + chip_kconfig = {"it81202bx": "ite", "npcx9m3f": "npcx"}[chip] + register_func( project_name=project_name, zephyr_board=chip, - dts_overlays=[ - here / "common.dts", - here / "power_signal.dts", - here / "usba.dts", - *extra_dts_overlays, + dts_overlays=[here / project_name / "project.overlay"], + kconfig_files=[ + here / "program.conf", + here / f"{chip_kconfig}_program.conf", + here / project_name / "project.conf", ], - kconfig_files=[here / "prj.conf", *extra_kconfig_files], ) -register_corsola_project( - "krabby", - extra_dts_overlays=[ - here / "adc_krabby.dts", - here / "battery_krabby.dts", - here / "gpio_krabby.dts", - here / "keyboard_krabby.dts", - here / "i2c_krabby.dts", - here / "interrupts_krabby.dts", - here / "led_krabby.dts", - here / "motionsense_krabby.dts", - here / "usbc_krabby.dts", - ], - extra_kconfig_files=[ - here / "prj_it81202_base.conf", - here / "prj_krabby.conf", - ], -) +register_corsola_project("krabby") register_corsola_project( project_name="kingler", chip="npcx9m3f", - extra_dts_overlays=[ - here / "adc_kingler.dts", - here / "battery_kingler.dts", - here / "host_interface_npcx.dts", - here / "i2c_kingler.dts", - here / "interrupts_kingler.dts", - here / "gpio_kingler.dts", - here / "npcx_keyboard.dts", - here / "led_kingler.dts", - here / "motionsense_kingler.dts", - here / "usbc_kingler.dts", - here / "default_gpio_pinctrl_kingler.dts", - ], - extra_kconfig_files=[ - here / "prj_npcx993_base.conf", - here / "prj_kingler.conf", - ], ) register_corsola_project( project_name="steelix", chip="npcx9m3f", - extra_dts_overlays=[ - here / "adc_kingler.dts", - here / "battery_steelix.dts", - here / "host_interface_npcx.dts", - here / "i2c_kingler.dts", - here / "interrupts_kingler.dts", - here / "interrupts_steelix.dts", - here / "cbi_steelix.dts", - here / "gpio_steelix.dts", - here / "npcx_keyboard.dts", - here / "keyboard_steelix.dts", - here / "led_steelix.dts", - here / "motionsense_kingler.dts", - here / "motionsense_steelix.dts", - here / "usba_steelix.dts", - here / "usbc_kingler.dts", - here / "default_gpio_pinctrl_kingler.dts", - ], - extra_kconfig_files=[ - here / "prj_npcx993_base.conf", - here / "prj_steelix.conf", - ], ) +register_corsola_project("tentacruel") -register_corsola_project( - "tentacruel", - extra_dts_overlays=[ - here / "adc_tentacruel.dts", - here / "battery_tentacruel.dts", - here / "cbi_tentacruel.dts", - here / "gpio_tentacruel.dts", - here / "keyboard_krabby.dts", - here / "i2c_tentacruel.dts", - here / "interrupts_tentacruel.dts", - here / "led_tentacruel.dts", - here / "motionsense_tentacruel.dts", - here / "usbc_tentacruel.dts", - here / "thermistor_tentacruel.dts", - ], - extra_kconfig_files=[ - here / "prj_it81202_base.conf", - here / "prj_tentacruel.conf", - ], -) - -register_corsola_project( - "magikarp", - extra_dts_overlays=[ - here / "adc_magikarp.dts", - here / "battery_magikarp.dts", - here / "cbi_magikarp.dts", - here / "gpio_magikarp.dts", - here / "keyboard_krabby.dts", - here / "i2c_magikarp.dts", - here / "interrupts_magikarp.dts", - here / "led_magikarp.dts", - here / "motionsense_magikarp.dts", - here / "usbc_magikarp.dts", - ], - extra_kconfig_files=[ - here / "prj_it81202_base.conf", - here / "prj_magikarp.conf", - ], -) +register_corsola_project("magikarp") diff --git a/zephyr/program/corsola/adc_kingler.dts b/zephyr/program/corsola/adc_kingler.dts deleted file mode 100644 index 7b69abe48a..0000000000 --- a/zephyr/program/corsola/adc_kingler.dts +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * Kingler and Steelix use the same dts, take care of this when modify it. - */ - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_charger_pmon_r { - enum-name = "ADC_PSYS"; - io-channels = <&adc0 0>; - /* - * ISL9238C PSYS output is 1.44 uA/W over 33K resistor. - */ - mul = <21043>; - }; - adc_ec_id0 { - enum-name = "ADC_ID_0"; - io-channels = <&adc0 1>; - }; - adc_ec_id1 { - enum-name = "ADC_ID_1"; - io-channels = <&adc0 2>; - }; - adc_charger_amon_r { - enum-name = "ADC_AMON_BMON"; - io-channels = <&adc0 3>; - mul = <1000>; - div = <18>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan0_gp45 - &adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/corsola/adc_krabby.dts b/zephyr/program/corsola/adc_krabby.dts deleted file mode 100644 index be65e9eea7..0000000000 --- a/zephyr/program/corsola/adc_krabby.dts +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_vbus_c0 { - enum-name = "ADC_VBUS_C0"; - io-channels = <&adc0 0>; - mul = <10>; - }; - adc_board_id0 { - enum-name = "ADC_BOARD_ID_0"; - io-channels = <&adc0 1>; - }; - adc_board_id1 { - enum-name = "ADC_BOARD_ID_1"; - io-channels = <&adc0 2>; - }; - adc_vbus_c1 { - enum-name = "ADC_VBUS_C1"; - io-channels = <&adc0 7>; - mul = <10>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch1_gpi1_default - &adc0_ch2_gpi2_default - &adc0_ch7_gpi7_default>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/corsola/adc_magikarp.dts b/zephyr/program/corsola/adc_magikarp.dts deleted file mode 100644 index 358af6f0f4..0000000000 --- a/zephyr/program/corsola/adc_magikarp.dts +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - adc_vbus_c0 { - enum-name = "ADC_VBUS_C0"; - io-channels = <&adc0 0>; - mul = <10>; - }; - adc_board_id0 { - enum-name = "ADC_BOARD_ID_0"; - io-channels = <&adc0 1>; - }; - adc_board_id1 { - enum-name = "ADC_BOARD_ID_1"; - io-channels = <&adc0 2>; - }; - adc_vbus_c1 { - enum-name = "ADC_VBUS_C1"; - io-channels = <&adc0 7>; - mul = <10>; - }; - adc_ambient: ambient { - enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; - io-channels = <&adc0 5>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch1_gpi1_default - &adc0_ch2_gpi2_default - &adc0_ch5_gpi5_default - &adc0_ch7_gpi7_default>; - pinctrl-names = "default"; -}; - -/ { - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; - adc = <&adc_ambient>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - ambient { - sensor = <&temp_ambient>; - }; - }; -}; - -&thermistor_3V3_30K9_47K_NCP15WB { - status = "okay"; -}; diff --git a/zephyr/program/corsola/adc_magikarp.dtsi b/zephyr/program/corsola/adc_magikarp.dtsi new file mode 100644 index 0000000000..358af6f0f4 --- /dev/null +++ b/zephyr/program/corsola/adc_magikarp.dtsi @@ -0,0 +1,63 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; + io-channels = <&adc0 5>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch1_gpi1_default + &adc0_ch2_gpi2_default + &adc0_ch5_gpi5_default + &adc0_ch7_gpi7_default>; + pinctrl-names = "default"; +}; + +/ { + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; + adc = <&adc_ambient>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ambient { + sensor = <&temp_ambient>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_NCP15WB { + status = "okay"; +}; diff --git a/zephyr/program/corsola/adc_tentacruel.dts b/zephyr/program/corsola/adc_tentacruel.dts deleted file mode 100644 index 7ab6f8817b..0000000000 --- a/zephyr/program/corsola/adc_tentacruel.dts +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - adc_vbus_c0 { - enum-name = "ADC_VBUS_C0"; - io-channels = <&adc0 0>; - mul = <10>; - }; - adc_board_id0 { - enum-name = "ADC_BOARD_ID_0"; - io-channels = <&adc0 1>; - }; - adc_board_id1 { - enum-name = "ADC_BOARD_ID_1"; - io-channels = <&adc0 2>; - }; - adc_vbus_c1 { - enum-name = "ADC_VBUS_C1"; - io-channels = <&adc0 7>; - mul = <10>; - }; - adc_ambient: ambient { - enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; - io-channels = <&adc0 5>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_ch0_gpi0_default - &adc0_ch1_gpi1_default - &adc0_ch2_gpi2_default - &adc0_ch5_gpi5_default - &adc0_ch7_gpi7_default>; - pinctrl-names = "default"; -}; - -/ { - temp_ambient: ambient { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; - adc = <&adc_ambient>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - ambient { - temp_host_high = <56>; - temp_host_halt = <80>; - temp_host_release_high = <42>; - sensor = <&temp_ambient>; - }; - temp_charger: charger { - temp_host_high = <68>; - temp_host_halt = <90>; - temp_host_release_high = <59>; - sensor = <&charger>; - }; - }; -}; - -&thermistor_3V3_30K9_47K_NCP15WB { - status = "okay"; -}; diff --git a/zephyr/program/corsola/adc_tentacruel.dtsi b/zephyr/program/corsola/adc_tentacruel.dtsi new file mode 100644 index 0000000000..7ab6f8817b --- /dev/null +++ b/zephyr/program/corsola/adc_tentacruel.dtsi @@ -0,0 +1,72 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; + io-channels = <&adc0 5>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch1_gpi1_default + &adc0_ch2_gpi2_default + &adc0_ch5_gpi5_default + &adc0_ch7_gpi7_default>; + pinctrl-names = "default"; +}; + +/ { + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; + adc = <&adc_ambient>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ambient { + temp_host_high = <56>; + temp_host_halt = <80>; + temp_host_release_high = <42>; + sensor = <&temp_ambient>; + }; + temp_charger: charger { + temp_host_high = <68>; + temp_host_halt = <90>; + temp_host_release_high = <59>; + sensor = <&charger>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_NCP15WB { + status = "okay"; +}; diff --git a/zephyr/program/corsola/battery_kingler.dts b/zephyr/program/corsola/battery_kingler.dts deleted file mode 100644 index b01fb8a46d..0000000000 --- a/zephyr/program/corsola/battery_kingler.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: smp_l20m3pg2 { - compatible = "smp,l20m3pg2", "battery-smart"; - }; - lgc_l20l3pg2 { - compatible = "lgc,l20l3pg2", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/corsola/battery_kingler.dtsi b/zephyr/program/corsola/battery_kingler.dtsi new file mode 100644 index 0000000000..b01fb8a46d --- /dev/null +++ b/zephyr/program/corsola/battery_kingler.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: smp_l20m3pg2 { + compatible = "smp,l20m3pg2", "battery-smart"; + }; + lgc_l20l3pg2 { + compatible = "lgc,l20l3pg2", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/battery_krabby.dts b/zephyr/program/corsola/battery_krabby.dts deleted file mode 100644 index ce41859182..0000000000 --- a/zephyr/program/corsola/battery_krabby.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: c235 { - compatible = "celxpert,c235-41", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/corsola/battery_krabby.dtsi b/zephyr/program/corsola/battery_krabby.dtsi new file mode 100644 index 0000000000..ce41859182 --- /dev/null +++ b/zephyr/program/corsola/battery_krabby.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: c235 { + compatible = "celxpert,c235-41", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/battery_magikarp.dts b/zephyr/program/corsola/battery_magikarp.dts deleted file mode 100644 index bbdd6ac0c5..0000000000 --- a/zephyr/program/corsola/battery_magikarp.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: smp_c31n1915 { - compatible = "smp,c31n1915", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/corsola/battery_magikarp.dtsi b/zephyr/program/corsola/battery_magikarp.dtsi new file mode 100644 index 0000000000..bbdd6ac0c5 --- /dev/null +++ b/zephyr/program/corsola/battery_magikarp.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: smp_c31n1915 { + compatible = "smp,c31n1915", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/battery_steelix.dts b/zephyr/program/corsola/battery_steelix.dts deleted file mode 100644 index 594c83478c..0000000000 --- a/zephyr/program/corsola/battery_steelix.dts +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: byd_l22b3pg0 { - compatible = "byd,l22b3pg0", "battery-smart"; - }; - celxpert_l22c3pg0 { - compatible = "celxpert,l22c3pg0", "battery-smart"; - }; - cosmx_l22x3pg0 { - compatible = "cosmx,l22x3pg0", "battery-smart"; - }; - smp_l22m3pg0 { - compatible = "smp,l22m3pg0", "battery-smart"; - }; - sunwoda_l22d3pg0 { - compatible = "sunwoda,l22d3pg0", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/corsola/battery_steelix.dtsi b/zephyr/program/corsola/battery_steelix.dtsi new file mode 100644 index 0000000000..594c83478c --- /dev/null +++ b/zephyr/program/corsola/battery_steelix.dtsi @@ -0,0 +1,24 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: byd_l22b3pg0 { + compatible = "byd,l22b3pg0", "battery-smart"; + }; + celxpert_l22c3pg0 { + compatible = "celxpert,l22c3pg0", "battery-smart"; + }; + cosmx_l22x3pg0 { + compatible = "cosmx,l22x3pg0", "battery-smart"; + }; + smp_l22m3pg0 { + compatible = "smp,l22m3pg0", "battery-smart"; + }; + sunwoda_l22d3pg0 { + compatible = "sunwoda,l22d3pg0", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/battery_tentacruel.dts b/zephyr/program/corsola/battery_tentacruel.dts deleted file mode 100644 index f116c20a51..0000000000 --- a/zephyr/program/corsola/battery_tentacruel.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: dynapack_c140254 { - compatible = "dynapack,c140254", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/corsola/battery_tentacruel.dtsi b/zephyr/program/corsola/battery_tentacruel.dtsi new file mode 100644 index 0000000000..f116c20a51 --- /dev/null +++ b/zephyr/program/corsola/battery_tentacruel.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: dynapack_c140254 { + compatible = "dynapack,c140254", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/corsola/cbi_magikarp.dts b/zephyr/program/corsola/cbi_magikarp.dts deleted file mode 100644 index 5eac6b82c6..0000000000 --- a/zephyr/program/corsola/cbi_magikarp.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* magikarp-specific fw_config fields. */ - magikarp-fw-config { - compatible = "cros-ec,cbi-fw-config"; - /* - * FW_CONFIG field to describe mainboard orientation in chassis. - */ - base-gyro { - enum-name = "FW_BASE_GYRO"; - start = <0>; - size = <2>; - - None { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_NONE"; - value = <0>; - }; - icm42607 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_ICM42607"; - value = <1>; - default; - }; - bmi323 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_BMI323"; - value = <2>; - }; - }; - }; -}; diff --git a/zephyr/program/corsola/cbi_magikarp.dtsi b/zephyr/program/corsola/cbi_magikarp.dtsi new file mode 100644 index 0000000000..5eac6b82c6 --- /dev/null +++ b/zephyr/program/corsola/cbi_magikarp.dtsi @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* magikarp-specific fw_config fields. */ + magikarp-fw-config { + compatible = "cros-ec,cbi-fw-config"; + /* + * FW_CONFIG field to describe mainboard orientation in chassis. + */ + base-gyro { + enum-name = "FW_BASE_GYRO"; + start = <0>; + size = <2>; + + None { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_NONE"; + value = <0>; + }; + icm42607 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_ICM42607"; + value = <1>; + default; + }; + bmi323 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_BMI323"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/cbi_steelix.dts b/zephyr/program/corsola/cbi_steelix.dts deleted file mode 100644 index 6636b53a96..0000000000 --- a/zephyr/program/corsola/cbi_steelix.dts +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - steelix-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - /* - * FW_CONFIG field to indicate the device is clamshell - * or convertible. - */ - form_factor { - enum-name = "FORM_FACTOR"; - start = <13>; - size = <3>; - - convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "CONVERTIBLE"; - value = <1>; - }; - clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "CLAMSHELL"; - value = <0>; - }; - }; - - /* FW_CONFIG field to indicate which DB is attached. */ - db_config: db { - enum-name = "DB"; - start = <0>; - size = <4>; - - sub-board-1 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_NONE"; - value = <0>; - }; - sub-board-2 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_USBA_HDMI"; - value = <1>; - }; - sub-board-3 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_USBA_HDMI_LTE"; - value = <2>; - }; - }; - }; - - /* Steelix-specific ssfc fields. */ - steelix-ssfc { - compatible = "cros-ec,cbi-ssfc"; - - /* SSFC field to identify BASE motion sensor. */ - base-sensor { - enum-name = "BASE_SENSOR"; - size = <3>; - - base_sensor_0: bmi323 { - compatible = "cros-ec,cbi-ssfc-value"; - status = "okay"; - value = <1>; - default; - }; - base_sensor_1: lsm6dsm { - compatible = "cros-ec,cbi-ssfc-value"; - status = "okay"; - value = <2>; - }; - }; - - /* SSFC field to identify LID motion sensor. */ - lid-sensor { - enum-name = "LID_SENSOR"; - size = <3>; - - lid_sensor_0: bma422 { - compatible = "cros-ec,cbi-ssfc-value"; - status = "okay"; - value = <1>; - default; - }; - lid_sensor_1: lis2dw12 { - compatible = "cros-ec,cbi-ssfc-value"; - status = "okay"; - value = <2>; - }; - }; - }; -}; diff --git a/zephyr/program/corsola/cbi_steelix.dtsi b/zephyr/program/corsola/cbi_steelix.dtsi new file mode 100644 index 0000000000..6636b53a96 --- /dev/null +++ b/zephyr/program/corsola/cbi_steelix.dtsi @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + steelix-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to indicate the device is clamshell + * or convertible. + */ + form_factor { + enum-name = "FORM_FACTOR"; + start = <13>; + size = <3>; + + convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CONVERTIBLE"; + value = <1>; + }; + clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CLAMSHELL"; + value = <0>; + }; + }; + + /* FW_CONFIG field to indicate which DB is attached. */ + db_config: db { + enum-name = "DB"; + start = <0>; + size = <4>; + + sub-board-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_NONE"; + value = <0>; + }; + sub-board-2 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_USBA_HDMI"; + value = <1>; + }; + sub-board-3 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_USBA_HDMI_LTE"; + value = <2>; + }; + }; + }; + + /* Steelix-specific ssfc fields. */ + steelix-ssfc { + compatible = "cros-ec,cbi-ssfc"; + + /* SSFC field to identify BASE motion sensor. */ + base-sensor { + enum-name = "BASE_SENSOR"; + size = <3>; + + base_sensor_0: bmi323 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + base_sensor_1: lsm6dsm { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + + /* SSFC field to identify LID motion sensor. */ + lid-sensor { + enum-name = "LID_SENSOR"; + size = <3>; + + lid_sensor_0: bma422 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + lid_sensor_1: lis2dw12 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/cbi_tentacruel.dts b/zephyr/program/corsola/cbi_tentacruel.dts deleted file mode 100644 index 2cd4594417..0000000000 --- a/zephyr/program/corsola/cbi_tentacruel.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - /* tentacruel-specific fw_config fields. */ - tentacruel-fw-config { - compatible = "cros-ec,cbi-fw-config"; - /* - * FW_CONFIG field to describe mainboard orientation in chassis. - */ - base-gyro { - enum-name = "FW_BASE_GYRO"; - start = <8>; - size = <2>; - - None { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_NONE"; - value = <0>; - }; - icm42607 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_ICM42607"; - value = <1>; - default; - }; - bmi323 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_BASE_BMI323"; - value = <2>; - }; - }; - }; -}; diff --git a/zephyr/program/corsola/cbi_tentacruel.dtsi b/zephyr/program/corsola/cbi_tentacruel.dtsi new file mode 100644 index 0000000000..2cd4594417 --- /dev/null +++ b/zephyr/program/corsola/cbi_tentacruel.dtsi @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* tentacruel-specific fw_config fields. */ + tentacruel-fw-config { + compatible = "cros-ec,cbi-fw-config"; + /* + * FW_CONFIG field to describe mainboard orientation in chassis. + */ + base-gyro { + enum-name = "FW_BASE_GYRO"; + start = <8>; + size = <2>; + + None { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_NONE"; + value = <0>; + }; + icm42607 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_ICM42607"; + value = <1>; + default; + }; + bmi323 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_BMI323"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/common.dts b/zephyr/program/corsola/common.dts deleted file mode 100644 index 001dcc7ce3..0000000000 --- a/zephyr/program/corsola/common.dts +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - ec-mkbp-host-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <( - HOST_EVENT_AC_CONNECTED | - HOST_EVENT_AC_DISCONNECTED | - HOST_EVENT_LID_OPEN | - HOST_EVENT_POWER_BUTTON | - HOST_EVENT_HANG_DETECT | - HOST_EVENT_MODE_CHANGE)>; - }; - - ec-mkbp-event-wakeup-mask { - compatible = "ec-wake-mask-event"; - wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | - MKBP_EVENT_HOST_EVENT)>; - }; -}; diff --git a/zephyr/program/corsola/common.dtsi b/zephyr/program/corsola/common.dtsi new file mode 100644 index 0000000000..001dcc7ce3 --- /dev/null +++ b/zephyr/program/corsola/common.dtsi @@ -0,0 +1,25 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + ec-mkbp-host-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <( + HOST_EVENT_AC_CONNECTED | + HOST_EVENT_AC_DISCONNECTED | + HOST_EVENT_LID_OPEN | + HOST_EVENT_POWER_BUTTON | + HOST_EVENT_HANG_DETECT | + HOST_EVENT_MODE_CHANGE)>; + }; + + ec-mkbp-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | + MKBP_EVENT_HOST_EVENT)>; + }; +}; diff --git a/zephyr/program/corsola/default_gpio_pinctrl_kingler.dts b/zephyr/program/corsola/default_gpio_pinctrl_kingler.dts deleted file mode 100644 index 604658a145..0000000000 --- a/zephyr/program/corsola/default_gpio_pinctrl_kingler.dts +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ -&{/def-io-conf-list} { - pinmux = <&alt0_gpio_no_spip - &alt0_gpio_no_fpip - &alt1_no_pwrgd - &alt1_no_lpc_espi - &alta_no_peci_en - &altd_npsl_in1_sl - &altd_npsl_in2_sl - &altd_psl_in3_sl - &altd_psl_in4_sl - &alt7_no_ksi0_sl - &alt7_no_ksi1_sl - &alt7_no_ksi2_sl - &alt7_no_ksi3_sl - &alt7_no_ksi4_sl - &alt7_no_ksi5_sl - &alt7_no_ksi6_sl - &alt7_no_ksi7_sl - &alt8_no_kso00_sl - &alt8_no_kso01_sl - &alt8_no_kso02_sl - &alt8_no_kso03_sl - &alt8_no_kso04_sl - &alt8_no_kso05_sl - &alt8_no_kso06_sl - &alt8_no_kso07_sl - &alt9_no_kso08_sl - &alt9_no_kso09_sl - &alt9_no_kso10_sl - &alt9_no_kso11_sl - &alt9_no_kso12_sl - &alt9_no_kso13_sl - &alt9_no_kso14_sl - &alt9_no_kso15_sl - &alta_no_kso16_sl - &alta_no_kso17_sl - &altg_psl_gpo_sl>; -}; diff --git a/zephyr/program/corsola/gpio_kingler.dts b/zephyr/program/corsola/gpio_kingler.dts deleted file mode 100644 index 9a827a06dd..0000000000 --- a/zephyr/program/corsola/gpio_kingler.dts +++ /dev/null @@ -1,249 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - /* - * In npcx9 series, gpio46, gpio47, and the whole gpio5 port - * belong to VHIF power well. On kingler, it is connencted to - * 1.8V. - */ - base_imu_int_l: base_imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - spi_ap_clk_ec { - gpios = <&gpio5 5 GPIO_INPUT>; - }; - spi_ap_cs_ec_l { - gpios = <&gpio5 3 GPIO_INPUT>; - }; - spi_ap_do_ec_di { - gpios = <&gpio4 6 GPIO_INPUT>; - }; - spi_ap_di_ec_do { - gpios = <&gpio4 7 GPIO_INPUT>; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; - }; - en_ec_id_odl { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - }; - sys_rst_odl { - gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - ec_i2c_sensor_scl { - gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_sensor_sda { - gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_usb_c0_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_c0_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_usb_c1_scl { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - ec_i2c_usb_c1_sda { - gpios = <&gpio9 1 GPIO_INPUT>; - }; - ec_i2c_pwr_cbi_scl { - gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_pwr_cbi_sda { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_batt_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_batt_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - ec_pen_chg_dis_odl { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_wp_l: ec_wp_odl { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | - GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpiob 2 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ec_ap_int_odl { - gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpio8 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; - }; - charger_prochot_odl { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - ec_rst_odl { - gpios = <&gpio7 7 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; - }; - packet_mode_en { - gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiod 4 GPIO_INPUT>; - }; - /* - * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 - * belong to VSPI power rail. On kingler, it is connencted to - * 1.8V. - */ - ap_sysrst_odl_r: ap_sysrst_odl_r { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio6 7 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - pg_pp5000_z2_od { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpio7 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpio3 7 GPIO_INPUT>; - }; - en_pp5000_z2 { - gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - ec_batt_pres_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - usb_a0_fault_odl { - gpios = <&gpioc 7 GPIO_INPUT>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpio6 1 GPIO_ODR_HIGH>; - }; - ec_pmic_en_odl { - gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; - - /* - * aliases for sub-board GPIOs - */ - aliases { - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_power_button - &int_lid_open - >; - }; -}; diff --git a/zephyr/program/corsola/gpio_krabby.dts b/zephyr/program/corsola/gpio_krabby.dts deleted file mode 100644 index 5f06609f43..0000000000 --- a/zephyr/program/corsola/gpio_krabby.dts +++ /dev/null @@ -1,231 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &ec_flash_wp_odl; - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - named-gpios { - compatible = "named-gpios"; - - power_button_l: power_button_l { - gpios = <&gpioe 4 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - lid_open: lid_open { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - tablet_mode_l: tablet_mode_l { - gpios = <&gpioj 7 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - base_imu_int_l: base_imu_int_l { - gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l: lid_accel_int_l { - gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - volume_down_l: volume_down_l { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - volume_up_l: volume_up_l { - gpios = <&gpiod 6 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ac_present: ac_present { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - ec_flash_wp_odl: ec_flash_wp_odl { - gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - }; - spi0_cs: spi0_cs { - gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - usb_c0_ppc_bc12_int_odl: usb_c0_ppc_bc12_int_odl { - gpios = <&gpiod 1 GPIO_INPUT>; - }; - usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { - gpios = <&gpioj 4 GPIO_INPUT>; - }; - ec_pmic_en_odl: ec_pmic_en_odl { - gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - en_pp5000_z2: en_pp5000_z2 { - gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; - }; - sys_rst_odl: sys_rst_odl { - gpios = <&gpiog 1 GPIO_ODR_LOW>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - ap_sysrst_odl_r: ap_ec_sysrst_odl { - gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ec_int_l: ec_int_l { - gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - }; - usb_c0_ppc_frsinfo: usb_c0_ppc_frsinfo { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - en_ec_id_odl: en_ec_id_odl { - gpios = <&gpioh 5 GPIO_ODR_HIGH>; - }; - entering_rw: entering_rw { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; - }; - usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&gpioj 6 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpioj 3 GPIO_INPUT>; - }; - gpio_packet_mode_en: packet_mode_en { - gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioc 4 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = <&int_ac_present - &int_power_button - &int_lid_open>; - }; - - unused-pins { - compatible = "unused-gpios"; - - unused-gpios = - /* pg_pp5000_z2_od */ - <&gpiod 2 GPIO_INPUT>, - /* pg_mt6315_proc_b_odl */ - <&gpioe 1 GPIO_INPUT>, - /* ec_pen_chg_dis_odl */ - <&gpioh 3 GPIO_ODR_HIGH>, - /* unnamed nc pins */ - <&gpioa 3 GPIO_INPUT_PULL_DOWN>, - <&gpioa 6 GPIO_INPUT_PULL_DOWN>, - <&gpioa 7 GPIO_INPUT_PULL_DOWN>, - <&gpiod 7 GPIO_INPUT_PULL_DOWN>, - <&gpiof 1 GPIO_INPUT_PULL_DOWN>, - <&gpioh 0 GPIO_INPUT_PULL_DOWN>, - <&gpioh 6 GPIO_INPUT_PULL_DOWN>, - <&gpioi 3 GPIO_INPUT_PULL_DOWN>, - <&gpioi 5 GPIO_INPUT_PULL_DOWN>, - <&gpioi 6 GPIO_INPUT_PULL_DOWN>, - <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, - /* spi_clk_gpg6 */ - <&gpiog 6 GPIO_INPUT_PULL_UP>, - /* spi_mosi_gpg4 */ - <&gpiog 4 GPIO_OUTPUT_LOW>, - /* spi_miso_gpg5 */ - <&gpiog 5 GPIO_OUTPUT_LOW>, - /* spi_cs_gpg7 */ - <&gpiog 7 GPIO_OUTPUT_LOW>; - }; -}; - -&pinctrl { - /* I2C property setting */ - i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { - gpio-voltage = "1v8"; - }; - i2c0_data_gpb4_default: i2c0_data_gpb4_default { - gpio-voltage = "1v8"; - }; - i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { - gpio-voltage = "1v8"; - }; - i2c3_data_gpf3_default: i2c3_data_gpf3_default { - gpio-voltage = "1v8"; - }; - /* SHI property setting */ - shi_mosi_gpm0_default: shi_mosi_gpm0_default { - gpio-voltage = "1v8"; - }; - shi_miso_gpm1_default: shi_miso_gpm1_default { - gpio-voltage = "1v8"; - }; - shi_clk_gpm4_default: shi_clk_gpm4_default { - gpio-voltage = "1v8"; - }; - shi_cs_gpm5_default: shi_cs_gpm5_default { - gpio-voltage = "1v8"; - }; -}; diff --git a/zephyr/program/corsola/gpio_magikarp.dts b/zephyr/program/corsola/gpio_magikarp.dts deleted file mode 100644 index cb9f6f1a0a..0000000000 --- a/zephyr/program/corsola/gpio_magikarp.dts +++ /dev/null @@ -1,237 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &ec_flash_wp_odl; - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - named-gpios { - compatible = "named-gpios"; - - power_button_l: power_button_l { - gpios = <&gpioe 4 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - lid_open: lid_open { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - tablet_mode_l: tablet_mode_l { - gpios = <&gpioj 7 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - base_imu_int_l: base_imu_int_l { - gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l: lid_accel_int_l { - gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - volume_down_l: volume_down_l { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - volume_up_l: volume_up_l { - gpios = <&gpiod 6 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ac_present: ac_present { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - ec_flash_wp_odl: ec_flash_wp_odl { - gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - }; - spi0_cs: spi0_cs { - gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpiod 1 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpiof 1 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { - gpios = <&gpioj 4 GPIO_INPUT>; - }; - ec_pmic_en_odl: ec_pmic_en_odl { - gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - en_pp5000_z2: en_pp5000_z2 { - gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; - }; - sys_rst_odl: sys_rst_odl { - gpios = <&gpiog 1 GPIO_ODR_LOW>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - ap_sysrst_odl_r: ap_ec_sysrst_odl { - gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ec_int_l: ec_int_l { - gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - }; - usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - en_ec_id_odl: en_ec_id_odl { - gpios = <&gpioh 5 GPIO_ODR_HIGH>; - }; - entering_rw: entering_rw { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; - }; - usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&gpioj 6 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpioj 3 GPIO_INPUT>; - }; - gpio_packet_mode_en: packet_mode_en { - gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioc 4 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = <&int_ac_present - &int_power_button - &int_lid_open>; - }; - - unused-pins { - compatible = "unused-gpios"; - - unused-gpios = - /* pg_pp5000_z2_od */ - <&gpiod 2 GPIO_INPUT>, - /* pg_mt6315_proc_b_odl */ - <&gpioe 1 GPIO_INPUT>, - /* ec_pen_chg_dis_odl */ - <&gpioh 3 GPIO_ODR_HIGH>, - /* unnamed nc pins */ - <&gpioa 3 GPIO_INPUT_PULL_DOWN>, - <&gpioa 6 GPIO_INPUT_PULL_DOWN>, - <&gpioa 7 GPIO_INPUT_PULL_DOWN>, - /* reserved for b:241345809 */ - <&gpiod 7 GPIO_OUTPUT_LOW>, - <&gpiog 2 GPIO_INPUT_PULL_DOWN>, - <&gpioh 0 GPIO_INPUT_PULL_DOWN>, - <&gpioh 6 GPIO_INPUT_PULL_DOWN>, - <&gpioi 3 GPIO_INPUT_PULL_DOWN>, - <&gpioi 6 GPIO_INPUT_PULL_DOWN>, - <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, - /* spi_clk_gpg6 */ - <&gpiog 6 GPIO_INPUT_PULL_UP>, - /* spi_mosi_gpg4 */ - <&gpiog 4 GPIO_OUTPUT_LOW>, - /* spi_miso_gpg5 */ - <&gpiog 5 GPIO_OUTPUT_LOW>, - /* spi_cs_gpg7 */ - <&gpiog 7 GPIO_OUTPUT_LOW>; - }; -}; - -&pinctrl { - /* I2C property setting */ - i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { - gpio-voltage = "1v8"; - }; - i2c0_data_gpb4_default: i2c0_data_gpb4_default { - gpio-voltage = "1v8"; - }; - i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { - gpio-voltage = "1v8"; - }; - i2c3_data_gpf3_default: i2c3_data_gpf3_default { - gpio-voltage = "1v8"; - }; - /* SHI property setting */ - shi_mosi_gpm0_default: shi_mosi_gpm0_default { - gpio-voltage = "1v8"; - }; - shi_miso_gpm1_default: shi_miso_gpm1_default { - gpio-voltage = "1v8"; - }; - shi_clk_gpm4_default: shi_clk_gpm4_default { - gpio-voltage = "1v8"; - }; - shi_cs_gpm5_default: shi_cs_gpm5_default { - gpio-voltage = "1v8"; - }; -}; diff --git a/zephyr/program/corsola/gpio_magikarp.dtsi b/zephyr/program/corsola/gpio_magikarp.dtsi new file mode 100644 index 0000000000..cb9f6f1a0a --- /dev/null +++ b/zephyr/program/corsola/gpio_magikarp.dtsi @@ -0,0 +1,237 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &ec_flash_wp_odl; + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + base_imu_int_l: base_imu_int_l { + gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l: lid_accel_int_l { + gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + volume_down_l: volume_down_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + volume_up_l: volume_up_l { + gpios = <&gpiod 6 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ac_present: ac_present { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_flash_wp_odl: ec_flash_wp_odl { + gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpiod 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpiof 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + ec_pmic_en_odl: ec_pmic_en_odl { + gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + en_pp5000_z2: en_pp5000_z2 { + gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; + }; + sys_rst_odl: sys_rst_odl { + gpios = <&gpiog 1 GPIO_ODR_LOW>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + ap_sysrst_odl_r: ap_ec_sysrst_odl { + gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ec_int_l: ec_int_l { + gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + }; + usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + en_ec_id_odl: en_ec_id_odl { + gpios = <&gpioh 5 GPIO_ODR_HIGH>; + }; + entering_rw: entering_rw { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; + }; + usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&gpioj 6 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpioj 3 GPIO_INPUT>; + }; + gpio_packet_mode_en: packet_mode_en { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioc 4 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_ac_present + &int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* pg_pp5000_z2_od */ + <&gpiod 2 GPIO_INPUT>, + /* pg_mt6315_proc_b_odl */ + <&gpioe 1 GPIO_INPUT>, + /* ec_pen_chg_dis_odl */ + <&gpioh 3 GPIO_ODR_HIGH>, + /* unnamed nc pins */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + <&gpioa 6 GPIO_INPUT_PULL_DOWN>, + <&gpioa 7 GPIO_INPUT_PULL_DOWN>, + /* reserved for b:241345809 */ + <&gpiod 7 GPIO_OUTPUT_LOW>, + <&gpiog 2 GPIO_INPUT_PULL_DOWN>, + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + <&gpioi 3 GPIO_INPUT_PULL_DOWN>, + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, + /* spi_clk_gpg6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + /* spi_mosi_gpg4 */ + <&gpiog 4 GPIO_OUTPUT_LOW>, + /* spi_miso_gpg5 */ + <&gpiog 5 GPIO_OUTPUT_LOW>, + /* spi_cs_gpg7 */ + <&gpiog 7 GPIO_OUTPUT_LOW>; + }; +}; + +&pinctrl { + /* I2C property setting */ + i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { + gpio-voltage = "1v8"; + }; + i2c0_data_gpb4_default: i2c0_data_gpb4_default { + gpio-voltage = "1v8"; + }; + i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { + gpio-voltage = "1v8"; + }; + i2c3_data_gpf3_default: i2c3_data_gpf3_default { + gpio-voltage = "1v8"; + }; + /* SHI property setting */ + shi_mosi_gpm0_default: shi_mosi_gpm0_default { + gpio-voltage = "1v8"; + }; + shi_miso_gpm1_default: shi_miso_gpm1_default { + gpio-voltage = "1v8"; + }; + shi_clk_gpm4_default: shi_clk_gpm4_default { + gpio-voltage = "1v8"; + }; + shi_cs_gpm5_default: shi_cs_gpm5_default { + gpio-voltage = "1v8"; + }; +}; diff --git a/zephyr/program/corsola/gpio_steelix.dts b/zephyr/program/corsola/gpio_steelix.dts deleted file mode 100644 index 14120e6d7d..0000000000 --- a/zephyr/program/corsola/gpio_steelix.dts +++ /dev/null @@ -1,255 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - /* - * In npcx9 series, gpio46, gpio47, and the whole gpio5 port - * belong to VHIF power well. On steelix, it is connencted to - * 1.8V. - */ - base_imu_int_l: base_imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - spi_ap_clk_ec { - gpios = <&gpio5 5 GPIO_INPUT>; - }; - spi_ap_cs_ec_l { - gpios = <&gpio5 3 GPIO_INPUT>; - }; - spi_ap_do_ec_di { - gpios = <&gpio4 6 GPIO_INPUT>; - }; - spi_ap_di_ec_do { - gpios = <&gpio4 7 GPIO_INPUT>; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; - }; - en_ec_id_odl { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - }; - sys_rst_odl { - gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - ec_i2c_sensor_scl { - gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_sensor_sda { - gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_usb_c0_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_c0_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_usb_c1_scl { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - ec_i2c_usb_c1_sda { - gpios = <&gpio9 1 GPIO_INPUT>; - }; - ec_i2c_pwr_cbi_scl { - gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_pwr_cbi_sda { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_batt_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_batt_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x { - gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; - }; - usb_a1_fault_odl { - gpios = <&gpiof 4 GPIO_INPUT>; - }; - ec_pen_chg_dis_odl { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_wp_l: ec_wp_odl { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | - GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpiob 2 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ec_ap_int_odl { - gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpio8 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; - }; - charger_prochot_odl { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - ec_rst_odl { - gpios = <&gpio7 7 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; - }; - packet_mode_en { - gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiod 4 GPIO_INPUT>; - }; - /* - * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 - * belong to VSPI power well. On steelix, it is connencted to - * 1.8V. - */ - ap_sysrst_odl_r: ap_sysrst_odl_r { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio6 7 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - pg_pp5000_z2_od { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpio7 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpio3 7 GPIO_INPUT>; - }; - en_pp5000_z2 { - gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - ec_batt_pres_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - usb_a0_fault_odl { - gpios = <&gpioc 7 GPIO_INPUT>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpio6 1 GPIO_ODR_HIGH>; - }; - ec_pmic_en_odl { - gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; - - /* - * aliases for sub-board GPIOs - */ - aliases { - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_power_button - &int_lid_open - >; - }; -}; diff --git a/zephyr/program/corsola/gpio_steelix.dtsi b/zephyr/program/corsola/gpio_steelix.dtsi new file mode 100644 index 0000000000..14120e6d7d --- /dev/null +++ b/zephyr/program/corsola/gpio_steelix.dtsi @@ -0,0 +1,255 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + /* + * In npcx9 series, gpio46, gpio47, and the whole gpio5 port + * belong to VHIF power well. On steelix, it is connencted to + * 1.8V. + */ + base_imu_int_l: base_imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + spi_ap_clk_ec { + gpios = <&gpio5 5 GPIO_INPUT>; + }; + spi_ap_cs_ec_l { + gpios = <&gpio5 3 GPIO_INPUT>; + }; + spi_ap_do_ec_di { + gpios = <&gpio4 6 GPIO_INPUT>; + }; + spi_ap_di_ec_do { + gpios = <&gpio4 7 GPIO_INPUT>; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; + }; + en_ec_id_odl { + gpios = <&gpio7 6 GPIO_ODR_HIGH>; + }; + sys_rst_odl { + gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + ec_i2c_sensor_scl { + gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_sensor_sda { + gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_usb_c0_scl { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + ec_i2c_usb_c0_sda { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + ec_i2c_usb_c1_scl { + gpios = <&gpio9 2 GPIO_INPUT>; + }; + ec_i2c_usb_c1_sda { + gpios = <&gpio9 1 GPIO_INPUT>; + }; + ec_i2c_pwr_cbi_scl { + gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_pwr_cbi_sda { + gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_batt_scl { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + ec_i2c_batt_sda { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x { + gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; + }; + usb_a1_fault_odl { + gpios = <&gpiof 4 GPIO_INPUT>; + }; + ec_pen_chg_dis_odl { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_wp_l: ec_wp_odl { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | + GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpiob 2 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ec_ap_int_odl { + gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpio8 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; + }; + charger_prochot_odl { + gpios = <&gpiob 1 GPIO_INPUT>; + }; + ec_rst_odl { + gpios = <&gpio7 7 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; + }; + packet_mode_en { + gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiod 4 GPIO_INPUT>; + }; + /* + * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 + * belong to VSPI power well. On steelix, it is connencted to + * 1.8V. + */ + ap_sysrst_odl_r: ap_sysrst_odl_r { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio6 7 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + pg_pp5000_z2_od { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + gpios = <&gpio7 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; + }; + gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpio3 7 GPIO_INPUT>; + }; + en_pp5000_z2 { + gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + ec_batt_pres_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + usb_a0_fault_odl { + gpios = <&gpioc 7 GPIO_INPUT>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpio6 1 GPIO_ODR_HIGH>; + }; + ec_pmic_en_odl { + gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + }; + + /* + * aliases for sub-board GPIOs + */ + aliases { + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_power_button + &int_lid_open + >; + }; +}; diff --git a/zephyr/program/corsola/gpio_tentacruel.dts b/zephyr/program/corsola/gpio_tentacruel.dts deleted file mode 100644 index a9ac9e8eac..0000000000 --- a/zephyr/program/corsola/gpio_tentacruel.dts +++ /dev/null @@ -1,235 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &ec_flash_wp_odl; - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - named-gpios { - compatible = "named-gpios"; - - power_button_l: power_button_l { - gpios = <&gpioe 4 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - lid_open: lid_open { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - tablet_mode_l: tablet_mode_l { - gpios = <&gpioj 7 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - base_imu_int_l: base_imu_int_l { - gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l: lid_accel_int_l { - gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - volume_down_l: volume_down_l { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - volume_up_l: volume_up_l { - gpios = <&gpiod 6 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ac_present: ac_present { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; - }; - ec_flash_wp_odl: ec_flash_wp_odl { - gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - }; - spi0_cs: spi0_cs { - gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiob 2 GPIO_INPUT>; - }; - usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpiod 1 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpiof 1 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { - gpios = <&gpioj 4 GPIO_INPUT>; - }; - ec_pmic_en_odl: ec_pmic_en_odl { - gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - en_pp5000_z2: en_pp5000_z2 { - gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; - }; - sys_rst_odl: sys_rst_odl { - gpios = <&gpiog 1 GPIO_ODR_LOW>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - ap_sysrst_odl_r: ap_ec_sysrst_odl { - gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ec_int_l: ec_int_l { - gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - }; - usb_c0_frs_en: usb_c0_frs_en { - gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_FRS_EN"; - }; - ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - en_ec_id_odl: en_ec_id_odl { - gpios = <&gpioh 5 GPIO_ODR_HIGH>; - }; - entering_rw: entering_rw { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; - }; - usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&gpioj 6 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpioj 3 GPIO_INPUT>; - }; - gpio_packet_mode_en: packet_mode_en { - gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioc 4 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = <&int_ac_present - &int_power_button - &int_lid_open>; - }; - - unused-pins { - compatible = "unused-gpios"; - - unused-gpios = - /* pg_pp5000_z2_od */ - <&gpiod 2 GPIO_INPUT>, - /* pg_mt6315_proc_b_odl */ - <&gpioe 1 GPIO_INPUT>, - /* ec_pen_chg_dis_odl */ - <&gpioh 3 GPIO_ODR_HIGH>, - /* unnamed nc pins */ - <&gpioa 3 GPIO_INPUT_PULL_DOWN>, - <&gpioa 6 GPIO_INPUT_PULL_DOWN>, - <&gpioa 7 GPIO_INPUT_PULL_DOWN>, - <&gpiod 7 GPIO_INPUT_PULL_DOWN>, - <&gpioh 0 GPIO_INPUT_PULL_DOWN>, - <&gpioh 6 GPIO_INPUT_PULL_DOWN>, - <&gpioi 3 GPIO_INPUT_PULL_DOWN>, - <&gpioi 6 GPIO_INPUT_PULL_DOWN>, - <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, - /* spi_clk_gpg6 */ - <&gpiog 6 GPIO_INPUT_PULL_UP>, - /* spi_mosi_gpg4 */ - <&gpiog 4 GPIO_OUTPUT_LOW>, - /* spi_miso_gpg5 */ - <&gpiog 5 GPIO_OUTPUT_LOW>, - /* spi_cs_gpg7 */ - <&gpiog 7 GPIO_OUTPUT_LOW>; - }; -}; - -&pinctrl { - /* I2C property setting */ - i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { - gpio-voltage = "1v8"; - }; - i2c0_data_gpb4_default: i2c0_data_gpb4_default { - gpio-voltage = "1v8"; - }; - i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { - gpio-voltage = "1v8"; - }; - i2c3_data_gpf3_default: i2c3_data_gpf3_default { - gpio-voltage = "1v8"; - }; - /* SHI property setting */ - shi_mosi_gpm0_default: shi_mosi_gpm0_default { - gpio-voltage = "1v8"; - }; - shi_miso_gpm1_default: shi_miso_gpm1_default { - gpio-voltage = "1v8"; - }; - shi_clk_gpm4_default: shi_clk_gpm4_default { - gpio-voltage = "1v8"; - }; - shi_cs_gpm5_default: shi_cs_gpm5_default { - gpio-voltage = "1v8"; - }; -}; diff --git a/zephyr/program/corsola/gpio_tentacruel.dtsi b/zephyr/program/corsola/gpio_tentacruel.dtsi new file mode 100644 index 0000000000..a9ac9e8eac --- /dev/null +++ b/zephyr/program/corsola/gpio_tentacruel.dtsi @@ -0,0 +1,235 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &ec_flash_wp_odl; + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + base_imu_int_l: base_imu_int_l { + gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l: lid_accel_int_l { + gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + volume_down_l: volume_down_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + volume_up_l: volume_up_l { + gpios = <&gpiod 6 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ac_present: ac_present { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_flash_wp_odl: ec_flash_wp_odl { + gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpiod 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpiof 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + ec_pmic_en_odl: ec_pmic_en_odl { + gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + en_pp5000_z2: en_pp5000_z2 { + gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; + }; + sys_rst_odl: sys_rst_odl { + gpios = <&gpiog 1 GPIO_ODR_LOW>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + ap_sysrst_odl_r: ap_ec_sysrst_odl { + gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ec_int_l: ec_int_l { + gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + }; + usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + en_ec_id_odl: en_ec_id_odl { + gpios = <&gpioh 5 GPIO_ODR_HIGH>; + }; + entering_rw: entering_rw { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; + }; + usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&gpioj 6 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpioj 3 GPIO_INPUT>; + }; + gpio_packet_mode_en: packet_mode_en { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioc 4 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_ac_present + &int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* pg_pp5000_z2_od */ + <&gpiod 2 GPIO_INPUT>, + /* pg_mt6315_proc_b_odl */ + <&gpioe 1 GPIO_INPUT>, + /* ec_pen_chg_dis_odl */ + <&gpioh 3 GPIO_ODR_HIGH>, + /* unnamed nc pins */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + <&gpioa 6 GPIO_INPUT_PULL_DOWN>, + <&gpioa 7 GPIO_INPUT_PULL_DOWN>, + <&gpiod 7 GPIO_INPUT_PULL_DOWN>, + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + <&gpioi 3 GPIO_INPUT_PULL_DOWN>, + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, + /* spi_clk_gpg6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + /* spi_mosi_gpg4 */ + <&gpiog 4 GPIO_OUTPUT_LOW>, + /* spi_miso_gpg5 */ + <&gpiog 5 GPIO_OUTPUT_LOW>, + /* spi_cs_gpg7 */ + <&gpiog 7 GPIO_OUTPUT_LOW>; + }; +}; + +&pinctrl { + /* I2C property setting */ + i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { + gpio-voltage = "1v8"; + }; + i2c0_data_gpb4_default: i2c0_data_gpb4_default { + gpio-voltage = "1v8"; + }; + i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { + gpio-voltage = "1v8"; + }; + i2c3_data_gpf3_default: i2c3_data_gpf3_default { + gpio-voltage = "1v8"; + }; + /* SHI property setting */ + shi_mosi_gpm0_default: shi_mosi_gpm0_default { + gpio-voltage = "1v8"; + }; + shi_miso_gpm1_default: shi_miso_gpm1_default { + gpio-voltage = "1v8"; + }; + shi_clk_gpm4_default: shi_clk_gpm4_default { + gpio-voltage = "1v8"; + }; + shi_cs_gpm5_default: shi_cs_gpm5_default { + gpio-voltage = "1v8"; + }; +}; diff --git a/zephyr/program/corsola/host_interface_npcx.dts b/zephyr/program/corsola/host_interface_npcx.dts deleted file mode 100644 index 14efa3c6b2..0000000000 --- a/zephyr/program/corsola/host_interface_npcx.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* host interface */ -&shi { - status = "okay"; - pinctrl-0 = <&shi_gp46_47_53_55>; - pinctrl-1 = <&shi_gpio_gp46_47_53_55>; - pinctrl-names = "default", "sleep"; -}; diff --git a/zephyr/program/corsola/i2c_kingler.dts b/zephyr/program/corsola/i2c_kingler.dts deleted file mode 100644 index 90390ab8a0..0000000000 --- a/zephyr/program/corsola/i2c_kingler.dts +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/* - * Kingler and Steelix use the same dts, take care of this when modify it. - */ - -/ { - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_sensor: sensor { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_SENSOR"; - }; - i2c_usb_c0: usb-c0 { - i2c-port = <&i2c1_0>; - remote-port = <7>; - enum-names = "I2C_PORT_USB_C0"; - }; - i2c_usb_c1: usb-c1 { - i2c-port = <&i2c2_0>; - enum-names = "I2C_PORT_USB_C1", - "I2C_PORT_USB_C1_TCPC", - "I2C_PORT_USB_C1_PPC"; - }; - i2c_charger: charger { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_POWER", - "I2C_PORT_EEPROM"; - }; - battery { - i2c-port = <&i2c5_0>; - remote-port = <1>; - enum-names = "I2C_PORT_BATTERY", - "I2C_PORT_VIRTUAL_BATTERY"; - }; - }; -}; - -&i2c0_0 { - label = "I2C_SENSOR"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - label = "I2C_USB_C0"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - tcpc_port0: anx7447-tcpc@2c { - compatible = "analogix,anx7447-tcpc"; - status = "okay"; - reg = <0x2c>; - tcpc-flags = <( - TCPC_FLAGS_VBUS_MONITOR | - TCPC_FLAGS_ALERT_OD | - TCPC_FLAGS_CONTROL_VCONN | - TCPC_FLAGS_CONTROL_FRS)>; - }; - - ppc_port0: nx20p348x@72 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x72>; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - label = "I2C_USB_C1"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; - - bc12_port1: rt1718s-bc12@40 { - compatible = "richtek,rt1718s-bc12"; - status = "okay"; - reg = <0x40>; - }; - - tcpc_port1: rt1718s-tcpc@40 { - compatible = "richtek,rt1718s-tcpc"; - reg = <0x40>; - tcpc-flags = <( - TCPC_FLAGS_ALERT_OD | - TCPC_FLAGS_CONTROL_VCONN | - TCPC_FLAGS_CONTROL_FRS)>; - }; - - ppc_port1: nx20p348x@72 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x72>; - }; - - ps8743_mux_1: ps8743-mux-1@10 { - compatible = "parade,ps8743"; - reg = <0x10>; - board-init = "ps8743_mux_1_board_init"; - }; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - label = "I2C_PWR_CBI"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; - - charger: isl923x@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c5_0 { - label = "I2C_BATTERY"; - status = "okay"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; -}; - -&i2c_ctrl5 { - status = "okay"; -}; diff --git a/zephyr/program/corsola/i2c_krabby.dts b/zephyr/program/corsola/i2c_krabby.dts deleted file mode 100644 index a873210ff7..0000000000 --- a/zephyr/program/corsola/i2c_krabby.dts +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ite_i2c.dtsi" - -&i2c0 { - charger: rt9490@53 { - compatible = "richtek,rt9490"; - status = "okay"; - reg = <0x53>; - }; -}; - -&i2c4 { - tusb1064_mux_1: tusb1064-mux-1@44 { - compatible = "ti,tusb1064"; - reg = <0x44>; - board-init = "tusb1064_mux_1_board_init"; - }; -}; diff --git a/zephyr/program/corsola/i2c_krabby.dtsi b/zephyr/program/corsola/i2c_krabby.dtsi new file mode 100644 index 0000000000..a873210ff7 --- /dev/null +++ b/zephyr/program/corsola/i2c_krabby.dtsi @@ -0,0 +1,22 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ite_i2c.dtsi" + +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; + }; +}; + +&i2c4 { + tusb1064_mux_1: tusb1064-mux-1@44 { + compatible = "ti,tusb1064"; + reg = <0x44>; + board-init = "tusb1064_mux_1_board_init"; + }; +}; diff --git a/zephyr/program/corsola/i2c_magikarp.dts b/zephyr/program/corsola/i2c_magikarp.dts deleted file mode 100644 index 45b7cf20fb..0000000000 --- a/zephyr/program/corsola/i2c_magikarp.dts +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ite_i2c.dtsi" - -&i2c0 { - charger: rt9490@53 { - compatible = "richtek,rt9490"; - status = "okay"; - reg = <0x53>; - }; -}; - -&i2c2 { - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - ppc_port0: syv682x@40 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x40>; - frs_en_gpio = <&usb_c0_frs_en>; - }; -}; - -&i2c4 { - ps8743_mux_1: ps8743-mux-1@10 { - compatible = "parade,ps8743"; - reg = <0x10>; - }; -}; diff --git a/zephyr/program/corsola/i2c_magikarp.dtsi b/zephyr/program/corsola/i2c_magikarp.dtsi new file mode 100644 index 0000000000..45b7cf20fb --- /dev/null +++ b/zephyr/program/corsola/i2c_magikarp.dtsi @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ite_i2c.dtsi" + +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; + }; +}; + +&i2c2 { + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + ppc_port0: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&usb_c0_frs_en>; + }; +}; + +&i2c4 { + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + }; +}; diff --git a/zephyr/program/corsola/i2c_tentacruel.dts b/zephyr/program/corsola/i2c_tentacruel.dts deleted file mode 100644 index e56119ff86..0000000000 --- a/zephyr/program/corsola/i2c_tentacruel.dts +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ite_i2c.dtsi" - -&i2c0 { - charger: rt9490@53 { - compatible = "richtek,rt9490"; - status = "okay"; - reg = <0x53>; - thermistor = <&thermistor_rt9490>; - }; -}; - -&i2c2 { - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - ppc_port0: syv682x@40 { - compatible = "silergy,syv682x"; - status = "okay"; - reg = <0x40>; - frs_en_gpio = <&usb_c0_frs_en>; - }; -}; - -&i2c4 { - ps8743_mux_1: ps8743-mux-1@10 { - compatible = "parade,ps8743"; - reg = <0x10>; - board-init = "ps8743_eq_c1_setting"; - }; -}; diff --git a/zephyr/program/corsola/i2c_tentacruel.dtsi b/zephyr/program/corsola/i2c_tentacruel.dtsi new file mode 100644 index 0000000000..e56119ff86 --- /dev/null +++ b/zephyr/program/corsola/i2c_tentacruel.dtsi @@ -0,0 +1,38 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ite_i2c.dtsi" + +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; + thermistor = <&thermistor_rt9490>; + }; +}; + +&i2c2 { + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + ppc_port0: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&usb_c0_frs_en>; + }; +}; + +&i2c4 { + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + board-init = "ps8743_eq_c1_setting"; + }; +}; diff --git a/zephyr/program/corsola/interrupts_kingler.dts b/zephyr/program/corsola/interrupts_kingler.dts deleted file mode 100644 index f3da785a60..0000000000 --- a/zephyr/program/corsola/interrupts_kingler.dts +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * Kingler and Steelix use the same dts, take care of this when modify it. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_ec_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_ec_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_warm_rst: warm_rst { - irq-pin = <&ap_ec_warm_rst_req>; - flags = ; - handler = "chipset_reset_request_interrupt"; - }; - int_ap_in_sleep: ap_in_sleep { - irq-pin = <&ap_in_sleep_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_in_rst: ap_in_rst { - irq-pin = <&ap_sysrst_odl_r>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_wdtrst: ap_wdtrst { - irq-pin = <&ap_ec_wdtrst_l>; - flags = ; - handler = "chipset_watchdog_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&gpio_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_usba: usba { - irq-pin = <&gpio_ap_xhci_init_done>; - flags = ; - handler = "usb_a0_interrupt"; - }; - int_wp: wp { - irq-pin = <&gpio_ec_wp_l>; - flags = ; - handler = "switch_interrupt"; - }; - int_usb_c0_tcpc: usb_c0_tcpc { - irq-pin = <&gpio_usb_c0_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_tcpc: usb_c1_tcpc { - irq-pin = <&gpio_usb_c1_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&gpio_usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_x_ec_gpio2: x_ec_gpio2 { - irq-pin = <&gpio_x_ec_gpio2>; - flags = ; - handler = "x_ec_interrupt"; - }; - int_base_imu: base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "bmi3xx_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&gpio_tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "ccd_interrupt"; - }; - }; -}; diff --git a/zephyr/program/corsola/interrupts_krabby.dts b/zephyr/program/corsola/interrupts_krabby.dts deleted file mode 100644 index 3caf4660ae..0000000000 --- a/zephyr/program/corsola/interrupts_krabby.dts +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&volume_up_l>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&volume_down_l>; - flags = ; - handler = "button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_warm_rst: warm_rst { - irq-pin = <&ap_ec_warm_rst_req>; - flags = ; - handler = "chipset_reset_request_interrupt"; - }; - int_ap_in_sleep: ap_in_sleep { - irq-pin = <&ap_in_sleep_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_in_rst: ap_in_rst { - irq-pin = <&ap_sysrst_odl_r>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_wdtrst: ap_wdtrst { - irq-pin = <&ap_ec_wdtrst_l>; - flags = ; - handler = "chipset_watchdog_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_base_imu: base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "icm42607_interrupt"; - }; - int_lid_imu: lid_imu { - irq-pin = <&lid_accel_int_l>; - flags = ; - handler = "lis2dw12_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&ac_present>; - flags = ; - handler = "extpower_interrupt"; - }; - int_usba: usba { - irq-pin = <&gpio_ap_xhci_init_done>; - flags = ; - handler = "usb_a0_interrupt"; - }; - int_wp: wp { - irq-pin = <&ec_flash_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_spi0_cs: spi0_cs { - irq-pin = <&spi0_cs>; - flags = ; - handler = "spi_event"; - }; - int_x_ec_gpio2: x_ec_gpio2 { - irq-pin = <&gpio_x_ec_gpio2>; - flags = ; - handler = "x_ec_interrupt"; - }; - int_usb_c0_ppc_bc12: usb_c0_ppc_bc12 { - irq-pin = <&usb_c0_ppc_bc12_int_odl>; - flags = ; - handler = "c0_bc12_interrupt"; - }; - int_usb_c1_bc12_charger: usb_c1_bc12_charger { - irq-pin = <&usb_c1_bc12_charger_int_odl>; - flags = ; - handler = "rt9490_bc12_dt_interrupt"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "ccd_interrupt"; - }; - }; -}; diff --git a/zephyr/program/corsola/interrupts_magikarp.dts b/zephyr/program/corsola/interrupts_magikarp.dts deleted file mode 100644 index 4f4e0ba100..0000000000 --- a/zephyr/program/corsola/interrupts_magikarp.dts +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&volume_up_l>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&volume_down_l>; - flags = ; - handler = "button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_warm_rst: warm_rst { - irq-pin = <&ap_ec_warm_rst_req>; - flags = ; - handler = "chipset_reset_request_interrupt"; - }; - int_ap_in_sleep: ap_in_sleep { - irq-pin = <&ap_in_sleep_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_in_rst: ap_in_rst { - irq-pin = <&ap_sysrst_odl_r>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_wdtrst: ap_wdtrst { - irq-pin = <&ap_ec_wdtrst_l>; - flags = ; - handler = "chipset_watchdog_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_base_imu: base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "motion_interrupt"; - }; - int_lid_imu: lid_imu { - irq-pin = <&lid_accel_int_l>; - flags = ; - handler = "lis2dw12_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&ac_present>; - flags = ; - handler = "extpower_interrupt"; - }; - int_usba: usba { - irq-pin = <&gpio_ap_xhci_init_done>; - flags = ; - handler = "usb_a0_interrupt"; - }; - int_wp: wp { - irq-pin = <&ec_flash_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_spi0_cs: spi0_cs { - irq-pin = <&spi0_cs>; - flags = ; - handler = "spi_event"; - }; - int_x_ec_gpio2: x_ec_gpio2 { - irq-pin = <&gpio_x_ec_gpio2>; - flags = ; - handler = "x_ec_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_bc12_charger: usb_c1_bc12_charger { - irq-pin = <&usb_c1_bc12_charger_int_odl>; - flags = ; - handler = "rt9490_bc12_dt_interrupt"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "ccd_interrupt"; - }; - }; -}; diff --git a/zephyr/program/corsola/interrupts_magikarp.dtsi b/zephyr/program/corsola/interrupts_magikarp.dtsi new file mode 100644 index 0000000000..4f4e0ba100 --- /dev/null +++ b/zephyr/program/corsola/interrupts_magikarp.dtsi @@ -0,0 +1,115 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&volume_up_l>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&volume_down_l>; + flags = ; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = ; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = ; + handler = "chipset_watchdog_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "motion_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&lid_accel_int_l>; + flags = ; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&ac_present>; + flags = ; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = ; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&ec_flash_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = ; + handler = "spi_event"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = ; + handler = "x_ec_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_bc12_charger: usb_c1_bc12_charger { + irq-pin = <&usb_c1_bc12_charger_int_odl>; + flags = ; + handler = "rt9490_bc12_dt_interrupt"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "ccd_interrupt"; + }; + }; +}; diff --git a/zephyr/program/corsola/interrupts_steelix.dts b/zephyr/program/corsola/interrupts_steelix.dts deleted file mode 100644 index 816beb95f4..0000000000 --- a/zephyr/program/corsola/interrupts_steelix.dts +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -&int_base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "motion_interrupt"; -}; diff --git a/zephyr/program/corsola/interrupts_steelix.dtsi b/zephyr/program/corsola/interrupts_steelix.dtsi new file mode 100644 index 0000000000..816beb95f4 --- /dev/null +++ b/zephyr/program/corsola/interrupts_steelix.dtsi @@ -0,0 +1,10 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +&int_base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "motion_interrupt"; +}; diff --git a/zephyr/program/corsola/interrupts_tentacruel.dts b/zephyr/program/corsola/interrupts_tentacruel.dts deleted file mode 100644 index 11229daf36..0000000000 --- a/zephyr/program/corsola/interrupts_tentacruel.dts +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - int-wp = &int_wp; - }; - - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_power_button: power_button { - irq-pin = <&power_button_l>; - flags = ; - handler = "power_button_interrupt"; - }; - int_volume_up: volume_up { - irq-pin = <&volume_up_l>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&volume_down_l>; - flags = ; - handler = "button_interrupt"; - }; - int_lid_open: lid_open { - irq-pin = <&lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_warm_rst: warm_rst { - irq-pin = <&ap_ec_warm_rst_req>; - flags = ; - handler = "chipset_reset_request_interrupt"; - }; - int_ap_in_sleep: ap_in_sleep { - irq-pin = <&ap_in_sleep_l>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_in_rst: ap_in_rst { - irq-pin = <&ap_sysrst_odl_r>; - flags = ; - handler = "power_signal_interrupt"; - }; - int_ap_wdtrst: ap_wdtrst { - irq-pin = <&ap_ec_wdtrst_l>; - flags = ; - handler = "chipset_watchdog_interrupt"; - }; - int_tablet_mode: tablet_mode { - irq-pin = <&tablet_mode_l>; - flags = ; - handler = "gmr_tablet_switch_isr"; - }; - int_base_imu: base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "motion_interrupt"; - }; - int_lid_imu: lid_imu { - irq-pin = <&lid_accel_int_l>; - flags = ; - handler = "lis2dw12_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&ac_present>; - flags = ; - handler = "extpower_interrupt"; - }; - int_usba: usba { - irq-pin = <&gpio_ap_xhci_init_done>; - flags = ; - handler = "usb_a0_interrupt"; - }; - int_wp: wp { - irq-pin = <&ec_flash_wp_odl>; - flags = ; - handler = "switch_interrupt"; - }; - int_spi0_cs: spi0_cs { - irq-pin = <&spi0_cs>; - flags = ; - handler = "spi_event"; - }; - int_x_ec_gpio2: x_ec_gpio2 { - irq-pin = <&gpio_x_ec_gpio2>; - flags = ; - handler = "x_ec_interrupt"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c1_bc12_charger: usb_c1_bc12_charger { - irq-pin = <&usb_c1_bc12_charger_int_odl>; - flags = ; - handler = "rt9490_bc12_dt_interrupt"; - }; - int_ccd_mode_odl: ccd-mode-odl { - irq-pin = <&gpio_ccd_mode_odl>; - flags = ; - handler = "ccd_interrupt"; - }; - }; -}; diff --git a/zephyr/program/corsola/interrupts_tentacruel.dtsi b/zephyr/program/corsola/interrupts_tentacruel.dtsi new file mode 100644 index 0000000000..11229daf36 --- /dev/null +++ b/zephyr/program/corsola/interrupts_tentacruel.dtsi @@ -0,0 +1,115 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&volume_up_l>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&volume_down_l>; + flags = ; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = ; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = ; + handler = "chipset_watchdog_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "motion_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&lid_accel_int_l>; + flags = ; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&ac_present>; + flags = ; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = ; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&ec_flash_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = ; + handler = "spi_event"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = ; + handler = "x_ec_interrupt"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c1_bc12_charger: usb_c1_bc12_charger { + irq-pin = <&usb_c1_bc12_charger_int_odl>; + flags = ; + handler = "rt9490_bc12_dt_interrupt"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "ccd_interrupt"; + }; + }; +}; diff --git a/zephyr/program/corsola/ite_adc.dtsi b/zephyr/program/corsola/ite_adc.dtsi new file mode 100644 index 0000000000..be65e9eea7 --- /dev/null +++ b/zephyr/program/corsola/ite_adc.dtsi @@ -0,0 +1,38 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch1_gpi1_default + &adc0_ch2_gpi2_default + &adc0_ch7_gpi7_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/ite_gpio.dtsi b/zephyr/program/corsola/ite_gpio.dtsi new file mode 100644 index 0000000000..5f06609f43 --- /dev/null +++ b/zephyr/program/corsola/ite_gpio.dtsi @@ -0,0 +1,231 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &ec_flash_wp_odl; + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + base_imu_int_l: base_imu_int_l { + gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l: lid_accel_int_l { + gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + volume_down_l: volume_down_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + volume_up_l: volume_up_l { + gpios = <&gpiod 6 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ac_present: ac_present { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_flash_wp_odl: ec_flash_wp_odl { + gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usb_c0_ppc_bc12_int_odl: usb_c0_ppc_bc12_int_odl { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + ec_pmic_en_odl: ec_pmic_en_odl { + gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + en_pp5000_z2: en_pp5000_z2 { + gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; + }; + sys_rst_odl: sys_rst_odl { + gpios = <&gpiog 1 GPIO_ODR_LOW>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + ap_sysrst_odl_r: ap_ec_sysrst_odl { + gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ec_int_l: ec_int_l { + gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + }; + usb_c0_ppc_frsinfo: usb_c0_ppc_frsinfo { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + en_ec_id_odl: en_ec_id_odl { + gpios = <&gpioh 5 GPIO_ODR_HIGH>; + }; + entering_rw: entering_rw { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; + }; + usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&gpioj 6 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpioj 3 GPIO_INPUT>; + }; + gpio_packet_mode_en: packet_mode_en { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioc 4 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_ac_present + &int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* pg_pp5000_z2_od */ + <&gpiod 2 GPIO_INPUT>, + /* pg_mt6315_proc_b_odl */ + <&gpioe 1 GPIO_INPUT>, + /* ec_pen_chg_dis_odl */ + <&gpioh 3 GPIO_ODR_HIGH>, + /* unnamed nc pins */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + <&gpioa 6 GPIO_INPUT_PULL_DOWN>, + <&gpioa 7 GPIO_INPUT_PULL_DOWN>, + <&gpiod 7 GPIO_INPUT_PULL_DOWN>, + <&gpiof 1 GPIO_INPUT_PULL_DOWN>, + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + <&gpioi 3 GPIO_INPUT_PULL_DOWN>, + <&gpioi 5 GPIO_INPUT_PULL_DOWN>, + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, + /* spi_clk_gpg6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + /* spi_mosi_gpg4 */ + <&gpiog 4 GPIO_OUTPUT_LOW>, + /* spi_miso_gpg5 */ + <&gpiog 5 GPIO_OUTPUT_LOW>, + /* spi_cs_gpg7 */ + <&gpiog 7 GPIO_OUTPUT_LOW>; + }; +}; + +&pinctrl { + /* I2C property setting */ + i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { + gpio-voltage = "1v8"; + }; + i2c0_data_gpb4_default: i2c0_data_gpb4_default { + gpio-voltage = "1v8"; + }; + i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { + gpio-voltage = "1v8"; + }; + i2c3_data_gpf3_default: i2c3_data_gpf3_default { + gpio-voltage = "1v8"; + }; + /* SHI property setting */ + shi_mosi_gpm0_default: shi_mosi_gpm0_default { + gpio-voltage = "1v8"; + }; + shi_miso_gpm1_default: shi_miso_gpm1_default { + gpio-voltage = "1v8"; + }; + shi_clk_gpm4_default: shi_clk_gpm4_default { + gpio-voltage = "1v8"; + }; + shi_cs_gpm5_default: shi_cs_gpm5_default { + gpio-voltage = "1v8"; + }; +}; diff --git a/zephyr/program/corsola/ite_interrupts.dtsi b/zephyr/program/corsola/ite_interrupts.dtsi new file mode 100644 index 0000000000..3caf4660ae --- /dev/null +++ b/zephyr/program/corsola/ite_interrupts.dtsi @@ -0,0 +1,110 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&volume_up_l>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&volume_down_l>; + flags = ; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = ; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = ; + handler = "chipset_watchdog_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "icm42607_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&lid_accel_int_l>; + flags = ; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&ac_present>; + flags = ; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = ; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&ec_flash_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = ; + handler = "spi_event"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = ; + handler = "x_ec_interrupt"; + }; + int_usb_c0_ppc_bc12: usb_c0_ppc_bc12 { + irq-pin = <&usb_c0_ppc_bc12_int_odl>; + flags = ; + handler = "c0_bc12_interrupt"; + }; + int_usb_c1_bc12_charger: usb_c1_bc12_charger { + irq-pin = <&usb_c1_bc12_charger_int_odl>; + flags = ; + handler = "rt9490_bc12_dt_interrupt"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "ccd_interrupt"; + }; + }; +}; diff --git a/zephyr/program/corsola/ite_keyboard.dtsi b/zephyr/program/corsola/ite_keyboard.dtsi new file mode 100644 index 0000000000..b1a9af6330 --- /dev/null +++ b/zephyr/program/corsola/ite_keyboard.dtsi @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + scan-period = <10000>; + + actual-key-mask = < + 0x1c /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; diff --git a/zephyr/program/corsola/ite_motionsense.dtsi b/zephyr/program/corsola/ite_motionsense.dtsi new file mode 100644 index 0000000000..1c7d5b2df4 --- /dev/null +++ b/zephyr/program/corsola/ite_motionsense.dtsi @@ -0,0 +1,146 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + icm42607-int = &base_accel; + lis2dw12-int = &lid_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: icm42607-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + icm42607_data: icm42607-drv-data { + compatible = "cros-ec,drvdata-icm42607"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,icm42607-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,icm42607-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/program/corsola/ite_program.conf b/zephyr/program/corsola/ite_program.conf new file mode 100644 index 0000000000..2a8b46bb28 --- /dev/null +++ b/zephyr/program/corsola/ite_program.conf @@ -0,0 +1,89 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Bring up options +CONFIG_SHELL_HISTORY_BUFFER=256 +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y +CONFIG_PLATFORM_EC_BRINGUP=y + +# Power Sequencing +CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y + +# Lid Switch +CONFIG_PLATFORM_EC_LID_SWITCH=y + +# Charger +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +# BOARD_RS2 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +# BOARD_RS1 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y + +# Host Commands +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y +CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# Sensors +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# Sensor Drivers +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y +CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=y +CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=y + +# Tasks +CONFIG_TASK_CHARGER_STACK_SIZE=1024 +CONFIG_TASK_CHIPSET_STACK_SIZE=1440 +CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024 +CONFIG_TASK_PD_STACK_SIZE=1280 + +# USB-C +CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n +CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y +CONFIG_PLATFORM_EC_USB_MUX_IT5205=y +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y +CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n +CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0 +CONFIG_PLATFORM_EC_USB_PD_PULLUP=1 + +CONFIG_PLATFORM_EC_SHA256_UNROLLED=y + +# TODO(b/180980668): bring these features up +CONFIG_LTO=n +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n diff --git a/zephyr/program/corsola/ite_usbc.dtsi b/zephyr/program/corsola/ite_usbc.dtsi new file mode 100644 index 0000000000..a72864da35 --- /dev/null +++ b/zephyr/program/corsola/ite_usbc.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_ppc_port0>; + ppc = <&bc12_ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; diff --git a/zephyr/program/corsola/keyboard_krabby.dts b/zephyr/program/corsola/keyboard_krabby.dts deleted file mode 100644 index b1a9af6330..0000000000 --- a/zephyr/program/corsola/keyboard_krabby.dts +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - scan-period = <10000>; - - actual-key-mask = < - 0x1c /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; -}; diff --git a/zephyr/program/corsola/keyboard_steelix.dts b/zephyr/program/corsola/keyboard_steelix.dts deleted file mode 100644 index 9a0dca3e05..0000000000 --- a/zephyr/program/corsola/keyboard_steelix.dts +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-keyscan"; - - debounce-down = <15000>; - debounce-up = <15000>; - - actual-key-mask = < - 0x1c /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; -}; diff --git a/zephyr/program/corsola/keyboard_steelix.dtsi b/zephyr/program/corsola/keyboard_steelix.dtsi new file mode 100644 index 0000000000..9a0dca3e05 --- /dev/null +++ b/zephyr/program/corsola/keyboard_steelix.dtsi @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + debounce-down = <15000>; + debounce-up = <15000>; + + actual-key-mask = < + 0x1c /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; diff --git a/zephyr/program/corsola/kingler/project.conf b/zephyr/program/corsola/kingler/project.conf new file mode 100644 index 0000000000..d7de991e93 --- /dev/null +++ b/zephyr/program/corsola/kingler/project.conf @@ -0,0 +1,12 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_KINGLER=y + +# LED +CONFIG_PLATFORM_EC_LED_PWM=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/program/corsola/kingler/project.overlay b/zephyr/program/corsola/kingler/project.overlay new file mode 100644 index 0000000000..baa3185616 --- /dev/null +++ b/zephyr/program/corsola/kingler/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola program common DTS includes */ + +#include "../common.dtsi" +#include "../power_signal.dtsi" +#include "../usba.dtsi" +#include "../npcx_adc.dtsi" +#include "../battery_kingler.dtsi" +#include "../npcx_host_interface.dtsi" +#include "../npcx_i2c.dtsi" +#include "../npcx_interrupts.dtsi" +#include "../npcx_gpio.dtsi" +#include "../npcx_keyboard.dtsi" +#include "../led_kingler.dtsi" +#include "../npcx_motionsense.dtsi" +#include "../npcx_usbc.dtsi" +#include "../npcx_default_gpio_pinctrl.dtsi" diff --git a/zephyr/program/corsola/krabby/project.conf b/zephyr/program/corsola/krabby/project.conf new file mode 100644 index 0000000000..c4cde05c16 --- /dev/null +++ b/zephyr/program/corsola/krabby/project.conf @@ -0,0 +1,9 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_KRABBY=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/program/corsola/krabby/project.overlay b/zephyr/program/corsola/krabby/project.overlay new file mode 100644 index 0000000000..6aafaf4379 --- /dev/null +++ b/zephyr/program/corsola/krabby/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola program common DTS includes */ + +#include "../common.dtsi" +#include "../power_signal.dtsi" +#include "../usba.dtsi" +#include "../ite_adc.dtsi" +#include "../battery_krabby.dtsi" +#include "../ite_gpio.dtsi" +#include "../ite_keyboard.dtsi" +#include "../i2c_krabby.dtsi" +#include "../ite_interrupts.dtsi" +#include "../led_krabby.dtsi" +#include "../ite_motionsense.dtsi" +#include "../ite_usbc.dtsi" diff --git a/zephyr/program/corsola/led_kingler.dts b/zephyr/program/corsola/led_kingler.dts deleted file mode 100644 index 92f6c4d4fe..0000000000 --- a/zephyr/program/corsola/led_kingler.dts +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED - &pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED - &pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0>; - - color-map-red = <100 0 0>; - color-map-green = < 0 100 0>; - color-map-amber = <100 20 0>; - - brightness-range = <255 255 0 0 0 255>; - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_BATTERY_LED"; - }; - }; -}; - -/* Red LED */ -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -/* Green LED */ -&pwm1_gpc2 { - drive-open-drain; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -/* Blue LED */ -&pwm2_gpc4 { - drive-open-drain; -}; - -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/corsola/led_kingler.dtsi b/zephyr/program/corsola/led_kingler.dtsi new file mode 100644 index 0000000000..92f6c4d4fe --- /dev/null +++ b/zephyr/program/corsola/led_kingler.dtsi @@ -0,0 +1,71 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED + &pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED + &pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0>; + + color-map-red = <100 0 0>; + color-map-green = < 0 100 0>; + color-map-amber = <100 20 0>; + + brightness-range = <255 255 0 0 0 255>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + }; +}; + +/* Red LED */ +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* Green LED */ +&pwm1_gpc2 { + drive-open-drain; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* Blue LED */ +&pwm2_gpc4 { + drive-open-drain; +}; + +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/led_krabby.dts b/zephyr/program/corsola/led_krabby.dts deleted file mode 100644 index b16bff3cac..0000000000 --- a/zephyr/program/corsola/led_krabby.dts +++ /dev/null @@ -1,5 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "led_it81202_base.dtsi" diff --git a/zephyr/program/corsola/led_krabby.dtsi b/zephyr/program/corsola/led_krabby.dtsi new file mode 100644 index 0000000000..b16bff3cac --- /dev/null +++ b/zephyr/program/corsola/led_krabby.dtsi @@ -0,0 +1,5 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "led_it81202_base.dtsi" diff --git a/zephyr/program/corsola/led_magikarp.dts b/zephyr/program/corsola/led_magikarp.dts deleted file mode 100644 index 0e2b0aca52..0000000000 --- a/zephyr/program/corsola/led_magikarp.dts +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "led_it81202_base.dtsi" - -/ { - led_colors: led-colors { - compatible = "cros-ec,led-policy"; - - /* Magikarp LED bat charge */ - bat-power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = ; - color-0 { - led-color = <&color_battery_amber>; - }; - }; - - bat-power-state-charge-near-full { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) - BATTERY_LEVEL_FULL>; - color-0 { - led-color = <&color_battery_white>; - }; - }; - - /* Magikarp LED bat discharge */ - bat-power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= 11%, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_battery_white>; - }; - }; - - - bat-power-state-discharge-s0-bat-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= 10%) */ - batt-lvl = ; - - color-0 { - led-color = <&color_battery_amber>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - color-0 { - led-color = <&color_battery_off>; - }; - }; - - /* Magikarp LED bat error */ - bat-power-state-error { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_battery_amber>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <1000>; - }; - }; - - bat-power-state-error-s3 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-error-s5 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_battery_off>; - }; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - /* Overwrite Power LED white to off */ - color_power_white: color-power-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 0>; - }; - }; -}; diff --git a/zephyr/program/corsola/led_magikarp.dtsi b/zephyr/program/corsola/led_magikarp.dtsi new file mode 100644 index 0000000000..0e2b0aca52 --- /dev/null +++ b/zephyr/program/corsola/led_magikarp.dtsi @@ -0,0 +1,136 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "led_it81202_base.dtsi" + +/ { + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + /* Magikarp LED bat charge */ + bat-power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = ; + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + bat-power-state-charge-near-full { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) + BATTERY_LEVEL_FULL>; + color-0 { + led-color = <&color_battery_white>; + }; + }; + + /* Magikarp LED bat discharge */ + bat-power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + + bat-power-state-discharge-s0-bat-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= 10%) */ + batt-lvl = ; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + color-0 { + led-color = <&color_battery_off>; + }; + }; + + /* Magikarp LED bat error */ + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <1000>; + }; + }; + + bat-power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + /* Overwrite Power LED white to off */ + color_power_white: color-power-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 0>; + }; + }; +}; diff --git a/zephyr/program/corsola/led_steelix.dts b/zephyr/program/corsola/led_steelix.dts deleted file mode 100644 index 6a25929327..0000000000 --- a/zephyr/program/corsola/led_steelix.dts +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - led_battery_red: ec_led1_odl { - pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - led_battery_green: ec_led2_odl { - pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - led_power_white: ec_led3_odl { - pwms = <&pwm4 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; -}; - -/* Red LED */ -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -/* Green LED */ -&pwm1_gpc2 { - drive-open-drain; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -/* White LED */ -&pwm4_gpb6 { - drive-open-drain; -}; - -&pwm4 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm4_gpb6>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/corsola/led_steelix.dtsi b/zephyr/program/corsola/led_steelix.dtsi new file mode 100644 index 0000000000..6a25929327 --- /dev/null +++ b/zephyr/program/corsola/led_steelix.dtsi @@ -0,0 +1,55 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + led_battery_red: ec_led1_odl { + pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + led_battery_green: ec_led2_odl { + pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + led_power_white: ec_led3_odl { + pwms = <&pwm4 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; +}; + +/* Red LED */ +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* Green LED */ +&pwm1_gpc2 { + drive-open-drain; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* White LED */ +&pwm4_gpb6 { + drive-open-drain; +}; + +&pwm4 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm4_gpb6>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/led_tentacruel.dts b/zephyr/program/corsola/led_tentacruel.dts deleted file mode 100644 index 5569a956f6..0000000000 --- a/zephyr/program/corsola/led_tentacruel.dts +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "led_it81202_base.dtsi" - -/ { - led_colors: led-colors { - compatible = "cros-ec,led-policy"; - - /* Tentacruel LED bat charge */ - bat-power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = ; - color-0 { - led-color = <&color_battery_amber>; - }; - }; - - bat-power-state-charge-near-full { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) - BATTERY_LEVEL_FULL>; - color-0 { - led-color = <&color_battery_white>; - }; - }; - - /* Tentacruel LED bat discharge */ - bat-power-state-discharge { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= 11%, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_battery_white>; - }; - }; - - bat-power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - color-0 { - led-color = <&color_battery_off>; - }; - }; - - /* Tentacruel LED bat error */ - bat-power-state-error { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S0"; - - color-0 { - led-color = <&color_battery_amber>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <1000>; - }; - }; - - bat-power-state-error-s3 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S3"; - - color-0 { - led-color = <&color_battery_white>; - period-ms = <1000>; - }; - - color-1 { - led-color = <&color_battery_off>; - period-ms = <3000>; - }; - }; - - bat-power-state-error-s5 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_battery_off>; - }; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - /* Overwrite Power LED white to off */ - color_power_white: color-power-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 0>; - }; - }; -}; diff --git a/zephyr/program/corsola/led_tentacruel.dtsi b/zephyr/program/corsola/led_tentacruel.dtsi new file mode 100644 index 0000000000..5569a956f6 --- /dev/null +++ b/zephyr/program/corsola/led_tentacruel.dtsi @@ -0,0 +1,118 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "led_it81202_base.dtsi" + +/ { + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + /* Tentacruel LED bat charge */ + bat-power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = ; + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + bat-power-state-charge-near-full { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) + BATTERY_LEVEL_FULL>; + color-0 { + led-color = <&color_battery_white>; + }; + }; + + /* Tentacruel LED bat discharge */ + bat-power-state-discharge { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + bat-power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + color-0 { + led-color = <&color_battery_off>; + }; + }; + + /* Tentacruel LED bat error */ + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <1000>; + }; + }; + + bat-power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + /* Overwrite Power LED white to off */ + color_power_white: color-power-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 0>; + }; + }; +}; diff --git a/zephyr/program/corsola/magikarp/project.conf b/zephyr/program/corsola/magikarp/project.conf new file mode 100644 index 0000000000..a5ec9ede3b --- /dev/null +++ b/zephyr/program/corsola/magikarp/project.conf @@ -0,0 +1,27 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_MAGIKARP=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y + +# Sensor +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y diff --git a/zephyr/program/corsola/magikarp/project.overlay b/zephyr/program/corsola/magikarp/project.overlay new file mode 100644 index 0000000000..f4ca85e375 --- /dev/null +++ b/zephyr/program/corsola/magikarp/project.overlay @@ -0,0 +1,20 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola program common DTS includes */ + +#include "../common.dtsi" +#include "../power_signal.dtsi" +#include "../usba.dtsi" +#include "../adc_magikarp.dtsi" +#include "../battery_magikarp.dtsi" +#include "../cbi_magikarp.dtsi" +#include "../gpio_magikarp.dtsi" +#include "../ite_keyboard.dtsi" +#include "../i2c_magikarp.dtsi" +#include "../interrupts_magikarp.dtsi" +#include "../led_magikarp.dtsi" +#include "../motionsense_magikarp.dtsi" +#include "../usbc_magikarp.dtsi" diff --git a/zephyr/program/corsola/motionsense_kingler.dts b/zephyr/program/corsola/motionsense_kingler.dts deleted file mode 100644 index a7f674e01f..0000000000 --- a/zephyr/program/corsola/motionsense_kingler.dts +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * Kingler and Steelix use the same dts, take care of this when modify it. - */ - -#include - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - base_mutex: base-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - (-1) 0 0 - 0 0 (-1)>; - }; - base_rot_ref: base-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&bma4xx_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <0>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_base_imu>; - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/corsola/motionsense_krabby.dts b/zephyr/program/corsola/motionsense_krabby.dts deleted file mode 100644 index 1c7d5b2df4..0000000000 --- a/zephyr/program/corsola/motionsense_krabby.dts +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - icm42607-int = &base_accel; - lis2dw12-int = &lid_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: icm42607-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - icm42607_data: icm42607-drv-data { - compatible = "cros-ec,drvdata-icm42607"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,icm42607-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,icm42607-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_base_imu &int_lid_imu>; - }; -}; diff --git a/zephyr/program/corsola/motionsense_magikarp.dts b/zephyr/program/corsola/motionsense_magikarp.dts deleted file mode 100644 index 92e73bd2c6..0000000000 --- a/zephyr/program/corsola/motionsense_magikarp.dts +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - icm42607-int = &base_accel; - lis2dw12-int = &lid_accel; - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: icm42607-mutex { - }; - - base_mutex_bmi323: bmi323-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 (-1)>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref_bmi: base-rotation-ref-bmi { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - icm42607_data: icm42607-drv-data { - compatible = "cros-ec,drvdata-icm42607"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - - bmi323_data: bmi323-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,icm42607-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,icm42607-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - }; - }; - - motionsense-sensor-alt { - alt_base_accel: alt-base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_bmi>; - drv-data = <&bmi323_data>; - alternate-for = <&base_accel>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_bmi>; - drv-data = <&bmi323_data>; - alternate-for = <&base_gyro>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_base_imu &int_lid_imu>; - }; -}; diff --git a/zephyr/program/corsola/motionsense_magikarp.dtsi b/zephyr/program/corsola/motionsense_magikarp.dtsi new file mode 100644 index 0000000000..92e73bd2c6 --- /dev/null +++ b/zephyr/program/corsola/motionsense_magikarp.dtsi @@ -0,0 +1,199 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + icm42607-int = &base_accel; + lis2dw12-int = &lid_accel; + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: icm42607-mutex { + }; + + base_mutex_bmi323: bmi323-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref_bmi: base-rotation-ref-bmi { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + icm42607_data: icm42607-drv-data { + compatible = "cros-ec,drvdata-icm42607"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,icm42607-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,icm42607-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + }; + }; + + motionsense-sensor-alt { + alt_base_accel: alt-base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_gyro>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/program/corsola/motionsense_steelix.dts b/zephyr/program/corsola/motionsense_steelix.dts deleted file mode 100644 index df96fc2e42..0000000000 --- a/zephyr/program/corsola/motionsense_steelix.dts +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/* inherit the rot_ref from Kingler and overwrite it */ -&lid_rot_ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; -}; - -&base_rot_ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; -}; - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - lsm6dsm-int = &base_accel; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - base_rot_ref_lsm6dsm: base-rotation-ref-lsm6dsm { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - lsm6dsm_data_accel: lsm6dsm-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dsm"; - status = "okay"; - }; - lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dsm"; - status = "okay"; - }; - }; - - motionsense-sensor-alt { - alt_lid_accel: alt-lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; - alternate-for = <&lid_accel>; - alternate-ssfc-indicator = <&lid_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_accel: alt-base-accel { - compatible = "cros-ec,lsm6dsm-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_lsm6dsm>; - drv-data = <&lsm6dsm_data_accel>; - alternate-for = <&base_accel>; - alternate-ssfc-indicator = <&base_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <0>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,lsm6dsm-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_lsm6dsm>; - default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ - drv-data = <&lsm6dsm_data_gyro>; - alternate-for = <&base_gyro>; - alternate-ssfc-indicator = <&base_sensor_1>; - }; - }; -}; diff --git a/zephyr/program/corsola/motionsense_steelix.dtsi b/zephyr/program/corsola/motionsense_steelix.dtsi new file mode 100644 index 0000000000..df96fc2e42 --- /dev/null +++ b/zephyr/program/corsola/motionsense_steelix.dtsi @@ -0,0 +1,133 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/* inherit the rot_ref from Kingler and overwrite it */ +&lid_rot_ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; +}; + +&base_rot_ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; +}; + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + lsm6dsm-int = &base_accel; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + base_rot_ref_lsm6dsm: base-rotation-ref-lsm6dsm { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + lsm6dsm_data_accel: lsm6dsm-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dsm"; + status = "okay"; + }; + lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dsm"; + status = "okay"; + }; + }; + + motionsense-sensor-alt { + alt_lid_accel: alt-lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + alternate-for = <&lid_accel>; + alternate-ssfc-indicator = <&lid_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_accel: alt-base-accel { + compatible = "cros-ec,lsm6dsm-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_lsm6dsm>; + drv-data = <&lsm6dsm_data_accel>; + alternate-for = <&base_accel>; + alternate-ssfc-indicator = <&base_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <0>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,lsm6dsm-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_lsm6dsm>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dsm_data_gyro>; + alternate-for = <&base_gyro>; + alternate-ssfc-indicator = <&base_sensor_1>; + }; + }; +}; diff --git a/zephyr/program/corsola/motionsense_tentacruel.dts b/zephyr/program/corsola/motionsense_tentacruel.dts deleted file mode 100644 index 68b2c023df..0000000000 --- a/zephyr/program/corsola/motionsense_tentacruel.dts +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright 2020 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - icm42607-int = &base_accel; - lis2dw12-int = &lid_accel; - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - base_mutex: icm42607-mutex { - }; - - base_mutex_bmi323: bmi323-mutex { - }; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref_bmi: base-rotation-ref-bmi { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - icm42607_data: icm42607-drv-data { - compatible = "cros-ec,drvdata-icm42607"; - status = "okay"; - }; - - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - - bmi323_data: bmi323-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,icm42607-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_gyro: base-gyro { - compatible = "cros-ec,icm42607-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&icm42607_data>; - }; - }; - - motionsense-sensor-alt { - alt_base_accel: alt-base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_bmi>; - drv-data = <&bmi323_data>; - alternate-for = <&base_accel>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(10000 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex_bmi323>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_bmi>; - drv-data = <&bmi323_data>; - alternate-for = <&base_gyro>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_base_imu &int_lid_imu>; - }; -}; diff --git a/zephyr/program/corsola/motionsense_tentacruel.dtsi b/zephyr/program/corsola/motionsense_tentacruel.dtsi new file mode 100644 index 0000000000..68b2c023df --- /dev/null +++ b/zephyr/program/corsola/motionsense_tentacruel.dtsi @@ -0,0 +1,199 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + icm42607-int = &base_accel; + lis2dw12-int = &lid_accel; + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: icm42607-mutex { + }; + + base_mutex_bmi323: bmi323-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref_bmi: base-rotation-ref-bmi { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + icm42607_data: icm42607-drv-data { + compatible = "cros-ec,drvdata-icm42607"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,icm42607-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,icm42607-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + }; + }; + + motionsense-sensor-alt { + alt_base_accel: alt-base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_gyro>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/program/corsola/npcx_adc.dtsi b/zephyr/program/corsola/npcx_adc.dtsi new file mode 100644 index 0000000000..7b69abe48a --- /dev/null +++ b/zephyr/program/corsola/npcx_adc.dtsi @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * Kingler and Steelix use the same dts, take care of this when modify it. + */ + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_charger_pmon_r { + enum-name = "ADC_PSYS"; + io-channels = <&adc0 0>; + /* + * ISL9238C PSYS output is 1.44 uA/W over 33K resistor. + */ + mul = <21043>; + }; + adc_ec_id0 { + enum-name = "ADC_ID_0"; + io-channels = <&adc0 1>; + }; + adc_ec_id1 { + enum-name = "ADC_ID_1"; + io-channels = <&adc0 2>; + }; + adc_charger_amon_r { + enum-name = "ADC_AMON_BMON"; + io-channels = <&adc0 3>; + mul = <1000>; + div = <18>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/npcx_default_gpio_pinctrl.dtsi b/zephyr/program/corsola/npcx_default_gpio_pinctrl.dtsi new file mode 100644 index 0000000000..604658a145 --- /dev/null +++ b/zephyr/program/corsola/npcx_default_gpio_pinctrl.dtsi @@ -0,0 +1,44 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ +&{/def-io-conf-list} { + pinmux = <&alt0_gpio_no_spip + &alt0_gpio_no_fpip + &alt1_no_pwrgd + &alt1_no_lpc_espi + &alta_no_peci_en + &altd_npsl_in1_sl + &altd_npsl_in2_sl + &altd_psl_in3_sl + &altd_psl_in4_sl + &alt7_no_ksi0_sl + &alt7_no_ksi1_sl + &alt7_no_ksi2_sl + &alt7_no_ksi3_sl + &alt7_no_ksi4_sl + &alt7_no_ksi5_sl + &alt7_no_ksi6_sl + &alt7_no_ksi7_sl + &alt8_no_kso00_sl + &alt8_no_kso01_sl + &alt8_no_kso02_sl + &alt8_no_kso03_sl + &alt8_no_kso04_sl + &alt8_no_kso05_sl + &alt8_no_kso06_sl + &alt8_no_kso07_sl + &alt9_no_kso08_sl + &alt9_no_kso09_sl + &alt9_no_kso10_sl + &alt9_no_kso11_sl + &alt9_no_kso12_sl + &alt9_no_kso13_sl + &alt9_no_kso14_sl + &alt9_no_kso15_sl + &alta_no_kso16_sl + &alta_no_kso17_sl + &altg_psl_gpo_sl>; +}; diff --git a/zephyr/program/corsola/npcx_gpio.dtsi b/zephyr/program/corsola/npcx_gpio.dtsi new file mode 100644 index 0000000000..9a827a06dd --- /dev/null +++ b/zephyr/program/corsola/npcx_gpio.dtsi @@ -0,0 +1,249 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + named-gpios { + compatible = "named-gpios"; + + /* + * In npcx9 series, gpio46, gpio47, and the whole gpio5 port + * belong to VHIF power well. On kingler, it is connencted to + * 1.8V. + */ + base_imu_int_l: base_imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + spi_ap_clk_ec { + gpios = <&gpio5 5 GPIO_INPUT>; + }; + spi_ap_cs_ec_l { + gpios = <&gpio5 3 GPIO_INPUT>; + }; + spi_ap_do_ec_di { + gpios = <&gpio4 6 GPIO_INPUT>; + }; + spi_ap_di_ec_do { + gpios = <&gpio4 7 GPIO_INPUT>; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; + }; + en_ec_id_odl { + gpios = <&gpio7 6 GPIO_ODR_HIGH>; + }; + sys_rst_odl { + gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + ec_i2c_sensor_scl { + gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_sensor_sda { + gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_usb_c0_scl { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + ec_i2c_usb_c0_sda { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + ec_i2c_usb_c1_scl { + gpios = <&gpio9 2 GPIO_INPUT>; + }; + ec_i2c_usb_c1_sda { + gpios = <&gpio9 1 GPIO_INPUT>; + }; + ec_i2c_pwr_cbi_scl { + gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_pwr_cbi_sda { + gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_batt_scl { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + ec_i2c_batt_sda { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + ec_pen_chg_dis_odl { + gpios = <&gpioe 4 GPIO_INPUT>; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; + }; + gpio_ec_wp_l: ec_wp_odl { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | + GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpiob 2 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ec_ap_int_odl { + gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpio8 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; + }; + charger_prochot_odl { + gpios = <&gpiob 1 GPIO_INPUT>; + }; + ec_rst_odl { + gpios = <&gpio7 7 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 1 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; + }; + packet_mode_en { + gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiod 4 GPIO_INPUT>; + }; + /* + * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 + * belong to VSPI power rail. On kingler, it is connencted to + * 1.8V. + */ + ap_sysrst_odl_r: ap_sysrst_odl_r { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio6 7 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + pg_pp5000_z2_od { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + gpios = <&gpio7 3 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; + }; + gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { + gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpio3 7 GPIO_INPUT>; + }; + en_pp5000_z2 { + gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpioe 1 GPIO_INPUT>; + }; + ec_batt_pres_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + usb_a0_fault_odl { + gpios = <&gpioc 7 GPIO_INPUT>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpio6 1 GPIO_ODR_HIGH>; + }; + ec_pmic_en_odl { + gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + }; + + /* + * aliases for sub-board GPIOs + */ + aliases { + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_ac_present + &int_power_button + &int_lid_open + >; + }; +}; diff --git a/zephyr/program/corsola/npcx_host_interface.dtsi b/zephyr/program/corsola/npcx_host_interface.dtsi new file mode 100644 index 0000000000..14efa3c6b2 --- /dev/null +++ b/zephyr/program/corsola/npcx_host_interface.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* host interface */ +&shi { + status = "okay"; + pinctrl-0 = <&shi_gp46_47_53_55>; + pinctrl-1 = <&shi_gpio_gp46_47_53_55>; + pinctrl-names = "default", "sleep"; +}; diff --git a/zephyr/program/corsola/npcx_i2c.dtsi b/zephyr/program/corsola/npcx_i2c.dtsi new file mode 100644 index 0000000000..90390ab8a0 --- /dev/null +++ b/zephyr/program/corsola/npcx_i2c.dtsi @@ -0,0 +1,169 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/* + * Kingler and Steelix use the same dts, take care of this when modify it. + */ + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_sensor: sensor { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_usb_c0: usb-c0 { + i2c-port = <&i2c1_0>; + remote-port = <7>; + enum-names = "I2C_PORT_USB_C0"; + }; + i2c_usb_c1: usb-c1 { + i2c-port = <&i2c2_0>; + enum-names = "I2C_PORT_USB_C1", + "I2C_PORT_USB_C1_TCPC", + "I2C_PORT_USB_C1_PPC"; + }; + i2c_charger: charger { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_POWER", + "I2C_PORT_EEPROM"; + }; + battery { + i2c-port = <&i2c5_0>; + remote-port = <1>; + enum-names = "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY"; + }; + }; +}; + +&i2c0_0 { + label = "I2C_SENSOR"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + label = "I2C_USB_C0"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + tcpc_port0: anx7447-tcpc@2c { + compatible = "analogix,anx7447-tcpc"; + status = "okay"; + reg = <0x2c>; + tcpc-flags = <( + TCPC_FLAGS_VBUS_MONITOR | + TCPC_FLAGS_ALERT_OD | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS)>; + }; + + ppc_port0: nx20p348x@72 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x72>; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + label = "I2C_USB_C1"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; + + bc12_port1: rt1718s-bc12@40 { + compatible = "richtek,rt1718s-bc12"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port1: rt1718s-tcpc@40 { + compatible = "richtek,rt1718s-tcpc"; + reg = <0x40>; + tcpc-flags = <( + TCPC_FLAGS_ALERT_OD | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS)>; + }; + + ppc_port1: nx20p348x@72 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x72>; + }; + + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + board-init = "ps8743_mux_1_board_init"; + }; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + label = "I2C_PWR_CBI"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; + + charger: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c5_0 { + label = "I2C_BATTERY"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; +}; + +&i2c_ctrl5 { + status = "okay"; +}; diff --git a/zephyr/program/corsola/npcx_interrupts.dtsi b/zephyr/program/corsola/npcx_interrupts.dtsi new file mode 100644 index 0000000000..f3da785a60 --- /dev/null +++ b/zephyr/program/corsola/npcx_interrupts.dtsi @@ -0,0 +1,114 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * Kingler and Steelix use the same dts, take care of this when modify it. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_ec_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_ec_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = ; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = ; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = ; + handler = "chipset_watchdog_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&gpio_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = ; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&gpio_ec_wp_l>; + flags = ; + handler = "switch_interrupt"; + }; + int_usb_c0_tcpc: usb_c0_tcpc { + irq-pin = <&gpio_usb_c0_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-pin = <&gpio_usb_c1_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&gpio_usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = ; + handler = "x_ec_interrupt"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "bmi3xx_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_ccd_mode_odl: ccd-mode-odl { + irq-pin = <&gpio_ccd_mode_odl>; + flags = ; + handler = "ccd_interrupt"; + }; + }; +}; diff --git a/zephyr/program/corsola/npcx_keyboard.dts b/zephyr/program/corsola/npcx_keyboard.dts deleted file mode 100644 index f9e46de1f2..0000000000 --- a/zephyr/program/corsola/npcx_keyboard.dts +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/corsola/npcx_keyboard.dtsi b/zephyr/program/corsola/npcx_keyboard.dtsi new file mode 100644 index 0000000000..f9e46de1f2 --- /dev/null +++ b/zephyr/program/corsola/npcx_keyboard.dtsi @@ -0,0 +1,32 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/npcx_motionsense.dtsi b/zephyr/program/corsola/npcx_motionsense.dtsi new file mode 100644 index 0000000000..a7f674e01f --- /dev/null +++ b/zephyr/program/corsola/npcx_motionsense.dtsi @@ -0,0 +1,150 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* + * Kingler and Steelix use the same dts, take care of this when modify it. + */ + +#include + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + (-1) 0 0 + 0 0 (-1)>; + }; + base_rot_ref: base-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma4xx_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <0>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/corsola/npcx_program.conf b/zephyr/program/corsola/npcx_program.conf new file mode 100644 index 0000000000..e144e345ed --- /dev/null +++ b/zephyr/program/corsola/npcx_program.conf @@ -0,0 +1,88 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +# Bring up options +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# Debug options and features; can be disabled to save memory or once bringup +# is complete. +CONFIG_SHELL_MINIMAL=n +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y + +# Charger +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=y +CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y + +# Math +CONFIG_PLATFORM_EC_MATH_UTIL=y + +# Power sequencing +CONFIG_PLATFORM_EC_POWERSEQ_MT8186=y +CONFIG_PLATFORM_EC_POWERSEQ_S4=n + +# Button +CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y + +# Sensors +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y + +# USBC +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n +CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY=15000 +CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY=15000 +CONFIG_PLATFORM_EC_USBC_PPC=y +CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y +CONFIG_PLATFORM_EC_USBC_PPC_RT1718S=y +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2 +CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447_AUX_PU_PD=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y + +# External power +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n + +# Keyboard +CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y + +CONFIG_SYSCON=y + +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n diff --git a/zephyr/program/corsola/npcx_usbc.dtsi b/zephyr/program/corsola/npcx_usbc.dtsi new file mode 100644 index 0000000000..18bc6ce303 --- /dev/null +++ b/zephyr/program/corsola/npcx_usbc.dtsi @@ -0,0 +1,56 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + tcpc = <&tcpc_port0>; + ppc = <&ppc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&anx7447_mux_0 &virtual_mux_0>; + }; + }; + + port0-muxes { + anx7447_mux_0: anx7447-mux-0 { + compatible = "analogix,usbc-mux-anx7447"; + }; + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + tcpc = <&tcpc_port1>; + ppc = <&ppc_port1>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/power_signal.dts b/zephyr/program/corsola/power_signal.dts deleted file mode 100644 index 5037bac228..0000000000 --- a/zephyr/program/corsola/power_signal.dts +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - power_signal_list: power-signal-list { - compatible = "mediatek,mt8186-power-signal-list"; - ap_in_rst { - power-enum-name = "AP_IN_RST"; - power-gpio-pin = <&ap_sysrst_odl_r>; - }; - ap_in_s3 { - power-enum-name = "AP_IN_S3"; - power-gpio-pin = <&ap_in_sleep_l>; - }; - ap_wdt_asserted { - power-enum-name = "AP_WDT_ASSERTED"; - power-gpio-pin = <&ap_ec_wdtrst_l>; - }; - ap_warm_rst_req { - power-enum-name = "AP_WARM_RST_REQ"; - power-gpio-pin = <&ap_ec_warm_rst_req>; - }; - }; -}; diff --git a/zephyr/program/corsola/power_signal.dtsi b/zephyr/program/corsola/power_signal.dtsi new file mode 100644 index 0000000000..5037bac228 --- /dev/null +++ b/zephyr/program/corsola/power_signal.dtsi @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + power_signal_list: power-signal-list { + compatible = "mediatek,mt8186-power-signal-list"; + ap_in_rst { + power-enum-name = "AP_IN_RST"; + power-gpio-pin = <&ap_sysrst_odl_r>; + }; + ap_in_s3 { + power-enum-name = "AP_IN_S3"; + power-gpio-pin = <&ap_in_sleep_l>; + }; + ap_wdt_asserted { + power-enum-name = "AP_WDT_ASSERTED"; + power-gpio-pin = <&ap_ec_wdtrst_l>; + }; + ap_warm_rst_req { + power-enum-name = "AP_WARM_RST_REQ"; + power-gpio-pin = <&ap_ec_warm_rst_req>; + }; + }; +}; diff --git a/zephyr/program/corsola/prj.conf b/zephyr/program/corsola/prj.conf deleted file mode 100644 index cb4ed7a3ef..0000000000 --- a/zephyr/program/corsola/prj.conf +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# - -# http://google3/hardware/standards/usb/ -CONFIG_PLATFORM_EC_USB_PID=0x505C - -# CROS EC -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_SHIMMED_TASKS=y - -# AP SoC configuration -CONFIG_AP=y -CONFIG_AP_ARM_MTK_MT8186=y - -# Variant config -CONFIG_VARIANT_CORSOLA_DB_DETECTION=y - -# Shell features -CONFIG_KERNEL_SHELL=y -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y - -# CBI -CONFIG_EEPROM=y -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y -CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y - -# MKBP -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - -# EFS2 -CONFIG_PLATFORM_EC_VBOOT_EFS2=y - -# USB -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK=y - -# USB-C -CONFIG_PLATFORM_EC_USBC=y -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_PD_DPS=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_USB_PD_CLEAR_HARD_RESET_STATUS=y - -# Power Seq -CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y - -# Optional features -CONFIG_FLASH_SHELL=n - -# EEPROM -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y - -# Host Commands -CONFIG_PLATFORM_EC_HOSTCMD=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=9000 -CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y -CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y - -# Charger -CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y -CONFIG_PLATFORM_EC_CHARGE_MANAGER=y - -# Button -CONFIG_PLATFORM_EC_CMD_BUTTON=y -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y diff --git a/zephyr/program/corsola/prj_it81202_base.conf b/zephyr/program/corsola/prj_it81202_base.conf deleted file mode 100644 index 2a8b46bb28..0000000000 --- a/zephyr/program/corsola/prj_it81202_base.conf +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Bring up options -CONFIG_SHELL_HISTORY_BUFFER=256 -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y -CONFIG_PLATFORM_EC_BRINGUP=y - -# Power Sequencing -CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y - -# Lid Switch -CONFIG_PLATFORM_EC_LID_SWITCH=y - -# Charger -CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -# BOARD_RS2 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -# BOARD_RS1 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y - -# Host Commands -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y -CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# Sensors -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 - -# Sensor Drivers -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y -CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=y -CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=y - -# Tasks -CONFIG_TASK_CHARGER_STACK_SIZE=1024 -CONFIG_TASK_CHIPSET_STACK_SIZE=1440 -CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024 -CONFIG_TASK_PD_STACK_SIZE=1280 - -# USB-C -CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n -CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y -CONFIG_PLATFORM_EC_USB_MUX_IT5205=y -CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y -CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n -CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0 -CONFIG_PLATFORM_EC_USB_PD_PULLUP=1 - -CONFIG_PLATFORM_EC_SHA256_UNROLLED=y - -# TODO(b/180980668): bring these features up -CONFIG_LTO=n -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n diff --git a/zephyr/program/corsola/prj_kingler.conf b/zephyr/program/corsola/prj_kingler.conf deleted file mode 100644 index d7de991e93..0000000000 --- a/zephyr/program/corsola/prj_kingler.conf +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_KINGLER=y - -# LED -CONFIG_PLATFORM_EC_LED_PWM=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/program/corsola/prj_krabby.conf b/zephyr/program/corsola/prj_krabby.conf deleted file mode 100644 index c4cde05c16..0000000000 --- a/zephyr/program/corsola/prj_krabby.conf +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_KRABBY=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/program/corsola/prj_magikarp.conf b/zephyr/program/corsola/prj_magikarp.conf deleted file mode 100644 index a5ec9ede3b..0000000000 --- a/zephyr/program/corsola/prj_magikarp.conf +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_MAGIKARP=y - -# USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n -CONFIG_PLATFORM_EC_USB_MUX_PS8743=y -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y - -# Sensor -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y diff --git a/zephyr/program/corsola/prj_npcx993_base.conf b/zephyr/program/corsola/prj_npcx993_base.conf deleted file mode 100644 index e144e345ed..0000000000 --- a/zephyr/program/corsola/prj_npcx993_base.conf +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - - -# Bring up options -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# Debug options and features; can be disabled to save memory or once bringup -# is complete. -CONFIG_SHELL_MINIMAL=n -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y - -# Math -CONFIG_PLATFORM_EC_MATH_UTIL=y - -# Power sequencing -CONFIG_PLATFORM_EC_POWERSEQ_MT8186=y -CONFIG_PLATFORM_EC_POWERSEQ_S4=n - -# Button -CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y - -# Sensors -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y - -# USBC -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n -CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY=15000 -CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY=15000 -CONFIG_PLATFORM_EC_USBC_PPC=y -CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y -CONFIG_PLATFORM_EC_USBC_PPC_RT1718S=y -CONFIG_PLATFORM_EC_USB_MUX_PS8743=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2 -CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447_AUX_PU_PD=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y - -# External power -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n - -# Keyboard -CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y - -CONFIG_SYSCON=y - -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n diff --git a/zephyr/program/corsola/prj_steelix.conf b/zephyr/program/corsola/prj_steelix.conf deleted file mode 100644 index bf2de72512..0000000000 --- a/zephyr/program/corsola/prj_steelix.conf +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_STEELIX=y - -# steelix only use D2, drop the workaround config for H1 -CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n - -# Motion sensor -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM=y -CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y - -# USBC -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250 -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 - -# Remove bring up options for FW QUAL -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n - -# Remove debug options and features for FW QUAL -CONFIG_LOG=n -CONFIG_LOG_MODE_MINIMAL=n -CONFIG_SHELL_MINIMAL=y - -# AC_OK debounce time -CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 diff --git a/zephyr/program/corsola/prj_tentacruel.conf b/zephyr/program/corsola/prj_tentacruel.conf deleted file mode 100644 index 71cc9d9694..0000000000 --- a/zephyr/program/corsola/prj_tentacruel.conf +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Variant config -CONFIG_BOARD_TENTACRUEL=y - -# USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n -CONFIG_PLATFORM_EC_USB_MUX_PS8743=y - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y - -# Sensor -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y - -# Battery -CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/program/corsola/program.conf b/zephyr/program/corsola/program.conf new file mode 100644 index 0000000000..cb4ed7a3ef --- /dev/null +++ b/zephyr/program/corsola/program.conf @@ -0,0 +1,94 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# + +# http://google3/hardware/standards/usb/ +CONFIG_PLATFORM_EC_USB_PID=0x505C + +# CROS EC +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_SHIMMED_TASKS=y + +# AP SoC configuration +CONFIG_AP=y +CONFIG_AP_ARM_MTK_MT8186=y + +# Variant config +CONFIG_VARIANT_CORSOLA_DB_DETECTION=y + +# Shell features +CONFIG_KERNEL_SHELL=y +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y + +# CBI +CONFIG_EEPROM=y +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD=y +CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y + +# MKBP +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y + +# EFS2 +CONFIG_PLATFORM_EC_VBOOT_EFS2=y + +# USB +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK=y + +# USB-C +CONFIG_PLATFORM_EC_USBC=y +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_PD_DPS=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_USB_PD_CLEAR_HARD_RESET_STATUS=y + +# Power Seq +CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y + +# Optional features +CONFIG_FLASH_SHELL=n + +# EEPROM +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# Host Commands +CONFIG_PLATFORM_EC_HOSTCMD=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=9000 +CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y +CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y + +# Charger +CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y +CONFIG_PLATFORM_EC_CHARGE_MANAGER=y + +# Button +CONFIG_PLATFORM_EC_CMD_BUTTON=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y diff --git a/zephyr/program/corsola/steelix/project.conf b/zephyr/program/corsola/steelix/project.conf new file mode 100644 index 0000000000..bf2de72512 --- /dev/null +++ b/zephyr/program/corsola/steelix/project.conf @@ -0,0 +1,34 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_STEELIX=y + +# steelix only use D2, drop the workaround config for H1 +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n + +# Motion sensor +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM=y +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y + +# USBC +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250 +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 + +# Remove bring up options for FW QUAL +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n + +# Remove debug options and features for FW QUAL +CONFIG_LOG=n +CONFIG_LOG_MODE_MINIMAL=n +CONFIG_SHELL_MINIMAL=y + +# AC_OK debounce time +CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 diff --git a/zephyr/program/corsola/steelix/project.overlay b/zephyr/program/corsola/steelix/project.overlay new file mode 100644 index 0000000000..3feea490be --- /dev/null +++ b/zephyr/program/corsola/steelix/project.overlay @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola program common DTS includes */ + +#include "../common.dtsi" +#include "../power_signal.dtsi" +#include "../usba.dtsi" +#include "../npcx_adc.dtsi" +#include "../battery_steelix.dtsi" +#include "../npcx_host_interface.dtsi" +#include "../npcx_i2c.dtsi" +#include "../npcx_interrupts.dtsi" +#include "../interrupts_steelix.dtsi" +#include "../cbi_steelix.dtsi" +#include "../gpio_steelix.dtsi" +#include "../npcx_keyboard.dtsi" +#include "../keyboard_steelix.dtsi" +#include "../led_steelix.dtsi" +#include "../npcx_motionsense.dtsi" +#include "../motionsense_steelix.dtsi" +#include "../usba_steelix.dtsi" +#include "../npcx_usbc.dtsi" +#include "../npcx_default_gpio_pinctrl.dtsi" diff --git a/zephyr/program/corsola/tentacruel/project.conf b/zephyr/program/corsola/tentacruel/project.conf new file mode 100644 index 0000000000..71cc9d9694 --- /dev/null +++ b/zephyr/program/corsola/tentacruel/project.conf @@ -0,0 +1,26 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_TENTACRUEL=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y + +# Sensor +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y + +# Battery +CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/program/corsola/tentacruel/project.overlay b/zephyr/program/corsola/tentacruel/project.overlay new file mode 100644 index 0000000000..79bf2baa3d --- /dev/null +++ b/zephyr/program/corsola/tentacruel/project.overlay @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola program common DTS includes */ + +#include "../common.dtsi" +#include "../power_signal.dtsi" +#include "../usba.dtsi" +#include "../adc_tentacruel.dtsi" +#include "../battery_tentacruel.dtsi" +#include "../cbi_tentacruel.dtsi" +#include "../gpio_tentacruel.dtsi" +#include "../ite_keyboard.dtsi" +#include "../i2c_tentacruel.dtsi" +#include "../interrupts_tentacruel.dtsi" +#include "../led_tentacruel.dtsi" +#include "../motionsense_tentacruel.dtsi" +#include "../usbc_tentacruel.dtsi" +#include "../thermistor_tentacruel.dtsi" diff --git a/zephyr/program/corsola/thermistor_tentacruel.dts b/zephyr/program/corsola/thermistor_tentacruel.dts deleted file mode 100644 index f9e5306f24..0000000000 --- a/zephyr/program/corsola/thermistor_tentacruel.dts +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - thermistor_rt9490: thermistor-rt9490 { - status = "okay"; - compatible = "cros-ec,thermistor"; - scaling-factor = <3>; - num-pairs = <21>; - steinhart-reference-mv = <4900>; - steinhart-reference-res = <10000>; - - sample-datum-0 { - milivolt = <(731 / 3)>; - temp = <0>; - sample-index = <0>; - }; - - sample-datum-1 { - milivolt = <(708 / 3)>; - temp = <5>; - sample-index = <1>; - }; - - sample-datum-2 { - milivolt = <(682 / 3)>; - temp = <10>; - sample-index = <2>; - }; - - sample-datum-3 { - milivolt = <(653 / 3)>; - temp = <15>; - sample-index = <3>; - }; - - sample-datum-4 { - milivolt = <(622 / 3)>; - temp = <20>; - sample-index = <4>; - }; - - sample-datum-5 { - milivolt = <(589 / 3)>; - temp = <25>; - sample-index = <5>; - }; - - sample-datum-6 { - milivolt = <(554 / 3)>; - temp = <30>; - sample-index = <6>; - }; - - sample-datum-7 { - milivolt = <(519 / 3)>; - temp = <35>; - sample-index = <7>; - }; - - sample-datum-8 { - milivolt = <(483 / 3)>; - temp = <40>; - sample-index = <8>; - }; - - sample-datum-9 { - milivolt = <(446 / 3)>; - temp = <45>; - sample-index = <9>; - }; - - sample-datum-10 { - milivolt = <(411 / 3)>; - temp = <50>; - sample-index = <10>; - }; - sample-datum-11 { - milivolt = <(376 / 3)>; - temp = <55>; - sample-index = <11>; - }; - - sample-datum-12 { - milivolt = <(343 / 3)>; - temp = <60>; - sample-index = <12>; - }; - - sample-datum-13 { - milivolt = <(312 / 3)>; - temp = <65>; - sample-index = <13>; - }; - - sample-datum-14 { - milivolt = <(284 / 3)>; - temp = <70>; - sample-index = <14>; - }; - - sample-datum-15 { - milivolt = <(257 / 3)>; - temp = <75>; - sample-index = <15>; - }; - - sample-datum-16 { - milivolt = <(232 / 3)>; - temp = <80>; - sample-index = <16>; - }; - - sample-datum-17 { - milivolt = <(209 / 3)>; - temp = <85>; - sample-index = <17>; - }; - - sample-datum-18 { - milivolt = <(188 / 3)>; - temp = <90>; - sample-index = <18>; - }; - - sample-datum-19 { - milivolt = <(169 / 3)>; - temp = <95>; - sample-index = <19>; - }; - - sample-datum-20 { - milivolt = <(152 / 3)>; - temp = <100>; - sample-index = <20>; - }; - }; -}; diff --git a/zephyr/program/corsola/thermistor_tentacruel.dtsi b/zephyr/program/corsola/thermistor_tentacruel.dtsi new file mode 100644 index 0000000000..f9e5306f24 --- /dev/null +++ b/zephyr/program/corsola/thermistor_tentacruel.dtsi @@ -0,0 +1,140 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + thermistor_rt9490: thermistor-rt9490 { + status = "okay"; + compatible = "cros-ec,thermistor"; + scaling-factor = <3>; + num-pairs = <21>; + steinhart-reference-mv = <4900>; + steinhart-reference-res = <10000>; + + sample-datum-0 { + milivolt = <(731 / 3)>; + temp = <0>; + sample-index = <0>; + }; + + sample-datum-1 { + milivolt = <(708 / 3)>; + temp = <5>; + sample-index = <1>; + }; + + sample-datum-2 { + milivolt = <(682 / 3)>; + temp = <10>; + sample-index = <2>; + }; + + sample-datum-3 { + milivolt = <(653 / 3)>; + temp = <15>; + sample-index = <3>; + }; + + sample-datum-4 { + milivolt = <(622 / 3)>; + temp = <20>; + sample-index = <4>; + }; + + sample-datum-5 { + milivolt = <(589 / 3)>; + temp = <25>; + sample-index = <5>; + }; + + sample-datum-6 { + milivolt = <(554 / 3)>; + temp = <30>; + sample-index = <6>; + }; + + sample-datum-7 { + milivolt = <(519 / 3)>; + temp = <35>; + sample-index = <7>; + }; + + sample-datum-8 { + milivolt = <(483 / 3)>; + temp = <40>; + sample-index = <8>; + }; + + sample-datum-9 { + milivolt = <(446 / 3)>; + temp = <45>; + sample-index = <9>; + }; + + sample-datum-10 { + milivolt = <(411 / 3)>; + temp = <50>; + sample-index = <10>; + }; + sample-datum-11 { + milivolt = <(376 / 3)>; + temp = <55>; + sample-index = <11>; + }; + + sample-datum-12 { + milivolt = <(343 / 3)>; + temp = <60>; + sample-index = <12>; + }; + + sample-datum-13 { + milivolt = <(312 / 3)>; + temp = <65>; + sample-index = <13>; + }; + + sample-datum-14 { + milivolt = <(284 / 3)>; + temp = <70>; + sample-index = <14>; + }; + + sample-datum-15 { + milivolt = <(257 / 3)>; + temp = <75>; + sample-index = <15>; + }; + + sample-datum-16 { + milivolt = <(232 / 3)>; + temp = <80>; + sample-index = <16>; + }; + + sample-datum-17 { + milivolt = <(209 / 3)>; + temp = <85>; + sample-index = <17>; + }; + + sample-datum-18 { + milivolt = <(188 / 3)>; + temp = <90>; + sample-index = <18>; + }; + + sample-datum-19 { + milivolt = <(169 / 3)>; + temp = <95>; + sample-index = <19>; + }; + + sample-datum-20 { + milivolt = <(152 / 3)>; + temp = <100>; + sample-index = <20>; + }; + }; +}; diff --git a/zephyr/program/corsola/usba.dts b/zephyr/program/corsola/usba.dts deleted file mode 100644 index 2ecb3b7d5a..0000000000 --- a/zephyr/program/corsola/usba.dts +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usba_port_enable_list: usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&en_pp5000_usb_a0_vbus>; - }; -}; diff --git a/zephyr/program/corsola/usba.dtsi b/zephyr/program/corsola/usba.dtsi new file mode 100644 index 0000000000..2ecb3b7d5a --- /dev/null +++ b/zephyr/program/corsola/usba.dtsi @@ -0,0 +1,11 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usba_port_enable_list: usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&en_pp5000_usb_a0_vbus>; + }; +}; diff --git a/zephyr/program/corsola/usba_steelix.dts b/zephyr/program/corsola/usba_steelix.dts deleted file mode 100644 index 0ddd67f664..0000000000 --- a/zephyr/program/corsola/usba_steelix.dts +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* steelix usba port enable config */ -&usba_port_enable_list { - enable-pins = <&en_pp5000_usb_a0_vbus - &en_pp5000_usb_a1_vbus>; -}; diff --git a/zephyr/program/corsola/usba_steelix.dtsi b/zephyr/program/corsola/usba_steelix.dtsi new file mode 100644 index 0000000000..0ddd67f664 --- /dev/null +++ b/zephyr/program/corsola/usba_steelix.dtsi @@ -0,0 +1,10 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* steelix usba port enable config */ +&usba_port_enable_list { + enable-pins = <&en_pp5000_usb_a0_vbus + &en_pp5000_usb_a1_vbus>; +}; diff --git a/zephyr/program/corsola/usbc_kingler.dts b/zephyr/program/corsola/usbc_kingler.dts deleted file mode 100644 index 18bc6ce303..0000000000 --- a/zephyr/program/corsola/usbc_kingler.dts +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - tcpc = <&tcpc_port0>; - ppc = <&ppc_port0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&anx7447_mux_0 &virtual_mux_0>; - }; - }; - - port0-muxes { - anx7447_mux_0: anx7447-mux-0 { - compatible = "analogix,usbc-mux-anx7447"; - }; - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - tcpc = <&tcpc_port1>; - ppc = <&ppc_port1>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; - }; - usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; diff --git a/zephyr/program/corsola/usbc_krabby.dts b/zephyr/program/corsola/usbc_krabby.dts deleted file mode 100644 index a72864da35..0000000000 --- a/zephyr/program/corsola/usbc_krabby.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_ppc_port0>; - ppc = <&bc12_ppc_port0>; - tcpc = <&usbpd0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&it5205_mux_0 &virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&usbpd1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>; - }; - usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; - -&usbpd0 { - status = "okay"; -}; - -&usbpd1 { - status = "okay"; -}; diff --git a/zephyr/program/corsola/usbc_magikarp.dts b/zephyr/program/corsola/usbc_magikarp.dts deleted file mode 100644 index c94db15b3a..0000000000 --- a/zephyr/program/corsola/usbc_magikarp.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&ppc_port0>; - tcpc = <&usbpd0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&it5205_mux_0 &virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&usbpd1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; - }; - usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; - -&usbpd0 { - status = "okay"; -}; - -&usbpd1 { - status = "okay"; -}; diff --git a/zephyr/program/corsola/usbc_magikarp.dtsi b/zephyr/program/corsola/usbc_magikarp.dtsi new file mode 100644 index 0000000000..c94db15b3a --- /dev/null +++ b/zephyr/program/corsola/usbc_magikarp.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; diff --git a/zephyr/program/corsola/usbc_tentacruel.dts b/zephyr/program/corsola/usbc_tentacruel.dts deleted file mode 100644 index bb105a8e08..0000000000 --- a/zephyr/program/corsola/usbc_tentacruel.dts +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - ppc = <&bc12_ppc_port0>; - ppc_alt = <&ppc_port0>; - tcpc = <&usbpd0>; - chg = <&charger>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&it5205_mux_0 &virtual_mux_0>; - }; - }; - port0-muxes { - virtual_mux_0: virtual-mux-0 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - - port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - ppc = <&ppc_port1>; - tcpc = <&usbpd1>; - usb-mux-chain-1 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; - }; - usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { - compatible = "cros-ec,usb-mux-chain"; - alternative-chain; - usb-muxes = <&virtual_mux_1>; - }; - }; - port1-muxes { - virtual_mux_1: virtual-mux-1 { - compatible = "cros-ec,usbc-mux-virtual"; - }; - }; - }; -}; - -&usbpd0 { - status = "okay"; -}; - -&usbpd1 { - status = "okay"; -}; diff --git a/zephyr/program/corsola/usbc_tentacruel.dtsi b/zephyr/program/corsola/usbc_tentacruel.dtsi new file mode 100644 index 0000000000..bb105a8e08 --- /dev/null +++ b/zephyr/program/corsola/usbc_tentacruel.dtsi @@ -0,0 +1,60 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&bc12_ppc_port0>; + ppc_alt = <&ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; diff --git a/zephyr/test/kingler/testcase.yaml b/zephyr/test/kingler/testcase.yaml index 7e26480c14..2b1051a510 100644 --- a/zephyr/test/kingler/testcase.yaml +++ b/zephyr/test/kingler/testcase.yaml @@ -6,36 +6,36 @@ common: platform_allow: native_posix tests: kingler.steelix: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_FORM_FACTOR_CONVERTIBLE=y kingler.rusty: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_FORM_FACTOR_CLAMSHELL=y kingler.db_detect_typec: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/gpio_steelix.dts;" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/gpio_steelix.dtsi;" extra_configs: - CONFIG_TEST_DB_DETECT_TYPEC=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.db_detect_hdmi: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/gpio_steelix.dtsi" extra_configs: - CONFIG_TEST_DB_DETECT_HDMI=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.db_detect_none: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" extra_configs: - CONFIG_TEST_DB_DETECT_NONE=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.ccd: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" extra_configs: - CONFIG_TEST_KINGLER_CCD=y kingler.alt_sensor: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/interrupts_kingler.dts;../program/corsola/interrupts_steelix.dts;../program/corsola/cbi_steelix.dts;../program/corsola/gpio_steelix.dts" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/interrupts_steelix.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_ALT_SENSOR_PROBE=y diff --git a/zephyr/test/krabby/testcase.yaml b/zephyr/test/krabby/testcase.yaml index 5cc3c42428..6e202c92c8 100644 --- a/zephyr/test/krabby/testcase.yaml +++ b/zephyr/test/krabby/testcase.yaml @@ -6,12 +6,12 @@ common: platform_allow: native_posix tests: krabby.default: - extra_args: DTC_OVERLAY_FILE="common.dts;../program/corsola/interrupts_krabby.dts;../program/corsola/gpio_krabby.dts;pinctrl.dts" + extra_args: DTC_OVERLAY_FILE="common.dts;../program/corsola/ite_interrupts.dtsi;../program/corsola/ite_gpio.dtsi;pinctrl.dts" extra_configs: - CONFIG_TEST_KRABBY=y - CONFIG_MUX_INIT_ADC=y krabby.tentacruel: - extra_args: DTC_OVERLAY_FILE="common.dts;adc_temp.dts;../program/corsola/interrupts_tentacruel.dts;../program/corsola/gpio_tentacruel.dts;../program/corsola/thermistor_tentacruel.dts;pinctrl.dts" + extra_args: DTC_OVERLAY_FILE="common.dts;adc_temp.dts;../program/corsola/interrupts_tentacruel.dtsi;../program/corsola/gpio_tentacruel.dtsi;../program/corsola/thermistor_tentacruel.dtsi;pinctrl.dts" extra_configs: - CONFIG_TEST_TENTACRUEL=y - CONFIG_PLATFORM_EC_TEMP_SENSOR=y -- cgit v1.2.1 From b4c0e88b9752a86b3261503c7ea8e8300a59d5e3 Mon Sep 17 00:00:00 2001 From: Michael5 Chen1 Date: Mon, 14 Nov 2022 09:13:55 +0800 Subject: marasov: Config the EC battery setting. Config the EC battery setting depend on battery spec. BUG=b:259008193 BRANCH=brya TEST=make BOARD=marasov Signed-off-by: Michael5 Chen1 Change-Id: I04a6e3d96780cbffd44b83f6453d40bb577564eb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022611 Reviewed-by: Kyle Lin Code-Coverage: Zoss Commit-Queue: Kyle Lin --- board/marasov/battery.c | 54 ++++++++++--------------------------------------- board/marasov/board.h | 9 ++++++++- 2 files changed, 19 insertions(+), 44 deletions(-) diff --git a/board/marasov/battery.c b/board/marasov/battery.c index f80ed9e9e4..dfc7dd007e 100644 --- a/board/marasov/battery.c +++ b/board/marasov/battery.c @@ -33,55 +33,23 @@ * address, mask, and disconnect value need to be provided. */ const struct board_batt_params board_battery_info[] = { - /* POW-TECH GQA05 Battery Information */ - [BATTERY_POWER_TECH] = { - /* BQ40Z50 Fuel Gauge */ + /* C490-42 Battery Information */ + [BATTERY_C490] = { .fuel_gauge = { - .manuf_name = "POW-TECH", - .device_name = "BATGQA05L22", + .manuf_name = "AS3GWQd3jB", + .device_name = "C490-42", .ship_mode = { .reg_addr = 0x00, .reg_data = { 0x0010, 0x0010 }, }, .fet = { - .mfgacc_support = 1, - .reg_addr = 0x00, - .reg_mask = 0x2000, /* XDSG */ - .disconnect_val = 0x2000, - } - }, - .batt_info = { - .voltage_max = TARGET_WITH_MARGIN(13050, 5), - .voltage_normal = 11400, /* mV */ - .voltage_min = 9000, /* mV */ - .precharge_current = 280, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 45, - .discharging_min_c = -10, - .discharging_max_c = 60, - }, - }, - /* LGC L17L3PB0 Battery Information */ - /* - * Battery info provided by ODM on b/143477210, comment #11 - */ - [BATTERY_LGC011] = { - .fuel_gauge = { - .manuf_name = "LGC", - .ship_mode = { - .reg_addr = 0x00, - .reg_data = { 0x0010, 0x0010 }, - }, - .fet = { - .reg_addr = 0x0, - .reg_mask = 0x6000, - .disconnect_val = 0x6000, + .reg_addr = 0x99, + .reg_mask = 0x000c, + .disconnect_val = 0x000c, } }, .batt_info = { - .voltage_max = TARGET_WITH_MARGIN(13200, 5), + .voltage_max = 13200, /* mV */ .voltage_normal = 11550, /* mV */ .voltage_min = 9000, /* mV */ .precharge_current = 256, /* mA */ @@ -89,14 +57,14 @@ const struct board_batt_params board_battery_info[] = { .start_charging_max_c = 45, .charging_min_c = 0, .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 75, + .discharging_min_c = -20, + .discharging_max_c = 60, }, }, }; BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); -const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_POWER_TECH; +const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_C490; enum battery_present battery_hw_present(void) { diff --git a/board/marasov/board.h b/board/marasov/board.h index 32b65e830a..4ae3e5adef 100644 --- a/board/marasov/board.h +++ b/board/marasov/board.h @@ -52,6 +52,13 @@ #define CONFIG_USB_PD_TCPM_PS8815_FORCE_DID #define CONFIG_USBC_RETIMER_INTEL_BB +/* Battery Configuration */ +#define CONFIG_SMBUS_PEC +#undef CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE +#define CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE 3 +#undef CONFIG_BATT_HOST_FULL_FACTOR +#define CONFIG_BATT_HOST_FULL_FACTOR 99 + /* I2C speed console command */ #define CONFIG_CMD_I2C_SPEED @@ -199,7 +206,7 @@ enum temp_sensor_id { enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT }; -enum battery_type { BATTERY_POWER_TECH, BATTERY_LGC011, BATTERY_TYPE_COUNT }; +enum battery_type { BATTERY_C490, BATTERY_TYPE_COUNT }; enum pwm_channel { PWM_CH_KBLIGHT, /* PWM3 */ -- cgit v1.2.1 From 791d419489b8174271f593ce68608a3ecd8e6441 Mon Sep 17 00:00:00 2001 From: johnwc_yeh Date: Tue, 15 Nov 2022 11:35:33 +0800 Subject: Xivu : Modify CP point setting This patch add dynamic adjust Cp point to meet power team Safety test criteria. Replace it with common function from nissa/src/common.c BUG=b:249407534 BRANCH=none TEST=test dynamic adjust CP point success Signed-off-by: johnwc_yeh Change-Id: I7cfa73d9a5a0b54cb126e3f3263c6a345ee93b79 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4023239 Reviewed-by: SamSP Liu Code-Coverage: Zoss Reviewed-by: Andrew McRae --- zephyr/program/nissa/xivu/src/usbc.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/zephyr/program/nissa/xivu/src/usbc.c b/zephyr/program/nissa/xivu/src/usbc.c index aab4f85438..773ffc0e9c 100644 --- a/zephyr/program/nissa/xivu/src/usbc.c +++ b/zephyr/program/nissa/xivu/src/usbc.c @@ -290,14 +290,6 @@ void usb_interrupt(enum gpio_signal signal) hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); } -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_ma = (charge_ma * 90) / 100; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} - struct chg_curr_step { int on; int off; -- cgit v1.2.1 From 2bbef559d259197864a6610b04d2745274f47315 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 14 Nov 2022 15:26:05 +0000 Subject: zephyr: keyboard: select PLATFORM_EC_KEYBOARD_DISCRETE automatically Select PLATFORM_EC_KEYBOARD_DISCRETE automatically and make it depend on having the corresponding nodelabel. This allows removal of an explicit config entry and prevents the driver from trying to build with an invalid configuration. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Ib2bbdf18952b0536761c72070f5113723e99bb7a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021953 Code-Coverage: Zoss Reviewed-by: Yuval Peress --- zephyr/Kconfig.keyboard | 2 ++ zephyr/program/intelrvp/mtlrvp/prj.conf | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/zephyr/Kconfig.keyboard b/zephyr/Kconfig.keyboard index 505f292e8b..444c20950c 100644 --- a/zephyr/Kconfig.keyboard +++ b/zephyr/Kconfig.keyboard @@ -50,6 +50,8 @@ endchoice # PLATFORM_EC_KEYBOARD_PROTOCOL_MODE config PLATFORM_EC_KEYBOARD_DISCRETE bool "Support discrete Keyboard" + default y + depends on $(dt_nodelabel_enabled,kb_discrete) help Enable support for a discrete Keyboard if the platform needs one or the raw Keyboard support is not built-in in the EC. diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index de1b8e71a5..3b0b0fa32e 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -33,7 +33,6 @@ CONFIG_PLATFORM_EC_IOEX_CCGXXF=y CONFIG_PLATFORM_EC_IOEX_IT8801=y #Keyboard from I/O expander -CONFIG_PLATFORM_EC_KEYBOARD_DISCRETE=y CONFIG_CROS_KB_RAW_NPCX=n # Temperature sensors -- cgit v1.2.1 From 5ddb5d2ea879164a420fb7f4335d5c9d12fdf6cd Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 14:48:22 -0700 Subject: zephyr/shim: Sort header files Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: I5fefbad560d33e2e8be1b02d0db618a19fdd403d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024019 Reviewed-by: Tomasz Michalec Code-Coverage: Zoss Tested-by: Jeremy Bettis Commit-Queue: Tomasz Michalec Auto-Submit: Jeremy Bettis --- zephyr/shim/chip/it8xxx2/clock.c | 7 ++++--- zephyr/shim/chip/it8xxx2/gpio.c | 5 ++--- zephyr/shim/chip/it8xxx2/keyboard_raw.c | 9 ++++---- zephyr/shim/chip/it8xxx2/power_policy.c | 7 ++++--- zephyr/shim/chip/mchp/clock.c | 7 ++++--- zephyr/shim/chip/mchp/gpio.c | 3 ++- zephyr/shim/chip/mchp/keyboard_raw.c | 9 ++++---- zephyr/shim/chip/mchp/system.c | 6 +++--- zephyr/shim/chip/mchp/system_download_from_flash.c | 7 ++++--- zephyr/shim/chip/mchp/system_external_storage.c | 11 +++++----- zephyr/shim/chip/npcx/clock.c | 7 ++++--- zephyr/shim/chip/npcx/gpio.c | 11 +++++----- zephyr/shim/chip/npcx/keyboard_raw.c | 9 ++++---- zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c | 6 ++++-- zephyr/shim/chip/npcx/power_policy.c | 9 ++++---- zephyr/shim/chip/npcx/shi.c | 15 +++++++------- zephyr/shim/chip/npcx/system.c | 6 +++--- zephyr/shim/chip/npcx/system_download_from_flash.c | 9 ++++---- zephyr/shim/chip/npcx/system_external_storage.c | 6 +++--- zephyr/shim/core/cortex-m/irq_command.c | 3 ++- zephyr/shim/core/cortex-m/mpu.c | 7 +++---- zephyr/shim/include/charger/chg_isl923x.h | 3 ++- zephyr/shim/include/charger/chg_isl9241.h | 3 ++- zephyr/shim/include/charger/chg_rt9490.h | 3 ++- zephyr/shim/include/charger/chg_sm5803.h | 3 ++- zephyr/shim/include/charger_chips.h | 1 + zephyr/shim/include/config_chip.h | 1 + zephyr/shim/include/cros_cbi.h | 2 +- zephyr/shim/include/motionsense_sensors.h | 3 ++- zephyr/shim/include/motionsense_sensors_defs.h | 4 ++-- zephyr/shim/include/temp_sensor/temp_sensor.h | 5 +++-- zephyr/shim/include/usbc/ppc.h | 7 ++++--- zephyr/shim/include/usbc/tcpc_anx7447.h | 3 ++- zephyr/shim/include/usbc/tcpc_anx7447_emul.h | 3 ++- zephyr/shim/include/usbc/tcpc_ccgxxf.h | 3 ++- zephyr/shim/include/usbc/tcpc_fusb302.h | 3 ++- zephyr/shim/include/usbc/tcpc_generic_emul.h | 4 ++-- zephyr/shim/include/usbc/tcpc_it8xxx2.h | 3 ++- zephyr/shim/include/usbc/tcpc_nct38xx.h | 3 ++- zephyr/shim/include/usbc/tcpc_ps8xxx.h | 3 ++- zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h | 3 ++- zephyr/shim/include/usbc/tcpc_rt1718s.h | 3 ++- zephyr/shim/include/usbc/tcpci.h | 4 ++-- zephyr/shim/include/usbc/usb_muxes.h | 5 +++-- zephyr/shim/include/zephyr_hooks_shim.h | 6 +++--- zephyr/shim/include/zephyr_host_command.h | 3 ++- zephyr/shim/include/zephyr_shim.h | 3 ++- zephyr/shim/include/zephyr_write_protect.h | 1 + zephyr/shim/src/adc.c | 5 +++-- zephyr/shim/src/battery.c | 4 ++-- zephyr/shim/src/bb_retimer_usb_mux.c | 5 +++-- zephyr/shim/src/bc12.c | 5 +++-- zephyr/shim/src/bc12_pi3usb9201.c | 5 +++-- zephyr/shim/src/bc12_rt9490.c | 3 ++- zephyr/shim/src/cbi/cbi_eeprom.c | 6 +++--- zephyr/shim/src/cbi/cros_cbi.c | 3 +-- zephyr/shim/src/cbi/cros_cbi_fw_config.c | 4 ++-- zephyr/shim/src/cbi/cros_cbi_ssfc.c | 4 ++-- zephyr/shim/src/charger.c | 3 ++- zephyr/shim/src/chipset_api.c | 3 +-- zephyr/shim/src/chipset_state_check.h | 2 +- zephyr/shim/src/console.c | 7 ++++--- zephyr/shim/src/console_buffer.c | 4 ++-- zephyr/shim/src/crc.c | 4 ++-- zephyr/shim/src/espi.c | 24 ++++++++++++---------- zephyr/shim/src/fan.c | 12 +++++------ zephyr/shim/src/flash.c | 11 +++++----- zephyr/shim/src/gpio.c | 2 +- zephyr/shim/src/gpio_int.c | 2 +- zephyr/shim/src/hooks.c | 11 +++++----- zephyr/shim/src/host_command.c | 4 ++-- zephyr/shim/src/hwtimer.c | 5 +++-- zephyr/shim/src/i2c.c | 6 +++--- zephyr/shim/src/ioex.c | 3 ++- zephyr/shim/src/ioex_drv.c | 12 ++++++----- zephyr/shim/src/keyboard_raw.c | 9 ++++---- zephyr/shim/src/keyscan.c | 6 ++++-- zephyr/shim/src/led_driver/led.c | 3 +-- zephyr/shim/src/log_backend_console_buffer.c | 6 +++--- zephyr/shim/src/motionsense_sensors.c | 7 ++++--- zephyr/shim/src/panic.c | 8 ++++---- zephyr/shim/src/power.c | 4 ++-- zephyr/shim/src/ppc.c | 7 ++++--- zephyr/shim/src/pwm_hc.c | 12 +++++------ zephyr/shim/src/pwm_led.c | 1 + zephyr/shim/src/rtc.c | 6 +++--- zephyr/shim/src/switchcap_gpio.c | 3 ++- zephyr/shim/src/switchcap_ln9310.c | 5 +++-- zephyr/shim/src/system.c | 11 +++++----- zephyr/shim/src/tasks.c | 12 +++++------ zephyr/shim/src/tcpc.c | 7 ++++--- zephyr/shim/src/tcpc_nct38xx.c | 6 +++--- zephyr/shim/src/thermal.c | 2 +- zephyr/shim/src/usb_muxes.c | 5 +++-- zephyr/shim/src/usba.c | 3 ++- zephyr/shim/src/watchdog.c | 10 ++++----- 96 files changed, 299 insertions(+), 240 deletions(-) diff --git a/zephyr/shim/chip/it8xxx2/clock.c b/zephyr/shim/chip/it8xxx2/clock.c index 14dbc0e7eb..a4df87dc1d 100644 --- a/zephyr/shim/chip/it8xxx2/clock.c +++ b/zephyr/shim/chip/it8xxx2/clock.c @@ -3,15 +3,16 @@ * found in the LICENSE file. */ +#include "module_id.h" + #include #include #include #include -#include -#include #include -#include "module_id.h" +#include +#include LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR); diff --git a/zephyr/shim/chip/it8xxx2/gpio.c b/zephyr/shim/chip/it8xxx2/gpio.c index 7106b2a294..16eb7a3963 100644 --- a/zephyr/shim/chip/it8xxx2/gpio.c +++ b/zephyr/shim/chip/it8xxx2/gpio.c @@ -3,14 +3,13 @@ * found in the LICENSE file. */ +#include "gpio/gpio.h" + #include #include #include - #include -#include "gpio/gpio.h" - LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR); static const struct unused_pin_config unused_pin_configs[] = { diff --git a/zephyr/shim/chip/it8xxx2/keyboard_raw.c b/zephyr/shim/chip/it8xxx2/keyboard_raw.c index 0a117cda14..5fe99b7efa 100644 --- a/zephyr/shim/chip/it8xxx2/keyboard_raw.c +++ b/zephyr/shim/chip/it8xxx2/keyboard_raw.c @@ -5,13 +5,14 @@ /* Functions needed by keyboard scanner module for Chrome EC */ +#include "drivers/cros_kb_raw.h" +#include "keyboard_raw.h" + #include -#include -#include #include +#include -#include "drivers/cros_kb_raw.h" -#include "keyboard_raw.h" +#include /** * Return true if the current value of the given input GPIO port is zero diff --git a/zephyr/shim/chip/it8xxx2/power_policy.c b/zephyr/shim/chip/it8xxx2/power_policy.c index c8efb0ca96..c6e73d53a4 100644 --- a/zephyr/shim/chip/it8xxx2/power_policy.c +++ b/zephyr/shim/chip/it8xxx2/power_policy.c @@ -3,12 +3,13 @@ * found in the LICENSE file. */ +#include "system.h" + +#include #include #include -#include -#include -#include "system.h" +#include static const struct pm_state_info pm_states[] = PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0)); diff --git a/zephyr/shim/chip/mchp/clock.c b/zephyr/shim/chip/mchp/clock.c index 6ee4cd931c..5fb39bfd43 100644 --- a/zephyr/shim/chip/mchp/clock.c +++ b/zephyr/shim/chip/mchp/clock.c @@ -3,15 +3,16 @@ * found in the LICENSE file. */ +#include "clock_chip.h" +#include "module_id.h" + #include #include #include #include #include -#include -#include "clock_chip.h" -#include "module_id.h" +#include LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR); diff --git a/zephyr/shim/chip/mchp/gpio.c b/zephyr/shim/chip/mchp/gpio.c index 7801c6f7cc..d772a566d8 100644 --- a/zephyr/shim/chip/mchp/gpio.c +++ b/zephyr/shim/chip/mchp/gpio.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ +#include "gpio/gpio.h" + #include #include #include #include -#include "gpio/gpio.h" LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR); diff --git a/zephyr/shim/chip/mchp/keyboard_raw.c b/zephyr/shim/chip/mchp/keyboard_raw.c index 95ad642d12..9183e4d7dd 100644 --- a/zephyr/shim/chip/mchp/keyboard_raw.c +++ b/zephyr/shim/chip/mchp/keyboard_raw.c @@ -5,13 +5,14 @@ /* Functions needed by keyboard scanner module for Chrome EC */ +#include "drivers/cros_kb_raw.h" +#include "keyboard_raw.h" + #include -#include -#include #include +#include -#include "drivers/cros_kb_raw.h" -#include "keyboard_raw.h" +#include /** * Return true if the current value of the given input GPIO port is zero diff --git a/zephyr/shim/chip/mchp/system.c b/zephyr/shim/chip/mchp/system.c index 35ba806533..6e5da9aa80 100644 --- a/zephyr/shim/chip/mchp/system.c +++ b/zephyr/shim/chip/mchp/system.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "system.h" #include "system_chip.h" +#include +#include + LOG_MODULE_REGISTER(shim_xec_system, LOG_LEVEL_ERR); #define GET_BBRAM_OFS(node) DT_PROP(DT_PATH(named_bbram_regions, node), offset) diff --git a/zephyr/shim/chip/mchp/system_download_from_flash.c b/zephyr/shim/chip/mchp/system_download_from_flash.c index 51cdc5aab6..8f6304274f 100644 --- a/zephyr/shim/chip/mchp/system_download_from_flash.c +++ b/zephyr/shim/chip/mchp/system_download_from_flash.c @@ -2,13 +2,14 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include - #include "common.h" #include "soc.h" #include "system_chip.h" +#include + +#include + /* Modules Map */ #define WDT_NODE DT_INST(0, microchip_xec_watchdog) #define STRUCT_WDT_REG_BASE_ADDR ((struct wdt_regs *)(DT_REG_ADDR(WDT_NODE))) diff --git a/zephyr/shim/chip/mchp/system_external_storage.c b/zephyr/shim/chip/mchp/system_external_storage.c index 4250b05fe3..5887e045a4 100644 --- a/zephyr/shim/chip/mchp/system_external_storage.c +++ b/zephyr/shim/chip/mchp/system_external_storage.c @@ -3,15 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "clock_chip.h" #include "common.h" +#include "config_chip.h" #include "system.h" #include "system_chip.h" -#include "config_chip.h" + +#include +#include + +#include #define MCHP_ECRO_WORD 0x4F524345u /* ASCII ECRO */ #define MCHP_ECRW_WORD 0x57524345u /* ASCII ECRW */ diff --git a/zephyr/shim/chip/npcx/clock.c b/zephyr/shim/chip/npcx/clock.c index fc483ef775..2a6fe27ef4 100644 --- a/zephyr/shim/chip/npcx/clock.c +++ b/zephyr/shim/chip/npcx/clock.c @@ -3,15 +3,16 @@ * found in the LICENSE file. */ +#include "clock_chip.h" +#include "module_id.h" + #include #include #include #include #include -#include -#include "clock_chip.h" -#include "module_id.h" +#include LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR); diff --git a/zephyr/shim/chip/npcx/gpio.c b/zephyr/shim/chip/npcx/gpio.c index 850123e17b..1d51c00f61 100644 --- a/zephyr/shim/chip/npcx/gpio.c +++ b/zephyr/shim/chip/npcx/gpio.c @@ -3,16 +3,15 @@ * found in the LICENSE file. */ +#include "gpio/gpio.h" +#include "soc_gpio.h" +#include "util.h" + #include #include #include -#include - #include - -#include "gpio/gpio.h" -#include "soc_gpio.h" -#include "util.h" +#include LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR); diff --git a/zephyr/shim/chip/npcx/keyboard_raw.c b/zephyr/shim/chip/npcx/keyboard_raw.c index 4d43134482..1f01952ab9 100644 --- a/zephyr/shim/chip/npcx/keyboard_raw.c +++ b/zephyr/shim/chip/npcx/keyboard_raw.c @@ -5,15 +5,16 @@ /* Functions needed by keyboard scanner module for Chrome EC */ +#include "drivers/cros_kb_raw.h" +#include "keyboard_raw.h" + #include #include +#include #include + #include #include -#include - -#include "drivers/cros_kb_raw.h" -#include "keyboard_raw.h" /** * Return true if the current value of the given input GPIO port is zero diff --git a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c index e3fecc0cbd..3062ed98a4 100644 --- a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c +++ b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c @@ -5,12 +5,14 @@ * NPCX SoC spi flash update tool - monitor firmware */ -#include -#include #include "config_chip.h" #include "npcx_monitor.h" #include "registers.h" +#include + +#include + /* * TODO(b/197162681): This was copied from chip/npcx/spiflashfw but this * needs to be moved to Zephyr upstream diff --git a/zephyr/shim/chip/npcx/power_policy.c b/zephyr/shim/chip/npcx/power_policy.c index aea6e62d30..29ebcbd542 100644 --- a/zephyr/shim/chip/npcx/power_policy.c +++ b/zephyr/shim/chip/npcx/power_policy.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ +#include "console.h" +#include "cros_version.h" +#include "system.h" + #include #include #include -#include -#include "console.h" -#include "cros_version.h" -#include "system.h" +#include static const struct pm_state_info residency_info[] = PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0)); diff --git a/zephyr/shim/chip/npcx/shi.c b/zephyr/shim/chip/npcx/shi.c index 8bec57252d..0cecc2c56e 100644 --- a/zephyr/shim/chip/npcx/shi.c +++ b/zephyr/shim/chip/npcx/shi.c @@ -5,19 +5,20 @@ /* Functions needed by Serial Host Interface module for Chrome EC */ -#include -#include -#include -#include -#include - -#include #include "chipset.h" #include "drivers/cros_shi.h" #include "hooks.h" #include "host_command.h" #include "system.h" +#include +#include +#include +#include + +#include +#include + LOG_MODULE_REGISTER(shim_cros_shi, LOG_LEVEL_DBG); #define SHI_NODE DT_NODELABEL(shi) diff --git a/zephyr/shim/chip/npcx/system.c b/zephyr/shim/chip/npcx/system.c index 2240acea54..1fbdca0803 100644 --- a/zephyr/shim/chip/npcx/system.c +++ b/zephyr/shim/chip/npcx/system.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include -#include - #include "system.h" #include "system_chip.h" +#include +#include + LOG_MODULE_REGISTER(shim_npcx_system, LOG_LEVEL_ERR); static void chip_bbram_status_check(void) diff --git a/zephyr/shim/chip/npcx/system_download_from_flash.c b/zephyr/shim/chip/npcx/system_download_from_flash.c index 1aef9560d1..53e22d4839 100644 --- a/zephyr/shim/chip/npcx/system_download_from_flash.c +++ b/zephyr/shim/chip/npcx/system_download_from_flash.c @@ -2,14 +2,15 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include -#include - #include "common.h" #include "soc.h" #include "system_chip.h" +#include +#include + +#include + /* Modules Map */ #define NPCX_PMC_BASE_ADDR 0x4000D000 #define NPCX_GDMA_BASE_ADDR 0x40011000 diff --git a/zephyr/shim/chip/npcx/system_external_storage.c b/zephyr/shim/chip/npcx/system_external_storage.c index 81e1968cf4..d3b2d26362 100644 --- a/zephyr/shim/chip/npcx/system_external_storage.c +++ b/zephyr/shim/chip/npcx/system_external_storage.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "clock_chip.h" #include "common.h" #include "rom_chip.h" #include "system.h" #include "system_chip.h" +#include +#include + /* TODO (b:179900857) Make this implementation not npcx specific. */ static const struct device *mdc_dev = DEVICE_DT_GET(DT_NODELABEL(mdc)); diff --git a/zephyr/shim/core/cortex-m/irq_command.c b/zephyr/shim/core/cortex-m/irq_command.c index 1cf1a213e4..651f804800 100644 --- a/zephyr/shim/core/cortex-m/irq_command.c +++ b/zephyr/shim/core/cortex-m/irq_command.c @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "console.h" +#include + /* IRQ counters */ int irq_count[CONFIG_NUM_IRQS]; diff --git a/zephyr/shim/core/cortex-m/mpu.c b/zephyr/shim/core/cortex-m/mpu.c index 8025227700..601961225c 100644 --- a/zephyr/shim/core/cortex-m/mpu.c +++ b/zephyr/shim/core/cortex-m/mpu.c @@ -3,13 +3,12 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "config.h" #include "mpu.h" +#include +#include +#include #include LOG_MODULE_REGISTER(shim_mpu, LOG_LEVEL_ERR); diff --git a/zephyr/shim/include/charger/chg_isl923x.h b/zephyr/shim/include/charger/chg_isl923x.h index b0323cd1b8..9156e574de 100644 --- a/zephyr/shim/include/charger/chg_isl923x.h +++ b/zephyr/shim/include/charger/chg_isl923x.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/charger/isl923x_public.h" +#include + #define ISL923X_CHG_COMPAT intersil_isl923x #define ISL923X_EMUL_COMPAT cros_isl923x_emul diff --git a/zephyr/shim/include/charger/chg_isl9241.h b/zephyr/shim/include/charger/chg_isl9241.h index 711a581c2f..c6d2239038 100644 --- a/zephyr/shim/include/charger/chg_isl9241.h +++ b/zephyr/shim/include/charger/chg_isl9241.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/charger/isl9241_public.h" +#include + #define ISL9241_CHG_COMPAT intersil_isl9241 #define CHG_CONFIG_ISL9241(id) \ diff --git a/zephyr/shim/include/charger/chg_rt9490.h b/zephyr/shim/include/charger/chg_rt9490.h index 3ac596d482..44d81eac48 100644 --- a/zephyr/shim/include/charger/chg_rt9490.h +++ b/zephyr/shim/include/charger/chg_rt9490.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/charger/rt9490.h" +#include + #define RT9490_CHG_COMPAT richtek_rt9490 #define RT9490_EMUL_COMPAT zephyr_rt9490_emul diff --git a/zephyr/shim/include/charger/chg_sm5803.h b/zephyr/shim/include/charger/chg_sm5803.h index 65ef066970..853dd06a63 100644 --- a/zephyr/shim/include/charger/chg_sm5803.h +++ b/zephyr/shim/include/charger/chg_sm5803.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/charger/sm5803.h" +#include + #define SM5803_CHG_COMPAT siliconmitus_sm5803 #define CHG_CONFIG_SM5803(id) \ diff --git a/zephyr/shim/include/charger_chips.h b/zephyr/shim/include/charger_chips.h index b24fa246bf..503a53330d 100644 --- a/zephyr/shim/include/charger_chips.h +++ b/zephyr/shim/include/charger_chips.h @@ -7,6 +7,7 @@ #define __CROS_EC_CHARGER_CHIPS_H #include "charger.h" + #include extern const struct charger_config_t chg_chips_alt[]; diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 7f56d9c342..7b3abce82e 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -15,6 +15,7 @@ #line 16 #include + #include #define SENSOR_NODE DT_PATH(motionsense_sensor) diff --git a/zephyr/shim/include/cros_cbi.h b/zephyr/shim/include/cros_cbi.h index 6f5bfd4d70..603be590c1 100644 --- a/zephyr/shim/include/cros_cbi.h +++ b/zephyr/shim/include/cros_cbi.h @@ -6,9 +6,9 @@ #ifndef __CROS_EC_CROS_CBI_H #define __CROS_EC_CROS_CBI_H -#include #include #include +#include /* * Macros are _INST_ types, so require DT_DRV_COMPAT to be defined. diff --git a/zephyr/shim/include/motionsense_sensors.h b/zephyr/shim/include/motionsense_sensors.h index e00eae426e..f83a8c63ad 100644 --- a/zephyr/shim/include/motionsense_sensors.h +++ b/zephyr/shim/include/motionsense_sensors.h @@ -6,9 +6,10 @@ #ifndef __CROS_EC_MOTIONSENSE_SENSORS_H #define __CROS_EC_MOTIONSENSE_SENSORS_H -#include #include "motion_sense.h" +#include + extern struct motion_sensor_t motion_sensors_alt[]; /* diff --git a/zephyr/shim/include/motionsense_sensors_defs.h b/zephyr/shim/include/motionsense_sensors_defs.h index ac0fc6bf56..b4b0274237 100644 --- a/zephyr/shim/include/motionsense_sensors_defs.h +++ b/zephyr/shim/include/motionsense_sensors_defs.h @@ -6,10 +6,10 @@ #ifndef __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H #define __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H -#include - #include "common.h" +#include + #define SENSOR_ID(id) DT_CAT(SENSOR_, id) /* Define the SENSOR_ID if: diff --git a/zephyr/shim/include/temp_sensor/temp_sensor.h b/zephyr/shim/include/temp_sensor/temp_sensor.h index a6cdfb5524..c4770ce767 100644 --- a/zephyr/shim/include/temp_sensor/temp_sensor.h +++ b/zephyr/shim/include/temp_sensor/temp_sensor.h @@ -6,9 +6,10 @@ #ifndef ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_ #define ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_ -#include -#include "include/temp_sensor.h" #include "charger/chg_rt9490.h" +#include "include/temp_sensor.h" + +#include #ifdef CONFIG_PLATFORM_EC_TEMP_SENSOR diff --git a/zephyr/shim/include/usbc/ppc.h b/zephyr/shim/include/usbc/ppc.h index 28e518a3ef..fa38145f66 100644 --- a/zephyr/shim/include/usbc/ppc.h +++ b/zephyr/shim/include/usbc/ppc.h @@ -6,15 +6,16 @@ #ifndef ZEPHYR_CHROME_USBC_PPC_H #define ZEPHYR_CHROME_USBC_PPC_H -#include -#include -#include "usbc/ppc_rt1739.h" #include "usbc/ppc_nx20p348x.h" +#include "usbc/ppc_rt1739.h" #include "usbc/ppc_sn5s330.h" #include "usbc/ppc_syv682x.h" #include "usbc/utils.h" #include "usbc_ppc.h" +#include +#include + extern struct ppc_config_t ppc_chips_alt[]; #define ALT_PPC_CHIP_CHK(usbc_id, usb_port_num) \ diff --git a/zephyr/shim/include/usbc/tcpc_anx7447.h b/zephyr/shim/include/usbc/tcpc_anx7447.h index b45e03393c..89076c8c49 100644 --- a/zephyr/shim/include/usbc/tcpc_anx7447.h +++ b/zephyr/shim/include/usbc/tcpc_anx7447.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "tcpm/anx7447_public.h" +#include + #define ANX7447_TCPC_COMPAT analogix_anx7447_tcpc #define TCPC_CONFIG_ANX7447(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_anx7447_emul.h b/zephyr/shim/include/usbc/tcpc_anx7447_emul.h index 78322a7329..f8ca60de6e 100644 --- a/zephyr/shim/include/usbc/tcpc_anx7447_emul.h +++ b/zephyr/shim/include/usbc/tcpc_anx7447_emul.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/tcpm/anx7447_public.h" +#include + #define ANX7447_EMUL_COMPAT cros_anx7447_emul #define TCPC_CONFIG_ANX7447_EMUL(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_ccgxxf.h b/zephyr/shim/include/usbc/tcpc_ccgxxf.h index 0c02cf6846..fb7bdcabcf 100644 --- a/zephyr/shim/include/usbc/tcpc_ccgxxf.h +++ b/zephyr/shim/include/usbc/tcpc_ccgxxf.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/tcpm/ccgxxf.h" +#include + #define CCGXXF_TCPC_COMPAT cypress_ccgxxf #define TCPC_CONFIG_CCGXXF(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_fusb302.h b/zephyr/shim/include/usbc/tcpc_fusb302.h index a2e512d938..fa309051cd 100644 --- a/zephyr/shim/include/usbc/tcpc_fusb302.h +++ b/zephyr/shim/include/usbc/tcpc_fusb302.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/tcpm/fusb302.h" +#include + #define FUSB302_TCPC_COMPAT fairchild_fusb302 #define TCPC_CONFIG_FUSB302(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_generic_emul.h b/zephyr/shim/include/usbc/tcpc_generic_emul.h index 7dc46c51ba..9000dfdf20 100644 --- a/zephyr/shim/include/usbc/tcpc_generic_emul.h +++ b/zephyr/shim/include/usbc/tcpc_generic_emul.h @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include - #include "driver/tcpm/tcpci.h" +#include + #define TCPCI_EMUL_COMPAT cros_tcpci_generic_emul #define TCPC_CONFIG_TCPCI_EMUL(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_it8xxx2.h b/zephyr/shim/include/usbc/tcpc_it8xxx2.h index c619656667..b9084782e0 100644 --- a/zephyr/shim/include/usbc/tcpc_it8xxx2.h +++ b/zephyr/shim/include/usbc/tcpc_it8xxx2.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/tcpm/it8xxx2_pd_public.h" +#include + #define IT8XXX2_TCPC_COMPAT ite_it8xxx2_usbpd #define TCPC_CONFIG_IT8XXX2(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_nct38xx.h b/zephyr/shim/include/usbc/tcpc_nct38xx.h index 87ba3379c8..7a0752904e 100644 --- a/zephyr/shim/include/usbc/tcpc_nct38xx.h +++ b/zephyr/shim/include/usbc/tcpc_nct38xx.h @@ -6,9 +6,10 @@ #ifndef __CROS_EC_TCPC_NCT38XX_H #define __CROS_EC_TCPC_NCT38XX_H -#include #include "driver/tcpm/nct38xx.h" +#include + #define NCT38XX_TCPC_COMPAT nuvoton_nct38xx #define TCPC_CONFIG_NCT38XX(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx.h b/zephyr/shim/include/usbc/tcpc_ps8xxx.h index 1a457af09b..7d3b9c6ccc 100644 --- a/zephyr/shim/include/usbc/tcpc_ps8xxx.h +++ b/zephyr/shim/include/usbc/tcpc_ps8xxx.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/tcpm/ps8xxx_public.h" +#include + #define PS8XXX_COMPAT parade_ps8xxx #define TCPC_CONFIG_PS8XXX(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h b/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h index fbd2e4bfd1..b1ea6f1705 100644 --- a/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h +++ b/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "driver/tcpm/ps8xxx_public.h" +#include + #define PS8XXX_EMUL_COMPAT cros_ps8xxx_emul #define TCPC_CONFIG_PS8XXX_EMUL(id) \ diff --git a/zephyr/shim/include/usbc/tcpc_rt1718s.h b/zephyr/shim/include/usbc/tcpc_rt1718s.h index 794fb99480..861b474ecf 100644 --- a/zephyr/shim/include/usbc/tcpc_rt1718s.h +++ b/zephyr/shim/include/usbc/tcpc_rt1718s.h @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "tcpm/rt1718s_public.h" +#include + #define RT1718S_TCPC_COMPAT richtek_rt1718s_tcpc #define TCPC_CONFIG_RT1718S(id) \ diff --git a/zephyr/shim/include/usbc/tcpci.h b/zephyr/shim/include/usbc/tcpci.h index 67138dbe99..15cea4b332 100644 --- a/zephyr/shim/include/usbc/tcpci.h +++ b/zephyr/shim/include/usbc/tcpci.h @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include - #include "driver/tcpm/tcpci.h" +#include + #define TCPCI_COMPAT cros_ec_tcpci #define TCPC_CONFIG_TCPCI(id) \ diff --git a/zephyr/shim/include/usbc/usb_muxes.h b/zephyr/shim/include/usbc/usb_muxes.h index 132ce77e91..6ee9c691a8 100644 --- a/zephyr/shim/include/usbc/usb_muxes.h +++ b/zephyr/shim/include/usbc/usb_muxes.h @@ -6,8 +6,6 @@ #ifndef ZEPHYR_CHROME_USBC_USB_MUXES_H #define ZEPHYR_CHROME_USBC_USB_MUXES_H -#include -#include #include "usb_mux.h" #include "usbc/amd_fp6_usb_mux.h" #include "usbc/anx7447_usb_mux.h" @@ -21,6 +19,9 @@ #include "usbc/utils.h" #include "usbc/virtual_usb_mux.h" +#include +#include + /** * @brief List of USB mux drivers compatibles and their configurations. Each * element of list has to have (compatible, config) format. diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h index f3949787bd..f1c25c6e8f 100644 --- a/zephyr/shim/include/zephyr_hooks_shim.h +++ b/zephyr/shim/include/zephyr_hooks_shim.h @@ -8,12 +8,12 @@ #endif #define __CROS_EC_ZEPHYR_HOOKS_SHIM_H -#include -#include - #include "common.h" #include "cros_version.h" +#include +#include + /** * The internal data structure stored for a deferred function. */ diff --git a/zephyr/shim/include/zephyr_host_command.h b/zephyr/shim/include/zephyr_host_command.h index e2f0a7c296..9271c6c368 100644 --- a/zephyr/shim/include/zephyr_host_command.h +++ b/zephyr/shim/include/zephyr_host_command.h @@ -10,9 +10,10 @@ #endif #define __CROS_EC_ZEPHYR_HOST_COMMAND_H -#include #include +#include + /* Initializes and runs the host command handler loop. */ void host_command_task(void *u); diff --git a/zephyr/shim/include/zephyr_shim.h b/zephyr/shim/include/zephyr_shim.h index 3e12568155..dce1706c5b 100644 --- a/zephyr/shim/include/zephyr_shim.h +++ b/zephyr/shim/include/zephyr_shim.h @@ -6,9 +6,10 @@ #ifndef __BOARD_H #define __BOARD_H -#include #include "common.h" +#include + /* Included shimed version of gpio signal. */ #include "gpio_signal.h" diff --git a/zephyr/shim/include/zephyr_write_protect.h b/zephyr/shim/include/zephyr_write_protect.h index 227af16bd0..59a305a0f9 100644 --- a/zephyr/shim/include/zephyr_write_protect.h +++ b/zephyr/shim/include/zephyr_write_protect.h @@ -8,6 +8,7 @@ #include "gpio/gpio_int.h" #include "gpio_signal.h" + #include /** diff --git a/zephyr/shim/src/adc.c b/zephyr/shim/src/adc.c index 9d5e64376c..b448823eee 100644 --- a/zephyr/shim/src/adc.c +++ b/zephyr/shim/src/adc.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ +#include "adc.h" +#include "zephyr_adc.h" + #include #include #include -#include "adc.h" -#include "zephyr_adc.h" LOG_MODULE_REGISTER(shim_adc, LOG_LEVEL_ERR); diff --git a/zephyr/shim/src/battery.c b/zephyr/shim/src/battery.c index 98c0877770..c70610a9e9 100644 --- a/zephyr/shim/src/battery.c +++ b/zephyr/shim/src/battery.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include - #include "battery_fuel_gauge.h" +#include + #define NODE_FUEL_GAUGE(node) \ { \ .manuf_name = DT_PROP(node, manuf_name), \ diff --git a/zephyr/shim/src/bb_retimer_usb_mux.c b/zephyr/shim/src/bb_retimer_usb_mux.c index 638a961ed1..2f45a5ee0f 100644 --- a/zephyr/shim/src/bb_retimer_usb_mux.c +++ b/zephyr/shim/src/bb_retimer_usb_mux.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -#include -#include #include "usb_mux.h" #include "usbc/usb_muxes.h" +#include +#include + /** * This prevents creating struct usb_mux bb_controls[] for platforms that didn't * migrate USB mux configuration to DTS yet. diff --git a/zephyr/shim/src/bc12.c b/zephyr/shim/src/bc12.c index 6542a166eb..12b45d2197 100644 --- a/zephyr/shim/src/bc12.c +++ b/zephyr/shim/src/bc12.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include +#include "usb_charge.h" #include "usbc/bc12_pi3usb9201.h" #include "usbc/bc12_rt1718s.h" #include "usbc/bc12_rt1739.h" #include "usbc/bc12_rt9490.h" #include "usbc/tcpc_rt1718s.h" #include "usbc/utils.h" -#include "usb_charge.h" + +#include #if DT_HAS_COMPAT_STATUS_OKAY(RT1718S_BC12_COMPAT) || \ DT_HAS_COMPAT_STATUS_OKAY(RT1739_BC12_COMPAT) || \ diff --git a/zephyr/shim/src/bc12_pi3usb9201.c b/zephyr/shim/src/bc12_pi3usb9201.c index cd79e8d4bd..d41fcc3212 100644 --- a/zephyr/shim/src/bc12_pi3usb9201.c +++ b/zephyr/shim/src/bc12_pi3usb9201.c @@ -5,15 +5,16 @@ #define DT_DRV_COMPAT pericom_pi3usb9201 -#include #include "bc12/pi3usb9201_public.h" #include "gpio/gpio_int.h" #include "hooks.h" +#include "i2c/i2c.h" #include "task.h" #include "usb_charge.h" #include "usb_pd.h" #include "usbc/utils.h" -#include "i2c/i2c.h" + +#include #define USBC_PORT_BC12(usbc_id, bc12_id) \ [USBC_PORT_NEW(usbc_id)] = { \ diff --git a/zephyr/shim/src/bc12_rt9490.c b/zephyr/shim/src/bc12_rt9490.c index df10fb5570..0b30a5d2da 100644 --- a/zephyr/shim/src/bc12_rt9490.c +++ b/zephyr/shim/src/bc12_rt9490.c @@ -5,12 +5,13 @@ #define DT_DRV_COMPAT richtek_rt9490_bc12 -#include #include "driver/charger/rt9490.h" #include "gpio/gpio_int.h" #include "hooks.h" #include "usbc/utils.h" +#include + #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) static void rt9490_bc12_enable_irqs(void) diff --git a/zephyr/shim/src/cbi/cbi_eeprom.c b/zephyr/shim/src/cbi/cbi_eeprom.c index 652c76f959..9cd0d0a955 100644 --- a/zephyr/shim/src/cbi/cbi_eeprom.c +++ b/zephyr/shim/src/cbi/cbi_eeprom.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "cros_board_info.h" #include "write_protect.h" +#include +#include + #define CBI_EEPROM_NODE DT_NODELABEL(cbi_eeprom) BUILD_ASSERT(DT_NODE_EXISTS(CBI_EEPROM_NODE), "cbi_eeprom node not defined"); diff --git a/zephyr/shim/src/cbi/cros_cbi.c b/zephyr/shim/src/cbi/cros_cbi.c index 5b90f9442d..e6fa3e8cd1 100644 --- a/zephyr/shim/src/cbi/cros_cbi.c +++ b/zephyr/shim/src/cbi/cros_cbi.c @@ -3,9 +3,8 @@ * found in the LICENSE file. */ -#include "cros_cbi.h" - #include "cros_board_info.h" +#include "cros_cbi.h" #include "hooks.h" static void cros_cbi_ec_init(void) diff --git a/zephyr/shim/src/cbi/cros_cbi_fw_config.c b/zephyr/shim/src/cbi/cros_cbi_fw_config.c index 605c7ca0f7..8f6086eb58 100644 --- a/zephyr/shim/src/cbi/cros_cbi_fw_config.c +++ b/zephyr/shim/src/cbi/cros_cbi_fw_config.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "cros_board_info.h" #include "cros_cbi.h" +#include + LOG_MODULE_REGISTER(cros_cbi_fw_config, LOG_LEVEL_ERR); /* diff --git a/zephyr/shim/src/cbi/cros_cbi_ssfc.c b/zephyr/shim/src/cbi/cros_cbi_ssfc.c index 9158e9f215..f20ca457f4 100644 --- a/zephyr/shim/src/cbi/cros_cbi_ssfc.c +++ b/zephyr/shim/src/cbi/cros_cbi_ssfc.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "cros_board_info.h" #include "cros_cbi.h" +#include + LOG_MODULE_REGISTER(cros_cbi_ssfc, LOG_LEVEL_ERR); /* Actually, two "compatible" values are handle here - cros_ec_cbi_ssfc_value diff --git a/zephyr/shim/src/charger.c b/zephyr/shim/src/charger.c index 35ede5a8f7..9d6021ad7d 100644 --- a/zephyr/shim/src/charger.c +++ b/zephyr/shim/src/charger.c @@ -4,7 +4,6 @@ */ #include "charger.h" -#include #include "charger/chg_bq25710.h" #include "charger/chg_isl923x.h" #include "charger/chg_isl9241.h" @@ -12,6 +11,8 @@ #include "charger/chg_sm5803.h" #include "usbc/utils.h" +#include + #define CHG_CHIP_ENTRY(usbc_id, chg_id, config_fn) \ [USBC_PORT_NEW(usbc_id)] = config_fn(chg_id) diff --git a/zephyr/shim/src/chipset_api.c b/zephyr/shim/src/chipset_api.c index 6c48719a7f..925d13f6e1 100644 --- a/zephyr/shim/src/chipset_api.c +++ b/zephyr/shim/src/chipset_api.c @@ -5,10 +5,9 @@ /* Chipset interface APIs */ -#include "common.h" - #include "ap_power/ap_power_interface.h" #include "chipset_state_check.h" +#include "common.h" int chipset_in_state(int state_mask) { diff --git a/zephyr/shim/src/chipset_state_check.h b/zephyr/shim/src/chipset_state_check.h index 2d10b2ce4a..c33a3f9553 100644 --- a/zephyr/shim/src/chipset_state_check.h +++ b/zephyr/shim/src/chipset_state_check.h @@ -6,8 +6,8 @@ #ifndef __CHIPSET_STATE_CHECK_H__ #define __CHIPSET_STATE_CHECK_H__ -#include "chipset.h" #include "ap_power/ap_power_interface.h" +#include "chipset.h" BUILD_ASSERT((int)AP_POWER_STATE_HARD_OFF == (int)CHIPSET_STATE_HARD_OFF); BUILD_ASSERT((int)AP_POWER_STATE_SOFT_OFF == (int)CHIPSET_STATE_SOFT_OFF); diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c index 4ac8e249cb..7bc8990789 100644 --- a/zephyr/shim/src/console.c +++ b/zephyr/shim/src/console.c @@ -9,13 +9,14 @@ #ifdef CONFIG_SHELL_BACKEND_DUMMY /* nocheck */ #include /* nocheck */ #endif -#include #include #include -#include -#include + #include #include +#include +#include +#include /* * TODO(b/238433667): Include EC printf functions diff --git a/zephyr/shim/src/console_buffer.c b/zephyr/shim/src/console_buffer.c index dad0031267..f5e80b2d20 100644 --- a/zephyr/shim/src/console_buffer.c +++ b/zephyr/shim/src/console_buffer.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "console.h" #include "ec_commands.h" +#include + static char console_buf[CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE]; static uint32_t previous_snapshot_idx; static uint32_t current_snapshot_idx; diff --git a/zephyr/shim/src/crc.c b/zephyr/shim/src/crc.c index f8ce335029..1e98c1cf3f 100644 --- a/zephyr/shim/src/crc.c +++ b/zephyr/shim/src/crc.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include - #include "crc8.h" +#include + /* Polynomial representation for x^8 + x^2 + x + 1 is 0x07 */ #define SMBUS_POLYNOMIAL 0x07 diff --git a/zephyr/shim/src/espi.c b/zephyr/shim/src/espi.c index 6a8e18e262..9cc5de8f0b 100644 --- a/zephyr/shim/src/espi.c +++ b/zephyr/shim/src/espi.c @@ -3,17 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include #include "acpi.h" #include "chipset.h" #include "common.h" @@ -28,6 +17,19 @@ #include "timer.h" #include "zephyr_espi_shim.h" +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + #define VWIRE_PULSE_TRIGGER_TIME \ CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US diff --git a/zephyr/shim/src/fan.c b/zephyr/shim/src/fan.c index a18a33beec..9bc36f878f 100644 --- a/zephyr/shim/src/fan.c +++ b/zephyr/shim/src/fan.c @@ -5,12 +5,6 @@ #define DT_DRV_COMPAT cros_ec_fans -#include -#include -#include -#include -#include - #include "fan.h" #include "gpio_signal.h" #include "hooks.h" @@ -18,6 +12,12 @@ #include "system.h" #include "util.h" +#include +#include +#include +#include +#include + LOG_MODULE_REGISTER(fan_shim, LOG_LEVEL_ERR); BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, diff --git a/zephyr/shim/src/flash.c b/zephyr/shim/src/flash.c index 8aa7deecf5..5b7079e450 100644 --- a/zephyr/shim/src/flash.c +++ b/zephyr/shim/src/flash.c @@ -3,17 +3,18 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "console.h" #include "drivers/cros_flash.h" #include "registers.h" #include "task.h" #include "util.h" +#include +#include +#include + +#include + LOG_MODULE_REGISTER(shim_flash, LOG_LEVEL_ERR); #if !DT_HAS_CHOSEN(cros_ec_flash_controller) diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c index d3aff5acb6..347640a7ab 100644 --- a/zephyr/shim/src/gpio.c +++ b/zephyr/shim/src/gpio.c @@ -11,11 +11,11 @@ #ifdef __REQUIRE_ZEPHYR_GPIOS__ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif +#include "cros_version.h" #include "gpio.h" #include "gpio/gpio.h" #include "ioexpander.h" #include "system.h" -#include "cros_version.h" LOG_MODULE_REGISTER(gpio_shim, LOG_LEVEL_ERR); diff --git a/zephyr/shim/src/gpio_int.c b/zephyr/shim/src/gpio_int.c index 8406f3abe8..c6339b497c 100644 --- a/zephyr/shim/src/gpio_int.c +++ b/zephyr/shim/src/gpio_int.c @@ -11,10 +11,10 @@ #ifdef __REQUIRE_ZEPHYR_GPIOS__ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif +#include "cros_version.h" #include "gpio.h" #include "gpio/gpio.h" #include "gpio/gpio_int.h" -#include "cros_version.h" LOG_MODULE_REGISTER(gpio_int, LOG_LEVEL_ERR); diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c index 3f11a578c5..b8f9b917e4 100644 --- a/zephyr/shim/src/hooks.c +++ b/zephyr/shim/src/hooks.c @@ -3,18 +3,19 @@ * found in the LICENSE file. */ -#include - -#include -#include #include "common.h" #include "console.h" #include "ec_tasks.h" -#include "hooks.h" #include "hook_types.h" +#include "hooks.h" #include "task.h" #include "timer.h" +#include + +#include +#include + /* * hook_registry maps each hook_type to the list of handlers for that hook type. * diff --git a/zephyr/shim/src/host_command.c b/zephyr/shim/src/host_command.c index c5a51332a1..16f5ae66d8 100644 --- a/zephyr/shim/src/host_command.c +++ b/zephyr/shim/src/host_command.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "host_command.h" #include "task.h" +#include + struct host_command *zephyr_find_host_command(int command) { STRUCT_SECTION_FOREACH(host_command, cmd) diff --git a/zephyr/shim/src/hwtimer.c b/zephyr/shim/src/hwtimer.c index d99f7a826b..cefbe4eb7f 100644 --- a/zephyr/shim/src/hwtimer.c +++ b/zephyr/shim/src/hwtimer.c @@ -3,10 +3,11 @@ * found in the LICENSE file. */ -#include +#include "hwtimer.h" + #include -#include "hwtimer.h" +#include uint64_t __hw_clock_source_read64(void) { diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c index 0a9fc41397..53766f1683 100644 --- a/zephyr/shim/src/i2c.c +++ b/zephyr/shim/src/i2c.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "i2c.h" #include "i2c/i2c.h" +#include +#include + /* * Initialize device bindings in i2c_devices. * This macro should be called from within DT_FOREACH_CHILD. diff --git a/zephyr/shim/src/ioex.c b/zephyr/shim/src/ioex.c index a5d685bc48..2b8d3b2cc4 100644 --- a/zephyr/shim/src/ioex.c +++ b/zephyr/shim/src/ioex.c @@ -3,10 +3,11 @@ * found in the LICENSE file. */ +#include "common.h" + #include #include #include -#include "common.h" #ifdef __REQUIRE_ZEPHYR_GPIOS__ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif diff --git a/zephyr/shim/src/ioex_drv.c b/zephyr/shim/src/ioex_drv.c index 3baa4777fd..0f1db5eb31 100644 --- a/zephyr/shim/src/ioex_drv.c +++ b/zephyr/shim/src/ioex_drv.c @@ -6,24 +6,26 @@ #define DT_DRV_COMPAT cros_ioex_port #define DT_DRV_COMPAT_CHIP cros_ioex_chip +#include + #include #include #include -#include #ifdef __REQUIRE_ZEPHYR_GPIOS__ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif +#include "common.h" +#include "config.h" #include "gpio.h" +#include "i2c.h" +#include "ioexpander.h" + #include #include #include #include #include #include -#include "common.h" -#include "config.h" -#include "i2c.h" -#include "ioexpander.h" /* Include drivers if enabled */ #ifdef CONFIG_PLATFORM_EC_IOEX_CCGXXF diff --git a/zephyr/shim/src/keyboard_raw.c b/zephyr/shim/src/keyboard_raw.c index 7d27e5ce39..73b3c2acaf 100644 --- a/zephyr/shim/src/keyboard_raw.c +++ b/zephyr/shim/src/keyboard_raw.c @@ -5,13 +5,14 @@ /* Functions needed by keyboard scanner module for Chrome EC */ +#include "drivers/cros_kb_raw.h" +#include "keyboard_raw.h" + #include -#include -#include #include +#include -#include "drivers/cros_kb_raw.h" -#include "keyboard_raw.h" +#include LOG_MODULE_REGISTER(shim_cros_kb_raw, LOG_LEVEL_ERR); diff --git a/zephyr/shim/src/keyscan.c b/zephyr/shim/src/keyscan.c index 514885379b..78a3e440be 100644 --- a/zephyr/shim/src/keyscan.c +++ b/zephyr/shim/src/keyscan.c @@ -5,11 +5,13 @@ #define DT_DRV_COMPAT cros_keyscan +#include "keyboard_scan.h" + #include + #include -#include -#include "keyboard_scan.h" +#include #if DT_NODE_EXISTS(DT_INST(0, cros_keyscan)) diff --git a/zephyr/shim/src/led_driver/led.c b/zephyr/shim/src/led_driver/led.c index 011632ac83..d673aa4c2e 100644 --- a/zephyr/shim/src/led_driver/led.c +++ b/zephyr/shim/src/led_driver/led.c @@ -5,8 +5,6 @@ * Power and battery LED control. */ -#include - #include "battery.h" #include "charge_manager.h" #include "charge_state.h" @@ -21,6 +19,7 @@ #include "util.h" #include +#include #include LOG_MODULE_REGISTER(led, LOG_LEVEL_ERR); diff --git a/zephyr/shim/src/log_backend_console_buffer.c b/zephyr/shim/src/log_backend_console_buffer.c index ee6992f916..3f455469c4 100644 --- a/zephyr/shim/src/log_backend_console_buffer.c +++ b/zephyr/shim/src/log_backend_console_buffer.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ +#include "console.h" + #include -#include #include - -#include "console.h" +#include static uint8_t char_out_buf[CONFIG_PLATFORM_EC_LOG_BACKEND_CONSOLE_BUFFER_TMP_BUF_SIZE]; diff --git a/zephyr/shim/src/motionsense_sensors.c b/zephyr/shim/src/motionsense_sensors.c index 8d886192ac..72bb677af6 100644 --- a/zephyr/shim/src/motionsense_sensors.c +++ b/zephyr/shim/src/motionsense_sensors.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include -#include "common.h" #include "accelgyro.h" +#include "common.h" #include "cros_cbi.h" -#include "hooks.h" #include "gpio/gpio_int.h" +#include "hooks.h" #include "motionsense_sensors.h" +#include + LOG_MODULE_REGISTER(shim_cros_motionsense_sensors); #define SENSOR_MUTEX_NODE DT_PATH(motionsense_mutex) diff --git a/zephyr/shim/src/panic.c b/zephyr/shim/src/panic.c index 9ff8a46f62..2ac8328e9e 100644 --- a/zephyr/shim/src/panic.c +++ b/zephyr/shim/src/panic.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ +#include "common.h" +#include "panic.h" + #include #include +#include #include #include -#include - -#include "common.h" -#include "panic.h" /* * Arch-specific configuration diff --git a/zephyr/shim/src/power.c b/zephyr/shim/src/power.c index 51ae788d98..ab58cf391d 100644 --- a/zephyr/shim/src/power.c +++ b/zephyr/shim/src/power.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "console.h" #include "power.h" #include "power/power.h" +#include + #define GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid) \ DT_STRING_UPPER_TOKEN(DT_PROP(cid, power_gpio_pin), enum_name) #define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \ diff --git a/zephyr/shim/src/ppc.c b/zephyr/shim/src/ppc.c index c4c54d002f..c15c6900b1 100644 --- a/zephyr/shim/src/ppc.c +++ b/zephyr/shim/src/ppc.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include -#include "usbc_ppc.h" +#include "usbc/ppc.h" #include "usbc/ppc_aoz1380.h" #include "usbc/ppc_nx20p348x.h" #include "usbc/ppc_rt1739.h" #include "usbc/ppc_sn5s330.h" #include "usbc/ppc_syv682x.h" -#include "usbc/ppc.h" +#include "usbc_ppc.h" + +#include #if DT_HAS_COMPAT_STATUS_OKAY(AOZ1380_COMPAT) || \ DT_HAS_COMPAT_STATUS_OKAY(NX20P348X_COMPAT) || \ diff --git a/zephyr/shim/src/pwm_hc.c b/zephyr/shim/src/pwm_hc.c index c0350c733f..3c7b2f1737 100644 --- a/zephyr/shim/src/pwm_hc.c +++ b/zephyr/shim/src/pwm_hc.c @@ -3,20 +3,20 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "common.h" #include "console.h" #include "drivers/cros_displight.h" #include "ec_commands.h" #include "host_command.h" -#include "pwm.h" #include "keyboard_backlight.h" +#include "pwm.h" #include "util.h" +#include +#include +#include +#include + LOG_MODULE_REGISTER(pwm_shim, LOG_LEVEL_ERR); #define HAS_PWM_GENERIC_CHANNEL(compat) \ diff --git a/zephyr/shim/src/pwm_led.c b/zephyr/shim/src/pwm_led.c index 498c543ffb..81cc3a9c28 100644 --- a/zephyr/shim/src/pwm_led.c +++ b/zephyr/shim/src/pwm_led.c @@ -6,6 +6,7 @@ #define DT_DRV_COMPAT cros_ec_pwm_leds #include + #include #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) diff --git a/zephyr/shim/src/rtc.c b/zephyr/shim/src/rtc.c index c8a0511c95..3acf6a3bb6 100644 --- a/zephyr/shim/src/rtc.c +++ b/zephyr/shim/src/rtc.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "console.h" #include "drivers/cros_rtc.h" #include "hooks.h" @@ -13,6 +10,9 @@ #include "system.h" #include "util.h" +#include +#include + LOG_MODULE_REGISTER(shim_cros_rtc, LOG_LEVEL_ERR); #define CROS_RTC_NODE DT_CHOSEN(cros_rtc) diff --git a/zephyr/shim/src/switchcap_gpio.c b/zephyr/shim/src/switchcap_gpio.c index 23bed493c8..54d69a3672 100644 --- a/zephyr/shim/src/switchcap_gpio.c +++ b/zephyr/shim/src/switchcap_gpio.c @@ -3,10 +3,11 @@ * found in the LICENSE file. */ +#include "common.h" + #include #include #include -#include "common.h" /* TODO(b/218600962): Consolidate switchcap code. */ diff --git a/zephyr/shim/src/switchcap_ln9310.c b/zephyr/shim/src/switchcap_ln9310.c index 7c5fd4ed8d..f3b037bfd4 100644 --- a/zephyr/shim/src/switchcap_ln9310.c +++ b/zephyr/shim/src/switchcap_ln9310.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -#include -#include #include "common.h" #include "ln9310.h" +#include +#include + /* TODO(b/218600962): Consolidate switchcap code. */ #if DT_NODE_EXISTS(DT_PATH(switchcap)) diff --git a/zephyr/shim/src/system.c b/zephyr/shim/src/system.c index 99f4f4c3e1..0b47782b42 100644 --- a/zephyr/shim/src/system.c +++ b/zephyr/shim/src/system.c @@ -3,17 +3,18 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "common.h" #include "console.h" #include "cros_version.h" #include "system.h" #include "watchdog.h" +#include +#include +#include + +#include + #define BBRAM_REGION_PD0 DT_PATH(named_bbram_regions, pd0) #define BBRAM_REGION_PD1 DT_PATH(named_bbram_regions, pd1) #define BBRAM_REGION_PD2 DT_PATH(named_bbram_regions, pd2) diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c index a03cf4daa8..68ebbbc482 100644 --- a/zephyr/shim/src/tasks.c +++ b/zephyr/shim/src/tasks.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "common.h" #include "host_command.h" -#include "timer.h" #include "task.h" +#include "timer.h" + +#include +#include +#include +#include /* Ensure that the idle task is at lower priority than lowest priority task. */ BUILD_ASSERT(EC_TASK_PRIORITY(EC_TASK_PRIO_LOWEST) < K_IDLE_PRIO, diff --git a/zephyr/shim/src/tcpc.c b/zephyr/shim/src/tcpc.c index ba251a196b..eecad4d6ad 100644 --- a/zephyr/shim/src/tcpc.c +++ b/zephyr/shim/src/tcpc.c @@ -3,10 +3,8 @@ * found in the LICENSE file. */ -#include -#include -#include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" #include "usbc/tcpc_anx7447.h" #include "usbc/tcpc_anx7447_emul.h" #include "usbc/tcpc_ccgxxf.h" @@ -20,6 +18,9 @@ #include "usbc/tcpci.h" #include "usbc/utils.h" +#include +#include + #define HAS_TCPC_PROP(usbc_id) \ COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, tcpc), (|| 1), ()) diff --git a/zephyr/shim/src/tcpc_nct38xx.c b/zephyr/shim/src/tcpc_nct38xx.c index 9580759a6c..5d3f5ac25c 100644 --- a/zephyr/shim/src/tcpc_nct38xx.c +++ b/zephyr/shim/src/tcpc_nct38xx.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "config.h" #include "usbc/tcpc_nct38xx.h" #include "usbc/utils.h" +#include +#include + #define GPIO_DEV_WITH_COMMA(id) DEVICE_DT_GET(DT_PHANDLE(id, gpio_dev)), #define GPIO_DEV_BINDING(usbc_id, tcpc_id) \ diff --git a/zephyr/shim/src/thermal.c b/zephyr/shim/src/thermal.c index abe6b7da9e..fd1b0bfb52 100644 --- a/zephyr/shim/src/thermal.c +++ b/zephyr/shim/src/thermal.c @@ -3,9 +3,9 @@ * found in the LICENSE file. */ +#include "ec_commands.h" #include "temp_sensor.h" #include "temp_sensor/temp_sensor.h" -#include "ec_commands.h" #define THERMAL_CONFIG(node_id) \ [TEMP_SENSOR_ID(node_id)] = { \ diff --git a/zephyr/shim/src/usb_muxes.c b/zephyr/shim/src/usb_muxes.c index 3f81e97787..af86cec0cd 100644 --- a/zephyr/shim/src/usb_muxes.c +++ b/zephyr/shim/src/usb_muxes.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -#include -#include #include "usb_mux.h" #include "usbc/usb_muxes.h" +#include +#include + /** * This prevents creating struct usb_mux usb_muxes[] for platforms that didn't * migrate USB mux configuration to DTS yet. diff --git a/zephyr/shim/src/usba.c b/zephyr/shim/src/usba.c index c8c056bad0..a7360a9ddb 100644 --- a/zephyr/shim/src/usba.c +++ b/zephyr/shim/src/usba.c @@ -5,9 +5,10 @@ #define DT_DRV_COMPAT cros_ec_usba_port_enable_pins -#include #include "hooks.h" +#include + #define PIN(node_id, prop, idx) \ GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, idx)), diff --git a/zephyr/shim/src/watchdog.c b/zephyr/shim/src/watchdog.c index eb82f228d5..413ba50484 100644 --- a/zephyr/shim/src/watchdog.c +++ b/zephyr/shim/src/watchdog.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "config.h" #include "hooks.h" #include "watchdog.h" +#include +#include +#include +#include + LOG_MODULE_REGISTER(watchdog_shim, LOG_LEVEL_ERR); #define wdt DEVICE_DT_GET(DT_CHOSEN(cros_ec_watchdog)) -- cgit v1.2.1 From 4e5c08ec698bd54eeac6099e8d0d27db071fdf00 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 14 Nov 2022 15:47:27 +0000 Subject: zephyr: Kconfig: fix wrong helptext indentation Fix wrong indentation of PLATFORM_EC_KEYBOARD_CUSTOMIZATION helptext. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I3021373f917e85c5d06a2b4d1bb28d65f64d5fce Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021955 Reviewed-by: Wai-Hong Tam Code-Coverage: Zoss --- zephyr/Kconfig.keyboard | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/zephyr/Kconfig.keyboard b/zephyr/Kconfig.keyboard index 444c20950c..15ca7d20e7 100644 --- a/zephyr/Kconfig.keyboard +++ b/zephyr/Kconfig.keyboard @@ -94,17 +94,17 @@ config PLATFORM_EC_KEYBOARD_VIVALDI config PLATFORM_EC_KEYBOARD_CUSTOMIZATION bool "Support keyboard customization" help - Enable support for customization keyboard, some boards need to custom matrix - because those board keyboard layout doesn't follow a common matrix. + Enable support for customization keyboard, some boards need to custom matrix + because those board keyboard layout doesn't follow a common matrix. - If define, the board layer - needs to implement: - 1. the scancode_set2 and keycap_label array - 2. keyboard_customization.h which is similar to keyboard_config.h + If define, the board layer + needs to implement: + 1. the scancode_set2 and keycap_label array + 2. keyboard_customization.h which is similar to keyboard_config.h - Note that if your board has the standard chromeos keyboard layout other - than the top row, and you are looking only for top row customization, - then you should be looking at overriding board_vivaldi_keybd_config() instead. + Note that if your board has the standard chromeos keyboard layout other + than the top row, and you are looking only for top row customization, + then you should be looking at overriding board_vivaldi_keybd_config() instead. choice PLATFORM_EC_KEYBOARD_PWRBTN_MODE prompt "Select the impact of pressing the power button" -- cgit v1.2.1 From 427adac454da3718fda4de7532c599504bdc3924 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 14 Nov 2022 16:34:16 +0000 Subject: zephyr: max695x: rework the binding, various cleanups Various cleanups on the max695x driver: - rename the binding to the Zephyr canonical vendor,device format - move the example in the binding description - make the PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY option automatic and drop the explicit config entries - find the node by compatible and drop the nodelabel - drop the label property BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I9b90d1b8bb3e3df9b76b2631a24f51133c4b73f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022154 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- zephyr/Kconfig.led | 2 ++ zephyr/dts/bindings/led/maxim,max695x.yaml | 18 ++++++++++++++++++ zephyr/dts/bindings/led/maxim,seven-seg-display.yaml | 19 ------------------- .../intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts | 5 ++--- zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 3 --- .../intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts | 5 ++--- zephyr/program/intelrvp/adlrvp/prj.conf | 3 --- .../intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts | 5 ++--- zephyr/program/intelrvp/mtlrvp/prj.conf | 3 --- zephyr/shim/include/config_chip.h | 2 +- 10 files changed, 27 insertions(+), 38 deletions(-) create mode 100644 zephyr/dts/bindings/led/maxim,max695x.yaml delete mode 100644 zephyr/dts/bindings/led/maxim,seven-seg-display.yaml diff --git a/zephyr/Kconfig.led b/zephyr/Kconfig.led index d3d50ccc56..90f59f2fff 100644 --- a/zephyr/Kconfig.led +++ b/zephyr/Kconfig.led @@ -167,6 +167,8 @@ endif # PLATFORM_EC_LED_COMMON config PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY bool "MAX695X Seven Segment Display" + default y + depends on DT_HAS_MAXIM_MAX695X_ENABLED help Enable this to support MAX6958/MAX6959 7-Segment LED Display. The MAX6958/MAX6959 is a compact multiplexed common - cathode display diff --git a/zephyr/dts/bindings/led/maxim,max695x.yaml b/zephyr/dts/bindings/led/maxim,max695x.yaml new file mode 100644 index 0000000000..a219512b0d --- /dev/null +++ b/zephyr/dts/bindings/led/maxim,max695x.yaml @@ -0,0 +1,18 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: | + MAX6958/MAX6959 7-Segment LED Display + + Example configuration + + max695x@38 { + compatible = "maxim,max695x"; + reg = <0x38>; + }; + + +compatible: "maxim,max695x" + +include: i2c-device.yaml diff --git a/zephyr/dts/bindings/led/maxim,seven-seg-display.yaml b/zephyr/dts/bindings/led/maxim,seven-seg-display.yaml deleted file mode 100644 index d66a0cdca2..0000000000 --- a/zephyr/dts/bindings/led/maxim,seven-seg-display.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: MAX6958/MAX6959 7-Segment LED Display - -compatible: "maxim,seven-seg-display" - -include: i2c-device.yaml - -# -# examples: -# -# seven_seg_display: max695x-seven-seg-display@38 { -# compatible = "maxim,seven-seg-display"; -# reg = <0x38>; -# label = "MAX695X_SEVEN_SEG_DISPLAY"; -# }; -# diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts index 527a62e776..39fd720290 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts @@ -80,10 +80,9 @@ <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>; }; - seven_seg_display: max695x-seven-seg-display@38 { - compatible = "maxim,seven-seg-display"; + max695x@38 { + compatible = "maxim,max695x"; reg = <0x38>; - label = "MAX695X_SEVEN_SEG_DISPLAY"; }; charger: isl9241@9 { diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf index bca7262642..f38982e87d 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf @@ -70,9 +70,6 @@ CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y # H1 issues second reset CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n -# 7-Segment Display -CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=n - # Debug options # Enable flash console commands CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts index 79723beabd..b8fbd6656d 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts @@ -112,10 +112,9 @@ <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>; }; - seven_seg_display: max695x-seven-seg-display@38 { - compatible = "maxim,seven-seg-display"; + max695x@38 { + compatible = "maxim,max695x"; reg = <0x38>; - label = "MAX695X_SEVEN_SEG_DISPLAY"; }; charger: isl9241@9 { diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index c2d4425d73..64cf5a2a4a 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -63,8 +63,5 @@ CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y # IOEX CONFIG_PLATFORM_EC_IOEX_PCA9675=y -# 7-Segment Display -CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y - # eSPI CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150 diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts index 44f283071b..25ad865dd7 100644 --- a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts @@ -105,10 +105,9 @@ reg = <0x39>; }; - seven_seg_display: max695x-seven-seg-display@38 { - compatible = "maxim,seven-seg-display"; + max695x@38 { + compatible = "maxim,max695x"; reg = <0x38>; - label = "MAX695X_SEVEN_SEG_DISPLAY"; }; charger: isl9241@9 { diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index 3b0b0fa32e..281d40a271 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -67,6 +67,3 @@ CONFIG_PLATFORM_EC_USB_PD_USB4=y CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y CONFIG_PLATFORM_EC_USB_PD_PORT_1_SHARED=y - -# 7-Segment Display -CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 7b3abce82e..fc0e434403 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -2107,7 +2107,7 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #undef CONFIG_MAX695X_SEVEN_SEGMENT_DISPLAY #ifdef CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY #define CONFIG_MAX695X_SEVEN_SEGMENT_DISPLAY -#define PORT80_I2C_ADDR DT_REG_ADDR(DT_NODELABEL(seven_seg_display)) +#define PORT80_I2C_ADDR DT_REG_ADDR(DT_INST(0, maxim_max695x)) #endif #undef CONFIG_CMD_SEVEN_SEG_DISPLAY -- cgit v1.2.1 From d42bcfdb3b2da8041d4a648664be710c41412e53 Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Tue, 15 Nov 2022 14:40:39 -0700 Subject: zephyr: Add check for twister.json before using it Check if twister.json exists before parsing for test results and skipped tests BUG=None BRANCH=NONE TEST=./twister -T zephyr/test/math ./twister -T zephyr/test/math_not_exist Signed-off-by: Al Semjonovs Change-Id: Ifc3983d4ceb085d76dd0a5c7ee1937508caaa2b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025838 Reviewed-by: Tristan Honscheid Code-Coverage: Zoss --- util/twister_launcher.py | 71 ++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/util/twister_launcher.py b/util/twister_launcher.py index 023ffbd2fa..c67d15d97d 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -176,28 +176,32 @@ def upload_results(ec_base, outdir): if is_rdb_login(): json_path = pathlib.Path(outdir) / "twister.json" - cmd = [ - "rdb", - "stream", - "-new", - "-realm", - "chromium:public", - "--", - str(ec_base / "util/zephyr_to_resultdb.py"), - "--result=" + str(json_path), - "--upload=True", - ] - - start_time = time.time() - ret = subprocess.run(cmd, capture_output=True, text=True, check=True) - end_time = time.time() - - # Extract URL to test report from captured output - rdb_url = re.search( - r"(?Phttps?://[^\s]+)", ret.stderr.split("\n")[0] - ).group("url") - print(f"\nTEST RESULTS ({end_time - start_time:.3f}s): {rdb_url}\n") - flag = ret.returncode == 0 + + if json_path.exists(): + cmd = [ + "rdb", + "stream", + "-new", + "-realm", + "chromium:public", + "--", + str(ec_base / "util/zephyr_to_resultdb.py"), + "--result=" + str(json_path), + "--upload=True", + ] + + start_time = time.time() + ret = subprocess.run( + cmd, capture_output=True, text=True, check=True + ) + end_time = time.time() + + # Extract URL to test report from captured output + rdb_url = re.search( + r"(?Phttps?://[^\s]+)", ret.stderr.split("\n")[0] + ).group("url") + print(f"\nTEST RESULTS ({end_time - start_time:.3f}s): {rdb_url}\n") + flag = ret.returncode == 0 else: print("Unable to upload test results, please run 'rdb auth-login'\n") @@ -208,17 +212,18 @@ def check_for_skipped_tests(outdir): """Checks Twister json test report for skipped tests""" found_skipped = False json_path = pathlib.Path(outdir) / "twister.json" - with open(json_path) as file: - data = json.load(file) - - for testsuite in data["testsuites"]: - for testcase in testsuite["testcases"]: - if testcase["status"] == "skipped": - tc_name = testcase["identifier"] - print(f"TEST SKIPPED: {tc_name}") - found_skipped = True - - file.close() + if json_path.exists(): + with open(json_path) as file: + data = json.load(file) + + for testsuite in data["testsuites"]: + for testcase in testsuite["testcases"]: + if testcase["status"] == "skipped": + tc_name = testcase["identifier"] + print(f"TEST SKIPPED: {tc_name}") + found_skipped = True + + file.close() return found_skipped -- cgit v1.2.1 From 41cf03de4c8c0cc1bf0297796893f925e8ee1cd8 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 15 Nov 2022 13:36:33 -0700 Subject: fuel_gauge: Simplify edge cases Update the local static function to take the type in and use an assert since the bound checking is done at the call site. Also, improve the bounds checking to >= BATTERY_TYPE_COUNT. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: Ia79bdaafdcd6c48d29d8cef5f981f746066d35b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030056 Code-Coverage: Zoss Reviewed-by: Aaron Massey --- common/battery_fuel_gauge.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/common/battery_fuel_gauge.c b/common/battery_fuel_gauge.c index 88f941f194..e6aca68472 100644 --- a/common/battery_fuel_gauge.c +++ b/common/battery_fuel_gauge.c @@ -237,17 +237,12 @@ enum ec_error_list battery_sleep_fuel_gauge(void) return sb_write(sleep_command->reg_addr, sleep_command->reg_data); } -static enum ec_error_list battery_get_fet_status_regval(int *regval) +static enum ec_error_list battery_get_fet_status_regval(int type, int *regval) { int rv; uint8_t data[6]; - int type = get_battery_type(); - /* If battery type is not known, can't check CHG/DCHG FETs */ - if (type == BATTERY_TYPE_COUNT) { - /* Still don't know, so return here */ - return EC_ERROR_BUSY; - } + ASSERT(type < BATTERY_TYPE_COUNT); /* Read the status of charge/discharge FETs */ if (board_battery_info[type].fuel_gauge.fet.mfgacc_support == 1) { @@ -270,7 +265,7 @@ int battery_is_charge_fet_disabled(void) int type = get_battery_type(); /* If battery type is not known, can't check CHG/DCHG FETs */ - if (type == BATTERY_TYPE_COUNT) { + if (type >= BATTERY_TYPE_COUNT) { /* Still don't know, so return here */ return -1; } @@ -281,7 +276,7 @@ int battery_is_charge_fet_disabled(void) if (!board_battery_info[type].fuel_gauge.fet.cfet_mask) return 0; - rv = battery_get_fet_status_regval(®); + rv = battery_get_fet_status_regval(type, ®); if (rv) return -1; @@ -307,12 +302,12 @@ enum battery_disconnect_state battery_get_disconnect_state(void) int type = get_battery_type(); /* If battery type is not known, can't check CHG/DCHG FETs */ - if (type == BATTERY_TYPE_COUNT) { + if (type >= BATTERY_TYPE_COUNT) { /* Still don't know, so return here */ return BATTERY_DISCONNECT_ERROR; } - if (battery_get_fet_status_regval(®)) + if (battery_get_fet_status_regval(type, ®)) return BATTERY_DISCONNECT_ERROR; if ((reg & board_battery_info[type].fuel_gauge.fet.reg_mask) == -- cgit v1.2.1 From b5b4376ce9d5257bc22d6a4d3350477b2ddea15a Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Mon, 14 Nov 2022 10:36:44 -0700 Subject: test: add tests for battery_fuel_gauge - Add error handling tests for fuel gauge. - Add cutoff handling tests for fuel gauge. - Add tests for default implementation of the get_default_battery_type - Add tests for battery_sleep_fuel_gauge - Add tests for battery_is_charge_fet_disabled - Add tests for battery_get_disconnect_state BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I87552b936184c6152c4be4a64bd42278ce5b5ca2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026562 Code-Coverage: Zoss Reviewed-by: Aaron Massey --- common/battery_fuel_gauge.c | 14 +- zephyr/emul/emul_smart_battery.c | 6 +- zephyr/shim/src/battery.c | 2 +- zephyr/test/drivers/boards/native_posix.overlay | 25 +++ zephyr/test/drivers/default/src/battery.c | 223 +++++++++++++++++++++++- 5 files changed, 264 insertions(+), 6 deletions(-) diff --git a/common/battery_fuel_gauge.c b/common/battery_fuel_gauge.c index e6aca68472..6a62c21479 100644 --- a/common/battery_fuel_gauge.c +++ b/common/battery_fuel_gauge.c @@ -7,6 +7,7 @@ #include "battery_fuel_gauge.h" #include "battery_smart.h" +#include "builtin/assert.h" #include "console.h" #include "hooks.h" #include "i2c.h" @@ -22,7 +23,8 @@ * a device name has been specified in the board_battery_info table, * then both the manufacturer and device name must match. */ -static bool authenticate_battery_type(int index, char *manuf_name) +test_export_static bool authenticate_battery_type(int index, + const char *manuf_name) { char device_name[32]; @@ -84,6 +86,12 @@ void battery_set_fixed_battery_type(int type) } #endif /* CONFIG_BATTERY_TYPE_NO_AUTO_DETECT */ +/** + * Allows us to override the battery in order to select the battery which has + * the right configuration for the test. + */ +test_export_static int battery_fuel_gauge_type_override = -1; + /* Get type of the battery connected on the board */ static int get_battery_type(void) { @@ -91,6 +99,10 @@ static int get_battery_type(void) int i; static enum battery_type battery_type = BATTERY_TYPE_COUNT; + if (IS_ENABLED(TEST_BUILD) && battery_fuel_gauge_type_override >= 0) { + return battery_fuel_gauge_type_override; + } + /* * If battery_type is not the default value, then can return here * as there is no need to query the fuel gauge. diff --git a/zephyr/emul/emul_smart_battery.c b/zephyr/emul/emul_smart_battery.c index 3f79ec2019..c064f093bf 100644 --- a/zephyr/emul/emul_smart_battery.c +++ b/zephyr/emul/emul_smart_battery.c @@ -788,8 +788,10 @@ static int sbat_emul_access_reg(const struct emul *emul, int reg, int bytes, static int sbat_emul_init(const struct emul *emul, const struct device *parent) { struct sbat_emul_data *data = emul->data; + const struct i2c_common_emul_cfg *cfg = emul->cfg; data->common.i2c = parent; + data->common.cfg = cfg; i2c_common_emul_init(&data->common); @@ -901,14 +903,14 @@ static void emul_smart_battery_reset_capacity(const struct emul *emul) } #define SBAT_EMUL_RESET_RULE_AFTER(n) \ - emul_smart_battery_reset_capacity(EMUL_DT_GET(DT_DRV_INST(n))) + emul_smart_battery_reset_capacity(EMUL_DT_GET(DT_DRV_INST(n))); static void emul_sbat_reset(const struct ztest_unit_test *test, void *data) { ARG_UNUSED(test); ARG_UNUSED(data); - DT_INST_FOREACH_STATUS_OKAY(SBAT_EMUL_RESET_RULE_AFTER); + DT_INST_FOREACH_STATUS_OKAY(SBAT_EMUL_RESET_RULE_AFTER) } ZTEST_RULE(emul_smart_battery_reset, NULL, emul_sbat_reset); diff --git a/zephyr/shim/src/battery.c b/zephyr/shim/src/battery.c index c70610a9e9..8485f1314e 100644 --- a/zephyr/shim/src/battery.c +++ b/zephyr/shim/src/battery.c @@ -17,7 +17,7 @@ .reg_data = DT_PROP(node, ship_mode_reg_data), \ }, \ .sleep_mode = { \ - .sleep_supported = DT_PROP_OR(node, sleep_mode_supported, 0), \ + .sleep_supported = DT_PROP_OR(node, sleep_mode_support, 0), \ .reg_addr = DT_PROP_OR(node, sleep_mode_reg_addr, 0), \ .reg_data = DT_PROP_OR(node, sleep_mode_reg_data, 0), \ }, \ diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index f56eec97c6..72b7bef5c0 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -385,6 +385,19 @@ default_battery: lgc_ac17a8m { compatible = "lgc,ac17a8m", "battery-smart"; }; + ap16l5j { + compatible = "panasonic,ap16l5j", "battery-smart"; + ship_mode_wb_support = <1>; + sleep_mode_support = <1>; + fet_mfgacc_support = <1>; + }; + ap16l8j { + compatible = "lgc,ap16l8j", "battery-smart"; + ship_mode_wb_support = <1>; + sleep_mode_support = <1>; + fet_cfet_mask = <0>; + fet_mfgacc_support = <1>; + }; }; cbi-ssfc { @@ -1076,6 +1089,18 @@ dev-name = "AC17A8M"; }; + battery2: sb@3a { + compatible = "zephyr,smart-battery"; + reg = <0x3a>; + cycle-count = <99>; + version = "BATTERY_SPEC_VER_1_1_WITH_PEC"; + /* Real battery voltages are multiples of 4.4V. */ + desired-charg-volt = <5000>; + desired-charg-cur = <1000>; + mf-name = "PANASONIC"; + dev-name = "AP16L5J"; + }; + bma_emul: bma@18 { compatible = "zephyr,bma255"; reg = <0x18>; diff --git a/zephyr/test/drivers/default/src/battery.c b/zephyr/test/drivers/default/src/battery.c index 5e57537a28..02f85d9662 100644 --- a/zephyr/test/drivers/default/src/battery.c +++ b/zephyr/test/drivers/default/src/battery.c @@ -4,25 +4,77 @@ */ #include "battery.h" +#include "battery_fuel_gauge.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_smart_battery.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include #include #include +#include #include #include #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) #define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) +FAKE_VALUE_FUNC(int, battery2_write_func, const struct emul *, int, uint8_t, + int, void *); +FAKE_VALUE_FUNC(int, battery2_read_func, const struct emul *, int, uint8_t *, + int, void *); + +bool authenticate_battery_type(int index, const char *manuf_name); + +extern int battery_fuel_gauge_type_override; + +struct battery_fixture { + struct i2c_common_emul_data *battery_i2c_common; + i2c_common_emul_finish_write_func finish_write_func; + i2c_common_emul_start_read_func start_read_func; +}; + +static void *battery_setup(void) +{ + static struct battery_fixture fixture; + static const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(battery)); + + fixture.battery_i2c_common = + emul_smart_battery_get_i2c_common_data(emul); + + return &fixture; +} + +static void battery_before(void *data) +{ + struct battery_fixture *fixture = data; + + RESET_FAKE(battery2_write_func); + RESET_FAKE(battery2_read_func); + fixture->finish_write_func = fixture->battery_i2c_common->finish_write; + fixture->start_read_func = fixture->battery_i2c_common->start_read; +} + static void battery_after(void *data) { + struct battery_fixture *fixture = data; const struct device *dev = DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios)); /* Set default state (battery is present) */ gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, 0); + battery_fuel_gauge_type_override = -1; + + i2c_common_emul_set_write_func(fixture->battery_i2c_common, NULL, NULL); + i2c_common_emul_set_read_func(fixture->battery_i2c_common, NULL, NULL); + fixture->battery_i2c_common->finish_write = fixture->finish_write_func; + fixture->battery_i2c_common->start_read = fixture->start_read_func; } +ZTEST_SUITE(battery, drivers_predicate_post_main, battery_setup, battery_before, + battery_after, NULL); + ZTEST_USER(battery, test_battery_is_present_gpio) { const struct device *dev = @@ -37,5 +89,172 @@ ZTEST_USER(battery, test_battery_is_present_gpio) zassert_equal(BP_NO, battery_is_present()); } -ZTEST_SUITE(battery, drivers_predicate_post_main, NULL, NULL, battery_after, - NULL); +ZTEST(battery, test_authenticate_battery_type) +{ + /* Invalid index */ + zassert_false(authenticate_battery_type(BATTERY_TYPE_COUNT, NULL)); + /* Use fuel-gauge 1's manufacturer name for index 0 */ + zassert_false(authenticate_battery_type( + 0, board_battery_info[1].fuel_gauge.manuf_name)); + /* Use the correct manufacturer name, but wrong device name (because the + * index is 1 and not 0) + */ + zassert_false(authenticate_battery_type( + 1, board_battery_info[1].fuel_gauge.manuf_name)); +} + +ZTEST(battery, test_board_get_default_battery_type) +{ + zassert_equal(DEFAULT_BATTERY_TYPE, board_get_default_battery_type()); +} + +ZTEST_F(battery, test_board_cutoff_actuates_driver) +{ + /* We check the return type because board_is_cut_off() is set outside of + * board_cut_off_battery() and may be changed by other factors. + */ + + /* Try with invalid battery type */ + battery_fuel_gauge_type_override = BATTERY_TYPE_COUNT; + zassert_equal(EC_RES_ERROR, board_cut_off_battery()); + + /* Setup error conditions for battery 1*/ + battery_fuel_gauge_type_override = 1; + fixture->battery_i2c_common->finish_write = NULL; + i2c_common_emul_set_write_func(fixture->battery_i2c_common, + battery2_write_func, NULL); + + /* Check that i2c error returns EC_RES_ERROR */ + battery2_write_func_fake.return_val = -1; + zassert_equal(EC_RES_ERROR, board_cut_off_battery()); + + /* Check for OK when i2c succeeds */ + battery2_write_func_fake.return_val = 0; + zassert_ok(board_cut_off_battery()); +} + +ZTEST_F(battery, test_sleep) +{ + /* Try with invalid battery type */ + battery_fuel_gauge_type_override = BATTERY_TYPE_COUNT; + zassert_equal(EC_ERROR_UNKNOWN, battery_sleep_fuel_gauge()); + + /* Check 1st battery (lgc,ac17a8m) */ + battery_fuel_gauge_type_override = 0; + zassert_equal(EC_ERROR_UNIMPLEMENTED, battery_sleep_fuel_gauge()); + + /* Check 2nd battery (panasonic,ap15l5j) */ + battery_fuel_gauge_type_override = 1; + fixture->battery_i2c_common->finish_write = NULL; + i2c_common_emul_set_write_func(fixture->battery_i2c_common, + battery2_write_func, NULL); + zassert_ok(battery_sleep_fuel_gauge()); +} + +struct battery2_read_data { + size_t count; + const uint8_t *values; +}; + +static int battery2_read(const struct emul *target, int reg, uint8_t *val, + int bytes, void *d) +{ + struct battery2_read_data *data = d; + + if (bytes < data->count) { + *val = data->values[bytes]; + } + + return 0; +} + +ZTEST(battery, test_is_charge_fet_disabled__invalid_battery_type) +{ + battery_fuel_gauge_type_override = BATTERY_TYPE_COUNT; + zassert_equal(-1, battery_is_charge_fet_disabled()); +} + +ZTEST(battery, test_is_charge_fet_disabled__cfet_mask_is_0) +{ + battery_fuel_gauge_type_override = 2; + zassert_equal(0, battery_is_charge_fet_disabled()); +} + +ZTEST_F(battery, test_is_charge_fet_disabled__i2c_error) +{ + /* Set the battery to battery 1 */ + battery_fuel_gauge_type_override = 1; + + /* Override the finish_write common callback since we don't actually + * want to be messing with the emulator. + */ + fixture->battery_i2c_common->finish_write = NULL; + + /* Set up an error condition for battery 1 to fail writing to i2c */ + battery2_write_func_fake.return_val = -1; + i2c_common_emul_set_write_func(fixture->battery_i2c_common, + battery2_write_func, NULL); + + /* Verify the error */ + zassert_equal(-1, battery_is_charge_fet_disabled()); +} + +ZTEST_F(battery, test_is_charge_fet_disabled) +{ + /* Custom data expected to be read from the battery */ + static const uint8_t values[] = { 0x20, 0x54, 0x00, 0x00, + 0x00, 0x00, 0x00 }; + static struct battery2_read_data data = { + .count = ARRAY_SIZE(values), + .values = values, + }; + + /* Set up the fake read function */ + battery2_read_func_fake.custom_fake = battery2_read; + i2c_common_emul_set_read_func(fixture->battery_i2c_common, + battery2_read_func, &data); + + /* Override the finish_write and start_read common callback since we + * don't actually want to be messing with the emulator. + */ + fixture->battery_i2c_common->finish_write = NULL; + fixture->battery_i2c_common->start_read = NULL; + + zassert_equal(1, battery_is_charge_fet_disabled()); +} + +ZTEST(battery, test_get_disconnect_state__invalid_battery_type) +{ + battery_fuel_gauge_type_override = BATTERY_TYPE_COUNT; + zassert_equal(BATTERY_DISCONNECT_ERROR, battery_get_disconnect_state()); +} + +ZTEST_F(battery, test_get_disconnect_state__fail_i2c_read) +{ + /* Use battery 0 */ + battery_fuel_gauge_type_override = 0; + + /* Configure i2c to fail on read */ + battery2_read_func_fake.return_val = -1; + i2c_common_emul_set_read_func(fixture->battery_i2c_common, + battery2_read_func, NULL); + + /* Check for disconnect error */ + zassert_equal(BATTERY_DISCONNECT_ERROR, battery_get_disconnect_state()); +} + +ZTEST_F(battery, test_get_disconnect_state) +{ + static const uint8_t values[] = { 0x00, 0x20 }; + static struct battery2_read_data data = { + .count = ARRAY_SIZE(values), + .values = values, + }; + + /* Enable i2c reads and set them to always return 0x2000 */ + battery2_read_func_fake.custom_fake = battery2_read; + i2c_common_emul_set_read_func(fixture->battery_i2c_common, + battery2_read_func, &data); + + zassert_equal(BATTERY_DISCONNECTED, battery_get_disconnect_state()); +} -- cgit v1.2.1 From 18adebdb14df3653def6195657a37c839c9f322f Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Tue, 15 Nov 2022 14:39:48 -0800 Subject: craask: fix lid accel interrupt handler setting BUG=b:254380338, b:258749707 BRANCH=nissa TEST=Check motionsense_simpleclient works for the lid accel. LOW_COVERAGE_REASON=board-specific code is not tested Fixes: 2fbedc6447dd1 ("craask: use interrupts for lid accel") Signed-off-by: Gwendal Grignou Change-Id: I1d0b2e44a4fceb5844869e72ed687d1680c65d1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029516 Reviewed-by: Peter Marheine --- zephyr/program/nissa/craask/src/form_factor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/program/nissa/craask/src/form_factor.c b/zephyr/program/nissa/craask/src/form_factor.c index 285901ea42..9f3267ab3d 100644 --- a/zephyr/program/nissa/craask/src/form_factor.c +++ b/zephyr/program/nissa/craask/src/form_factor.c @@ -50,9 +50,9 @@ void motion_interrupt(enum gpio_signal signal) void lid_accel_interrupt(enum gpio_signal signal) { if (use_alt_lid_accel) - lis2dw12_interrupt(signal); - else bma4xx_interrupt(signal); + else + lis2dw12_interrupt(signal); } static void form_factor_init(void) -- cgit v1.2.1 From 4115c899e6705fb589c4b2e1c78e18eb9b50c11e Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 14 Nov 2022 15:38:33 +0000 Subject: zephyr: bindings: rename cros-keyscan to cros-ec,keyscan Rename the cros-keyscan binding so that it has a cros-ec prefix, like most of the other "soft" bindings in the project. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I26d72952f44df2ab0bf6228b6f1878e3f099b8f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021954 Code-Coverage: Zoss Reviewed-by: Keith Short --- zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml | 82 ++++++++++++++++++++++ zephyr/dts/bindings/keyboard/cros-keyscan.yaml | 82 ---------------------- zephyr/program/corsola/ite_keyboard.dtsi | 2 +- zephyr/program/corsola/keyboard_steelix.dtsi | 2 +- .../intelrvp/adlrvp/adlrvp_mchp/keyboard.dts | 2 +- .../intelrvp/adlrvp/adlrvp_npcx/keyboard.dts | 2 +- .../intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts | 2 +- zephyr/program/npcx_evb/npcx7/keyboard.dts | 2 +- zephyr/program/npcx_evb/npcx9/keyboard.dts | 2 +- zephyr/program/trogdor/lazor/keyboard.dts | 2 +- zephyr/shim/src/keyscan.c | 4 +- 11 files changed, 92 insertions(+), 92 deletions(-) create mode 100644 zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml delete mode 100644 zephyr/dts/bindings/keyboard/cros-keyscan.yaml diff --git a/zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml b/zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml new file mode 100644 index 0000000000..0e093bf015 --- /dev/null +++ b/zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml @@ -0,0 +1,82 @@ + # Copyright 2021 The ChromiumOS Authors + # Use of this source code is governed by a BSD-style license that can be + # found in the LICENSE file. + +description: Keyboard scanning properties + +compatible: "cros-ec,keyscan" + +properties: + output-settle: + type: int + required: false + default: 80 + description: | + Delay time, in microseconds, between setting up output and waiting for + it to settle. 80 microseconds is the recommended value when column 2 + of the keyboard passes through the Google Security Chip. Otherwise 50 + microseconds is the recommended value. + + debounce-down: + type: int + required: false + default: 9000 + description: | + Time, in microseconds, to debounce key-down. + + debounce-up: + type: int + required: false + default: 30000 + description: | + Time, in microseconds, to debounce key-up. + + scan-period: + type: int + required: false + default: 3000 + description: | + Time between scans when keyboard scan task runs in polling mode. + + min-post-scan-delay: + type: int + required: false + default: 1000 + description: | + Minimum time between end of one scan and start of the next one. + This ensures keyboard scanning doesn't starve the rest of the system + if the scan period is set too short, or if other higher-priority + system activity is starving the keyboard scan task too. + + poll-timeout: + type: int + required: false + default: 100000 + description: | + Revert to interrupt mode after no keyboard activity for this period. + Specified in microseconds. + + actual-key-mask: + type: array + required: false + default: [ + 0x1c, # C0 + 0xff, # C1 + 0xff, # C2 + 0xff, # C3 + 0xff, # C4 + 0xf5, # C5 + 0xff, # C6 + 0xa4, # C7 + 0xfe, # C8 + 0x55, # C9 + 0xfa, # C10 + 0xff, # C11 + 0xca, # C12 + 0x00, # C13 for keypad + 0x00, # C14 for keypad + ] + description: | + Keyboard scanning mask. For each keyboard column, specify which + keyboard rows actually exist. Default key mask includes scanning for + full Chromebook keyboard, excluding the keypad. diff --git a/zephyr/dts/bindings/keyboard/cros-keyscan.yaml b/zephyr/dts/bindings/keyboard/cros-keyscan.yaml deleted file mode 100644 index a2ec2afc46..0000000000 --- a/zephyr/dts/bindings/keyboard/cros-keyscan.yaml +++ /dev/null @@ -1,82 +0,0 @@ - # Copyright 2021 The ChromiumOS Authors - # Use of this source code is governed by a BSD-style license that can be - # found in the LICENSE file. - -description: Keyboard scanning properties - -compatible: "cros-keyscan" - -properties: - output-settle: - type: int - required: false - default: 80 - description: | - Delay time, in microseconds, between setting up output and waiting for - it to settle. 80 microseconds is the recommended value when column 2 - of the keyboard passes through the Google Security Chip. Otherwise 50 - microseconds is the recommended value. - - debounce-down: - type: int - required: false - default: 9000 - description: | - Time, in microseconds, to debounce key-down. - - debounce-up: - type: int - required: false - default: 30000 - description: | - Time, in microseconds, to debounce key-up. - - scan-period: - type: int - required: false - default: 3000 - description: | - Time between scans when keyboard scan task runs in polling mode. - - min-post-scan-delay: - type: int - required: false - default: 1000 - description: | - Minimum time between end of one scan and start of the next one. - This ensures keyboard scanning doesn't starve the rest of the system - if the scan period is set too short, or if other higher-priority - system activity is starving the keyboard scan task too. - - poll-timeout: - type: int - required: false - default: 100000 - description: | - Revert to interrupt mode after no keyboard activity for this period. - Specified in microseconds. - - actual-key-mask: - type: array - required: false - default: [ - 0x1c, # C0 - 0xff, # C1 - 0xff, # C2 - 0xff, # C3 - 0xff, # C4 - 0xf5, # C5 - 0xff, # C6 - 0xa4, # C7 - 0xfe, # C8 - 0x55, # C9 - 0xfa, # C10 - 0xff, # C11 - 0xca, # C12 - 0x00, # C13 for keypad - 0x00, # C14 for keypad - ] - description: | - Keyboard scanning mask. For each keyboard column, specify which - keyboard rows actually exist. Default key mask includes scanning for - full Chromebook keyboard, excluding the keypad. diff --git a/zephyr/program/corsola/ite_keyboard.dtsi b/zephyr/program/corsola/ite_keyboard.dtsi index b1a9af6330..8d2a345ff0 100644 --- a/zephyr/program/corsola/ite_keyboard.dtsi +++ b/zephyr/program/corsola/ite_keyboard.dtsi @@ -5,7 +5,7 @@ / { cros-keyscan { - compatible = "cros-keyscan"; + compatible = "cros-ec,keyscan"; scan-period = <10000>; diff --git a/zephyr/program/corsola/keyboard_steelix.dtsi b/zephyr/program/corsola/keyboard_steelix.dtsi index 9a0dca3e05..951389448a 100644 --- a/zephyr/program/corsola/keyboard_steelix.dtsi +++ b/zephyr/program/corsola/keyboard_steelix.dtsi @@ -5,7 +5,7 @@ / { cros-keyscan { - compatible = "cros-keyscan"; + compatible = "cros-ec,keyscan"; debounce-down = <15000>; debounce-up = <15000>; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts index b3577e6afd..2601da793d 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts @@ -5,7 +5,7 @@ / { cros-keyscan { - compatible = "cros-keyscan"; + compatible = "cros-ec,keyscan"; output-settle = <80>; debounce-down = <9000>; diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts index 81d6e82f48..be0a570e95 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts @@ -5,7 +5,7 @@ / { cros-keyscan { - compatible = "cros-keyscan"; + compatible = "cros-ec,keyscan"; output-settle = <35>; debounce-down = <5000>; diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts index 81d6e82f48..be0a570e95 100644 --- a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts @@ -5,7 +5,7 @@ / { cros-keyscan { - compatible = "cros-keyscan"; + compatible = "cros-ec,keyscan"; output-settle = <35>; debounce-down = <5000>; diff --git a/zephyr/program/npcx_evb/npcx7/keyboard.dts b/zephyr/program/npcx_evb/npcx7/keyboard.dts index 3fb6986f1a..e7e35d1493 100644 --- a/zephyr/program/npcx_evb/npcx7/keyboard.dts +++ b/zephyr/program/npcx_evb/npcx7/keyboard.dts @@ -5,7 +5,7 @@ / { cros-keyscan { - compatible = "cros-keyscan"; + compatible = "cros-ec,keyscan"; output-settle = <40>; debounce-down = <6000>; diff --git a/zephyr/program/npcx_evb/npcx9/keyboard.dts b/zephyr/program/npcx_evb/npcx9/keyboard.dts index 3fb6986f1a..e7e35d1493 100644 --- a/zephyr/program/npcx_evb/npcx9/keyboard.dts +++ b/zephyr/program/npcx_evb/npcx9/keyboard.dts @@ -5,7 +5,7 @@ / { cros-keyscan { - compatible = "cros-keyscan"; + compatible = "cros-ec,keyscan"; output-settle = <40>; debounce-down = <6000>; diff --git a/zephyr/program/trogdor/lazor/keyboard.dts b/zephyr/program/trogdor/lazor/keyboard.dts index b8689b883c..6580fa2a35 100644 --- a/zephyr/program/trogdor/lazor/keyboard.dts +++ b/zephyr/program/trogdor/lazor/keyboard.dts @@ -5,7 +5,7 @@ / { cros-keyscan { - compatible = "cros-keyscan"; + compatible = "cros-ec,keyscan"; actual-key-mask = < 0x14 /* C0 */ diff --git a/zephyr/shim/src/keyscan.c b/zephyr/shim/src/keyscan.c index 78a3e440be..9bf2a5ec1f 100644 --- a/zephyr/shim/src/keyscan.c +++ b/zephyr/shim/src/keyscan.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_keyscan +#define DT_DRV_COMPAT cros_ec_keyscan #include "keyboard_scan.h" @@ -13,7 +13,7 @@ #include -#if DT_NODE_EXISTS(DT_INST(0, cros_keyscan)) +#if DT_NODE_EXISTS(DT_INST(0, cros_ec_keyscan)) /* The keyboard matrix should have at least enough columns for the * standard keyboard with no keypad. -- cgit v1.2.1 From 86853653efb5acf2bb84ca220d9e309a4745d3a0 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 11:33:01 +0000 Subject: zephyr: keyboard: split dt based keymap to its own config Add a separate config for instantiating keyscan_config based on the devicetree, decoupling it from the main PLATFORM_EC_KEYBOARD option. The new one is selected automatically based on devicetree and the driver does not need a #if guard anymore. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I8e6654c7ebca8553b1f930b87c320af50895048f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030886 Code-Coverage: Zoss Reviewed-by: Keith Short --- zephyr/Kconfig.keyboard | 9 +++++++++ zephyr/shim/src/CMakeLists.txt | 2 +- zephyr/shim/src/keyscan.c | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/zephyr/Kconfig.keyboard b/zephyr/Kconfig.keyboard index 15ca7d20e7..400f295418 100644 --- a/zephyr/Kconfig.keyboard +++ b/zephyr/Kconfig.keyboard @@ -19,6 +19,15 @@ menuconfig PLATFORM_EC_KEYBOARD if PLATFORM_EC_KEYBOARD +config CROS_EC_KEYSCAN + bool "Devicetree based keyscan map" + default y + depends on DT_HAS_CROS_EC_KEYSCAN_ENABLED + help + Define a keyscan_config data structure based on a the keyscan + configuration found in devicetree. Requires a cros-ec,keyscan node to + be defined. + choice PLATFORM_EC_KEYBOARD_PROTOCOL_MODE prompt "Select the keyboard protocol to use" help diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 5aa94b31ce..74da11da2c 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -42,7 +42,7 @@ if (NOT DEFINED CONFIG_PLATFORM_EC_KEYBOARD_DISCRETE) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD keyboard_raw.c) endif() -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD keyscan.c) +zephyr_library_sources_ifdef(CONFIG_CROS_EC_KEYSCAN keyscan.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LOG_BACKEND_CONSOLE_BUFFER log_backend_console_buffer.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MKBP_EVENT mkbp_event.c) diff --git a/zephyr/shim/src/keyscan.c b/zephyr/shim/src/keyscan.c index 9bf2a5ec1f..46bb5fcc7f 100644 --- a/zephyr/shim/src/keyscan.c +++ b/zephyr/shim/src/keyscan.c @@ -13,7 +13,8 @@ #include -#if DT_NODE_EXISTS(DT_INST(0, cros_ec_keyscan)) +BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, + "Exactly one instance of cros-ec,keyscan should be defined."); /* The keyboard matrix should have at least enough columns for the * standard keyboard with no keypad. @@ -33,4 +34,3 @@ __override struct keyboard_scan_config keyscan_config = { .poll_timeout_us = DT_INST_PROP(0, poll_timeout), .actual_key_mask = DT_INST_PROP(0, actual_key_mask), }; -#endif -- cgit v1.2.1 From 3af8ca99c7b5c0575272e2cd9888fd93ddcf211a Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 11:53:17 +0000 Subject: zephyr: config: drop few redundant CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD=y is the default on non-posix, drop it from few configs. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I2fe20b0f41a82781804527e07f7cdaf500395277 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030887 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/program.conf | 1 - zephyr/program/herobrine/program.conf | 1 - zephyr/program/intelrvp/prj.conf | 1 - zephyr/program/nissa/program.conf | 1 - zephyr/program/rex/prj.conf | 1 - zephyr/program/skyrim/prj.conf | 1 - zephyr/program/trogdor/lazor/prj.conf | 1 - 8 files changed, 8 deletions(-) diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index afb3469055..6d4c304b77 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -86,7 +86,6 @@ CONFIG_PLATFORM_EC_PMIC=y CONFIG_PLATFORM_EC_MP2964=y # Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y diff --git a/zephyr/program/corsola/program.conf b/zephyr/program/corsola/program.conf index cb4ed7a3ef..402f8ab1cf 100644 --- a/zephyr/program/corsola/program.conf +++ b/zephyr/program/corsola/program.conf @@ -31,7 +31,6 @@ CONFIG_EEPROM=y CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y # Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index baff6ef280..ffe8ed7a8b 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -54,7 +54,6 @@ CONFIG_PLATFORM_EC_MKBP_EVENT=y CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y # Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y diff --git a/zephyr/program/intelrvp/prj.conf b/zephyr/program/intelrvp/prj.conf index 97b44e476d..4b56a42b53 100644 --- a/zephyr/program/intelrvp/prj.conf +++ b/zephyr/program/intelrvp/prj.conf @@ -40,7 +40,6 @@ CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y # Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index a3cbe768e4..606c66969e 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -55,7 +55,6 @@ CONFIG_AP_PWRSEQ_S0IX_ERROR_RECOVERY=y # Keyboard support CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y -CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_CMD_BUTTON=n diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 227a415095..e52812c001 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -129,7 +129,6 @@ CONFIG_PLATFORM_EC_POWER_BUTTON=y CONFIG_PLATFORM_EC_LID_SWITCH=y # Keyboard support -CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y # Column 2 is driven through the GSC, which inverts the signal going through it CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 3d9b650b43..63f2a54ae1 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -56,7 +56,6 @@ CONFIG_PLATFORM_EC_LID_SWITCH=y # Keyboard CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y -CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 323fb1ca00..83bd48d61b 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -52,7 +52,6 @@ CONFIG_PLATFORM_EC_MKBP_EVENT=y CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y # Keyboard -CONFIG_PLATFORM_EC_KEYBOARD=y CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -- cgit v1.2.1 From aba6b6f0e8377b239195d35706498cdc5927cfe8 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Wed, 16 Nov 2022 02:01:09 -0700 Subject: test: flashinfo command The info output was reworked to print a little nicer (one flag per line) which makes the output more readable. Additionally, we can assert that each bit in the flags is checked and the correct state is printed. BRANCH=none BUG=b:254926324 TEST=twister Signed-off-by: Yuval Peress Change-Id: I1141a8055575627aba2d98eae0f5cbe3bf15bc64 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030062 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- common/flash.c | 53 +++++++++++++++++---------------- zephyr/test/drivers/default/src/flash.c | 13 ++++---- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/common/flash.c b/common/flash.c index 0a027fd312..de042e76cb 100644 --- a/common/flash.c +++ b/common/flash.c @@ -978,6 +978,8 @@ DECLARE_DEFERRED(flash_erase_deferred); /* Console commands */ #ifdef CONFIG_CMD_FLASHINFO +#define BIT_TO_ON_OFF(value, mask) \ + ((((value) & (mask)) == (mask)) ? "ON" : "OFF") static int command_flash_info(int argc, const char **argv) { int i, flags; @@ -1002,36 +1004,35 @@ static int command_flash_info(int argc, const char **argv) ccprintf("Protect: %4d B\n", CONFIG_FLASH_BANK_SIZE); #endif flags = crec_flash_get_protect(); - ccprintf("Flags: "); - if (flags & EC_FLASH_PROTECT_GPIO_ASSERTED) - ccputs(" wp_gpio_asserted"); - if (flags & EC_FLASH_PROTECT_RO_AT_BOOT) - ccputs(" ro_at_boot"); - if (flags & EC_FLASH_PROTECT_ALL_AT_BOOT) - ccputs(" all_at_boot"); - if (flags & EC_FLASH_PROTECT_RO_NOW) - ccputs(" ro_now"); - if (flags & EC_FLASH_PROTECT_ALL_NOW) - ccputs(" all_now"); + ccprintf("Flags:\n"); + ccprintf(" wp_gpio_asserted: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_GPIO_ASSERTED)); + ccprintf(" ro_at_boot: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_RO_AT_BOOT)); + ccprintf(" all_at_boot: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ALL_AT_BOOT)); + ccprintf(" ro_now: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_RO_NOW)); + ccprintf(" all_now: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ALL_NOW)); #ifdef CONFIG_FLASH_PROTECT_RW - if (flags & EC_FLASH_PROTECT_RW_AT_BOOT) - ccputs(" rw_at_boot"); - if (flags & EC_FLASH_PROTECT_RW_NOW) - ccputs(" rw_now"); + ccprintf(" rw_at_boot: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_RW_AT_BOOT)); + ccprintf(" rw_now: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_RW_NOW)); #endif - if (flags & EC_FLASH_PROTECT_ERROR_STUCK) - ccputs(" STUCK"); - if (flags & EC_FLASH_PROTECT_ERROR_INCONSISTENT) - ccputs(" INCONSISTENT"); - if (flags & EC_FLASH_PROTECT_ERROR_UNKNOWN) - ccputs(" UNKNOWN_ERROR"); + ccprintf(" STUCK: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ERROR_STUCK)); + ccprintf(" INCONSISTENT: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ERROR_INCONSISTENT)); + ccprintf(" UNKNOWN_ERROR: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ERROR_UNKNOWN)); #ifdef CONFIG_ROLLBACK - if (flags & EC_FLASH_PROTECT_ROLLBACK_AT_BOOT) - ccputs(" rollback_at_boot"); - if (flags & EC_FLASH_PROTECT_ROLLBACK_NOW) - ccputs(" rollback_now"); + ccprintf(" rollback_at_boot: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ROLLBACK_AT_BOOT)); + ccprintf(" rollback_now: %s\n", + BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ROLLBACK_NOW)); #endif - ccputs("\n"); ccputs("Protected now:"); for (i = 0; i < PHYSICAL_BANKS; i++) { diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c index 29ea381893..71d6853653 100644 --- a/zephyr/test/drivers/default/src/flash.c +++ b/zephyr/test/drivers/default/src/flash.c @@ -309,12 +309,15 @@ ZTEST_USER(flash, test_console_cmd_flash_info) sprintf(format_buffer, "Protect: %4d B", CONFIG_FLASH_BANK_SIZE); zassert_not_null(strstr(outbuffer, format_buffer)); - zassert_not_null(strstr(outbuffer, "wp_gpio_asserted")); + zassert_not_null(strstr(outbuffer, "wp_gpio_asserted: ON")); + zassert_not_null(strstr(outbuffer, "ro_at_boot: OFF")); + zassert_not_null(strstr(outbuffer, "all_at_boot: OFF")); + zassert_not_null(strstr(outbuffer, "ro_now: OFF")); + zassert_not_null(strstr(outbuffer, "all_now: OFF")); + zassert_not_null(strstr(outbuffer, "STUCK: OFF")); + zassert_not_null(strstr(outbuffer, "INCONSISTENT: OFF")); + zassert_not_null(strstr(outbuffer, "UNKNOWN_ERROR: OFF")); zassert_not_null(strstr(outbuffer, "Protected now")); - /* - * TODO(b/254926324): Fake crec_flash_get_protect() to get more - * flag messages. - */ } ZTEST_USER(flash, test_console_cmd_flashwp__invalid) -- cgit v1.2.1 From 9c52ce0b7c401ecd07d25901f16acf95369bcc5e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 15 Nov 2022 14:09:43 -0800 Subject: board/corori2: Free up flash space BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=corori2 Signed-off-by: Tom Hughes Change-Id: I788d367b3ad8ae5d40574da31b844cbb08db1fe4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029518 Code-Coverage: Zoss Reviewed-by: Edward Hill --- board/corori2/board.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/board/corori2/board.h b/board/corori2/board.h index 3483d96f88..79c57c98bb 100644 --- a/board/corori2/board.h +++ b/board/corori2/board.h @@ -20,6 +20,7 @@ /* Save some flash space */ #define CONFIG_CHIP_INIT_ROM_REGION #undef CONFIG_CONSOLE_CMDHELP +#undef CONFIG_CONSOLE_HISTORY #define CONFIG_DEBUG_ASSERT_BRIEF #define CONFIG_USB_PD_DEBUG_LEVEL 0 @@ -30,6 +31,8 @@ #undef CONFIG_CMD_ACCELSPOOF #undef CONFIG_CMD_BATTFAKE #undef CONFIG_CMD_GETTIME +#undef CONFIG_CMD_I2C_SCAN +#undef CONFIG_CMD_I2C_XFER #undef CONFIG_CMD_MEM /* Battery */ -- cgit v1.2.1 From 0abdee36c61f8dc3e9164377ef77bd17394b744e Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Tue, 15 Nov 2022 17:17:37 -0700 Subject: docs: twister: Update docs for new twister -s flag behavior An upstream change modified the way the `-s` flag works in Twister. This CL updates places in our docs that reference this flag. BRANCH=None BUG=None TEST=None Signed-off-by: Tristan Honscheid Change-Id: Ib610c6c8779dea3842cbf33c82f95e18c1fed99d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4028959 Code-Coverage: Zoss Reviewed-by: Yuval Peress --- docs/code_coverage.md | 4 ++-- docs/zephyr/ztest.md | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/docs/code_coverage.md b/docs/code_coverage.md index 49b6cfb493..0a5eeb3150 100644 --- a/docs/code_coverage.md +++ b/docs/code_coverage.md @@ -80,10 +80,10 @@ The coverage report top-level page is `build/zephyr/coverage_rpt/index.html`. For coverage report for a single test you can run: -`./twister -v -i --coverage -p native_posix -p unit_testing -s /` +`./twister -v -i --coverage -p native_posix -p unit_testing -s external/platform/ec/zephyr/test//` Example of running test tasks.default from zephyr/test/tasks/testcase.yaml: -`./twister -v -i --coverage -p native_posix -p unit_testing -s zephyr/test/tasks/tasks.default` +`./twister -v -i --coverage -p native_posix -p unit_testing -s external/platform/ec/zephyr/test/tasks/tasks.default` ## Code Coverage in CQ diff --git a/docs/zephyr/ztest.md b/docs/zephyr/ztest.md index 84faa9371f..d6b598b0e3 100644 --- a/docs/zephyr/ztest.md +++ b/docs/zephyr/ztest.md @@ -120,24 +120,39 @@ For most use cases these are the things to remember: ## Running twister -Run all tests under a specific directory: +### Run all tests under a specific directory ```shell platform/ec$ ./twister -T path/to/my/tests ``` -Run a specific test: +### Run a specific test ```shell -platform/ec$ ./twister -s path/to/my/tests/my.test.case +platform/ec$ ./twister -s external/platform/ec/zephyr/test// ``` -Run all tests with coverage (get more info on code coverage at -[Zephyr ztest code coverage](../code_coverage.md#Zephyr_ztest_code_coverage): +For example: +```shell +platform/ec$ ./twister -s external/platform/ec/zephyr/test/drivers/drivers.default +``` + +Explanation of this string: `external/` is not a path component, but rather a +label that indicates we are running tests from outside of the Zephyr tree; +`platform/ec/zephyr/test/` is the location of our tests relative to the first +common parent of `ZEPHYR_BASE` and `platform/ec`; `drivers` is the directory for +our driver tests, and `drivers.default` is a specific test scenario defined in +that directory's `testcase.yaml` file. + +### Run all tests with coverage + +You can find more info on code coverage at +[Zephyr ztest code coverage](../code_coverage.md#Zephyr_ztest_code_coverage). + ```shell platform/ec$ ./twister -p native_posix -p unit_testing --coverage ``` -Get more info on twister: +### Get more info on twister ```shell platform/ec$ ./twister --help ``` -- cgit v1.2.1 From 4a4973379013329cba7363d4625c97070780c9f6 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 14 Nov 2022 16:01:07 +0000 Subject: zephyr: Kconfig: enable PLATFORM_EC_LED_PWM automatically Enable PLATFORM_EC_LED_PWM automatically based devicetree compatible nodes, drop few explicit config entries. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I79fef282bf78ce029d2bb0b37912da85ad1cc4b0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4021956 Code-Coverage: Zoss Reviewed-by: Abe Levkoy --- zephyr/Kconfig.led | 2 ++ zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/kingler/project.conf | 3 --- zephyr/program/intelrvp/adlrvp/prj.conf | 1 - zephyr/program/nissa/program.conf | 1 - 5 files changed, 2 insertions(+), 6 deletions(-) diff --git a/zephyr/Kconfig.led b/zephyr/Kconfig.led index 90f59f2fff..86e423aacd 100644 --- a/zephyr/Kconfig.led +++ b/zephyr/Kconfig.led @@ -19,6 +19,8 @@ if PLATFORM_EC_LED_COMMON config PLATFORM_EC_LED_PWM bool "PWM (Pulse Width Modulation) LEDs" + default y + depends on DT_HAS_CROS_EC_PWM_LEDS_ENABLED help Enable PWM (Pulse Width Modulation) controlled LEDs that conform to the Chromium OS LED behavior specification. diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 6d4c304b77..293d3972ad 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -154,7 +154,6 @@ CONFIG_SYSCON=y # LED CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_PWM=y CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n CONFIG_PLATFORM_EC_LED_PWM_NEAR_FULL_COLOR=4 CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR=4 diff --git a/zephyr/program/corsola/kingler/project.conf b/zephyr/program/corsola/kingler/project.conf index d7de991e93..cd4a735d71 100644 --- a/zephyr/program/corsola/kingler/project.conf +++ b/zephyr/program/corsola/kingler/project.conf @@ -5,8 +5,5 @@ # Variant config CONFIG_BOARD_KINGLER=y -# LED -CONFIG_PLATFORM_EC_LED_PWM=y - # Keyboard CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index 64cf5a2a4a..a5f2ad34a5 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -31,7 +31,6 @@ CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y # LED CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_PWM=y CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=y # Temperature sensors diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 606c66969e..02dc458a61 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -63,7 +63,6 @@ CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y # LED CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_PWM=y CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n -- cgit v1.2.1 From f4da1ab986322cad522ceea28d81de5c42a1b8c2 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 14 Nov 2022 16:40:29 +0000 Subject: zephyr: corsola: drop few unnecessary led_colors nodelabels Drop few led_colors nodelabels, they have no references in the code or other dts, no point copying them around forever. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I7b0f332820cf9a598dcc16f60041c2278363f09b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022155 Reviewed-by: Tristan Honscheid Code-Coverage: Zoss --- zephyr/program/corsola/led_it81202_base.dtsi | 2 +- zephyr/program/corsola/led_magikarp.dtsi | 2 +- zephyr/program/corsola/led_tentacruel.dtsi | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zephyr/program/corsola/led_it81202_base.dtsi b/zephyr/program/corsola/led_it81202_base.dtsi index dce7bb4f95..2703e6c997 100644 --- a/zephyr/program/corsola/led_it81202_base.dtsi +++ b/zephyr/program/corsola/led_it81202_base.dtsi @@ -5,7 +5,7 @@ #include / { - led_colors: led-colors { + led-colors { compatible = "cros-ec,led-policy"; bat-power-state-charge { diff --git a/zephyr/program/corsola/led_magikarp.dtsi b/zephyr/program/corsola/led_magikarp.dtsi index 0e2b0aca52..01382d95c0 100644 --- a/zephyr/program/corsola/led_magikarp.dtsi +++ b/zephyr/program/corsola/led_magikarp.dtsi @@ -5,7 +5,7 @@ #include "led_it81202_base.dtsi" / { - led_colors: led-colors { + led-colors { compatible = "cros-ec,led-policy"; /* Magikarp LED bat charge */ diff --git a/zephyr/program/corsola/led_tentacruel.dtsi b/zephyr/program/corsola/led_tentacruel.dtsi index 5569a956f6..39197bd51d 100644 --- a/zephyr/program/corsola/led_tentacruel.dtsi +++ b/zephyr/program/corsola/led_tentacruel.dtsi @@ -5,7 +5,7 @@ #include "led_it81202_base.dtsi" / { - led_colors: led-colors { + led-colors { compatible = "cros-ec,led-policy"; /* Tentacruel LED bat charge */ -- cgit v1.2.1 From 859432dfa6d6ed36f22a12e7a6206f0eb10540b9 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 14 Nov 2022 16:50:07 +0000 Subject: zephyr: Kconfig: enable PLATFORM_EC_MP2964 automatically Enable PLATFORM_EC_MP2964 automatically based devicetree compatible nodes, drop few explicit config entries, use the compatible instead of the node label. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I1f4cce37641e050256bb1b92d48c878f278b2b21 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022160 Code-Coverage: Zoss Reviewed-by: Aaron Massey --- zephyr/Kconfig.pmic | 4 ++-- zephyr/program/brya/i2c.dts | 3 +-- zephyr/program/brya/prj.conf | 1 - zephyr/shim/include/config_chip.h | 6 +++++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/zephyr/Kconfig.pmic b/zephyr/Kconfig.pmic index 831767c546..ef1df085c8 100644 --- a/zephyr/Kconfig.pmic +++ b/zephyr/Kconfig.pmic @@ -15,8 +15,8 @@ if PLATFORM_EC_PMIC config PLATFORM_EC_MP2964 bool "Enable MP2964 PMIC support" - depends on AP_X86_INTEL - depends on PLATFORM_EC_I2C + default y + depends on DT_HAS_MPS_MP2964_ENABLED help Enables support for the MPS MP2964 PMIC (Power Management IC). This is a dual rail IMVP8 - IMVP9.1 compatible Digital diff --git a/zephyr/program/brya/i2c.dts b/zephyr/program/brya/i2c.dts index 7284d80870..8de12cdb5e 100644 --- a/zephyr/program/brya/i2c.dts +++ b/zephyr/program/brya/i2c.dts @@ -258,10 +258,9 @@ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; pinctrl-names = "default"; - pmic_mp2964: pmic_mp2964@20 { + pmic_mp2964@20 { compatible = "mps,mp2964"; reg = <0x20>; - label = "I2C_ADDR_MP2964_FLAGS"; }; charger: bq25710@9 { diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 293d3972ad..4a814c9ab8 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -83,7 +83,6 @@ CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y # PMIC CONFIG_PLATFORM_EC_PMIC=y -CONFIG_PLATFORM_EC_MP2964=y # Keyboard CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index fc0e434403..51f06a2bcb 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -15,6 +15,7 @@ #line 16 #include +#include #include @@ -2581,7 +2582,10 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #undef CONFIG_MP2964 #ifdef CONFIG_PLATFORM_EC_MP2964 #define CONFIG_MP2964 -#define I2C_ADDR_MP2964_FLAGS DT_REG_ADDR(DT_NODELABEL(pmic_mp2964)) +#define I2C_ADDR_MP2964_FLAGS \ + DT_REG_ADDR(DT_COMPAT_GET_ANY_STATUS_OKAY(mps_mp2964)) +BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(mps_mp2964)) == 1, + "Only one instance of mps,mp2964 should be defined"); #endif #undef CONFIG_ACCELGYRO_ICM_COMM_SPI -- cgit v1.2.1 From 435c14e5d7821751d14b2955ee7b076c892860fd Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 10:25:27 +0000 Subject: zephyr: config: check for multiple instances of maxim,max695x Use DT_COMPAT_GET_ANY_STATUS_OKAY to find the address of maxim,max695x devices and add a build check to ensure there's only on instance active. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I9e7008759d68b7e03a38067b95abe1caaf950e09 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030437 Code-Coverage: Zoss Reviewed-by: Aaron Massey --- zephyr/shim/include/config_chip.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 51f06a2bcb..1d88f1832e 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -2108,7 +2108,10 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #undef CONFIG_MAX695X_SEVEN_SEGMENT_DISPLAY #ifdef CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY #define CONFIG_MAX695X_SEVEN_SEGMENT_DISPLAY -#define PORT80_I2C_ADDR DT_REG_ADDR(DT_INST(0, maxim_max695x)) +#define PORT80_I2C_ADDR \ + DT_REG_ADDR(DT_COMPAT_GET_ANY_STATUS_OKAY(maxim_max695x)) +BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(maxim_max695x)) == 1, + "Only one instance of maxim,max695x should be defined"); #endif #undef CONFIG_CMD_SEVEN_SEG_DISPLAY -- cgit v1.2.1 From e5833c7225d609ab06d768279674a86aca151c8f Mon Sep 17 00:00:00 2001 From: "Jes B. Klinke" Date: Wed, 16 Nov 2022 10:22:49 -0800 Subject: board/hyperdebug: USB serial number Make the HyperDebug board present non-empty USB serial number. The serial number is computed based on a factory programmed register, in a manner that attempts to exactly replicate what the STM DFU ROM bootloader does. BUG=b:258237976 TEST=Observed USB serial on two HyperDebug boards Change-Id: Ic55de3f736ffb1ecab419658ad08423371845699 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4028741 Reviewed-by: Edward Hill Commit-Queue: Jes Klinke Code-Coverage: Zoss Tested-by: Jes Klinke --- board/hyperdebug/board.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/board/hyperdebug/board.c b/board/hyperdebug/board.c index 37e41f66a9..66cd981dca 100644 --- a/board/hyperdebug/board.c +++ b/board/hyperdebug/board.c @@ -20,6 +20,8 @@ #include "usb-stream.h" #include "gpio_list.h" +#include + void board_config_pre_init(void) { /* enable SYSCFG clock */ @@ -236,6 +238,26 @@ static void board_init(void) } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); +const char *board_read_serial(void) +{ + const uint32_t *stm32_unique_id = + (const uint32_t *)STM32_UNIQUE_ID_BASE; + static char serial[13]; + + // Compute 12 hex digits from three factory programmed 32-bit "Unique + // ID" words in a manner that has been observed to be consistent with + // how the STM DFU ROM bootloader presents its serial number. This + // means that the serial number of any particular HyperDebug board will + // remain the same as it enters and leaves DFU mode for software + // upgrade. + int rc = snprintf(serial, sizeof(serial), "%08X%04X", + stm32_unique_id[0] + stm32_unique_id[2], + stm32_unique_id[1] >> 16); + if (12 != rc) + return NULL; + return serial; +} + /** * Find a GPIO signal by name. * -- cgit v1.2.1 From c45cb8764f3c4c5b1917488aac7bb6a5be7b5be4 Mon Sep 17 00:00:00 2001 From: mick_hsiao Date: Wed, 16 Nov 2022 14:40:59 +0800 Subject: Frostflow: FAFT firmware_ECSystem_Locked is fail Modify CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED BUG=b:259179974 BRANCH=none TEST=zmake build frostflow Signed-off-by: mick_hsiao Change-Id: Ic4d8fc27892b1dc8a87fa35c3feb975dca74bf8f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4027790 Reviewed-by: Chao Gui Reviewed-by: Diana Z Reviewed-by: SamSP Liu Commit-Queue: Chao Gui Code-Coverage: Zoss --- zephyr/program/skyrim/prj_frostflow.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf index d72ac2b9c6..caae3ba985 100644 --- a/zephyr/program/skyrim/prj_frostflow.conf +++ b/zephyr/program/skyrim/prj_frostflow.conf @@ -8,7 +8,7 @@ CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR=90 # TODO(b/215404321): Remove later in board development CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n # LED CONFIG_PLATFORM_EC_LED_DT=y -- cgit v1.2.1 From fcc7716bf1461477a3b3d8a53b85fdc81df677e4 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 15 Nov 2022 13:21:48 -0800 Subject: util/build_with_clang: Add option to remove build directory By default remove the build directory, but allow disabling it with a flag. BRANCH=none BUG=b:172020503 TEST=./util/build_with_clang.py Signed-off-by: Tom Hughes Change-Id: I0342768da9e340aa4d84bb695cc97550e305326d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026667 Reviewed-by: Diana Z Code-Coverage: Zoss --- util/build_with_clang.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 085dcde8c2..5d662f7bce 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -10,6 +10,7 @@ import concurrent import logging import multiprocessing import os +import shutil import subprocess import sys import typing @@ -212,7 +213,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "voxel", "voxel_ecmodeentry", "voxel_npcx797fc", - "waddledoo", "waddledoo2", "whiskers", "woomax", @@ -299,6 +299,7 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ "mushu", # overflows flash "terrador", # overflows flash "volteer", # overflows flash + "waddledoo", # overflows flash ] # TODO(b/201311714): NDS32 is not supported by LLVM. @@ -362,9 +363,27 @@ def main() -> int: "--num_threads", "-j", type=int, default=multiprocessing.cpu_count() ) + group = parser.add_mutually_exclusive_group(required=False) + group.add_argument( + "--clean", + action="store_true", + help="Remove build directory before compiling", + ) + group.add_argument( + "--no-clean", + dest="clean", + action="store_false", + help="Do not remove build directory before compiling", + ) + parser.set_defaults(clean=True) + args = parser.parse_args() logging.basicConfig(level=args.log_level) + if args.clean: + logging.debug("Removing build directory") + shutil.rmtree("./build", ignore_errors=True) + check_boards() logging.debug("Building with %d threads", args.num_threads) -- cgit v1.2.1 From ec31407993ec9b5ae14fed72d728a4061d656d65 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Wed, 9 Nov 2022 16:51:36 +1100 Subject: Add CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT Many boards derate their charge current limits by some fixed ratio, which results in duplicate code appearing in many different boards. Since nearly all of these are in implementations of board_set_charge_limit() and themselves call charge_set_input_current_limit(), make that derating a config option and move it into charge_set_input_current_limit(). This makes most boards' implementations uniform and ripe for further simplification in later changes. For those boards that do more complex adjustments, those can be retained by keeping the existing logic in board_set_charge_limit(). Several boards also uselessly defined multiple versions of board_set_charge_limit(): the redundant ones are removed. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none LOW_COVERAGE_REASON=follow-up CLs delete uncovered code Change-Id: I0a7162e72538a91ad06ba85b91a10b93eb6af96b Signed-off-by: Peter Marheine Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4015966 Code-Coverage: Zoss Commit-Queue: Keith Short Reviewed-by: Keith Short --- baseboard/brya/charger_bq25720.c | 7 ------- baseboard/grunt/baseboard.c | 5 ----- baseboard/grunt/baseboard.h | 1 + baseboard/octopus/baseboard.c | 7 ------- baseboard/octopus/baseboard.h | 4 ++++ board/anahera/board.c | 12 ------------ board/anahera/board.h | 2 ++ board/anahera/charger.c | 4 ++-- board/atlas/board.c | 17 ++++------------- board/atlas/board.h | 1 + board/beetley/board.c | 5 ----- board/beetley/board.h | 5 +++++ board/bellis/board.c | 1 - board/bellis/board.h | 1 + board/blipper/board.c | 6 ------ board/blipper/board.h | 5 +++++ board/boten/board.c | 6 ------ board/boten/board.h | 5 +++++ board/brya/charger.c | 4 ++-- board/bugzzy/board.c | 6 ------ board/bugzzy/board.h | 5 +++++ board/burnet/board.c | 1 - board/burnet/board.h | 1 + board/cappy2/board.c | 6 ------ board/cappy2/board.h | 5 +++++ board/cerise/board.c | 1 - board/cerise/board.h | 1 + board/coachz/board.c | 1 - board/coachz/board.h | 2 ++ board/coral/board.c | 1 - board/coral/board.h | 1 + board/corori/board.c | 6 ------ board/corori/board.h | 5 +++++ board/corori2/board.c | 6 ------ board/corori2/board.h | 5 +++++ board/cret/board.c | 6 ------ board/cret/board.h | 5 +++++ board/damu/board.c | 1 - board/damu/board.h | 1 + board/driblee/board.c | 6 ------ board/driblee/board.h | 5 +++++ board/drobit/board.c | 5 ----- board/drobit/board.h | 1 + board/eldrid/board.c | 6 ------ board/eldrid/board.h | 2 ++ board/elm/board.c | 2 -- board/elm/board.h | 1 + board/eve/board.c | 1 - board/eve/board.h | 1 + board/ezkinil/board.c | 6 ------ board/ezkinil/board.h | 3 +++ board/felwinter/board.h | 1 + board/felwinter/charger_isl9241.c | 5 ++--- board/fennel/board.c | 1 - board/fennel/board.h | 1 + board/gelarshie/board.c | 1 - board/gelarshie/board.h | 3 +++ board/gimble/board.c | 13 ------------- board/gimble/board.h | 2 ++ board/gimble/charger.c | 4 ++-- board/gooey/board.c | 6 ------ board/gooey/board.h | 5 +++++ board/homestar/board.c | 1 - board/homestar/board.h | 3 +++ board/icarus/board.c | 1 - board/icarus/board.h | 1 + board/jacuzzi/board.c | 1 - board/jacuzzi/board.h | 1 + board/kappa/board.c | 1 - board/kappa/board.h | 1 + board/lalala/board.c | 6 ------ board/lalala/board.h | 5 +++++ board/madoo/board.c | 7 ------- board/madoo/board.h | 5 +++++ board/magolor/board.c | 6 ------ board/magolor/board.h | 5 +++++ board/makomo/board.c | 1 - board/makomo/board.h | 1 + board/metaknight/board.c | 6 ------ board/metaknight/board.h | 5 +++++ board/mithrax/board.h | 1 + board/mithrax/charger_isl9241.c | 1 - board/mrbland/board.c | 1 - board/mrbland/board.h | 2 ++ board/munna/board.c | 1 - board/munna/board.h | 1 + board/nautilus/board.c | 5 ----- board/nautilus/board.h | 1 + board/nocturne/board.c | 6 ------ board/nocturne/board.h | 5 +++++ board/pico/board.c | 1 - board/pico/board.h | 1 + board/pompom/board.c | 1 - board/pompom/board.h | 2 ++ board/primus/charger.c | 7 ------- board/quackingstick/board.c | 1 - board/quackingstick/board.h | 2 ++ board/rammus/board.c | 5 ----- board/rammus/board.h | 1 + board/reef/board.c | 1 - board/reef/board.h | 1 + board/reef_it8320/board.c | 1 - board/reef_it8320/board.h | 1 + board/reef_mchp/board.c | 1 - board/reef_mchp/board.h | 1 + board/sasuke/board.c | 6 ------ board/sasuke/board.h | 5 +++++ board/sasukette/board.c | 6 ------ board/sasukette/board.h | 5 +++++ board/stern/board.c | 1 - board/stern/board.h | 1 + board/storo/board.c | 6 ------ board/storo/board.h | 5 +++++ board/taeko/board.c | 13 ------------- board/taeko/board.h | 3 +++ board/taeko/charger.c | 4 ++-- board/taniks/board.c | 13 ------------- board/taniks/board.h | 3 +++ board/taniks/charger.c | 4 ++-- board/vell/board.h | 2 ++ board/vell/charger.c | 5 ----- board/vilboz/board.c | 6 ------ board/vilboz/board.h | 1 + board/waddledoo/board.c | 6 ------ board/waddledoo/board.h | 5 +++++ board/waddledoo2/board.c | 6 ------ board/waddledoo2/board.h | 5 +++++ board/willow/board.c | 1 - board/willow/board.h | 1 + board/wormdingler/board.c | 1 - board/wormdingler/board.h | 2 ++ common/charge_state_v2.c | 7 +++++++ include/charge_state_v2.h | 3 +++ include/config.h | 15 +++++++++++++++ zephyr/Kconfig.usbc | 16 ++++++++++++++++ zephyr/program/corsola/program.conf | 3 +++ zephyr/program/corsola/src/usbc_config.c | 7 +------ zephyr/program/nissa/program.conf | 2 ++ zephyr/program/nissa/src/common.c | 7 ------- zephyr/program/nissa/xivu/project.conf | 2 ++ zephyr/program/skyrim/Kconfig | 6 ------ zephyr/program/skyrim/prj_frostflow.conf | 2 +- zephyr/program/skyrim/src/usbc_config.c | 2 -- zephyr/shim/include/config_chip.h | 6 ++++++ .../drivers/common_charger/src/test_charge_state_v2.c | 17 +++++++++++++++++ zephyr/test/drivers/testcase.yaml | 1 + 146 files changed, 254 insertions(+), 311 deletions(-) diff --git a/baseboard/brya/charger_bq25720.c b/baseboard/brya/charger_bq25720.c index a4fa209246..7fabd2082e 100644 --- a/baseboard/brya/charger_bq25720.c +++ b/baseboard/brya/charger_bq25720.c @@ -81,10 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c index 5fbf2823be..50db1887f1 100644 --- a/baseboard/grunt/baseboard.c +++ b/baseboard/grunt/baseboard.c @@ -467,11 +467,6 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* - * Limit the input current to 95% negotiated limit, - * to account for the charger chip margin. - */ - charge_ma = charge_ma * 95 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h index 1c19c05330..b83b274d49 100644 --- a/baseboard/grunt/baseboard.h +++ b/baseboard/grunt/baseboard.h @@ -73,6 +73,7 @@ * See also b/111214767 */ #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c index 0f012d1352..b35bbcd67b 100644 --- a/baseboard/octopus/baseboard.c +++ b/baseboard/octopus/baseboard.c @@ -301,13 +301,6 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* - * Empirically, the charger seems to draw a little more current that - * it is set to, so we reduce our limit by 5%. - */ -#if defined(CONFIG_CHARGER_BQ25710) || defined(CONFIG_CHARGER_ISL9238) - charge_ma = (charge_ma * 95) / 100; -#endif charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h index 724540d0f0..8662749c98 100644 --- a/baseboard/octopus/baseboard.h +++ b/baseboard/octopus/baseboard.h @@ -125,6 +125,8 @@ */ #undef CONFIG_EXTPOWER_DEBOUNCE_MS #define CONFIG_EXTPOWER_DEBOUNCE_MS 200 +/* Charger seems to overdraw by about 5% */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #elif defined(VARIANT_OCTOPUS_CHARGER_BQ25703) #define CONFIG_CHARGER_BQ25703 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 @@ -133,6 +135,8 @@ */ #undef CONFIG_EXTPOWER_DEBOUNCE_MS #define CONFIG_EXTPOWER_DEBOUNCE_MS 50 +/* Charger seems to overdraw by about 5% */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #elif defined(CONFIG_CHARGER_RUNTIME_CONFIG) #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_BQ25710 diff --git a/board/anahera/board.c b/board/anahera/board.c index e087d629a7..cd9eb30870 100644 --- a/board/anahera/board.c +++ b/board/anahera/board.c @@ -64,15 +64,3 @@ enum battery_present battery_hw_present(void) /* The GPIO is low when the battery is physically present */ return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES; } - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - /* - * Limit the input current to 95% negotiated limit, - * to account for the charger chip margin. - */ - charge_ma = charge_ma * 95 / 100; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} diff --git a/board/anahera/board.h b/board/anahera/board.h index 18360171e3..82ba5a4e1c 100644 --- a/board/anahera/board.h +++ b/board/anahera/board.h @@ -33,6 +33,8 @@ #define CONFIG_USB_PORT_POWER_DUMB #define CONFIG_USBC_RETIMER_PS8811 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* USB Type C and USB PD defines */ #define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY diff --git a/board/anahera/charger.c b/board/anahera/charger.c index a4fa209246..29211bc033 100644 --- a/board/anahera/charger.c +++ b/board/anahera/charger.c @@ -82,8 +82,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); diff --git a/board/atlas/board.c b/board/atlas/board.c index 6fbbb64b16..633543b51f 100644 --- a/board/atlas/board.c +++ b/board/atlas/board.c @@ -531,20 +531,12 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -/* - * Limit the input current to 95% negotiated limit, - * to account for the charger chip margin. - */ - -static int charger_derate(int current) -{ - return current * 95 / 100; -} - static void board_charger_init(void) { - charger_set_input_current_limit(CHARGER_SOLO, - charger_derate(PD_MAX_CURRENT_MA)); + charger_set_input_current_limit( + CHARGER_SOLO, + PD_MAX_CURRENT_MA * + (100 - CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT) / 100); } DECLARE_HOOK(HOOK_INIT, board_charger_init, HOOK_PRIO_DEFAULT); @@ -559,7 +551,6 @@ DECLARE_HOOK(HOOK_INIT, board_charger_init, HOOK_PRIO_DEFAULT); void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = charger_derate(charge_ma); charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/atlas/board.h b/board/atlas/board.h index 9718ab7cdd..97f6d67e49 100644 --- a/board/atlas/board.h +++ b/board/atlas/board.h @@ -78,6 +78,7 @@ #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_PSYS_READ diff --git a/board/beetley/board.c b/board/beetley/board.c index f6b1f1008c..e0ba900a70 100644 --- a/board/beetley/board.c +++ b/board/beetley/board.c @@ -389,11 +389,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/beetley/board.h b/board/beetley/board.h index a70ee73ebb..b05b8e2eb5 100644 --- a/board/beetley/board.h +++ b/board/beetley/board.h @@ -27,6 +27,11 @@ /* Charger */ #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_RAA489000 +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define PD_MAX_VOLTAGE_MV 20000 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/board/bellis/board.c b/board/bellis/board.c index e03ae1c36c..fc960749f3 100644 --- a/board/bellis/board.c +++ b/board/bellis/board.c @@ -239,7 +239,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/bellis/board.h b/board/bellis/board.h index d502c4c5ef..0741de5dc7 100644 --- a/board/bellis/board.h +++ b/board/bellis/board.h @@ -40,6 +40,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/blipper/board.c b/board/blipper/board.c index 766f55579c..b7782a8af9 100644 --- a/board/blipper/board.c +++ b/board/blipper/board.c @@ -540,12 +540,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/blipper/board.h b/board/blipper/board.h index 379a92a007..896ebec76a 100644 --- a/board/blipper/board.h +++ b/board/blipper/board.h @@ -29,6 +29,11 @@ #define CONFIG_CHARGER_SENSE_RESISTOR 10 #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* DAC for PSYS */ #define CONFIG_DAC diff --git a/board/boten/board.c b/board/boten/board.c index c47b9e46f0..9a54a4a341 100644 --- a/board/boten/board.c +++ b/board/boten/board.c @@ -248,12 +248,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/boten/board.h b/board/boten/board.h index ec5d25ff9f..2e607f73c1 100644 --- a/board/boten/board.h +++ b/board/boten/board.h @@ -32,6 +32,11 @@ */ #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* DAC for PSYS */ #define CONFIG_DAC diff --git a/board/brya/charger.c b/board/brya/charger.c index a4fa209246..b1a29c725b 100644 --- a/board/brya/charger.c +++ b/board/brya/charger.c @@ -82,8 +82,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) { charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); diff --git a/board/bugzzy/board.c b/board/bugzzy/board.c index 5a28fb2c25..b6a015999e 100644 --- a/board/bugzzy/board.c +++ b/board/bugzzy/board.c @@ -397,12 +397,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/bugzzy/board.h b/board/bugzzy/board.h index b1d8568ee1..45bdfdc9f3 100644 --- a/board/bugzzy/board.h +++ b/board/bugzzy/board.h @@ -43,6 +43,11 @@ #undef CONFIG_CHARGER_SINGLE_CHIP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define CONFIG_BATTERY_CHECK_CHARGE_TEMP_LIMITS #define CONFIG_CHARGER_PROFILE_OVERRIDE diff --git a/board/burnet/board.c b/board/burnet/board.c index aa378ca289..923a7a76ce 100644 --- a/board/burnet/board.c +++ b/board/burnet/board.c @@ -225,7 +225,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/burnet/board.h b/board/burnet/board.h index 6870ccc2d2..17ca27daea 100644 --- a/board/burnet/board.h +++ b/board/burnet/board.h @@ -28,6 +28,7 @@ #define CONFIG_BATTERY_COUNT 1 #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_BC12_DETECT_PI3USB9201 diff --git a/board/cappy2/board.c b/board/cappy2/board.c index de651ac874..d81e731ebf 100644 --- a/board/cappy2/board.c +++ b/board/cappy2/board.c @@ -233,12 +233,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/cappy2/board.h b/board/cappy2/board.h index b21a20d6e5..8f503b1bcc 100644 --- a/board/cappy2/board.h +++ b/board/cappy2/board.h @@ -39,6 +39,11 @@ #define CONFIG_CHARGER_PROFILE_OVERRIDE #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* Keyboard */ #undef CONFIG_PWM_KBLIGHT diff --git a/board/cerise/board.c b/board/cerise/board.c index e3fa60c76a..62fbc69254 100644 --- a/board/cerise/board.c +++ b/board/cerise/board.c @@ -239,7 +239,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/cerise/board.h b/board/cerise/board.h index 41d86b956d..d2c58e9f6e 100644 --- a/board/cerise/board.h +++ b/board/cerise/board.h @@ -28,6 +28,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/coachz/board.c b/board/coachz/board.c index 723078036a..96ed26b819 100644 --- a/board/coachz/board.c +++ b/board/coachz/board.c @@ -697,7 +697,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_ma = charge_ma * 95 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/coachz/board.h b/board/coachz/board.h index c332b98c34..70594d3efa 100644 --- a/board/coachz/board.h +++ b/board/coachz/board.h @@ -40,6 +40,8 @@ #define CONFIG_BATTERY_FUEL_GAUGE #define CONFIG_BATTERY_VENDOR_PARAM +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* BC 1.2 Charger */ #define CONFIG_BC12_DETECT_PI3USB9201 diff --git a/board/coral/board.c b/board/coral/board.c index c63a2f6ddc..922a19e97c 100644 --- a/board/coral/board.c +++ b/board/coral/board.c @@ -566,7 +566,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/coral/board.h b/board/coral/board.h index bc6226152c..eee201669c 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -25,6 +25,7 @@ #define CONFIG_CMD_CHARGER_ADC_AMON_BMON #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define BD9995X_IOUT_GAIN_SELECT \ BD9995X_CMD_PMON_IOUT_CTRL_SET_IOUT_GAIN_SET_20V diff --git a/board/corori/board.c b/board/corori/board.c index 4fe1e01fec..09baf1eabf 100644 --- a/board/corori/board.c +++ b/board/corori/board.c @@ -315,12 +315,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/corori/board.h b/board/corori/board.h index 75e0e4eec6..646b14227d 100644 --- a/board/corori/board.h +++ b/board/corori/board.h @@ -28,6 +28,11 @@ #undef CONFIG_CMD_CHARGER_DUMP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* LED defines */ #define CONFIG_LED_COMMON diff --git a/board/corori2/board.c b/board/corori2/board.c index efebc3af2e..c06ccbb15b 100644 --- a/board/corori2/board.c +++ b/board/corori2/board.c @@ -458,12 +458,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/corori2/board.h b/board/corori2/board.h index 79c57c98bb..c62cade1c3 100644 --- a/board/corori2/board.h +++ b/board/corori2/board.h @@ -50,6 +50,11 @@ #undef CONFIG_CHARGER_SINGLE_CHIP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* * GPIO for C1 interrupts, for baseboard use diff --git a/board/cret/board.c b/board/cret/board.c index c9c34d6d32..90bfc7d41a 100644 --- a/board/cret/board.c +++ b/board/cret/board.c @@ -308,12 +308,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/cret/board.h b/board/cret/board.h index 2080185c7c..eb6b261cdf 100644 --- a/board/cret/board.h +++ b/board/cret/board.h @@ -34,6 +34,11 @@ #define CONFIG_CHARGER_SENSE_RESISTOR 10 #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CHARGING_CURRENT_1100MA 1100 diff --git a/board/damu/board.c b/board/damu/board.c index ddc8885e22..a2415f228d 100644 --- a/board/damu/board.c +++ b/board/damu/board.c @@ -239,7 +239,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/damu/board.h b/board/damu/board.h index 49875e6883..16e03cf45c 100644 --- a/board/damu/board.h +++ b/board/damu/board.h @@ -28,6 +28,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/driblee/board.c b/board/driblee/board.c index 30075e683e..5c78dbda06 100644 --- a/board/driblee/board.c +++ b/board/driblee/board.c @@ -342,12 +342,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/driblee/board.h b/board/driblee/board.h index f6a3ac9130..514fe584ff 100644 --- a/board/driblee/board.h +++ b/board/driblee/board.h @@ -31,6 +31,11 @@ #undef CONFIG_CMD_CHARGER_DUMP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define CONFIG_MATH_UTIL #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CHARGING_CURRENT_1100MA 1100 diff --git a/board/drobit/board.c b/board/drobit/board.c index 1a20870d1f..c2bdbec773 100644 --- a/board/drobit/board.c +++ b/board/drobit/board.c @@ -481,11 +481,6 @@ DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* - * Limit the input current to 98% negotiated limit, - * to account for the charger chip margin. - */ - charge_ma = charge_ma * 98 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/drobit/board.h b/board/drobit/board.h index d6fda98f3d..bf3e64ae5a 100644 --- a/board/drobit/board.h +++ b/board/drobit/board.h @@ -89,6 +89,7 @@ /* charger defines */ #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 2 /* * Macros for GPIO signals used in common code that don't match the diff --git a/board/eldrid/board.c b/board/eldrid/board.c index 81fdf22ffc..6212c6a375 100644 --- a/board/eldrid/board.c +++ b/board/eldrid/board.c @@ -182,12 +182,6 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma, else isl9241_set_ac_prochot(0, 3328); - /* - * Follow OEM request to limit the input current to - * 90% negotiated limit. - */ - charge_ma = charge_ma * 90 / 100; - charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/eldrid/board.h b/board/eldrid/board.h index 1bbe183425..8cfac4d8bc 100644 --- a/board/eldrid/board.h +++ b/board/eldrid/board.h @@ -93,6 +93,8 @@ /* charger defines */ #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 +/* OEM requested 10% derating */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 10 /* Retimer */ #undef CONFIG_USBC_RETIMER_INTEL_BB diff --git a/board/elm/board.c b/board/elm/board.c index 4007d34379..329c411c8a 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -340,8 +340,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* Limit input current 95% ratio on elm board for safety */ - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); pd_send_host_event(PD_EVENT_POWER_CHANGE); diff --git a/board/elm/board.h b/board/elm/board.h index 2dc53dab75..31a6ec7b61 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -44,6 +44,7 @@ #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 #define CONFIG_CHARGER_DISCHARGE_ON_AC +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHIPSET_MT817X #define CONFIG_CMD_TYPEC #define CONFIG_EXTPOWER_GPIO diff --git a/board/eve/board.c b/board/eve/board.c index 3f5da1a83a..77e5b403a0 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -646,7 +646,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/eve/board.h b/board/eve/board.h index 064bce4b60..361f2ddd53 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -101,6 +101,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_MAINTAIN_VBAT #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGER_PSYS_READ diff --git a/board/ezkinil/board.c b/board/ezkinil/board.c index c9e1aca267..2173a2062d 100644 --- a/board/ezkinil/board.c +++ b/board/ezkinil/board.c @@ -869,12 +869,6 @@ int fan_percent_to_rpm(int fan, int pct) __override void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* - * Limit the input current to 95% negotiated limit, - * to account for the charger chip margin. - */ - charge_ma = charge_ma * 95 / 100; - charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/ezkinil/board.h b/board/ezkinil/board.h index aa1fe065f4..c5e6ce1771 100644 --- a/board/ezkinil/board.h +++ b/board/ezkinil/board.h @@ -15,6 +15,9 @@ #define CONFIG_KEYBOARD_FACTORY_TEST +/* charger margin */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* Motion sensing drivers */ #define CONFIG_ACCELGYRO_ICM426XX #define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \ diff --git a/board/felwinter/board.h b/board/felwinter/board.h index 17e1cf9246..0ca6a59b9c 100644 --- a/board/felwinter/board.h +++ b/board/felwinter/board.h @@ -179,6 +179,7 @@ #define CONFIG_CHARGE_RAMP_SW #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 10 #define CONFIG_KEYBOARD_REFRESH_ROW3 diff --git a/board/felwinter/charger_isl9241.c b/board/felwinter/charger_isl9241.c index dd2535ea7c..7d4026b818 100644 --- a/board/felwinter/charger_isl9241.c +++ b/board/felwinter/charger_isl9241.c @@ -80,10 +80,9 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) { - charge_ma = (charge_ma * 90) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/fennel/board.c b/board/fennel/board.c index 563f680dee..e583a21285 100644 --- a/board/fennel/board.c +++ b/board/fennel/board.c @@ -240,7 +240,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/fennel/board.h b/board/fennel/board.h index 6bb90ef0f3..42e1fcd451 100644 --- a/board/fennel/board.h +++ b/board/fennel/board.h @@ -26,6 +26,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/gelarshie/board.c b/board/gelarshie/board.c index 7ae2e06372..dfa85037a2 100644 --- a/board/gelarshie/board.c +++ b/board/gelarshie/board.c @@ -696,7 +696,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_ma = charge_ma * 95 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/gelarshie/board.h b/board/gelarshie/board.h index 34e5d47f0c..737f005639 100644 --- a/board/gelarshie/board.h +++ b/board/gelarshie/board.h @@ -43,6 +43,9 @@ #define CONFIG_BATTERY_FUEL_GAUGE #define CONFIG_BATTERY_VENDOR_PARAM +/* charger margin */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* Enable PD3.0 */ #define CONFIG_USB_PD_REV30 /* BC 1.2 Charger */ diff --git a/board/gimble/board.c b/board/gimble/board.c index 0ca135b9fd..5373eb2bff 100644 --- a/board/gimble/board.c +++ b/board/gimble/board.c @@ -185,16 +185,3 @@ __overridable void board_ps8xxx_tcpc_init(int port) CPRINTS("ps8815: fail to write reg 0x%02x", PS8815_REG_RX_EQ_AT_5G); } - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - /* - * Follow OEM request to limit the input current to - * 90% negotiated limit. - */ - charge_ma = charge_ma * 90 / 100; - - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} diff --git a/board/gimble/board.h b/board/gimble/board.h index 015f3f78e6..1d4099e7eb 100644 --- a/board/gimble/board.h +++ b/board/gimble/board.h @@ -196,6 +196,8 @@ #define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10 #define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10 #define CONFIG_CHARGER_BQ25710_PSYS_SENSING +/* OEM requested 10% derating */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 10 /* PROCHOT defines */ #define BATT_MAX_CONTINUE_DISCHARGE_WATT 45 diff --git a/board/gimble/charger.c b/board/gimble/charger.c index a4fa209246..b1a29c725b 100644 --- a/board/gimble/charger.c +++ b/board/gimble/charger.c @@ -82,8 +82,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) { charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); diff --git a/board/gooey/board.c b/board/gooey/board.c index 250f6afd61..9acbadd10d 100644 --- a/board/gooey/board.c +++ b/board/gooey/board.c @@ -263,12 +263,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/gooey/board.h b/board/gooey/board.h index b586c0f334..fde32f8866 100644 --- a/board/gooey/board.h +++ b/board/gooey/board.h @@ -32,6 +32,11 @@ */ #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* DAC for PSYS */ #define CONFIG_DAC diff --git a/board/homestar/board.c b/board/homestar/board.c index 1964bc86eb..b1a136dd67 100644 --- a/board/homestar/board.c +++ b/board/homestar/board.c @@ -644,7 +644,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_ma = charge_ma * 95 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/homestar/board.h b/board/homestar/board.h index 230aa6e7d3..60d943b300 100644 --- a/board/homestar/board.h +++ b/board/homestar/board.h @@ -27,6 +27,9 @@ #define CONFIG_BATTERY_FUEL_GAUGE #define CONFIG_BATTERY_VENDOR_PARAM +/* charger margin */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* Enable PD3.0 */ #define CONFIG_USB_PD_REV30 diff --git a/board/icarus/board.c b/board/icarus/board.c index be464e3a77..d0a98c901e 100644 --- a/board/icarus/board.c +++ b/board/icarus/board.c @@ -207,7 +207,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/icarus/board.h b/board/icarus/board.h index 98b6da3fd5..ca1a236307 100644 --- a/board/icarus/board.h +++ b/board/icarus/board.h @@ -24,6 +24,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c index 129b75f8e2..6df0b8dc82 100644 --- a/board/jacuzzi/board.c +++ b/board/jacuzzi/board.c @@ -247,7 +247,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/jacuzzi/board.h b/board/jacuzzi/board.h index 0fd5f6496d..d5d0523790 100644 --- a/board/jacuzzi/board.h +++ b/board/jacuzzi/board.h @@ -34,6 +34,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/kappa/board.c b/board/kappa/board.c index c04b24d3ed..e3e374e18d 100644 --- a/board/kappa/board.c +++ b/board/kappa/board.c @@ -220,7 +220,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/kappa/board.h b/board/kappa/board.h index 6b6461ae83..5c49053a7b 100644 --- a/board/kappa/board.h +++ b/board/kappa/board.h @@ -26,6 +26,7 @@ #define CONFIG_BATTERY_COUNT 1 #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_BC12_DETECT_PI3USB9201 diff --git a/board/lalala/board.c b/board/lalala/board.c index 78404d6821..feedfe0262 100644 --- a/board/lalala/board.c +++ b/board/lalala/board.c @@ -401,12 +401,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/lalala/board.h b/board/lalala/board.h index 4967e49752..2996ad3613 100644 --- a/board/lalala/board.h +++ b/board/lalala/board.h @@ -33,6 +33,11 @@ #undef CONFIG_CMD_CHARGER_DUMP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* GPIO for C1 interrupts, for baseboard use */ #define GPIO_USB_C1_INT_ODL GPIO_SUB_USB_C1_INT_ODL diff --git a/board/madoo/board.c b/board/madoo/board.c index eedf8e6fdd..9f2021cf99 100644 --- a/board/madoo/board.c +++ b/board/madoo/board.c @@ -316,13 +316,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - reduce - * our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/madoo/board.h b/board/madoo/board.h index 82cfa30b0e..0d5e24c2a0 100644 --- a/board/madoo/board.h +++ b/board/madoo/board.h @@ -19,6 +19,11 @@ #define CONFIG_OCPC_DEF_RBATT_MOHMS \ 22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \ */ +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define CONFIG_OCPC #undef CONFIG_CHARGER_SINGLE_CHIP diff --git a/board/magolor/board.c b/board/magolor/board.c index bfa77375e5..57f6791ae3 100644 --- a/board/magolor/board.c +++ b/board/magolor/board.c @@ -597,12 +597,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/magolor/board.h b/board/magolor/board.h index 481856323f..beb2cc279c 100644 --- a/board/magolor/board.h +++ b/board/magolor/board.h @@ -45,6 +45,11 @@ #undef CONFIG_CMD_CHARGER_DUMP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* GPIO for C1 interrupts, for baseboard use */ #define GPIO_USB_C1_INT_ODL GPIO_SUB_C1_INT_EN_RAILS_ODL diff --git a/board/makomo/board.c b/board/makomo/board.c index 24b34d9a75..09fe5fdd74 100644 --- a/board/makomo/board.c +++ b/board/makomo/board.c @@ -238,7 +238,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/makomo/board.h b/board/makomo/board.h index bf705e9560..86e5e78862 100644 --- a/board/makomo/board.h +++ b/board/makomo/board.h @@ -27,6 +27,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/metaknight/board.c b/board/metaknight/board.c index 5aa3a21cc0..f075f58ee4 100644 --- a/board/metaknight/board.c +++ b/board/metaknight/board.c @@ -400,12 +400,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/metaknight/board.h b/board/metaknight/board.h index 5bd3c56a83..79027a3e9c 100644 --- a/board/metaknight/board.h +++ b/board/metaknight/board.h @@ -22,6 +22,11 @@ #undef CONFIG_CHARGER_SINGLE_CHIP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* * GPIO for C1 interrupts, for baseboard use diff --git a/board/mithrax/board.h b/board/mithrax/board.h index d12375d678..0b6ea04bd4 100644 --- a/board/mithrax/board.h +++ b/board/mithrax/board.h @@ -176,6 +176,7 @@ #define CONFIG_CHARGE_RAMP_SW #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 10 /* RGB Keyboard */ #ifdef SECTION_IS_RW diff --git a/board/mithrax/charger_isl9241.c b/board/mithrax/charger_isl9241.c index a9eafe353e..88f5b85a41 100644 --- a/board/mithrax/charger_isl9241.c +++ b/board/mithrax/charger_isl9241.c @@ -83,7 +83,6 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 90) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/mrbland/board.c b/board/mrbland/board.c index 50ba008512..04fef6ec82 100644 --- a/board/mrbland/board.c +++ b/board/mrbland/board.c @@ -598,7 +598,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_ma = charge_ma * 95 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/mrbland/board.h b/board/mrbland/board.h index 0f78db50d9..cc6207ca83 100644 --- a/board/mrbland/board.h +++ b/board/mrbland/board.h @@ -24,6 +24,8 @@ #define CONFIG_BATTERY_FUEL_GAUGE #define CONFIG_BATTERY_VENDOR_PARAM +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* Enable PD3.0 */ #define CONFIG_USB_PD_REV30 diff --git a/board/munna/board.c b/board/munna/board.c index f6996b8460..408a81d47d 100644 --- a/board/munna/board.c +++ b/board/munna/board.c @@ -239,7 +239,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/munna/board.h b/board/munna/board.h index 5dc35c68df..20194bed88 100644 --- a/board/munna/board.h +++ b/board/munna/board.h @@ -40,6 +40,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/nautilus/board.c b/board/nautilus/board.c index 3cdd7abaf1..36b79aa0c7 100644 --- a/board/nautilus/board.c +++ b/board/nautilus/board.c @@ -538,11 +538,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* - * Limit the input current to 96% negotiated limit, - * to account for the charger chip margin. - */ - charge_ma = charge_ma * 96 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/nautilus/board.h b/board/nautilus/board.h index cbca28a71f..f40b2f00b5 100644 --- a/board/nautilus/board.h +++ b/board/nautilus/board.h @@ -84,6 +84,7 @@ #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* margining */ #define CONFIG_CMD_CHARGER_ADC_AMON_BMON #define CONFIG_HOSTCMD_PD_CONTROL #define CONFIG_EXTPOWER_GPIO diff --git a/board/nocturne/board.c b/board/nocturne/board.c index d32f036844..dbe5f50b68 100644 --- a/board/nocturne/board.c +++ b/board/nocturne/board.c @@ -764,12 +764,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * Nocturne seems to overdraw its set input current limit by about 5%. - * Request at most 95% of what's desired. - */ - icl = icl * 95 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/nocturne/board.h b/board/nocturne/board.h index 9f54c1a51d..7c38e48ee3 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -72,6 +72,11 @@ #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 128 #define CONFIG_CHARGER_ISL9238 +/* + * Nocturne seems to overdraw its set input current limit by about 5%. + * Request at most 95% of what's desired. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 #define CONFIG_CHARGER_PROFILE_OVERRIDE diff --git a/board/pico/board.c b/board/pico/board.c index f884545b6d..8dbfcdec12 100644 --- a/board/pico/board.c +++ b/board/pico/board.c @@ -323,7 +323,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/pico/board.h b/board/pico/board.h index 665cf59691..97128b54f1 100644 --- a/board/pico/board.h +++ b/board/pico/board.h @@ -28,6 +28,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/pompom/board.c b/board/pompom/board.c index 394f06be8e..b46e347f88 100644 --- a/board/pompom/board.c +++ b/board/pompom/board.c @@ -469,7 +469,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_ma = charge_ma * 95 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/pompom/board.h b/board/pompom/board.h index 40e7185c16..1282ecdb41 100644 --- a/board/pompom/board.h +++ b/board/pompom/board.h @@ -23,6 +23,8 @@ /* BC 1.2 Charger */ #define CONFIG_BC12_DETECT_PI3USB9201 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* USB */ #define CONFIG_USB_PD_TCPM_MULTI_PS8XXX #define CONFIG_USB_PD_TCPM_PS8751 diff --git a/board/primus/charger.c b/board/primus/charger.c index a4fa209246..7fabd2082e 100644 --- a/board/primus/charger.c +++ b/board/primus/charger.c @@ -81,10 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} diff --git a/board/quackingstick/board.c b/board/quackingstick/board.c index 6cdf814c74..8985254a23 100644 --- a/board/quackingstick/board.c +++ b/board/quackingstick/board.c @@ -625,7 +625,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_ma = charge_ma * 95 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/quackingstick/board.h b/board/quackingstick/board.h index 9b50237b4d..a8ec5a4231 100644 --- a/board/quackingstick/board.h +++ b/board/quackingstick/board.h @@ -32,6 +32,8 @@ #define CONFIG_BATTERY_FUEL_GAUGE #define CONFIG_BATTERY_VENDOR_PARAM +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* BC 1.2 Charger */ #define CONFIG_BC12_DETECT_PI3USB9201 diff --git a/board/rammus/board.c b/board/rammus/board.c index 8cbc6c6856..3696733047 100644 --- a/board/rammus/board.c +++ b/board/rammus/board.c @@ -569,11 +569,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* - * Limit the input current to 96% negotiated limit, - * to account for the charger chip margin. - */ - charge_ma = charge_ma * 96 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/rammus/board.h b/board/rammus/board.h index c0c8238c3e..83f0f35c57 100644 --- a/board/rammus/board.h +++ b/board/rammus/board.h @@ -88,6 +88,7 @@ #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* charger margin */ #define CONFIG_CMD_CHARGER_ADC_AMON_BMON #define CONFIG_HOSTCMD_PD_CONTROL #define CONFIG_EXTPOWER_GPIO diff --git a/board/reef/board.c b/board/reef/board.c index e41921a436..b3732f6be9 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -555,7 +555,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/reef/board.h b/board/reef/board.h index fc25024dff..bce20f4645 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -51,6 +51,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000 #define CONFIG_CHARGER_MAINTAIN_VBAT diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c index b00e451842..6196f1967a 100644 --- a/board/reef_it8320/board.c +++ b/board/reef_it8320/board.c @@ -311,7 +311,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h index 45abf34151..fc1ca0079d 100644 --- a/board/reef_it8320/board.h +++ b/board/reef_it8320/board.h @@ -49,6 +49,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000 #define CONFIG_CHARGER_MAINTAIN_VBAT diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c index 0a40f5dd04..67cbfa5aa9 100644 --- a/board/reef_mchp/board.c +++ b/board/reef_mchp/board.c @@ -748,7 +748,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h index bde2d831d3..3cc3d2b77f 100644 --- a/board/reef_mchp/board.h +++ b/board/reef_mchp/board.h @@ -54,6 +54,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000 #define CONFIG_CHARGER_MAINTAIN_VBAT diff --git a/board/sasuke/board.c b/board/sasuke/board.c index ddd5279d62..567dc8cee7 100644 --- a/board/sasuke/board.c +++ b/board/sasuke/board.c @@ -399,12 +399,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/sasuke/board.h b/board/sasuke/board.h index 64c830df0f..df390d2d99 100644 --- a/board/sasuke/board.h +++ b/board/sasuke/board.h @@ -29,6 +29,11 @@ #define CONFIG_OCPC_DEF_RBATT_MOHMS \ 22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \ */ +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define CONFIG_OCPC #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGE_RAMP_HW diff --git a/board/sasukette/board.c b/board/sasukette/board.c index e45213a63a..019df9348a 100644 --- a/board/sasukette/board.c +++ b/board/sasukette/board.c @@ -255,12 +255,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/sasukette/board.h b/board/sasukette/board.h index 44cb65239a..f06a89a5f0 100644 --- a/board/sasukette/board.h +++ b/board/sasukette/board.h @@ -36,6 +36,11 @@ #define CONFIG_CHARGER_PROFILE_OVERRIDE #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE #define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC) +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* LED */ #define CONFIG_LED_COMMON diff --git a/board/stern/board.c b/board/stern/board.c index 26576ede86..41f63d40a4 100644 --- a/board/stern/board.c +++ b/board/stern/board.c @@ -239,7 +239,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/stern/board.h b/board/stern/board.h index eedbc2a44c..d7d96ea67c 100644 --- a/board/stern/board.h +++ b/board/stern/board.h @@ -28,6 +28,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/storo/board.c b/board/storo/board.c index f6f3ed5750..e4f2ad2fb9 100644 --- a/board/storo/board.c +++ b/board/storo/board.c @@ -435,12 +435,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/storo/board.h b/board/storo/board.h index 93dd573ba1..1f33ce53b0 100644 --- a/board/storo/board.h +++ b/board/storo/board.h @@ -31,6 +31,11 @@ #define CONFIG_OCPC_DEF_RBATT_MOHMS \ 22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \ */ +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define CONFIG_OCPC #undef CONFIG_CHARGER_SINGLE_CHIP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE diff --git a/board/taeko/board.c b/board/taeko/board.c index 79ef4029d6..9f0d21b8b8 100644 --- a/board/taeko/board.c +++ b/board/taeko/board.c @@ -136,16 +136,3 @@ enum battery_present battery_hw_present(void) /* The GPIO is low when the battery is physically present */ return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES; } - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - /* - * Follow OEM request to limit the input current to - * 95% negotiated limit. - */ - charge_ma = charge_ma * 95 / 100; - - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} diff --git a/board/taeko/board.h b/board/taeko/board.h index c3193c8847..a3ae9abb00 100644 --- a/board/taeko/board.h +++ b/board/taeko/board.h @@ -26,6 +26,9 @@ #define CONFIG_MP2964 +/* OEM requested 5% charger current margin */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* LED */ #define CONFIG_LED_ONOFF_STATES diff --git a/board/taeko/charger.c b/board/taeko/charger.c index a4fa209246..29211bc033 100644 --- a/board/taeko/charger.c +++ b/board/taeko/charger.c @@ -82,8 +82,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); diff --git a/board/taniks/board.c b/board/taniks/board.c index 5da998524b..f8501d761b 100644 --- a/board/taniks/board.c +++ b/board/taniks/board.c @@ -115,16 +115,3 @@ enum battery_present battery_hw_present(void) /* The GPIO is low when the battery is physically present */ return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES; } - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - /* - * Follow OEM request to limit the input current to - * 95% negotiated limit. - */ - charge_ma = charge_ma * 95 / 100; - - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} diff --git a/board/taniks/board.h b/board/taniks/board.h index 6cd42ad7bb..a301f3b458 100644 --- a/board/taniks/board.h +++ b/board/taniks/board.h @@ -36,6 +36,9 @@ */ #define CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP +/* OEM requested 5% charger margin */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* LED */ #define CONFIG_LED_ONOFF_STATES diff --git a/board/taniks/charger.c b/board/taniks/charger.c index a4fa209246..b1a29c725b 100644 --- a/board/taniks/charger.c +++ b/board/taniks/charger.c @@ -82,8 +82,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) { charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); diff --git a/board/vell/board.h b/board/vell/board.h index 4b3d527901..3a7d97858c 100644 --- a/board/vell/board.h +++ b/board/vell/board.h @@ -61,6 +61,8 @@ #undef CONFIG_SYV682X_HV_ILIM #define CONFIG_SYV682X_HV_ILIM SYV682X_HV_ILIM_5_50 +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 + /* TODO: b/177608416 - measure and check these values on brya */ #define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ #define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */ diff --git a/board/vell/charger.c b/board/vell/charger.c index e33a0ed44a..a153d57704 100644 --- a/board/vell/charger.c +++ b/board/vell/charger.c @@ -84,11 +84,6 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* - * Limit the input current to 96% negotiated limit, - * to account for the charger chip margin. - */ - charge_ma = charge_ma * 96 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/vilboz/board.c b/board/vilboz/board.c index 7c74794d9d..fe0b8ee32e 100644 --- a/board/vilboz/board.c +++ b/board/vilboz/board.c @@ -508,12 +508,6 @@ const int usb_port_enable[USBA_PORT_COUNT] = { __override void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - /* - * Limit the input current to 95% negotiated limit, - * to account for the charger chip margin. - */ - charge_ma = charge_ma * 95 / 100; - charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/vilboz/board.h b/board/vilboz/board.h index 5160abbc26..8a7c86824d 100644 --- a/board/vilboz/board.h +++ b/board/vilboz/board.h @@ -20,6 +20,7 @@ #define GPIO_USB2_ILIM_SEL GPIO_USB_A1_CHARGE_EN_DB_L #define CONFIG_CHARGER_PROFILE_OVERRIDE +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 /* Motion sensing drivers */ #define CONFIG_ACCELGYRO_LSM6DSM diff --git a/board/waddledoo/board.c b/board/waddledoo/board.c index e207e59456..e71151f6b5 100644 --- a/board/waddledoo/board.c +++ b/board/waddledoo/board.c @@ -394,12 +394,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/waddledoo/board.h b/board/waddledoo/board.h index c13dbe37c9..23a89c84d6 100644 --- a/board/waddledoo/board.h +++ b/board/waddledoo/board.h @@ -43,6 +43,11 @@ #define CONFIG_OCPC_DEF_RBATT_MOHMS \ 22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \ */ +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define CONFIG_OCPC #undef CONFIG_CHARGER_SINGLE_CHIP #undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE diff --git a/board/waddledoo2/board.c b/board/waddledoo2/board.c index fd12aec449..b1417d8ee2 100644 --- a/board/waddledoo2/board.c +++ b/board/waddledoo2/board.c @@ -401,12 +401,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * b/147463641: The charger IC seems to overdraw ~4%, therefore we - * reduce our target accordingly. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/board/waddledoo2/board.h b/board/waddledoo2/board.h index 93f0a0f108..3b4587037d 100644 --- a/board/waddledoo2/board.h +++ b/board/waddledoo2/board.h @@ -28,6 +28,11 @@ #define CONFIG_OCPC_DEF_RBATT_MOHMS \ 22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \ */ +/* + * b/147463641: The charger IC seems to overdraw ~4%, therefore we + * reduce our target accordingly. + */ +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 #define CONFIG_OCPC #undef CONFIG_CHARGER_SINGLE_CHIP #undef CONFIG_CMD_CHARGER_DUMP diff --git a/board/willow/board.c b/board/willow/board.c index 826df6940c..3bd5c4633b 100644 --- a/board/willow/board.c +++ b/board/willow/board.c @@ -237,7 +237,6 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * 95) / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/willow/board.h b/board/willow/board.h index 18745a07a4..315c206a07 100644 --- a/board/willow/board.h +++ b/board/willow/board.h @@ -27,6 +27,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM #define CONFIG_CHARGER_PSYS +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_RUNTIME_CONFIG diff --git a/board/wormdingler/board.c b/board/wormdingler/board.c index 273c41d1a7..8705e0d2cb 100644 --- a/board/wormdingler/board.c +++ b/board/wormdingler/board.c @@ -643,7 +643,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_ma = charge_ma * 95 / 100; charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/board/wormdingler/board.h b/board/wormdingler/board.h index 3c3ba6ead5..447846c509 100644 --- a/board/wormdingler/board.h +++ b/board/wormdingler/board.h @@ -24,6 +24,8 @@ #define CONFIG_BATTERY_FUEL_GAUGE #define CONFIG_BATTERY_VENDOR_PARAM +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 + /* Enable PD3.0 */ #define CONFIG_USB_PD_REV30 diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index cd1b5988e2..6967cf5333 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -2330,6 +2330,13 @@ int charge_set_input_current_limit(int ma, int mv) { __maybe_unused int chgnum = 0; +#ifdef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT + if (CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT != 0) { + ma = (ma * (100 - CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT)) / + 100; + } +#endif + if (IS_ENABLED(CONFIG_OCPC)) chgnum = charge_get_active_chg_chip(); #ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h index 0817204774..5f886257d3 100644 --- a/include/charge_state_v2.h +++ b/include/charge_state_v2.h @@ -71,6 +71,9 @@ int charge_set_output_current_limit(int chgnum, int ma, int mv); * Set the charge input current limit. This value is stored and sent every * time AC is applied. * + * The input current limit is automatically derated by + * CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT, if configured. + * * @param ma New input current limit in mA * @param mv Negotiated charge voltage in mV. * @return EC_SUCCESS or error diff --git a/include/config.h b/include/config.h index 10de8f80bf..baf86db418 100644 --- a/include/config.h +++ b/include/config.h @@ -1037,6 +1037,21 @@ */ #undef CONFIG_CHARGER_INPUT_CURRENT +/* + * Percentage derating factor applied to charger input current limits. + * + * Desired charger current is reduced by this many percent when programming + * chargers via the charge manager, which is usually used to account for + * chargers that draw slightly more current than the programmed limit or to + * provide some margin for accuracy. For example, if this value is set to 4 + * and input current is limited to 1000 mA, the charger will be given a limit + * of 960 mA. + * + * Boards requiring more complex control over input current should leave this + * undefined and override board_set_charge_limit instead. + */ +#undef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT + /* * This config option is used to enable IDCHG trigger for prochot. This macro * should be set to the desired current limit to draw from the battery before diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc index 903cf575c6..5350c1cbbf 100644 --- a/zephyr/Kconfig.usbc +++ b/zephyr/Kconfig.usbc @@ -44,6 +44,22 @@ config PLATFORM_EC_CHARGER_INPUT_CURRENT chargers, this should be set to 512 mA in order to not brown-out low-current USB charge ports in accordance with USB-PD r3.0 Sec. 7.3 +config PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT + int "Charger input current derating percentage" + default 0 + depends on PLATFORM_EC_CHARGE_MANAGER + help + Setting this to a nonzero value causes actual charger current limits + to be adjusted by the given percentage. For example, setting this to + 4 and requesting a current limit of 1000 mA causes the charge manager + to program an actual current limit of 960 mA. + + This is useful if a charger consistently draws more current than the + programmed limit, or if it is desired to derate for other + safety-related reasons. If a more complex (non-linear) adjustment is + required, boards should override the board_set_charge_limit() + function instead of configuring this option. + config PLATFORM_EC_USBC_OCP bool help diff --git a/zephyr/program/corsola/program.conf b/zephyr/program/corsola/program.conf index 402f8ab1cf..86bd30aaed 100644 --- a/zephyr/program/corsola/program.conf +++ b/zephyr/program/corsola/program.conf @@ -86,6 +86,9 @@ CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y # Charger CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y CONFIG_PLATFORM_EC_CHARGE_MANAGER=y +# b:257167723: Adapter output current exceeds the spec on heavy-load. +# Preserve a margin in case of charger overdraw. +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=3 # Button CONFIG_PLATFORM_EC_CMD_BUTTON=y diff --git a/zephyr/program/corsola/src/usbc_config.c b/zephyr/program/corsola/src/usbc_config.c index b776bc1ca9..838f676694 100644 --- a/zephyr/program/corsola/src/usbc_config.c +++ b/zephyr/program/corsola/src/usbc_config.c @@ -129,12 +129,7 @@ __override enum pd_dual_role_states pd_get_drp_state_in_s0(void) __override void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = charge_ma * 97 / 100; - /* - * b:257167723: Adapter output current exceeds the spec on heavy-load. - * Preserve a margin in case of charger overdraw. - */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 02dc458a61..a8a2ec3319 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -134,6 +134,8 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS=200 +# Assume 4% overdraw, which could be changed with actual characterization +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=4 # Dynamically select PD voltage to maximize charger efficiency CONFIG_PLATFORM_EC_USB_PD_DPS=y diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c index e278387a84..4f27d1d84f 100644 --- a/zephyr/program/nissa/src/common.c +++ b/zephyr/program/nissa/src/common.c @@ -85,13 +85,6 @@ __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - /* - * Assume charger overdraws by about 4%, keeping the actual draw - * within spec. This adjustment can be changed with characterization - * of actual hardware. - */ - icl = icl * 96 / 100; charge_set_input_current_limit(icl, charge_mv); } diff --git a/zephyr/program/nissa/xivu/project.conf b/zephyr/program/nissa/xivu/project.conf index fe56a9d562..d686f5bd0b 100644 --- a/zephyr/program/nissa/xivu/project.conf +++ b/zephyr/program/nissa/xivu/project.conf @@ -6,6 +6,8 @@ CONFIG_BOARD_XIVU=y CONFIG_PLATFORM_EC_OCPC=y CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10 + # LED CONFIG_PLATFORM_EC_LED_COMMON=n CONFIG_PLATFORM_EC_LED_DT=y diff --git a/zephyr/program/skyrim/Kconfig b/zephyr/program/skyrim/Kconfig index fbb797f6fc..896958e446 100644 --- a/zephyr/program/skyrim/Kconfig +++ b/zephyr/program/skyrim/Kconfig @@ -26,12 +26,6 @@ config BOARD_FROSTFLOW Build Google Frostflow reference board. This board uses an AMD SoC and NPCX9 EC -config BOARD_INPUT_CURRENT_SCALE_FACTOR - int "Input current scale factor" - default 100 - help - Limit input current to fraction of negotiated limit. - config BOARD_USB_HUB_RESET bool "Support USB hub reset or not" default y diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf index caae3ba985..835230be67 100644 --- a/zephyr/program/skyrim/prj_frostflow.conf +++ b/zephyr/program/skyrim/prj_frostflow.conf @@ -4,7 +4,7 @@ # Frostflow reference-board-specific Kconfig settings. CONFIG_BOARD_FROSTFLOW=y -CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR=90 +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10 # TODO(b/215404321): Remove later in board development CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y diff --git a/zephyr/program/skyrim/src/usbc_config.c b/zephyr/program/skyrim/src/usbc_config.c index dec9f928b5..1795cb2b1e 100644 --- a/zephyr/program/skyrim/src/usbc_config.c +++ b/zephyr/program/skyrim/src/usbc_config.c @@ -193,8 +193,6 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_ma = (charge_ma * CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR) / 100; - charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 1d88f1832e..f8e69fe55d 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1077,6 +1077,12 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256]; #define CONFIG_CHARGER_INPUT_CURRENT CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT #endif +#undef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT +#ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT +#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT \ + CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT +#endif + #undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON #ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON \ diff --git a/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c index d6504b92f9..e1c602e86d 100644 --- a/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c +++ b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c @@ -97,3 +97,20 @@ ZTEST(charge_state_v2, test_battery_temperature_range) (batt_info->charging_max_c + batt_info->charging_min_c) / 2); zassert_ok(battery_outside_charging_temperature()); } + +ZTEST(charge_state_v2, test_current_limit_derating) +{ + int charger_current_limit; + + charge_set_input_current_limit(1000, 5000); + zassert_ok(charger_get_input_current_limit(0, &charger_current_limit)); + /* + * ISL923x sets ICL in multiples of 20 mA, so 950 mA gets rounded down + * to the nearest multiple of 20. + */ + zassert_equal( + charger_current_limit, 944, + "%d%% derating of 1A should be 944 mA, but charger is set for %d mA", + CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT, + charger_current_limit); +} diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 8a68a2af23..9548596026 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -51,6 +51,7 @@ tests: - CONFIG_PLATFORM_EC_CBI_GPIO=y drivers.common_charger: extra_configs: + - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=5 - CONFIG_LINK_TEST_SUITE_COMMON_CHARGER=y # Set to focus testing for Herobrine # Config is y only in nissa -- cgit v1.2.1 From afdd762d014f295e19b71d789890e565d5b9286d Mon Sep 17 00:00:00 2001 From: Rob Barnes Date: Wed, 14 Sep 2022 20:47:00 +0000 Subject: system: Ensure space for panic and jump data Ensure space is available for end of ram data. End of ram data must be located at the very end of noinit ram. This currently includes panic_data followed by jump_data. This is being enforced with linker asserts and build asserts rather than allocating the space directly so RAM utiliztion reports are still relevant. Introduce PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE config option and default it to 1KB. This can be adjusted on boards that are constrained. BUG=b:246778588,b:246798928 BRANCH=None TEST=./twister -c -s zephyr/test/jump_tags/jump_tags.default && make run-kb_8042 Change-Id: I444bbe3a583396b4f9b104bb6999e78ae3ff6f2f Signed-off-by: Rob Barnes Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3896272 Reviewed-by: Aaron Massey Reviewed-by: Daisuke Nojiri Reviewed-by: Fabio Baltieri Code-Coverage: Zoss --- common/panic_output.c | 12 +- common/system.c | 34 ++++- include/config.h | 5 + include/sysjump.h | 10 ++ include/system.h | 2 +- zephyr/Kconfig.panic | 8 + zephyr/linker/CMakeLists.txt | 4 + zephyr/linker/end-of-ram.ld | 29 ++++ zephyr/shim/include/config_chip.h | 14 +- zephyr/shim/src/ztest_system.c | 2 +- zephyr/test/jump_tags/CMakeLists.txt | 13 ++ zephyr/test/jump_tags/boards/native_posix.overlay | 33 ++++ zephyr/test/jump_tags/prj.conf | 15 ++ zephyr/test/jump_tags/src/jump_tags.c | 175 ++++++++++++++++++++++ zephyr/test/jump_tags/testcase.yaml | 13 ++ 15 files changed, 360 insertions(+), 9 deletions(-) create mode 100644 zephyr/linker/end-of-ram.ld create mode 100644 zephyr/test/jump_tags/CMakeLists.txt create mode 100644 zephyr/test/jump_tags/boards/native_posix.overlay create mode 100644 zephyr/test/jump_tags/prj.conf create mode 100644 zephyr/test/jump_tags/src/jump_tags.c create mode 100644 zephyr/test/jump_tags/testcase.yaml diff --git a/common/panic_output.c b/common/panic_output.c index 2f92e65514..a5bba9d184 100644 --- a/common/panic_output.c +++ b/common/panic_output.c @@ -208,7 +208,7 @@ struct panic_data *get_panic_data_write(void) * end of RAM. */ struct panic_data *const pdata_ptr = PANIC_DATA_PTR; - const struct jump_data *jdata_ptr; + struct jump_data *jdata_ptr; uintptr_t data_begin; size_t move_size; int delta; @@ -264,6 +264,16 @@ struct panic_data *get_panic_data_write(void) move_size = 0; } + /* Check if there's enough space for jump tags after move */ + if (data_begin - move_size < JUMP_DATA_MIN_ADDRESS) { + /* Not enough room for jump tags, clear tags. + * TODO(b/251190975): This failure should be reported + * in the panic data structure for more visibility. + */ + move_size -= jdata_ptr->jump_tag_total; + jdata_ptr->jump_tag_total = 0; + } + data_begin -= move_size; if (move_size != 0) { diff --git a/common/system.c b/common/system.c index 375cca2882..af5d670216 100644 --- a/common/system.c +++ b/common/system.c @@ -67,6 +67,11 @@ static enum ec_reboot_cmd reboot_at_shutdown; static enum sysinfo_flags system_info_flags; +/* Ensure enough space for panic_data, jump_data and at least one jump tag */ +BUILD_ASSERT((sizeof(struct panic_data) + sizeof(struct jump_data) + + JUMP_TAG_MAX_SIZE) <= CONFIG_PRESERVED_END_OF_RAM_SIZE, + "End of ram data size is too small for panic and jump data"); + STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_seconds; STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_microseconds; @@ -349,15 +354,24 @@ test_mockable int system_jumped_late(void) int system_add_jump_tag(uint16_t tag, int version, int size, const void *data) { struct jump_tag *t; + size_t new_entry_size; /* Only allowed during a sysjump */ if (!jdata || jdata->magic != JUMP_DATA_MAGIC) return EC_ERROR_UNKNOWN; /* Make room for the new tag */ - if (size > 255) + if (size > JUMP_TAG_MAX_SIZE) return EC_ERROR_INVAL; - jdata->jump_tag_total += ROUNDUP4(size) + sizeof(struct jump_tag); + + new_entry_size = ROUNDUP4(size) + sizeof(struct jump_tag); + + if (system_usable_ram_end() - new_entry_size < JUMP_DATA_MIN_ADDRESS) { + ccprintf("ERROR: out of space for jump tags\n"); + return EC_ERROR_INVAL; + } + + jdata->jump_tag_total += new_entry_size; t = (struct jump_tag *)system_usable_ram_end(); t->tag = tag; @@ -378,6 +392,10 @@ test_mockable const uint8_t *system_get_jump_tag(uint16_t tag, int *version, if (!jdata) return NULL; + /* Ensure system_usable_ram_end() is within bounds */ + if (system_usable_ram_end() < JUMP_DATA_MIN_ADDRESS) + return NULL; + /* Search through tag data for a match */ while (used < jdata->jump_tag_total) { /* Check the next tag */ @@ -918,6 +936,18 @@ void system_common_pre_init(void) else delta = sizeof(struct jump_data) - jdata->struct_size; + /* + * Check if enough space for jump data. + * Clear jump data and return if not. + */ + if (system_usable_ram_end() < JUMP_DATA_MIN_ADDRESS) { + /* TODO(b/251190975): This failure should be reported + * in the panic data structure for more visibility. + */ + memset(jdata, 0, sizeof(struct jump_data)); + return; + } + if (delta && jdata->jump_tag_total) { uint8_t *d = (uint8_t *)system_usable_ram_end(); memmove(d, d + delta, jdata->jump_tag_total); diff --git a/include/config.h b/include/config.h index baf86db418..e8bcf8b604 100644 --- a/include/config.h +++ b/include/config.h @@ -6944,4 +6944,9 @@ #define HAS_GPU_DRIVER #endif +/* Default to 1024 for end of ram data (panic and jump data) */ +#ifndef CONFIG_PRESERVED_END_OF_RAM_SIZE +#define CONFIG_PRESERVED_END_OF_RAM_SIZE 1024 +#endif + #endif /* __CROS_EC_CONFIG_H */ diff --git a/include/sysjump.h b/include/sysjump.h index 7d86df2e61..b7779b9c86 100644 --- a/include/sysjump.h +++ b/include/sysjump.h @@ -21,6 +21,16 @@ #define JUMP_DATA_SIZE_V1 12 /* Size of version 1 jump data struct */ #define JUMP_DATA_SIZE_V2 16 /* Size of version 2 jump data struct */ +#define JUMP_TAG_MAX_SIZE 255 + +#if !defined(CONFIG_RAM_SIZE) || !(CONFIG_RAM_SIZE > 0) +/* Disable check by setting jump data min address to zero */ +#define JUMP_DATA_MIN_ADDRESS 0 +#else +#define JUMP_DATA_MIN_ADDRESS \ + (CONFIG_RAM_BASE + CONFIG_RAM_SIZE - CONFIG_PRESERVED_END_OF_RAM_SIZE) +#endif + struct jump_data { /* * Add new fields to the _start_ of the struct, since we copy it to the diff --git a/include/system.h b/include/system.h index ed811e9626..4d98136da5 100644 --- a/include/system.h +++ b/include/system.h @@ -214,7 +214,7 @@ int system_jumped_late(void); * This may ONLY be called from within a HOOK_SYSJUMP handler. * * @param tag Data type - * @param size Size of data; must be less than 255 bytes. + * @param size Size of data; must be less than JUMP_TAG_MAX_SIZE bytes. * @param version Data version, so that tag data can evolve as firmware * is updated. * @param data Pointer to data to save diff --git a/zephyr/Kconfig.panic b/zephyr/Kconfig.panic index c402fc1e70..4bffa64b39 100644 --- a/zephyr/Kconfig.panic +++ b/zephyr/Kconfig.panic @@ -2,6 +2,14 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +config PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE + int "Size of preserved ram for panic and jump data" + default 1024 + help + Size of preserved non-initialized memory at end of ram for panic and + jump data. The linker will ensure at least this much space is + unallocated. + if PLATFORM_EC_PANIC config PLATFORM_EC_SOFTWARE_PANIC diff --git a/zephyr/linker/CMakeLists.txt b/zephyr/linker/CMakeLists.txt index 94544d454b..adffc2246f 100644 --- a/zephyr/linker/CMakeLists.txt +++ b/zephyr/linker/CMakeLists.txt @@ -21,3 +21,7 @@ zephyr_linker_sources_ifdef(CONFIG_SOC_FAMILY_MEC ROM_START SORT_KEY 1 zephyr_linker_sources(DATA_SECTIONS iterables-ram.ld) zephyr_linker_sources(SECTIONS iterables-rom.ld) + +# Ensure there's space for panic and jump data at the end of ram +# Must be added to "SECTIONS" because this is applied last +zephyr_linker_sources(SECTIONS end-of-ram.ld) diff --git a/zephyr/linker/end-of-ram.ld b/zephyr/linker/end-of-ram.ld new file mode 100644 index 0000000000..e03de7481d --- /dev/null +++ b/zephyr/linker/end-of-ram.ld @@ -0,0 +1,29 @@ +/* Copyright 2022 The Chromium OS Authors. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* This section simply ensures there's enough unused space at the end of ram to + * hold panic and jump data. This space isn't directly allocated because it + * would result in the SRAM utilization always being reported as 100%. + */ +#if !defined(CONFIG_BOARD_NATIVE_POSIX) +SECTION_PROLOGUE(.end_of_ram_info, 0, ) +{ + ASSERT(DEFINED(_image_ram_end) && _image_ram_end > 0, "Error: _image_ram_end is not defined"); + +#if defined(RAM_ADDR) && defined(RAM_SIZE) + PROVIDE(__unused_ram_start = _image_ram_end); + PROVIDE(__unused_ram_end = RAM_ADDR + RAM_SIZE); + PROVIDE(__unused_ram_size = __unused_ram_end - __unused_ram_start); + ASSERT(__unused_ram_size >= CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE, + "ERROR: Not enough space for preserved end of ram data (see PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE)"); +#endif + +#if defined(CONFIG_SHAREDMEM_MINIMUM_SIZE) + ASSERT(CONFIG_SHAREDMEM_MINIMUM_SIZE >= CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE, + "ERROR: Sharedmem must be at least large enough for preserved end of ram data"); +#endif + +} +#endif diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index f8e69fe55d..3caa3db634 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -495,17 +495,23 @@ /* The jump data goes at the end of data ram, so for posix, the end of ram is * wherever the jump data ended up. */ -#include "sysjump.h" -extern char mock_jump_data[sizeof(struct jump_data) + 256]; +extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; #define CONFIG_RAM_BASE 0x0 -#define CONFIG_DATA_RAM_SIZE \ - (((uintptr_t)&mock_jump_data) + sizeof(mock_jump_data)) +#define CONFIG_DATA_RAM_SIZE \ + (((uintptr_t)&mock_jump_data) + \ + CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE) #else #error "A zephyr,sram device must be chosen in the device tree" #endif #define CONFIG_RAM_SIZE CONFIG_DATA_RAM_SIZE +#undef CONFIG_PRESERVED_END_OF_RAM_SIZE +#ifdef CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE +#define CONFIG_PRESERVED_END_OF_RAM_SIZE \ + CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE +#endif + #define CONFIG_RO_MEM_OFF CONFIG_CROS_EC_RO_MEM_OFF #define CONFIG_RO_MEM_SIZE CONFIG_CROS_EC_RO_MEM_SIZE #define CONFIG_RW_MEM_OFF CONFIG_CROS_EC_RW_MEM_OFF diff --git a/zephyr/shim/src/ztest_system.c b/zephyr/shim/src/ztest_system.c index 5933f18f05..13614ec8f0 100644 --- a/zephyr/shim/src/ztest_system.c +++ b/zephyr/shim/src/ztest_system.c @@ -12,7 +12,7 @@ #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) -char mock_jump_data[sizeof(struct jump_data) + 256]; +char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; /* When CONFIG_RAM_SIZE is defined, this is provided by common/system.c */ #ifndef CONFIG_RAM_SIZE diff --git a/zephyr/test/jump_tags/CMakeLists.txt b/zephyr/test/jump_tags/CMakeLists.txt new file mode 100644 index 0000000000..710195275e --- /dev/null +++ b/zephyr/test/jump_tags/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(jump_tags) + +# Include FFF fakes +add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) + +FILE(GLOB test_sources src/*.c) +target_sources(app PRIVATE ${test_sources}) diff --git a/zephyr/test/jump_tags/boards/native_posix.overlay b/zephyr/test/jump_tags/boards/native_posix.overlay new file mode 100644 index 0000000000..9f3238d076 --- /dev/null +++ b/zephyr/test/jump_tags/boards/native_posix.overlay @@ -0,0 +1,33 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +/ { + chosen { + cros-ec,flash = &flash1; + cros-ec,flash-controller = &cros_flash; + }; + aliases { + gpio-wp = &gpio_wp_l; + }; + named-gpios { + compatible = "named-gpios"; + gpio_wp_l: wp_l { + gpios = <&gpio0 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + }; + cros_flash: cros-flash { + compatible = "cros-ec,flash-emul"; + }; + flash1: flash@64000000 { + reg = <0x64000000 DT_SIZE_K(512)>; + }; +}; + +&gpio0 { + ngpios = <4>; +}; diff --git a/zephyr/test/jump_tags/prj.conf b/zephyr/test/jump_tags/prj.conf new file mode 100644 index 0000000000..9a2a537b89 --- /dev/null +++ b/zephyr/test/jump_tags/prj.conf @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_EMUL_CROS_FLASH=y +CONFIG_FLASH=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGEN=n +CONFIG_PLATFORM_EC=y +CONFIG_SERIAL=y +CONFIG_SHELL_BACKEND_DUMMY=y +CONFIG_SHELL_BACKEND_SERIAL=n +CONFIG_SHIMMED_TASKS=y +CONFIG_ZTEST_NEW_API=y +CONFIG_ZTEST=y diff --git a/zephyr/test/jump_tags/src/jump_tags.c b/zephyr/test/jump_tags/src/jump_tags.c new file mode 100644 index 0000000000..5811f11648 --- /dev/null +++ b/zephyr/test/jump_tags/src/jump_tags.c @@ -0,0 +1,175 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "ec_commands.h" +#include "hooks.h" +#include "host_command.h" +#include "sysjump.h" +#include "system_fake.h" +#include "system.h" + +#define TEST_BASIC_JUMP_TAG 0x9901 +#define TEST_MISSING_JUMP_TAG 0x9902 +#define TEST_MAX_JUMP_TAG 0x9903 +#define TEST_TOO_BIG_JUMP_TAG 0x9904 + +#define TEST_JUMP_TAG_VERSION 1 + +#define SOME_STR_VAL "JumpTagTest" + +void (*add_tag_func)(void); + +struct test_basic_jump_data_struct { + char some_str[32]; +}; + +struct test_max_jump_data_struct { + char some_str[JUMP_TAG_MAX_SIZE]; +}; + +struct test_too_big_jump_data_struct { + char some_str[JUMP_TAG_MAX_SIZE + 1]; +}; + +static void system_before(void *data) +{ + add_tag_func = NULL; + system_common_pre_init(); + system_set_shrspi_image_copy(EC_IMAGE_RO); +} + +static void do_fake_sysjump(void) +{ + jmp_buf env; + enum ec_image target_image = system_get_image_copy() == EC_IMAGE_RO ? + EC_IMAGE_RW : + EC_IMAGE_RO; + + if (!setjmp(env)) { + system_fake_setenv(&env); + system_run_image_copy(target_image); + zassert_unreachable(); + } + + system_set_shrspi_image_copy(target_image); + zassert_equal(system_get_image_copy(), target_image); +} + +static void add_max_jump_tag(void) +{ + struct test_max_jump_data_struct max_tag = { + .some_str = SOME_STR_VAL, + }; + zassert_ok(system_add_jump_tag(TEST_MAX_JUMP_TAG, TEST_JUMP_TAG_VERSION, + sizeof(max_tag), &max_tag)); +} + +static void add_too_big_jump_tag(void) +{ + struct test_too_big_jump_data_struct too_big_tag = { + .some_str = SOME_STR_VAL, + }; + zassert_equal(system_add_jump_tag(TEST_TOO_BIG_JUMP_TAG, + TEST_JUMP_TAG_VERSION, + sizeof(too_big_tag), &too_big_tag), + EC_ERROR_INVAL); +} + +static void add_too_many_jump_tags(void) +{ + int rv; + struct test_max_jump_data_struct max_tag = { + .some_str = SOME_STR_VAL, + }; + /* Ensure at least one tag can be added, but not 10 */ + for (int i = 0; i < 10; i++) { + rv = system_add_jump_tag(TEST_MAX_JUMP_TAG, + TEST_JUMP_TAG_VERSION, sizeof(max_tag), + &max_tag); + if (rv != 0) { + zassert_equal(rv, EC_ERROR_INVAL); + zassert_true(i > 0); + return; + } + } + zassert_unreachable( + "Adding too many jump tags failed to result in an error"); +} + +static void add_basic_jump_tag(void) +{ + struct test_basic_jump_data_struct basic_tag = { + .some_str = SOME_STR_VAL, + }; + zassert_ok(system_add_jump_tag(TEST_BASIC_JUMP_TAG, + TEST_JUMP_TAG_VERSION, sizeof(basic_tag), + &basic_tag)); +} + +static void test_sysjump_hook(void) +{ + if (add_tag_func) + add_tag_func(); +} +DECLARE_HOOK(HOOK_SYSJUMP, test_sysjump_hook, HOOK_PRIO_DEFAULT); + +static void check_for_jump_tag(int jump_tag, int expected_size) +{ + int version; + int size; + const unsigned char *data; + + data = system_get_jump_tag(jump_tag, &version, &size); + zassert_equal(size, expected_size); + zassert_equal(version, TEST_JUMP_TAG_VERSION); + zassert_equal(strcmp(data, SOME_STR_VAL), 0); +} + +ZTEST(jump_tags, test_get_missing_jump_tag) +{ + int version; + int size; + struct test_jump_data_struct *data; + + data = (struct test_jump_data_struct *)system_get_jump_tag( + TEST_MISSING_JUMP_TAG, &version, &size); + zassert_equal(data, NULL); +} + +ZTEST(jump_tags, test_add_max_jump_tag) +{ + add_tag_func = add_max_jump_tag; + do_fake_sysjump(); + check_for_jump_tag(TEST_MAX_JUMP_TAG, + sizeof(struct test_max_jump_data_struct)); +} + +ZTEST(jump_tags, test_too_big_jump_tag) +{ + add_tag_func = add_too_big_jump_tag; + do_fake_sysjump(); +} + +ZTEST(jump_tags, test_too_many_jump_tags) +{ + add_tag_func = add_too_many_jump_tags; + do_fake_sysjump(); + check_for_jump_tag(TEST_MAX_JUMP_TAG, + sizeof(struct test_max_jump_data_struct)); +} + +ZTEST(jump_tags, test_add_basic_jump_tag) +{ + add_tag_func = add_basic_jump_tag; + do_fake_sysjump(); + check_for_jump_tag(TEST_BASIC_JUMP_TAG, + sizeof(struct test_basic_jump_data_struct)); +} + +ZTEST_SUITE(jump_tags, NULL, NULL, system_before, NULL, NULL); diff --git a/zephyr/test/jump_tags/testcase.yaml b/zephyr/test/jump_tags/testcase.yaml new file mode 100644 index 0000000000..11ef8d73ec --- /dev/null +++ b/zephyr/test/jump_tags/testcase.yaml @@ -0,0 +1,13 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +common: + platform_allow: native_posix +tests: + jump_tags.default: + extra_configs: + - CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE=1024 + tags: + common + system -- cgit v1.2.1 From 925dec6cc62e41b67799e7afc6ff518f9b18c9c5 Mon Sep 17 00:00:00 2001 From: Edward Hill Date: Wed, 16 Nov 2022 21:01:43 +0000 Subject: util: Improve uart_stress_tester.py Adjust prompt detection and cleanup to work with AP UART, not just EC UART. BUG=b:227228605 BRANCH=none TEST=uart_stress_tester.py -t 10 -d Change-Id: I9041e926b11e287942fe3152652fc38e2df7b1d2 Signed-off-by: Edward Hill Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032321 Reviewed-by: Mark Hasemeyer Code-Coverage: Zoss --- util/uart_stress_tester.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/util/uart_stress_tester.py b/util/uart_stress_tester.py index 3b29a50a2b..05976889d6 100755 --- a/util/uart_stress_tester.py +++ b/util/uart_stress_tester.py @@ -90,6 +90,7 @@ class UartSerial: "touch " + FLAG_FILENAME, # Create a temp file ], "cleanup_cmd": [ + "\x03", "rm -f " + FLAG_FILENAME, # Remove the temp file "dmesg -E", # Enable console message "logout", # Logout @@ -109,7 +110,7 @@ class UartSerial: "prompt": "ec:~$", "device_type": "EC(Zephyr)", "prepare_cmd": ["chan save", "chan 0"], # Disable console message - "cleanup_cmd": ["", "chan restore"], + "cleanup_cmd": ["x", "", "chan restore"], "end_of_input": CRLF, }, ) @@ -213,8 +214,6 @@ class UartSerial: self.serial.flushInput() self.serial.flushOutput() - # Send 'x' to cancel any previous chargen command still running. - self.run_command(["x"], delay=1) self.get_output() # drain data # Send a couple of line feeds, and capture the prompt text. @@ -330,9 +329,9 @@ class UartSerial: if captured: if self.num_ch_cap == 0: # Strip prompt on first read (if it's there) - prefixstr = self.dev_prof["prompt"] + " " - if captured.startswith(prefixstr): - captured = captured[len(prefixstr) :] + start = captured.find("0123") + if start > 0: + captured = captured[start:] # There is some output data. Reset the data starvation count. data_starve_count = 0 else: -- cgit v1.2.1 From fe22a4525d7224937e3b1470f624ce2a4a2f0e2d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 08:40:32 -0800 Subject: util/build_with_clang: More boards successfully compile BRANCH=none BUG=b:172020503 TEST=./util/build_with_clang.py Signed-off-by: Tom Hughes Change-Id: Ie096e68f8e2f1287aac04babf63e2759039e591d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024041 Code-Coverage: Zoss Reviewed-by: Abe Levkoy --- util/build_with_clang.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 5d662f7bce..7a728ba591 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -28,10 +28,12 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ # Boards that use CHIP:=stm32 and *not* CHIP_FAMILY:=stm32f0 # git grep --name-only 'CHIP:=stm32' | xargs grep -L 'CHIP_FAMILY:=stm32f0' | sed 's#board/\(.*\)/build.mk#"\1",#' "baklava", + "bellis", "discovery", "gingerbread", "hatch_fp", "hyperdebug", + "munna", "nocturne_fp", "nucleo-f411re", "nucleo-g431rb", @@ -45,19 +47,30 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ # git grep --name-only 'CHIP:=stm32' | xargs grep -L 'CHIP_FAMILY:=stm32f0' | sed 's#board/\(.*\)/build.mk#"\1",#' "bland", "c2d2", + "cerise", "coffeecake", + "damu", "dingdong", "discovery-stm32f072", "don", "duck", "eel", "elm", + "fennel", "fluffy", "fusb307bgevb", "gelatin", "hammer", "hoho", + "jacuzzi", + "juniper", + "kakadu", + "kappa", + "katsu", + "krane", + "kukui", "magnemite", + "makomo", "masterball", "minimuffin", "moonball", @@ -73,9 +86,11 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "servo_v4p1", "staff", "star", + "stern", "tigertail", "twinkie", "wand", + "willow", "zed", "zinger", # Boards that use CHIP:=mchp @@ -274,26 +289,10 @@ RISCV_BOARDS = [ ] BOARDS_THAT_FAIL_WITH_CLANG = [ - # Boards that use CHIP:=stm32 and *not* CHIP_FAMILY:=stm32f0 - "bellis", # overflows flash - "munna", # overflows flash # Boards that use CHIP:=stm32 *and* CHIP_FAMILY:=stm32f0 "burnet", # overflows flash - "cerise", # overflows flash "chocodile_vpdmcu", # compilation error: b/254710459 - "damu", # overflows flash - "fennel", # overflows flash - "jacuzzi", # overflows flash - "juniper", # overflows flash - "kakadu", # overflows flash - "kappa", # overflows flash - "katsu", # overflows flash "kodama", # overflows flash - "krane", # overflows flash - "kukui", # overflows flash - "makomo", # overflows flash - "stern", # overflows flash - "willow", # overflows flash # Boards that use CHIP:=npcx "garg", # overflows flash "mushu", # overflows flash -- cgit v1.2.1 From f24003765b325932c9109527a7eb077197f277fc Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Wed, 16 Nov 2022 12:09:40 -0800 Subject: builtin/assert: Make assert.h C++ friendly Update the keyword "noreturn" when the code is compiled for C++. This follows the approach used for system_reset() in include/system.h. BUG=b:235476822 TEST=test/run_device_tests.py -b bloonchipper -t aes TEST=make run-aes BRANCH=none Signed-off-by: Andrea Grandi Change-Id: I8ec7b3e0c776fa620e699fd646a625d45eb885da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032314 Code-Coverage: Zoss Reviewed-by: Tom Hughes --- builtin/assert.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/builtin/assert.h b/builtin/assert.h index 2e943f7615..71a275bf23 100644 --- a/builtin/assert.h +++ b/builtin/assert.h @@ -21,7 +21,12 @@ extern "C" { #ifdef CONFIG_DEBUG_ASSERT_REBOOTS #ifdef CONFIG_DEBUG_ASSERT_BRIEF -noreturn void panic_assert_fail(const char *fname, int linenum); +#if defined(__cplusplus) && !defined(__clang__) +[[noreturn]] +#else +noreturn +#endif +void panic_assert_fail(const char *fname, int linenum); #define ASSERT(cond) \ do { \ if (!(cond)) \ @@ -30,7 +35,12 @@ noreturn void panic_assert_fail(const char *fname, int linenum); #else /* !CONFIG_DEBUG_ASSERT_BRIEF */ -noreturn void panic_assert_fail(const char *msg, const char *func, +#if defined(__cplusplus) && !defined(__clang__) +[[noreturn]] +#else +noreturn +#endif +void panic_assert_fail(const char *msg, const char *func, const char *fname, int linenum); #define ASSERT(cond) \ do { \ -- cgit v1.2.1 From ba50d8b3f7a6a9e24f24233cf61616c950606d0e Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Wed, 16 Nov 2022 12:08:57 -0800 Subject: test: Convert AES test to C++ Convert the AES test file from C to C++ to be able to use the benchmark library later on. BUG=b:235476822 TEST=test/run_device_tests.py -b bloonchipper -t aes TEST=make run-aes BRANCH=none Signed-off-by: Andrea Grandi Change-Id: I5f0dd0a5f256e75b8688b28cc37c56b2f98039d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4026545 Reviewed-by: Tom Hughes Code-Coverage: Zoss --- test/aes.c | 588 ----------------------------------------------------------- test/aes.cc | 592 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 592 insertions(+), 588 deletions(-) delete mode 100644 test/aes.c create mode 100644 test/aes.cc diff --git a/test/aes.c b/test/aes.c deleted file mode 100644 index 0fc220d997..0000000000 --- a/test/aes.c +++ /dev/null @@ -1,588 +0,0 @@ -/* Copyright 2018 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#include "aes.h" -#include "aes-gcm.h" -#include "builtin/assert.h" -#include "console.h" -#include "common.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" -#include "watchdog.h" - -/* Temporary buffer, to avoid using too much stack space. */ -static uint8_t tmp[512]; - -/* - * Do encryption, put result in |result|, and compare with |ciphertext|. - */ -static int test_aes_gcm_encrypt(uint8_t *result, const uint8_t *key, - int key_size, const uint8_t *plaintext, - const uint8_t *ciphertext, int plaintext_size, - const uint8_t *nonce, int nonce_size, - const uint8_t *tag, int tag_size) -{ - static AES_KEY aes_key; - static GCM128_CONTEXT ctx; - - TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0); - - CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); - CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); - TEST_ASSERT(CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, result, - plaintext_size)); - TEST_ASSERT(CRYPTO_gcm128_finish(&ctx, tag, tag_size)); - TEST_ASSERT_ARRAY_EQ(ciphertext, result, plaintext_size); - - return EC_SUCCESS; -} - -/* - * Do decryption, put result in |result|, and compare with |plaintext|. - */ -static int test_aes_gcm_decrypt(uint8_t *result, const uint8_t *key, - int key_size, const uint8_t *plaintext, - const uint8_t *ciphertext, int plaintext_size, - const uint8_t *nonce, int nonce_size, - const uint8_t *tag, int tag_size) -{ - static AES_KEY aes_key; - static GCM128_CONTEXT ctx; - - TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0); - - CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); - CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); - TEST_ASSERT(CRYPTO_gcm128_decrypt(&ctx, &aes_key, ciphertext, result, - plaintext_size)); - TEST_ASSERT(CRYPTO_gcm128_finish(&ctx, tag, tag_size)); - TEST_ASSERT_ARRAY_EQ(plaintext, result, plaintext_size); - - return EC_SUCCESS; -} - -static int test_aes_gcm_raw_inplace(const uint8_t *key, int key_size, - const uint8_t *plaintext, - const uint8_t *ciphertext, - int plaintext_size, const uint8_t *nonce, - int nonce_size, const uint8_t *tag, - int tag_size) -{ - /* - * Make copies that will be clobbered during in-place encryption or - * decryption. - */ - uint8_t plaintext_copy[plaintext_size]; - uint8_t ciphertext_copy[plaintext_size]; - - memcpy(plaintext_copy, plaintext, plaintext_size); - memcpy(ciphertext_copy, ciphertext, plaintext_size); - - TEST_ASSERT(test_aes_gcm_encrypt(plaintext_copy, key, key_size, - plaintext_copy, ciphertext, - plaintext_size, nonce, nonce_size, tag, - tag_size) == EC_SUCCESS); - - TEST_ASSERT(test_aes_gcm_decrypt(ciphertext_copy, key, key_size, - plaintext, ciphertext_copy, - plaintext_size, nonce, nonce_size, tag, - tag_size) == EC_SUCCESS); - - return EC_SUCCESS; -} - -static int test_aes_gcm_raw_non_inplace(const uint8_t *key, int key_size, - const uint8_t *plaintext, - const uint8_t *ciphertext, - int plaintext_size, - const uint8_t *nonce, int nonce_size, - const uint8_t *tag, int tag_size) -{ - TEST_ASSERT(test_aes_gcm_encrypt(tmp, key, key_size, plaintext, - ciphertext, plaintext_size, nonce, - nonce_size, tag, - tag_size) == EC_SUCCESS); - - TEST_ASSERT(test_aes_gcm_decrypt(tmp, key, key_size, plaintext, - ciphertext, plaintext_size, nonce, - nonce_size, tag, - tag_size) == EC_SUCCESS); - - return EC_SUCCESS; -} - -static int test_aes_gcm_raw(const uint8_t *key, int key_size, - const uint8_t *plaintext, const uint8_t *ciphertext, - int plaintext_size, const uint8_t *nonce, - int nonce_size, const uint8_t *tag, int tag_size) -{ - TEST_ASSERT(plaintext_size <= sizeof(tmp)); - - TEST_ASSERT(test_aes_gcm_raw_non_inplace(key, key_size, plaintext, - ciphertext, plaintext_size, - nonce, nonce_size, tag, - tag_size) == EC_SUCCESS); - TEST_ASSERT(test_aes_gcm_raw_inplace(key, key_size, plaintext, - ciphertext, plaintext_size, nonce, - nonce_size, tag, - tag_size) == EC_SUCCESS); - - return EC_SUCCESS; -} - -static int test_aes_gcm(void) -{ - /* - * Test vectors from BoringSSL crypto/fipsmodule/modes/gcm_tests.txt - * (only the ones with actual data, and no additional data). - */ - static const uint8_t key1[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t plain1[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t nonce1[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t cipher1[] = { - 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, - 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78, - }; - static const uint8_t tag1[] = { - 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd, - 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf, - }; - - static const uint8_t key2[] = { - 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, - }; - static const uint8_t plain2[] = { - 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, - 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, - 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, - 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, - 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, - 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, - 0x1a, 0xaf, 0xd2, 0x55, - }; - static const uint8_t nonce2[] = { - 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, - 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, - }; - static const uint8_t cipher2[] = { - 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72, - 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f, - 0x2c, 0x02, 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, - 0xa1, 0x2e, 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, - 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3, - 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 0x3d, 0x58, 0xe0, 0x91, - 0x47, 0x3f, 0x59, 0x85, - }; - static const uint8_t tag2[] = { - 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6, - 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4, - }; - - static const uint8_t key3[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t plain3[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t nonce3[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t cipher3[] = { - 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41, - 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00, - }; - static const uint8_t tag3[] = { - 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab, - 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb, - }; - - static const uint8_t key4[] = { - 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, - 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - }; - static const uint8_t plain4[] = { - 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, - 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, - 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, - 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, - 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, - 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, - 0x1a, 0xaf, 0xd2, 0x55, - }; - static const uint8_t nonce4[] = { - 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, - 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, - }; - static const uint8_t cipher4[] = { - 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 0xeb, 0x06, - 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 0x85, 0x9e, 0x1c, 0xea, - 0xa6, 0xef, 0xd9, 0x84, 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, - 0xe1, 0x9c, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, - 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 0x18, 0xe2, - 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 0xcc, 0xda, 0x27, 0x10, - 0xac, 0xad, 0xe2, 0x56, - }; - static const uint8_t tag4[] = { - 0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf, - 0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14, - }; - - static const uint8_t key5[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t plain5[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t nonce5[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t cipher5[] = { - 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e, - 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18, - }; - static const uint8_t tag5[] = { - 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0, - 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19, - }; - - static const uint8_t key6[] = { - 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, - 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, - 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, - }; - static const uint8_t plain6[] = { - 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, - 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, - 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, - 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, - 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, - 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, - 0x1a, 0xaf, 0xd2, 0x55, - }; - static const uint8_t nonce6[] = { - 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, - 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, - }; - static const uint8_t cipher6[] = { - 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 0xf4, 0x7f, - 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 0x64, 0x3a, 0x8c, 0xdc, - 0xbf, 0xe5, 0xc0, 0xc9, 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, - 0xd1, 0xaa, 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, - 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 0xc5, 0xf6, - 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 0xbc, 0xc9, 0xf6, 0x62, - 0x89, 0x80, 0x15, 0xad, - }; - static const uint8_t tag6[] = { - 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd, - 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c, - }; - - static const uint8_t key7[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t plain7[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - /* This nonce results in 0xfff in counter LSB. */ - static const uint8_t nonce7[] = { - 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }; - static const uint8_t cipher7[] = { - 0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a, 0x2b, 0x64, - 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14, 0x25, 0xf1, 0x0d, 0x47, - 0xa7, 0x5a, 0x5f, 0xce, 0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a, - 0xf2, 0x4f, 0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70, - 0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18, 0xa9, 0xae, - 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf, 0xc6, 0xa7, 0x83, 0x97, - 0xb9, 0xa8, 0x5b, 0x49, 0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67, - 0xca, 0xab, 0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c, - 0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c, 0xb4, 0xf3, - 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29, 0xc9, 0xe8, 0xc4, 0xdc, - 0x0a, 0x2a, 0x5f, 0xf1, 0x90, 0x3e, 0x50, 0x15, 0x11, 0x22, - 0x13, 0x76, 0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2, - 0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce, 0xb0, 0xab, - 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f, 0x8c, 0x90, 0xbe, 0x40, - 0x2d, 0xdf, 0x6d, 0x86, 0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1, - 0x5b, 0xfb, 0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18, - 0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65, 0x3c, 0x71, - 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42, 0x11, 0xf4, 0x2b, 0xae, - 0x12, 0xaf, 0x46, 0x2b, 0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e, - 0x36, 0x06, 0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24, - 0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c, 0x4b, 0xcc, - 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4, 0x20, 0xa2, 0xf8, 0xeb, - 0x66, 0xdc, 0xf3, 0x64, 0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69, - 0x90, 0x03, 0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6, - 0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90, 0x27, 0x83, - 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74, 0x18, 0x8a, 0x43, 0x9c, - 0x7e, 0xbc, 0xc0, 0x67, 0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2, - 0x79, 0x46, 0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78, - 0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c, - }; - static const uint8_t tag7[] = { - 0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a, - 0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f, - }; - - TEST_ASSERT(!test_aes_gcm_raw(key1, sizeof(key1), plain1, cipher1, - sizeof(plain1), nonce1, sizeof(nonce1), - tag1, sizeof(tag1))); - TEST_ASSERT(!test_aes_gcm_raw(key2, sizeof(key2), plain2, cipher2, - sizeof(plain2), nonce2, sizeof(nonce2), - tag2, sizeof(tag2))); - TEST_ASSERT(!test_aes_gcm_raw(key3, sizeof(key3), plain3, cipher3, - sizeof(plain3), nonce3, sizeof(nonce3), - tag3, sizeof(tag3))); - TEST_ASSERT(!test_aes_gcm_raw(key4, sizeof(key4), plain4, cipher4, - sizeof(plain4), nonce4, sizeof(nonce4), - tag4, sizeof(tag4))); - TEST_ASSERT(!test_aes_gcm_raw(key5, sizeof(key5), plain5, cipher5, - sizeof(plain5), nonce5, sizeof(nonce5), - tag5, sizeof(tag5))); - TEST_ASSERT(!test_aes_gcm_raw(key6, sizeof(key6), plain6, cipher6, - sizeof(plain6), nonce6, sizeof(nonce6), - tag6, sizeof(tag6))); - TEST_ASSERT(!test_aes_gcm_raw(key7, sizeof(key7), plain7, cipher7, - sizeof(plain7), nonce7, sizeof(nonce7), - tag7, sizeof(tag7))); - - return EC_SUCCESS; -} - -static void test_aes_gcm_speed(void) -{ - int i; - static const uint8_t key[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - const int key_size = sizeof(key); - static const uint8_t plaintext[512] = { 0 }; - const int plaintext_size = sizeof(plaintext); - static const uint8_t nonce[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; - const int nonce_size = sizeof(nonce); - uint8_t tag[16] = { 0 }; - const int tag_size = sizeof(tag); - - uint8_t *out = tmp; - static AES_KEY aes_key; - static GCM128_CONTEXT ctx; - timestamp_t t0, t1; - - assert(plaintext_size <= sizeof(tmp)); - - t0 = get_time(); - for (i = 0; i < 1000; i++) { - AES_set_encrypt_key(key, 8 * key_size, &aes_key); - CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); - CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); - CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, out, - plaintext_size); - CRYPTO_gcm128_tag(&ctx, tag, tag_size); - } - t1 = get_time(); - ccprintf("AES-GCM duration %lld us\n", (long long)(t1.val - t0.val)); -} - -static int test_aes_raw(const uint8_t *key, int key_size, - const uint8_t *plaintext, const uint8_t *ciphertext) -{ - AES_KEY aes_key; - uint8_t *block = tmp; - - TEST_ASSERT(AES_BLOCK_SIZE <= sizeof(tmp)); - - TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0); - - /* Test encryption. */ - AES_encrypt(plaintext, block, &aes_key); - TEST_ASSERT_ARRAY_EQ(ciphertext, block, AES_BLOCK_SIZE); - - /* Test in-place encryption. */ - memcpy(block, plaintext, AES_BLOCK_SIZE); - AES_encrypt(block, block, &aes_key); - TEST_ASSERT_ARRAY_EQ(ciphertext, block, AES_BLOCK_SIZE); - - TEST_ASSERT(AES_set_decrypt_key(key, 8 * key_size, &aes_key) == 0); - - /* Test decryption. */ - AES_decrypt(ciphertext, block, &aes_key); - TEST_ASSERT_ARRAY_EQ(plaintext, block, AES_BLOCK_SIZE); - - /* Test in-place decryption. */ - memcpy(block, ciphertext, AES_BLOCK_SIZE); - AES_decrypt(block, block, &aes_key); - TEST_ASSERT_ARRAY_EQ(plaintext, block, AES_BLOCK_SIZE); - - return EC_SUCCESS; -} - -static int test_aes(void) -{ - /* Test vectors from FIPS-197, Appendix C. */ - static const uint8_t key1[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - }; - static const uint8_t plain1[] = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, - }; - static const uint8_t cipher1[] = { - 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, - 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a, - }; - - static const uint8_t key2[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - }; - static const uint8_t plain2[] = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, - }; - static const uint8_t cipher2[] = { - 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, - 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91, - }; - - static const uint8_t key3[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - }; - static const uint8_t plain3[] = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, - }; - static const uint8_t cipher3[] = { - 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, - 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89, - }; - - TEST_ASSERT(!test_aes_raw(key1, sizeof(key1), plain1, cipher1)); - TEST_ASSERT(!test_aes_raw(key2, sizeof(key2), plain2, cipher2)); - TEST_ASSERT(!test_aes_raw(key3, sizeof(key3), plain3, cipher3)); - - return EC_SUCCESS; -} - -static void test_aes_speed(void) -{ - int i; - /* Test vectors from FIPS-197, Appendix C. */ - static const uint8_t key[] __aligned(4) = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - }; - const int key_size = sizeof(key); - static const uint8_t plaintext[] __aligned(4) = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, - }; - - AES_KEY aes_key; - uint8_t block[AES_BLOCK_SIZE]; - timestamp_t t0, t1; - - AES_set_encrypt_key(key, 8 * key_size, &aes_key); - AES_encrypt(plaintext, block, &aes_key); - t0 = get_time(); - for (i = 0; i < 1000; i++) - AES_encrypt(block, block, &aes_key); - t1 = get_time(); - ccprintf("AES duration %lld us\n", (long long)(t1.val - t0.val)); -} - -void run_test(int argc, const char **argv) -{ - watchdog_reload(); - - /* do not check result, just as a benchmark */ - test_aes_speed(); - - watchdog_reload(); - RUN_TEST(test_aes); - - /* do not check result, just as a benchmark */ - test_aes_gcm_speed(); - - watchdog_reload(); - RUN_TEST(test_aes_gcm); - - test_print_result(); -} diff --git a/test/aes.cc b/test/aes.cc new file mode 100644 index 0000000000..659f9ec971 --- /dev/null +++ b/test/aes.cc @@ -0,0 +1,592 @@ +/* Copyright 2018 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "common.h" +#include "test_util.h" + +extern "C" { +#include "aes.h" +#include "aes-gcm.h" +#include "builtin/assert.h" +#include "console.h" +#include "timer.h" +#include "util.h" +#include "watchdog.h" +} + +/* Temporary buffer, to avoid using too much stack space. */ +static uint8_t tmp[512]; + +/* + * Do encryption, put result in |result|, and compare with |ciphertext|. + */ +static int test_aes_gcm_encrypt(uint8_t *result, const uint8_t *key, + int key_size, const uint8_t *plaintext, + const uint8_t *ciphertext, int plaintext_size, + const uint8_t *nonce, int nonce_size, + const uint8_t *tag, int tag_size) +{ + static AES_KEY aes_key; + static GCM128_CONTEXT ctx; + + TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0); + + CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); + CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); + TEST_ASSERT(CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, result, + plaintext_size)); + TEST_ASSERT(CRYPTO_gcm128_finish(&ctx, tag, tag_size)); + TEST_ASSERT_ARRAY_EQ(ciphertext, result, plaintext_size); + + return EC_SUCCESS; +} + +/* + * Do decryption, put result in |result|, and compare with |plaintext|. + */ +static int test_aes_gcm_decrypt(uint8_t *result, const uint8_t *key, + int key_size, const uint8_t *plaintext, + const uint8_t *ciphertext, int plaintext_size, + const uint8_t *nonce, int nonce_size, + const uint8_t *tag, int tag_size) +{ + static AES_KEY aes_key; + static GCM128_CONTEXT ctx; + + TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0); + + CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); + CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); + TEST_ASSERT(CRYPTO_gcm128_decrypt(&ctx, &aes_key, ciphertext, result, + plaintext_size)); + TEST_ASSERT(CRYPTO_gcm128_finish(&ctx, tag, tag_size)); + TEST_ASSERT_ARRAY_EQ(plaintext, result, plaintext_size); + + return EC_SUCCESS; +} + +static int test_aes_gcm_raw_inplace(const uint8_t *key, int key_size, + const uint8_t *plaintext, + const uint8_t *ciphertext, + int plaintext_size, const uint8_t *nonce, + int nonce_size, const uint8_t *tag, + int tag_size) +{ + /* + * Make copies that will be clobbered during in-place encryption or + * decryption. + */ + uint8_t plaintext_copy[plaintext_size]; + uint8_t ciphertext_copy[plaintext_size]; + + memcpy(plaintext_copy, plaintext, plaintext_size); + memcpy(ciphertext_copy, ciphertext, plaintext_size); + + TEST_ASSERT(test_aes_gcm_encrypt(plaintext_copy, key, key_size, + plaintext_copy, ciphertext, + plaintext_size, nonce, nonce_size, tag, + tag_size) == EC_SUCCESS); + + TEST_ASSERT(test_aes_gcm_decrypt(ciphertext_copy, key, key_size, + plaintext, ciphertext_copy, + plaintext_size, nonce, nonce_size, tag, + tag_size) == EC_SUCCESS); + + return EC_SUCCESS; +} + +static int test_aes_gcm_raw_non_inplace(const uint8_t *key, int key_size, + const uint8_t *plaintext, + const uint8_t *ciphertext, + int plaintext_size, + const uint8_t *nonce, int nonce_size, + const uint8_t *tag, int tag_size) +{ + TEST_ASSERT(test_aes_gcm_encrypt(tmp, key, key_size, plaintext, + ciphertext, plaintext_size, nonce, + nonce_size, tag, + tag_size) == EC_SUCCESS); + + TEST_ASSERT(test_aes_gcm_decrypt(tmp, key, key_size, plaintext, + ciphertext, plaintext_size, nonce, + nonce_size, tag, + tag_size) == EC_SUCCESS); + + return EC_SUCCESS; +} + +static int test_aes_gcm_raw(const uint8_t *key, int key_size, + const uint8_t *plaintext, const uint8_t *ciphertext, + std::size_t plaintext_size, const uint8_t *nonce, + std::size_t nonce_size, const uint8_t *tag, + std::size_t tag_size) +{ + TEST_ASSERT(plaintext_size <= sizeof(tmp)); + + TEST_ASSERT(test_aes_gcm_raw_non_inplace(key, key_size, plaintext, + ciphertext, plaintext_size, + nonce, nonce_size, tag, + tag_size) == EC_SUCCESS); + TEST_ASSERT(test_aes_gcm_raw_inplace(key, key_size, plaintext, + ciphertext, plaintext_size, nonce, + nonce_size, tag, + tag_size) == EC_SUCCESS); + + return EC_SUCCESS; +} + +static int test_aes_gcm(void) +{ + /* + * Test vectors from BoringSSL crypto/fipsmodule/modes/gcm_tests.txt + * (only the ones with actual data, and no additional data). + */ + static const uint8_t key1[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t plain1[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t nonce1[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t cipher1[] = { + 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92, + 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78, + }; + static const uint8_t tag1[] = { + 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd, + 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf, + }; + + static const uint8_t key2[] = { + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + }; + static const uint8_t plain2[] = { + 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, + 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, + 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, + 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, + 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, + 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, + 0x1a, 0xaf, 0xd2, 0x55, + }; + static const uint8_t nonce2[] = { + 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, + 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, + }; + static const uint8_t cipher2[] = { + 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72, + 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f, + 0x2c, 0x02, 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, + 0xa1, 0x2e, 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c, + 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3, + 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 0x3d, 0x58, 0xe0, 0x91, + 0x47, 0x3f, 0x59, 0x85, + }; + static const uint8_t tag2[] = { + 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6, + 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4, + }; + + static const uint8_t key3[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t plain3[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t nonce3[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t cipher3[] = { + 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41, + 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00, + }; + static const uint8_t tag3[] = { + 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab, + 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb, + }; + + static const uint8_t key4[] = { + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + }; + static const uint8_t plain4[] = { + 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, + 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, + 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, + 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, + 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, + 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, + 0x1a, 0xaf, 0xd2, 0x55, + }; + static const uint8_t nonce4[] = { + 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, + 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, + }; + static const uint8_t cipher4[] = { + 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 0xeb, 0x06, + 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 0x85, 0x9e, 0x1c, 0xea, + 0xa6, 0xef, 0xd9, 0x84, 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, + 0xe1, 0x9c, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25, + 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 0x18, 0xe2, + 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 0xcc, 0xda, 0x27, 0x10, + 0xac, 0xad, 0xe2, 0x56, + }; + static const uint8_t tag4[] = { + 0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf, + 0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14, + }; + + static const uint8_t key5[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t plain5[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t nonce5[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t cipher5[] = { + 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e, + 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18, + }; + static const uint8_t tag5[] = { + 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0, + 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19, + }; + + static const uint8_t key6[] = { + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c, + 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08, + }; + static const uint8_t plain6[] = { + 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59, + 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53, + 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, + 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53, + 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a, + 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39, + 0x1a, 0xaf, 0xd2, 0x55, + }; + static const uint8_t nonce6[] = { + 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, + 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88, + }; + static const uint8_t cipher6[] = { + 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 0xf4, 0x7f, + 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 0x64, 0x3a, 0x8c, 0xdc, + 0xbf, 0xe5, 0xc0, 0xc9, 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, + 0xd1, 0xaa, 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d, + 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 0xc5, 0xf6, + 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 0xbc, 0xc9, 0xf6, 0x62, + 0x89, 0x80, 0x15, 0xad, + }; + static const uint8_t tag6[] = { + 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd, + 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c, + }; + + static const uint8_t key7[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t plain7[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + /* This nonce results in 0xfff in counter LSB. */ + static const uint8_t nonce7[] = { + 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }; + static const uint8_t cipher7[] = { + 0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a, 0x2b, 0x64, + 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14, 0x25, 0xf1, 0x0d, 0x47, + 0xa7, 0x5a, 0x5f, 0xce, 0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a, + 0xf2, 0x4f, 0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70, + 0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18, 0xa9, 0xae, + 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf, 0xc6, 0xa7, 0x83, 0x97, + 0xb9, 0xa8, 0x5b, 0x49, 0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67, + 0xca, 0xab, 0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c, + 0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c, 0xb4, 0xf3, + 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29, 0xc9, 0xe8, 0xc4, 0xdc, + 0x0a, 0x2a, 0x5f, 0xf1, 0x90, 0x3e, 0x50, 0x15, 0x11, 0x22, + 0x13, 0x76, 0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2, + 0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce, 0xb0, 0xab, + 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f, 0x8c, 0x90, 0xbe, 0x40, + 0x2d, 0xdf, 0x6d, 0x86, 0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1, + 0x5b, 0xfb, 0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18, + 0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65, 0x3c, 0x71, + 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42, 0x11, 0xf4, 0x2b, 0xae, + 0x12, 0xaf, 0x46, 0x2b, 0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e, + 0x36, 0x06, 0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24, + 0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c, 0x4b, 0xcc, + 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4, 0x20, 0xa2, 0xf8, 0xeb, + 0x66, 0xdc, 0xf3, 0x64, 0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69, + 0x90, 0x03, 0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6, + 0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90, 0x27, 0x83, + 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74, 0x18, 0x8a, 0x43, 0x9c, + 0x7e, 0xbc, 0xc0, 0x67, 0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2, + 0x79, 0x46, 0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78, + 0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c, + }; + static const uint8_t tag7[] = { + 0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a, + 0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f, + }; + + TEST_ASSERT(!test_aes_gcm_raw(key1, sizeof(key1), plain1, cipher1, + sizeof(plain1), nonce1, sizeof(nonce1), + tag1, sizeof(tag1))); + TEST_ASSERT(!test_aes_gcm_raw(key2, sizeof(key2), plain2, cipher2, + sizeof(plain2), nonce2, sizeof(nonce2), + tag2, sizeof(tag2))); + TEST_ASSERT(!test_aes_gcm_raw(key3, sizeof(key3), plain3, cipher3, + sizeof(plain3), nonce3, sizeof(nonce3), + tag3, sizeof(tag3))); + TEST_ASSERT(!test_aes_gcm_raw(key4, sizeof(key4), plain4, cipher4, + sizeof(plain4), nonce4, sizeof(nonce4), + tag4, sizeof(tag4))); + TEST_ASSERT(!test_aes_gcm_raw(key5, sizeof(key5), plain5, cipher5, + sizeof(plain5), nonce5, sizeof(nonce5), + tag5, sizeof(tag5))); + TEST_ASSERT(!test_aes_gcm_raw(key6, sizeof(key6), plain6, cipher6, + sizeof(plain6), nonce6, sizeof(nonce6), + tag6, sizeof(tag6))); + TEST_ASSERT(!test_aes_gcm_raw(key7, sizeof(key7), plain7, cipher7, + sizeof(plain7), nonce7, sizeof(nonce7), + tag7, sizeof(tag7))); + + return EC_SUCCESS; +} + +static void test_aes_gcm_speed(void) +{ + int i; + static const uint8_t key[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + const int key_size = sizeof(key); + static const uint8_t plaintext[512] = { 0 }; + const auto plaintext_size = sizeof(plaintext); + static const uint8_t nonce[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + const int nonce_size = sizeof(nonce); + uint8_t tag[16] = { 0 }; + const int tag_size = sizeof(tag); + + uint8_t *out = tmp; + static AES_KEY aes_key; + static GCM128_CONTEXT ctx; + timestamp_t t0, t1; + + assert(plaintext_size <= sizeof(tmp)); + + t0 = get_time(); + for (i = 0; i < 1000; i++) { + AES_set_encrypt_key(key, 8 * key_size, &aes_key); + CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); + CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); + CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, out, + plaintext_size); + CRYPTO_gcm128_tag(&ctx, tag, tag_size); + } + t1 = get_time(); + ccprintf("AES-GCM duration %lld us\n", (long long)(t1.val - t0.val)); +} + +static int test_aes_raw(const uint8_t *key, int key_size, + const uint8_t *plaintext, const uint8_t *ciphertext) +{ + AES_KEY aes_key; + uint8_t *block = tmp; + + TEST_ASSERT(AES_BLOCK_SIZE <= sizeof(tmp)); + + TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0); + + /* Test encryption. */ + AES_encrypt(plaintext, block, &aes_key); + TEST_ASSERT_ARRAY_EQ(ciphertext, block, AES_BLOCK_SIZE); + + /* Test in-place encryption. */ + memcpy(block, plaintext, AES_BLOCK_SIZE); + AES_encrypt(block, block, &aes_key); + TEST_ASSERT_ARRAY_EQ(ciphertext, block, AES_BLOCK_SIZE); + + TEST_ASSERT(AES_set_decrypt_key(key, 8 * key_size, &aes_key) == 0); + + /* Test decryption. */ + AES_decrypt(ciphertext, block, &aes_key); + TEST_ASSERT_ARRAY_EQ(plaintext, block, AES_BLOCK_SIZE); + + /* Test in-place decryption. */ + memcpy(block, ciphertext, AES_BLOCK_SIZE); + AES_decrypt(block, block, &aes_key); + TEST_ASSERT_ARRAY_EQ(plaintext, block, AES_BLOCK_SIZE); + + return EC_SUCCESS; +} + +static int test_aes(void) +{ + /* Test vectors from FIPS-197, Appendix C. */ + static const uint8_t key1[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }; + static const uint8_t plain1[] = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, + }; + static const uint8_t cipher1[] = { + 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, + 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a, + }; + + static const uint8_t key2[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + }; + static const uint8_t plain2[] = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, + }; + static const uint8_t cipher2[] = { + 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, + 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91, + }; + + static const uint8_t key3[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }; + static const uint8_t plain3[] = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, + }; + static const uint8_t cipher3[] = { + 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, + 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89, + }; + + TEST_ASSERT(!test_aes_raw(key1, sizeof(key1), plain1, cipher1)); + TEST_ASSERT(!test_aes_raw(key2, sizeof(key2), plain2, cipher2)); + TEST_ASSERT(!test_aes_raw(key3, sizeof(key3), plain3, cipher3)); + + return EC_SUCCESS; +} + +static void test_aes_speed(void) +{ + int i; + /* Test vectors from FIPS-197, Appendix C. */ + static const uint8_t key[] __aligned(4) = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }; + const int key_size = sizeof(key); + static const uint8_t plaintext[] __aligned(4) = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, + }; + + AES_KEY aes_key; + uint8_t block[AES_BLOCK_SIZE]; + timestamp_t t0, t1; + + AES_set_encrypt_key(key, 8 * key_size, &aes_key); + AES_encrypt(plaintext, block, &aes_key); + t0 = get_time(); + for (i = 0; i < 1000; i++) + AES_encrypt(block, block, &aes_key); + t1 = get_time(); + ccprintf("AES duration %lld us\n", (long long)(t1.val - t0.val)); +} + +void run_test(int argc, const char **argv) +{ + watchdog_reload(); + + /* do not check result, just as a benchmark */ + test_aes_speed(); + + watchdog_reload(); + RUN_TEST(test_aes); + + /* do not check result, just as a benchmark */ + test_aes_gcm_speed(); + + watchdog_reload(); + RUN_TEST(test_aes_gcm); + + test_print_result(); +} -- cgit v1.2.1 From 9322a632b37e0efd0d1239c96b25be944dbc1c61 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 17 Nov 2022 15:08:00 +0000 Subject: util/build_with_clang: More boards unsuccessfully compile These boards were at the very limit of flash usage when compiled with clang and are now over the limit and failing in CI. BRANCH=none BUG=b:258143176 TEST=./util/build_with_clang.py Signed-off-by: Fabio Baltieri Change-Id: I7f532fd60ce9fad0be3c323efcd3b23d77b23242 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4034172 Reviewed-by: Jack Rosenthal Code-Coverage: Zoss --- util/build_with_clang.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 7a728ba591..339384740e 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -56,26 +56,22 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "duck", "eel", "elm", - "fennel", "fluffy", "fusb307bgevb", "gelatin", "hammer", "hoho", "jacuzzi", - "juniper", "kakadu", "kappa", "katsu", "krane", "kukui", "magnemite", - "makomo", "masterball", "minimuffin", "moonball", "nucleo-f072rb", - "oak", "pdeval-stm32f072", "plankton", "prism", @@ -114,7 +110,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "banshee", "berknip", "bloog", - "bobba", "boldar", "brask", "brya", @@ -123,7 +118,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "careena", "casta", "chronicler", - "coachz", "collis", "copano", "coral", @@ -292,8 +286,14 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ # Boards that use CHIP:=stm32 *and* CHIP_FAMILY:=stm32f0 "burnet", # overflows flash "chocodile_vpdmcu", # compilation error: b/254710459 + "fennel", # overflows flash + "juniper", # overflows flash "kodama", # overflows flash + "makomo", # overflows flash + "oak", # overflows flash # Boards that use CHIP:=npcx + "bobba", # overflows flash + "coachz", # overflows flash "garg", # overflows flash "mushu", # overflows flash "terrador", # overflows flash -- cgit v1.2.1 From 6d80b51050df216c0589f31b1ff457f7f5308910 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 14 Nov 2022 16:55:29 +0000 Subject: zephyr: temp: enable few temperature Kconfig options automatically Enable few temperature sensor options automatically based devicetree compatible nodes, drop few explicit config entries. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I8c6cbcadd14001c3ed62631da85b038d55fab090 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022161 Code-Coverage: Zoss Reviewed-by: Sam Hurst --- zephyr/Kconfig.temperature | 10 ++++++++++ zephyr/program/brya/prj.conf | 2 -- zephyr/program/corsola/magikarp/project.conf | 4 ---- zephyr/program/corsola/tentacruel/project.conf | 4 ---- zephyr/program/intelrvp/adlrvp/prj.conf | 2 -- zephyr/program/intelrvp/mtlrvp/prj.conf | 2 -- zephyr/program/nissa/program.conf | 2 -- zephyr/program/rex/prj.conf | 2 -- zephyr/program/skyrim/prj.conf | 3 --- zephyr/program/skyrim/prj_frostflow.conf | 2 -- zephyr/program/skyrim/prj_morthal.conf | 3 --- zephyr/program/skyrim/prj_skyrim.conf | 3 --- zephyr/program/skyrim/prj_winterhold.conf | 3 --- zephyr/test/drivers/prj.conf | 2 -- zephyr/test/krabby/testcase.yaml | 2 -- 15 files changed, 10 insertions(+), 36 deletions(-) diff --git a/zephyr/Kconfig.temperature b/zephyr/Kconfig.temperature index 8b46d323a8..9bea40d274 100644 --- a/zephyr/Kconfig.temperature +++ b/zephyr/Kconfig.temperature @@ -4,6 +4,8 @@ menuconfig PLATFORM_EC_TEMP_SENSOR bool "Temperature sensors" + default y + depends on DT_HAS_CROS_EC_TEMP_SENSORS_ENABLED help Support for temperature sensors. Once enabled, "temps" console command and EC_CMD_TEMP_SENSOR_GET_INFO host command are available. @@ -33,6 +35,8 @@ config PLATFORM_EC_DPTF config PLATFORM_EC_THERMISTOR bool "Thermistor support" + default y + depends on DT_HAS_CROS_EC_THERMISTOR_ENABLED depends on ADC help Enables support for thermistors (resistor whose resistance is @@ -40,18 +44,24 @@ config PLATFORM_EC_THERMISTOR config PLATFORM_EC_TEMP_SENSOR_PCT2075 bool "PCT2075 support" + default y + depends on DT_HAS_NXP_PCT2075_ENABLED help Enables support for the CrosEC PCT2075 sensor, an i2c peripheral temperature sensor from NXP. config PLATFORM_EC_TEMP_SENSOR_SB_TSI bool "SB TSI support" + default y + depends on DT_HAS_AMD_SB_TSI_ENABLED help Enables support for the Side Band Temperature Sensor Interface, an i2c peripheral available on AMD platforms. config PLATFORM_EC_TEMP_SENSOR_TMP112 bool "TMP112 support" + default y + depends on DT_HAS_CROS_EC_TEMP_SENSOR_TMP112_ENABLED help Enables support for the CrosEC TMP112 driver, an i2c peripheral temperature sensor from TI. diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 4a814c9ab8..e0e62ac85a 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -72,8 +72,6 @@ CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y CONFIG_PLATFORM_EC_ALS_TCS3400=y # Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y # MKBP event diff --git a/zephyr/program/corsola/magikarp/project.conf b/zephyr/program/corsola/magikarp/project.conf index a5ec9ede3b..73433b242a 100644 --- a/zephyr/program/corsola/magikarp/project.conf +++ b/zephyr/program/corsola/magikarp/project.conf @@ -19,9 +19,5 @@ CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y - # Battery CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y diff --git a/zephyr/program/corsola/tentacruel/project.conf b/zephyr/program/corsola/tentacruel/project.conf index 71cc9d9694..239fc339fb 100644 --- a/zephyr/program/corsola/tentacruel/project.conf +++ b/zephyr/program/corsola/tentacruel/project.conf @@ -18,9 +18,5 @@ CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -# Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y - # Battery CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index a5f2ad34a5..df0811ecdd 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -34,8 +34,6 @@ CONFIG_PLATFORM_EC_LED_COMMON=y CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=y # Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y # USB-C and PD diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index 281d40a271..1270712f99 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -36,8 +36,6 @@ CONFIG_PLATFORM_EC_IOEX_IT8801=y CONFIG_CROS_KB_RAW_NPCX=n # Temperature sensors -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y # USB CONFIG diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index a8a2ec3319..a803dadc4c 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -72,8 +72,6 @@ CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y # Temperature sensor support -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY=y # CBI EEPROM support diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index e52812c001..38b55aa783 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -59,8 +59,6 @@ CONFIG_PWM=y # Temperature sensors CONFIG_SENSOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_THERMISTOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y # CBI EEPROM support diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 63f2a54ae1..587d191358 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -34,9 +34,6 @@ CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y # Temperature Sensors CONFIG_PLATFORM_EC_AMD_SB_RMI=y CONFIG_PLATFORM_EC_AMD_STT=y -CONFIG_PLATFORM_EC_TEMP_SENSOR=y -CONFIG_PLATFORM_EC_TEMP_SENSOR_SB_TSI=y -CONFIG_PLATFORM_EC_THERMISTOR=y CONFIG_PLATFORM_EC_THROTTLE_AP=y # External power diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf index 835230be67..675c387aae 100644 --- a/zephyr/program/skyrim/prj_frostflow.conf +++ b/zephyr/program/skyrim/prj_frostflow.conf @@ -18,8 +18,6 @@ CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000 CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000 -# Only Frostflow has the PCT2075 -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y # Keyboard CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y diff --git a/zephyr/program/skyrim/prj_morthal.conf b/zephyr/program/skyrim/prj_morthal.conf index f0833418ca..8a22f58ab8 100644 --- a/zephyr/program/skyrim/prj_morthal.conf +++ b/zephyr/program/skyrim/prj_morthal.conf @@ -17,9 +17,6 @@ CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 -# Only Morthal has the PCT2075 -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y - CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y # Battery diff --git a/zephyr/program/skyrim/prj_skyrim.conf b/zephyr/program/skyrim/prj_skyrim.conf index 0ebd1e91fa..67b3f0f142 100644 --- a/zephyr/program/skyrim/prj_skyrim.conf +++ b/zephyr/program/skyrim/prj_skyrim.conf @@ -16,9 +16,6 @@ CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 -# Only Skyrim has the PCT2075 -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y - CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y # Enable alternative charger chip diff --git a/zephyr/program/skyrim/prj_winterhold.conf b/zephyr/program/skyrim/prj_winterhold.conf index 4501e0e6ff..0703a50b14 100644 --- a/zephyr/program/skyrim/prj_winterhold.conf +++ b/zephyr/program/skyrim/prj_winterhold.conf @@ -12,9 +12,6 @@ CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y # LED CONFIG_PLATFORM_EC_LED_DT=y -# Only Winterhold has the PCT2075 -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y - CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y # Enable charger chip diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 68a13a1f9d..ffb5af8281 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -100,9 +100,7 @@ CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=y CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y -CONFIG_PLATFORM_EC_TEMP_SENSOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y -CONFIG_PLATFORM_EC_THERMISTOR=y CONFIG_PLATFORM_EC_SWITCH=y CONFIG_PLATFORM_EC_SWITCHCAP_LN9310=y CONFIG_PLATFORM_EC_ACCEL_BMA255=y diff --git a/zephyr/test/krabby/testcase.yaml b/zephyr/test/krabby/testcase.yaml index 6e202c92c8..54a8ce59d4 100644 --- a/zephyr/test/krabby/testcase.yaml +++ b/zephyr/test/krabby/testcase.yaml @@ -14,7 +14,5 @@ tests: extra_args: DTC_OVERLAY_FILE="common.dts;adc_temp.dts;../program/corsola/interrupts_tentacruel.dtsi;../program/corsola/gpio_tentacruel.dtsi;../program/corsola/thermistor_tentacruel.dtsi;pinctrl.dts" extra_configs: - CONFIG_TEST_TENTACRUEL=y - - CONFIG_PLATFORM_EC_TEMP_SENSOR=y - - CONFIG_PLATFORM_EC_THERMISTOR=y - CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y - CONFIG_ADC_EMUL=y -- cgit v1.2.1 From 4f6def440f575126fae7db8f1bb9a50716f6b5bb Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Wed, 16 Nov 2022 02:52:40 -0700 Subject: test: add tests for flash info 2 host command Verify that the flash info v2 command works as expected producing the correct number of banks for the test binary). BRANCH=none BUG=none TEST=twister Change-Id: I79e7b81d90eb6b6d56ca1fbbdc70cd1c91f42625 Signed-off-by: Yuval Peress Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030063 Code-Coverage: Zoss Reviewed-by: Simon Glass --- zephyr/test/drivers/default/src/flash.c | 46 ++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c index 71d6853653..958585c61e 100644 --- a/zephyr/test/drivers/default/src/flash.c +++ b/zephyr/test/drivers/default/src/flash.c @@ -252,7 +252,7 @@ ZTEST_USER(flash, test_hostcmd_flash_region_info_active_invalid) zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, NULL); } -ZTEST_USER(flash, test_hostcmd_flash_info) +ZTEST_USER(flash, test_hostcmd_flash_info_1) { struct ec_response_flash_info_1 response; struct host_cmd_handler_args args = @@ -280,6 +280,50 @@ ZTEST_USER(flash, test_hostcmd_flash_info) "response.write_ideal_size = %d", response.write_ideal_size); } +ZTEST_USER(flash, test_hostcmd_flash_info_2) +{ + uint8_t response_buffer[sizeof(struct ec_response_flash_info_2) + + sizeof(struct ec_flash_bank)]; + struct ec_response_flash_info_2 *response = + (struct ec_response_flash_info_2 *)response_buffer; + struct ec_params_flash_info_2 params = { + .num_banks_desc = 1, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_FLASH_INFO, 2, *response, params); + + /* Get the flash info. */ + zassert_ok(host_command_process(&args), NULL); + zassert_equal(response->flash_size, + CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START, "got %d", + response->flash_size); + zassert_equal(response->flags, 0, "got %d", response->flags); + zassert_equal( + response->write_ideal_size, + (args.response_max - sizeof(struct ec_params_flash_write)) & + ~(CONFIG_FLASH_WRITE_SIZE - 1), + "got %d", response->write_ideal_size); + zassert_equal(response->num_banks_total, 1, "got %d", + response->num_banks_total); + zassert_equal(response->num_banks_desc, 1, "got %d", + response->num_banks_desc); + zassert_equal(response->banks[0].count, + CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE, + "got %d", response->banks[0].count); + zassert_equal(response->banks[0].size_exp, + __fls(CONFIG_FLASH_BANK_SIZE), "got %d", + response->banks[0].size_exp); + zassert_equal(response->banks[0].write_size_exp, + __fls(CONFIG_FLASH_WRITE_SIZE), "got %d", + response->banks[0].write_size_exp); + zassert_equal(response->banks[0].erase_size_exp, + __fls(CONFIG_FLASH_ERASE_SIZE), "got %d", + response->banks[0].erase_size_exp); + zassert_equal(response->banks[0].protect_size_exp, + __fls(CONFIG_FLASH_BANK_SIZE), "got %d", + response->banks[0].protect_size_exp); +} + ZTEST_USER(flash, test_console_cmd_flash_info) { const struct shell *shell_zephyr = get_ec_shell(); -- cgit v1.2.1 From 86fb647593499b5e5cf3f8cff7b4da8df6d2b08f Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Tue, 15 Nov 2022 16:52:31 +0000 Subject: zephyr: switchcap: rename binding, clean up code Various cleanups on the switchcap code: - rename the bindings to add the vendor prefix - split the Kconfig option for the common code (used in project specific drivers) and the generic one (devicetree based) - drop the choice and use the compatible to select the option automatically instead - cleanup the code to remove the now unnecessary guards - use DT_INST macros instead of DT_PATH so we don't depends on the node path anymore BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I77e790c0b7b0d947e4eafed64b0ace556a22c034 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4028145 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- zephyr/Kconfig | 23 +++++++++--------- .../bindings/switchcap/cros-ec,switchcap-gpio.yaml | 22 +++++++++++++++++ zephyr/dts/bindings/switchcap/lion,ln9310.yaml | 28 ++++++++++++++++++++++ zephyr/dts/bindings/switchcap/switchcap-gpio.yaml | 22 ----------------- .../dts/bindings/switchcap/switchcap-ln9310.yaml | 28 ---------------------- zephyr/program/herobrine/program.conf | 3 --- zephyr/program/herobrine/switchcap.dtsi | 2 +- zephyr/shim/src/CMakeLists.txt | 6 ++--- zephyr/shim/src/switchcap_gpio.c | 28 +++++++--------------- zephyr/shim/src/switchcap_ln9310.c | 21 ++++++---------- zephyr/test/qcom_power/boards/native_posix.overlay | 2 +- zephyr/test/qcom_power/prj.conf | 1 - 12 files changed, 81 insertions(+), 105 deletions(-) create mode 100644 zephyr/dts/bindings/switchcap/cros-ec,switchcap-gpio.yaml create mode 100644 zephyr/dts/bindings/switchcap/lion,ln9310.yaml delete mode 100644 zephyr/dts/bindings/switchcap/switchcap-gpio.yaml delete mode 100644 zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 7f9dee962c..9af9f6280e 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -631,25 +631,17 @@ config PLATFORM_EC_SWITCH This also enables the "mmapinfo" console command to report the current state of all switches. -choice PLATFORM_EC_SWITCHCAP_TYPE - prompt "Enable switchcap support" - optional - help - Enable support for switchcap used to power on the AP. - If enabled, type of switchcap must be selected and node in device - tree must be added that describes the driver and pins used to control - the switchcap. - config PLATFORM_EC_SWITCHCAP_GPIO bool "GPIO controlled switchcap" + default y + depends on DT_HAS_CROS_EC_SWITCHCAP_GPIO_ENABLED help Enable support for the GPIO controlled switchcap. Pins used for controlling the switchcap must be defined in board's device tree. config PLATFORM_EC_SWITCHCAP_LN9310 - bool "LN9310 switchcap driver" - depends on PLATFORM_EC_I2C + bool "LN9310 switchcap common code" help Enable support for the LION Semiconductor LN9310 switched capacitor converter. This will export definitions for @@ -657,7 +649,14 @@ config PLATFORM_EC_SWITCHCAP_LN9310 project-specific code should call appropriately if there's no switchcap node in device tree. -endchoice +config CROS_EC_SWITCHCAP_LN9310 + bool "LN9310 switchcap generic driver" + default y + depends on DT_HAS_LION_LN9310_ENABLED + help + Enable support for the generic driver for the LION Semiconductor + LN9310 switched capacitor converter. This requires a lion,ln9310 node + to be defined. config PLATFORM_EC_SYSTEM_UNLOCKED bool "System unlocked: allow dangerous commands while in development" diff --git a/zephyr/dts/bindings/switchcap/cros-ec,switchcap-gpio.yaml b/zephyr/dts/bindings/switchcap/cros-ec,switchcap-gpio.yaml new file mode 100644 index 0000000000..344738c8c0 --- /dev/null +++ b/zephyr/dts/bindings/switchcap/cros-ec,switchcap-gpio.yaml @@ -0,0 +1,22 @@ +description: SwitchCap controlled by gpios + +compatible: "cros-ec,switchcap-gpio" + +properties: + enable-pin: + type: phandle + required: true + description: | + GPIO used to enable the switch cap + + power-good-pin: + type: phandle + required: false + description: | + GPIO used to read if power is good + + poff-delay-ms: + type: int + required: false + description: | + Additional power off delay required for some systems diff --git a/zephyr/dts/bindings/switchcap/lion,ln9310.yaml b/zephyr/dts/bindings/switchcap/lion,ln9310.yaml new file mode 100644 index 0000000000..c1c4a99bee --- /dev/null +++ b/zephyr/dts/bindings/switchcap/lion,ln9310.yaml @@ -0,0 +1,28 @@ +description: SwitchCap controlled by Lion Semiconductor LN9310 + +compatible: "lion,ln9310" + +properties: + enable-pin: + type: phandle + required: true + description: | + GPIO used to enable the switch cap. Relies on + GPIO flags to determine active low or high. + + port: + type: phandle + required: true + description: | + I2C port used to communicate with controller + + addr-flags: + type: string + default: "LN9310_I2C_ADDR_0_FLAGS" + enum: + - "LN9310_I2C_ADDR_0_FLAGS" + - "LN9310_I2C_ADDR_1_FLAGS" + - "LN9310_I2C_ADDR_2_FLAGS" + - "LN9310_I2C_ADDR_3_FLAGS" + description: | + I2C address of controller diff --git a/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml b/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml deleted file mode 100644 index 0016401835..0000000000 --- a/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml +++ /dev/null @@ -1,22 +0,0 @@ -description: SwitchCap controlled by gpios - -compatible: "switchcap-gpio" - -properties: - enable-pin: - type: phandle - required: true - description: | - GPIO used to enable the switch cap - - power-good-pin: - type: phandle - required: false - description: | - GPIO used to read if power is good - - poff-delay-ms: - type: int - required: false - description: | - Additional power off delay required for some systems diff --git a/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml b/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml deleted file mode 100644 index 2a73325cd3..0000000000 --- a/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml +++ /dev/null @@ -1,28 +0,0 @@ -description: SwitchCap controlled by LN9310 - -compatible: "switchcap-ln9310" - -properties: - enable-pin: - type: phandle - required: true - description: | - GPIO used to enable the switch cap. Relies on - GPIO flags to determine active low or high. - - port: - type: phandle - required: true - description: | - I2C port used to communicate with controller - - addr-flags: - type: string - default: "LN9310_I2C_ADDR_0_FLAGS" - enum: - - "LN9310_I2C_ADDR_0_FLAGS" - - "LN9310_I2C_ADDR_1_FLAGS" - - "LN9310_I2C_ADDR_2_FLAGS" - - "LN9310_I2C_ADDR_3_FLAGS" - description: | - I2C address of controller diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index ffe8ed7a8b..57fe6614d5 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -35,9 +35,6 @@ CONFIG_PWM_SHELL=n # Application Processor is Qualcomm SC7280 CONFIG_AP_ARM_QUALCOMM_SC7280=y -# GPIO Switchcap -CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y - # Board version is selected over GPIO board ID pins. CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y diff --git a/zephyr/program/herobrine/switchcap.dtsi b/zephyr/program/herobrine/switchcap.dtsi index ed200a0c6f..fb2db35d1a 100644 --- a/zephyr/program/herobrine/switchcap.dtsi +++ b/zephyr/program/herobrine/switchcap.dtsi @@ -5,7 +5,7 @@ / { switchcap { - compatible = "switchcap-gpio"; + compatible = "cros-ec,switchcap-gpio"; enable-pin = <&gpio_switchcap_on>; power-good-pin = <&gpio_switchcap_pg>; }; diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 74da11da2c..543c2b2303 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -55,9 +55,9 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_HC pwm_hc.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM pwm_led.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_RTC rtc.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SWITCHCAP_GPIO - switchcap_gpio.c) -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SWITCHCAP_LN9310 - switchcap_ln9310.c) + switchcap_gpio.c) +zephyr_library_sources_ifdef(CONFIG_CROS_EC_SWITCHCAP_LN9310 + switchcap_ln9310.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR temp_sensors.c thermal.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TIMER hwtimer.c) diff --git a/zephyr/shim/src/switchcap_gpio.c b/zephyr/shim/src/switchcap_gpio.c index 54d69a3672..982e5ff98c 100644 --- a/zephyr/shim/src/switchcap_gpio.c +++ b/zephyr/shim/src/switchcap_gpio.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#define DT_DRV_COMPAT cros_ec_switchcap_gpio + #include "common.h" #include @@ -11,26 +13,14 @@ /* TODO(b/218600962): Consolidate switchcap code. */ -#if DT_NODE_EXISTS(DT_PATH(switchcap)) - -#if !DT_NODE_HAS_COMPAT(DT_PATH(switchcap), switchcap_gpio) -#error "Invalid /switchcap node in device tree" -#endif - -#define SC_PIN_ENABLE_PHANDLE \ - DT_PHANDLE_BY_IDX(DT_PATH(switchcap), enable_pin, 0) -#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_PHANDLE) +#define SC_PIN_ENABLE_GPIO DT_INST_PROP(0, enable_pin) +#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_GPIO) -#define SC_PIN_POWER_GOOD_PHANDLE \ - DT_PHANDLE_BY_IDX(DT_PATH(switchcap), power_good_pin, 0) -#define SC_PIN_POWER_GOOD_EXISTS DT_NODE_EXISTS(SC_PIN_POWER_GOOD_PHANDLE) -#define SC_PIN_POWER_GOOD GPIO_DT_FROM_NODE(SC_PIN_POWER_GOOD_PHANDLE) +#define SC_PIN_POWER_GOOD_GPIO DT_INST_PROP(0, power_good_pin) +#define SC_PIN_POWER_GOOD_EXISTS DT_NODE_EXISTS(SC_PIN_POWER_GOOD_GPIO) +#define SC_PIN_POWER_GOOD GPIO_DT_FROM_NODE(SC_PIN_POWER_GOOD_GPIO) -#if DT_NODE_HAS_PROP(DT_PATH(switchcap), poff_delay_ms) -static const int32_t poff_delay_ms = DT_PROP(DT_PATH(switchcap), poff_delay_ms); -#else -static const int32_t poff_delay_ms; -#endif +static const int32_t poff_delay_ms = DT_INST_PROP_OR(0, poff_delay_ms, 0); void board_set_switchcap_power(int enable) { @@ -52,5 +42,3 @@ int board_is_switchcap_power_good(void) return 1; #endif } - -#endif diff --git a/zephyr/shim/src/switchcap_ln9310.c b/zephyr/shim/src/switchcap_ln9310.c index f3b037bfd4..54087ef6f2 100644 --- a/zephyr/shim/src/switchcap_ln9310.c +++ b/zephyr/shim/src/switchcap_ln9310.c @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#define DT_DRV_COMPAT lion_ln9310 + #include "common.h" #include "ln9310.h" @@ -11,20 +13,13 @@ /* TODO(b/218600962): Consolidate switchcap code. */ -#if DT_NODE_EXISTS(DT_PATH(switchcap)) - -#if !DT_NODE_HAS_COMPAT(DT_PATH(switchcap), switchcap_ln9310) -#error "Invalid /switchcap node in device tree" -#endif +#define SC_PIN_ENABLE_GPIO DT_INST_PROP(0, enable_pin) +#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_GPIO) -#define SC_PIN_ENABLE_PHANDLE \ - DT_PHANDLE_BY_IDX(DT_PATH(switchcap), enable_pin, 0) -#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_PHANDLE) +#define SC_PORT_NODE DT_INST_PHANDLE(0, port) +#define SC_PORT DT_STRING_UPPER_TOKEN_BY_IDX(SC_PORT_NODE, enum_names, 0) -#define SC_PORT_PHANDLE DT_PHANDLE(DT_PATH(switchcap), port) -#define SC_PORT DT_STRING_UPPER_TOKEN_BY_IDX(SC_PORT_PHANDLE, enum_names, 0) - -#define SC_ADDR_FLAGS DT_STRING_UPPER_TOKEN(DT_PATH(switchcap), addr_flags) +#define SC_ADDR_FLAGS DT_INST_STRING_UPPER_TOKEN(0, addr_flags) void board_set_switchcap_power(int enable) { @@ -46,5 +41,3 @@ const struct ln9310_config_t ln9310_config = { .i2c_port = SC_PORT, .i2c_addr_flags = SC_ADDR_FLAGS, }; - -#endif diff --git a/zephyr/test/qcom_power/boards/native_posix.overlay b/zephyr/test/qcom_power/boards/native_posix.overlay index be0db668ea..9af8f4cd13 100644 --- a/zephyr/test/qcom_power/boards/native_posix.overlay +++ b/zephyr/test/qcom_power/boards/native_posix.overlay @@ -140,7 +140,7 @@ }; switchcap { - compatible = "switchcap-gpio"; + compatible = "cros-ec,switchcap-gpio"; enable-pin = <&gpio_switchcap_on>; power-good-pin = <&gpio_switchcap_pg>; poff-delay-ms = <1>; diff --git a/zephyr/test/qcom_power/prj.conf b/zephyr/test/qcom_power/prj.conf index a74109ddde..16a00da41d 100644 --- a/zephyr/test/qcom_power/prj.conf +++ b/zephyr/test/qcom_power/prj.conf @@ -40,4 +40,3 @@ CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y CONFIG_PLATFORM_EC_POWERSEQ_SC7280=y CONFIG_PLATFORM_EC_POWER_BUTTON=y CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y -- cgit v1.2.1 From 27ec1a5fdf6a3ece0ead8fa4ace031094a725bad Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 14:45:47 +0000 Subject: zephyr: config: drop redundant logging options LOG and LOG_MODE_MINIMAL are already default since http://crrev.com/c/3819160. Drop a bunch of redundant configs. BRANCH=none BUG=none TEST=cq dry run TEST=checked the configs https://paste.googleplex.com/6293893212536832 Signed-off-by: Fabio Baltieri Change-Id: I620d1568045c638a9abe877dc87d45b4accad206 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031187 Code-Coverage: Zoss Reviewed-by: Wai-Hong Tam --- zephyr/program/corsola/npcx_program.conf | 2 -- zephyr/program/intelrvp/prj.conf | 4 ---- zephyr/program/it8xxx2_evb/prj.conf | 3 --- zephyr/program/nissa/program.conf | 5 ----- zephyr/program/npcx_evb/npcx7/prj.conf | 1 - zephyr/program/npcx_evb/npcx9/prj.conf | 1 - zephyr/program/rex/prj.conf | 4 ---- zephyr/test/ap_power/prj.conf | 1 - zephyr/test/drivers/prj.conf | 1 - zephyr/test/i2c/prj.conf | 1 - zephyr/test/i2c_dts/prj.conf | 1 - zephyr/test/qcom_power/prj.conf | 1 - zephyr/test/system_common/prj.conf | 1 - zephyr/test/system_shim/prj.conf | 1 - 14 files changed, 27 deletions(-) diff --git a/zephyr/program/corsola/npcx_program.conf b/zephyr/program/corsola/npcx_program.conf index e144e345ed..57cea6930d 100644 --- a/zephyr/program/corsola/npcx_program.conf +++ b/zephyr/program/corsola/npcx_program.conf @@ -9,8 +9,6 @@ CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y # Debug options and features; can be disabled to save memory or once bringup # is complete. CONFIG_SHELL_MINIMAL=n -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y # Charger CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y diff --git a/zephyr/program/intelrvp/prj.conf b/zephyr/program/intelrvp/prj.conf index 4b56a42b53..890122f510 100644 --- a/zephyr/program/intelrvp/prj.conf +++ b/zephyr/program/intelrvp/prj.conf @@ -57,10 +57,6 @@ CONFIG_SHELL_TAB=y CONFIG_SHELL_TAB_AUTOCOMPLETION=y CONFIG_KERNEL_SHELL=y -# Logging -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y - # TODO # Below conf are disabled to compile successfully # These will be enabled in upcoming CLs diff --git a/zephyr/program/it8xxx2_evb/prj.conf b/zephyr/program/it8xxx2_evb/prj.conf index 1e1cac492b..ca11e57ca6 100644 --- a/zephyr/program/it8xxx2_evb/prj.conf +++ b/zephyr/program/it8xxx2_evb/prj.conf @@ -13,9 +13,6 @@ CONFIG_AP_ARM_MTK_MT8192=y # Lid switch CONFIG_PLATFORM_EC_LID_SWITCH=y -# Logging -CONFIG_LOG=y - # Fan CONFIG_SENSOR=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index a803dadc4c..c70dd547ac 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -9,11 +9,6 @@ CONFIG_PLATFORM_EC=y CONFIG_SHIMMED_TASKS=y CONFIG_LTO=y -# Debug options and features; can be disabled to save memory or once bringup -# is complete. -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y - # RAM-saving options # flash shell command is unused, allocated a 4kB buffer for flash test CONFIG_FLASH_SHELL=n diff --git a/zephyr/program/npcx_evb/npcx7/prj.conf b/zephyr/program/npcx_evb/npcx7/prj.conf index 5f1fc03f88..c485e6a631 100644 --- a/zephyr/program/npcx_evb/npcx7/prj.conf +++ b/zephyr/program/npcx_evb/npcx7/prj.conf @@ -52,7 +52,6 @@ CONFIG_PLATFORM_EC_USB_PD_USB4=n # Zephyr feature CONFIG_ASSERT=y CONFIG_SHELL_MINIMAL=n -CONFIG_LOG=y # Avoid underflow info from tachometer CONFIG_SENSOR_LOG_LEVEL_ERR=y diff --git a/zephyr/program/npcx_evb/npcx9/prj.conf b/zephyr/program/npcx_evb/npcx9/prj.conf index 827b6366c6..a4b4c90a55 100644 --- a/zephyr/program/npcx_evb/npcx9/prj.conf +++ b/zephyr/program/npcx_evb/npcx9/prj.conf @@ -56,7 +56,6 @@ CONFIG_PLATFORM_EC_USB_PD_USB4=n # Zephyr feature CONFIG_ASSERT=y CONFIG_SHELL_MINIMAL=n -CONFIG_LOG=y # Avoid underflow info from tachometer CONFIG_SENSOR_LOG_LEVEL_ERR=y diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 38b55aa783..ee0774d43d 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -18,10 +18,6 @@ CONFIG_SHELL_TAB=y CONFIG_SHELL_TAB_AUTOCOMPLETION=y CONFIG_KERNEL_SHELL=y -# Logging -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y - # Disable default features we don't want in a minimal example. CONFIG_PLATFORM_EC_BACKLIGHT_LID=y CONFIG_PLATFORM_EC_SWITCH=y diff --git a/zephyr/test/ap_power/prj.conf b/zephyr/test/ap_power/prj.conf index 122b84e877..2d7e478e29 100644 --- a/zephyr/test/ap_power/prj.conf +++ b/zephyr/test/ap_power/prj.conf @@ -35,7 +35,6 @@ CONFIG_PLATFORM_EC=y CONFIG_CROS_EC=y CONFIG_SHIMMED_TASKS=y CONFIG_EMUL=y -CONFIG_LOG=y CONFIG_GPIO=y CONFIG_GPIO_EMUL=y CONFIG_HEAP_MEM_POOL_SIZE=1024 diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index ffb5af8281..8b113777b2 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -44,7 +44,6 @@ CONFIG_PLATFORM_EC=y CONFIG_CROS_EC=y CONFIG_SHIMMED_TASKS=y CONFIG_EMUL=y -CONFIG_LOG=y CONFIG_I2C_EMUL=y CONFIG_GPIO=y CONFIG_GPIO_EMUL=y diff --git a/zephyr/test/i2c/prj.conf b/zephyr/test/i2c/prj.conf index b81e088ceb..0232fb33a9 100644 --- a/zephyr/test/i2c/prj.conf +++ b/zephyr/test/i2c/prj.conf @@ -3,7 +3,6 @@ # found in the LICENSE file. CONFIG_ZTEST=y -CONFIG_LOG=y CONFIG_EMUL=y CONFIG_I2C_EMUL=y diff --git a/zephyr/test/i2c_dts/prj.conf b/zephyr/test/i2c_dts/prj.conf index 37e0b443a4..8449e32d32 100644 --- a/zephyr/test/i2c_dts/prj.conf +++ b/zephyr/test/i2c_dts/prj.conf @@ -4,7 +4,6 @@ CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y -CONFIG_LOG=y CONFIG_EMUL=y CONFIG_I2C_EMUL=y diff --git a/zephyr/test/qcom_power/prj.conf b/zephyr/test/qcom_power/prj.conf index 16a00da41d..11aa3e6fb3 100644 --- a/zephyr/test/qcom_power/prj.conf +++ b/zephyr/test/qcom_power/prj.conf @@ -19,7 +19,6 @@ CONFIG_FLASH=y CONFIG_GPIO=y CONFIG_GPIO_EMUL=y CONFIG_GPIO_GET_CONFIG=y -CONFIG_LOG=y CONFIG_PLATFORM_EC=y CONFIG_RING_BUFFER=y CONFIG_SERIAL=y diff --git a/zephyr/test/system_common/prj.conf b/zephyr/test/system_common/prj.conf index 02ba4c42a1..67dc659eed 100644 --- a/zephyr/test/system_common/prj.conf +++ b/zephyr/test/system_common/prj.conf @@ -5,7 +5,6 @@ CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y CONFIG_CROS_EC=y -CONFIG_LOG=y CONFIG_PLATFORM_EC_CROS_FWID_VERSION=y CONFIG_PLATFORM_EC=y diff --git a/zephyr/test/system_shim/prj.conf b/zephyr/test/system_shim/prj.conf index 98e133f5ff..6888f70a53 100644 --- a/zephyr/test/system_shim/prj.conf +++ b/zephyr/test/system_shim/prj.conf @@ -6,7 +6,6 @@ CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y CONFIG_PLATFORM_EC=y CONFIG_CROS_EC=y -CONFIG_LOG=y CONFIG_BBRAM=y CONFIG_BBRAM_EMUL=y -- cgit v1.2.1 From 7a3b97fe12c43a81a599067884ee53edacad246d Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 15:19:38 +0000 Subject: zephyr: pwm: default to CONFIG_PWM_SHELL=n Most boards set CONFIG_PWM_SHELL to no explicitly, only nissa enables it. Change the default config so it's off by default and leave it enabled only on nissa where it was already explicitly enabled. Drop a bunch of CONFIG_PWM_SHELL=n from project configs. BRANCH=none BUG=none TEST=cq dry run TEST=verified the config on menuconfig Signed-off-by: Fabio Baltieri Change-Id: I2976505930ec6f866c18c9d4f154b48f14766881 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031188 Code-Coverage: Zoss Reviewed-by: Sam Hurst --- zephyr/Kconfig.defaults | 3 +++ zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig | 1 - zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig | 1 - zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/ite_program.conf | 1 - zephyr/program/corsola/npcx_program.conf | 1 - zephyr/program/herobrine/program.conf | 1 - zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf | 1 - zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf | 1 - zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf | 1 - zephyr/program/it8xxx2_evb/prj.conf | 1 - zephyr/program/skyrim/prj.conf | 1 - zephyr/program/trogdor/lazor/prj.conf | 1 - 13 files changed, 3 insertions(+), 12 deletions(-) diff --git a/zephyr/Kconfig.defaults b/zephyr/Kconfig.defaults index dd980600fa..6eaa34c727 100644 --- a/zephyr/Kconfig.defaults +++ b/zephyr/Kconfig.defaults @@ -40,4 +40,7 @@ config EXTRA_EXCEPTION_INFO config EEPROM_SHELL default n +config PWM_SHELL + default n + orsource "Kconfig.defaults-$(ARCH)" diff --git a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig index 5e0228ac26..48d91ef0d5 100644 --- a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig @@ -42,7 +42,6 @@ CONFIG_I2C=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # Power Management CONFIG_PM=y diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig index c39b9997f4..1e0d012b7d 100644 --- a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig @@ -39,7 +39,6 @@ CONFIG_WATCHDOG=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # Power Management CONFIG_PM=y diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index e0e62ac85a..be3bce0a5a 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -159,7 +159,6 @@ CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR=5 # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # TODO(b/188605676): bring these features up CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n diff --git a/zephyr/program/corsola/ite_program.conf b/zephyr/program/corsola/ite_program.conf index 2a8b46bb28..dc0e54a665 100644 --- a/zephyr/program/corsola/ite_program.conf +++ b/zephyr/program/corsola/ite_program.conf @@ -38,7 +38,6 @@ CONFIG_PLATFORM_EC_LED_DT=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # Sensors CONFIG_PLATFORM_EC_MOTIONSENSE=y diff --git a/zephyr/program/corsola/npcx_program.conf b/zephyr/program/corsola/npcx_program.conf index 57cea6930d..d619afade1 100644 --- a/zephyr/program/corsola/npcx_program.conf +++ b/zephyr/program/corsola/npcx_program.conf @@ -21,7 +21,6 @@ CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # LED CONFIG_PLATFORM_EC_LED_COMMON=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 57fe6614d5..f4fbb931b2 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -30,7 +30,6 @@ CONFIG_PLATFORM_EC_LED_DT=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # Application Processor is Qualcomm SC7280 CONFIG_AP_ARM_QUALCOMM_SC7280=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf index f38982e87d..d7220368a2 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf @@ -41,7 +41,6 @@ CONFIG_PLATFORM_EC_RTC=n # PWM CONFIG_PWM=n -CONFIG_PWM_SHELL=n ## INTEL RVP # Host command diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf index f279e669ad..747fe22a49 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf @@ -11,7 +11,6 @@ CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # RTC CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf index 585b0fcc11..19befba033 100644 --- a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf @@ -8,7 +8,6 @@ CONFIG_SYSCON=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n #RTC CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/program/it8xxx2_evb/prj.conf b/zephyr/program/it8xxx2_evb/prj.conf index ca11e57ca6..b499ba9086 100644 --- a/zephyr/program/it8xxx2_evb/prj.conf +++ b/zephyr/program/it8xxx2_evb/prj.conf @@ -18,7 +18,6 @@ CONFIG_SENSOR=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # Power Button CONFIG_PLATFORM_EC_POWER_BUTTON=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 587d191358..52eb48c095 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -60,7 +60,6 @@ CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n CONFIG_SYSCON=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 83bd48d61b..d8cf4009ea 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -26,7 +26,6 @@ CONFIG_PLATFORM_EC_LED_DT=y # PWM CONFIG_PWM=y -CONFIG_PWM_SHELL=n # Application Processor is Qualcomm SC7180 CONFIG_AP_ARM_QUALCOMM_SC7180=y -- cgit v1.2.1 From 100bf6c96e2499dbf126afb57fedc565545e6c28 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Wed, 16 Nov 2022 02:54:28 -0700 Subject: test: verify flash read hostcommand's overflow conditions Check for overflow error when the host command response buffer is smaller (in this case 0) than the requested read size. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I2722efacf12a55239379e6f4203ff1615c87886e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030064 Reviewed-by: Tomasz Michalec Code-Coverage: Zoss --- zephyr/test/drivers/default/src/flash.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c index 958585c61e..e0c6743cde 100644 --- a/zephyr/test/drivers/default/src/flash.c +++ b/zephyr/test/drivers/default/src/flash.c @@ -135,6 +135,17 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_deasserted) response.flags); } +ZTEST_USER(flash, test_hostcmd_flash_read__overflow) +{ + struct ec_params_flash_read params = { + .size = 32, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_PARAMS(EC_CMD_FLASH_READ, 0, params); + + zassert_equal(EC_RES_OVERFLOW, host_command_process(&args)); +} + #define TEST_BUF_SIZE 0x100 ZTEST_USER(flash, test_hostcmd_flash_write_and_erase) -- cgit v1.2.1 From 2c07deae07162b1ce86bd5251c575408b4403f0a Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Wed, 16 Nov 2022 02:56:27 -0700 Subject: test: test memory mapped storage config Add a new binary variant for memory mapped storage. Add tests for All the edge cases around the flash memory as well as verify that reads and writes work. As done in other tests, an override is added to common/flash.c allowing us to provide our own buffer to intercept the flash address. BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: Icca8ac74a6c98a93b995162efb87b3f5fa111a8a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030065 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- common/flash.c | 10 ++++ zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/Kconfig | 4 ++ zephyr/test/drivers/memmap/CMakeLists.txt | 5 ++ zephyr/test/drivers/memmap/src/main.c | 88 +++++++++++++++++++++++++++++++ zephyr/test/drivers/testcase.yaml | 3 ++ 6 files changed, 111 insertions(+) create mode 100644 zephyr/test/drivers/memmap/CMakeLists.txt create mode 100644 zephyr/test/drivers/memmap/src/main.c diff --git a/common/flash.c b/common/flash.c index de042e76cb..4f3f578eed 100644 --- a/common/flash.c +++ b/common/flash.c @@ -232,6 +232,13 @@ static int flash_range_ok(int offset, int size_req, int align) } #ifdef CONFIG_MAPPED_STORAGE + +/** + * A test public variable allowing us to override the base address of + * flash_physical_dataptr(). + */ +test_export_static const char *flash_physical_dataptr_override; + /** * Get the physical memory address of a flash offset * @@ -245,6 +252,9 @@ static int flash_range_ok(int offset, int size_req, int align) */ static const char *flash_physical_dataptr(int offset) { + if (IS_ENABLED(TEST_BUILD) && flash_physical_dataptr_override != NULL) { + return flash_physical_dataptr_override + offset; + } return (char *)((uintptr_t)CONFIG_MAPPED_STORAGE_BASE + offset); } diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index dd8ab61b59..863c9cb8b6 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -50,6 +50,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON button) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_CONSOLE console) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_CMD_THREAD host_command_thread) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_PI3USB9201 bc12_pi3usb9201) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_MEMMAP memmap) get_target_property(TEST_SOURCES_NEW app SOURCES) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index 496bfd2ac0..07b387f2c6 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -126,4 +126,8 @@ config LINK_TEST_SUITE_HOST_CMD_THREAD config LINK_TEST_SUITE_PI3USB9201 bool "Link and test the pi3usb9201 tests" +config LINK_TEST_SUITE_MEMMAP + bool "Link and test memory mapped tests for common/flash.c" + select PLATFORM_EC_MAPPED_STORAGE + source "Kconfig.zephyr" diff --git a/zephyr/test/drivers/memmap/CMakeLists.txt b/zephyr/test/drivers/memmap/CMakeLists.txt new file mode 100644 index 0000000000..9386414deb --- /dev/null +++ b/zephyr/test/drivers/memmap/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +target_sources(app PRIVATE src/main.c) diff --git a/zephyr/test/drivers/memmap/src/main.c b/zephyr/test/drivers/memmap/src/main.c new file mode 100644 index 0000000000..67c27b5c8d --- /dev/null +++ b/zephyr/test/drivers/memmap/src/main.c @@ -0,0 +1,88 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "flash.h" +#include "host_command.h" +#include "test/drivers/test_state.h" + +extern const char *flash_physical_dataptr_override; + +static char flash[CONFIG_FLASH_SIZE_BYTES]; + +static void after(void *f) +{ + ARG_UNUSED(f); + flash_physical_dataptr_override = NULL; +} + +ZTEST_SUITE(memmap, drivers_predicate_post_main, NULL, NULL, after, NULL); + +ZTEST(memmap, test_crec_flash_dataptr__invalid) +{ + zassert_equal(-1, crec_flash_dataptr(/*offset=*/-1, /*size_req=*/1, + /*align=*/1, /*ptrp=*/NULL)); +} + +ZTEST(memmap, test_crec_flash_dataptr) +{ + const char *ptr = NULL; + + zassert_equal(CONFIG_PLATFORM_EC_FLASH_SIZE_BYTES, + crec_flash_dataptr(0, 1, 1, &ptr)); + zassert_equal(CONFIG_PLATFORM_EC_MAPPED_STORAGE_BASE, (uintptr_t)ptr); +} + +ZTEST(memmap, test_crec_flash_is_erased__invalid_args) +{ + zassert_equal(0, crec_flash_is_erased(/*offset=*/0, /*size=*/-1)); +} + +ZTEST(memmap, test_crec_flash_is_erased__fail) +{ + sprintf(flash, "non empty data"); + flash_physical_dataptr_override = flash; + zassert_equal(0, crec_flash_is_erased(/*offset=*/0, /*size=*/8)); +} + +ZTEST(memmap, test_crec_flash_is_erased__pass) +{ + memset(flash, 0xff, 32); + flash_physical_dataptr_override = flash; + zassert_equal(1, crec_flash_is_erased(/*offset=*/0, /*size=*/32)); +} + +ZTEST(memmap, test_crec_flash_read__invalid_args) +{ + zassert_equal(EC_ERROR_INVAL, crec_flash_read(/*offset=*/-1, /*size=*/0, + /*data=*/NULL)); +} + +ZTEST(memmap, test_crec_flash_read) +{ + char output[16] = { 0 }; + + sprintf(flash, "0123456789abcdef"); + flash_physical_dataptr_override = flash; + + zassert_ok(crec_flash_read(/*offset=*/0, ARRAY_SIZE(output), output)); + zassert_mem_equal(output, flash, ARRAY_SIZE(output)); +} + +ZTEST(memmap, test_crec_flash_write__invalid_args) +{ + zassert_equal(EC_ERROR_INVAL, + crec_flash_write(/*offset=*/-1, /*size=*/0, + /*data=*/NULL)); +} + +ZTEST(memmap, test_crec_flash_erase__invalid_args) +{ + zassert_equal(EC_ERROR_INVAL, + crec_flash_erase(/*offset=*/-1, /*size=*/0)); +} diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 9548596026..2a2f8157f8 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -216,3 +216,6 @@ tests: drivers.pi3usb9201: extra_configs: - CONFIG_LINK_TEST_SUITE_PI3USB9201=y + drivers.memmap: + extra_configs: + - CONFIG_LINK_TEST_SUITE_MEMMAP=y -- cgit v1.2.1 From ede61d51be526389bef177cbcd9b25a96743a6f4 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Wed, 16 Nov 2022 03:24:56 -0700 Subject: test: add coverage to led_common.c Exclude empty functions that cannot be tested. Also, add tests for the led_common function 'led_is_supported' BRANCH=none BUG=none TEST=twister Change-Id: I4d40edf49d025398f2a72e70d0a1847429cc15bf Signed-off-by: Yuval Peress Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4030066 Reviewed-by: Tristan Honscheid Code-Coverage: Zoss --- common/led_common.c | 7 ++++++ zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/Kconfig | 5 +++++ zephyr/test/drivers/led_common/CMakeLists.txt | 5 +++++ zephyr/test/drivers/led_common/src/main.c | 31 +++++++++++++++++++++++++++ zephyr/test/drivers/testcase.yaml | 4 ++++ 6 files changed, 53 insertions(+) create mode 100644 zephyr/test/drivers/led_common/CMakeLists.txt create mode 100644 zephyr/test/drivers/led_common/src/main.c diff --git a/common/led_common.c b/common/led_common.c index 2c73ba95e6..cabaf22e10 100644 --- a/common/led_common.c +++ b/common/led_common.c @@ -47,6 +47,10 @@ int led_auto_control_is_enabled(enum ec_led_id led_id) return (led_auto_control_flags & LED_AUTO_CONTROL_FLAG(led_id)) != 0; } +/* Empty functions cannot be verified in testing to not have had any + * side-effects, remove from coverage. + * LCOV_EXCL_START + */ __attribute__((weak)) void board_led_auto_control(void) { /* @@ -56,6 +60,7 @@ __attribute__((weak)) void board_led_auto_control(void) * is changed. */ } +/* LCOV_EXCL_STOP */ static enum ec_status led_command_control(struct host_cmd_handler_args *args) { @@ -91,6 +96,7 @@ static enum ec_status led_command_control(struct host_cmd_handler_args *args) } DECLARE_HOST_COMMAND(EC_CMD_LED_CONTROL, led_command_control, EC_VER_MASK(1)); +#ifndef CONFIG_ZEPHYR __attribute__((weak)) void led_control(enum ec_led_id led_id, enum ec_led_state state) { @@ -99,3 +105,4 @@ __attribute__((weak)) void led_control(enum ec_led_id led_id, * LED. Boards can provide their own implementation. */ } +#endif diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index 863c9cb8b6..befbe42efb 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -51,6 +51,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_CONSOLE console) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_CMD_THREAD host_command_thread) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_PI3USB9201 bc12_pi3usb9201) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_MEMMAP memmap) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_LED_COMMON led_common) get_target_property(TEST_SOURCES_NEW app SOURCES) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index 07b387f2c6..a96cb0a5f1 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -130,4 +130,9 @@ config LINK_TEST_SUITE_MEMMAP bool "Link and test memory mapped tests for common/flash.c" select PLATFORM_EC_MAPPED_STORAGE +config LINK_TEST_SUITE_LED_COMMON + bool "Link and test the led_common.c file" + depends on !PLATFORM_EC_LED_DT + select PLATFORM_EC_LED_COMMON + source "Kconfig.zephyr" diff --git a/zephyr/test/drivers/led_common/CMakeLists.txt b/zephyr/test/drivers/led_common/CMakeLists.txt new file mode 100644 index 0000000000..9386414deb --- /dev/null +++ b/zephyr/test/drivers/led_common/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +target_sources(app PRIVATE src/main.c) diff --git a/zephyr/test/drivers/led_common/src/main.c b/zephyr/test/drivers/led_common/src/main.c new file mode 100644 index 0000000000..4a712a3779 --- /dev/null +++ b/zephyr/test/drivers/led_common/src/main.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "led_common.h" +#include "test/drivers/test_state.h" + +#include +#include + +const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED, + EC_LED_ID_POWER_LED }; +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +FAKE_VOID_FUNC(led_get_brightness_range, enum ec_led_id, uint8_t *); +FAKE_VALUE_FUNC(int, led_set_brightness, enum ec_led_id, const uint8_t *); + +ZTEST_SUITE(led_common, drivers_predicate_post_main, NULL, NULL, NULL, NULL); + +ZTEST(led_common, test_led_is_supported) +{ + zassert_true(led_is_supported(EC_LED_ID_BATTERY_LED)); + zassert_true(led_is_supported(EC_LED_ID_POWER_LED)); + + zassert_false(led_is_supported(EC_LED_ID_ADAPTER_LED)); + zassert_false(led_is_supported(EC_LED_ID_LEFT_LED)); + zassert_false(led_is_supported(EC_LED_ID_RIGHT_LED)); + zassert_false(led_is_supported(EC_LED_ID_RECOVERY_HW_REINIT_LED)); + zassert_false(led_is_supported(EC_LED_ID_SYSRQ_DEBUG_LED)); +} diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 2a2f8157f8..37fa309836 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -98,6 +98,10 @@ tests: extra_args: CONF_FILE="prj.conf;led_driver/prj.conf" DTC_OVERLAY_FILE="./boards/native_posix.overlay;./led_driver/led_pins.dts;./led_driver/led_policy.dts" extra_configs: - CONFIG_LINK_TEST_SUITE_LED_DRIVER=y + drivers.led_common: + extra_configs: + - CONFIG_LINK_TEST_SUITE_LED_COMMON=y + - CONFIG_PLATFORM_EC_LED_DT=n drivers.locate_chip: extra_configs: - CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS=y -- cgit v1.2.1 From 5b3578dbff19ca2166e6f7303f069ac1b4dd0be3 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Thu, 17 Nov 2022 13:38:10 -0700 Subject: test: move BC1.2 driver from default testcase Move the BC1.2 test from the default testcase into the PI3USB9201 testcase. The BC1.2 test is tightly coupled with the PIUSB9201 driver and emulator. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I79bbfd11ac84cf1a8554daa8c77ad4fa3c5b2631 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4038049 Code-Coverage: Zoss Reviewed-by: Fabio Baltieri --- zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt | 3 +- zephyr/test/drivers/bc12_pi3usb9201/src/main.c | 119 --------- .../test/drivers/bc12_pi3usb9201/src/pi3usb9201.c | 275 +++++++++++++++++++++ .../bc12_pi3usb9201/src/pi3usb9201_interrupt.c | 119 +++++++++ .../drivers/common/include/test/drivers/utils.h | 6 +- zephyr/test/drivers/default/CMakeLists.txt | 1 - zephyr/test/drivers/default/src/bc12.c | 275 --------------------- 7 files changed, 401 insertions(+), 397 deletions(-) delete mode 100644 zephyr/test/drivers/bc12_pi3usb9201/src/main.c create mode 100644 zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c create mode 100644 zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c delete mode 100644 zephyr/test/drivers/default/src/bc12.c diff --git a/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt b/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt index 842a514e16..2f1925b635 100644 --- a/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt +++ b/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt @@ -2,4 +2,5 @@ #Use of this source code is governed by a BSD-style license that can be #found in the LICENSE file. -target_sources(app PRIVATE src/main.c) +target_sources(app PRIVATE src/pi3usb9201.c) +target_sources(app PRIVATE src/pi3usb9201_interrupt.c) diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/main.c b/zephyr/test/drivers/bc12_pi3usb9201/src/main.c deleted file mode 100644 index b2c69c712a..0000000000 --- a/zephyr/test/drivers/bc12_pi3usb9201/src/main.c +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include -#include -#include -#include - -#include "gpio_signal.h" -#include "task.h" -#include "test/drivers/test_state.h" -#include "test/drivers/utils.h" -#include "usb_charge.h" - -/* Get reference to externally linked handlers (defined in DTS) */ -#define USBC0_GPIO_PATH DT_PATH(named_gpios, usb_c0_bc12_int_l) -#define USBC0_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC0_GPIO_PATH, gpios)) -#define USBC0_GPIO_PORT DT_GPIO_PIN(USBC0_GPIO_PATH, gpios) - -#define USBC1_GPIO_PATH DT_PATH(named_gpios, usb_c1_bc12_int_l) -#define USBC1_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC1_GPIO_PATH, gpios)) -#define USBC1_GPIO_PORT DT_GPIO_PIN(USBC1_GPIO_PATH, gpios) - -static void toggle_gpio(const struct device *dev, gpio_pin_t pin) -{ - static const int values[] = { 1, 0, 1 }; - - for (int i = 0; i < ARRAY_SIZE(values); ++i) { - gpio_emul_input_set(dev, pin, values[i]); - } -} - -FAKE_VOID_FUNC(usb_charger_task_event, int, uint32_t); - -struct pi3usb9201_fixture { - const struct bc12_drv *drv[2]; - struct bc12_drv mock_drv; -}; - -static void *setup(void) -{ - static struct pi3usb9201_fixture fixture; - - fixture.mock_drv.usb_charger_task_event = usb_charger_task_event; - - return &fixture; -} - -static void before(void *f) -{ - struct pi3usb9201_fixture *fixture = f; - - fixture->drv[0] = bc12_ports[0].drv; - fixture->drv[1] = bc12_ports[1].drv; - - RESET_FAKE(usb_charger_task_event); - test_set_chipset_to_s0(); -} - -static void after(void *f) -{ - struct pi3usb9201_fixture *fixture = f; - - bc12_ports[0].drv = fixture->drv[0]; - bc12_ports[1].drv = fixture->drv[1]; -} - -ZTEST_SUITE(pi3usb9201, drivers_predicate_post_main, setup, before, after, - NULL); - -ZTEST_F(pi3usb9201, test_usb0_evt) -{ - /* Set up the driver to use the mock */ - bc12_ports[0].drv = &fixture->mock_drv; - - /* Trigger the event and verify that port0 was added to the task event - * bitmap - */ - toggle_gpio(USBC0_GPIO_DEV, USBC0_GPIO_PORT); - zassert_true(*task_get_event_bitmap(TASK_ID_USB_CHG) & BIT(0)); - - /* Give the task a bit of time to process the events */ - task_wake(TASK_ID_USB_CHG); - k_msleep(500); - - /* Ensure that the callback was made (it should be the first, but others - * may exist). - */ - zassert_true(usb_charger_task_event_fake.call_count > 0); - zassert_equal(0, usb_charger_task_event_fake.arg0_history[0]); - zassert_equal(USB_CHG_EVENT_BC12, - usb_charger_task_event_fake.arg1_history[0]); -} - -ZTEST_F(pi3usb9201, test_usb1_evt) -{ - /* Set up the driver to use the mock */ - bc12_ports[1].drv = &fixture->mock_drv; - - /* Trigger the event and verify that port1 was added to the task event - * bitmap - */ - toggle_gpio(USBC1_GPIO_DEV, USBC1_GPIO_PORT); - zassert_true(*task_get_event_bitmap(TASK_ID_USB_CHG) & BIT(1)); - - /* Give the task a bit of time to process the events */ - task_wake(TASK_ID_USB_CHG); - k_msleep(500); - - /* Ensure that the callback was made (it should be the first, but others - * may exist). - */ - zassert_true(usb_charger_task_event_fake.call_count > 0); - zassert_equal(1, usb_charger_task_event_fake.arg0_history[0]); - zassert_equal(USB_CHG_EVENT_BC12, - usb_charger_task_event_fake.arg1_history[0]); -} diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c new file mode 100644 index 0000000000..5d143dcbdb --- /dev/null +++ b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c @@ -0,0 +1,275 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "battery.h" +#include "emul/emul_pi3usb9201.h" +#include "extpower.h" +#include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include "timer.h" +#include "usb_charge.h" + +#include +#include +#include +#include +#include +LOG_MODULE_REGISTER(test_drivers_bc12, LOG_LEVEL_DBG); + +#define EMUL_NODE DT_NODELABEL(pi3usb9201_emul0) + +/* Control_1 register bit definitions */ +#define PI3USB9201_REG_CTRL_1_INT_MASK BIT(0) +#define PI3USB9201_REG_CTRL_1_MODE_SHIFT 1 +#define PI3USB9201_REG_CTRL_1_MODE_MASK \ + (0x7 << PI3USB9201_REG_CTRL_1_MODE_SHIFT) + +/* Control_2 register bit definitions */ +#define PI3USB9201_REG_CTRL_2_AUTO_SW BIT(1) +#define PI3USB9201_REG_CTRL_2_START_DET BIT(3) + +/* Host status register bit definitions */ +#define PI3USB9201_REG_HOST_STS_BC12_DET BIT(0) +#define PI3USB9201_REG_HOST_STS_DEV_PLUG BIT(1) +#define PI3USB9201_REG_HOST_STS_DEV_UNPLUG BIT(2) + +enum pi3usb9201_mode { + PI3USB9201_POWER_DOWN, + PI3USB9201_SDP_HOST_MODE, + PI3USB9201_DCP_HOST_MODE, + PI3USB9201_CDP_HOST_MODE, + PI3USB9201_CLIENT_MODE, + PI3USB9201_RESERVED_1, + PI3USB9201_RESERVED_2, + PI3USB9201_USB_PATH_ON, +}; + +enum pi3usb9201_client_sts { + CHG_OTHER = 0, + CHG_2_4A, + CHG_2_0A, + CHG_1_0A, + CHG_RESERVED, + CHG_CDP, + CHG_SDP, + CHG_DCP, +}; + +struct bc12_status { + enum charge_supplier supplier; + int current_limit; +}; + +static const struct bc12_status bc12_chg_limits[] = { + [CHG_OTHER] = { .supplier = CHARGE_SUPPLIER_OTHER, + .current_limit = 500 }, + [CHG_2_4A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY, + .current_limit = USB_CHARGER_MAX_CURR_MA }, + [CHG_2_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY, + .current_limit = USB_CHARGER_MAX_CURR_MA }, + [CHG_1_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY, + .current_limit = 1000 }, + [CHG_RESERVED] = { .supplier = CHARGE_SUPPLIER_NONE, + .current_limit = 0 }, + [CHG_CDP] = { .supplier = CHARGE_SUPPLIER_BC12_CDP, + .current_limit = USB_CHARGER_MAX_CURR_MA }, + [CHG_SDP] = { .supplier = CHARGE_SUPPLIER_BC12_SDP, + .current_limit = 500 }, +#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW) + [CHG_DCP] = { .supplier = CHARGE_SUPPLIER_BC12_DCP, + .current_limit = USB_CHARGER_MAX_CURR_MA }, +#else + [CHG_DCP] = { .supplier = CHARGE_SUPPLIER_BC12_DCP, + .current_limit = 500 }, +#endif +}; + +#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) +#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) + +static void test_bc12_pi3usb9201_host_mode(void) +{ + const struct emul *emul = EMUL_DT_GET(EMUL_NODE); + uint8_t a, b; + + /* + * Pretend that the USB-C Port Manager (TCPMv2) has set the port data + * role to DFP. + */ + usb_charger_task_set_event(0, USB_CHG_EVENT_DR_DFP); + msleep(1); + /* + * Expect the pi3usb9201 driver to configure CDP host mode and unmask + * interrupts. + */ + pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); + b = PI3USB9201_CDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT; + zassert_equal(a, b); + + /* Pretend that a device has been plugged in. */ + msleep(500); + pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, + PI3USB9201_REG_HOST_STS_DEV_PLUG); + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + msleep(1); + /* Expect the pi3usb9201 driver to configure SDP host mode. */ + pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); + b = PI3USB9201_SDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT; + zassert_equal(a, b); + pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, 0); + + /* Pretend that a device has been unplugged. */ + msleep(500); + pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, + PI3USB9201_REG_HOST_STS_DEV_UNPLUG); + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + msleep(1); + /* Expect the pi3usb9201 driver to configure CDP host mode. */ + pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); + b = PI3USB9201_CDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT; + zassert_equal(a, b); + pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, 0); +} + +static void +test_bc12_pi3usb9201_client_mode(enum pi3usb9201_client_sts detect_result, + enum charge_supplier supplier, + int current_limit) +{ + const struct emul *emul = EMUL_DT_GET(EMUL_NODE); + uint8_t a, b; + int port, voltage; + + /* + * Pretend that the USB-C Port Manager (TCPMv2) has set the port data + * role to UFP and decided charging from the port is allowed. + */ + msleep(500); + usb_charger_task_set_event(0, USB_CHG_EVENT_DR_UFP); + charge_manager_update_dualrole(USBC_PORT_C0, CAP_DEDICATED); + msleep(1); + /* + * Expect the pi3usb9201 driver to configure client mode and start + * detection. + */ + pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); + b = PI3USB9201_CLIENT_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT; + zassert_equal(a, b); + pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a); + b = PI3USB9201_REG_CTRL_2_START_DET; + zassert_equal(a, b); + + /* Pretend that detection completed. */ + msleep(500); + pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS, + 1 << detect_result); + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); + msleep(1); + /* Expect the pi3usb9201 driver to clear the start bit. */ + pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a); + zassert_equal(a, 0); + pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS, 0); + /* + * Expect the charge manager to select the detected BC1.2 supplier. + */ + port = CHARGE_PORT_NONE; + voltage = 0; + if (supplier != CHARGE_SUPPLIER_NONE) { + port = USBC_PORT_C0; + voltage = USB_CHARGER_VOLTAGE_MV; + } + /* Wait for the charge port to update. */ + msleep(500); + zassert_equal(charge_manager_get_active_charge_port(), port); + zassert_equal(charge_manager_get_supplier(), supplier); + zassert_equal(charge_manager_get_charger_current(), current_limit, + NULL); + zassert_equal(charge_manager_get_charger_voltage(), voltage); + + /* + * Pretend that the USB-C Port Manager (TCPMv2) has set the port data + * role to disconnected. + */ + msleep(500); + usb_charger_task_set_event(0, USB_CHG_EVENT_CC_OPEN); + msleep(1); + /* + * Expect the pi3usb9201 driver to configure power down mode and mask + * interrupts. + */ + pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); + b = PI3USB9201_POWER_DOWN << PI3USB9201_REG_CTRL_1_MODE_SHIFT; + b |= PI3USB9201_REG_CTRL_1_INT_MASK; + zassert_equal(a, b); + /* Expect the charge manager to have no active supplier. */ + zassert_equal(charge_manager_get_active_charge_port(), CHARGE_PORT_NONE, + NULL); + zassert_equal(charge_manager_get_supplier(), CHARGE_SUPPLIER_NONE, + NULL); + zassert_equal(charge_manager_get_charger_current(), 0); + zassert_equal(charge_manager_get_charger_voltage(), 0); +} + +/* + * PI3USB9201 is a dual-role BC1.2 charger detector/advertiser used on USB + * ports. It can be programmed to operate in host mode or client mode through + * I2C. When operating as a host, PI3USB9201 enables BC1.2 SDP/CDP/DCP + * advertisement to the attached USB devices via the D+/- connection. When + * operating as a client, PI3USB9201 starts BC1.2 detection to detect the + * attached host type. In both host mode and client mode, the detection results + * are reported through I2C to the controller. + */ +ZTEST_USER(bc12, test_bc12_pi3usb9201) +{ + const struct device *batt_pres_dev = + DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios)); + const struct emul *emul = EMUL_DT_GET(EMUL_NODE); + uint8_t a, b; + + /* Pretend we have battery and AC so charging works normally. */ + zassert_ok(gpio_emul_input_set(batt_pres_dev, GPIO_BATT_PRES_ODL_PORT, + 0), + NULL); + zassert_equal(BP_YES, battery_is_present()); + set_ac_enabled(true); + + /* Wait long enough for TCPMv2 to be idle. */ + msleep(2000); + + /* + * Pretend that the USB-C Port Manager (TCPMv2) has set the port data + * role to disconnected. + */ + usb_charger_task_set_event(0, USB_CHG_EVENT_CC_OPEN); + usb_charger_task_set_event(1, USB_CHG_EVENT_CC_OPEN); + msleep(1); + /* + * Expect the pi3usb9201 driver to configure power down mode and mask + * interrupts. + */ + pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); + b = PI3USB9201_POWER_DOWN << PI3USB9201_REG_CTRL_1_MODE_SHIFT; + b |= PI3USB9201_REG_CTRL_1_INT_MASK; + zassert_equal(a, b); + + test_bc12_pi3usb9201_host_mode(); + + for (int c = CHG_OTHER; c <= CHG_DCP; c++) { + test_bc12_pi3usb9201_client_mode( + c, bc12_chg_limits[c].supplier, + bc12_chg_limits[c].current_limit); + } +} + +/* + * TODO(b/216660795): Cleanup state using a teardown_fn + */ +static void bc12_after(void *unused) +{ + set_ac_enabled(false); +} + +ZTEST_SUITE(bc12, drivers_predicate_post_main, NULL, NULL, bc12_after, NULL); diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c new file mode 100644 index 0000000000..b2c69c712a --- /dev/null +++ b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c @@ -0,0 +1,119 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include + +#include "gpio_signal.h" +#include "task.h" +#include "test/drivers/test_state.h" +#include "test/drivers/utils.h" +#include "usb_charge.h" + +/* Get reference to externally linked handlers (defined in DTS) */ +#define USBC0_GPIO_PATH DT_PATH(named_gpios, usb_c0_bc12_int_l) +#define USBC0_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC0_GPIO_PATH, gpios)) +#define USBC0_GPIO_PORT DT_GPIO_PIN(USBC0_GPIO_PATH, gpios) + +#define USBC1_GPIO_PATH DT_PATH(named_gpios, usb_c1_bc12_int_l) +#define USBC1_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC1_GPIO_PATH, gpios)) +#define USBC1_GPIO_PORT DT_GPIO_PIN(USBC1_GPIO_PATH, gpios) + +static void toggle_gpio(const struct device *dev, gpio_pin_t pin) +{ + static const int values[] = { 1, 0, 1 }; + + for (int i = 0; i < ARRAY_SIZE(values); ++i) { + gpio_emul_input_set(dev, pin, values[i]); + } +} + +FAKE_VOID_FUNC(usb_charger_task_event, int, uint32_t); + +struct pi3usb9201_fixture { + const struct bc12_drv *drv[2]; + struct bc12_drv mock_drv; +}; + +static void *setup(void) +{ + static struct pi3usb9201_fixture fixture; + + fixture.mock_drv.usb_charger_task_event = usb_charger_task_event; + + return &fixture; +} + +static void before(void *f) +{ + struct pi3usb9201_fixture *fixture = f; + + fixture->drv[0] = bc12_ports[0].drv; + fixture->drv[1] = bc12_ports[1].drv; + + RESET_FAKE(usb_charger_task_event); + test_set_chipset_to_s0(); +} + +static void after(void *f) +{ + struct pi3usb9201_fixture *fixture = f; + + bc12_ports[0].drv = fixture->drv[0]; + bc12_ports[1].drv = fixture->drv[1]; +} + +ZTEST_SUITE(pi3usb9201, drivers_predicate_post_main, setup, before, after, + NULL); + +ZTEST_F(pi3usb9201, test_usb0_evt) +{ + /* Set up the driver to use the mock */ + bc12_ports[0].drv = &fixture->mock_drv; + + /* Trigger the event and verify that port0 was added to the task event + * bitmap + */ + toggle_gpio(USBC0_GPIO_DEV, USBC0_GPIO_PORT); + zassert_true(*task_get_event_bitmap(TASK_ID_USB_CHG) & BIT(0)); + + /* Give the task a bit of time to process the events */ + task_wake(TASK_ID_USB_CHG); + k_msleep(500); + + /* Ensure that the callback was made (it should be the first, but others + * may exist). + */ + zassert_true(usb_charger_task_event_fake.call_count > 0); + zassert_equal(0, usb_charger_task_event_fake.arg0_history[0]); + zassert_equal(USB_CHG_EVENT_BC12, + usb_charger_task_event_fake.arg1_history[0]); +} + +ZTEST_F(pi3usb9201, test_usb1_evt) +{ + /* Set up the driver to use the mock */ + bc12_ports[1].drv = &fixture->mock_drv; + + /* Trigger the event and verify that port1 was added to the task event + * bitmap + */ + toggle_gpio(USBC1_GPIO_DEV, USBC1_GPIO_PORT); + zassert_true(*task_get_event_bitmap(TASK_ID_USB_CHG) & BIT(1)); + + /* Give the task a bit of time to process the events */ + task_wake(TASK_ID_USB_CHG); + k_msleep(500); + + /* Ensure that the callback was made (it should be the first, but others + * may exist). + */ + zassert_true(usb_charger_task_event_fake.call_count > 0); + zassert_equal(1, usb_charger_task_event_fake.arg0_history[0]); + zassert_equal(USB_CHG_EVENT_BC12, + usb_charger_task_event_fake.arg1_history[0]); +} diff --git a/zephyr/test/drivers/common/include/test/drivers/utils.h b/zephyr/test/drivers/common/include/test/drivers/utils.h index d2e0b06a5d..7be7dd5400 100644 --- a/zephyr/test/drivers/common/include/test/drivers/utils.h +++ b/zephyr/test/drivers/common/include/test/drivers/utils.h @@ -593,7 +593,11 @@ static inline void set_ac_enabled(bool enabled) zassert_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled), NULL); - k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1)); + /* + * b/253284635 - Sleep for a full second past the debounce time + * to ensure the power button debounce logic runs. + */ + k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1000)); zassert_equal(enabled, extpower_is_present(), NULL); } diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt index 16b9aad4b6..d7396ad159 100644 --- a/zephyr/test/drivers/default/CMakeLists.txt +++ b/zephyr/test/drivers/default/CMakeLists.txt @@ -1,7 +1,6 @@ target_sources(app PRIVATE src/battery.c src/bb_retimer.c - src/bc12.c src/bma2x2.c src/bmi_common.c src/bmi160.c diff --git a/zephyr/test/drivers/default/src/bc12.c b/zephyr/test/drivers/default/src/bc12.c deleted file mode 100644 index 5d143dcbdb..0000000000 --- a/zephyr/test/drivers/default/src/bc12.c +++ /dev/null @@ -1,275 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "battery.h" -#include "emul/emul_pi3usb9201.h" -#include "extpower.h" -#include "test/drivers/stubs.h" -#include "test/drivers/test_state.h" -#include "test/drivers/utils.h" -#include "timer.h" -#include "usb_charge.h" - -#include -#include -#include -#include -#include -LOG_MODULE_REGISTER(test_drivers_bc12, LOG_LEVEL_DBG); - -#define EMUL_NODE DT_NODELABEL(pi3usb9201_emul0) - -/* Control_1 register bit definitions */ -#define PI3USB9201_REG_CTRL_1_INT_MASK BIT(0) -#define PI3USB9201_REG_CTRL_1_MODE_SHIFT 1 -#define PI3USB9201_REG_CTRL_1_MODE_MASK \ - (0x7 << PI3USB9201_REG_CTRL_1_MODE_SHIFT) - -/* Control_2 register bit definitions */ -#define PI3USB9201_REG_CTRL_2_AUTO_SW BIT(1) -#define PI3USB9201_REG_CTRL_2_START_DET BIT(3) - -/* Host status register bit definitions */ -#define PI3USB9201_REG_HOST_STS_BC12_DET BIT(0) -#define PI3USB9201_REG_HOST_STS_DEV_PLUG BIT(1) -#define PI3USB9201_REG_HOST_STS_DEV_UNPLUG BIT(2) - -enum pi3usb9201_mode { - PI3USB9201_POWER_DOWN, - PI3USB9201_SDP_HOST_MODE, - PI3USB9201_DCP_HOST_MODE, - PI3USB9201_CDP_HOST_MODE, - PI3USB9201_CLIENT_MODE, - PI3USB9201_RESERVED_1, - PI3USB9201_RESERVED_2, - PI3USB9201_USB_PATH_ON, -}; - -enum pi3usb9201_client_sts { - CHG_OTHER = 0, - CHG_2_4A, - CHG_2_0A, - CHG_1_0A, - CHG_RESERVED, - CHG_CDP, - CHG_SDP, - CHG_DCP, -}; - -struct bc12_status { - enum charge_supplier supplier; - int current_limit; -}; - -static const struct bc12_status bc12_chg_limits[] = { - [CHG_OTHER] = { .supplier = CHARGE_SUPPLIER_OTHER, - .current_limit = 500 }, - [CHG_2_4A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY, - .current_limit = USB_CHARGER_MAX_CURR_MA }, - [CHG_2_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY, - .current_limit = USB_CHARGER_MAX_CURR_MA }, - [CHG_1_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY, - .current_limit = 1000 }, - [CHG_RESERVED] = { .supplier = CHARGE_SUPPLIER_NONE, - .current_limit = 0 }, - [CHG_CDP] = { .supplier = CHARGE_SUPPLIER_BC12_CDP, - .current_limit = USB_CHARGER_MAX_CURR_MA }, - [CHG_SDP] = { .supplier = CHARGE_SUPPLIER_BC12_SDP, - .current_limit = 500 }, -#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW) - [CHG_DCP] = { .supplier = CHARGE_SUPPLIER_BC12_DCP, - .current_limit = USB_CHARGER_MAX_CURR_MA }, -#else - [CHG_DCP] = { .supplier = CHARGE_SUPPLIER_BC12_DCP, - .current_limit = 500 }, -#endif -}; - -#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) -#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) - -static void test_bc12_pi3usb9201_host_mode(void) -{ - const struct emul *emul = EMUL_DT_GET(EMUL_NODE); - uint8_t a, b; - - /* - * Pretend that the USB-C Port Manager (TCPMv2) has set the port data - * role to DFP. - */ - usb_charger_task_set_event(0, USB_CHG_EVENT_DR_DFP); - msleep(1); - /* - * Expect the pi3usb9201 driver to configure CDP host mode and unmask - * interrupts. - */ - pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); - b = PI3USB9201_CDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT; - zassert_equal(a, b); - - /* Pretend that a device has been plugged in. */ - msleep(500); - pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, - PI3USB9201_REG_HOST_STS_DEV_PLUG); - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - msleep(1); - /* Expect the pi3usb9201 driver to configure SDP host mode. */ - pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); - b = PI3USB9201_SDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT; - zassert_equal(a, b); - pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, 0); - - /* Pretend that a device has been unplugged. */ - msleep(500); - pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, - PI3USB9201_REG_HOST_STS_DEV_UNPLUG); - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - msleep(1); - /* Expect the pi3usb9201 driver to configure CDP host mode. */ - pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); - b = PI3USB9201_CDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT; - zassert_equal(a, b); - pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, 0); -} - -static void -test_bc12_pi3usb9201_client_mode(enum pi3usb9201_client_sts detect_result, - enum charge_supplier supplier, - int current_limit) -{ - const struct emul *emul = EMUL_DT_GET(EMUL_NODE); - uint8_t a, b; - int port, voltage; - - /* - * Pretend that the USB-C Port Manager (TCPMv2) has set the port data - * role to UFP and decided charging from the port is allowed. - */ - msleep(500); - usb_charger_task_set_event(0, USB_CHG_EVENT_DR_UFP); - charge_manager_update_dualrole(USBC_PORT_C0, CAP_DEDICATED); - msleep(1); - /* - * Expect the pi3usb9201 driver to configure client mode and start - * detection. - */ - pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); - b = PI3USB9201_CLIENT_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT; - zassert_equal(a, b); - pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a); - b = PI3USB9201_REG_CTRL_2_START_DET; - zassert_equal(a, b); - - /* Pretend that detection completed. */ - msleep(500); - pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS, - 1 << detect_result); - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - msleep(1); - /* Expect the pi3usb9201 driver to clear the start bit. */ - pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a); - zassert_equal(a, 0); - pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS, 0); - /* - * Expect the charge manager to select the detected BC1.2 supplier. - */ - port = CHARGE_PORT_NONE; - voltage = 0; - if (supplier != CHARGE_SUPPLIER_NONE) { - port = USBC_PORT_C0; - voltage = USB_CHARGER_VOLTAGE_MV; - } - /* Wait for the charge port to update. */ - msleep(500); - zassert_equal(charge_manager_get_active_charge_port(), port); - zassert_equal(charge_manager_get_supplier(), supplier); - zassert_equal(charge_manager_get_charger_current(), current_limit, - NULL); - zassert_equal(charge_manager_get_charger_voltage(), voltage); - - /* - * Pretend that the USB-C Port Manager (TCPMv2) has set the port data - * role to disconnected. - */ - msleep(500); - usb_charger_task_set_event(0, USB_CHG_EVENT_CC_OPEN); - msleep(1); - /* - * Expect the pi3usb9201 driver to configure power down mode and mask - * interrupts. - */ - pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); - b = PI3USB9201_POWER_DOWN << PI3USB9201_REG_CTRL_1_MODE_SHIFT; - b |= PI3USB9201_REG_CTRL_1_INT_MASK; - zassert_equal(a, b); - /* Expect the charge manager to have no active supplier. */ - zassert_equal(charge_manager_get_active_charge_port(), CHARGE_PORT_NONE, - NULL); - zassert_equal(charge_manager_get_supplier(), CHARGE_SUPPLIER_NONE, - NULL); - zassert_equal(charge_manager_get_charger_current(), 0); - zassert_equal(charge_manager_get_charger_voltage(), 0); -} - -/* - * PI3USB9201 is a dual-role BC1.2 charger detector/advertiser used on USB - * ports. It can be programmed to operate in host mode or client mode through - * I2C. When operating as a host, PI3USB9201 enables BC1.2 SDP/CDP/DCP - * advertisement to the attached USB devices via the D+/- connection. When - * operating as a client, PI3USB9201 starts BC1.2 detection to detect the - * attached host type. In both host mode and client mode, the detection results - * are reported through I2C to the controller. - */ -ZTEST_USER(bc12, test_bc12_pi3usb9201) -{ - const struct device *batt_pres_dev = - DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios)); - const struct emul *emul = EMUL_DT_GET(EMUL_NODE); - uint8_t a, b; - - /* Pretend we have battery and AC so charging works normally. */ - zassert_ok(gpio_emul_input_set(batt_pres_dev, GPIO_BATT_PRES_ODL_PORT, - 0), - NULL); - zassert_equal(BP_YES, battery_is_present()); - set_ac_enabled(true); - - /* Wait long enough for TCPMv2 to be idle. */ - msleep(2000); - - /* - * Pretend that the USB-C Port Manager (TCPMv2) has set the port data - * role to disconnected. - */ - usb_charger_task_set_event(0, USB_CHG_EVENT_CC_OPEN); - usb_charger_task_set_event(1, USB_CHG_EVENT_CC_OPEN); - msleep(1); - /* - * Expect the pi3usb9201 driver to configure power down mode and mask - * interrupts. - */ - pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a); - b = PI3USB9201_POWER_DOWN << PI3USB9201_REG_CTRL_1_MODE_SHIFT; - b |= PI3USB9201_REG_CTRL_1_INT_MASK; - zassert_equal(a, b); - - test_bc12_pi3usb9201_host_mode(); - - for (int c = CHG_OTHER; c <= CHG_DCP; c++) { - test_bc12_pi3usb9201_client_mode( - c, bc12_chg_limits[c].supplier, - bc12_chg_limits[c].current_limit); - } -} - -/* - * TODO(b/216660795): Cleanup state using a teardown_fn - */ -static void bc12_after(void *unused) -{ - set_ac_enabled(false); -} - -ZTEST_SUITE(bc12, drivers_predicate_post_main, NULL, NULL, bc12_after, NULL); -- cgit v1.2.1 From 8e66b54342f612c499ebb48a3038054bf40537e6 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Thu, 17 Nov 2022 15:44:38 -0800 Subject: battery_v2: remove redundant checks p->index is unsigned BUG=b:64477774 BRANCH=none TEST=make -j buildall Signed-off-by: Boris Mittelberg Change-Id: I706c27b4e65b8bf8d378bf4f1b31687e66af8f90 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4035429 Reviewed-by: Daisuke Nojiri Reviewed-by: caveh jalali Code-Coverage: Zoss --- common/battery_v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/battery_v2.c b/common/battery_v2.c index 57ae07196b..50b5fb12f1 100644 --- a/common/battery_v2.c +++ b/common/battery_v2.c @@ -86,7 +86,7 @@ host_command_battery_get_static(struct host_cmd_handler_args *args) const struct ec_params_battery_static_info *p = args->params; const struct battery_static_info *bs; - if (p->index < 0 || p->index >= CONFIG_BATTERY_COUNT) + if (p->index >= CONFIG_BATTERY_COUNT) return EC_RES_INVALID_PARAM; bs = &battery_static[p->index]; @@ -144,7 +144,7 @@ host_command_battery_get_dynamic(struct host_cmd_handler_args *args) const struct ec_params_battery_dynamic_info *p = args->params; struct ec_response_battery_dynamic_info *r = args->response; - if (p->index < 0 || p->index >= CONFIG_BATTERY_COUNT) + if (p->index >= CONFIG_BATTERY_COUNT) return EC_RES_INVALID_PARAM; args->response_size = sizeof(*r); -- cgit v1.2.1 From eccb0c71b575e461dd7b3c54af368bf95365a5de Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 16 Nov 2022 16:45:50 -0800 Subject: isl923x: fix index check Fix chgnum bound check to avoid out-of-bound access BUG=b:64477774 BRANCH=none TEST=make -j buildall Signed-off-by: Boris Mittelberg Change-Id: I293732c2a751f71552b6cf17bc9c9e9e2df70391 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032281 Reviewed-by: caveh jalali Reviewed-by: Daisuke Nojiri Code-Coverage: Zoss --- driver/charger/isl923x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index 2263c45b78..04db73353a 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -865,7 +865,7 @@ enum ec_error_list raa489000_is_acok(int chgnum, bool *acok) { int regval, rv; - if ((chgnum < 0) || (chgnum > board_get_charger_chip_count())) { + if ((chgnum < 0) || (chgnum >= board_get_charger_chip_count())) { CPRINTS("%s: Invalid chgnum! (%d)", __func__, chgnum); return EC_ERROR_INVAL; } @@ -890,7 +890,7 @@ void raa489000_hibernate(int chgnum, bool disable_adc) { int rv, regval; - if ((chgnum < 0) || (chgnum > board_get_charger_chip_count())) { + if ((chgnum < 0) || (chgnum >= board_get_charger_chip_count())) { CPRINTS("%s: Invalid chgnum! (%d)", __func__, chgnum); return; } -- cgit v1.2.1 From 4c1230c1e6e4d4884c7aa110ebb72b5d14e7b614 Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Wed, 16 Nov 2022 14:09:55 -0700 Subject: twister: Add tags to enable Testhaus Add queued_time and board tags to test results Example twister.json format -- go/paste/5260283562950656 BUG=b:247857971 BRANCH=None TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs Change-Id: Ia252aa72fa433e13ec45e4d9470d96370888ad00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032325 Reviewed-by: Zhihui Xie Code-Coverage: Zoss --- util/twister_launcher.py | 1 + util/zephyr_to_resultdb.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/util/twister_launcher.py b/util/twister_launcher.py index c67d15d97d..f0e49c5298 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -185,6 +185,7 @@ def upload_results(ec_base, outdir): "-realm", "chromium:public", "--", + "vpython3", str(ec_base / "util/zephyr_to_resultdb.py"), "--result=" + str(json_path), "--upload=True", diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py index 48bfe151e4..683cf98eb5 100755 --- a/util/zephyr_to_resultdb.py +++ b/util/zephyr_to_resultdb.py @@ -11,6 +11,7 @@ import argparse import base64 +import datetime import json import os @@ -82,7 +83,7 @@ def testcase_artifact(testcase): return base64.b64encode(artifact.encode()) -def testcase_to_result(testsuite, testcase): +def testcase_to_result(testsuite, testcase, base_tags): """Translates ZTEST testcase to ResultDB format""" result = { "testId": testcase["identifier"], @@ -103,19 +104,43 @@ def testcase_to_result(testsuite, testcase): "testMetadata": {"name": testcase["identifier"]}, } + for (key, value) in base_tags: + result["tags"].append({"key": key, "value": value}) + return result +def create_base_tags(data): + """Creates base tags needed for Testhaus""" + base_tags = [] + + queued_time = datetime.datetime.fromisoformat( + data["environment"]["run_date"] + ) + base_tags.append( + ("queued_time", queued_time.strftime("%Y-%m-%d %H:%M:%S.%f UTC")) + ) + + base_tags.append(("zephyr_version", data["environment"]["zephyr_version"])) + base_tags.append(("board", data["environment"]["os"])) + base_tags.append(("toolchain", data["environment"]["toolchain"])) + + return base_tags + + def json_to_resultdb(result_file): """Translates Twister json test report to ResultDB format""" with open(result_file) as file: data = json.load(file) results = [] + base_tags = create_base_tags(data) for testsuite in data["testsuites"]: for testcase in testsuite["testcases"]: if testcase["status"]: - results.append(testcase_to_result(testsuite, testcase)) + results.append( + testcase_to_result(testsuite, testcase, base_tags) + ) file.close() -- cgit v1.2.1 From 24fa4c10964224b12799ae8b6b08ea85a52acbd4 Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Wed, 16 Nov 2022 14:12:58 -0700 Subject: twister: Add config to tags for tests Parse autoconf.h to add testsuite configuration as tags for the test BUG=b:239952573 BRANCH=NONE TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs Change-Id: I964c0e7e1f5c50435075e5c76fb29426eb54d184 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032746 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- util/zephyr_to_resultdb.py | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py index 683cf98eb5..0375e42ddb 100755 --- a/util/zephyr_to_resultdb.py +++ b/util/zephyr_to_resultdb.py @@ -14,6 +14,8 @@ import base64 import datetime import json import os +import pathlib +import re import requests # pylint: disable=import-error @@ -83,8 +85,11 @@ def testcase_artifact(testcase): return base64.b64encode(artifact.encode()) -def testcase_to_result(testsuite, testcase, base_tags): - """Translates ZTEST testcase to ResultDB format""" +def testcase_to_result(testsuite, testcase, base_tags, config_tags): + """Translates ZTEST testcase to ResultDB format + See TestResult type in + https://crsrc.org/i/go/src/go.chromium.org/luci/resultdb/sink/proto/v1/test_result.proto + """ result = { "testId": testcase["identifier"], "status": translate_status(testcase["status"]), @@ -95,9 +100,7 @@ def testcase_to_result(testsuite, testcase, base_tags): "contents": testcase_artifact(testcase), } }, - # TODO(b/239952573) Add all test configs as tags "tags": [ - {"key": "category", "value": "ChromeOS/EC"}, {"key": "platform", "value": testsuite["platform"]}, ], "duration": translate_duration(testcase), @@ -107,9 +110,31 @@ def testcase_to_result(testsuite, testcase, base_tags): for (key, value) in base_tags: result["tags"].append({"key": key, "value": value}) + for (key, value) in config_tags: + result["tags"].append({"key": key.lower(), "value": value}) + return result +def get_testsuite_config_tags(twister_dir, testsuite): + """Creates config tags from the testsuite""" + config_tags = [] + suite_path = f"{twister_dir}/{testsuite['platform']}/{testsuite['name']}" + autoconf_h = f"{suite_path}/zephyr/include/generated/autoconf.h" + + if pathlib.Path(autoconf_h).exists(): + with open(autoconf_h) as file: + lines = file.readlines() + + for line in lines: + result = re.search(r"#define\s*(\w+)\s*(.+$)", line) + config_tags.append((result.group(1), result.group(2))) + else: + print(f"Can't find config file for {testsuite['name']}") + + return config_tags + + def create_base_tags(data): """Creates base tags needed for Testhaus""" base_tags = [] @@ -136,10 +161,15 @@ def json_to_resultdb(result_file): base_tags = create_base_tags(data) for testsuite in data["testsuites"]: + config_tags = get_testsuite_config_tags( + os.path.dirname(result_file), testsuite + ) for testcase in testsuite["testcases"]: if testcase["status"]: results.append( - testcase_to_result(testsuite, testcase, base_tags) + testcase_to_result( + testsuite, testcase, base_tags, config_tags + ) ) file.close() -- cgit v1.2.1 From d01200c9c770b857ec642164cb767f9d86023184 Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Wed, 16 Nov 2022 16:14:39 -0700 Subject: twister: Upload full test suite logs to ResultDB Include full testsuite log with test results BUG=b:248067639 BRANCH=NONE TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs Change-Id: I7cf0413ba4479fd09770851988c77e9206f8e923 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4033066 Reviewed-by: Simon Glass Code-Coverage: Zoss --- util/zephyr_to_resultdb.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py index 0375e42ddb..438a3cd4d1 100755 --- a/util/zephyr_to_resultdb.py +++ b/util/zephyr_to_resultdb.py @@ -62,9 +62,7 @@ def testcase_summary(testcase): or "reason" in testcase or translate_status(testcase["status"]) == "SKIP" ): - html = ( - '

' - ) + html = '

' return html @@ -85,6 +83,16 @@ def testcase_artifact(testcase): return base64.b64encode(artifact.encode()) +def testsuite_artifact(testsuite): + """Translates ZTEST testcase to ResultDB artifact""" + artifact = "Unknown" + + if "log" in testsuite and testsuite["log"]: + artifact = testsuite["log"] + + return base64.b64encode(artifact.encode()) + + def testcase_to_result(testsuite, testcase, base_tags, config_tags): """Translates ZTEST testcase to ResultDB format See TestResult type in @@ -96,9 +104,12 @@ def testcase_to_result(testsuite, testcase, base_tags, config_tags): "expected": translate_expected(testcase["status"]), "summaryHtml": testcase_summary(testcase), "artifacts": { - "artifact-content-in-request": { + "test_log": { "contents": testcase_artifact(testcase), - } + }, + "testsuite_log": { + "contents": testsuite_artifact(testsuite), + }, }, "tags": [ {"key": "platform", "value": testsuite["platform"]}, @@ -113,6 +124,12 @@ def testcase_to_result(testsuite, testcase, base_tags, config_tags): for (key, value) in config_tags: result["tags"].append({"key": key.lower(), "value": value}) + if result["status"] == "FAIL" and "log" in testcase and testcase["log"]: + assert_msg = re.findall( + r"Assertion failed.*$", testcase["log"], re.MULTILINE + ) + result["failureReason"] = {"primaryErrorMessage": assert_msg[0]} + return result -- cgit v1.2.1 From 406f02c99b61ff7a1b6e0c947e3653263d82bcc9 Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Thu, 17 Nov 2022 09:53:26 -0700 Subject: zephyr:tests: Validate powerinfo console command Add test to check 'powerinfo' console command BUG=b:236074676 BRANCH=NONE TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs Change-Id: I4f4f71aa5a50a0fe26a6e9c8ac0a0fd255c3c7d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4033898 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss Commit-Queue: Jeremy Bettis --- zephyr/test/drivers/default/src/power_common.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/zephyr/test/drivers/default/src/power_common.c b/zephyr/test/drivers/default/src/power_common.c index 6e18204188..2b8ba4ac88 100644 --- a/zephyr/test/drivers/default/src/power_common.c +++ b/zephyr/test/drivers/default/src/power_common.c @@ -486,6 +486,19 @@ ZTEST(power_common, power_console_cmd) shell_execute_cmd(get_ec_shell(), "power off"), NULL); } +/** + * Test powerinfo console command + */ +ZTEST_USER(power_common, powerinfo_console_cmd) +{ + char expected_buffer[32]; + + snprintf(expected_buffer, sizeof(expected_buffer), "power state %d", + power_get_state()); + + CHECK_CONSOLE_CMD("powerinfo", expected_buffer, EC_SUCCESS); +} + /** * Common setup for hibernation delay tests. Smart discharge zone is setup, * battery is set in safe zone (which trigger hibernation), power state is -- cgit v1.2.1 From b3d7ad5e5efb98192154f807dc6ae6ade702438d Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Wed, 16 Nov 2022 22:51:15 -0700 Subject: test: add missing coverage for mkbp_event.c Add tests for: - host and console commands setting and getting the event masks - setting no events while sleeping should not fire interrupt BRANCH=none BUG=none TEST=twister Signed-off-by: Yuval Peress Change-Id: I0f2a1b516287e45a13ab2418b00a1d9e713b9b16 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032392 Commit-Queue: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Jeremy Bettis --- common/mkbp_event.c | 7 ++ zephyr/test/drivers/Kconfig | 2 + zephyr/test/drivers/boards/native_posix.overlay | 10 +- zephyr/test/drivers/keyboard_scan/src/mkbp_event.c | 106 ++++++++++++++++++++- 4 files changed, 121 insertions(+), 4 deletions(-) diff --git a/common/mkbp_event.c b/common/mkbp_event.c index e602f81baf..4282da95b9 100644 --- a/common/mkbp_event.c +++ b/common/mkbp_event.c @@ -586,5 +586,12 @@ void mkbp_event_clear_all(void) /* Reset the interrupt line */ mkbp_set_host_active(0, NULL); +#ifdef CONFIG_MKBP_EVENT_WAKEUP_MASK + mkbp_event_wake_mask = CONFIG_MKBP_EVENT_WAKEUP_MASK; +#endif /* CONFIG_MKBP_EVENT_WAKEUP_MASK */ + +#ifdef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK + mkbp_host_event_wake_mask = CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK; +#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */ } #endif diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index a96cb0a5f1..9f80e53dd3 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -44,6 +44,8 @@ config LINK_TEST_SUITE_I2C_CONTROLLER config LINK_TEST_SUITE_KEYBOARD_SCAN bool "Link and test the keyboard_scan tests" + select PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK + select PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK config LINK_TEST_SUITE_LED_DRIVER bool "Link and test the led_driver tests" diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index 72b7bef5c0..c47c63494d 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -47,7 +47,15 @@ HOST_EVENT_HANG_DETECT | HOST_EVENT_RTC | HOST_EVENT_MODE_CHANGE | - HOST_EVENT_DEVICE)>; + HOST_EVENT_DEVICE | + HOST_EVENT_KEYBOARD_RECOVERY)>; + }; + + ec-mkbp-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \ + MKBP_EVENT_HOST_EVENT | \ + MKBP_EVENT_SENSOR_FIFO)>; }; usbc { diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c index b45f7b20ef..2d6560fd1e 100644 --- a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c +++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c @@ -2,12 +2,15 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + +#include "chipset.h" #include "console.h" #include "host_command.h" #include "mkbp_event.h" #include "mkbp_fifo.h" #include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include #include @@ -34,7 +37,7 @@ struct event_fixture { static struct event_fixture fixture; -ZTEST(mkbp_event, host_command_get_events__empty) +ZTEST(mkbp_event, test_host_command_get_events__empty) { /* Issue a host command to get the next event (from any source) */ uint16_t ret; @@ -47,7 +50,102 @@ ZTEST(mkbp_event, host_command_get_events__empty) "Expected EC_RES_UNAVAILABLE but got %d", ret); } -ZTEST(mkbp_event, host_command_get_events__get_event) +ZTEST(mkbp_event, test_activate_with_events) +{ + const struct device *gpio_dev = DEVICE_DT_GET( + DT_GPIO_CTLR(DT_NODELABEL(gpio_ap_ec_int_l), gpios)); + const int gpio_pin = DT_GPIO_PIN(DT_NODELABEL(gpio_ap_ec_int_l), gpios); + + /* Put the chipset to sleep */ + chipset_force_shutdown(CHIPSET_SHUTDOWN_BUTTON); + k_sleep(K_SECONDS(15)); + + /* Activate with no events, should not trigger an interrupt */ + activate_mkbp_with_events(0); + + /* Check that GPIO is still 1 */ + zassert_equal(1, gpio_emul_output_get(gpio_dev, gpio_pin)); +} + +ZTEST(mkbp_event, test_host_command_host_event_wake_mask) +{ + struct ec_response_mkbp_event_wake_mask response = { 0 }; + struct ec_params_mkbp_event_wake_mask params = { 0 }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params); + + /* Set the wake mask to 0x12345678 */ + params.action = SET_WAKE_MASK; + params.mask_type = EC_MKBP_HOST_EVENT_WAKE_MASK; + params.new_wake_mask = 0x12345678; + + zassert_ok(host_command_process(&args)); + + /* Get the wake mask */ + params.action = GET_WAKE_MASK; + + zassert_ok(host_command_process(&args)); + zassert_equal(0x12345678, response.wake_mask); +} + +ZTEST(mkbp_event, test_host_command_event_wake_mask) +{ + struct ec_response_mkbp_event_wake_mask response = { 0 }; + struct ec_params_mkbp_event_wake_mask params = { 0 }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params); + + /* Set the wake mask to 0x87654321 */ + params.action = SET_WAKE_MASK; + params.mask_type = EC_MKBP_EVENT_WAKE_MASK; + params.new_wake_mask = 0x87654321; + + zassert_ok(host_command_process(&args)); + + /* Get the wake mask */ + params.action = GET_WAKE_MASK; + + zassert_ok(host_command_process(&args)); + zassert_equal(0x87654321, response.wake_mask); +} + +ZTEST(mkbp_event, test_host_command_wake_mask__invalid_args) +{ + struct ec_response_mkbp_event_wake_mask response = { 0 }; + struct ec_params_mkbp_event_wake_mask params = { + .action = -1, + .mask_type = -1, + }; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params); + + /* Check invalid action */ + zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args)); + + /* Check invalid mask type in getter */ + params.action = GET_WAKE_MASK; + zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args)); + + /* Check invalid mask type in setter */ + params.action = SET_WAKE_MASK; + zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args)); +} + +ZTEST(mkbp_event, test_console_command_wake_mask_event) +{ + check_console_cmd("mkbpwakemask event 500", + "MKBP event wake mask: 0x000001f4", 0, __FILE__, + __LINE__); + check_console_cmd("mkbpwakemask hostevent 7934", + "MKBP host event wake mask: 0x00001efe", 0, __FILE__, + __LINE__); + check_console_cmd("mkbpwakemask event f", NULL, EC_ERROR_PARAM2, + __FILE__, __LINE__); + check_console_cmd("mkbpwakemask event", NULL, EC_ERROR_PARAM_COUNT, + __FILE__, __LINE__); +} + +ZTEST(mkbp_event, test_host_command_get_events__get_event) { /* Dispatch a fake keyboard event and ensure it gets returned by the * host command. @@ -99,7 +197,7 @@ ZTEST(mkbp_event, host_command_get_events__get_event) interrupt_gpio_monitor_fake.call_count); } -ZTEST(mkbp_event, no_ap_response) +ZTEST(mkbp_event, test_no_ap_response) { /* Cause an event but do not send any host commands. This should cause * the EC to send the interrupt to the AP 3 times before giving up. @@ -184,6 +282,8 @@ static void reset_events(void *data) RESET_FAKE(interrupt_gpio_monitor); RESET_FAKE(mkbp_send_event); mkbp_send_event_fake.return_val = 1; + + test_set_chipset_to_s0(); } ZTEST_SUITE(mkbp_event, drivers_predicate_post_main, setup, reset_events, -- cgit v1.2.1 From c1642270ed023a462223e93d1a9b3f953182b6d5 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 15 Nov 2022 13:50:29 -0700 Subject: zephyr: Remove unneeded nocheck markers The shell_dummy is in the unblocked words list for zephyr/test, so nocheck is not needed. BRANCH=None BUG=None TEST=None Signed-off-by: Jeremy Bettis Change-Id: I2e2588f5bc0e1a7ef7951deedbbc14d3251c028f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032914 Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Reviewed-by: Tristan Honscheid --- zephyr/test/drivers/common/src/utils.c | 2 +- zephyr/test/drivers/default/src/console_cmd/pwr_avg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c index 14da1331aa..afea5edbac 100644 --- a/zephyr/test/drivers/common/src/utils.c +++ b/zephyr/test/drivers/common/src/utils.c @@ -23,7 +23,7 @@ #include #include #include -#include /* nocheck */ +#include #include #include diff --git a/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c b/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c index 3e00b5e432..b21755a465 100644 --- a/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c +++ b/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c @@ -11,7 +11,7 @@ #include #include -#include /* nocheck */ +#include #include ZTEST_SUITE(console_cmd_pwr_avg, drivers_predicate_post_main, NULL, NULL, NULL, -- cgit v1.2.1 From 92ee12965a30e88904ee1e72642ea370b32d784c Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Thu, 17 Nov 2022 16:03:12 -0800 Subject: pompom: dead code elimination Pompom has only one type-c port, remove the unnecessary loops. BUG=b:64477774 BRANCH=none TEST=make BOARD=pompom Signed-off-by: Boris Mittelberg Change-Id: I3a9197ecd6f66d591b20baf10231db226ad4dad4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4035430 Code-Coverage: Zoss Reviewed-by: Wai-Hong Tam --- board/pompom/board.c | 43 ++++++++++++------------------------------- board/pompom/board.h | 1 + 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/board/pompom/board.c b/board/pompom/board.c index b46e347f88..2f1de29013 100644 --- a/board/pompom/board.c +++ b/board/pompom/board.c @@ -269,8 +269,6 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); void board_hibernate(void) { - int i; - /* * Sensors are unpowered in hibernate. Apply PD to the * interrupt lines such that they don't float. @@ -290,8 +288,7 @@ void board_hibernate(void) * otherwise, ACOK won't go High and can't wake EC up. Check the * bug b/170324206 for details. */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) - ppc_vbus_sink_enable(i, 1); + ppc_vbus_sink_enable(USB_PD_PORT_C0, 1); } __override uint16_t board_get_ps8xxx_product_id(int port) @@ -323,9 +320,9 @@ void board_tcpc_init(void) * Initialize HPD to low; after sysjump SOC needs to see * HPD pulse to enable video path */ - for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) - usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); + usb_mux_hpd_update(USB_PD_PORT_C0, + USB_PD_MUX_HPD_LVL_DEASSERTED | + USB_PD_MUX_HPD_IRQ_DEASSERTED); } DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1); @@ -405,24 +402,20 @@ void board_overcurrent_event(int port, int is_overcurrented) int board_set_active_charge_port(int port) { - int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); - int i; + int is_real_port = (port == USB_PD_PORT_C0); if (!is_real_port && port != CHARGE_PORT_NONE) return EC_ERROR_INVAL; if (port == CHARGE_PORT_NONE) { CPRINTS("Disabling all charging port"); - - /* Disable all ports. */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - /* - * Do not return early if one fails otherwise we can - * get into a boot loop assertion failure. - */ - if (board_vbus_sink_enable(i, 0)) - CPRINTS("Disabling p%d sink path failed.", i); - } + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (board_vbus_sink_enable(USB_PD_PORT_C0, 0)) + CPRINTS("Disabling p%d sink path failed.", + USB_PD_PORT_C0); return EC_SUCCESS; } @@ -435,18 +428,6 @@ int board_set_active_charge_port(int port) CPRINTS("New charge port: p%d", port); - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { - if (i == port) - continue; - - if (board_vbus_sink_enable(i, 0)) - CPRINTS("p%d: sink path disable failed.", i); - } - /* Enable requested charge port. */ if (board_vbus_sink_enable(port, 1)) { CPRINTS("p%d: sink path enable failed.", port); diff --git a/board/pompom/board.h b/board/pompom/board.h index 1282ecdb41..774b339273 100644 --- a/board/pompom/board.h +++ b/board/pompom/board.h @@ -32,6 +32,7 @@ #define CONFIG_USB_PD_TCPM_PS8805 #define CONFIG_USBC_PPC_SN5S330 #define CONFIG_USB_PD_PORT_MAX_COUNT 1 +#define USB_PD_PORT_C0 0 /* USB-A */ #define USB_PORT_COUNT 1 -- cgit v1.2.1 From 1c5c179db16ce361a680f18006b80c1d6e173ec8 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 16 Nov 2022 16:47:46 -0800 Subject: pirika: fix index check Fix port bound check to avoid out-of-bound access BUG=b:64477774 BRANCH=none TEST=make -j buildall Signed-off-by: Boris Mittelberg Change-Id: I3571a42ef38adf3a49395c08344182908e479b43 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032283 Reviewed-by: caveh jalali Code-Coverage: Zoss --- board/pirika/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/pirika/board.c b/board/pirika/board.c index 8913ec0f07..f7c5c0d19b 100644 --- a/board/pirika/board.c +++ b/board/pirika/board.c @@ -590,7 +590,7 @@ __override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { - if (port < 0 || port > board_get_usb_pd_port_count()) + if (!board_is_usb_pd_port_present(port)) return; raa489000_set_output_current(port, rp); -- cgit v1.2.1 From 2d85efd59b7dd76998c7063142d69aa9874bd514 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Wed, 16 Nov 2022 18:44:53 -0700 Subject: tcpm_header: add test for set_vconn failure Create test file and suite "tcpm_header" to house this test. BRANCH=none BUG=none TEST=twister Signed-off-by: Clayton Whitelaw Change-Id: I3abd0cb47eb9d2fdf1196e525001429b7055fecc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031969 Reviewed-by: Yuval Peress Code-Coverage: Zoss Commit-Queue: Yuval Peress Reviewed-by: Aaron Massey --- zephyr/test/drivers/default/CMakeLists.txt | 1 + zephyr/test/drivers/default/src/tcpm_header.c | 71 +++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 zephyr/test/drivers/default/src/tcpm_header.c diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt index d7396ad159..8f1c2ddf84 100644 --- a/zephyr/test/drivers/default/CMakeLists.txt +++ b/zephyr/test/drivers/default/CMakeLists.txt @@ -85,6 +85,7 @@ target_sources(app PRIVATE src/task.c src/tcpci.c src/tcpci_test_common.c + src/tcpm_header.c src/tcs3400.c src/temp_sensor.c src/thermistor.c diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c new file mode 100644 index 0000000000..b4c3ece359 --- /dev/null +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -0,0 +1,71 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "tcpm/tcpci.h" +#include "tcpm/tcpm.h" +#include "test/drivers/stubs.h" +#include "test/drivers/test_state.h" + +#include +#include + +#define TCPM_TEST_PORT USBC_PORT_C0 + +FAKE_VALUE_FUNC(int, set_vconn, int, int); + +struct tcpm_header_fixture { + /* The original driver pointer that gets restored after the tests */ + const struct tcpm_drv *saved_driver_ptr; + /* Mock driver that gets substituted */ + struct tcpm_drv mock_driver; + /* Saved tcpc config flags that get restored after the tests */ + uint32_t saved_tcpc_flags; +}; + +ZTEST_F(tcpm_header, test_tcpm_header_drv_set_vconn_failure) +{ + int res; + + tcpc_config[TCPM_TEST_PORT].flags = TCPC_FLAGS_CONTROL_VCONN; + + fixture->mock_driver.set_vconn = set_vconn; + set_vconn_fake.return_val = -1; + + res = tcpm_set_vconn(TCPM_TEST_PORT, true); + + zassert_true(set_vconn_fake.call_count > 0); + zassert_equal(-1, res); +} + +static void *tcpm_header_setup(void) +{ + static struct tcpm_header_fixture fixture; + + return &fixture; +} + +static void tcpm_header_before(void *state) +{ + struct tcpm_header_fixture *fixture = state; + + RESET_FAKE(set_vconn); + + fixture->mock_driver = (struct tcpm_drv){ 0 }; + fixture->saved_driver_ptr = tcpc_config[TCPM_TEST_PORT].drv; + tcpc_config[TCPM_TEST_PORT].drv = &fixture->mock_driver; + + fixture->saved_tcpc_flags = tcpc_config[TCPM_TEST_PORT].flags; +} + +static void tcpm_header_after(void *state) +{ + struct tcpm_header_fixture *fixture = state; + + tcpc_config[TCPM_TEST_PORT].drv = fixture->saved_driver_ptr; + tcpc_config[TCPM_TEST_PORT].flags = fixture->saved_tcpc_flags; +} + +ZTEST_SUITE(tcpm_header, drivers_predicate_pre_main, tcpm_header_setup, + tcpm_header_before, tcpm_header_after, NULL); -- cgit v1.2.1 From 1feffe0294d2a4378357ad9bab333b3182de4bac Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Fri, 18 Nov 2022 14:26:26 +1100 Subject: nissa: disable DPS for devices with SM5803 Silicon Mitus say the SM5803 is very inefficient in buck-boost mode, which is much more likely to be used when DPS reduces input voltage to closely match VSYS. Disable DPS for devices using this charger. BUG=b:258754576 TEST=Confirmed DPS disabled on yaviks and nereid BRANCH=nissa Signed-off-by: Peter Marheine Change-Id: If30575f88d3a10edebaf3db2037695569e5157d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4037163 Reviewed-by: Andrew McRae Code-Coverage: Zoss --- zephyr/program/nissa/it8xxx2_program.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zephyr/program/nissa/it8xxx2_program.conf b/zephyr/program/nissa/it8xxx2_program.conf index 3272c04209..475f34cf9d 100644 --- a/zephyr/program/nissa/it8xxx2_program.conf +++ b/zephyr/program/nissa/it8xxx2_program.conf @@ -55,6 +55,9 @@ CONFIG_PLATFORM_EC_OCPC=y CONFIG_PLATFORM_EC_CHARGER_SM5803=y CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=21 CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=15000 +# SM5803 is very inefficient in buck-boost operation, so DPS doesn't help and +# might actually contribute to charger failures. +CONFIG_PLATFORM_EC_USB_PD_DPS=n # VSENSE: PP3300_S5 & PP1050_PROC CONFIG_VCMP_IT8XXX2=y -- cgit v1.2.1 From 1a796f1ed1e2cf39363ed5e885b75e3a4342c484 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Mon, 21 Nov 2022 11:53:41 +1100 Subject: nissa: globally disable DPS We expect buck-boost mode on nissa chargers to be less efficient than buck mode, so we want to ensure that DPS doesn't lower input voltage too far. For now disable DPS completely and revisit the configuration later. BUG=b:259859051 TEST=zmake build craask BRANCH=nissa Signed-off-by: Peter Marheine Change-Id: I03c08f2ff9dfa6e9e9074d5a9037244462c2c540 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4041801 Reviewed-by: Andrew McRae Commit-Queue: Andrew McRae Code-Coverage: Zoss --- zephyr/program/nissa/program.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index c70dd547ac..4a3df6b922 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -131,7 +131,8 @@ CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS=200 CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=4 # Dynamically select PD voltage to maximize charger efficiency -CONFIG_PLATFORM_EC_USB_PD_DPS=y +# TODO(b:259859051) re-enable after writing dps_config +CONFIG_PLATFORM_EC_USB_PD_DPS=n # Reduce logging so that state transitions do not cause protocol issues # pd dump [1-3] can be used to increase the debugging level CONFIG_PLATFORM_EC_USB_PD_INITIAL_DEBUG_LEVEL=0 -- cgit v1.2.1 From 7a0b3b08d27b50021ff31372de44a130dc66fdcd Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 18 Nov 2022 15:48:40 -0700 Subject: zephyr: IWYU Add missing headers to board_led.h Include the headers for uint32_t and pwm_flags_t. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ie8fb97161b3c01206047f95a641372dc6fabe85c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4039148 Auto-Submit: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Yuval Peress Commit-Queue: Yuval Peress Tested-by: Jeremy Bettis --- zephyr/shim/include/board_led.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zephyr/shim/include/board_led.h b/zephyr/shim/include/board_led.h index 074ffa0256..ae4b23d74e 100644 --- a/zephyr/shim/include/board_led.h +++ b/zephyr/shim/include/board_led.h @@ -6,6 +6,10 @@ #ifndef __BOARD_LED_H #define __BOARD_LED_H +#include + +#include + struct board_led_pwm_dt_channel { const struct device *dev; uint32_t channel; -- cgit v1.2.1 From a12feef2d3eb943edc340bf3cb098c0a47b38b83 Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Thu, 17 Nov 2022 09:55:26 -0700 Subject: zephyr:tests: Enable PLATFORM_EC_BRINGUP code paths for coverage Create a drivers variant where PLATFORM_EC_BRINGUP is enabled to cover bringup code paths BUG=None BRANCH=NONE TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs Change-Id: I3e487f33c2bb43aa459387efffbd3a3f0a3bafe7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4033899 Code-Coverage: Zoss Reviewed-by: Tomasz Michalec --- zephyr/test/drivers/testcase.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 37fa309836..db341b3048 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -11,6 +11,17 @@ tests: - CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y - CONFIG_PLATFORM_EC_USB_PD_DPS=y + drivers.default.bring_up: + timeout: 240 + extra_args: CONF_FILE="prj.conf;default/prj.conf" + DTC_OVERLAY_FILE="default/boards/native_posix.overlay" + extra_configs: + - CONFIG_LINK_TEST_SUITE_DEFAULT=y + - CONFIG_LINK_TEST_SUITE_USB_MALFUNCTION_SINK=y + - CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y + - CONFIG_PLATFORM_EC_BRINGUP=y + - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y + - CONFIG_PLATFORM_EC_USB_PD_DPS=y drivers.default.mock_power: timeout: 240 extra_args: CONF_FILE="prj.conf;default/prj.conf" -- cgit v1.2.1 From 053debc4602a323a5d2e80f230c84b83718730c4 Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Fri, 18 Nov 2022 16:19:57 -0700 Subject: test: Verify TCPM handles missing DP config ACK Add a test suite and test that verifies the TCPM gracefully handles a partner refusing to allow DP configuration after a DP enter mode command. BRANCH=none BUG=none TEST=twister external/platform/ec/zephyr/test/drivers/drivers.usbc_alt_mode Signed-off-by: Aaron Massey Change-Id: I700d88c10133f23a1ac943b16ae036be1920337b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4039145 Code-Coverage: Zoss Reviewed-by: Yuval Peress --- .../usbc_alt_mode/include/test_usbc_alt_mode.h | 7 ++ .../test/drivers/usbc_alt_mode/src/usbc_alt_mode.c | 110 +++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h b/zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h index 2d494af8cf..ea178fcfaa 100644 --- a/zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h +++ b/zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h @@ -33,4 +33,11 @@ struct usbc_alt_mode_dp_unsupported_fixture { struct tcpci_src_emul_data src_ext; }; +struct usbc_alt_mode_minus_dp_configure_fixture { + const struct emul *tcpci_emul; + const struct emul *charger_emul; + struct tcpci_partner_data partner; + struct tcpci_src_emul_data src_ext; +}; + #endif /* ZEPHYR_TEST_DRIVERS_USBC_ALT_MODE_TEST_USBC_ALT_MODE_H_ */ diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c index 24ee58bd01..c6387aae64 100644 --- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c +++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c @@ -130,6 +130,40 @@ static void add_displayport_mode_responses(struct tcpci_partner_data *partner) partner->dp_config_vdos = VDO_INDEX_HDR + 1; } +static void add_displayport_mode_responses__minus_configure_responses( + struct tcpci_partner_data *partner) +{ + /* + * This is the same function as add_displayport_mode_responses() but + * does not include the configure response so as to induce a failure to + * enter dp alt mode + */ + + /* Add DisplayPort EnterMode response */ + partner->enter_mode_vdm[VDO_INDEX_HDR] = + VDO(USB_SID_DISPLAYPORT, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_ENTER_MODE); + partner->enter_mode_vdos = VDO_INDEX_HDR + 1; + + /* Add DisplayPort StatusUpdate response */ + partner->dp_status_vdm[VDO_INDEX_HDR] = + VDO(USB_SID_DISPLAYPORT, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_DP_STATUS); + partner->dp_status_vdm[VDO_INDEX_HDR + 1] = + /* Mainly copied from hoho */ + VDO_DP_STATUS(0, /* IRQ_HPD */ + false, /* HPD_HI|LOW - Changed*/ + 0, /* request exit DP */ + 0, /* request exit USB */ + 0, /* MF pref */ + true, /* DP Enabled */ + 0, /* power low e.g. normal */ + 0x2 /* Connected as Sink */); + partner->dp_status_vdos = VDO_INDEX_HDR + 2; + + /* NO DisplayPort Configure Response */ +} + static void *usbc_alt_mode_setup(void) { static struct usbc_alt_mode_fixture fixture; @@ -395,3 +429,79 @@ ZTEST_SUITE(usbc_alt_mode_dp_unsupported, drivers_predicate_post_main, usbc_alt_mode_dp_unsupported_setup, usbc_alt_mode_dp_unsupported_before, usbc_alt_mode_dp_unsupported_after, NULL); + +static void *usbc_alt_mode_minus_dp_configure_setup(void) +{ + static struct usbc_alt_mode_minus_dp_configure_fixture fixture; + struct tcpci_partner_data *partner = &fixture.partner; + struct tcpci_src_emul_data *src_ext = &fixture.src_ext; + + tcpci_partner_init(partner, PD_REV20); + partner->extensions = tcpci_src_emul_init(src_ext, partner, NULL); + + /* Get references for the emulators */ + fixture.tcpci_emul = EMUL_GET_USBC_BINDING(TEST_PORT, tcpc); + fixture.charger_emul = EMUL_GET_USBC_BINDING(TEST_PORT, chg); + + add_discovery_responses(partner); + add_displayport_mode_responses__minus_configure_responses(partner); + + return &fixture; +} + +static void usbc_alt_mode_minus_dp_configure_before(void *data) +{ + /* Set chipset to ON, this will set TCPM to DRP */ + test_set_chipset_to_s0(); + + /* TODO(b/214401892): Check why need to give time TCPM to spin */ + k_sleep(K_SECONDS(1)); + + struct usbc_alt_mode_minus_dp_configure_fixture *fixture = data; + + connect_partner_to_port(fixture->tcpci_emul, fixture->charger_emul, + &fixture->partner, &fixture->src_ext); +} + +static void usbc_alt_mode_minus_dp_configure_after(void *data) +{ + struct usbc_alt_mode_fixture *fixture = data; + + disconnect_partner_from_port(fixture->tcpci_emul, + fixture->charger_emul); +} + +ZTEST_F(usbc_alt_mode_minus_dp_configure, test_dp_mode_entry_minus_config) +{ + if (IS_ENABLED(CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY)) { + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_DP); + k_sleep(K_SECONDS(1)); + } + + /* Verify host command when VDOs are present. */ + struct ec_response_typec_status status; + struct ec_params_usb_pd_get_mode_response response; + int response_size; + + host_cmd_usb_pd_get_amode(TEST_PORT, 0, &response, &response_size); + + /* Response should be populated with a DisplayPort VDO */ + zassert_equal(response_size, sizeof(response)); + zassert_equal(response.svid, USB_SID_DISPLAYPORT); + zassert_equal(response.vdo[0], + fixture->partner.modes_vdm[response.opos], NULL); + + /* DPM configures the partner on DP mode entry */ + /* Verify port partner thinks it's *NOT* configured for DisplayPort */ + zassert_false(fixture->partner.displayport_configured); + /* Also verify DP config is missing from mux */ + status = host_cmd_typec_status(TEST_PORT); + zassert_not_equal((status.mux_state & USB_PD_MUX_DP_ENABLED), + USB_PD_MUX_DP_ENABLED, + "Failed to *NOT* see DP set in mux"); +} + +ZTEST_SUITE(usbc_alt_mode_minus_dp_configure, drivers_predicate_post_main, + usbc_alt_mode_minus_dp_configure_setup, + usbc_alt_mode_minus_dp_configure_before, + usbc_alt_mode_minus_dp_configure_after, NULL); -- cgit v1.2.1 From 5f2355b16ee8306a7d520ef6a1855aab78bff5b3 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 18 Nov 2022 11:49:55 -0700 Subject: test: i2c: Add tests for fast plus speed Add tests that set/get the I2C bus speed to fast-plus (1 MHz). BUG=b:236132195 BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I31db7ae0e8493f67d65c7eedb9a3879c8b0355d2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4038784 Reviewed-by: Tomasz Michalec Code-Coverage: Zoss --- zephyr/test/drivers/default/src/i2c.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/zephyr/test/drivers/default/src/i2c.c b/zephyr/test/drivers/default/src/i2c.c index a1fa2451f5..ca27fedbb2 100644 --- a/zephyr/test/drivers/default/src/i2c.c +++ b/zephyr/test/drivers/default/src/i2c.c @@ -52,12 +52,29 @@ ZTEST_USER(i2c, test_i2c_set_speed_success) "response.cmd_response.speed_khz = %d", response.cmd_response.speed_khz); + /* Set the speed to 1000. */ + set_params.cmd_params.speed_khz = 1000; + zassert_ok(host_command_process(&set_args), NULL); + zassert_ok(set_args.result, NULL); + zassert_equal(set_args.response_size, sizeof(response), NULL); + zassert_equal(response.cmd_response.speed_khz, 400, + "response.cmd_response.speed_khz = %d", + response.cmd_response.speed_khz); + + /* Get the speed to verify. */ + zassert_ok(host_command_process(&get_args), NULL); + zassert_ok(get_args.result, NULL); + zassert_equal(get_args.response_size, sizeof(response), NULL); + zassert_equal(response.cmd_response.speed_khz, 1000, + "response.cmd_response.speed_khz = %d", + response.cmd_response.speed_khz); + /* Set the speed back to 100. */ set_params.cmd_params.speed_khz = 100; zassert_ok(host_command_process(&set_args), NULL); zassert_ok(set_args.result, NULL); zassert_equal(set_args.response_size, sizeof(response), NULL); - zassert_equal(response.cmd_response.speed_khz, 400, + zassert_equal(response.cmd_response.speed_khz, 1000, "response.cmd_response.speed_khz = %d", response.cmd_response.speed_khz); } -- cgit v1.2.1 From 44c5d409288bf19f03502f6f7de40b76dfc49023 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 18 Nov 2022 12:36:22 -0700 Subject: test: i2c_passthru: Verify TCPC protect Verify that TCPC port protect allows passthru commands when the system is unlocked and that passthru commands are rejected when the system is locked. BUG=b:236131905 BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I3a30b15f13e5dade5b92c3370dc81877ca14b439 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4038785 Reviewed-by: Simon Glass Code-Coverage: Zoss --- zephyr/test/drivers/default/src/i2c_passthru.c | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/zephyr/test/drivers/default/src/i2c_passthru.c b/zephyr/test/drivers/default/src/i2c_passthru.c index 421d4bb69c..7354678016 100644 --- a/zephyr/test/drivers/default/src/i2c_passthru.c +++ b/zephyr/test/drivers/default/src/i2c_passthru.c @@ -7,6 +7,7 @@ #include "ec_commands.h" #include "host_command.h" #include "i2c.h" +#include "test/drivers/test_mocks.h" #include "test/drivers/test_state.h" #include @@ -107,10 +108,56 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs) }; struct host_cmd_handler_args enable_args = BUILD_HOST_COMMAND_PARAMS( EC_CMD_I2C_PASSTHRU_PROTECT, 0, enable_params); + uint16_t tcpc_addr = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)); + uint8_t *out_data; + uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) + + 2 * sizeof(struct ec_params_i2c_passthru_msg) + 1]; + uint8_t response_buf[sizeof(struct ec_response_i2c_passthru) + 2]; + struct ec_params_i2c_passthru *passthru_params = + (struct ec_params_i2c_passthru *)¶m_buf; + struct ec_response_i2c_passthru *passthru_response = + (struct ec_response_i2c_passthru *)&response_buf; + struct host_cmd_handler_args passthru_args = + BUILD_HOST_COMMAND_SIMPLE(EC_CMD_I2C_PASSTHRU, 0); + + /* If the system is unlocked, TCPC protection is disabled */ + system_is_locked_fake.return_val = false; + + /* Protect the all TCPC buses */ + zassert_ok(host_command_process(&enable_args), NULL); + zassert_ok(enable_args.result, NULL); + + passthru_params->port = I2C_PORT_USB_C0; + passthru_params->num_msgs = 2; + passthru_params->msg[0].addr_flags = tcpc_addr; + passthru_params->msg[0].len = 1; + passthru_params->msg[1].addr_flags = tcpc_addr | EC_I2C_FLAG_READ; + passthru_params->msg[1].len = 2; /* 2 byte vendor ID */ + + /* Write data follows the passthru messages */ + out_data = (uint8_t *)&passthru_params->msg[2]; + out_data[0] = 0; /* TCPC_REG_VENDOR_ID 0x0 */ + + passthru_args.params = ¶m_buf; + passthru_args.params_size = sizeof(param_buf); + passthru_args.response = &response_buf; + passthru_args.response_max = sizeof(response_buf); + + zassert_ok(host_command_process(&passthru_args)); + zassert_ok(passthru_args.result); + zassert_ok(passthru_response->i2c_status); + zassert_equal(passthru_args.response_size, + sizeof(struct ec_response_i2c_passthru) + 2, NULL); + + /* Now attempt TCPC protection while the system is locked */ + system_is_locked_fake.return_val = true; /* Protect the all TCPC buses */ zassert_ok(host_command_process(&enable_args), NULL); zassert_ok(enable_args.result, NULL); + + zassert_equal(host_command_process(&passthru_args), + EC_RES_ACCESS_DENIED); } static void i2c_passthru_after(void *state) -- cgit v1.2.1 From 40170ee693204db9a8245d0874fb834766226755 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 18 Nov 2022 14:28:06 -0700 Subject: test: i2c_passthru: Add tests for failure paths Verify I2C passthru fails for various combinations of invalid parameters. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I208238671fe5e03a6cdb198e0025f774b874e737 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4038786 Code-Coverage: Zoss Tested-by: Fernando Perea Code-Coverage: Fernando Perea Reviewed-by: Fernando Perea Reviewed-by: Jeremy Bettis --- zephyr/test/drivers/default/src/i2c_passthru.c | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/zephyr/test/drivers/default/src/i2c_passthru.c b/zephyr/test/drivers/default/src/i2c_passthru.c index 7354678016..d06e0ffffa 100644 --- a/zephyr/test/drivers/default/src/i2c_passthru.c +++ b/zephyr/test/drivers/default/src/i2c_passthru.c @@ -41,6 +41,55 @@ ZTEST_USER(i2c_passthru, test_read_without_write) sizeof(struct ec_response_i2c_passthru), NULL); } +ZTEST_USER(i2c_passthru, test_passthru_invalid_params) +{ + uint16_t tcpc_addr = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)); + uint8_t *out_data; + uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) + + 2 * sizeof(struct ec_params_i2c_passthru_msg) + 1]; + uint8_t response_buf[sizeof(struct ec_response_i2c_passthru) + 2]; + struct ec_params_i2c_passthru *passthru_params = + (struct ec_params_i2c_passthru *)¶m_buf; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND_SIMPLE(EC_CMD_I2C_PASSTHRU, 0); + + passthru_params->port = I2C_PORT_USB_C0; + passthru_params->num_msgs = 2; + passthru_params->msg[0].addr_flags = tcpc_addr; + passthru_params->msg[0].len = 1; + passthru_params->msg[1].addr_flags = tcpc_addr | EC_I2C_FLAG_READ; + passthru_params->msg[1].len = 2; /* 2 byte vendor ID */ + + /* Write data follows the passthru messages */ + out_data = (uint8_t *)&passthru_params->msg[2]; + out_data[0] = 0; /* TCPC_REG_VENDOR_ID 0x0 */ + + args.params = ¶m_buf; + args.params_size = sizeof(param_buf); + args.response = &response_buf; + args.response_max = sizeof(response_buf); + + /* Set the params_size to smaller than struct ec_params_i2c_passthru */ + args.params_size = 1; + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); + + /* Set the params_size so it truncates the 2nd I2C message */ + args.params_size = sizeof(struct ec_params_i2c_passthru) + + sizeof(struct ec_params_i2c_passthru_msg); + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); + + /* Don't provide enough room for the response */ + args.params_size = sizeof(param_buf); + args.response_max = sizeof(struct ec_response_i2c_passthru) + 1; + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); + + /* Don't provide the write data */ + args.response_max = sizeof(response_buf); + args.params_size = sizeof(struct ec_params_i2c_passthru) + + 2 * sizeof(struct ec_params_i2c_passthru_msg); + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); +} + ZTEST_USER(i2c_passthru, test_passthru_protect) { struct ec_response_i2c_passthru_protect response; -- cgit v1.2.1 From 9e93cddabcdf456c3806f918739f4599596c2ce6 Mon Sep 17 00:00:00 2001 From: Jun Lin Date: Thu, 17 Nov 2022 10:41:17 +0800 Subject: npcx9: fix SHA256 ROM API table address It was found that the hardware SHA256 accelerator is broken. This is caused by the table address of SHA ROM API changed from 0x100 to 0x13C since the ES2 chip. This CL fixed the issues described above. BRANCH=none BUG=b:155771688 TEST=burn the same RW image; #define/#undef CONFIG_SHA256_HW_ACCELERATE; verify the RW hash value is the same in the console message. TEST=with the test CL:2455022, move test patterns in test/sha256.c to board/npcx9_evb/test_sha256.c; pass all test patterns. Signed-off-by: Jun Lin Change-Id: I12ce8531a925f02474f66d90bf7efd950b3eeba3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4033807 Tested-by: Daisuke Nojiri Reviewed-by: caveh jalali Reviewed-by: Daisuke Nojiri Commit-Queue: Boris Mittelberg Tested-by: CH Lin Code-Coverage: Zoss --- chip/npcx/sha256_chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chip/npcx/sha256_chip.c b/chip/npcx/sha256_chip.c index e2590cad65..4d90ba6e74 100644 --- a/chip/npcx/sha256_chip.c +++ b/chip/npcx/sha256_chip.c @@ -32,7 +32,7 @@ enum ncl_sha_type { * The base address of the table that holds the function pointer for each * SHA256 API in ROM. */ -#define NCL_SHA_BASE_ADDR 0x00000100UL +#define NCL_SHA_BASE_ADDR 0x0000013CUL struct ncl_sha { /* Get the SHA context size required by SHA APIs. */ uint32_t (*get_context_size)(void); -- cgit v1.2.1 From cfddbe6bd68f25ea32646cc713c0f51279f46c29 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 16:53:49 +0000 Subject: zephyr: lazor: drop gpio_led.dts This is not referenced anywhere in the BUILD.py file, seems like it's been converted to PWM. Drop it. BRANCH=none BUG=none TEST=cq dry run TEST=zmake build lazor Signed-off-by: Fabio Baltieri Change-Id: Ibcf4c3663043bc31fccaea885f102bf6198d27b7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031192 Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- zephyr/program/trogdor/lazor/gpio_led.dts | 33 ------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 zephyr/program/trogdor/lazor/gpio_led.dts diff --git a/zephyr/program/trogdor/lazor/gpio_led.dts b/zephyr/program/trogdor/lazor/gpio_led.dts deleted file mode 100644 index c8c026506b..0000000000 --- a/zephyr/program/trogdor/lazor/gpio_led.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-led-pins { - compatible = "cros-ec,gpio-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_b_c1 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_b_c1 0>; - }; - - color_blue: color-blue { - led-color = "LED_BLUE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_b_c1 1>; - }; - }; -}; -- cgit v1.2.1 From 87f7a365391dbe2c23e23ff7f06000d9944daa99 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 16:24:42 +0000 Subject: zephyr: led_driver: add separate config for gpio and pwm Add separate automatic config for gpio and pwm variations of the generic devicetree led driver, this control the build and allows dropping the precompiler guards on the source files and move compat in the right files. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I75155d3e020b45e29f88f318c28d4a713196064c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031190 Reviewed-by: Wai-Hong Tam Code-Coverage: Zoss --- zephyr/Kconfig.led_dt | 21 ++++++++++++++++++++- zephyr/shim/src/led_driver/CMakeLists.txt | 4 ++-- zephyr/shim/src/led_driver/led.c | 4 ++-- zephyr/shim/src/led_driver/led.h | 7 ++----- zephyr/shim/src/led_driver/led_gpio.c | 6 ++---- zephyr/shim/src/led_driver/led_pwm.c | 5 ++--- 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/zephyr/Kconfig.led_dt b/zephyr/Kconfig.led_dt index 25993802a3..17a85be737 100644 --- a/zephyr/Kconfig.led_dt +++ b/zephyr/Kconfig.led_dt @@ -3,7 +3,26 @@ # found in the LICENSE file. menuconfig PLATFORM_EC_LED_DT - bool "LED Support" + bool "DT LED Support" help Enable devicetree based LED module supporting automatic control of the battery and power LEDs. + +if PLATFORM_EC_LED_DT + +config PLATFORM_EC_LED_DT_GPIO + bool "DT LED Support (GPIO)" + default y + depends on DT_HAS_CROS_EC_GPIO_LED_PINS_ENABLED + help + Enable support for devicetree GPIO LEDs, requires a node using the + cros-ec,gpio-led-pins compatible. + +config PLATFORM_EC_LED_DT_PWM + bool "DT LED Support (PWM)" + default y + depends on DT_HAS_CROS_EC_PWM_LED_PINS_ENABLED + help + Enable support for devicetree PWM LEDs, requires a node using the + cros-ec,pwm-led-pins compatible. +endif diff --git a/zephyr/shim/src/led_driver/CMakeLists.txt b/zephyr/shim/src/led_driver/CMakeLists.txt index 179f540fe1..7f513ed425 100644 --- a/zephyr/shim/src/led_driver/CMakeLists.txt +++ b/zephyr/shim/src/led_driver/CMakeLists.txt @@ -3,5 +3,5 @@ # found in the LICENSE file. zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led.c) -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led_gpio.c) -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led_pwm.c) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT_GPIO led_gpio.c) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT_PWM led_pwm.c) diff --git a/zephyr/shim/src/led_driver/led.c b/zephyr/shim/src/led_driver/led.c index d673aa4c2e..279e889993 100644 --- a/zephyr/shim/src/led_driver/led.c +++ b/zephyr/shim/src/led_driver/led.c @@ -32,9 +32,9 @@ struct led_color_node_t { #define DECLARE_PINS_NODE(id) extern struct led_pins_node_t PINS_NODE(id); -#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED) +#if CONFIG_PLATFORM_EC_LED_DT_PWM DT_FOREACH_CHILD(PWM_LED_PINS_NODE, DECLARE_PINS_NODE) -#elif DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED) +#elif CONFIG_PLATFORM_EC_LED_DT_GPIO DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, DECLARE_PINS_NODE) #endif diff --git a/zephyr/shim/src/led_driver/led.h b/zephyr/shim/src/led_driver/led.h index b8cedf5af7..43ee672bdc 100644 --- a/zephyr/shim/src/led_driver/led.h +++ b/zephyr/shim/src/led_driver/led.h @@ -10,9 +10,6 @@ #include #include -#define COMPAT_GPIO_LED cros_ec_gpio_led_pins -#define COMPAT_PWM_LED cros_ec_pwm_led_pins - #define PINS_NODE(id) DT_CAT(PIN_NODE_, id) #define PINS_ARRAY(id) DT_CAT(PINS_ARRAY_, id) @@ -85,12 +82,12 @@ struct led_pins_node_t { /* Brightness Range color, only used to support ectool functionality */ enum ec_led_colors br_color; -#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED) +#if CONFIG_PLATFORM_EC_LED_DT_GPIO /* Array of GPIO pins to set to enable particular color */ struct gpio_pin_t *gpio_pins; #endif -#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED) +#if CONFIG_PLATFORM_EC_LED_DT_PWM /* Array of PWM pins to set to enable particular color */ struct pwm_pin_t *pwm_pins; #endif diff --git a/zephyr/shim/src/led_driver/led_gpio.c b/zephyr/shim/src/led_driver/led_gpio.c index 122794dc82..51883eee71 100644 --- a/zephyr/shim/src/led_driver/led_gpio.c +++ b/zephyr/shim/src/led_driver/led_gpio.c @@ -5,6 +5,8 @@ * GPIO LED control. */ +#define DT_DRV_COMPAT cros_ec_gpio_led_pins + #include "ec_commands.h" #include "led.h" #include "util.h" @@ -13,8 +15,6 @@ #include #include -#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED) - LOG_MODULE_REGISTER(gpio_led, LOG_LEVEL_ERR); #define SET_PIN(node_id, prop, i) \ @@ -138,5 +138,3 @@ const struct led_pins_node_t *led_get_node(enum led_color color, return pin_node; } #endif /* TEST_BUILD */ - -#endif /* DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED) */ diff --git a/zephyr/shim/src/led_driver/led_pwm.c b/zephyr/shim/src/led_driver/led_pwm.c index 00002fc32e..cfb0d13fb4 100644 --- a/zephyr/shim/src/led_driver/led_pwm.c +++ b/zephyr/shim/src/led_driver/led_pwm.c @@ -5,6 +5,8 @@ * PWM LED control. */ +#define DT_DRV_COMPAT cros_ec_pwm_led_pins + #include "ec_commands.h" #include "led.h" #include "util.h" @@ -13,8 +15,6 @@ #include #include -#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED) - LOG_MODULE_REGISTER(pwm_led, LOG_LEVEL_ERR); /* @@ -147,4 +147,3 @@ __override int led_is_supported(enum ec_led_id led_id) return ((1 << (int)led_id) & supported_leds); } -#endif /* DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED) */ -- cgit v1.2.1 From 193457f17af848b0c3232967f6af4a019c77908b Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 16:51:21 +0000 Subject: zephyr: config: select PWM automatically Add the missing dependency to the PWM subsystem for the drivers that depends on PWM. This is done using the select Kconfig directive, so that the subsystem gets enabled explicitly as soon as the first of these gets defined in the devicetree. Drop a bunch of now unnecessary CONFIG_PWM=y settings. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I55a78d6324f753fe5fe13a0b81b5e129626621af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031191 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/Kconfig | 1 + zephyr/Kconfig.keyboard | 1 + zephyr/Kconfig.led | 1 + zephyr/Kconfig.led_dt | 1 + zephyr/Kconfig.temperature | 1 + zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig | 3 --- zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig | 3 --- zephyr/program/brya/prj.conf | 3 --- zephyr/program/corsola/ite_program.conf | 3 --- zephyr/program/herobrine/program.conf | 3 --- zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf | 3 --- zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf | 5 +---- zephyr/program/it8xxx2_evb/prj.conf | 3 --- zephyr/program/nissa/program.conf | 1 - zephyr/program/npcx_evb/npcx7/prj.conf | 3 --- zephyr/program/npcx_evb/npcx9/prj.conf | 3 --- zephyr/program/rex/prj.conf | 3 --- zephyr/program/skyrim/prj.conf | 4 +--- 18 files changed, 7 insertions(+), 38 deletions(-) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 9af9f6280e..dcb0de3cf9 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -561,6 +561,7 @@ config PLATFORM_EC_PWM_DISPLIGHT bool "PWM display backlight" default y depends on DT_HAS_CROS_EC_DISPLIGHT_ENABLED + select PWM select PLATFORM_EC_PWM_HC help Enables display backlight controlled by a PWM signal connected diff --git a/zephyr/Kconfig.keyboard b/zephyr/Kconfig.keyboard index 400f295418..c425d7af0d 100644 --- a/zephyr/Kconfig.keyboard +++ b/zephyr/Kconfig.keyboard @@ -217,6 +217,7 @@ config PLATFORM_EC_PWM_KBLIGHT bool "PWM keyboard backlight" default y depends on DT_HAS_CROS_EC_KBLIGHT_PWM_ENABLED + select PWM select PLATFORM_EC_PWM_HC help Enables a PWM-controlled keyboard backlight controlled by a PWM signal diff --git a/zephyr/Kconfig.led b/zephyr/Kconfig.led index 86e423aacd..da00d6ff9c 100644 --- a/zephyr/Kconfig.led +++ b/zephyr/Kconfig.led @@ -21,6 +21,7 @@ config PLATFORM_EC_LED_PWM bool "PWM (Pulse Width Modulation) LEDs" default y depends on DT_HAS_CROS_EC_PWM_LEDS_ENABLED + select PWM help Enable PWM (Pulse Width Modulation) controlled LEDs that conform to the Chromium OS LED behavior specification. diff --git a/zephyr/Kconfig.led_dt b/zephyr/Kconfig.led_dt index 17a85be737..adedfb16b6 100644 --- a/zephyr/Kconfig.led_dt +++ b/zephyr/Kconfig.led_dt @@ -22,6 +22,7 @@ config PLATFORM_EC_LED_DT_PWM bool "DT LED Support (PWM)" default y depends on DT_HAS_CROS_EC_PWM_LED_PINS_ENABLED + select PWM help Enable support for devicetree PWM LEDs, requires a node using the cros-ec,pwm-led-pins compatible. diff --git a/zephyr/Kconfig.temperature b/zephyr/Kconfig.temperature index 9bea40d274..82bac6922f 100644 --- a/zephyr/Kconfig.temperature +++ b/zephyr/Kconfig.temperature @@ -91,6 +91,7 @@ config PLATFORM_EC_FAN bool "Fan support" default y depends on DT_HAS_CROS_EC_FANS_ENABLED + select PWM help Enables support for fans. Allows periodic thermal task to automatically set the fan speed (control temperature). diff --git a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig index 48d91ef0d5..755d982eef 100644 --- a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig @@ -40,9 +40,6 @@ CONFIG_WATCHDOG=y # I2C CONFIG_I2C=y -# PWM -CONFIG_PWM=y - # Power Management CONFIG_PM=y CONFIG_PM_DEVICE=y diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig index 1e0d012b7d..bdedd931c1 100644 --- a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig +++ b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig @@ -37,9 +37,6 @@ CONFIG_CLOCK_CONTROL=y # WATCHDOG configuration CONFIG_WATCHDOG=y -# PWM -CONFIG_PWM=y - # Power Management CONFIG_PM=y CONFIG_PM_DEVICE=y diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index be3bce0a5a..e9d35dc0e2 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -157,9 +157,6 @@ CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR=4 CONFIG_PLATFORM_EC_LED_PWM_SOC_SUSPEND_COLOR=4 CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR=5 -# PWM -CONFIG_PWM=y - # TODO(b/188605676): bring these features up CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n diff --git a/zephyr/program/corsola/ite_program.conf b/zephyr/program/corsola/ite_program.conf index dc0e54a665..55aecebb90 100644 --- a/zephyr/program/corsola/ite_program.conf +++ b/zephyr/program/corsola/ite_program.conf @@ -36,9 +36,6 @@ CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y # LED CONFIG_PLATFORM_EC_LED_DT=y -# PWM -CONFIG_PWM=y - # Sensors CONFIG_PLATFORM_EC_MOTIONSENSE=y CONFIG_PLATFORM_EC_ACCEL_FIFO=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index f4fbb931b2..60b78f6758 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -28,9 +28,6 @@ CONFIG_SHELL_TAB_AUTOCOMPLETION=y CONFIG_PLATFORM_EC_LED_COMMON=n CONFIG_PLATFORM_EC_LED_DT=y -# PWM -CONFIG_PWM=y - # Application Processor is Qualcomm SC7280 CONFIG_AP_ARM_QUALCOMM_SC7280=y diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf index 747fe22a49..d04abada31 100644 --- a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf @@ -9,8 +9,5 @@ CONFIG_SYSCON=y # Charger CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y -# PWM -CONFIG_PWM=y - # RTC CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf index 19befba033..e4b25b48e7 100644 --- a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf @@ -6,8 +6,5 @@ CONFIG_BOARD_MTLRVP_NPCX=y CONFIG_CROS_SYSTEM_NPCX=y CONFIG_SYSCON=y -# PWM -CONFIG_PWM=y - -#RTC +# RTC CONFIG_PLATFORM_EC_RTC=y diff --git a/zephyr/program/it8xxx2_evb/prj.conf b/zephyr/program/it8xxx2_evb/prj.conf index b499ba9086..7a608cb831 100644 --- a/zephyr/program/it8xxx2_evb/prj.conf +++ b/zephyr/program/it8xxx2_evb/prj.conf @@ -16,9 +16,6 @@ CONFIG_PLATFORM_EC_LID_SWITCH=y # Fan CONFIG_SENSOR=y -# PWM -CONFIG_PWM=y - # Power Button CONFIG_PLATFORM_EC_POWER_BUTTON=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 4a3df6b922..05c6c326a5 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -74,7 +74,6 @@ CONFIG_EEPROM=y CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y # PWM support -CONFIG_PWM=y CONFIG_PWM_SHELL=y # Sensors support diff --git a/zephyr/program/npcx_evb/npcx7/prj.conf b/zephyr/program/npcx_evb/npcx7/prj.conf index c485e6a631..f94c5ac2fa 100644 --- a/zephyr/program/npcx_evb/npcx7/prj.conf +++ b/zephyr/program/npcx_evb/npcx7/prj.conf @@ -18,9 +18,6 @@ CONFIG_PLATFORM_EC_VSTORE=n # Board version is selected over GPIO board ID pins. CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y -# PWM -CONFIG_PWM=y - # Sensors CONFIG_SENSOR=y CONFIG_SENSOR_SHELL=n diff --git a/zephyr/program/npcx_evb/npcx9/prj.conf b/zephyr/program/npcx_evb/npcx9/prj.conf index a4b4c90a55..73b263c830 100644 --- a/zephyr/program/npcx_evb/npcx9/prj.conf +++ b/zephyr/program/npcx_evb/npcx9/prj.conf @@ -22,9 +22,6 @@ CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y # Board version is selected over GPIO board ID pins. CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y -# PWM -CONFIG_PWM=y - # Sensors CONFIG_SENSOR=y CONFIG_SENSOR_SHELL=n diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index ee0774d43d..e5900afd54 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -50,9 +50,6 @@ CONFIG_AP_PWRSEQ_S0IX=y # I2C CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y -# PWM -CONFIG_PWM=y - # Temperature sensors CONFIG_SENSOR=y CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 52eb48c095..951926f537 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -58,9 +58,7 @@ CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -# PWM -CONFIG_PWM=y - +# Syscon CONFIG_SYSCON=y # Battery -- cgit v1.2.1 From f8db72bf954cfc85b78cf25dece7e2d5f6a5ca04 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 17 Nov 2022 11:43:27 +0000 Subject: zephyr: leds: move led value in the gpio led binding The current cros-ec,gpio-led-pins binding is leaking values into the named-gpios binding. That's an incorrect way of using the devicetree and only works because named-gpios is not currently using the value cell and because we control the binding. Move the values in a separate property within the cros-ec,gpio-led-pins binding. BRANCH=none BUG=b:242826402 TEST=validated the resulting structure with gdb TEST=zmake build -a; ./twister Signed-off-by: Fabio Baltieri Change-Id: I77a09b25cc69c5faed254da38316104b304c8f5e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031268 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- docs/zephyr/zephyr_leds.md | 16 +++++----- zephyr/dts/bindings/gpio/named-gpios.yaml | 5 ---- .../dts/bindings/leds/cros-ec,gpio-led-pins.yaml | 19 +++++++----- zephyr/program/herobrine/evoker/gpio.dtsi | 4 --- zephyr/program/herobrine/evoker/led_pins.dtsi | 34 +++++++++++++--------- zephyr/program/herobrine/gpio.dtsi | 4 --- zephyr/program/herobrine/herobrine/led_pins.dtsi | 30 +++++++++++-------- zephyr/program/herobrine/hoglin/gpio.dtsi | 2 -- zephyr/program/herobrine/hoglin/led_pins.dtsi | 15 ++++++---- zephyr/program/herobrine/villager/gpio.dtsi | 2 -- zephyr/program/herobrine/villager/led_pins.dtsi | 15 ++++++---- zephyr/program/herobrine/zombie/gpio.dtsi | 2 -- zephyr/program/herobrine/zombie/led_pins.dtsi | 15 ++++++---- zephyr/program/rex/led.dts | 28 ++++-------------- zephyr/program/trogdor/lazor/gpio.dts | 2 -- zephyr/shim/src/led_driver/led_gpio.c | 2 +- zephyr/test/drivers/boards/native_posix.overlay | 4 --- zephyr/test/drivers/led_driver/led_pins.dts | 30 +++++++++++-------- 18 files changed, 110 insertions(+), 119 deletions(-) diff --git a/docs/zephyr/zephyr_leds.md b/docs/zephyr/zephyr_leds.md index bed81933eb..cec7638fba 100644 --- a/docs/zephyr/zephyr_leds.md +++ b/docs/zephyr/zephyr_leds.md @@ -53,23 +53,23 @@ gpio-led-pins { compatible = "cros-ec,gpio-led-pins"; /* Amber - turn on yellow LED */ color_amber: color-amber { - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_b_c1 0>; + led-pins = <&gpio_ec_chg_led_y_c1 &gpio_ec_chg_led_b_c1>; + led-values = <1 0>; }; /* Blue - turn on blue LED */ color_blue: color-blue { - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_b_c1 1>; + led-pins = <&gpio_ec_chg_led_y_c1 &gpio_ec_chg_led_b_c1>; + led-values = <0 1>; }; /* White - turn on both LEDs */ color_white: color-white { - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_b_c1 1>; + led-pins = <&gpio_ec_chg_led_y_c1 &gpio_ec_chg_led_b_c1>; + led-values = <1 1>; }; /* Off - turn off both LEDs */ color_off: color-off { - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_b_c1 0>; + led-pins = <&gpio_ec_chg_led_y_c1 &gpio_ec_chg_led_b_c1>; + led-values = <0 0>; }; }; ``` diff --git a/zephyr/dts/bindings/gpio/named-gpios.yaml b/zephyr/dts/bindings/gpio/named-gpios.yaml index bf0ba7237e..7b92f1a636 100644 --- a/zephyr/dts/bindings/gpio/named-gpios.yaml +++ b/zephyr/dts/bindings/gpio/named-gpios.yaml @@ -15,9 +15,6 @@ child-binding: gpios: type: phandle-array required: false - "#led-pin-cells": - type: int - required: false no-auto-init: description: When set, the GPIO is not initialised, and can be @@ -36,5 +33,3 @@ child-binding: to the particular board's GPIO name. type: string required: false - led-pin-cells: - - value diff --git a/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml b/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml index 2e5fe7cff0..fbf4e5217c 100644 --- a/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml +++ b/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml @@ -15,8 +15,8 @@ child-binding: the LED and 0 always turns off the LED. So a node looks like color-amber { led-color = "LED_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_b_c1 0>; + led-pins = <&gpio_ec_chg_led_y_c1 gpio_ec_chg_led_b_c1>; + led-values = <1 0>; }; properties: led-color: @@ -61,10 +61,15 @@ child-binding: - EC_LED_COLOR_WHITE - EC_LED_COLOR_AMBER led-pins: - type: phandle-array + type: phandles required: true description: | - This property is used to specify an array of gpio pins and - corresponding values to enable a particular color. - e.g. Amber color - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_b_c1 0>; + This property is used to specify an array of gpio pins to set a + particular color. + + led-values: + type: array + required: true + description: | + This property is used to specify an array of values to set on the + corresponding led-pins to set a particular color. diff --git a/zephyr/program/herobrine/evoker/gpio.dtsi b/zephyr/program/herobrine/evoker/gpio.dtsi index 63225917c6..fd4a773369 100644 --- a/zephyr/program/herobrine/evoker/gpio.dtsi +++ b/zephyr/program/herobrine/evoker/gpio.dtsi @@ -165,19 +165,15 @@ enum-name = "GPIO_USB_C1_FRS_EN"; }; gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { - #led-pin-cells = <1>; gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { - #led-pin-cells = <1>; gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { - #led-pin-cells = <1>; gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; }; ap_ec_spi_mosi { diff --git a/zephyr/program/herobrine/evoker/led_pins.dtsi b/zephyr/program/herobrine/evoker/led_pins.dtsi index 7bbbea04d2..8365691f4d 100644 --- a/zephyr/program/herobrine/evoker/led_pins.dtsi +++ b/zephyr/program/herobrine/evoker/led_pins.dtsi @@ -10,49 +10,55 @@ color_power_off: color-power-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&gpio_ec_chg_led_w_c1 0>; + led-pins = <&gpio_ec_chg_led_w_c1>; + led-values = <0>; }; color_power_white: color-power-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_POWER_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_w_c1 1>; + led-pins = <&gpio_ec_chg_led_w_c1>; + led-values = <1>; }; color_battery_off: color-battery-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0 + &gpio_ec_chg_led_r_c0>; + led-values = <0 0 0>; }; color_battery_amber: color-battery-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0 + &gpio_ec_chg_led_r_c0>; + led-values = <1 0 0>; }; color_battery_white: color-battery-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 1>, - <&gpio_ec_chg_led_r_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0 + &gpio_ec_chg_led_r_c0>; + led-values = <0 1 0>; }; color_battery_red: color-battery-red { led-color = "LED_RED"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_RED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>, - <&gpio_ec_chg_led_r_c0 1>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0 + &gpio_ec_chg_led_r_c0>; + led-values = <0 0 1>; }; }; }; diff --git a/zephyr/program/herobrine/gpio.dtsi b/zephyr/program/herobrine/gpio.dtsi index 89aebe365c..60a60ec658 100644 --- a/zephyr/program/herobrine/gpio.dtsi +++ b/zephyr/program/herobrine/gpio.dtsi @@ -175,19 +175,15 @@ enum-name = "GPIO_USB_C1_FRS_EN"; }; gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { - #led-pin-cells = <1>; gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { - #led-pin-cells = <1>; gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { - #led-pin-cells = <1>; gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; }; ap_ec_spi_mosi { diff --git a/zephyr/program/herobrine/herobrine/led_pins.dtsi b/zephyr/program/herobrine/herobrine/led_pins.dtsi index c509ab1a64..23a0271e69 100644 --- a/zephyr/program/herobrine/herobrine/led_pins.dtsi +++ b/zephyr/program/herobrine/herobrine/led_pins.dtsi @@ -10,47 +10,53 @@ color_off_left: color-off-left { led-color = "LED_OFF"; led-id = "EC_LED_ID_LEFT_LED"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_w_c1 0>; + led-pins = <&gpio_ec_chg_led_y_c1 + &gpio_ec_chg_led_w_c1>; + led-values = <0 0>; }; color_off_right: color-off-right { led-color = "LED_OFF"; led-id = "EC_LED_ID_RIGHT_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0>; + led-values = <0 0>; }; color_amber_left: color-amber-left { led-color = "LED_AMBER"; led-id = "EC_LED_ID_LEFT_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_w_c1 0>; + led-pins = <&gpio_ec_chg_led_y_c1 + &gpio_ec_chg_led_w_c1>; + led-values = <1 0>; }; color_amber_right: color-amber-right { led-color = "LED_AMBER"; led-id = "EC_LED_ID_RIGHT_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_w_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0>; + led-values = <1 0>; }; color_white_left: color-white-left { led-color = "LED_WHITE"; led-id = "EC_LED_ID_LEFT_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_w_c1 1>; + led-pins = <&gpio_ec_chg_led_y_c1 + &gpio_ec_chg_led_w_c1>; + led-values = <0 1>; }; color_white_right: color-white-right { led-color = "LED_WHITE"; led-id = "EC_LED_ID_RIGHT_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 1>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0>; + led-values = <0 1>; }; }; }; diff --git a/zephyr/program/herobrine/hoglin/gpio.dtsi b/zephyr/program/herobrine/hoglin/gpio.dtsi index 4be8af5775..c742393ff8 100644 --- a/zephyr/program/herobrine/hoglin/gpio.dtsi +++ b/zephyr/program/herobrine/hoglin/gpio.dtsi @@ -175,11 +175,9 @@ enum-name = "GPIO_USB_C1_FRS_EN"; }; gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 { - #led-pin-cells = <1>; gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_y_c1: ec_chg_led_b_c1 { diff --git a/zephyr/program/herobrine/hoglin/led_pins.dtsi b/zephyr/program/herobrine/hoglin/led_pins.dtsi index 7b125c5cac..b70c385b98 100644 --- a/zephyr/program/herobrine/hoglin/led_pins.dtsi +++ b/zephyr/program/herobrine/hoglin/led_pins.dtsi @@ -10,24 +10,27 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_b_c0 0>, - <&gpio_ec_chg_led_r_c0 0>; + led-pins = <&gpio_ec_chg_led_b_c0 + &gpio_ec_chg_led_r_c0>; + led-values = <0 0>; }; color_blue: color-blue { led-color = "LED_BLUE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_b_c0 1>, - <&gpio_ec_chg_led_r_c0 0>; + led-pins = <&gpio_ec_chg_led_b_c0 + &gpio_ec_chg_led_r_c0>; + led-values = <1 0>; }; color_red: color-red { led-color = "LED_RED"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_RED"; - led-pins = <&gpio_ec_chg_led_b_c0 0>, - <&gpio_ec_chg_led_r_c0 1>; + led-pins = <&gpio_ec_chg_led_b_c0 + &gpio_ec_chg_led_r_c0>; + led-values = <0 1>; }; }; }; diff --git a/zephyr/program/herobrine/villager/gpio.dtsi b/zephyr/program/herobrine/villager/gpio.dtsi index 9ad9df6a0d..9884fc7fb2 100644 --- a/zephyr/program/herobrine/villager/gpio.dtsi +++ b/zephyr/program/herobrine/villager/gpio.dtsi @@ -175,11 +175,9 @@ enum-name = "GPIO_USB_C1_FRS_EN"; }; gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; }; ap_ec_spi_mosi { diff --git a/zephyr/program/herobrine/villager/led_pins.dtsi b/zephyr/program/herobrine/villager/led_pins.dtsi index b0913cdbce..2a74fce58c 100644 --- a/zephyr/program/herobrine/villager/led_pins.dtsi +++ b/zephyr/program/herobrine/villager/led_pins.dtsi @@ -10,24 +10,27 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_b_c0>; + led-values = <0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_b_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_b_c0>; + led-values = <1 0>; }; color_blue: color-blue { led-color = "LED_BLUE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 1>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_b_c0>; + led-values = <0 1>; }; }; }; diff --git a/zephyr/program/herobrine/zombie/gpio.dtsi b/zephyr/program/herobrine/zombie/gpio.dtsi index e154d2a62a..711854fb79 100644 --- a/zephyr/program/herobrine/zombie/gpio.dtsi +++ b/zephyr/program/herobrine/zombie/gpio.dtsi @@ -175,11 +175,9 @@ enum-name = "GPIO_USB_C1_FRS_EN"; }; gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 { - #led-pin-cells = <1>; gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; }; ap_ec_spi_mosi { diff --git a/zephyr/program/herobrine/zombie/led_pins.dtsi b/zephyr/program/herobrine/zombie/led_pins.dtsi index b0913cdbce..2a74fce58c 100644 --- a/zephyr/program/herobrine/zombie/led_pins.dtsi +++ b/zephyr/program/herobrine/zombie/led_pins.dtsi @@ -10,24 +10,27 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_b_c0>; + led-values = <0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_b_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_b_c0>; + led-values = <1 0>; }; color_blue: color-blue { led-color = "LED_BLUE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_b_c0 1>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_b_c0>; + led-values = <0 1>; }; }; }; diff --git a/zephyr/program/rex/led.dts b/zephyr/program/rex/led.dts index 94acb6da5c..fb31eaac43 100644 --- a/zephyr/program/rex/led.dts +++ b/zephyr/program/rex/led.dts @@ -10,24 +10,24 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&gpio_led_1_l 1>, - <&gpio_led_2_l 1>; + led-pins = <&gpio_led_1_l &gpio_led_2_l>; + led-values = <1 1>; }; color_white: color-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_led_1_l 1>, - <&gpio_led_2_l 0>; + led-pins = <&gpio_led_1_l &gpio_led_2_l>; + led-values = <1 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&gpio_led_1_l 0>, - <&gpio_led_2_l 1>; + led-pins = <&gpio_led_1_l &gpio_led_2_l>; + led-values = <0 1>; }; }; @@ -120,19 +120,3 @@ }; }; }; - -&gpio_led_1_l { - #led-pin-cells = <1>; -}; - -&gpio_led_2_l { - #led-pin-cells = <1>; -}; - -&gpio_led_3_l { - #led-pin-cells = <1>; -}; - -&gpio_led_4_l { - #led-pin-cells = <1>; -}; diff --git a/zephyr/program/trogdor/lazor/gpio.dts b/zephyr/program/trogdor/lazor/gpio.dts index c5d982a3cb..d40a593949 100644 --- a/zephyr/program/trogdor/lazor/gpio.dts +++ b/zephyr/program/trogdor/lazor/gpio.dts @@ -188,11 +188,9 @@ gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>; }; gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { - #led-pin-cells = <1>; gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; }; gpio_ec_chg_led_b_c1: ec_chg_led_b_c1 { - #led-pin-cells = <1>; gpios = <&gpioc 4 GPIO_OUTPUT_LOW>; }; gpio_brd_id0: brd_id0 { diff --git a/zephyr/shim/src/led_driver/led_gpio.c b/zephyr/shim/src/led_driver/led_gpio.c index 51883eee71..9ca429e3d1 100644 --- a/zephyr/shim/src/led_driver/led_gpio.c +++ b/zephyr/shim/src/led_driver/led_gpio.c @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(gpio_led, LOG_LEVEL_ERR); #define SET_PIN(node_id, prop, i) \ { .signal = GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, i)), \ - .val = DT_PHA_BY_IDX(node_id, prop, i, value) }, + .val = DT_PROP_BY_IDX(node_id, led_values, i) }, #define SET_GPIO_PIN(node_id) \ { DT_FOREACH_PROP_ELEM(node_id, led_pins, SET_PIN) }; diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index c47c63494d..b077cd984c 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -231,20 +231,16 @@ no-auto-init; }; gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 { - #led-pin-cells = <1>; gpios = <&gpio0 30 (GPIO_INPUT | GPIO_OUTPUT_LOW)>; }; gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 { - #led-pin-cells = <1>; gpios = <&gpio0 31 (GPIO_INPUT | GPIO_OUTPUT_LOW)>; }; /* gpio1 */ gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 { - #led-pin-cells = <1>; gpios = <&gpio1 0 (GPIO_INPUT | GPIO_OUTPUT_LOW)>; }; gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 { - #led-pin-cells = <1>; gpios = <&gpio1 1 (GPIO_INPUT | GPIO_OUTPUT_LOW)>; }; gpio_ap_ec_int_l: ap_ec_int_l { diff --git a/zephyr/test/drivers/led_driver/led_pins.dts b/zephyr/test/drivers/led_driver/led_pins.dts index 7c14a48166..cf57102a3c 100644 --- a/zephyr/test/drivers/led_driver/led_pins.dts +++ b/zephyr/test/drivers/led_driver/led_pins.dts @@ -17,42 +17,48 @@ color_off_left: color-off-left { led-color = "LED_OFF"; led-id = "EC_LED_ID_SYSRQ_DEBUG_LED"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_w_c1 0>; + led-pins = <&gpio_ec_chg_led_y_c1 + &gpio_ec_chg_led_w_c1>; + led-values = <0 0>; }; color_off_right: color-off-right { led-color = "LED_OFF"; led-id = "EC_LED_ID_RIGHT_LED"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0>; + led-values = <0 0>; }; color_blue_left: color-blue-left { led-color = "LED_BLUE"; led-id = "EC_LED_ID_SYSRQ_DEBUG_LED"; br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c1 1>, - <&gpio_ec_chg_led_w_c1 0>; + led-pins = <&gpio_ec_chg_led_y_c1 + &gpio_ec_chg_led_w_c1>; + led-values = <1 0>; }; color_blue_right: color-blue-right { led-color = "LED_BLUE"; led-id = "EC_LED_ID_RIGHT_LED"; br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&gpio_ec_chg_led_y_c0 1>, - <&gpio_ec_chg_led_w_c0 0>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0>; + led-values = <1 0>; }; color_white_left: color-white-left { led-color = "LED_WHITE"; led-id = "EC_LED_ID_SYSRQ_DEBUG_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c1 0>, - <&gpio_ec_chg_led_w_c1 1>; + led-pins = <&gpio_ec_chg_led_y_c1 + &gpio_ec_chg_led_w_c1>; + led-values = <0 1>; }; color_white_right: color-white-right { led-color = "LED_WHITE"; led-id = "EC_LED_ID_RIGHT_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&gpio_ec_chg_led_y_c0 0>, - <&gpio_ec_chg_led_w_c0 1>; + led-pins = <&gpio_ec_chg_led_y_c0 + &gpio_ec_chg_led_w_c0>; + led-values = <0 1>; }; }; }; -- cgit v1.2.1 From b194182b97f42295bfe8b6f422b59d13a3d9c378 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Mon, 21 Nov 2022 17:41:57 +0000 Subject: keyboard_backlight: drop the get() function struct kblight_drv defines a get() function to access the current brightness level from the hardware, but nothing uses it in the code. The higher level kblight_get() uses a cached value. Drop the method, save some flash. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I822b0bf2c44ba4298cf4365504797f280aaab946 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043981 Code-Coverage: Zoss Reviewed-by: Daisuke Nojiri --- common/pwm_kblight.c | 6 ------ common/rgb_keyboard.c | 1 - driver/ioexpander/it8801.c | 6 ------ driver/led/lm3509.c | 11 ----------- include/keyboard_backlight.h | 6 ------ zephyr/drivers/cros_kblight/pwm_kblight.c | 6 ------ 6 files changed, 36 deletions(-) diff --git a/common/pwm_kblight.c b/common/pwm_kblight.c index 5748bef700..bd7e07644d 100644 --- a/common/pwm_kblight.c +++ b/common/pwm_kblight.c @@ -19,11 +19,6 @@ static int kblight_pwm_set(int percent) return EC_SUCCESS; } -static int kblight_pwm_get(void) -{ - return pwm_get_duty(kblight_pwm_ch); -} - static int kblight_pwm_init(void) { /* dnojiri: Why do we need save/restore setting over sysjump? */ @@ -46,7 +41,6 @@ static int kblight_pwm_get_enabled(void) const struct kblight_drv kblight_pwm = { .init = kblight_pwm_init, .set = kblight_pwm_set, - .get = kblight_pwm_get, .enable = kblight_pwm_enable, .get_enabled = kblight_pwm_get_enabled, }; diff --git a/common/rgb_keyboard.c b/common/rgb_keyboard.c index 5f130ee776..c0d4dd7f3c 100644 --- a/common/rgb_keyboard.c +++ b/common/rgb_keyboard.c @@ -476,7 +476,6 @@ static void rgbkbd_reset(void) const struct kblight_drv kblight_rgbkbd = { .init = rgbkbd_init, .set = rgbkbd_kblight_set, - .get = NULL, .enable = rgbkbd_enable, .get_enabled = rgbkbd_get_enabled, }; diff --git a/driver/ioexpander/it8801.c b/driver/ioexpander/it8801.c index 256b4c9654..f484e33284 100644 --- a/driver/ioexpander/it8801.c +++ b/driver/ioexpander/it8801.c @@ -685,11 +685,6 @@ static int it8801_kblight_set_brightness(int percent) return EC_SUCCESS; } -static int it8801_kblight_get_brightness(void) -{ - return it8801_pwm_get_duty(it8801_kblight_pwm_ch); -} - static int it8801_kblight_init(void) { it8801_pwm_set_duty(it8801_kblight_pwm_ch, 0); @@ -700,7 +695,6 @@ static int it8801_kblight_init(void) const struct kblight_drv kblight_it8801 = { .init = it8801_kblight_init, .set = it8801_kblight_set_brightness, - .get = it8801_kblight_get_brightness, .enable = it8801_kblight_enable, .get_enabled = it8801_kblight_get_enabled, }; diff --git a/driver/led/lm3509.c b/driver/led/lm3509.c index 5df604bac6..81dd940c4f 100644 --- a/driver/led/lm3509.c +++ b/driver/led/lm3509.c @@ -70,16 +70,6 @@ static int lm3509_set_brightness(int percent) return lm3509_write(LM3509_REG_BMAIN, brightness_to_bmain(percent)); } -static int lm3509_get_brightness(void) -{ - int rv, val; - rv = lm3509_read(LM3509_REG_BMAIN, &val); - if (rv) - return -1; - val &= LM3509_BMAIN_MASK; - return lm3509_brightness[val] / 10; -} - static int lm3509_init(void) { return EC_SUCCESS; @@ -88,7 +78,6 @@ static int lm3509_init(void) const struct kblight_drv kblight_lm3509 = { .init = lm3509_init, .set = lm3509_set_brightness, - .get = lm3509_get_brightness, .enable = lm3509_power, .get_enabled = lm3509_get_power, }; diff --git a/include/keyboard_backlight.h b/include/keyboard_backlight.h index cf68805235..929dbfa90e 100644 --- a/include/keyboard_backlight.h +++ b/include/keyboard_backlight.h @@ -31,12 +31,6 @@ struct kblight_drv { */ int (*set)(int percent); - /** - * Get the current brightness - * @return Brightness in percentage - */ - int (*get)(void); - /** * Enable or disable keyboard backlight * @param enable: 1=Enable, 0=Disable. diff --git a/zephyr/drivers/cros_kblight/pwm_kblight.c b/zephyr/drivers/cros_kblight/pwm_kblight.c index ea6004412e..cc4af1d757 100644 --- a/zephyr/drivers/cros_kblight/pwm_kblight.c +++ b/zephyr/drivers/cros_kblight/pwm_kblight.c @@ -56,11 +56,6 @@ static int kblight_pwm_set(int percent) return EC_SUCCESS; } -static int kblight_pwm_get(void) -{ - return kblight_percent; -} - static int kblight_pwm_enable(int enable) { kblight_enabled = enable; @@ -88,7 +83,6 @@ static int kblight_pwm_init(void) const struct kblight_drv kblight_pwm = { .init = kblight_pwm_init, .set = kblight_pwm_set, - .get = kblight_pwm_get, .enable = kblight_pwm_enable, .get_enabled = kblight_pwm_get_enabled, }; -- cgit v1.2.1 From a12a53e040d83d49cfd4e08ee75d7684b355e8f0 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 10:08:28 -0700 Subject: zephyr: IWYU Include header for PWR_SIGNAL_ENUM PWR_SIGNAL_ENUM is defined in power_signals.h, so add include for that header. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I426432b253d41516fe5158198fb7763f9b64d7dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043351 Tested-by: Fernando Perea Auto-Submit: Jeremy Bettis Reviewed-by: Fernando Perea Commit-Queue: Jeremy Bettis Code-Coverage: Zoss Tested-by: Jeremy Bettis Reviewed-by: Tristan Honscheid Code-Coverage: Fernando Perea --- zephyr/subsys/ap_pwrseq/include/signal_adc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zephyr/subsys/ap_pwrseq/include/signal_adc.h b/zephyr/subsys/ap_pwrseq/include/signal_adc.h index 81c6a1edd4..dea6d315d8 100644 --- a/zephyr/subsys/ap_pwrseq/include/signal_adc.h +++ b/zephyr/subsys/ap_pwrseq/include/signal_adc.h @@ -6,6 +6,8 @@ #ifndef __AP_PWRSEQ_SIGNAL_ADC_H__ #define __AP_PWRSEQ_SIGNAL_ADC_H__ +#include + #define PWR_SIG_TAG_ADC PWR_ADC_ /* -- cgit v1.2.1 From e9f7e3195708b5970e05b94da9132ac829d0047f Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 14 Nov 2022 14:02:02 -0700 Subject: zephyr/emul: Sort header files Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I6d9671149004496a12937a4176e177e12b29dd68 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024016 Auto-Submit: Jeremy Bettis Commit-Queue: Jeremy Bettis Code-Coverage: Zoss Tested-by: Jeremy Bettis Reviewed-by: Abe Levkoy --- zephyr/emul/emul_bb_retimer.c | 17 ++++++++-------- zephyr/emul/emul_bma255.c | 17 ++++++++-------- zephyr/emul/emul_bmi.c | 21 ++++++++++---------- zephyr/emul/emul_bmi160.c | 15 +++++++------- zephyr/emul/emul_bmi260.c | 15 +++++++------- zephyr/emul/emul_clock_control.c | 8 ++++---- zephyr/emul/emul_common_i2c.c | 8 ++++---- zephyr/emul/emul_flash.c | 16 +++++++-------- zephyr/emul/emul_isl923x.c | 23 +++++++++++----------- zephyr/emul/emul_kb_raw.c | 11 ++++++----- zephyr/emul/emul_lis2dw12.c | 19 +++++++++--------- zephyr/emul/emul_ln9310.c | 17 ++++++++-------- zephyr/emul/emul_pct2075.c | 6 +++--- zephyr/emul/emul_pi3usb9201.c | 10 +++++----- zephyr/emul/emul_rt9490.c | 4 ++-- zephyr/emul/emul_rtc.c | 14 ++++++------- zephyr/emul/emul_smart_battery.c | 19 +++++++++--------- zephyr/emul/emul_sn5s330.c | 25 ++++++++++++------------ zephyr/emul/emul_syv682x.c | 19 +++++++++--------- zephyr/emul/emul_tcs3400.c | 17 ++++++++-------- zephyr/emul/emul_tusb1064.c | 4 ++-- zephyr/emul/i2c_mock.c | 6 +++--- zephyr/emul/pwm_mock.c | 6 +++--- zephyr/emul/tcpc/emul_anx7447.c | 11 +++++------ zephyr/emul/tcpc/emul_ps8xxx.c | 16 +++++++-------- zephyr/emul/tcpc/emul_tcpci.c | 11 +++++------ zephyr/emul/tcpc/emul_tcpci_generic.c | 11 +++++------ zephyr/emul/tcpc/emul_tcpci_partner_common.c | 13 ++++++------ zephyr/emul/tcpc/emul_tcpci_partner_drp.c | 6 +++--- zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c | 6 +++--- zephyr/emul/tcpc/emul_tcpci_partner_snk.c | 6 +++--- zephyr/emul/tcpc/emul_tcpci_partner_src.c | 8 ++++---- 32 files changed, 200 insertions(+), 205 deletions(-) diff --git a/zephyr/emul/emul_bb_retimer.c b/zephyr/emul/emul_bb_retimer.c index 0536f19de6..8028c53c0f 100644 --- a/zephyr/emul/emul_bb_retimer.c +++ b/zephyr/emul/emul_bb_retimer.c @@ -3,22 +3,21 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT intel_jhl8040r - -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL -#include -LOG_MODULE_REGISTER(emul_bb_retimer); +#include "driver/retimer/bb_retimer.h" +#include "emul/emul_bb_retimer.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" #include #include #include #include +#include -#include "emul/emul_common_i2c.h" -#include "emul/emul_bb_retimer.h" -#include "emul/emul_stub_device.h" +#define DT_DRV_COMPAT intel_jhl8040r -#include "driver/retimer/bb_retimer.h" +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(emul_bb_retimer); /** Run-time data used by the emulator */ struct bb_emul_data { diff --git a/zephyr/emul/emul_bma255.c b/zephyr/emul/emul_bma255.c index a57c8fbdbb..c563937561 100644 --- a/zephyr/emul/emul_bma255.c +++ b/zephyr/emul/emul_bma255.c @@ -3,22 +3,21 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT zephyr_bma255 - -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL -#include -LOG_MODULE_REGISTER(emul_bma255); +#include "driver/accel_bma2x2.h" +#include "emul/emul_bma255.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" #include #include #include #include +#include -#include "emul/emul_common_i2c.h" -#include "emul/emul_bma255.h" +#define DT_DRV_COMPAT zephyr_bma255 -#include "driver/accel_bma2x2.h" -#include "emul/emul_stub_device.h" +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(emul_bma255); /** Run-time data used by the emulator */ struct bma_emul_data { diff --git a/zephyr/emul/emul_bmi.c b/zephyr/emul/emul_bmi.c index fe46428f01..99a06ec00c 100644 --- a/zephyr/emul/emul_bmi.c +++ b/zephyr/emul/emul_bmi.c @@ -3,25 +3,24 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT zephyr_bmi - -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL -#include -LOG_MODULE_REGISTER(emul_bmi); +#include "driver/accelgyro_bmi160.h" +#include "driver/accelgyro_bmi260.h" +#include "driver/accelgyro_bmi_common.h" +#include "emul/emul_bmi.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" #include #include #include #include +#include #include -#include "emul/emul_common_i2c.h" -#include "emul/emul_bmi.h" -#include "emul/emul_stub_device.h" +#define DT_DRV_COMPAT zephyr_bmi -#include "driver/accelgyro_bmi160.h" -#include "driver/accelgyro_bmi260.h" -#include "driver/accelgyro_bmi_common.h" +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(emul_bmi); /** Run-time data used by the emulator */ struct bmi_emul_data { diff --git a/zephyr/emul/emul_bmi160.c b/zephyr/emul/emul_bmi160.c index c1d6b58a8f..1b1991a24d 100644 --- a/zephyr/emul/emul_bmi160.c +++ b/zephyr/emul/emul_bmi160.c @@ -3,21 +3,20 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT zephyr_bmi - -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL -#include -LOG_MODULE_REGISTER(emul_bmi160); +#include "driver/accelgyro_bmi160.h" +#include "driver/accelgyro_bmi_common.h" +#include "emul/emul_bmi.h" #include #include #include #include +#include -#include "emul/emul_bmi.h" +#define DT_DRV_COMPAT zephyr_bmi -#include "driver/accelgyro_bmi160.h" -#include "driver/accelgyro_bmi_common.h" +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(emul_bmi160); /** Mask reserved bits in each register of BMI160 */ static const uint8_t bmi_emul_160_rsvd_mask[] = { diff --git a/zephyr/emul/emul_bmi260.c b/zephyr/emul/emul_bmi260.c index 5892a9ae96..2c93e1c2ea 100644 --- a/zephyr/emul/emul_bmi260.c +++ b/zephyr/emul/emul_bmi260.c @@ -3,21 +3,20 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT zephyr_bmi - -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL -#include -LOG_MODULE_REGISTER(emul_bmi260); +#include "driver/accelgyro_bmi260.h" +#include "driver/accelgyro_bmi_common.h" +#include "emul/emul_bmi.h" #include #include #include #include +#include -#include "emul/emul_bmi.h" +#define DT_DRV_COMPAT zephyr_bmi -#include "driver/accelgyro_bmi260.h" -#include "driver/accelgyro_bmi_common.h" +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(emul_bmi260); /** Mask reserved bits in each register of BMI260 */ static const uint8_t bmi_emul_260_rsvd_mask[] = { diff --git a/zephyr/emul/emul_clock_control.c b/zephyr/emul/emul_clock_control.c index 561298a705..e4223a5b43 100644 --- a/zephyr/emul/emul_clock_control.c +++ b/zephyr/emul/emul_clock_control.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_clock_control_emul +#include "common.h" +#include "emul/emul_clock_control.h" #include #include #include +#include -#include "common.h" -#include "emul/emul_clock_control.h" +#define DT_DRV_COMPAT cros_clock_control_emul -#include LOG_MODULE_REGISTER(clock_control_emul, CONFIG_CLOCK_CONTROL_EMUL_LOG_LEVEL); /** Data needed to maintain the current emulator state */ diff --git a/zephyr/emul/emul_common_i2c.c b/zephyr/emul/emul_common_i2c.c index 70bc962c5f..3af150ddfc 100644 --- a/zephyr/emul/emul_common_i2c.c +++ b/zephyr/emul/emul_common_i2c.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL -#include -LOG_MODULE_REGISTER(emul_common_i2c); +#include "emul/emul_common_i2c.h" #include #include #include #include +#include -#include "emul/emul_common_i2c.h" +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(emul_common_i2c); /** Check description in emul_common_i2c.h */ int i2c_common_emul_lock_data(struct i2c_common_emul_data *common_data, diff --git a/zephyr/emul/emul_flash.c b/zephyr/emul/emul_flash.c index 0efc690fd4..936ee5470c 100644 --- a/zephyr/emul/emul_flash.c +++ b/zephyr/emul/emul_flash.c @@ -3,19 +3,19 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_ec_flash_emul - -#include -#include -LOG_MODULE_REGISTER(emul_flash); +#include "drivers/cros_flash.h" +#include "ec_commands.h" +#include "flash.h" #include #include -#include -#include +#include +#include #include -#include "flash.h" +#define DT_DRV_COMPAT cros_ec_flash_emul + +LOG_MODULE_REGISTER(emul_flash); struct flash_emul_data { const struct device *flash_dev; diff --git a/zephyr/emul/emul_isl923x.c b/zephyr/emul/emul_isl923x.c index 1ecb9e79f9..d46f1131d4 100644 --- a/zephyr/emul/emul_isl923x.c +++ b/zephyr/emul/emul_isl923x.c @@ -3,25 +3,26 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_isl923x_emul - -#include -#include -#include -#include -#include -#include -#include - #include "driver/charger/isl923x.h" #include "driver/charger/isl923x_public.h" #include "emul/emul_common_i2c.h" #include "emul/emul_isl923x.h" #include "emul/emul_smart_battery.h" -#include "i2c.h" #include "emul/emul_stub_device.h" +#include "i2c.h" +#include + +#include +#include +#include +#include #include +#include +#include + +#define DT_DRV_COMPAT cros_isl923x_emul + LOG_MODULE_REGISTER(isl923x_emul, CONFIG_ISL923X_EMUL_LOG_LEVEL); /** Mask used for the charge current register */ diff --git a/zephyr/emul/emul_kb_raw.c b/zephyr/emul/emul_kb_raw.c index 1fdd93d1a0..2e8cdbdd7d 100644 --- a/zephyr/emul/emul_kb_raw.c +++ b/zephyr/emul/emul_kb_raw.c @@ -3,16 +3,17 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_ec_kb_raw_emul - -#include -LOG_MODULE_REGISTER(emul_kb_raw); - #include #include +#include + #include #include +#define DT_DRV_COMPAT cros_ec_kb_raw_emul + +LOG_MODULE_REGISTER(emul_kb_raw); + struct kb_raw_emul_data { int active_column; int *matrix; diff --git a/zephyr/emul/emul_lis2dw12.c b/zephyr/emul/emul_lis2dw12.c index bdc4b50358..547e74912c 100644 --- a/zephyr/emul/emul_lis2dw12.c +++ b/zephyr/emul/emul_lis2dw12.c @@ -3,22 +3,23 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_lis2dw12_emul +#include "driver/accel_lis2dw12.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_lis2dw12.h" +#include "emul/emul_stub_device.h" +#include "i2c.h" + +#include #include +#include #include #include -#include -#include +#include #include -#include "driver/accel_lis2dw12.h" -#include "emul/emul_common_i2c.h" -#include "emul/emul_lis2dw12.h" -#include "i2c.h" -#include "emul/emul_stub_device.h" +#define DT_DRV_COMPAT cros_lis2dw12_emul -#include LOG_MODULE_REGISTER(lis2dw12_emul, CONFIG_LIS2DW12_EMUL_LOG_LEVEL); struct lis2dw12_emul_data { diff --git a/zephyr/emul/emul_ln9310.c b/zephyr/emul/emul_ln9310.c index bd6d41bce3..9d6a0197a0 100644 --- a/zephyr/emul/emul_ln9310.c +++ b/zephyr/emul/emul_ln9310.c @@ -3,9 +3,15 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_ln9310_emul +#include "driver/ln9310.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_ln9310.h" +#include "emul/emul_stub_device.h" +#include "hooks.h" +#include "i2c.h" #include + #include #include #include @@ -13,16 +19,11 @@ #include #include #include +#include #include -#include "driver/ln9310.h" -#include "emul/emul_common_i2c.h" -#include "emul/emul_ln9310.h" -#include "hooks.h" -#include "i2c.h" -#include "emul/emul_stub_device.h" +#define DT_DRV_COMPAT cros_ln9310_emul -#include LOG_MODULE_REGISTER(ln9310_emul, CONFIG_LN9310_EMUL_LOG_LEVEL); enum functional_mode { diff --git a/zephyr/emul/emul_pct2075.c b/zephyr/emul/emul_pct2075.c index f820fbd30a..cfd172b6dc 100644 --- a/zephyr/emul/emul_pct2075.c +++ b/zephyr/emul/emul_pct2075.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "driver/temp_sensor/pct2075.h" #include "emul/emul_common_i2c.h" -#include "emul/emul_stub_device.h" #include "emul/emul_pct2075.h" +#include "emul/emul_stub_device.h" #include "util.h" +#include + /* NOTE: The emulator doesn't support OS pin */ #define DT_DRV_COMPAT nxp_pct2075 diff --git a/zephyr/emul/emul_pi3usb9201.c b/zephyr/emul/emul_pi3usb9201.c index 8073313d69..a722fc3039 100644 --- a/zephyr/emul/emul_pi3usb9201.c +++ b/zephyr/emul/emul_pi3usb9201.c @@ -3,18 +3,18 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT pericom_pi3usb9201 +#include "emul/emul_common_i2c.h" +#include "emul/emul_pi3usb9201.h" +#include "emul/emul_stub_device.h" #include #include #include #include +#include -#include "emul/emul_pi3usb9201.h" -#include "emul/emul_stub_device.h" -#include "emul/emul_common_i2c.h" +#define DT_DRV_COMPAT pericom_pi3usb9201 -#include LOG_MODULE_REGISTER(emul_pi3usb9201, LOG_LEVEL_DBG); #define EMUL_REG_COUNT (PI3USB9201_REG_HOST_STS + 1) diff --git a/zephyr/emul/emul_rt9490.c b/zephyr/emul/emul_rt9490.c index bc156b7085..1775bc9235 100644 --- a/zephyr/emul/emul_rt9490.c +++ b/zephyr/emul/emul_rt9490.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "driver/charger/rt9490.h" #include "emul/emul_common_i2c.h" #include "emul/emul_rt9490.h" #include "emul/emul_stub_device.h" #include "util.h" +#include + #define DT_DRV_COMPAT zephyr_rt9490_emul #define RT9490_REG_MAX 255 diff --git a/zephyr/emul/emul_rtc.c b/zephyr/emul/emul_rtc.c index 0bd2ef0828..845f0e8d78 100644 --- a/zephyr/emul/emul_rtc.c +++ b/zephyr/emul/emul_rtc.c @@ -5,18 +5,18 @@ /* This is not a chip emulator, it's a fake driver. */ -#define DT_DRV_COMPAT cros_ec_rtc_emul - -#include -LOG_MODULE_REGISTER(emul_rtc); +#include "drivers/cros_rtc.h" +#include "ec_commands.h" +#include "flash.h" #include #include -#include -#include +#include #include -#include "flash.h" +#define DT_DRV_COMPAT cros_ec_rtc_emul + +LOG_MODULE_REGISTER(emul_rtc); struct cros_rtc_emul_data { const struct device *rtc_dev; diff --git a/zephyr/emul/emul_smart_battery.c b/zephyr/emul/emul_smart_battery.c index c064f093bf..7ad4ba41bc 100644 --- a/zephyr/emul/emul_smart_battery.c +++ b/zephyr/emul/emul_smart_battery.c @@ -3,24 +3,23 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT zephyr_smart_battery - -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL -#include -LOG_MODULE_REGISTER(smart_battery); +#include "battery_smart.h" +#include "crc8.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_smart_battery.h" +#include "emul/emul_stub_device.h" #include #include #include #include +#include #include -#include "emul/emul_common_i2c.h" -#include "emul/emul_smart_battery.h" +#define DT_DRV_COMPAT zephyr_smart_battery -#include "crc8.h" -#include "battery_smart.h" -#include "emul/emul_stub_device.h" +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(smart_battery); /** Run-time data used by the emulator */ struct sbat_emul_data { diff --git a/zephyr/emul/emul_sn5s330.c b/zephyr/emul/emul_sn5s330.c index 6a520ed195..96342abf70 100644 --- a/zephyr/emul/emul_sn5s330.c +++ b/zephyr/emul/emul_sn5s330.c @@ -3,25 +3,26 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_sn5s330_emul - -#include -#include -#include -#include -#include -#include -#include -#include - #include "driver/ppc/sn5s330.h" #include "driver/ppc/sn5s330_public.h" #include "emul/emul_common_i2c.h" #include "emul/emul_sn5s330.h" -#include "i2c.h" #include "emul/emul_stub_device.h" +#include "i2c.h" +#include + +#include +#include +#include +#include +#include +#include #include +#include + +#define DT_DRV_COMPAT cros_sn5s330_emul + LOG_MODULE_REGISTER(sn5s330_emul, CONFIG_SN5S330_EMUL_LOG_LEVEL); struct sn5s330_emul_data { diff --git a/zephyr/emul/emul_syv682x.c b/zephyr/emul/emul_syv682x.c index 8fb4bfc928..68c1a84e15 100644 --- a/zephyr/emul/emul_syv682x.c +++ b/zephyr/emul/emul_syv682x.c @@ -3,25 +3,26 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT zephyr_syv682x_emul +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" +#include "emul/emul_syv682x.h" + +#include +#include #include #include -#include #include +#include #include #include -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL #include -LOG_MODULE_REGISTER(syv682x); -#include -#include #include -#include "emul/emul_common_i2c.h" -#include "emul/emul_syv682x.h" -#include "emul/emul_stub_device.h" +#define DT_DRV_COMPAT zephyr_syv682x_emul +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(syv682x); #define EMUL_REG_COUNT (SYV682X_CONTROL_4_REG + 1) #define EMUL_REG_IS_VALID(reg) (reg >= 0 && reg < EMUL_REG_COUNT) diff --git a/zephyr/emul/emul_tcs3400.c b/zephyr/emul/emul_tcs3400.c index e87deebc35..a9cbc2a1dc 100644 --- a/zephyr/emul/emul_tcs3400.c +++ b/zephyr/emul/emul_tcs3400.c @@ -3,23 +3,22 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT zephyr_tcs3400 - -#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL -#include -LOG_MODULE_REGISTER(emul_tcs); +#include "driver/als_tcs3400.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" +#include "emul/emul_tcs3400.h" #include #include #include #include +#include #include -#include "emul/emul_common_i2c.h" -#include "emul/emul_tcs3400.h" -#include "emul/emul_stub_device.h" +#define DT_DRV_COMPAT zephyr_tcs3400 -#include "driver/als_tcs3400.h" +#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL +LOG_MODULE_REGISTER(emul_tcs); /** Run-time data used by the emulator */ struct tcs_emul_data { diff --git a/zephyr/emul/emul_tusb1064.c b/zephyr/emul/emul_tusb1064.c index 4396cc5fc5..866493bc32 100644 --- a/zephyr/emul/emul_tusb1064.c +++ b/zephyr/emul/emul_tusb1064.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - #include "driver/usb_mux/tusb1064.h" #include "emul/emul_common_i2c.h" #include "emul/emul_stub_device.h" #include "util.h" +#include + #define DT_DRV_COMPAT zephyr_tusb1064_emul #define TUSB1064_REG_MAX 255 diff --git a/zephyr/emul/i2c_mock.c b/zephyr/emul/i2c_mock.c index 8601c87ee7..c906e76c13 100644 --- a/zephyr/emul/i2c_mock.c +++ b/zephyr/emul/i2c_mock.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_i2c_mock +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" #include #include -#include "emul/emul_common_i2c.h" -#include "emul/emul_stub_device.h" +#define DT_DRV_COMPAT cros_i2c_mock LOG_MODULE_REGISTER(i2c_mock, CONFIG_I2C_MOCK_LOG_LEVEL); diff --git a/zephyr/emul/pwm_mock.c b/zephyr/emul/pwm_mock.c index 0d32155d8f..26f7891cb8 100644 --- a/zephyr/emul/pwm_mock.c +++ b/zephyr/emul/pwm_mock.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_pwm_mock +#include "pwm_mock.h" #include #include -#include #include +#include -#include "pwm_mock.h" +#define DT_DRV_COMPAT cros_pwm_mock #define CYCLES_PER_SEC 1000000 diff --git a/zephyr/emul/tcpc/emul_anx7447.c b/zephyr/emul/tcpc/emul_anx7447.c index 6a351a4182..9514afdeed 100644 --- a/zephyr/emul/tcpc/emul_anx7447.c +++ b/zephyr/emul/tcpc/emul_anx7447.c @@ -8,18 +8,17 @@ #include LOG_MODULE_REGISTER(anx7447_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" +#include "emul/tcpc/emul_tcpci.h" +#include "tcpm/tcpci.h" + #include #include #include #include #include -#include "tcpm/tcpci.h" -#include "emul/emul_stub_device.h" - -#include "emul/emul_common_i2c.h" -#include "emul/tcpc/emul_tcpci.h" - /** * @brief Function called for each byte of read message from anx7447 emulator * diff --git a/zephyr/emul/tcpc/emul_ps8xxx.c b/zephyr/emul/tcpc/emul_ps8xxx.c index 57cc2c85f5..d54d0b7c3e 100644 --- a/zephyr/emul/tcpc/emul_ps8xxx.c +++ b/zephyr/emul/tcpc/emul_ps8xxx.c @@ -8,21 +8,19 @@ #include LOG_MODULE_REGISTER(ps8xxx_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); +#include "driver/tcpm/ps8xxx.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" +#include "emul/tcpc/emul_ps8xxx.h" +#include "emul/tcpc/emul_tcpci.h" +#include "tcpm/tcpci.h" + #include #include #include #include #include -#include "tcpm/tcpci.h" - -#include "emul/emul_common_i2c.h" -#include "emul/tcpc/emul_ps8xxx.h" -#include "emul/tcpc/emul_tcpci.h" -#include "emul/emul_stub_device.h" - -#include "driver/tcpm/ps8xxx.h" - #define PS8XXX_REG_MUX_IN_HPD_ASSERTION MUX_IN_HPD_ASSERTION_REG /** Run-time data used by the emulator */ diff --git a/zephyr/emul/tcpc/emul_tcpci.c b/zephyr/emul/tcpc/emul_tcpci.c index aa4e508489..fa6caea4ca 100644 --- a/zephyr/emul/tcpc/emul_tcpci.c +++ b/zephyr/emul/tcpc/emul_tcpci.c @@ -6,19 +6,18 @@ #include LOG_MODULE_REGISTER(tcpci_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); +#include "emul/emul_common_i2c.h" +#include "emul/tcpc/emul_tcpci.h" +#include "tcpm/tcpci.h" + #include #include +#include #include #include -#include #include #include -#include "tcpm/tcpci.h" - -#include "emul/emul_common_i2c.h" -#include "emul/tcpc/emul_tcpci.h" - /** * @brief Returns number of bytes in specific register * diff --git a/zephyr/emul/tcpc/emul_tcpci_generic.c b/zephyr/emul/tcpc/emul_tcpci_generic.c index 204e040ede..795459a45c 100644 --- a/zephyr/emul/tcpc/emul_tcpci_generic.c +++ b/zephyr/emul/tcpc/emul_tcpci_generic.c @@ -8,18 +8,17 @@ #include LOG_MODULE_REGISTER(tcpci_generic_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); +#include "emul/emul_common_i2c.h" +#include "emul/emul_stub_device.h" +#include "emul/tcpc/emul_tcpci.h" +#include "tcpm/tcpci.h" + #include #include #include #include #include -#include "tcpm/tcpci.h" -#include "emul/emul_stub_device.h" - -#include "emul/emul_common_i2c.h" -#include "emul/tcpc/emul_tcpci.h" - /** * @brief Function called for each byte of read message from TCPCI emulator * diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c index 22a9ddb91e..e9fd9ad9ef 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c @@ -6,17 +6,18 @@ #include LOG_MODULE_REGISTER(tcpci_partner, CONFIG_TCPCI_EMUL_LOG_LEVEL); -#include -#include -#include -#include - #include "common.h" -#include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_common.h" #include "usb_pd.h" #include "util.h" +#include + +#include +#include +#include + /** Length of PDO, RDO and BIST request object in SOP message in bytes */ #define TCPCI_MSG_DO_LEN 4 /** Length of header in SOP message in bytes */ diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_drp.c b/zephyr/emul/tcpc/emul_tcpci_partner_drp.c index 277957282d..82a7b045b3 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_drp.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_drp.c @@ -6,9 +6,6 @@ #include LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); -#include -#include - #include "common.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" @@ -18,6 +15,9 @@ LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include "tcpm/tcpci.h" #include "usb_pd.h" +#include +#include + /** * @brief Handle SOP messages as TCPCI dual role device * diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c b/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c index fc4cd06b82..c5de54f562 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c @@ -6,15 +6,15 @@ #include LOG_MODULE_REGISTER(tcpci_faulty_ext, CONFIG_TCPCI_EMUL_LOG_LEVEL); -#include -#include - #include "common.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci_partner_faulty_ext.h" #include "usb_pd.h" +#include +#include + /** * @brief Reduce number of times to repeat action. If count reaches zero, action * is removed from queue. diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c index 8d0fe1fa1e..d9ff23762a 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c @@ -6,15 +6,15 @@ #include LOG_MODULE_REGISTER(tcpci_snk_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); -#include -#include - #include "common.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "usb_pd.h" +#include +#include + /** Length of PDO, RDO and BIST request object in SOP message in bytes */ #define TCPCI_MSG_DO_LEN 4 /** Length of header in SOP message in bytes */ diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_src.c b/zephyr/emul/tcpc/emul_tcpci_partner_src.c index c81d69c25f..b823926dd3 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_src.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_src.c @@ -6,15 +6,15 @@ #include LOG_MODULE_REGISTER(tcpci_src_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); -#include -#include - #include "common.h" +#include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci_partner_src.h" -#include "emul/tcpc/emul_tcpci.h" #include "usb_pd.h" +#include +#include + /** * @brief Start source capability timer. Capability message will be send after * @p time. -- cgit v1.2.1 From 8f334860cd7bc8ceb7cf4e5c25b29a0d2754ac2e Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 15 Nov 2022 14:25:40 -0700 Subject: zephyr: Manually reorder includes Embedded comments or preprocessor directives confuse clang format, and it can't reorder the includes. Manually fix these files to put the headers in order. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: Ie5e0ec55712aab6cbc5446b0f81c7b653846084a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032915 Tested-by: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Aaron Massey Commit-Queue: Jeremy Bettis --- zephyr/emul/tcpc/emul_anx7447.c | 10 ++--- zephyr/emul/tcpc/emul_ps8xxx.c | 7 ++-- zephyr/emul/tcpc/emul_tcpci.c | 3 +- zephyr/emul/tcpc/emul_tcpci_generic.c | 7 ++-- zephyr/emul/tcpc/emul_tcpci_partner_common.c | 3 +- zephyr/emul/tcpc/emul_tcpci_partner_drp.c | 3 +- zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c | 3 +- zephyr/emul/tcpc/emul_tcpci_partner_snk.c | 3 +- zephyr/emul/tcpc/emul_tcpci_partner_src.c | 3 +- zephyr/program/corsola/src/kingler/usbc_config.c | 9 +++-- zephyr/shim/src/console.c | 30 +++++++-------- zephyr/shim/src/gpio.c | 10 ++--- zephyr/shim/src/gpio_id.c | 5 ++- zephyr/shim/src/gpio_int.c | 10 ++--- zephyr/shim/src/ioex.c | 8 ++-- zephyr/shim/src/ioex_drv.c | 49 ++++++++++++------------ 16 files changed, 85 insertions(+), 78 deletions(-) diff --git a/zephyr/emul/tcpc/emul_anx7447.c b/zephyr/emul/tcpc/emul_anx7447.c index 9514afdeed..9f92bf8ab1 100644 --- a/zephyr/emul/tcpc/emul_anx7447.c +++ b/zephyr/emul/tcpc/emul_anx7447.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_anx7447_emul - -#include -LOG_MODULE_REGISTER(anx7447_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); - #include "emul/emul_common_i2c.h" #include "emul/emul_stub_device.h" #include "emul/tcpc/emul_tcpci.h" @@ -17,8 +12,13 @@ LOG_MODULE_REGISTER(anx7447_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include #include +#include #include +#define DT_DRV_COMPAT cros_anx7447_emul + +LOG_MODULE_REGISTER(anx7447_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** * @brief Function called for each byte of read message from anx7447 emulator * diff --git a/zephyr/emul/tcpc/emul_ps8xxx.c b/zephyr/emul/tcpc/emul_ps8xxx.c index d54d0b7c3e..af4dee4960 100644 --- a/zephyr/emul/tcpc/emul_ps8xxx.c +++ b/zephyr/emul/tcpc/emul_ps8xxx.c @@ -3,11 +3,7 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_ps8xxx_emul - #include -LOG_MODULE_REGISTER(ps8xxx_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); - #include "driver/tcpm/ps8xxx.h" #include "emul/emul_common_i2c.h" #include "emul/emul_stub_device.h" @@ -21,8 +17,11 @@ LOG_MODULE_REGISTER(ps8xxx_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include +#define DT_DRV_COMPAT cros_ps8xxx_emul #define PS8XXX_REG_MUX_IN_HPD_ASSERTION MUX_IN_HPD_ASSERTION_REG +LOG_MODULE_REGISTER(ps8xxx_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** Run-time data used by the emulator */ struct ps8xxx_emul_data { /** Common I2C data used by "hidden" ports */ diff --git a/zephyr/emul/tcpc/emul_tcpci.c b/zephyr/emul/tcpc/emul_tcpci.c index fa6caea4ca..f444584344 100644 --- a/zephyr/emul/tcpc/emul_tcpci.c +++ b/zephyr/emul/tcpc/emul_tcpci.c @@ -4,7 +4,6 @@ */ #include -LOG_MODULE_REGISTER(tcpci_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include "emul/emul_common_i2c.h" #include "emul/tcpc/emul_tcpci.h" @@ -18,6 +17,8 @@ LOG_MODULE_REGISTER(tcpci_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include +LOG_MODULE_REGISTER(tcpci_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** * @brief Returns number of bytes in specific register * diff --git a/zephyr/emul/tcpc/emul_tcpci_generic.c b/zephyr/emul/tcpc/emul_tcpci_generic.c index 795459a45c..fcb453de38 100644 --- a/zephyr/emul/tcpc/emul_tcpci_generic.c +++ b/zephyr/emul/tcpc/emul_tcpci_generic.c @@ -3,10 +3,7 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_tcpci_generic_emul - #include -LOG_MODULE_REGISTER(tcpci_generic_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include "emul/emul_common_i2c.h" #include "emul/emul_stub_device.h" @@ -19,6 +16,10 @@ LOG_MODULE_REGISTER(tcpci_generic_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include +#define DT_DRV_COMPAT cros_tcpci_generic_emul + +LOG_MODULE_REGISTER(tcpci_generic_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** * @brief Function called for each byte of read message from TCPCI emulator * diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c index e9fd9ad9ef..40dbb4682a 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c @@ -4,7 +4,6 @@ */ #include -LOG_MODULE_REGISTER(tcpci_partner, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include "common.h" #include "emul/tcpc/emul_tcpci.h" @@ -18,6 +17,8 @@ LOG_MODULE_REGISTER(tcpci_partner, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include +LOG_MODULE_REGISTER(tcpci_partner, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** Length of PDO, RDO and BIST request object in SOP message in bytes */ #define TCPCI_MSG_DO_LEN 4 /** Length of header in SOP message in bytes */ diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_drp.c b/zephyr/emul/tcpc/emul_tcpci_partner_drp.c index 82a7b045b3..80f9baf97b 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_drp.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_drp.c @@ -4,7 +4,6 @@ */ #include -LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include "common.h" #include "emul/tcpc/emul_tcpci.h" @@ -18,6 +17,8 @@ LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include +LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** * @brief Handle SOP messages as TCPCI dual role device * diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c b/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c index c5de54f562..47580a0f33 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c @@ -4,7 +4,6 @@ */ #include -LOG_MODULE_REGISTER(tcpci_faulty_ext, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include "common.h" #include "emul/tcpc/emul_tcpci.h" @@ -15,6 +14,8 @@ LOG_MODULE_REGISTER(tcpci_faulty_ext, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include +LOG_MODULE_REGISTER(tcpci_faulty_ext, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** * @brief Reduce number of times to repeat action. If count reaches zero, action * is removed from queue. diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c index d9ff23762a..c8719086f7 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c @@ -4,7 +4,6 @@ */ #include -LOG_MODULE_REGISTER(tcpci_snk_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include "common.h" #include "emul/tcpc/emul_tcpci.h" @@ -15,6 +14,8 @@ LOG_MODULE_REGISTER(tcpci_snk_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include +LOG_MODULE_REGISTER(tcpci_snk_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** Length of PDO, RDO and BIST request object in SOP message in bytes */ #define TCPCI_MSG_DO_LEN 4 /** Length of header in SOP message in bytes */ diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_src.c b/zephyr/emul/tcpc/emul_tcpci_partner_src.c index b823926dd3..142254ec35 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_src.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_src.c @@ -4,7 +4,6 @@ */ #include -LOG_MODULE_REGISTER(tcpci_src_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include "common.h" #include "emul/tcpc/emul_tcpci.h" @@ -15,6 +14,8 @@ LOG_MODULE_REGISTER(tcpci_src_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); #include #include +LOG_MODULE_REGISTER(tcpci_src_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); + /** * @brief Start source capability timer. Capability message will be send after * @p time. diff --git a/zephyr/program/corsola/src/kingler/usbc_config.c b/zephyr/program/corsola/src/kingler/usbc_config.c index 7531904c4a..5b243bae93 100644 --- a/zephyr/program/corsola/src/kingler/usbc_config.c +++ b/zephyr/program/corsola/src/kingler/usbc_config.c @@ -5,6 +5,11 @@ /* Kingler board-specific USB-C configuration */ +/* TODO(b/220196310): Create GPIO driver for RT17181S TCPC */ +#ifdef __REQUIRE_ZEPHYR_GPIOS__ +#undef __REQUIRE_ZEPHYR_GPIOS__ +#endif + #include "charger.h" #include "console.h" #include "driver/bc12/pi3usb9201_public.h" @@ -25,10 +30,6 @@ #include "baseboard_usbc_config.h" #include "variant_db_detection.h" -/* TODO(b/220196310): Create GPIO driver for RT17181S TCPC */ -#ifdef __REQUIRE_ZEPHYR_GPIOS__ -#undef __REQUIRE_ZEPHYR_GPIOS__ -#endif #include "gpio.h" #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c index 7bc8990789..6e78fc29c8 100644 --- a/zephyr/shim/src/console.c +++ b/zephyr/shim/src/console.c @@ -3,21 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#ifdef CONFIG_SHELL_BACKEND_DUMMY /* nocheck */ -#include /* nocheck */ -#endif -#include -#include - -#include -#include -#include -#include -#include - /* * TODO(b/238433667): Include EC printf functions * (crec_vsnprintf/crec_snprintf) until we switch to the standard @@ -31,6 +16,21 @@ #include "usb_console.h" #include "zephyr_console_shim.h" +#include +#include + +#include +#include +#include +#include +#include +#ifdef CONFIG_SHELL_BACKEND_DUMMY /* nocheck */ +#include /* nocheck */ +#endif +#include +#include +#include + #if !defined(CONFIG_SHELL_BACKEND_SERIAL) && \ !defined(CONFIG_SHELL_BACKEND_DUMMY) /* nocheck */ #error Must select either CONFIG_SHELL_BACKEND_SERIAL or \ diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c index 347640a7ab..a629c77a11 100644 --- a/zephyr/shim/src/gpio.c +++ b/zephyr/shim/src/gpio.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #ifdef __REQUIRE_ZEPHYR_GPIOS__ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif @@ -17,6 +12,11 @@ #include "ioexpander.h" #include "system.h" +#include +#include +#include +#include + LOG_MODULE_REGISTER(gpio_shim, LOG_LEVEL_ERR); /* diff --git a/zephyr/shim/src/gpio_id.c b/zephyr/shim/src/gpio_id.c index 154924866d..e157e2d487 100644 --- a/zephyr/shim/src/gpio_id.c +++ b/zephyr/shim/src/gpio_id.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include - #ifdef __REQUIRE_ZEPHYR_GPIOS__ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif + #include "gpio.h" #include "util.h" +#include + #define CONVERT_NUMERAL_SYSTEM_EVAL(system, bits, nbits) \ system##_from_bits(bits, nbits) #define CONVERT_NUMERAL_SYSTEM(system, bits, nbits) \ diff --git a/zephyr/shim/src/gpio_int.c b/zephyr/shim/src/gpio_int.c index c6339b497c..761e7e7b3c 100644 --- a/zephyr/shim/src/gpio_int.c +++ b/zephyr/shim/src/gpio_int.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #ifdef __REQUIRE_ZEPHYR_GPIOS__ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif @@ -16,6 +11,11 @@ #include "gpio/gpio.h" #include "gpio/gpio_int.h" +#include +#include +#include +#include + LOG_MODULE_REGISTER(gpio_int, LOG_LEVEL_ERR); /* diff --git a/zephyr/shim/src/ioex.c b/zephyr/shim/src/ioex.c index 2b8d3b2cc4..afda051c8a 100644 --- a/zephyr/shim/src/ioex.c +++ b/zephyr/shim/src/ioex.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ +#ifdef __REQUIRE_ZEPHYR_GPIOS__ +#undef __REQUIRE_ZEPHYR_GPIOS__ +#endif #include "common.h" +#include "ioexpander.h" #include #include #include -#ifdef __REQUIRE_ZEPHYR_GPIOS__ -#undef __REQUIRE_ZEPHYR_GPIOS__ -#endif -#include "ioexpander.h" LOG_MODULE_REGISTER(ioex_shim, LOG_LEVEL_ERR); diff --git a/zephyr/shim/src/ioex_drv.c b/zephyr/shim/src/ioex_drv.c index 0f1db5eb31..98f67a4459 100644 --- a/zephyr/shim/src/ioex_drv.c +++ b/zephyr/shim/src/ioex_drv.c @@ -3,40 +3,15 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT cros_ioex_port -#define DT_DRV_COMPAT_CHIP cros_ioex_chip - -#include - -#include -#include -#include #ifdef __REQUIRE_ZEPHYR_GPIOS__ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif #include "common.h" #include "config.h" -#include "gpio.h" -#include "i2c.h" -#include "ioexpander.h" - -#include -#include -#include -#include -#include -#include - /* Include drivers if enabled */ -#ifdef CONFIG_PLATFORM_EC_IOEX_CCGXXF -#include "driver/tcpm/ccgxxf.h" -#endif #ifdef CONFIG_PLATFORM_EC_IOEX_IT8801 #include "driver/ioexpander/it8801.h" #endif -#ifdef CONFIG_PLATFORM_EC_IOEX_NCT38XX -#include "driver/tcpm/nct38xx.h" -#endif #ifdef CONFIG_PLATFORM_EC_IOEX_PCA9675 #include "driver/ioexpander/pca9675.h" #endif @@ -46,6 +21,30 @@ #ifdef CONFIG_PLATFORM_EC_IOEX_TCA64XXA #include "driver/ioexpander/tca64xxa.h" #endif +#ifdef CONFIG_PLATFORM_EC_IOEX_CCGXXF +#include "driver/tcpm/ccgxxf.h" +#endif +#ifdef CONFIG_PLATFORM_EC_IOEX_NCT38XX +#include "driver/tcpm/nct38xx.h" +#endif +#include "gpio.h" +#include "i2c.h" +#include "ioexpander.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DT_DRV_COMPAT cros_ioex_port +#define DT_DRV_COMPAT_CHIP cros_ioex_chip LOG_MODULE_REGISTER(cros_ioex_port, CONFIG_GPIO_LOG_LEVEL); -- cgit v1.2.1 From 9ff48ff131b44af163190aca38673a952652f90d Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 18 Nov 2022 15:49:50 -0700 Subject: zephyr/program: Sort header files Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ibd81df9a27fc0c934b4134106d6f09487439c245 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4039149 Commit-Queue: Jeremy Bettis Reviewed-by: Aaron Massey Tested-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/program/brya/battery_present.c | 4 ++-- zephyr/program/brya/kblight_hooks.c | 8 +++++--- zephyr/program/corsola/src/board.c | 3 +-- zephyr/program/corsola/src/board_chipset.c | 6 ++++-- zephyr/program/corsola/src/hibernate.c | 4 ++-- zephyr/program/corsola/src/kingler/board_steelix.c | 6 +++--- zephyr/program/corsola/src/kingler/i2c.c | 2 +- zephyr/program/corsola/src/kingler/led_steelix.c | 6 +++--- zephyr/program/corsola/src/kingler/usb_pd_policy.c | 3 +-- zephyr/program/corsola/src/kingler/usbc_config.c | 6 ++---- .../program/corsola/src/krabby/charger_workaround.c | 4 ++-- zephyr/program/corsola/src/krabby/hooks.c | 11 ++++++----- zephyr/program/corsola/src/krabby/i2c.c | 2 +- zephyr/program/corsola/src/krabby/ppc_krabby.c | 2 +- zephyr/program/corsola/src/krabby/sensor_magikarp.c | 2 +- .../program/corsola/src/krabby/sensor_tentacruel.c | 2 +- zephyr/program/corsola/src/krabby/temp_tentacruel.c | 2 +- zephyr/program/corsola/src/krabby/usbc_config.c | 1 - zephyr/program/corsola/src/usb_pd_policy.c | 5 ++--- zephyr/program/corsola/src/usbc_config.c | 14 +++++++------- zephyr/program/corsola/src/variant_db_detection.c | 5 ++--- .../herobrine/herobrine/src/alt_dev_replacement.c | 7 ++++--- zephyr/program/herobrine/src/board_chipset.c | 5 ++--- zephyr/program/herobrine/src/i2c.c | 2 +- zephyr/program/herobrine/src/usb_pd_policy.c | 4 ++-- zephyr/program/herobrine/src/usbc_config.c | 12 ++++++------ zephyr/program/intelrvp/adlrvp/src/adlrvp.c | 14 +++++++------- zephyr/program/intelrvp/mtlrvp/src/board_power.c | 10 +++++----- zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c | 2 +- zephyr/program/intelrvp/src/intel_rvp_board_id.c | 3 ++- zephyr/program/it8xxx2_evb/include/i2c_map.h | 4 ++-- zephyr/program/nissa/craask/src/charger.c | 6 +++--- zephyr/program/nissa/craask/src/form_factor.c | 9 ++++----- zephyr/program/nissa/craask/src/usbc.c | 13 ++++++------- zephyr/program/nissa/joxer/src/charger.c | 6 +++--- zephyr/program/nissa/joxer/src/fan.c | 9 ++++----- zephyr/program/nissa/joxer/src/keyboard.c | 8 ++++---- zephyr/program/nissa/joxer/src/led.c | 4 ++-- zephyr/program/nissa/joxer/src/usbc.c | 14 +++++++------- zephyr/program/nissa/nereid/src/charger.c | 6 +++--- zephyr/program/nissa/nereid/src/hdmi.c | 3 ++- zephyr/program/nissa/nereid/src/usbc.c | 14 +++++++------- zephyr/program/nissa/nivviks/src/charger.c | 6 +++--- zephyr/program/nissa/nivviks/src/fan.c | 9 ++++----- zephyr/program/nissa/nivviks/src/form_factor.c | 7 +++---- zephyr/program/nissa/nivviks/src/usbc.c | 13 ++++++------- zephyr/program/nissa/pujjo/src/charger.c | 12 ++++++------ zephyr/program/nissa/pujjo/src/fan.c | 9 ++++----- zephyr/program/nissa/pujjo/src/form_factor.c | 9 ++++----- zephyr/program/nissa/pujjo/src/led.c | 4 ++-- zephyr/program/nissa/pujjo/src/usbc.c | 13 ++++++------- zephyr/program/nissa/src/board_power.c | 10 +++++----- zephyr/program/nissa/src/common.c | 13 ++++++------- zephyr/program/nissa/src/sub_board.c | 20 ++++++++++---------- zephyr/program/nissa/xivu/src/charger.c | 6 +++--- zephyr/program/nissa/xivu/src/usbc.c | 14 +++++++------- zephyr/program/nissa/yaviks/src/charger.c | 8 ++++---- zephyr/program/nissa/yaviks/src/fan.c | 7 ++++--- zephyr/program/nissa/yaviks/src/keyboard.c | 4 ++-- zephyr/program/nissa/yaviks/src/led.c | 6 +++--- zephyr/program/nissa/yaviks/src/thermal.c | 3 ++- zephyr/program/nissa/yaviks/src/usbc.c | 14 +++++++------- zephyr/program/rex/src/board_power.c | 8 ++++---- zephyr/program/rex/src/usb_pd_policy.c | 4 ++-- zephyr/program/rex/src/usbc_config.c | 9 ++++----- .../skyrim/src/frostflow/keyboard_customization.c | 4 ++-- zephyr/program/skyrim/src/frostflow/ppc_config.c | 6 +++--- zephyr/program/skyrim/src/morthal/ppc_config.c | 6 +++--- zephyr/program/skyrim/src/morthal/usb_mux_config.c | 4 ++-- zephyr/program/skyrim/src/power_signals.c | 2 +- zephyr/program/skyrim/src/skyrim/alt_charger.c | 6 +++--- zephyr/program/skyrim/src/skyrim/fan.c | 8 ++++---- zephyr/program/skyrim/src/skyrim/form_factor.c | 7 ++++--- zephyr/program/skyrim/src/skyrim/ppc_config.c | 6 +++--- zephyr/program/skyrim/src/skyrim/usb_mux_config.c | 4 ++-- zephyr/program/skyrim/src/usb_pd_policy.c | 4 ++-- zephyr/program/skyrim/src/usbc_config.c | 12 ++++++------ .../program/skyrim/src/winterhold/battery_present.c | 4 ++-- zephyr/program/skyrim/src/winterhold/kb_backlight.c | 6 +++--- zephyr/program/skyrim/src/winterhold/ppc_config.c | 4 ++-- .../program/skyrim/src/winterhold/usb_mux_config.c | 4 ++-- zephyr/program/trogdor/lazor/src/i2c.c | 2 +- zephyr/program/trogdor/lazor/src/power.c | 9 +++++---- zephyr/program/trogdor/lazor/src/sku.c | 2 +- zephyr/program/trogdor/lazor/src/switchcap.c | 6 +++--- zephyr/program/trogdor/lazor/src/usb_pd_policy.c | 4 ++-- zephyr/program/trogdor/lazor/src/usbc_config.c | 8 ++++---- 87 files changed, 286 insertions(+), 293 deletions(-) diff --git a/zephyr/program/brya/battery_present.c b/zephyr/program/brya/battery_present.c index c487a01f36..b2af448271 100644 --- a/zephyr/program/brya/battery_present.c +++ b/zephyr/program/brya/battery_present.c @@ -2,11 +2,11 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "battery.h" #include "cbi.h" +#include + enum battery_present battery_hw_present(void) { const struct gpio_dt_spec *batt_pres; diff --git a/zephyr/program/brya/kblight_hooks.c b/zephyr/program/brya/kblight_hooks.c index d6d795f28e..8716537f5d 100644 --- a/zephyr/program/brya/kblight_hooks.c +++ b/zephyr/program/brya/kblight_hooks.c @@ -3,12 +3,14 @@ * found in the LICENSE file. */ -#include +#include "cbi.h" +#include "hooks.h" + #include +#include + #include -#include "cbi.h" -#include "hooks.h" /* Enable/Disable keyboard backlight gpio */ static inline void kbd_backlight_enable(bool enable) diff --git a/zephyr/program/corsola/src/board.c b/zephyr/program/corsola/src/board.c index 93a2443191..bd0ee739b5 100644 --- a/zephyr/program/corsola/src/board.c +++ b/zephyr/program/corsola/src/board.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ +#include "baseboard_usbc_config.h" #include "console.h" #include "hooks.h" #include "typec_control.h" @@ -11,8 +12,6 @@ #include "usb_pd.h" #include "usbc_ppc.h" -#include "baseboard_usbc_config.h" - #define CPRINTS(format, args...) cprints(CC_USB, format, ##args) static void ccd_interrupt_deferred(void) diff --git a/zephyr/program/corsola/src/board_chipset.c b/zephyr/program/corsola/src/board_chipset.c index 54e96bc631..e534bfafcb 100644 --- a/zephyr/program/corsola/src/board_chipset.c +++ b/zephyr/program/corsola/src/board_chipset.c @@ -5,10 +5,12 @@ /* Corsola baseboard-chipset specific configuration */ +#include "gpio.h" + +#include #include + #include -#include -#include "gpio.h" static void board_backlight_handler(struct ap_power_ev_callback *cb, struct ap_power_ev_data data) diff --git a/zephyr/program/corsola/src/hibernate.c b/zephyr/program/corsola/src/hibernate.c index 56c085e077..2b7ed9795d 100644 --- a/zephyr/program/corsola/src/hibernate.c +++ b/zephyr/program/corsola/src/hibernate.c @@ -2,12 +2,12 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "charger.h" #include "driver/charger/isl923x_public.h" #include "system.h" +#include + /* Corsola board specific hibernate implementation */ __override void board_hibernate(void) { diff --git a/zephyr/program/corsola/src/kingler/board_steelix.c b/zephyr/program/corsola/src/kingler/board_steelix.c index 8b88a6d7c7..b4faf5af0c 100644 --- a/zephyr/program/corsola/src/kingler/board_steelix.c +++ b/zephyr/program/corsola/src/kingler/board_steelix.c @@ -8,9 +8,6 @@ * Steelix is convertible but Rusty is clamshell * so some functions should be disabled for clamshell. */ -#include -#include - #include "accelgyro.h" #include "common.h" #include "cros_cbi.h" @@ -22,6 +19,9 @@ #include "motionsense_sensors.h" #include "tablet_mode.h" +#include +#include + LOG_MODULE_REGISTER(board_init, LOG_LEVEL_ERR); static bool board_is_clamshell; diff --git a/zephyr/program/corsola/src/kingler/i2c.c b/zephyr/program/corsola/src/kingler/i2c.c index f2bbff3749..5bd8aef7d5 100644 --- a/zephyr/program/corsola/src/kingler/i2c.c +++ b/zephyr/program/corsola/src/kingler/i2c.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "i2c/i2c.h" #include "i2c.h" +#include "i2c/i2c.h" /* Kingler and Steelix board specific i2c implementation */ diff --git a/zephyr/program/corsola/src/kingler/led_steelix.c b/zephyr/program/corsola/src/kingler/led_steelix.c index 87b76128e8..1188c4f95e 100644 --- a/zephyr/program/corsola/src/kingler/led_steelix.c +++ b/zephyr/program/corsola/src/kingler/led_steelix.c @@ -5,9 +5,6 @@ * Battery LED control for Steelix */ -#include -#include - #include "board_led.h" #include "common.h" #include "cros_cbi.h" @@ -15,6 +12,9 @@ #include "led_onoff_states.h" #include "util.h" +#include +#include + LOG_MODULE_REGISTER(board_led, LOG_LEVEL_ERR); #define BOARD_LED_PWM_PERIOD_NS BOARD_LED_HZ_TO_PERIOD_NS(100) diff --git a/zephyr/program/corsola/src/kingler/usb_pd_policy.c b/zephyr/program/corsola/src/kingler/usb_pd_policy.c index 3de2857ad1..c9e26f6681 100644 --- a/zephyr/program/corsola/src/kingler/usb_pd_policy.c +++ b/zephyr/program/corsola/src/kingler/usb_pd_policy.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ +#include "baseboard_usbc_config.h" #include "charge_manager.h" #include "console.h" #include "driver/ppc/rt1718s.h" @@ -12,8 +13,6 @@ #include "usbc_ppc.h" #include "util.h" -#include "baseboard_usbc_config.h" - #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/corsola/src/kingler/usbc_config.c b/zephyr/program/corsola/src/kingler/usbc_config.c index 5b243bae93..2e05d3720e 100644 --- a/zephyr/program/corsola/src/kingler/usbc_config.c +++ b/zephyr/program/corsola/src/kingler/usbc_config.c @@ -10,6 +10,7 @@ #undef __REQUIRE_ZEPHYR_GPIOS__ #endif +#include "baseboard_usbc_config.h" #include "charger.h" #include "console.h" #include "driver/bc12/pi3usb9201_public.h" @@ -19,6 +20,7 @@ #include "driver/tcpm/anx7447.h" #include "driver/tcpm/rt1718s.h" #include "driver/usb_mux/ps8743.h" +#include "gpio.h" #include "gpio/gpio_int.h" #include "hooks.h" #include "timer.h" @@ -26,12 +28,8 @@ #include "usb_mux.h" #include "usb_pd_tcpm.h" #include "usbc_ppc.h" - -#include "baseboard_usbc_config.h" #include "variant_db_detection.h" -#include "gpio.h" - #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) diff --git a/zephyr/program/corsola/src/krabby/charger_workaround.c b/zephyr/program/corsola/src/krabby/charger_workaround.c index d7fd05cc00..be046a947b 100644 --- a/zephyr/program/corsola/src/krabby/charger_workaround.c +++ b/zephyr/program/corsola/src/krabby/charger_workaround.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "charger.h" #include "driver/charger/rt9490.h" #include "hooks.h" #include "i2c.h" #include "system.h" +#include + /* * This workaround and the board id checks only apply to krabby and early * tentacruel devices. diff --git a/zephyr/program/corsola/src/krabby/hooks.c b/zephyr/program/corsola/src/krabby/hooks.c index 1eb4f600f2..2582998b9c 100644 --- a/zephyr/program/corsola/src/krabby/hooks.c +++ b/zephyr/program/corsola/src/krabby/hooks.c @@ -3,17 +3,18 @@ * found in the LICENSE file. */ -#include -#include -#include - -#include #include "charger.h" #include "driver/charger/rt9490.h" #include "extpower.h" #include "gpio.h" #include "hooks.h" +#include +#include +#include + +#include + #define I2C3_NODE DT_NODELABEL(i2c3) PINCTRL_DT_DEFINE(I2C3_NODE); diff --git a/zephyr/program/corsola/src/krabby/i2c.c b/zephyr/program/corsola/src/krabby/i2c.c index a83af77dbd..66b88b09b0 100644 --- a/zephyr/program/corsola/src/krabby/i2c.c +++ b/zephyr/program/corsola/src/krabby/i2c.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "i2c/i2c.h" #include "i2c.h" +#include "i2c/i2c.h" /* Krabby board specific i2c implementation */ diff --git a/zephyr/program/corsola/src/krabby/ppc_krabby.c b/zephyr/program/corsola/src/krabby/ppc_krabby.c index d4f574a725..dbbfee57b5 100644 --- a/zephyr/program/corsola/src/krabby/ppc_krabby.c +++ b/zephyr/program/corsola/src/krabby/ppc_krabby.c @@ -6,9 +6,9 @@ /* Krabby PPC/BC12 (RT1739) configuration */ #include "baseboard_usbc_config.h" -#include "gpio/gpio_int.h" #include "driver/ppc/rt1739.h" #include "driver/ppc/syv682x.h" +#include "gpio/gpio_int.h" #include "hooks.h" #include "variant_db_detection.h" diff --git a/zephyr/program/corsola/src/krabby/sensor_magikarp.c b/zephyr/program/corsola/src/krabby/sensor_magikarp.c index 269bc26fae..48e6f6c23c 100644 --- a/zephyr/program/corsola/src/krabby/sensor_magikarp.c +++ b/zephyr/program/corsola/src/krabby/sensor_magikarp.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "common.h" #include "accelgyro.h" +#include "common.h" #include "cros_cbi.h" #include "driver/accelgyro_bmi323.h" #include "driver/accelgyro_icm42607.h" diff --git a/zephyr/program/corsola/src/krabby/sensor_tentacruel.c b/zephyr/program/corsola/src/krabby/sensor_tentacruel.c index 269bc26fae..48e6f6c23c 100644 --- a/zephyr/program/corsola/src/krabby/sensor_tentacruel.c +++ b/zephyr/program/corsola/src/krabby/sensor_tentacruel.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "common.h" #include "accelgyro.h" +#include "common.h" #include "cros_cbi.h" #include "driver/accelgyro_bmi323.h" #include "driver/accelgyro_icm42607.h" diff --git a/zephyr/program/corsola/src/krabby/temp_tentacruel.c b/zephyr/program/corsola/src/krabby/temp_tentacruel.c index 5d2c304f76..08d5204e28 100644 --- a/zephyr/program/corsola/src/krabby/temp_tentacruel.c +++ b/zephyr/program/corsola/src/krabby/temp_tentacruel.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "charger.h" #include "charge_state.h" +#include "charger.h" #include "common.h" #include "config.h" #include "console.h" diff --git a/zephyr/program/corsola/src/krabby/usbc_config.c b/zephyr/program/corsola/src/krabby/usbc_config.c index 8e03e8dbad..1307538922 100644 --- a/zephyr/program/corsola/src/krabby/usbc_config.c +++ b/zephyr/program/corsola/src/krabby/usbc_config.c @@ -14,7 +14,6 @@ #include "i2c.h" #include "usb_pd.h" #include "usbc_ppc.h" - #include "variant_db_detection.h" #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/corsola/src/usb_pd_policy.c b/zephyr/program/corsola/src/usb_pd_policy.c index a885362c61..a5f3f11134 100644 --- a/zephyr/program/corsola/src/usb_pd_policy.c +++ b/zephyr/program/corsola/src/usb_pd_policy.c @@ -4,8 +4,9 @@ */ #include "atomic.h" -#include "console.h" +#include "baseboard_usbc_config.h" #include "chipset.h" +#include "console.h" #include "hooks.h" #include "timer.h" #include "typec_control.h" @@ -14,8 +15,6 @@ #include "usb_pd.h" #include "usbc_ppc.h" -#include "baseboard_usbc_config.h" - #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) diff --git a/zephyr/program/corsola/src/usbc_config.c b/zephyr/program/corsola/src/usbc_config.c index 838f676694..c96f3b5e32 100644 --- a/zephyr/program/corsola/src/usbc_config.c +++ b/zephyr/program/corsola/src/usbc_config.c @@ -5,14 +5,11 @@ /* Corsola baseboard-specific USB-C configuration */ -#include -#include - #include "adc.h" #include "baseboard_usbc_config.h" #include "button.h" -#include "charger.h" #include "charge_state_v2.h" +#include "charger.h" #include "console.h" #include "ec_commands.h" #include "extpower.h" @@ -20,13 +17,13 @@ #include "hooks.h" #include "i2c.h" #include "lid_switch.h" -#include "task.h" -#include "ppc/syv682x_public.h" #include "power.h" #include "power_button.h" +#include "ppc/syv682x_public.h" #include "spi.h" #include "switch.h" #include "tablet_mode.h" +#include "task.h" #include "uart.h" #include "usb_charge.h" #include "usb_mux.h" @@ -34,9 +31,12 @@ #include "usb_tc_sm.h" #include "usbc/usb_muxes.h" #include "usbc_ppc.h" - #include "variant_db_detection.h" +#include + +#include + #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) diff --git a/zephyr/program/corsola/src/variant_db_detection.c b/zephyr/program/corsola/src/variant_db_detection.c index f68d9c8fad..9ade144513 100644 --- a/zephyr/program/corsola/src/variant_db_detection.c +++ b/zephyr/program/corsola/src/variant_db_detection.c @@ -4,17 +4,16 @@ */ /* Corsola daughter board detection */ -#include - #include "baseboard_usbc_config.h" #include "console.h" #include "cros_cbi.h" #include "gpio/gpio_int.h" #include "hooks.h" #include "usb_mux.h" - #include "variant_db_detection.h" +#include + #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) diff --git a/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c b/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c index 00acd509f4..e1e9250ec4 100644 --- a/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c +++ b/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c @@ -2,10 +2,11 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include "usbc/ppc.h" -#include "hooks.h" #include "cros_board_info.h" +#include "hooks.h" +#include "usbc/ppc.h" + +#include LOG_MODULE_REGISTER(alt_dev_replacement); diff --git a/zephyr/program/herobrine/src/board_chipset.c b/zephyr/program/herobrine/src/board_chipset.c index 2312bdb1c4..dece9708ff 100644 --- a/zephyr/program/herobrine/src/board_chipset.c +++ b/zephyr/program/herobrine/src/board_chipset.c @@ -5,17 +5,16 @@ /* Herobrine chipset-specific configuration */ +#include "battery.h" +#include "board_chipset.h" #include "charger.h" #include "common.h" #include "console.h" -#include "battery.h" #include "gpio.h" #include "hooks.h" #include "timer.h" #include "usb_pd.h" -#include "board_chipset.h" - #define CPRINTS(format, args...) cprints(CC_HOOK, format, ##args) #define CPRINTF(format, args...) cprintf(CC_HOOK, format, ##args) diff --git a/zephyr/program/herobrine/src/i2c.c b/zephyr/program/herobrine/src/i2c.c index 88b722c42d..8cf2cfc232 100644 --- a/zephyr/program/herobrine/src/i2c.c +++ b/zephyr/program/herobrine/src/i2c.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "i2c/i2c.h" #include "i2c.h" +#include "i2c/i2c.h" /* Herobrine-NPCX9 board specific i2c implementation */ diff --git a/zephyr/program/herobrine/src/usb_pd_policy.c b/zephyr/program/herobrine/src/usb_pd_policy.c index adc517d3cb..ad34f3b6e4 100644 --- a/zephyr/program/herobrine/src/usb_pd_policy.c +++ b/zephyr/program/herobrine/src/usb_pd_policy.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "charge_manager.h" #include "chipset.h" #include "console.h" @@ -13,6 +11,8 @@ #include "usbc_ppc.h" #include "util.h" +#include + #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/herobrine/src/usbc_config.c b/zephyr/program/herobrine/src/usbc_config.c index 1c0ab8205b..e757e3f2e1 100644 --- a/zephyr/program/herobrine/src/usbc_config.c +++ b/zephyr/program/herobrine/src/usbc_config.c @@ -5,12 +5,10 @@ /* Herobrine board-specific USB-C configuration */ -#include - -#include "charger.h" -#include "charger/isl923x_public.h" #include "charge_manager.h" #include "charge_state.h" +#include "charger.h" +#include "charger/isl923x_public.h" #include "common.h" #include "config.h" #include "cros_board_info.h" @@ -22,11 +20,13 @@ #include "tcpm/ps8xxx_public.h" #include "tcpm/tcpci.h" #include "timer.h" -#include "usb_pd.h" #include "usb_mux.h" +#include "usb_pd.h" +#include "usbc/ppc.h" #include "usbc_ocp.h" #include "usbc_ppc.h" -#include "usbc/ppc.h" + +#include #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/intelrvp/adlrvp/src/adlrvp.c b/zephyr/program/intelrvp/adlrvp/src/adlrvp.c index ce5196c60d..d7d192b1af 100644 --- a/zephyr/program/intelrvp/adlrvp/src/adlrvp.c +++ b/zephyr/program/intelrvp/adlrvp/src/adlrvp.c @@ -4,19 +4,19 @@ */ /* TODO: b/218904113: Convert to using Zephyr GPIOs */ -#include "gpio_signal.h" #include "adlrvp_zephyr.h" -#include "common.h" -#include "console.h" -#include "intelrvp.h" -#include "intel_rvp_board_id.h" -#include "battery_fuel_gauge.h" -#include "charger.h" #include "battery.h" +#include "battery_fuel_gauge.h" #include "bq25710.h" +#include "charger.h" +#include "common.h" +#include "console.h" #include "driver/retimer/bb_retimer_public.h" #include "extpower.h" +#include "gpio_signal.h" #include "hooks.h" +#include "intel_rvp_board_id.h" +#include "intelrvp.h" #include "ioexpander.h" #include "isl9241.h" #include "power/icelake.h" diff --git a/zephyr/program/intelrvp/mtlrvp/src/board_power.c b/zephyr/program/intelrvp/mtlrvp/src/board_power.c index 301402bf0f..e35450b8b5 100644 --- a/zephyr/program/intelrvp/mtlrvp/src/board_power.c +++ b/zephyr/program/intelrvp/mtlrvp/src/board_power.c @@ -3,9 +3,12 @@ * found in the LICENSE file. */ -#include -#include +#include "gpio/gpio.h" +#include "gpio_signal.h" + #include +#include +#include #include #include @@ -14,9 +17,6 @@ #include #include -#include "gpio_signal.h" -#include "gpio/gpio.h" - LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); #if CONFIG_X86_NON_DSX_PWRSEQ_MTL diff --git a/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c b/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c index 9d96a08712..d6bd0f85b7 100644 --- a/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c +++ b/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c @@ -17,8 +17,8 @@ #include "gpio/gpio_int.h" #include "hooks.h" #include "i2c.h" -#include "intelrvp.h" #include "intel_rvp_board_id.h" +#include "intelrvp.h" #include "ioexpander.h" #include "isl9241.h" #include "keyboard_raw.h" diff --git a/zephyr/program/intelrvp/src/intel_rvp_board_id.c b/zephyr/program/intelrvp/src/intel_rvp_board_id.c index 77d4e93afd..7062cb74b9 100644 --- a/zephyr/program/intelrvp/src/intel_rvp_board_id.c +++ b/zephyr/program/intelrvp/src/intel_rvp_board_id.c @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "intel_rvp_board_id.h" +#include + #define DT_DRV_COMPAT intel_rvp_board_id BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1, diff --git a/zephyr/program/it8xxx2_evb/include/i2c_map.h b/zephyr/program/it8xxx2_evb/include/i2c_map.h index e83a238d3a..a6878e8bae 100644 --- a/zephyr/program/it8xxx2_evb/include/i2c_map.h +++ b/zephyr/program/it8xxx2_evb/include/i2c_map.h @@ -6,10 +6,10 @@ #ifndef __ZEPHYR_CHROME_I2C_MAP_H #define __ZEPHYR_CHROME_I2C_MAP_H -#include - #include "config.h" +#include + /* We need registers.h to get the chip specific defines for now */ #include "i2c/i2c.h" diff --git a/zephyr/program/nissa/craask/src/charger.c b/zephyr/program/nissa/craask/src/charger.c index d4723e4a0a..3984045a19 100644 --- a/zephyr/program/nissa/craask/src/charger.c +++ b/zephyr/program/nissa/craask/src/charger.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charger.h" #include "charger/isl923x_public.h" #include "console.h" #include "extpower.h" -#include "usb_pd.h" #include "nissa_common.h" +#include "usb_pd.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/craask/src/form_factor.c b/zephyr/program/nissa/craask/src/form_factor.c index 9f3267ab3d..56d0c50f73 100644 --- a/zephyr/program/nissa/craask/src/form_factor.c +++ b/zephyr/program/nissa/craask/src/form_factor.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "accelgyro.h" #include "button.h" #include "cros_board_info.h" @@ -16,11 +13,13 @@ #include "driver/accelgyro_lsm6dso.h" #include "gpio/gpio_int.h" #include "hooks.h" -#include "motionsense_sensors.h" #include "motion_sense.h" +#include "motionsense_sensors.h" +#include "nissa_common.h" #include "tablet_mode.h" -#include "nissa_common.h" +#include +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/craask/src/usbc.c b/zephyr/program/nissa/craask/src/usbc.c index a15460a212..a32cc41331 100644 --- a/zephyr/program/nissa/craask/src/usbc.c +++ b/zephyr/program/nissa/craask/src/usbc.c @@ -3,19 +3,18 @@ * found in the LICENSE file. */ -#include - #include "charge_state_v2.h" #include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" #include "driver/tcpm/raa489000.h" - +#include "driver/tcpm/tcpci.h" +#include "hooks.h" #include "nissa_common.h" +#include "system.h" +#include "usb_mux.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/joxer/src/charger.c b/zephyr/program/nissa/joxer/src/charger.c index b9454d8b80..4bb7de7ecb 100644 --- a/zephyr/program/nissa/joxer/src/charger.c +++ b/zephyr/program/nissa/joxer/src/charger.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charger.h" #include "console.h" #include "driver/charger/sm5803.h" #include "extpower.h" -#include "usb_pd.h" #include "nissa_common.h" +#include "usb_pd.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/joxer/src/fan.c b/zephyr/program/nissa/joxer/src/fan.c index 6d234b2fc3..82be341da5 100644 --- a/zephyr/program/nissa/joxer/src/fan.c +++ b/zephyr/program/nissa/joxer/src/fan.c @@ -3,17 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "cros_cbi.h" #include "fan.h" #include "gpio/gpio.h" #include "hooks.h" - #include "nissa_common.h" +#include +#include +#include + LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); /* diff --git a/zephyr/program/nissa/joxer/src/keyboard.c b/zephyr/program/nissa/joxer/src/keyboard.c index 48db40f53f..e9e20194f0 100644 --- a/zephyr/program/nissa/joxer/src/keyboard.c +++ b/zephyr/program/nissa/joxer/src/keyboard.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "cros_cbi.h" #include "ec_commands.h" #include "gpio/gpio.h" @@ -14,6 +10,10 @@ #include "keyboard_8042_sharedlib.h" #include "nissa_common.h" +#include +#include +#include + LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); static const struct ec_response_keybd_config joxer_kb_legacy = { diff --git a/zephyr/program/nissa/joxer/src/led.c b/zephyr/program/nissa/joxer/src/led.c index d66e5b27a6..c617ee9507 100644 --- a/zephyr/program/nissa/joxer/src/led.c +++ b/zephyr/program/nissa/joxer/src/led.c @@ -4,8 +4,6 @@ * * Battery LED control for nissa */ -#include - #include "charge_manager.h" #include "common.h" #include "compile_time_macros.h" @@ -16,6 +14,8 @@ #include "pwm.h" #include "util.h" +#include + #define BAT_LED_ON_LVL 0 #define BAT_LED_OFF_LVL 1 diff --git a/zephyr/program/nissa/joxer/src/usbc.c b/zephyr/program/nissa/joxer/src/usbc.c index 5fec9ab544..8c81d596dc 100644 --- a/zephyr/program/nissa/joxer/src/usbc.c +++ b/zephyr/program/nissa/joxer/src/usbc.c @@ -3,20 +3,20 @@ * found in the LICENSE file. */ -#include -#include - #include "charge_state_v2.h" #include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" #include "driver/charger/sm5803.h" #include "driver/tcpm/it83xx_pd.h" #include "driver/tcpm/ps8xxx_public.h" #include "driver/tcpm/tcpci.h" - +#include "hooks.h" #include "nissa_common.h" +#include "system.h" +#include "usb_mux.h" + +#include + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/nereid/src/charger.c b/zephyr/program/nissa/nereid/src/charger.c index 181e9a61fd..dc4eda9291 100644 --- a/zephyr/program/nissa/nereid/src/charger.c +++ b/zephyr/program/nissa/nereid/src/charger.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charger.h" #include "console.h" #include "driver/charger/sm5803.h" #include "extpower.h" -#include "usb_pd.h" #include "nissa_common.h" +#include "usb_pd.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/nereid/src/hdmi.c b/zephyr/program/nissa/nereid/src/hdmi.c index 7e5708c6eb..5025472c6d 100644 --- a/zephyr/program/nissa/nereid/src/hdmi.c +++ b/zephyr/program/nissa/nereid/src/hdmi.c @@ -3,9 +3,10 @@ * found in the LICENSE file. */ -#include #include "nissa_hdmi.h" +#include + __override void nissa_configure_hdmi_power_gpios(void) { /* diff --git a/zephyr/program/nissa/nereid/src/usbc.c b/zephyr/program/nissa/nereid/src/usbc.c index 48f7cfd9cb..01e48e79e0 100644 --- a/zephyr/program/nissa/nereid/src/usbc.c +++ b/zephyr/program/nissa/nereid/src/usbc.c @@ -3,20 +3,20 @@ * found in the LICENSE file. */ -#include -#include - #include "charge_state_v2.h" #include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" #include "driver/charger/sm5803.h" #include "driver/tcpm/it83xx_pd.h" #include "driver/tcpm/ps8xxx_public.h" #include "driver/tcpm/tcpci.h" - +#include "hooks.h" #include "nissa_common.h" +#include "system.h" +#include "usb_mux.h" + +#include + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/nivviks/src/charger.c b/zephyr/program/nissa/nivviks/src/charger.c index e2f9f966e7..234bcbbd55 100644 --- a/zephyr/program/nissa/nivviks/src/charger.c +++ b/zephyr/program/nissa/nivviks/src/charger.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charger.h" #include "charger/isl923x_public.h" #include "console.h" #include "extpower.h" -#include "usb_pd.h" #include "nissa_common.h" +#include "usb_pd.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/nivviks/src/fan.c b/zephyr/program/nissa/nivviks/src/fan.c index 840049722c..3111a70e03 100644 --- a/zephyr/program/nissa/nivviks/src/fan.c +++ b/zephyr/program/nissa/nivviks/src/fan.c @@ -3,17 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "cros_cbi.h" #include "fan.h" #include "gpio/gpio.h" #include "hooks.h" - #include "nissa_common.h" +#include +#include +#include + LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); /* diff --git a/zephyr/program/nissa/nivviks/src/form_factor.c b/zephyr/program/nissa/nivviks/src/form_factor.c index 602b22baff..08dfa5c04b 100644 --- a/zephyr/program/nissa/nivviks/src/form_factor.c +++ b/zephyr/program/nissa/nivviks/src/form_factor.c @@ -3,16 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "accelgyro.h" #include "cros_cbi.h" #include "hooks.h" #include "motionsense_sensors.h" - #include "nissa_common.h" +#include +#include + LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); /* diff --git a/zephyr/program/nissa/nivviks/src/usbc.c b/zephyr/program/nissa/nivviks/src/usbc.c index 14fc5a071d..5b0eed5aea 100644 --- a/zephyr/program/nissa/nivviks/src/usbc.c +++ b/zephyr/program/nissa/nivviks/src/usbc.c @@ -3,19 +3,18 @@ * found in the LICENSE file. */ -#include - #include "charge_state_v2.h" #include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" #include "driver/tcpm/raa489000.h" - +#include "driver/tcpm/tcpci.h" +#include "hooks.h" #include "nissa_common.h" +#include "system.h" +#include "usb_mux.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/pujjo/src/charger.c b/zephyr/program/nissa/pujjo/src/charger.c index f1f1d57790..8763f24793 100644 --- a/zephyr/program/nissa/pujjo/src/charger.c +++ b/zephyr/program/nissa/pujjo/src/charger.c @@ -3,18 +3,18 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charger.h" #include "charger/isl923x_public.h" -#include "driver/tcpm/raa489000.h" -#include "driver/charger/isl923x.h" #include "console.h" +#include "driver/charger/isl923x.h" +#include "driver/tcpm/raa489000.h" #include "extpower.h" -#include "usb_pd.h" -#include "nissa_common.h" #include "hooks.h" +#include "nissa_common.h" +#include "usb_pd.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/pujjo/src/fan.c b/zephyr/program/nissa/pujjo/src/fan.c index 97323a7edf..8b8634a653 100644 --- a/zephyr/program/nissa/pujjo/src/fan.c +++ b/zephyr/program/nissa/pujjo/src/fan.c @@ -3,17 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "cros_cbi.h" #include "fan.h" #include "gpio/gpio.h" #include "hooks.h" - #include "nissa_common.h" +#include +#include +#include + LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); /* diff --git a/zephyr/program/nissa/pujjo/src/form_factor.c b/zephyr/program/nissa/pujjo/src/form_factor.c index 1b096e8fa4..f160c88d78 100644 --- a/zephyr/program/nissa/pujjo/src/form_factor.c +++ b/zephyr/program/nissa/pujjo/src/form_factor.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "accelgyro.h" #include "button.h" #include "cros_board_info.h" @@ -16,11 +13,13 @@ #include "driver/accelgyro_lsm6dsm.h" #include "gpio/gpio_int.h" #include "hooks.h" -#include "motionsense_sensors.h" #include "motion_sense.h" +#include "motionsense_sensors.h" +#include "nissa_common.h" #include "tablet_mode.h" -#include "nissa_common.h" +#include +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/pujjo/src/led.c b/zephyr/program/nissa/pujjo/src/led.c index bd04af5a25..4d859f2764 100644 --- a/zephyr/program/nissa/pujjo/src/led.c +++ b/zephyr/program/nissa/pujjo/src/led.c @@ -10,9 +10,9 @@ */ #include "common.h" -#include "led_onoff_states.h" -#include "led_common.h" #include "gpio.h" +#include "led_common.h" +#include "led_onoff_states.h" #define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) #define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) diff --git a/zephyr/program/nissa/pujjo/src/usbc.c b/zephyr/program/nissa/pujjo/src/usbc.c index 5d3d94c243..b56e36049c 100644 --- a/zephyr/program/nissa/pujjo/src/usbc.c +++ b/zephyr/program/nissa/pujjo/src/usbc.c @@ -3,19 +3,18 @@ * found in the LICENSE file. */ -#include - #include "charge_state_v2.h" #include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" #include "driver/tcpm/raa489000.h" - +#include "driver/tcpm/tcpci.h" +#include "hooks.h" #include "nissa_common.h" +#include "system.h" +#include "usb_mux.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/src/board_power.c b/zephyr/program/nissa/src/board_power.c index d7fb4aeffe..858076686b 100644 --- a/zephyr/program/nissa/src/board_power.c +++ b/zephyr/program/nissa/src/board_power.c @@ -3,9 +3,12 @@ * found in the LICENSE file. */ -#include -#include +#include "gpio/gpio.h" +#include "gpio_signal.h" + #include +#include +#include #include #include @@ -14,9 +17,6 @@ #include #include -#include "gpio_signal.h" -#include "gpio/gpio.h" - LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); #define X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS 5 diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c index 4f27d1d84f..bfcbabcbaa 100644 --- a/zephyr/program/nissa/src/common.c +++ b/zephyr/program/nissa/src/common.c @@ -3,21 +3,20 @@ * found in the LICENSE file. */ -#include -#include - #include "battery.h" -#include "charger.h" #include "charge_state_v2.h" +#include "charger.h" #include "chipset.h" #include "cros_cbi.h" #include "hooks.h" -#include "usb_mux.h" -#include "system.h" - #include "nissa_common.h" +#include "system.h" +#include "usb_mux.h" +#include #include + +#include LOG_MODULE_REGISTER(nissa, CONFIG_NISSA_LOG_LEVEL); static uint8_t cached_usb_pd_port_count; diff --git a/zephyr/program/nissa/src/sub_board.c b/zephyr/program/nissa/src/sub_board.c index f50c0bdca8..830e361ac1 100644 --- a/zephyr/program/nissa/src/sub_board.c +++ b/zephyr/program/nissa/src/sub_board.c @@ -5,24 +5,24 @@ /* Nissa sub-board hardware configuration */ -#include -#include -#include -#include -#include -#include - #include "cros_board_info.h" #include "driver/tcpm/tcpci.h" #include "gpio/gpio_int.h" #include "hooks.h" +#include "nissa_common.h" +#include "nissa_hdmi.h" +#include "task.h" #include "usb_charge.h" #include "usb_pd.h" #include "usbc/usb_muxes.h" -#include "task.h" -#include "nissa_common.h" -#include "nissa_hdmi.h" +#include +#include +#include +#include +#include + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/xivu/src/charger.c b/zephyr/program/nissa/xivu/src/charger.c index 5021a55758..a3d9d16443 100644 --- a/zephyr/program/nissa/xivu/src/charger.c +++ b/zephyr/program/nissa/xivu/src/charger.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charger.h" #include "charger/isl923x_public.h" #include "console.h" #include "extpower.h" -#include "usb_pd.h" #include "nissa_common.h" +#include "usb_pd.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/xivu/src/usbc.c b/zephyr/program/nissa/xivu/src/usbc.c index 773ffc0e9c..54a9244ecc 100644 --- a/zephyr/program/nissa/xivu/src/usbc.c +++ b/zephyr/program/nissa/xivu/src/usbc.c @@ -3,19 +3,19 @@ * found in the LICENSE file. */ -#include - #include "charge_state_v2.h" #include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" -#include "driver/tcpm/tcpci.h" #include "driver/tcpm/raa489000.h" -#include "temp_sensor/temp_sensor.h" +#include "driver/tcpm/tcpci.h" +#include "hooks.h" #include "nissa_common.h" +#include "system.h" +#include "temp_sensor/temp_sensor.h" +#include "usb_mux.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/yaviks/src/charger.c b/zephyr/program/nissa/yaviks/src/charger.c index 9be2e685b0..ec2247f4b4 100644 --- a/zephyr/program/nissa/yaviks/src/charger.c +++ b/zephyr/program/nissa/yaviks/src/charger.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include - #include "battery.h" +#include "battery_fuel_gauge.h" #include "charger.h" #include "console.h" #include "driver/charger/sm5803.h" #include "extpower.h" -#include "usb_pd.h" #include "nissa_common.h" -#include "battery_fuel_gauge.h" +#include "usb_pd.h" + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/nissa/yaviks/src/fan.c b/zephyr/program/nissa/yaviks/src/fan.c index 23c3ec1143..c01ee3d752 100644 --- a/zephyr/program/nissa/yaviks/src/fan.c +++ b/zephyr/program/nissa/yaviks/src/fan.c @@ -2,14 +2,15 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include -#include #include "cros_cbi.h" #include "fan.h" #include "gpio/gpio.h" #include "hooks.h" #include "nissa_common.h" + +#include +#include +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); static void fan_init(void) diff --git a/zephyr/program/nissa/yaviks/src/keyboard.c b/zephyr/program/nissa/yaviks/src/keyboard.c index 46d6083dbf..54f8750e98 100644 --- a/zephyr/program/nissa/yaviks/src/keyboard.c +++ b/zephyr/program/nissa/yaviks/src/keyboard.c @@ -2,8 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "cros_cbi.h" #include "ec_commands.h" #include "hooks.h" @@ -11,6 +9,8 @@ #include "keyboard_scan.h" #include "timer.h" +#include + LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); /* Keyboard scan setting */ diff --git a/zephyr/program/nissa/yaviks/src/led.c b/zephyr/program/nissa/yaviks/src/led.c index 88a476f1b0..7671bd3a92 100644 --- a/zephyr/program/nissa/yaviks/src/led.c +++ b/zephyr/program/nissa/yaviks/src/led.c @@ -3,17 +3,17 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "charge_manager.h" #include "charge_state.h" #include "chipset.h" #include "ec_commands.h" #include "gpio.h" +#include "hooks.h" #include "host_command.h" #include "led_common.h" -#include "hooks.h" + +#include #define BAT_LED_ON 0 #define BAT_LED_OFF 1 diff --git a/zephyr/program/nissa/yaviks/src/thermal.c b/zephyr/program/nissa/yaviks/src/thermal.c index 43b30f0497..4522f8bd09 100644 --- a/zephyr/program/nissa/yaviks/src/thermal.c +++ b/zephyr/program/nissa/yaviks/src/thermal.c @@ -3,13 +3,14 @@ * found in the LICENSE file. */ -#include #include "common.h" #include "fan.h" #include "temp_sensor/temp_sensor.h" #include "thermal.h" #include "util.h" +#include + #define TEMP_CPU TEMP_SENSOR_ID(DT_NODELABEL(temp_cpu)) #define TEMP_5V TEMP_SENSOR_ID(DT_NODELABEL(temp_5v_regulator)) #define TEMP_CHARGER TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)) diff --git a/zephyr/program/nissa/yaviks/src/usbc.c b/zephyr/program/nissa/yaviks/src/usbc.c index 48f7cfd9cb..01e48e79e0 100644 --- a/zephyr/program/nissa/yaviks/src/usbc.c +++ b/zephyr/program/nissa/yaviks/src/usbc.c @@ -3,20 +3,20 @@ * found in the LICENSE file. */ -#include -#include - #include "charge_state_v2.h" #include "chipset.h" -#include "hooks.h" -#include "usb_mux.h" -#include "system.h" #include "driver/charger/sm5803.h" #include "driver/tcpm/it83xx_pd.h" #include "driver/tcpm/ps8xxx_public.h" #include "driver/tcpm/tcpci.h" - +#include "hooks.h" #include "nissa_common.h" +#include "system.h" +#include "usb_mux.h" + +#include + +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/program/rex/src/board_power.c b/zephyr/program/rex/src/board_power.c index c7f12d024e..655edaa452 100644 --- a/zephyr/program/rex/src/board_power.c +++ b/zephyr/program/rex/src/board_power.c @@ -3,8 +3,11 @@ * found in the LICENSE file. */ -#include +#include "gpio/gpio.h" +#include "gpio_signal.h" + #include +#include #include #include @@ -13,9 +16,6 @@ #include #include -#include "gpio_signal.h" -#include "gpio/gpio.h" - LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF); #if CONFIG_X86_NON_DSX_PWRSEQ_MTL diff --git a/zephyr/program/rex/src/usb_pd_policy.c b/zephyr/program/rex/src/usb_pd_policy.c index 7e9876f9c1..7c78c4ebae 100644 --- a/zephyr/program/rex/src/usb_pd_policy.c +++ b/zephyr/program/rex/src/usb_pd_policy.c @@ -5,8 +5,6 @@ /* Shared USB-C policy for Rex boards */ -#include - #include "charge_manager.h" #include "chipset.h" #include "common.h" @@ -20,6 +18,8 @@ #include "usbc_ppc.h" #include "util.h" +#include + int pd_check_vconn_swap(int port) { /* Allow VCONN swaps if the AP is on. */ diff --git a/zephyr/program/rex/src/usbc_config.c b/zephyr/program/rex/src/usbc_config.c index 66f3a1f45d..6f09887eed 100644 --- a/zephyr/program/rex/src/usbc_config.c +++ b/zephyr/program/rex/src/usbc_config.c @@ -3,16 +3,14 @@ * found in the LICENSE file. */ -#include - #include "battery_fuel_gauge.h" -#include "charger.h" #include "charge_manager.h" #include "charge_ramp.h" -#include "charge_state_v2.h" #include "charge_state.h" +#include "charge_state_v2.h" #include "charger.h" #include "driver/charger/isl9241.h" +#include "driver/ppc/nx20p348x.h" #include "driver/retimer/bb_retimer_public.h" #include "driver/tcpm/nct38xx.h" #include "driver/tcpm/ps8xxx_public.h" @@ -21,13 +19,14 @@ #include "hooks.h" #include "i2c.h" #include "ioexpander.h" -#include "driver/ppc/nx20p348x.h" #include "ppc/syv682x_public.h" #include "system.h" #include "task.h" #include "usb_mux.h" #include "usbc_ppc.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/skyrim/src/frostflow/keyboard_customization.c b/zephyr/program/skyrim/src/frostflow/keyboard_customization.c index d176323d80..bd02940e03 100644 --- a/zephyr/program/skyrim/src/frostflow/keyboard_customization.c +++ b/zephyr/program/skyrim/src/frostflow/keyboard_customization.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "gpio.h" #include "keyboard_customization.h" #include "keyboard_protocol.h" #include "keyboard_raw.h" +#include + static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 }, { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 }, diff --git a/zephyr/program/skyrim/src/frostflow/ppc_config.c b/zephyr/program/skyrim/src/frostflow/ppc_config.c index 6072a788eb..513c025dec 100644 --- a/zephyr/program/skyrim/src/frostflow/ppc_config.c +++ b/zephyr/program/skyrim/src/frostflow/ppc_config.c @@ -5,12 +5,12 @@ /* Frostflow board-specific PPC code */ -#include - -#include "driver/ppc/nx20p348x.h" #include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" #include "usbc_ppc.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/skyrim/src/morthal/ppc_config.c b/zephyr/program/skyrim/src/morthal/ppc_config.c index f3ec1d312e..8108742fdc 100644 --- a/zephyr/program/skyrim/src/morthal/ppc_config.c +++ b/zephyr/program/skyrim/src/morthal/ppc_config.c @@ -5,12 +5,12 @@ /* Morthal board-specific PPC code */ -#include - -#include "driver/ppc/nx20p348x.h" #include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" #include "usbc_ppc.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/skyrim/src/morthal/usb_mux_config.c b/zephyr/program/skyrim/src/morthal/usb_mux_config.c index 8fe76233e2..f4b6502b35 100644 --- a/zephyr/program/skyrim/src/morthal/usb_mux_config.c +++ b/zephyr/program/skyrim/src/morthal/usb_mux_config.c @@ -5,8 +5,6 @@ /* Morthal board-specific USB-C mux configuration */ -#include - #include "console.h" #include "cros_board_info.h" #include "cros_cbi.h" @@ -16,6 +14,8 @@ #include "usb_mux.h" #include "usbc/usb_muxes.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/skyrim/src/power_signals.c b/zephyr/program/skyrim/src/power_signals.c index 5d372d35ae..04ed3d441d 100644 --- a/zephyr/program/skyrim/src/power_signals.c +++ b/zephyr/program/skyrim/src/power_signals.c @@ -7,8 +7,8 @@ #include "charger.h" #include "chipset.h" #include "config.h" -#include "gpio_signal.h" #include "gpio/gpio_int.h" +#include "gpio_signal.h" #include "hooks.h" #include "i2c.h" #include "ioexpander.h" diff --git a/zephyr/program/skyrim/src/skyrim/alt_charger.c b/zephyr/program/skyrim/src/skyrim/alt_charger.c index 4b717901cd..91e5af8426 100644 --- a/zephyr/program/skyrim/src/skyrim/alt_charger.c +++ b/zephyr/program/skyrim/src/skyrim/alt_charger.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "charger_chips.h" #include "common.h" #include "cros_board_info.h" #include "cros_cbi.h" #include "hooks.h" +#include +#include + LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); static void alt_charger_init(void) diff --git a/zephyr/program/skyrim/src/skyrim/fan.c b/zephyr/program/skyrim/src/skyrim/fan.c index 0a368ee6f0..c584022a92 100644 --- a/zephyr/program/skyrim/src/skyrim/fan.c +++ b/zephyr/program/skyrim/src/skyrim/fan.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "cros_board_info.h" #include "cros_cbi.h" #include "fan.h" #include "gpio/gpio.h" #include "hooks.h" +#include +#include +#include + LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); /* diff --git a/zephyr/program/skyrim/src/skyrim/form_factor.c b/zephyr/program/skyrim/src/skyrim/form_factor.c index f137c6db31..b13d905364 100644 --- a/zephyr/program/skyrim/src/skyrim/form_factor.c +++ b/zephyr/program/skyrim/src/skyrim/form_factor.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include "common.h" #include "accelgyro.h" +#include "common.h" #include "cros_board_info.h" #include "hooks.h" #include "motionsense_sensors.h" +#include +#include + LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); /* diff --git a/zephyr/program/skyrim/src/skyrim/ppc_config.c b/zephyr/program/skyrim/src/skyrim/ppc_config.c index bebc8adcc7..047103baee 100644 --- a/zephyr/program/skyrim/src/skyrim/ppc_config.c +++ b/zephyr/program/skyrim/src/skyrim/ppc_config.c @@ -5,12 +5,12 @@ /* Skyrim board-specific PPC code */ -#include - -#include "driver/ppc/nx20p348x.h" #include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" #include "usbc_ppc.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/skyrim/src/skyrim/usb_mux_config.c b/zephyr/program/skyrim/src/skyrim/usb_mux_config.c index 6c65e56d9e..8d409dffdd 100644 --- a/zephyr/program/skyrim/src/skyrim/usb_mux_config.c +++ b/zephyr/program/skyrim/src/skyrim/usb_mux_config.c @@ -5,8 +5,6 @@ /* Skyrim board-specific USB-C mux configuration */ -#include - #include "console.h" #include "cros_board_info.h" #include "cros_cbi.h" @@ -16,6 +14,8 @@ #include "usb_mux.h" #include "usbc/usb_muxes.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/skyrim/src/usb_pd_policy.c b/zephyr/program/skyrim/src/usb_pd_policy.c index ec9f873863..745d95bc00 100644 --- a/zephyr/program/skyrim/src/usb_pd_policy.c +++ b/zephyr/program/skyrim/src/usb_pd_policy.c @@ -5,8 +5,6 @@ /* Shared USB-C policy for Zork boards */ -#include - #include "charge_manager.h" #include "chipset.h" #include "common.h" @@ -20,6 +18,8 @@ #include "usbc_ppc.h" #include "util.h" +#include + int pd_check_vconn_swap(int port) { /* diff --git a/zephyr/program/skyrim/src/usbc_config.c b/zephyr/program/skyrim/src/usbc_config.c index 1795cb2b1e..1b728f1cf0 100644 --- a/zephyr/program/skyrim/src/usbc_config.c +++ b/zephyr/program/skyrim/src/usbc_config.c @@ -5,16 +5,14 @@ /* Skyrim family-specific USB-C configuration */ -#include - -#include "cros_board_info.h" -#include "cros_cbi.h" #include "battery_fuel_gauge.h" #include "charge_manager.h" #include "charge_ramp.h" -#include "charge_state_v2.h" #include "charge_state.h" +#include "charge_state_v2.h" #include "charger.h" +#include "cros_board_info.h" +#include "cros_cbi.h" #include "driver/bc12/pi3usb9201.h" #include "driver/charger/isl9241.h" #include "driver/ppc/nx20p348x.h" @@ -29,8 +27,10 @@ #include "power.h" #include "usb_mux.h" #include "usb_pd_tcpm.h" -#include "usbc_ppc.h" #include "usbc/usb_muxes.h" +#include "usbc_ppc.h" + +#include #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/skyrim/src/winterhold/battery_present.c b/zephyr/program/skyrim/src/winterhold/battery_present.c index eb5a5bba90..290955a242 100644 --- a/zephyr/program/skyrim/src/winterhold/battery_present.c +++ b/zephyr/program/skyrim/src/winterhold/battery_present.c @@ -2,12 +2,12 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "battery.h" #include "battery_smart.h" #include "common.h" +#include + static enum battery_present batt_pres_prev = BP_NOT_SURE; __overridable bool board_battery_is_initialized(void) diff --git a/zephyr/program/skyrim/src/winterhold/kb_backlight.c b/zephyr/program/skyrim/src/winterhold/kb_backlight.c index 049b99e3a1..cbbfc0a4e9 100644 --- a/zephyr/program/skyrim/src/winterhold/kb_backlight.c +++ b/zephyr/program/skyrim/src/winterhold/kb_backlight.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "board_config.h" #include "common.h" #include "cros_board_info.h" #include "cros_cbi.h" +#include +#include + LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); __override uint32_t board_override_feature_flags0(uint32_t flags0) diff --git a/zephyr/program/skyrim/src/winterhold/ppc_config.c b/zephyr/program/skyrim/src/winterhold/ppc_config.c index 72ddb6ce6c..d6adb145ff 100644 --- a/zephyr/program/skyrim/src/winterhold/ppc_config.c +++ b/zephyr/program/skyrim/src/winterhold/ppc_config.c @@ -5,11 +5,11 @@ /* Winterhold board-specific PPC code */ -#include - #include "driver/ppc/nx20p348x.h" #include "usbc_ppc.h" +#include + void ppc_interrupt(enum gpio_signal signal) { switch (signal) { diff --git a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c b/zephyr/program/skyrim/src/winterhold/usb_mux_config.c index 1eff945ed7..19153eb676 100644 --- a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c +++ b/zephyr/program/skyrim/src/winterhold/usb_mux_config.c @@ -5,8 +5,6 @@ /* Winterhold board-specific USB-C mux configuration */ -#include - #include "console.h" #include "cros_board_info.h" #include "cros_cbi.h" @@ -16,6 +14,8 @@ #include "usb_mux.h" #include "usbc/usb_muxes.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/trogdor/lazor/src/i2c.c b/zephyr/program/trogdor/lazor/src/i2c.c index 6d737b410f..e572bbdf37 100644 --- a/zephyr/program/trogdor/lazor/src/i2c.c +++ b/zephyr/program/trogdor/lazor/src/i2c.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "i2c/i2c.h" #include "i2c.h" +#include "i2c/i2c.h" /* Lazor board specific i2c implementation */ diff --git a/zephyr/program/trogdor/lazor/src/power.c b/zephyr/program/trogdor/lazor/src/power.c index 96f9bc43c5..ee99c77196 100644 --- a/zephyr/program/trogdor/lazor/src/power.c +++ b/zephyr/program/trogdor/lazor/src/power.c @@ -3,13 +3,14 @@ * found in the LICENSE file. */ -#include +#include "gpio.h" +#include "power.h" +#include "task.h" + #include +#include #include -#include "power.h" -#include "task.h" -#include "gpio.h" static void board_power_change(struct ap_power_ev_callback *cb, struct ap_power_ev_data data) diff --git a/zephyr/program/trogdor/lazor/src/sku.c b/zephyr/program/trogdor/lazor/src/sku.c index 1d88437031..a6187d422f 100644 --- a/zephyr/program/trogdor/lazor/src/sku.c +++ b/zephyr/program/trogdor/lazor/src/sku.c @@ -7,10 +7,10 @@ #include "config.h" #include "console.h" #include "driver/ln9310.h" -#include "tcpm/ps8xxx_public.h" #include "hooks.h" #include "sku.h" #include "system.h" +#include "tcpm/ps8xxx_public.h" #include "util.h" #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/trogdor/lazor/src/switchcap.c b/zephyr/program/trogdor/lazor/src/switchcap.c index d8205cbcfc..77413fb336 100644 --- a/zephyr/program/trogdor/lazor/src/switchcap.c +++ b/zephyr/program/trogdor/lazor/src/switchcap.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "config.h" #include "console.h" @@ -13,8 +11,10 @@ #include "hooks.h" #include "i2c.h" #include "power/qcom.h" -#include "system.h" #include "sku.h" +#include "system.h" + +#include #define CPRINTS(format, args...) cprints(CC_I2C, format, ##args) #define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args) diff --git a/zephyr/program/trogdor/lazor/src/usb_pd_policy.c b/zephyr/program/trogdor/lazor/src/usb_pd_policy.c index 8d046826f9..32e3376ca0 100644 --- a/zephyr/program/trogdor/lazor/src/usb_pd_policy.c +++ b/zephyr/program/trogdor/lazor/src/usb_pd_policy.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "charge_manager.h" #include "chipset.h" #include "console.h" @@ -13,6 +11,8 @@ #include "usbc_ppc.h" #include "util.h" +#include + #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/trogdor/lazor/src/usbc_config.c b/zephyr/program/trogdor/lazor/src/usbc_config.c index 2e40223c4c..9639b556a0 100644 --- a/zephyr/program/trogdor/lazor/src/usbc_config.c +++ b/zephyr/program/trogdor/lazor/src/usbc_config.c @@ -7,23 +7,23 @@ #include "battery_fuel_gauge.h" #include "bc12/pi3usb9201_public.h" -#include "charger.h" -#include "charger/isl923x_public.h" #include "charge_manager.h" #include "charge_state.h" +#include "charger.h" +#include "charger/isl923x_public.h" #include "common.h" #include "config.h" #include "driver/ln9310.h" -#include "gpio_signal.h" #include "gpio/gpio_int.h" +#include "gpio_signal.h" #include "hooks.h" #include "ppc/sn5s330_public.h" #include "system.h" #include "tcpm/ps8xxx_public.h" #include "tcpm/tcpci.h" #include "timer.h" -#include "usb_pd.h" #include "usb_mux.h" +#include "usb_pd.h" #include "usbc_ocp.h" #include "usbc_ppc.h" -- cgit v1.2.1 From dd187c5173e956c7aa50a2773101e3bd89615704 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 11:02:37 -0700 Subject: zephyr/program/nissa: Fix copyright header Remove extra . BRANCH=None BUG=None TEST=None Signed-off-by: Jeremy Bettis Change-Id: I0a98da4b1a5a81b5a2dba403cc5df3247a0da9bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043354 Auto-Submit: Jeremy Bettis Commit-Queue: Jeremy Bettis Commit-Queue: Aaron Massey Code-Coverage: Zoss Reviewed-by: Aaron Massey Tested-by: Jeremy Bettis --- zephyr/program/nissa/yaviks/src/thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/program/nissa/yaviks/src/thermal.c b/zephyr/program/nissa/yaviks/src/thermal.c index 4522f8bd09..a22a9a74c0 100644 --- a/zephyr/program/nissa/yaviks/src/thermal.c +++ b/zephyr/program/nissa/yaviks/src/thermal.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -- cgit v1.2.1 From dc0c0f58c43ab49da69765c30e138476f21e7385 Mon Sep 17 00:00:00 2001 From: Chao Gui Date: Fri, 18 Nov 2022 14:36:08 -0800 Subject: crystaldrift : Initial EC image Create the initial Zephyr EC image for the crystaldrift variant by copying the skyrim reference board EC files. More changes will be added later. LOW_COVERAGE_REASON=New device specific configuration BUG=b:259442793 BRANCH=none TEST=zmake build crystaldrift Signed-off-by: Chao Gui Change-Id: I50aa05e2ce7e2e67b25382656dbed7de249a6f42 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4038788 Code-Coverage: Zoss Reviewed-by: Diana Z Tested-by: Chao Gui Commit-Queue: Chao Gui --- zephyr/program/skyrim/BUILD.py | 14 ++ zephyr/program/skyrim/CMakeLists.txt | 12 ++ zephyr/program/skyrim/Kconfig | 6 + zephyr/program/skyrim/battery_crystaldrift.dts | 15 ++ zephyr/program/skyrim/crystaldrift.dts | 207 +++++++++++++++++++++ zephyr/program/skyrim/led_pins_crystaldrift.dts | 63 +++++++ zephyr/program/skyrim/led_policy_crystaldrift.dts | 103 ++++++++++ zephyr/program/skyrim/motionsense_crystaldrift.dts | 135 ++++++++++++++ zephyr/program/skyrim/prj_crystaldrift.conf | 26 +++ .../program/skyrim/src/crystaldrift/alt_charger.c | 31 +++ zephyr/program/skyrim/src/crystaldrift/fan.c | 62 ++++++ .../program/skyrim/src/crystaldrift/form_factor.c | 37 ++++ .../program/skyrim/src/crystaldrift/ppc_config.c | 46 +++++ .../skyrim/src/crystaldrift/usb_mux_config.c | 142 ++++++++++++++ 14 files changed, 899 insertions(+) create mode 100644 zephyr/program/skyrim/battery_crystaldrift.dts create mode 100644 zephyr/program/skyrim/crystaldrift.dts create mode 100644 zephyr/program/skyrim/led_pins_crystaldrift.dts create mode 100644 zephyr/program/skyrim/led_policy_crystaldrift.dts create mode 100644 zephyr/program/skyrim/motionsense_crystaldrift.dts create mode 100644 zephyr/program/skyrim/prj_crystaldrift.conf create mode 100644 zephyr/program/skyrim/src/crystaldrift/alt_charger.c create mode 100644 zephyr/program/skyrim/src/crystaldrift/fan.c create mode 100644 zephyr/program/skyrim/src/crystaldrift/form_factor.c create mode 100644 zephyr/program/skyrim/src/crystaldrift/ppc_config.c create mode 100644 zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c diff --git a/zephyr/program/skyrim/BUILD.py b/zephyr/program/skyrim/BUILD.py index 5eb2f01503..654c2bf630 100644 --- a/zephyr/program/skyrim/BUILD.py +++ b/zephyr/program/skyrim/BUILD.py @@ -87,3 +87,17 @@ register_skyrim_project( here / "prj_frostflow.conf", ], ) + +register_skyrim_project( + project_name="crystaldrift", + extra_dts_overlays=[ + here / "crystaldrift.dts", + here / "battery_crystaldrift.dts", + here / "led_pins_crystaldrift.dts", + here / "led_policy_crystaldrift.dts", + here / "motionsense_crystaldrift.dts", + ], + extra_kconfig_files=[ + here / "prj_crystaldrift.conf", + ], +) diff --git a/zephyr/program/skyrim/CMakeLists.txt b/zephyr/program/skyrim/CMakeLists.txt index cf357a4a0a..7291ad93ce 100644 --- a/zephyr/program/skyrim/CMakeLists.txt +++ b/zephyr/program/skyrim/CMakeLists.txt @@ -62,3 +62,15 @@ if(DEFINED CONFIG_BOARD_FROSTFLOW) "src/frostflow/keyboard.c" "src/frostflow/keyboard_customization.c") endif() + +if(DEFINED CONFIG_BOARD_CRYSTALDRIFT) + project(crystaldrift) + cros_ec_library_include_directories_ifdef(CONFIG_BOARD_CRYSTALDRIFT include) + zephyr_library_sources( + "src/crystaldrift/usb_mux_config.c" + "src/crystaldrift/ppc_config.c" + "src/crystaldrift/form_factor.c" + "src/crystaldrift/alt_charger.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/crystaldrift/fan.c") +endif() \ No newline at end of file diff --git a/zephyr/program/skyrim/Kconfig b/zephyr/program/skyrim/Kconfig index 896958e446..a80ba2bd24 100644 --- a/zephyr/program/skyrim/Kconfig +++ b/zephyr/program/skyrim/Kconfig @@ -26,6 +26,12 @@ config BOARD_FROSTFLOW Build Google Frostflow reference board. This board uses an AMD SoC and NPCX9 EC +config BOARD_CRYSTALDRIFT + bool "Google Crystaldrift Board" + help + Build Google Crystaldrift reference board. This board uses an AMD SoC + and NPCX9 EC + config BOARD_USB_HUB_RESET bool "Support USB hub reset or not" default y diff --git a/zephyr/program/skyrim/battery_crystaldrift.dts b/zephyr/program/skyrim/battery_crystaldrift.dts new file mode 100644 index 0000000000..6b1799c233 --- /dev/null +++ b/zephyr/program/skyrim/battery_crystaldrift.dts @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift.dts b/zephyr/program/skyrim/crystaldrift.dts new file mode 100644 index 0000000000..b74136172a --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift.dts @@ -0,0 +1,207 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "i2c_common.dtsi" + +/ { + named-gpios { + /* Crystaldrift-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <35>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + crystaldrift-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + + charger-option { + enum-name = "FW_CHARGER"; + start = <11>; + size = <2>; + + charger-option-isl9241 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9241"; + value = <0>; + default; + }; + charger-option-isl9538 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9538"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + alt_charger: isl9538@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + chg_alt = <&alt_charger>; + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/led_pins_crystaldrift.dts b/zephyr/program/skyrim/led_pins_crystaldrift.dts new file mode 100644 index 0000000000..d294490208 --- /dev/null +++ b/zephyr/program/skyrim/led_pins_crystaldrift.dts @@ -0,0 +1,63 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwm_pins { + compatible = "cros-ec,pwm-pin-config"; + + pwm_y: pwm_y { + #led-pin-cells = <1>; + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + + pwm_w: pwm_w { + #led-pin-cells = <1>; + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&pwm_y 0>, + <&pwm_w 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pins = <&pwm_y 100>, + <&pwm_w 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pins = <&pwm_y 0>, + <&pwm_w 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/led_policy_crystaldrift.dts b/zephyr/program/skyrim/led_policy_crystaldrift.dts new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/led_policy_crystaldrift.dts @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/motionsense_crystaldrift.dts b/zephyr/program/skyrim/motionsense_crystaldrift.dts new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/motionsense_crystaldrift.dts @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/prj_crystaldrift.conf b/zephyr/program/skyrim/prj_crystaldrift.conf new file mode 100644 index 0000000000..e9339c1c3c --- /dev/null +++ b/zephyr/program/skyrim/prj_crystaldrift.conf @@ -0,0 +1,26 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Crystaldrift reference-board-specific Kconfig settings. +CONFIG_BOARD_CRYSTALDRIFT=y + +# CBI WP pin present +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Crystaldrfit is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable alternative charger chip +CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/src/crystaldrift/alt_charger.c b/zephyr/program/skyrim/src/crystaldrift/alt_charger.c new file mode 100644 index 0000000000..992215161c --- /dev/null +++ b/zephyr/program/skyrim/src/crystaldrift/alt_charger.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "charger_chips.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "hooks.h" + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +static void alt_charger_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FW_CHARGER, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); + return; + } + + if (val == FW_CHARGER_ISL9538) + CHG_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/src/crystaldrift/fan.c b/zephyr/program/skyrim/src/crystaldrift/fan.c new file mode 100644 index 0000000000..01416616c2 --- /dev/null +++ b/zephyr/program/skyrim/src/crystaldrift/fan.c @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Skyrim fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + uint32_t board_version; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + + ret = cbi_get_board_version(&board_version); + if (ret != EC_SUCCESS) { + LOG_ERR("Error retrieving CBI board version"); + return; + } + + if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { + /* Disable the fan */ + fan_set_count(0); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); + +/* + * Pcore OCP support + * Note: early boards should note enable this interrupt as they are not + * correctly configured for it. + */ +__override bool board_supports_pcore_ocp(void) +{ + uint32_t board_version; + + if (cbi_get_board_version(&board_version) == EC_SUCCESS && + board_version > 3) + return true; + + return false; +} diff --git a/zephyr/program/skyrim/src/crystaldrift/form_factor.c b/zephyr/program/skyrim/src/crystaldrift/form_factor.c new file mode 100644 index 0000000000..b9cfe9890e --- /dev/null +++ b/zephyr/program/skyrim/src/crystaldrift/form_factor.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include "common.h" +#include "accelgyro.h" +#include "cros_board_info.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) +#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + /* + * If the board version >=4 + * use ver1 rotation matrix. + */ + ret = cbi_get_board_version(&val); + if (ret == EC_SUCCESS && val >= 4) { + LOG_INF("Switching to ver1 lid"); + motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/src/crystaldrift/ppc_config.c b/zephyr/program/skyrim/src/crystaldrift/ppc_config.c new file mode 100644 index 0000000000..423824b1a6 --- /dev/null +++ b/zephyr/program/skyrim/src/crystaldrift/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Crystaldrift board-specific PPC code */ + +#include + +#include "driver/ppc/nx20p348x.h" +#include "driver/ppc/aoz1380_public.h" +#include "usbc_ppc.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c b/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c new file mode 100644 index 0000000000..9ea3df3e39 --- /dev/null +++ b/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Crystaldrift board-specific USB-C mux configuration */ + +#include + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); -- cgit v1.2.1 From 5f10481142e0c2166532ebbaf419539a5670e26d Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Mon, 21 Nov 2022 09:26:34 -0700 Subject: twister: RDB expects duration to be populated in unit of seconds Populate RDB duration in units of seconds BUG=None BRANCH=NONE TEST=./twister -T zephyr/test Signed-off-by: Al Semjonovs Change-Id: I4dc8c9c2ea8e6620940979f035e1271cab77b13b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043342 Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- util/zephyr_to_resultdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py index 438a3cd4d1..722c5b0323 100755 --- a/util/zephyr_to_resultdb.py +++ b/util/zephyr_to_resultdb.py @@ -50,7 +50,7 @@ def translate_duration(testcase): if not time: return None - return f"{time}ms" + return f"{float(time)/1000:.9f}s" def testcase_summary(testcase): -- cgit v1.2.1 From 3a23edc42f236a11f7c220bdc4dc35e096583ece Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 10:49:54 -0700 Subject: zephyr/test: IWUY Add missing header fakes.h uses uint64_t and needs stdint.h BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ie60703f90272edd72cb8c3fed0bdbafb38915040 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043352 Commit-Queue: Al Semjonovs Auto-Submit: Jeremy Bettis Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Reviewed-by: Al Semjonovs --- zephyr/test/system_shim/include/fakes.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zephyr/test/system_shim/include/fakes.h b/zephyr/test/system_shim/include/fakes.h index 80da06a313..29031a10b7 100644 --- a/zephyr/test/system_shim/include/fakes.h +++ b/zephyr/test/system_shim/include/fakes.h @@ -6,6 +6,8 @@ #ifndef ZEPHYR_TEST_SYSTEM_SHIM_INCLUDE_FAKES_H_ #define ZEPHYR_TEST_SYSTEM_SHIM_INCLUDE_FAKES_H_ +#include + #include DECLARE_FAKE_VALUE_FUNC(int, cros_system_native_posix_get_reset_cause, -- cgit v1.2.1 From 37b812ec24e86025c281cfbc437e7b24d3456eff Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 14:34:27 -0700 Subject: zmake: Run compare-builds in parallel We were building just one commit at a time when doing compare builds. Add flag to configure() to wait for the executor, and disable that in compare builds. BRANCH=None BUG=None TEST=Ran zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I9a152f88372140810146bd360c4df518dec39e13 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043731 Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Commit-Queue: Jack Rosenthal Commit-Queue: Keith Short Reviewed-by: Keith Short Reviewed-by: Jack Rosenthal Code-Coverage: Zoss Commit-Queue: Jeremy Bettis --- zephyr/zmake/zmake/zmake.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py index 963b1b4f44..fb88dae7e9 100644 --- a/zephyr/zmake/zmake/zmake.py +++ b/zephyr/zmake/zmake/zmake.py @@ -240,6 +240,7 @@ class Zmake: delete_intermediates=False, static_version=False, save_temps=False, + wait_for_executor=True, ): """Locate and configure the specified projects.""" # Resolve build_dir if needed. @@ -275,11 +276,11 @@ class Zmake: result = self.executor.wait() if result: return result - result = self.executor.wait() - if result: - return result non_test_projects = [p for p in projects if not p.config.is_test] if len(non_test_projects) > 1 and coverage and build_after_configure: + result = self.executor.wait() + if result: + return result result = self._merge_lcov_files( projects=non_test_projects, build_dir=build_dir, @@ -288,6 +289,11 @@ class Zmake: if result: self.failed_projects.append(str(build_dir / "all_builds.info")) return result + elif wait_for_executor: + result = self.executor.wait() + if result: + return result + return 0 def build( @@ -381,8 +387,10 @@ class Zmake: delete_intermediates=False, static_version=True, save_temps=False, + wait_for_executor=False, ) - + if not result: + result = self.executor.wait() if result: self.logger.error( "compare-builds failed to build all projects at %s", -- cgit v1.2.1 From 0d12d559931c1e47d1693cd28d1005f4a168b50b Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Tue, 15 Nov 2022 16:47:14 -0700 Subject: zephyr test: Verify pd bistsharemode arg checking Verify that 'pd bistsharemode' console command checks its arguments. BUG=b:236074634 TEST=twister -s zephyr/test/drivers/drivers.default BRANCH=none Change-Id: I412782a99a5c67dde73d2d6c5d9076a67a13edca Signed-off-by: Abe Levkoy Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029596 Code-Coverage: Zoss Reviewed-by: Simon Glass --- zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c index 8e40f9ec2a..ac3ece0082 100644 --- a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c +++ b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c @@ -188,6 +188,10 @@ ZTEST_USER(console_cmd_usb_pd, test_bistsharemode) rv = shell_execute_cmd(get_ec_shell(), "pd bistsharemode disable"); zassert_equal(rv, EC_SUCCESS, "Expected %d, but got %d", EC_SUCCESS, rv); + + rv = shell_execute_cmd(get_ec_shell(), "pd bistsharemode foo"); + zassert_equal(rv, EC_ERROR_PARAM2, "Expected %d, but got %d", + EC_ERROR_PARAM2, rv); } ZTEST_USER(console_cmd_usb_pd, test_hard) -- cgit v1.2.1 From 2e289a5e4366001abcb414b0d29d835c6c29fb9e Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Fri, 18 Nov 2022 16:44:15 -0700 Subject: zephyr: Sort header files Sort all headers in zephyr with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ic4431f9354cfb87b8357e6288f651aaef8a50f7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043353 Reviewed-by: Simon Glass Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Code-Coverage: Zoss --- zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c | 7 ++++--- zephyr/app/ec/ec_app_main.c | 10 +++++----- zephyr/app/ec/main_shim.c | 3 ++- zephyr/emul/tcpc/emul_ps8xxx.c | 2 +- zephyr/emul/tcpc/emul_tcpci.c | 3 +-- zephyr/emul/tcpc/emul_tcpci_generic.c | 3 +-- zephyr/emul/tcpc/emul_tcpci_partner_common.c | 3 +-- zephyr/emul/tcpc/emul_tcpci_partner_drp.c | 3 +-- zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c | 3 +-- zephyr/emul/tcpc/emul_tcpci_partner_snk.c | 3 +-- zephyr/emul/tcpc/emul_tcpci_partner_src.c | 3 +-- zephyr/include/drivers/cros_flash.h | 2 +- zephyr/include/drivers/cros_kb_raw.h | 6 +++--- zephyr/include/drivers/cros_rtc.h | 2 +- zephyr/include/drivers/cros_shi.h | 2 +- zephyr/include/drivers/cros_system.h | 2 +- zephyr/include/emul/emul_isl923x.h | 2 +- zephyr/include/emul/emul_ln9310.h | 4 +++- zephyr/include/emul/emul_pct2075.h | 3 ++- zephyr/include/emul/emul_smart_battery.h | 7 ++++--- zephyr/include/emul/emul_syv682x.h | 3 ++- zephyr/include/emul/tcpc/emul_tcpci.h | 5 +++-- zephyr/include/emul/tcpc/emul_tcpci_partner_common.h | 13 +++++++------ zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h | 3 ++- zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h | 3 ++- zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h | 5 +++-- zephyr/include/emul/tcpc/emul_tcpci_partner_src.h | 5 +++-- zephyr/mock/power.c | 7 +++---- zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h | 1 + zephyr/subsys/ap_pwrseq/power_signals.c | 10 +++++----- zephyr/subsys/ap_pwrseq/signal_gpio.c | 6 ++++-- zephyr/subsys/ap_pwrseq/signal_vw.c | 7 ++++--- .../subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c | 4 +++- .../ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c | 5 +++-- zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c | 16 ++++++++-------- .../drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c | 10 +++++----- zephyr/test/drivers/default/src/chipset.c | 8 ++++---- zephyr/test/drivers/memmap/src/main.c | 9 +++++---- zephyr/test/jump_tags/src/jump_tags.c | 11 ++++++----- zephyr/test/system_shim/src/no_chosen.c | 4 ++-- zephyr/test/system_shim/src/suite.c | 4 ++-- 41 files changed, 113 insertions(+), 99 deletions(-) diff --git a/zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c b/zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c index 6109964cb9..3c623b5aac 100644 --- a/zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c +++ b/zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c @@ -2,12 +2,13 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include -#include -#include #include #include +#include +#include +#include + LOG_MODULE_REGISTER(ec_chip_it8xxx2_espi, CONFIG_ESPI_LOG_LEVEL); /* diff --git a/zephyr/app/ec/ec_app_main.c b/zephyr/app/ec/ec_app_main.c index 9b13c8ab86..4ab5fd3a44 100644 --- a/zephyr/app/ec/ec_app_main.c +++ b/zephyr/app/ec/ec_app_main.c @@ -3,14 +3,11 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "ap_power/ap_pwrseq.h" #include "button.h" #include "chipset.h" #include "cros_board_info.h" +#include "ec_app_main.h" #include "ec_tasks.h" #include "hooks.h" #include "keyboard_scan.h" @@ -19,7 +16,10 @@ #include "vboot.h" #include "watchdog.h" #include "zephyr_espi_shim.h" -#include "ec_app_main.h" + +#include +#include +#include /* For testing purposes this is not named main. See main_shim.c for the real * main() function. diff --git a/zephyr/app/ec/main_shim.c b/zephyr/app/ec/main_shim.c index a14cff2dcb..0ec92b70bf 100644 --- a/zephyr/app/ec/main_shim.c +++ b/zephyr/app/ec/main_shim.c @@ -3,10 +3,11 @@ * found in the LICENSE file. */ -#include #include "ec_app_main.h" #include "host_command.h" +#include + /** A stub main to call the real ec app main function. LCOV_EXCL_START */ void main(void) { diff --git a/zephyr/emul/tcpc/emul_ps8xxx.c b/zephyr/emul/tcpc/emul_ps8xxx.c index af4dee4960..90b9ce7af3 100644 --- a/zephyr/emul/tcpc/emul_ps8xxx.c +++ b/zephyr/emul/tcpc/emul_ps8xxx.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include #include "driver/tcpm/ps8xxx.h" #include "emul/emul_common_i2c.h" #include "emul/emul_stub_device.h" @@ -15,6 +14,7 @@ #include #include #include +#include #include #define DT_DRV_COMPAT cros_ps8xxx_emul diff --git a/zephyr/emul/tcpc/emul_tcpci.c b/zephyr/emul/tcpc/emul_tcpci.c index f444584344..e5dcf78bdc 100644 --- a/zephyr/emul/tcpc/emul_tcpci.c +++ b/zephyr/emul/tcpc/emul_tcpci.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "emul/emul_common_i2c.h" #include "emul/tcpc/emul_tcpci.h" #include "tcpm/tcpci.h" @@ -14,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/zephyr/emul/tcpc/emul_tcpci_generic.c b/zephyr/emul/tcpc/emul_tcpci_generic.c index fcb453de38..01fae7c978 100644 --- a/zephyr/emul/tcpc/emul_tcpci_generic.c +++ b/zephyr/emul/tcpc/emul_tcpci_generic.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "emul/emul_common_i2c.h" #include "emul/emul_stub_device.h" #include "emul/tcpc/emul_tcpci.h" @@ -14,6 +12,7 @@ #include #include #include +#include #include #define DT_DRV_COMPAT cros_tcpci_generic_emul diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c index 40dbb4682a..db3441716c 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" @@ -14,6 +12,7 @@ #include #include +#include #include #include diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_drp.c b/zephyr/emul/tcpc/emul_tcpci_partner_drp.c index 80f9baf97b..45fa21d972 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_drp.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_drp.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" @@ -15,6 +13,7 @@ #include "usb_pd.h" #include +#include #include LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c b/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c index 47580a0f33..f2920ba20c 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" @@ -12,6 +10,7 @@ #include "usb_pd.h" #include +#include #include LOG_MODULE_REGISTER(tcpci_faulty_ext, CONFIG_TCPCI_EMUL_LOG_LEVEL); diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c index c8719086f7..d14012af41 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" @@ -12,6 +10,7 @@ #include "usb_pd.h" #include +#include #include LOG_MODULE_REGISTER(tcpci_snk_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_src.c b/zephyr/emul/tcpc/emul_tcpci_partner_src.c index 142254ec35..7f4245fa6f 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_src.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_src.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" @@ -12,6 +10,7 @@ #include "usb_pd.h" #include +#include #include LOG_MODULE_REGISTER(tcpci_src_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); diff --git a/zephyr/include/drivers/cros_flash.h b/zephyr/include/drivers/cros_flash.h index 267649476b..d7078cfb83 100644 --- a/zephyr/include/drivers/cros_flash.h +++ b/zephyr/include/drivers/cros_flash.h @@ -16,8 +16,8 @@ #ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_ #define ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_ -#include #include +#include /** * @brief CROS Flash Driver APIs diff --git a/zephyr/include/drivers/cros_kb_raw.h b/zephyr/include/drivers/cros_kb_raw.h index cbf461866c..7b9255bb9f 100644 --- a/zephyr/include/drivers/cros_kb_raw.h +++ b/zephyr/include/drivers/cros_kb_raw.h @@ -22,11 +22,11 @@ #ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_KB_RAW_H_ #define ZEPHYR_INCLUDE_DRIVERS_CROS_KB_RAW_H_ -#include +#include "gpio_signal.h" + #include #include - -#include "gpio_signal.h" +#include /* * When CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED is enabled, the keyboard diff --git a/zephyr/include/drivers/cros_rtc.h b/zephyr/include/drivers/cros_rtc.h index 3a0f332b98..540391aac6 100644 --- a/zephyr/include/drivers/cros_rtc.h +++ b/zephyr/include/drivers/cros_rtc.h @@ -16,8 +16,8 @@ #ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_RTC_H_ #define ZEPHYR_INCLUDE_DRIVERS_CROS_RTC_H_ -#include #include +#include /** * @brief CROS Real-Time Clock (RTC) Driver APIs diff --git a/zephyr/include/drivers/cros_shi.h b/zephyr/include/drivers/cros_shi.h index 3eb3038a45..2ec2d2233a 100644 --- a/zephyr/include/drivers/cros_shi.h +++ b/zephyr/include/drivers/cros_shi.h @@ -18,8 +18,8 @@ * @{ */ -#include #include +#include /** * @cond INTERNAL_HIDDEN diff --git a/zephyr/include/drivers/cros_system.h b/zephyr/include/drivers/cros_system.h index 5105d97cc9..c098c2cfcd 100644 --- a/zephyr/include/drivers/cros_system.h +++ b/zephyr/include/drivers/cros_system.h @@ -18,8 +18,8 @@ * @{ */ -#include #include +#include /** * @brief system_reset_cause enum diff --git a/zephyr/include/emul/emul_isl923x.h b/zephyr/include/emul/emul_isl923x.h index e41cf26f87..7d085658cf 100644 --- a/zephyr/include/emul/emul_isl923x.h +++ b/zephyr/include/emul/emul_isl923x.h @@ -7,8 +7,8 @@ #define ZEPHYR_INCLUDE_EMUL_EMUL_ISL923X_H_ #include -#include #include +#include /** * @brief Get the emulator's parent bus device diff --git a/zephyr/include/emul/emul_ln9310.h b/zephyr/include/emul/emul_ln9310.h index 0c0e61003e..5d0cab9c20 100644 --- a/zephyr/include/emul/emul_ln9310.h +++ b/zephyr/include/emul/emul_ln9310.h @@ -12,10 +12,12 @@ #ifndef ZEPHYR_INCLUDE_EMUL_EMUL_LN9310_H_ #define ZEPHYR_INCLUDE_EMUL_EMUL_LN9310_H_ -#include #include "driver/ln9310.h" + #include +#include + /** * @brief Select the current emulator to use. * diff --git a/zephyr/include/emul/emul_pct2075.h b/zephyr/include/emul/emul_pct2075.h index 0c62942a20..f9e1ef60b2 100644 --- a/zephyr/include/emul/emul_pct2075.h +++ b/zephyr/include/emul/emul_pct2075.h @@ -6,9 +6,10 @@ #ifndef EMUL_PCT2075_H #define EMUL_PCT2075_H -#include #include "emul/emul_common_i2c.h" +#include + #define PCT2075_REG_NUMBER 5 struct pct2075_data { diff --git a/zephyr/include/emul/emul_smart_battery.h b/zephyr/include/emul/emul_smart_battery.h index 826e817992..35018f37f7 100644 --- a/zephyr/include/emul/emul_smart_battery.h +++ b/zephyr/include/emul/emul_smart_battery.h @@ -12,12 +12,13 @@ #ifndef __EMUL_SMART_BATTERY_H #define __EMUL_SMART_BATTERY_H +#include "emul/emul_common_i2c.h" + +#include + #include #include #include -#include - -#include "emul/emul_common_i2c.h" /** * @brief Smart Battery emulator backend API diff --git a/zephyr/include/emul/emul_syv682x.h b/zephyr/include/emul/emul_syv682x.h index 78ee2406eb..3e4328323e 100644 --- a/zephyr/include/emul/emul_syv682x.h +++ b/zephyr/include/emul/emul_syv682x.h @@ -11,9 +11,10 @@ #ifndef __EMUL_SYV682X_H #define __EMUL_SYV682X_H -#include #include +#include + /* Register info copied from syv682.h */ /* SYV682x register addresses */ diff --git a/zephyr/include/emul/tcpc/emul_tcpci.h b/zephyr/include/emul/tcpc/emul_tcpci.h index 8175b9ce96..8badf7dbc4 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci.h +++ b/zephyr/include/emul/tcpc/emul_tcpci.h @@ -12,12 +12,13 @@ #ifndef __EMUL_TCPCI_H #define __EMUL_TCPCI_H +#include "emul/emul_common_i2c.h" + #include #include #include -#include -#include "emul/emul_common_i2c.h" +#include /** * Number of emulated register. This include vendor registers defined in TCPCI diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h index f232724ece..36071bc7d3 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h @@ -12,16 +12,17 @@ #ifndef __EMUL_TCPCI_PARTNER_COMMON_H #define __EMUL_TCPCI_PARTNER_COMMON_H -#include -#include -#include -#include -#include - #include "ec_commands.h" #include "emul/tcpc/emul_tcpci.h" #include "usb_pd.h" +#include +#include + +#include +#include +#include + /** * @brief Common code used by TCPCI partner device emulators * @defgroup tcpci_partner Common code for TCPCI partner device emulators diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h index e4f58fcd37..cacb4e6270 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h @@ -12,13 +12,14 @@ #ifndef __EMUL_TCPCI_PARTNER_DRP_H #define __EMUL_TCPCI_PARTNER_DRP_H -#include #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "usb_pd.h" +#include + /** * @brief USB-C dual role device extension backend API * @defgroup tcpci_snk_emul USB-C dual role device extension diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h index f0627c95bd..317e9817d4 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h @@ -12,11 +12,12 @@ #ifndef __EMUL_TCPCI_PARTNER_FAULTY_EXT_H #define __EMUL_TCPCI_PARTNER_FAULTY_EXT_H -#include #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "usb_pd.h" +#include + /** * @brief USB-C malfunctioning device extension backend API * @defgroup tcpci_faulty_ext USB-C malfunctioning device extension diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h index 584458942b..edf09d25eb 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h @@ -12,11 +12,12 @@ #ifndef __EMUL_TCPCI_PARTNER_SNK_H #define __EMUL_TCPCI_PARTNER_SNK_H -#include -#include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_common.h" #include "usb_pd.h" +#include + /** * @brief USB-C sink device extension backend API * @defgroup tcpci_snk_emul USB-C sink device extension diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_src.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_src.h index e72d0e4135..7ce14da82a 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_src.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_src.h @@ -12,11 +12,12 @@ #ifndef __EMUL_TCPCI_PARTNER_SRC_H #define __EMUL_TCPCI_PARTNER_SRC_H -#include -#include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_common.h" #include "usb_pd.h" +#include + /** * @brief USB-C source device extension backend API * @defgroup tcpci_src_emul USB-C source device extension diff --git a/zephyr/mock/power.c b/zephyr/mock/power.c index 73f93ce3b5..b0de50a30e 100644 --- a/zephyr/mock/power.c +++ b/zephyr/mock/power.c @@ -3,16 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "hooks.h" #include "lid_switch.h" +#include "mock/power.h" #include "power.h" #include "task.h" #include "util.h" -#include "mock/power.h" +#include +#include LOG_MODULE_REGISTER(mock_power); diff --git a/zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h b/zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h index dcb2b3b968..75390b5005 100644 --- a/zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h +++ b/zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h @@ -7,6 +7,7 @@ #define __X86_COMMON_PWRSEQ_H__ #include + #include #include #include diff --git a/zephyr/subsys/ap_pwrseq/power_signals.c b/zephyr/subsys/ap_pwrseq/power_signals.c index a02eef6e6b..1ae8604a3a 100644 --- a/zephyr/subsys/ap_pwrseq/power_signals.c +++ b/zephyr/subsys/ap_pwrseq/power_signals.c @@ -3,18 +3,18 @@ * found in the LICENSE file. */ +#include "signal_adc.h" +#include "signal_gpio.h" +#include "signal_vw.h" + #include -#include #include #include +#include #include #include -#include "signal_gpio.h" -#include "signal_vw.h" -#include "signal_adc.h" - LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL); #if DT_HAS_COMPAT_STATUS_OKAY(intel_ap_pwrseq) diff --git a/zephyr/subsys/ap_pwrseq/signal_gpio.c b/zephyr/subsys/ap_pwrseq/signal_gpio.c index 1dbd430bef..f09f6b23cb 100644 --- a/zephyr/subsys/ap_pwrseq/signal_gpio.c +++ b/zephyr/subsys/ap_pwrseq/signal_gpio.c @@ -3,10 +3,12 @@ * found in the LICENSE file. */ +#include "system.h" + +#include + #include #include -#include -#include "system.h" #define MY_COMPAT intel_ap_pwrseq_gpio diff --git a/zephyr/subsys/ap_pwrseq/signal_vw.c b/zephyr/subsys/ap_pwrseq/signal_vw.c index 0e9e4affff..cee88e362d 100644 --- a/zephyr/subsys/ap_pwrseq/signal_vw.c +++ b/zephyr/subsys/ap_pwrseq/signal_vw.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -#include +#include "signal_vw.h" + #include -#include -#include "signal_vw.h" +#include +#include #define MY_COMPAT intel_ap_pwrseq_vw diff --git a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c index dbceeacc85..6ac2b5e0ba 100644 --- a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c +++ b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c @@ -3,8 +3,10 @@ * found in the LICENSE file. */ -#include #include + +#include + #include LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL); diff --git a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c index 09846759ee..55f1414a4b 100644 --- a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c +++ b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c @@ -3,11 +3,12 @@ * found in the LICENSE file. */ -#include +#include "zephyr_console_shim.h" + #include +#include #include -#include "zephyr_console_shim.h" static K_KERNEL_STACK_DEFINE(pwrseq_thread_stack, CONFIG_AP_PWRSEQ_STACK_SIZE); static struct k_thread pwrseq_thread_data; diff --git a/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c b/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c index 9f68a18bdc..e8f211bb56 100644 --- a/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c +++ b/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c @@ -3,21 +3,21 @@ * found in the LICENSE file. */ -#include -#include -#include -#include -#include -#include - #include "ap_power/ap_power.h" #include "ap_power/ap_power_events.h" -#include #include "chipset.h" #include "emul/emul_power_signals.h" #include "power_signals.h" #include "test_state.h" +#include +#include +#include +#include +#include +#include +#include + LOG_MODULE_REGISTER(emul_power_signal, CONFIG_EMUL_POWER_SIGNALS_LOG_LEVEL); /** diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c index b2c69c712a..959684c23b 100644 --- a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c +++ b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c @@ -3,17 +3,17 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "gpio_signal.h" #include "task.h" #include "test/drivers/test_state.h" #include "test/drivers/utils.h" #include "usb_charge.h" +#include +#include +#include +#include + /* Get reference to externally linked handlers (defined in DTS) */ #define USBC0_GPIO_PATH DT_PATH(named_gpios, usb_c0_bc12_int_l) #define USBC0_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC0_GPIO_PATH, gpios)) diff --git a/zephyr/test/drivers/default/src/chipset.c b/zephyr/test/drivers/default/src/chipset.c index 83dba6c768..fc62135622 100644 --- a/zephyr/test/drivers/default/src/chipset.c +++ b/zephyr/test/drivers/default/src/chipset.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include -#include - #include "chipset.h" - #include "test/drivers/test_state.h" +#include + +#include + ZTEST(chipset, test_get_ap_reset_stats__bad_pointers) { zassert_equal(EC_ERROR_INVAL, get_ap_reset_stats(NULL, 0, NULL)); diff --git a/zephyr/test/drivers/memmap/src/main.c b/zephyr/test/drivers/memmap/src/main.c index 67c27b5c8d..89ea2c52cd 100644 --- a/zephyr/test/drivers/memmap/src/main.c +++ b/zephyr/test/drivers/memmap/src/main.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "flash.h" #include "host_command.h" #include "test/drivers/test_state.h" +#include +#include + +#include + extern const char *flash_physical_dataptr_override; static char flash[CONFIG_FLASH_SIZE_BYTES]; diff --git a/zephyr/test/jump_tags/src/jump_tags.c b/zephyr/test/jump_tags/src/jump_tags.c index 5811f11648..a2a377bb35 100644 --- a/zephyr/test/jump_tags/src/jump_tags.c +++ b/zephyr/test/jump_tags/src/jump_tags.c @@ -3,16 +3,17 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "ec_commands.h" #include "hooks.h" #include "host_command.h" #include "sysjump.h" -#include "system_fake.h" #include "system.h" +#include "system_fake.h" + +#include + +#include +#include #define TEST_BASIC_JUMP_TAG 0x9901 #define TEST_MISSING_JUMP_TAG 0x9902 diff --git a/zephyr/test/system_shim/src/no_chosen.c b/zephyr/test/system_shim/src/no_chosen.c index 55504691d1..0e41d562b9 100644 --- a/zephyr/test/system_shim/src/no_chosen.c +++ b/zephyr/test/system_shim/src/no_chosen.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "fakes.h" #include "system.h" +#include + ZTEST(system, test_fail_get_bbram_no_device) { zassert_equal(EC_ERROR_INVAL, system_get_bbram(0, NULL)); diff --git a/zephyr/test/system_shim/src/suite.c b/zephyr/test/system_shim/src/suite.c index 0d825ad9d7..b430780d0a 100644 --- a/zephyr/test/system_shim/src/suite.c +++ b/zephyr/test/system_shim/src/suite.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ +#include "fakes.h" + #include #include #include #include -#include "fakes.h" - DEFINE_FAKE_VALUE_FUNC(int, cros_system_native_posix_get_reset_cause, const struct device *); DEFINE_FAKE_VALUE_FUNC(uint64_t, cros_system_native_posix_deep_sleep_ticks, -- cgit v1.2.1 From d87825f8d3eabdf597dee0f3c6112a18cbd00ea3 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 14:35:37 -0700 Subject: ec: IWYU Add missing include Include stdint.h in task_id.h or uint8_t. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ia654dca3baf56bf29b682f29bb2cc0a32310e1c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043732 Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Tristan Honscheid Commit-Queue: Tristan Honscheid --- include/task_id.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/task_id.h b/include/task_id.h index e617d820b5..9ddc61678b 100644 --- a/include/task_id.h +++ b/include/task_id.h @@ -16,6 +16,8 @@ #include "config.h" #include "task_filter.h" +#include + /* define the name of the header containing the list of tasks */ #define STRINGIFY0(name) #name #define STRINGIFY(name) STRINGIFY0(name) -- cgit v1.2.1 From ceec0ae016a86a640ae65e1aab16f74e92518cbb Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 17 Nov 2022 12:48:03 +0000 Subject: zephyr: leds: move led value in the pwm led binding Similarly to the gpio led binding, the pwm led binding is using phandle cells as values. Fix up the code to use a separate property instead, at this point the -config binding is not needed anymore and we can use the upstream pwm-leds directly. BRANCH=none BUG=b:242826402 TEST=validated the resulting structure with gdb TEST=zmake build -a; ./twister Signed-off-by: Fabio Baltieri Change-Id: Iec480da15e2ff5e356bad11fbfb6031d4d56353a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031269 Reviewed-by: Sam Hurst Code-Coverage: Zoss --- docs/zephyr/zephyr_leds.md | 24 +++++++------- zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml | 21 +++++++----- .../dts/bindings/leds/cros-ec,pwm-pin-config.yaml | 19 ----------- zephyr/program/corsola/led_it81202_base.dtsi | 38 ++++++++-------------- zephyr/program/corsola/led_magikarp.dtsi | 3 +- zephyr/program/corsola/led_tentacruel.dtsi | 3 +- zephyr/program/nissa/xivu/led_pins.dtsi | 32 +++++++----------- zephyr/program/skyrim/led_pins_crystaldrift.dts | 18 +++++----- zephyr/program/skyrim/led_pins_frostflow.dts | 20 +++++------- zephyr/program/skyrim/led_pins_morthal.dts | 20 +++++------- zephyr/program/skyrim/led_pins_skyrim.dts | 20 +++++------- zephyr/program/skyrim/led_pins_winterhold.dts | 20 +++++------- zephyr/program/trogdor/lazor/pwm_led.dts | 20 +++++------- zephyr/shim/src/led_driver/led_pwm.c | 6 ++-- zephyr/test/drivers/boards/native_posix.overlay | 30 ++++++++--------- 15 files changed, 117 insertions(+), 177 deletions(-) delete mode 100644 zephyr/dts/bindings/leds/cros-ec,pwm-pin-config.yaml diff --git a/docs/zephyr/zephyr_leds.md b/docs/zephyr/zephyr_leds.md index cec7638fba..3f57aea013 100644 --- a/docs/zephyr/zephyr_leds.md +++ b/docs/zephyr/zephyr_leds.md @@ -77,7 +77,7 @@ GPIO LED Pins dts file example: [led_pins_herobrine.dts] #### PWM based LEDs Configure PWM based LEDs with two separate nodes. -The `cros-ec,pwm-pin-config` node, described in [cros-ec,pwm_led_pin_config.yaml], configures the PWM channel and frequency. +The `pwm-leds` node, described in [pwm-leds.yaml], configures the PWM channel and frequency. The `cros-ec,pwm-led-pins` node, described in [cros-ec,pwm_led_pins.yaml], configures the LED colors. PWM LEDs can vary duty-cycle percentage, providing finer color control over GPIO LEDs. @@ -86,16 +86,14 @@ Example: For this example, the board contains dual-channel LED, one channel controls white color intensity, and one channel controls the amber color intensity. To set the LED color to amber, the yellow channel duty-cycle is set to 100 percentage and white channel duty-cycle is set to 0. ``` -pwm_pins { - compatible = "cros-ec,pwm-pin-config"; +pwmleds { + compatible = "pwm-leds"; pwm_y: pwm_y { - #led-pin-cells = <1>; pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; pwm_w: pwm_w { - #led-pin-cells = <1>; pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; }; @@ -105,18 +103,18 @@ pwm-led-pins { pwm-frequency = <100>; /* Amber - turn on yellow LED */ color_amber: color-amber { - led-pins = <&pwm_y 100>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + pwm-values = <100 0>; }; /* White - turn on white LED */ color_white: color-white { - led-pins = <&pwm_y 0>, - <&pwm_w 100>; + led-pwms = <&pwm_y &pwm_w>; + pwm-values = <0 100>; }; /* Off - turn off both LEDs */ color_off: color-off { - led-pins = <&pwm_y 0>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + pwm-values = <0 0>; }; }; ``` @@ -198,7 +196,7 @@ TODO: Enable support for ledtest - Look for the gpio/pwm pins in the schematic with which the LEDs are attached to. - In the above snippet, LEDs are configured to use PWM pins and attached to PWM2 and PWM3. -- Add PWM config nodes as shown in [cros-ec,pwm_led_pin_config.yaml] and [led_pins_skyrim.dts]. +- Add PWM config nodes as shown in [pwm-leds.yaml] and [led_pins_skyrim.dts]. - Add pin nodes based on the color of the LEDs attached as shown in [cros-ec,pwm_led_pins.yaml] and [led_pins_skyrim.dts]. Name the nodes according to the LED color for readability. e.g. `color-amber` - Based on the device LED policy, create led_policy nodes as shown in [cros-ec,led_policy.yaml] and [led_policy_skyrim.dts]. @@ -214,7 +212,7 @@ TODO: Enable support for ledtest [cros-ec,led_policy.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,led-colors.yaml [cros-ec,gpio_led_pins.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml [cros-ec,pwm_led_pins.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml -[cros-ec,pwm_led_pin_config.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,pwm-led-pin-config.yaml +[pwm-leds.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/zephyr/main/dts/bindings/led/pwm-leds.yaml [led_policy_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/skyrim/led_policy_skyrim.dts [led_pins_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/skyrim/led_pins_skyrim.dts [led_policy_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/herobrine/led_policy_herobrine.dts diff --git a/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml b/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml index 19fee69be4..5ee8e112b5 100644 --- a/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml +++ b/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml @@ -14,8 +14,8 @@ child-binding: looks like this where 100 is PWM duty cycle in percentage. color-amber { led-color = "LED_AMBER"; - led-pins = <&pwm_led_y 100>, - <&pwm_led_b 0>; + led-pwms = <&pwm_led_y &pwm_led_b>; + led-values = <100 0>; }; properties: led-color: @@ -59,11 +59,16 @@ child-binding: - EC_LED_COLOR_YELLOW - EC_LED_COLOR_WHITE - EC_LED_COLOR_AMBER - led-pins: - type: phandle-array + led-pwms: + type: phandles required: true description: | - This property is used to specify an array of PWM pins and - corresponding values to enable a particular color. - e.g. Amber color - led-pins = <&pwm_led_y 100>, - <&pwm_led_b 0>; + This property is used to specify an array of pwms to set a + particular color. + + led-values: + type: array + required: true + description: | + This property is used to specify an array of values to set on the + corresponding pwm-pins to set a particular color. diff --git a/zephyr/dts/bindings/leds/cros-ec,pwm-pin-config.yaml b/zephyr/dts/bindings/leds/cros-ec,pwm-pin-config.yaml deleted file mode 100644 index bdef6b6144..0000000000 --- a/zephyr/dts/bindings/leds/cros-ec,pwm-pin-config.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: PWM LED pin configuration - -compatible: "cros-ec,pwm-pin-config" - -child-binding: - description: PWMs associated with LEDs - properties: - pwms: - type: phandle-array - required: true - "#led-pin-cells": - type: int - required: false - led-pin-cells: - - value diff --git a/zephyr/program/corsola/led_it81202_base.dtsi b/zephyr/program/corsola/led_it81202_base.dtsi index 2703e6c997..582af0b092 100644 --- a/zephyr/program/corsola/led_it81202_base.dtsi +++ b/zephyr/program/corsola/led_it81202_base.dtsi @@ -92,29 +92,17 @@ }; pwmleds { - compatible = "cros-ec,pwm-pin-config"; + compatible = "pwm-leds"; /* NOTE: &pwm number needs same with channel number */ led_power_white: ec_led1_odl { - #led-pin-cells = <1>; - pwms = <&pwm0 - PWM_CHANNEL_0 - PWM_HZ(324) - PWM_POLARITY_INVERTED>; + pwms = <&pwm0 PWM_CHANNEL_0 PWM_HZ(324) PWM_POLARITY_INVERTED>; }; led_battery_amber: ec_led2_odl { - #led-pin-cells = <1>; - pwms = <&pwm1 - PWM_CHANNEL_1 - PWM_HZ(324) - PWM_POLARITY_INVERTED>; + pwms = <&pwm1 PWM_CHANNEL_1 PWM_HZ(324) PWM_POLARITY_INVERTED>; }; led_battery_white: ec_led3_odl { - #led-pin-cells = <1>; - pwms = <&pwm2 - PWM_CHANNEL_2 - PWM_HZ(324) - PWM_POLARITY_INVERTED>; + pwms = <&pwm2 PWM_CHANNEL_2 PWM_HZ(324) PWM_POLARITY_INVERTED>; }; }; @@ -124,37 +112,39 @@ color_power_off: color-power-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 0>; + led-pwms = <&led_power_white>; + led-values = <0>; }; color_power_white: color-power-white { led-color = "LED_WHITE"; br-color = "EC_LED_COLOR_WHITE"; led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 100>; + led-pwms = <&led_power_white>; + led-values = <100>; }; color_battery_off: color-battery-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&led_battery_amber 0>, - <&led_battery_white 0>; + led-pwms = <&led_battery_amber &led_battery_white>; + led-values = <0 0>; }; color_battery_amber: color-battery-amber { led-color = "LED_AMBER"; br-color = "EC_LED_COLOR_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&led_battery_amber 100>, - <&led_battery_white 0>; + led-pwms = <&led_battery_amber &led_battery_white>; + led-values = <100 0>; }; color_battery_white: color-battery-white { led-color = "LED_WHITE"; br-color = "EC_LED_COLOR_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&led_battery_amber 0>, - <&led_battery_white 100>; + led-pwms = <&led_battery_amber &led_battery_white>; + led-values = <0 100>; }; }; }; diff --git a/zephyr/program/corsola/led_magikarp.dtsi b/zephyr/program/corsola/led_magikarp.dtsi index 01382d95c0..f8b53a42ec 100644 --- a/zephyr/program/corsola/led_magikarp.dtsi +++ b/zephyr/program/corsola/led_magikarp.dtsi @@ -130,7 +130,8 @@ color_power_white: color-power-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 0>; + led-pwms = <&led_power_white>; + led-values = <0>; }; }; }; diff --git a/zephyr/program/corsola/led_tentacruel.dtsi b/zephyr/program/corsola/led_tentacruel.dtsi index 39197bd51d..05d49371af 100644 --- a/zephyr/program/corsola/led_tentacruel.dtsi +++ b/zephyr/program/corsola/led_tentacruel.dtsi @@ -112,7 +112,8 @@ color_power_white: color-power-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_POWER_LED"; - led-pins = <&led_power_white 0>; + led-pwms = <&led_power_white>; + led-values = <0>; }; }; }; diff --git a/zephyr/program/nissa/xivu/led_pins.dtsi b/zephyr/program/nissa/xivu/led_pins.dtsi index d85004a0c9..e8c0738efd 100644 --- a/zephyr/program/nissa/xivu/led_pins.dtsi +++ b/zephyr/program/nissa/xivu/led_pins.dtsi @@ -4,25 +4,18 @@ */ / { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; + pwmleds { + compatible = "pwm-leds"; pwm_led_y_c0: pwm_led_y_c0 { - #led-pin-cells = <1>; pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; }; - pwm_led_w_c0: pwm_led_w_c0 { - #led-pin-cells = <1>; pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; }; - pwm_led_y_c1: pwm_led_y_c1 { - #led-pin-cells = <1>; pwms = <&pwm6 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; }; - pwm_led_w_c1: pwm_led_w_c1 { - #led-pin-cells = <1>; pwms = <&pwm1 0 PWM_HZ(324) PWM_POLARITY_INVERTED>; }; }; @@ -33,30 +26,27 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_led_y_c0 0>, - <&pwm_led_y_c1 0>, - <&pwm_led_w_c0 0>, - <&pwm_led_w_c1 0>; + led-pwms = <&pwm_led_y_c0 &pwm_led_y_c1 + &pwm_led_w_c0 &pwm_led_w_c1>; + led-values = <0 0 0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_led_y_c0 1>, - <&pwm_led_y_c1 1>, - <&pwm_led_w_c0 0>, - <&pwm_led_w_c1 0>; + led-pwms = <&pwm_led_y_c0 &pwm_led_y_c1 + &pwm_led_w_c0 &pwm_led_w_c1>; + led-values = <1 1 0 0>; }; color_white: color-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_led_y_c0 0>, - <&pwm_led_y_c1 0>, - <&pwm_led_w_c0 1>, - <&pwm_led_w_c1 1>; + led-pwms = <&pwm_led_y_c0 &pwm_led_y_c1 + &pwm_led_w_c0 &pwm_led_w_c1>; + led-values = <0 0 1 1>; }; }; }; diff --git a/zephyr/program/skyrim/led_pins_crystaldrift.dts b/zephyr/program/skyrim/led_pins_crystaldrift.dts index d294490208..f778a24a51 100644 --- a/zephyr/program/skyrim/led_pins_crystaldrift.dts +++ b/zephyr/program/skyrim/led_pins_crystaldrift.dts @@ -4,16 +4,14 @@ */ / { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; + pwmleds { + compatible = "pwm-leds"; pwm_y: pwm_y { - #led-pin-cells = <1>; pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; pwm_w: pwm_w { - #led-pin-cells = <1>; pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; }; @@ -24,24 +22,24 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; }; color_white: color-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; }; }; }; diff --git a/zephyr/program/skyrim/led_pins_frostflow.dts b/zephyr/program/skyrim/led_pins_frostflow.dts index d294490208..78b9a59c40 100644 --- a/zephyr/program/skyrim/led_pins_frostflow.dts +++ b/zephyr/program/skyrim/led_pins_frostflow.dts @@ -4,16 +4,12 @@ */ / { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - + pwmleds { + compatible = "pwm-leds"; pwm_y: pwm_y { - #led-pin-cells = <1>; pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; - pwm_w: pwm_w { - #led-pin-cells = <1>; pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; }; @@ -24,24 +20,24 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; }; color_white: color-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; }; }; }; diff --git a/zephyr/program/skyrim/led_pins_morthal.dts b/zephyr/program/skyrim/led_pins_morthal.dts index d294490208..78b9a59c40 100644 --- a/zephyr/program/skyrim/led_pins_morthal.dts +++ b/zephyr/program/skyrim/led_pins_morthal.dts @@ -4,16 +4,12 @@ */ / { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - + pwmleds { + compatible = "pwm-leds"; pwm_y: pwm_y { - #led-pin-cells = <1>; pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; - pwm_w: pwm_w { - #led-pin-cells = <1>; pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; }; @@ -24,24 +20,24 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; }; color_white: color-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; }; }; }; diff --git a/zephyr/program/skyrim/led_pins_skyrim.dts b/zephyr/program/skyrim/led_pins_skyrim.dts index d294490208..78b9a59c40 100644 --- a/zephyr/program/skyrim/led_pins_skyrim.dts +++ b/zephyr/program/skyrim/led_pins_skyrim.dts @@ -4,16 +4,12 @@ */ / { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - + pwmleds { + compatible = "pwm-leds"; pwm_y: pwm_y { - #led-pin-cells = <1>; pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; - pwm_w: pwm_w { - #led-pin-cells = <1>; pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; }; @@ -24,24 +20,24 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; }; color_white: color-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; }; }; }; diff --git a/zephyr/program/skyrim/led_pins_winterhold.dts b/zephyr/program/skyrim/led_pins_winterhold.dts index d294490208..78b9a59c40 100644 --- a/zephyr/program/skyrim/led_pins_winterhold.dts +++ b/zephyr/program/skyrim/led_pins_winterhold.dts @@ -4,16 +4,12 @@ */ / { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - + pwmleds { + compatible = "pwm-leds"; pwm_y: pwm_y { - #led-pin-cells = <1>; pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; - pwm_w: pwm_w { - #led-pin-cells = <1>; pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; }; }; @@ -24,24 +20,24 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_w 0>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; }; color_white: color-white { led-color = "LED_WHITE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwm_y 0>, - <&pwm_w 100>; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; }; }; }; diff --git a/zephyr/program/trogdor/lazor/pwm_led.dts b/zephyr/program/trogdor/lazor/pwm_led.dts index 0582966d6a..f8375b3596 100644 --- a/zephyr/program/trogdor/lazor/pwm_led.dts +++ b/zephyr/program/trogdor/lazor/pwm_led.dts @@ -4,16 +4,12 @@ */ / { - pwm_pins { - compatible = "cros-ec,pwm-pin-config"; - + pwmleds { + compatible = "pwm-leds"; pwm_y: pwm_y { - #led-pin-cells = <1>; pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; }; - pwm_b: pwm_b { - #led-pin-cells = <1>; pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_NORMAL>; }; }; @@ -24,24 +20,24 @@ color_off: color-off { led-color = "LED_OFF"; led-id = "EC_LED_ID_BATTERY_LED"; - led-pins = <&pwm_y 0>, - <&pwm_b 0>; + led-pwms = <&pwm_y &pwm_b>; + led-values = <0 0>; }; color_amber: color-amber { led-color = "LED_AMBER"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwm_y 100>, - <&pwm_b 0>; + led-pwms = <&pwm_y &pwm_b>; + led-values = <100 0>; }; color_blue: color-blue { led-color = "LED_BLUE"; led-id = "EC_LED_ID_BATTERY_LED"; br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&pwm_y 0>, - <&pwm_b 100>; + led-pwms = <&pwm_y &pwm_b>; + led-values = <0 100>; }; }; }; diff --git a/zephyr/shim/src/led_driver/led_pwm.c b/zephyr/shim/src/led_driver/led_pwm.c index cfb0d13fb4..dbf98bc3b4 100644 --- a/zephyr/shim/src/led_driver/led_pwm.c +++ b/zephyr/shim/src/led_driver/led_pwm.c @@ -33,12 +33,12 @@ LOG_MODULE_REGISTER(pwm_led, LOG_LEVEL_ERR); .pwm = PWM_DT_SPEC_GET(DT_PHANDLE_BY_IDX(node_id, prop, i)), \ .pulse_ns = DIV_ROUND_NEAREST( \ DT_PWMS_PERIOD(DT_PHANDLE_BY_IDX(node_id, prop, i)) * \ - DT_PHA_BY_IDX(node_id, prop, i, value), \ + DT_PROP_BY_IDX(node_id, led_values, i), \ 100), \ }, #define SET_PWM_PIN(node_id) \ - { DT_FOREACH_PROP_ELEM(node_id, led_pins, SET_PIN) }; + { DT_FOREACH_PROP_ELEM(node_id, led_pwms, SET_PIN) }; #define GEN_PINS_ARRAY(id) struct pwm_pin_t PINS_ARRAY(id)[] = SET_PWM_PIN(id) @@ -49,7 +49,7 @@ DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_ARRAY) .led_id = GET_PROP(node_id, led_id), \ .br_color = GET_PROP_NVE(node_id, br_color), \ .pwm_pins = PINS_ARRAY(node_id), \ - .pins_count = DT_PROP_LEN(node_id, led_pins) }; + .pins_count = DT_PROP_LEN(node_id, led_pwms) }; /* * Initialize led_pins_node_t struct for each pin node defined diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index b077cd984c..fa427c30f5 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -970,22 +970,18 @@ }; pwmleds { - compatible = "cros-ec,pwm-pin-config"; + compatible = "pwm-leds"; pwmled_blue_left: pwmled_b_left { - #led-pin-cells = <1>; pwms = <&pwm_blue_left 0 1000000 PWM_POLARITY_NORMAL>; }; pwmled_white_left: pwmled_w_left { - #led-pin-cells = <1>; pwms = <&pwm_white_left 0 1000000 PWM_POLARITY_NORMAL>; }; pwmled_amber_right: pwmled_y_right { - #led-pin-cells = <1>; pwms = <&pwm_amber_right 0 1000000 PWM_POLARITY_NORMAL>; }; pwmled_white_right: pwmled_w_right { - #led-pin-cells = <1>; pwms = <&pwm_white_right 0 1000000 PWM_POLARITY_NORMAL>; }; }; @@ -996,42 +992,42 @@ color-off-left { led-color = "LED_OFF"; led-id = "EC_LED_ID_LEFT_LED"; - led-pins = <&pwmled_blue_left 0>, - <&pwmled_white_left 0>; + led-pwms = <&pwmled_blue_left &pwmled_white_left>; + led-values = <0 0>; }; color-off-right { led-color = "LED_OFF"; led-id = "EC_LED_ID_RIGHT_LED"; - led-pins = <&pwmled_amber_right 0>, - <&pwmled_white_right 0>; + led-pwms = <&pwmled_amber_right &pwmled_white_right>; + led-values = <0 0>; }; color-blue-left { led-color = "LED_BLUE"; led-id = "EC_LED_ID_LEFT_LED"; br-color = "EC_LED_COLOR_BLUE"; - led-pins = <&pwmled_blue_left 100>, - <&pwmled_white_left 0>; + led-pwms = <&pwmled_blue_left &pwmled_white_left>; + led-values = <100 0>; }; color-amber-right { led-color = "LED_AMBER"; led-id = "EC_LED_ID_RIGHT_LED"; br-color = "EC_LED_COLOR_AMBER"; - led-pins = <&pwmled_amber_right 100>, - <&pwmled_white_right 0>; + led-pwms = <&pwmled_amber_right &pwmled_white_right>; + led-values = <100 0>; }; color-white-left { led-color = "LED_WHITE"; led-id = "EC_LED_ID_LEFT_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwmled_blue_left 0>, - <&pwmled_white_left 100>; + led-pwms = <&pwmled_blue_left &pwmled_white_left>; + led-values = <0 100>; }; color-white-right { led-color = "LED_WHITE"; led-id = "EC_LED_ID_RIGHT_LED"; br-color = "EC_LED_COLOR_WHITE"; - led-pins = <&pwmled_amber_right 0>, - <&pwmled_white_right 100>; + led-pwms = <&pwmled_amber_right &pwmled_white_right>; + led-values = <0 100>; }; }; -- cgit v1.2.1 From e5d38683d436b29ce8ff7434dafae7dd6c3bb301 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Mon, 21 Nov 2022 14:10:35 -0700 Subject: tcpm_header: add tests for tcpm_reset_bist_type_2 This function's call-through to the driver's implementation was uncovered by current testing. Added tests for both cases where the driver does and does not implement this function. BUG=none TEST=twister, verify line is now covered BRANCH=none Signed-off-by: Clayton Whitelaw Change-Id: Ib38b70e076938a8c139cf4b785967ec546faa7d8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043730 Commit-Queue: Aaron Massey Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/test/drivers/default/src/tcpm_header.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c index b4c3ece359..affaa9d99a 100644 --- a/zephyr/test/drivers/default/src/tcpm_header.c +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -14,6 +14,7 @@ #define TCPM_TEST_PORT USBC_PORT_C0 FAKE_VALUE_FUNC(int, set_vconn, int, int); +FAKE_VALUE_FUNC(int, reset_bist_type_2, int); struct tcpm_header_fixture { /* The original driver pointer that gets restored after the tests */ @@ -39,6 +40,29 @@ ZTEST_F(tcpm_header, test_tcpm_header_drv_set_vconn_failure) zassert_equal(-1, res); } +ZTEST_F(tcpm_header, test_tcpm_header_reset_bist_type_2__unimplemented) +{ + int res; + + res = tcpm_reset_bist_type_2(TCPM_TEST_PORT); + + zassert_equal(EC_SUCCESS, res); +} + +ZTEST_F(tcpm_header, test_tcpm_header_reset_bist_type_2__implemented) +{ + int res; + const int driver_return_code = 7458; /* arbitrary */ + + fixture->mock_driver.reset_bist_type_2 = reset_bist_type_2; + reset_bist_type_2_fake.return_val = driver_return_code; + res = tcpm_reset_bist_type_2(TCPM_TEST_PORT); + + zassert_equal(1, reset_bist_type_2_fake.call_count); + zassert_equal(TCPM_TEST_PORT, reset_bist_type_2_fake.arg0_history[0]); + zassert_equal(driver_return_code, res); +} + static void *tcpm_header_setup(void) { static struct tcpm_header_fixture fixture; @@ -51,6 +75,7 @@ static void tcpm_header_before(void *state) struct tcpm_header_fixture *fixture = state; RESET_FAKE(set_vconn); + RESET_FAKE(reset_bist_type_2); fixture->mock_driver = (struct tcpm_drv){ 0 }; fixture->saved_driver_ptr = tcpc_config[TCPM_TEST_PORT].drv; -- cgit v1.2.1 From fdd733a8b26f8843271ae63a1432a44409857df0 Mon Sep 17 00:00:00 2001 From: Michael5 Chen1 Date: Fri, 18 Nov 2022 08:51:22 +0800 Subject: marasov: Modify the EC battery setting 1. Remove CONFIG_BATT_HOST_SHUTDOWN_PRECENTAGE to default. 2. Modify voltage_normal value depend on b:259008193#3 BUG=b:259008193 BRANCH=none TEST=make BOARD=marasov Signed-off-by: Michael5 Chen1 Change-Id: I14c05eadfcc2e923273014dbfd18fc2946711208 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4037122 Reviewed-by: Kyle Lin Code-Coverage: Zoss Reviewed-by: Boris Mittelberg --- board/marasov/battery.c | 2 +- board/marasov/board.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/board/marasov/battery.c b/board/marasov/battery.c index dfc7dd007e..b974930d5b 100644 --- a/board/marasov/battery.c +++ b/board/marasov/battery.c @@ -50,7 +50,7 @@ const struct board_batt_params board_battery_info[] = { }, .batt_info = { .voltage_max = 13200, /* mV */ - .voltage_normal = 11550, /* mV */ + .voltage_normal = 11880, /* mV */ .voltage_min = 9000, /* mV */ .precharge_current = 256, /* mA */ .start_charging_min_c = 0, diff --git a/board/marasov/board.h b/board/marasov/board.h index 4ae3e5adef..7e7e140905 100644 --- a/board/marasov/board.h +++ b/board/marasov/board.h @@ -54,8 +54,6 @@ /* Battery Configuration */ #define CONFIG_SMBUS_PEC -#undef CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE -#define CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE 3 #undef CONFIG_BATT_HOST_FULL_FACTOR #define CONFIG_BATT_HOST_FULL_FACTOR 99 -- cgit v1.2.1 From 3a9cc3afab285ddc3fe9fe4a42a1fc37f497a63f Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Mon, 19 Sep 2022 17:53:22 +0800 Subject: zephyr: krabby usbc_config test This test verifies the sink path switching logic on Krabby. BUG=b:243841599 TEST=twister -T zephyr/test/krabby/ BRANCH=none Signed-off-by: Ting Shen Change-Id: I0128f9b1b200397afe30bfdd5e99903a35ac0260 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3902757 Code-Coverage: Zoss Auto-Submit: Ting Shen Commit-Queue: Eric Yilun Lin Tested-by: Ting Shen Reviewed-by: Eric Yilun Lin --- zephyr/dts/it8xxx2_emul.dts | 7 ++ zephyr/program/corsola/src/krabby/usbc_config.c | 2 - zephyr/test/krabby/CMakeLists.txt | 4 +- zephyr/test/krabby/adc_temp.dts | 23 +---- zephyr/test/krabby/common.dts | 69 +++++++++++++ zephyr/test/krabby/pinctrl.dts | 2 + zephyr/test/krabby/prj.conf | 14 ++- zephyr/test/krabby/src/stubs.c | 52 +--------- zephyr/test/krabby/src/usbc_config.c | 131 ++++++++++++++++++++++++ 9 files changed, 229 insertions(+), 75 deletions(-) create mode 100644 zephyr/test/krabby/src/usbc_config.c diff --git a/zephyr/dts/it8xxx2_emul.dts b/zephyr/dts/it8xxx2_emul.dts index d88d743ebd..5f517b0c1b 100644 --- a/zephyr/dts/it8xxx2_emul.dts +++ b/zephyr/dts/it8xxx2_emul.dts @@ -185,4 +185,11 @@ #size-cells = <0>; reg = <0x00f03500 0x0080>; }; + + adc0: adc { + compatible = "zephyr,adc-emul"; + nchannels = <6>; + ref-internal-mv = <3300>; + #io-channel-cells = <1>; + }; }; diff --git a/zephyr/program/corsola/src/krabby/usbc_config.c b/zephyr/program/corsola/src/krabby/usbc_config.c index 1307538922..ab5888616e 100644 --- a/zephyr/program/corsola/src/krabby/usbc_config.c +++ b/zephyr/program/corsola/src/krabby/usbc_config.c @@ -68,7 +68,6 @@ void board_reset_pd_mcu(void) */ } -#ifndef CONFIG_TEST int board_set_active_charge_port(int port) { int i; @@ -127,7 +126,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -#endif #ifdef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT enum adc_channel board_get_vbus_adc(int port) diff --git a/zephyr/test/krabby/CMakeLists.txt b/zephyr/test/krabby/CMakeLists.txt index ce13e9520a..dbab1bd19c 100644 --- a/zephyr/test/krabby/CMakeLists.txt +++ b/zephyr/test/krabby/CMakeLists.txt @@ -12,12 +12,14 @@ zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/corsola/include") target_sources(app PRIVATE src/stubs.c - ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/usbc_config.c) + ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/usbc_config.c + ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/usb_pd_policy.c) target_sources_ifdef(CONFIG_TEST_KRABBY app PRIVATE src/charger_workaround.c src/usb_mux_init.c + src/usbc_config.c ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/charger_workaround.c) target_sources_ifdef(CONFIG_TEST_TENTACRUEL diff --git a/zephyr/test/krabby/adc_temp.dts b/zephyr/test/krabby/adc_temp.dts index 28e98adf64..c0d17cca13 100644 --- a/zephyr/test/krabby/adc_temp.dts +++ b/zephyr/test/krabby/adc_temp.dts @@ -6,28 +6,11 @@ #include / { - adc0: adc { - compatible = "zephyr,adc-emul"; - nchannels = <1>; - ref-internal-mv = <3300>; - #io-channel-cells = <1>; - status = "okay"; - }; - - named-adc-channels { - compatible = "named-adc-channels"; - - adc_charger: charger { - enum-name = "ADC_TEMP_SENSOR_CHARGER"; - io-channels = <&adc0 0>; - }; - }; - name_temp_charger: charger { - compatible = "cros-ec,temp-sensor-thermistor"; + compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_rt9490>; - adc = <&adc_charger>; + thermistor = <&thermistor_rt9490>; + adc = <&adc_charger>; }; named-temp-sensors { diff --git a/zephyr/test/krabby/common.dts b/zephyr/test/krabby/common.dts index b8f1eb0733..8f7c6c114d 100644 --- a/zephyr/test/krabby/common.dts +++ b/zephyr/test/krabby/common.dts @@ -31,17 +31,34 @@ reg = <0>; chg = <&charger>; tcpc = <&tcpci_emul>; + ppc = <&ppc0_emul>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; }; port1@1 { compatible = "named-usbc-port"; status = "okay"; reg = <1>; + tcpc = <&tcpci_emul>; + ppc = <&ppc1_emul>; usb-mux-chain-1 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&tusb1064_mux_1>; }; }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; }; batteries { @@ -49,6 +66,33 @@ compatible = "lgc,ac17a8m", "battery-smart"; }; }; + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + adc_charger: charger { + enum-name = "ADC_TEMP_SENSOR_CHARGER"; + io-channels = <&adc0 5>; + }; + }; }; &i2c_ctrl0 { @@ -77,6 +121,31 @@ status = "okay"; reg = <0x82>; }; + + ppc0_emul: syv682x@42 { + compatible = "zephyr,syv682x-emul"; + status = "okay"; + reg = <0x42>; + frs_en_gpio = <&gpio_ec_x_gpio1>; + alert_gpio = <&gpio_x_ec_gpio2>; + }; + + ppc1_emul: syv682x@43 { + compatible = "zephyr,syv682x-emul"; + status = "okay"; + reg = <0x43>; + /* + * the gpio pins are intentionally reused in both ppc emuls, to + * avoid handling different frs-en pin names on krabby and + * tentacruel. + */ + frs_en_gpio = <&gpio_ec_x_gpio1>; + alert_gpio = <&gpio_x_ec_gpio2>; + }; +}; + +&adc0 { + status = "okay"; }; &i2c_ctrl4 { diff --git a/zephyr/test/krabby/pinctrl.dts b/zephyr/test/krabby/pinctrl.dts index 9d01591238..ecc7b88538 100644 --- a/zephyr/test/krabby/pinctrl.dts +++ b/zephyr/test/krabby/pinctrl.dts @@ -5,3 +5,5 @@ /* remove pinctrl to avoid pull in too many unwanted dependency */ /delete-node/ &pinctrl; + +/delete-node/ &{/hibernate-wake-pins}; diff --git a/zephyr/test/krabby/prj.conf b/zephyr/test/krabby/prj.conf index fd41778593..c5af7e2cec 100644 --- a/zephyr/test/krabby/prj.conf +++ b/zephyr/test/krabby/prj.conf @@ -22,14 +22,24 @@ CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CHARGE_MANAGER=n +CONFIG_PLATFORM_EC_CHARGE_MANAGER=y +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y +CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY=49 CONFIG_PLATFORM_EC_HOOKS=y CONFIG_PLATFORM_EC_HOSTCMD=y CONFIG_PLATFORM_EC_LID_SWITCH=n CONFIG_PLATFORM_EC_SWITCH=n CONFIG_PLATFORM_EC_USBC=y -CONFIG_PLATFORM_EC_USB_CHARGER=n +CONFIG_PLATFORM_EC_USB_CHARGER=y +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE=y CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y CONFIG_PLATFORM_EC_USB_POWER_DELIVERY=y CONFIG_PLATFORM_EC_VBOOT_HASH=n + +CONFIG_PLATFORM_EC_USBC_PPC=y +CONFIG_EMUL_PPC_SYV682X=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y diff --git a/zephyr/test/krabby/src/stubs.c b/zephyr/test/krabby/src/stubs.c index 1e955fa8f0..655c59ec2c 100644 --- a/zephyr/test/krabby/src/stubs.c +++ b/zephyr/test/krabby/src/stubs.c @@ -8,65 +8,17 @@ #include "charge_state.h" #include "usbc_ppc.h" -int board_set_active_charge_port(int port) -{ - return 0; -} - -int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) -{ - return 0; -} - void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { } -const struct batt_params *charger_current_battery_params(void) -{ - static const struct batt_params params = {}; - - return ¶ms; -} - -int board_get_battery_soc(void) -{ - return 0; -} - -void pd_power_supply_reset(void) -{ -} - int pd_check_vconn_swap(int port) { return 0; } -void pd_set_input_current_limit(int port, uint32_t max_ma, - uint32_t supply_voltage) -{ -} - -int pd_set_power_supply_ready(int port) -{ - return 0; -} - -void usb_charger_vbus_change(int port, int vbus_level) -{ -} - -int charge_manager_get_active_charge_port(void) +int board_get_adjusted_usb_pd_port_count(int port) { - return 0; + return 2; } - -struct ppc_config_t ppc_chips[] = {}; - -unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); - -#ifdef CONFIG_MUX_INIT_ADC -const struct adc_t adc_channels[] = {}; -#endif diff --git a/zephyr/test/krabby/src/usbc_config.c b/zephyr/test/krabby/src/usbc_config.c new file mode 100644 index 0000000000..ea9c4b3eed --- /dev/null +++ b/zephyr/test/krabby/src/usbc_config.c @@ -0,0 +1,131 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "adc.h" +#include "charge_manager.h" +#include "driver/ppc/syv682x.h" +#include "driver/ppc/syv682x_public.h" +#include "emul/emul_common_i2c.h" +#include "emul/emul_syv682x.h" +#include "i2c/i2c.h" +#include "usb_pd.h" +#include "usbc_ppc.h" + +bool ppc_sink_enabled(int port) +{ + const struct emul *emul = (port == 0) ? + EMUL_DT_GET(DT_NODELABEL(ppc0_emul)) : + EMUL_DT_GET(DT_NODELABEL(ppc1_emul)); + uint8_t val = 0; + + syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &val); + + return !(val & (SYV682X_CONTROL_1_PWR_ENB | SYV682X_CONTROL_1_HV_DR)); +} + +ZTEST(usbc_config, test_set_active_charge_port) +{ + /* reset ppc state */ + zassert_ok(board_set_active_charge_port(CHARGE_PORT_NONE), NULL); + zassert_false(ppc_sink_enabled(0), NULL); + zassert_false(ppc_sink_enabled(1), NULL); + + /* sourcing port 0, expect port 0 not sinkable */ + zassert_ok(pd_set_power_supply_ready(0)); + zassert_not_equal(board_set_active_charge_port(0), 0, NULL); + zassert_true(board_vbus_source_enabled(0), NULL); + zassert_false(board_vbus_source_enabled(1), NULL); + zassert_false(ppc_sink_enabled(0), NULL); + zassert_false(ppc_sink_enabled(1), NULL); + + /* sinking port 1 */ + zassert_ok(board_set_active_charge_port(1), NULL); + zassert_false(ppc_sink_enabled(0), NULL); + zassert_true(ppc_sink_enabled(1), NULL); + + /* + * sinking an invalid port should return error and doesn't change + * any state + */ + zassert_not_equal(board_set_active_charge_port(2), 0, NULL); + zassert_true(board_vbus_source_enabled(0), NULL); + zassert_false(board_vbus_source_enabled(1), NULL); + zassert_false(ppc_sink_enabled(0), NULL); + zassert_true(ppc_sink_enabled(1), NULL); + + /* turn of sourcing, sinking port 0 */ + pd_power_supply_reset(0); + zassert_ok(board_set_active_charge_port(0), NULL); + zassert_true(ppc_sink_enabled(0), NULL); + zassert_false(ppc_sink_enabled(1), NULL); + + /* sinking port 1 */ + zassert_ok(board_set_active_charge_port(1), NULL); + zassert_false(ppc_sink_enabled(0), NULL); + zassert_true(ppc_sink_enabled(1), NULL); + + /* back to port 0 */ + zassert_ok(board_set_active_charge_port(0), NULL); + zassert_true(ppc_sink_enabled(0), NULL); + zassert_false(ppc_sink_enabled(1), NULL); + + /* reset */ + zassert_ok(board_set_active_charge_port(CHARGE_PORT_NONE), NULL); + zassert_false(board_vbus_source_enabled(0), NULL); + zassert_false(board_vbus_source_enabled(1), NULL); + zassert_false(ppc_sink_enabled(0), NULL); + zassert_false(ppc_sink_enabled(1), NULL); +} + +ZTEST(usbc_config, test_set_active_charge_port_fail) +{ + const struct emul *ppc0 = EMUL_DT_GET(DT_NODELABEL(ppc0_emul)); + + /* Verify that failure on ppc0 doesn't affect ppc1 */ + i2c_common_emul_set_write_fail_reg( + emul_syv682x_get_i2c_common_data(ppc0), + I2C_COMMON_EMUL_FAIL_ALL_REG); + + zassert_ok(board_set_active_charge_port(1), NULL); + zassert_true(ppc_sink_enabled(1), NULL); + zassert_ok(board_set_active_charge_port(CHARGE_PORT_NONE), NULL); + zassert_false(ppc_sink_enabled(1), NULL); + zassert_ok(board_set_active_charge_port(1), NULL); + zassert_true(ppc_sink_enabled(1), NULL); + + /* trying to enable ppc0 results in error */ + zassert_not_equal(board_set_active_charge_port(0), 0, NULL); + zassert_false(ppc_sink_enabled(1), NULL); +} + +ZTEST(usbc_config, test_adc_channel) +{ + zassert_equal(board_get_vbus_adc(0), ADC_VBUS_C0, NULL); + zassert_equal(board_get_vbus_adc(1), ADC_VBUS_C1, NULL); + zassert_equal(board_get_vbus_adc(99), ADC_VBUS_C0, NULL); +} + +static void reset_ppc_state(void *fixture) +{ + const struct emul *ppc0 = EMUL_DT_GET(DT_NODELABEL(ppc0_emul)); + const struct emul *ppc1 = EMUL_DT_GET(DT_NODELABEL(ppc1_emul)); + + i2c_common_emul_set_write_fail_reg( + emul_syv682x_get_i2c_common_data(ppc0), + I2C_COMMON_EMUL_NO_FAIL_REG); + i2c_common_emul_set_write_fail_reg( + emul_syv682x_get_i2c_common_data(ppc1), + I2C_COMMON_EMUL_NO_FAIL_REG); + + ppc_vbus_source_enable(0, false); + ppc_vbus_source_enable(1, false); + board_set_active_charge_port(CHARGE_PORT_NONE); +} + +ZTEST_SUITE(usbc_config, NULL, NULL, reset_ppc_state, NULL, NULL); -- cgit v1.2.1 From 13673d5a7dec5bfcbea51a7e2012587a69286238 Mon Sep 17 00:00:00 2001 From: Josh Tsai Date: Thu, 15 Sep 2022 14:41:51 +0800 Subject: zephyr: Kconfig: Add body detection Add the body detection related configuration to Kconfig BRANCH=none BUG=b:236668095;b:232946420 TEST=zmake build winterhold Signed-off-by: Josh Tsai Change-Id: Ic44154d556a89c1779bd16cbf07b15558f63f8f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3868870 Code-Coverage: Zoss Reviewed-by: Tim Van Patten Reviewed-by: Keith Short Reviewed-by: Ching-Kang Yen Reviewed-by: Elthan Huang Reviewed-by: Diana Z --- util/config_allowed.txt | 8 ---- zephyr/CMakeLists.txt | 2 + zephyr/Kconfig.body_detection | 82 +++++++++++++++++++++++++++++++++++++++ zephyr/Kconfig.motionsense | 1 + zephyr/shim/include/config_chip.h | 28 +++++++++++++ 5 files changed, 113 insertions(+), 8 deletions(-) create mode 100644 zephyr/Kconfig.body_detection diff --git a/util/config_allowed.txt b/util/config_allowed.txt index 650bd50cce..ca3a980429 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -122,15 +122,7 @@ CONFIG_BOARD_I2C_ADDR_FLAGS CONFIG_BOARD_ID_CMD_ACPI_EC1 CONFIG_BOARD_POST_GPIO_INIT CONFIG_BOARD_PRE_INIT -CONFIG_BODY_DETECTION -CONFIG_BODY_DETECTION_CONFIDENCE_DELTA -CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE -CONFIG_BODY_DETECTION_OFF_BODY_CON -CONFIG_BODY_DETECTION_ON_BODY_CON CONFIG_BODY_DETECTION_SENSOR -CONFIG_BODY_DETECTION_STATIONARY_DURATION -CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR -CONFIG_BODY_DETECTION_VAR_THRESHOLD CONFIG_BOOTBLOCK CONFIG_BOOTCFG_VALUE CONFIG_BOOT_HEADER_STORAGE_OFF diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index ec88fa7e43..0b36bcc24e 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -182,6 +182,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM "${PLATFORM_EC}/driver/accelgyro_lsm6dsm.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_FIFO "${PLATFORM_EC}/common/motion_sense_fifo.c") +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BODY_DETECTION + "${PLATFORM_EC}/common/body_detection.c") zephyr_library_sources_ifdef(CONFIG_ADC "${PLATFORM_EC}/common/adc.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ALS_TCS3400 diff --git a/zephyr/Kconfig.body_detection b/zephyr/Kconfig.body_detection new file mode 100644 index 0000000000..a3610ef6c9 --- /dev/null +++ b/zephyr/Kconfig.body_detection @@ -0,0 +1,82 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +menuconfig PLATFORM_EC_BODY_DETECTION + bool "Sensor body detection" + help + Enable the body detection function. + + The Power Reduction Algorithm is based on the Motion Detector + output of In Motion (on body) state or Stationary (off body) state. + The input of the Motion Detector is the X and Y axis signal + from an accelerometer. + +if PLATFORM_EC_BODY_DETECTION + +config PLATFORM_EC_BODY_DETECTION_MAX_WINDOW_SIZE + int "Maximal sensor data rate" + default 250 + help + Sets the maximum sensor data rate, in Hz. Note that larger data rate + values consume more memory and computing resource. + +config PLATFORM_EC_BODY_DETECTION_VAR_THRESHOLD + int "The threshold of acceleration variance for confidence calculation" + default 550 + help + The unit is (mm/s^2)^2 + + The motion confidence is calculated if the variance is within + variance_threshold +/- confidence_delta. Otherwise, if variance is + too high/low, confidence will be 100%/0% + +config PLATFORM_EC_BODY_DETECTION_CONFIDENCE_DELTA + int "The delta of acceleration variance for confidence calculation" + default 525 + help + The unit is (mm/s^2)^2 + + The motion confidence is calculated if the variance is within + variance_threshold +/- confidence_delta. Otherwise, if variance is + too high/low, confidence will be 100%/0% + +config PLATFORM_EC_BODY_DETECTION_VAR_NOISE_FACTOR + int "How much noise affects the threshold of variance" + default 120 + help + The unit is percentage + + This is used for mitigate the effect of the noise from the sensor. + If set to 100%, the average noise is canceled out. This is set to + 120% by default because the noise might get larger than average + sometimes. + +config PLATFORM_EC_BODY_DETECTION_ON_BODY_CON + int "The confidence limit of on_body" + default 50 + help + The unit is percentage + + Higher the value, more diffcult to enter the on-body from off-body + +config PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON + int "The confidence limit of off body" + default 10 + help + The unit is percentage + + Lower the value, more diffcult to enter the off-body from on-body. + Should be set less than the PLATFORM_EC_BODY_DETECTION_ON_BODY_CON + +config PLATFORM_EC_BODY_DETECTION_STATIONARY_DURATION + int "The threshold duration to change to off_body" + default 15 + help + The unit is seconds + + How long should we stay in on-body state before entering to off-body + state when the motion confidence is less than + PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON + +endif # PLATFORM_EC_BODY_DETECTION diff --git a/zephyr/Kconfig.motionsense b/zephyr/Kconfig.motionsense index 7cf991918b..98291dc0c3 100644 --- a/zephyr/Kconfig.motionsense +++ b/zephyr/Kconfig.motionsense @@ -175,3 +175,4 @@ config PLATFORM_EC_CONSOLE_CMD_ACCEL_SPOOF endif # PLATFORM_EC_ACCEL_SPOOF_MODE rsource "Kconfig.sensor_devices" +rsource "Kconfig.body_detection" diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 3caa3db634..c52db885b0 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1974,6 +1974,34 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; #define CONFIG_ACCEL_FIFO_THRES CONFIG_PLATFORM_EC_ACCEL_FIFO_THRES #endif /* CONFIG_PLATFORM_EC_ACCEL_FIFO */ +#undef CONFIG_BODY_DETECTION +#undef CONFIG_BODY_DETECTION_SENSOR +#undef CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE +#undef CONFIG_BODY_DETECTION_VAR_THRESHOLD +#undef CONFIG_BODY_DETECTION_CONFIDENCE_DELTA +#undef CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR +#undef CONFIG_BODY_DETECTION_ON_BODY_CON +#undef CONFIG_BODY_DETECTION_OFF_BODY_CON +#undef CONFIG_BODY_DETECTION_STATIONARY_DURATION +#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION +#define CONFIG_BODY_DETECTION +#define CONFIG_BODY_DETECTION_SENSOR SENSOR_ID(DT_ALIAS(on_body_sensor)) +#define CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE \ + CONFIG_PLATFORM_EC_BODY_DETECTION_MAX_WINDOW_SIZE +#define CONFIG_BODY_DETECTION_VAR_THRESHOLD \ + CONFIG_PLATFORM_EC_BODY_DETECTION_VAR_THRESHOLD +#define CONFIG_BODY_DETECTION_CONFIDENCE_DELTA \ + CONFIG_PLATFORM_EC_BODY_DETECTION_CONFIDENCE_DELTA +#define CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR \ + CONFIG_PLATFORM_EC_BODY_DETECTION_VAR_NOISE_FACTOR +#define CONFIG_BODY_DETECTION_ON_BODY_CON \ + CONFIG_PLATFORM_EC_BODY_DETECTION_ON_BODY_CON +#define CONFIG_BODY_DETECTION_OFF_BODY_CON \ + CONFIG_PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON +#define CONFIG_BODY_DETECTION_STATIONARY_DURATION \ + CONFIG_PLATFORM_EC_BODY_DETECTION_STATIONARY_DURATION +#endif /* CONFIG_PLATFORM_EC_BODY_DETECTION */ + #undef CONFIG_CMD_ACCELS #ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS #define CONFIG_CMD_ACCELS -- cgit v1.2.1 From 949477c098b288dec19a69baf5c31e379bb38d98 Mon Sep 17 00:00:00 2001 From: Josh Tsai Date: Thu, 15 Sep 2022 14:43:41 +0800 Subject: common: body_detection: notify host when body status is changed When body status is changed, EC will send the SCI event "EC_HOST_EVENT_MODE_CHANGE" to host, the host will use the ACPI command to get the mode change value. BRANCH=none BUG=b:236668095;b:232946420 LOW_COVERAGE_REASON=no unit test for body_detection yet: b/259754018 TEST=zmake build winterhold and test on Whiterun MB. When shake MB trigger on body, and flat in desk trigger off body. ec:$ [359.832100 even[359.834200 event clear 0x0000000010000000] ec:$ [359.837000 ACPI query = 29] t set 0x0000000010000000] ec:$ [359.840800 HC 0x0067 err 9] ec:$ [359.842300 body_detect changed state to: off body] ec:$ [366.634800 even[366.636600 event clear 0x0000000010000000] ec:$ [366.639600 ACPI query = 29] t set 0x0000000010000000] ec:$ [366.644300 HC 0x0067 err 9] ec:$ [366.645100 body_detect changed state to: on body] Signed-off-by: Josh Tsai Change-Id: Ia42accf551e6a4ea02a573d63389d388309cd3b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3868880 Reviewed-by: Gwendal Grignou Code-Coverage: Zoss Reviewed-by: Elthan Huang Reviewed-by: Diana Z --- common/acpi.c | 6 ++++++ common/body_detection.c | 5 +++++ include/config.h | 3 +++ include/ec_commands.h | 4 ++++ zephyr/Kconfig.body_detection | 8 ++++++++ zephyr/shim/include/config_chip.h | 4 ++++ 6 files changed, 30 insertions(+) diff --git a/common/acpi.c b/common/acpi.c index c6fcfce417..6145cbc96a 100644 --- a/common/acpi.c +++ b/common/acpi.c @@ -5,6 +5,7 @@ #include "acpi.h" #include "battery.h" +#include "body_detection.h" #include "common.h" #include "console.h" #include "dptf.h" @@ -235,6 +236,11 @@ int acpi_ap_to_ec(int is_cmd, uint8_t value, uint8_t *resultptr) EC_ACPI_MEM_DDPN_MASK) << EC_ACPI_MEM_DDPN_SHIFT; #endif + +#ifdef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE + if (body_detect_get_state() == BODY_DETECTION_ON_BODY) + result |= BIT(EC_ACPI_MEM_STTB_SHIFT); +#endif break; case EC_ACPI_MEM_DEVICE_FEATURES0: diff --git a/common/body_detection.c b/common/body_detection.c index 848c4f08c1..e6b842ddf1 100644 --- a/common/body_detection.c +++ b/common/body_detection.c @@ -113,6 +113,11 @@ void body_detect_change_state(enum body_detect_states state, bool spoof) /* reset time counting of stationary */ stationary_timeframe = 0; } + +#ifdef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE + host_set_single_event(EC_HOST_EVENT_MODE_CHANGE); +#endif + /* state changing log */ CPRINTS("body_detect changed state to: %s body", motion_state ? "on" : "off"); diff --git a/include/config.h b/include/config.h index e8bcf8b604..967354fd97 100644 --- a/include/config.h +++ b/include/config.h @@ -221,6 +221,9 @@ /* The threshold duration to change to off_body */ #undef CONFIG_BODY_DETECTION_STATIONARY_DURATION +/* Send the SCI event to notify host when body status change */ +#undef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE + /* * Use the old standard reference frame for accelerometers. The old * reference frame is: diff --git a/include/ec_commands.h b/include/ec_commands.h index f7e40b8c0a..5384fb70ae 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -416,6 +416,7 @@ extern "C" { /* * Report device orientation * Bits Definition + * 4 Off Body/On Body status: 0 = Off Body. * 3:1 Device DPTF Profile Number (DDPN) * 0 = Reserved for backward compatibility (indicates no valid * profile number. Host should fall back to using TBMD). @@ -428,6 +429,8 @@ extern "C" { #define EC_ACPI_MEM_TBMD_MASK 0x1 #define EC_ACPI_MEM_DDPN_SHIFT 1 #define EC_ACPI_MEM_DDPN_MASK 0x7 +#define EC_ACPI_MEM_STTB_SHIFT 4 +#define EC_ACPI_MEM_STTB_MASK 0x1 /* * Report device features. Uses the same format as the host command, except: @@ -752,6 +755,7 @@ enum host_event_code { * * - TABLET/LAPTOP mode * - detachable base attach/detach event + * - on body/off body transition event */ EC_HOST_EVENT_MODE_CHANGE = 29, diff --git a/zephyr/Kconfig.body_detection b/zephyr/Kconfig.body_detection index a3610ef6c9..e9daa40e5a 100644 --- a/zephyr/Kconfig.body_detection +++ b/zephyr/Kconfig.body_detection @@ -79,4 +79,12 @@ config PLATFORM_EC_BODY_DETECTION_STATIONARY_DURATION state when the motion confidence is less than PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON +config PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE + bool "Notify host with a specific host event when body status is changed" + default n + help + Notify the host via SCI events EC_HOST_EVENT_MODE_CHANGE when body + status is changed, in addition to adding an event in the motion sensor + FIFO queue. + endif # PLATFORM_EC_BODY_DETECTION diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index c52db885b0..b7ef323ed5 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1983,6 +1983,7 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; #undef CONFIG_BODY_DETECTION_ON_BODY_CON #undef CONFIG_BODY_DETECTION_OFF_BODY_CON #undef CONFIG_BODY_DETECTION_STATIONARY_DURATION +#undef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE #ifdef CONFIG_PLATFORM_EC_BODY_DETECTION #define CONFIG_BODY_DETECTION #define CONFIG_BODY_DETECTION_SENSOR SENSOR_ID(DT_ALIAS(on_body_sensor)) @@ -2000,6 +2001,9 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; CONFIG_PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON #define CONFIG_BODY_DETECTION_STATIONARY_DURATION \ CONFIG_PLATFORM_EC_BODY_DETECTION_STATIONARY_DURATION +#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE +#define CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE +#endif /* CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE */ #endif /* CONFIG_PLATFORM_EC_BODY_DETECTION */ #undef CONFIG_CMD_ACCELS -- cgit v1.2.1 From fa3f37c670071c2a67df91a46a2040a64639e573 Mon Sep 17 00:00:00 2001 From: Josh Tsai Date: Thu, 29 Sep 2022 13:37:58 +0800 Subject: common: body_detection: add a configuration to enable body detection in S0 state Currently, the body detection needs to be activated by host command. Add a new configuration to always enable the body detection function without host command. BRANCH=none BUG=b:236668095;b:232946420 LOW_COVERAGE_REASON=no unit test for body_detection yet: b/259754018 TEST=zmake build winterhold Signed-off-by: Josh Tsai Change-Id: I9cd9e984cd302898ff2960c9c197a6eef0393f6a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3928568 Reviewed-by: Tim Van Patten Reviewed-by: Raul Rangel Code-Coverage: Zoss Reviewed-by: Diana Z Reviewed-by: Elthan Huang --- common/motion_sense.c | 7 ++++++- include/config.h | 3 +++ zephyr/Kconfig.body_detection | 7 +++++++ zephyr/shim/include/config_chip.h | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/common/motion_sense.c b/common/motion_sense.c index f6011ae6d5..ff9f186ee3 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -328,7 +328,12 @@ static void motion_sense_switch_sensor_rate(void) body_detect_set_enable(false); break; case SENSOR_ACTIVE_S0: - body_detect_set_enable(was_enabled); + /* force to enable the body detection in S0 */ + if (IS_ENABLED( + CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0)) + body_detect_set_enable(true); + else + body_detect_set_enable(was_enabled); break; default: break; diff --git a/include/config.h b/include/config.h index 967354fd97..74ac859dc3 100644 --- a/include/config.h +++ b/include/config.h @@ -224,6 +224,9 @@ /* Send the SCI event to notify host when body status change */ #undef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE +/* Always enable the body detection function in S0 */ +#undef CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0 + /* * Use the old standard reference frame for accelerometers. The old * reference frame is: diff --git a/zephyr/Kconfig.body_detection b/zephyr/Kconfig.body_detection index e9daa40e5a..85386a68c1 100644 --- a/zephyr/Kconfig.body_detection +++ b/zephyr/Kconfig.body_detection @@ -87,4 +87,11 @@ config PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE status is changed, in addition to adding an event in the motion sensor FIFO queue. +config PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0 + bool "Always enable body detection function in S0" + default n + help + Always enable the body detection function in S0 + w/o the host command + endif # PLATFORM_EC_BODY_DETECTION diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index b7ef323ed5..5e38ad800c 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1984,6 +1984,7 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; #undef CONFIG_BODY_DETECTION_OFF_BODY_CON #undef CONFIG_BODY_DETECTION_STATIONARY_DURATION #undef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE +#undef CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0 #ifdef CONFIG_PLATFORM_EC_BODY_DETECTION #define CONFIG_BODY_DETECTION #define CONFIG_BODY_DETECTION_SENSOR SENSOR_ID(DT_ALIAS(on_body_sensor)) @@ -2004,6 +2005,9 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; #ifdef CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE #define CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE #endif /* CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE */ +#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0 +#define CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0 +#endif #endif /* CONFIG_PLATFORM_EC_BODY_DETECTION */ #undef CONFIG_CMD_ACCELS -- cgit v1.2.1 From a4fb69b3d14417ae8b83dc978310b6bd43c32811 Mon Sep 17 00:00:00 2001 From: Josh Tsai Date: Thu, 29 Sep 2022 14:48:56 +0800 Subject: zephyr: add the gesture host detection Kconfig If we need to get the body detection status via ectool, need to enable the CONFIG_GESTURE_HOST_DETECTION. This change add the Kconfig to enable the gesture host detection function in zephyr. BRANCH=none BUG=b:236668095;b:232946420 TEST=zmake build winterhold Signed-off-by: Josh Tsai Change-Id: Id7ae11321b6128b7aba4f6a47897e6cb1ea2f2d8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3928570 Reviewed-by: Diana Z Reviewed-by: Elthan Huang Code-Coverage: Zoss --- util/config_allowed.txt | 1 - zephyr/Kconfig.motionsense | 5 +++++ zephyr/shim/include/config_chip.h | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/util/config_allowed.txt b/util/config_allowed.txt index ca3a980429..033439a022 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -420,7 +420,6 @@ CONFIG_FW_PSTATE_OFF CONFIG_FW_PSTATE_SIZE CONFIG_GESTURE_DETECTION CONFIG_GESTURE_DETECTION_MASK -CONFIG_GESTURE_HOST_DETECTION CONFIG_GESTURE_ORIENTATION CONFIG_GESTURE_SAMPLING_INTERVAL_MS CONFIG_GESTURE_SENSOR_DOUBLE_TAP diff --git a/zephyr/Kconfig.motionsense b/zephyr/Kconfig.motionsense index 98291dc0c3..af859e0075 100644 --- a/zephyr/Kconfig.motionsense +++ b/zephyr/Kconfig.motionsense @@ -174,5 +174,10 @@ config PLATFORM_EC_CONSOLE_CMD_ACCEL_SPOOF endif # PLATFORM_EC_ACCEL_SPOOF_MODE +config PLATFORM_EC_GESTURE_HOST_DETECTION + bool "Gesture host detection" + help + Enable gesture host interface + rsource "Kconfig.sensor_devices" rsource "Kconfig.body_detection" diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 5e38ad800c..b0c0aa2a47 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -2036,6 +2036,11 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; #define CONFIG_CMD_ACCEL_SPOOF #endif +#undef CONFIG_GESTURE_HOST_DETECTION +#ifdef CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION +#define CONFIG_GESTURE_HOST_DETECTION +#endif + #undef CONFIG_SENSOR_TIGHT_TIMESTAMPS #ifdef CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS #define CONFIG_SENSOR_TIGHT_TIMESTAMPS -- cgit v1.2.1 From 13bfcc62f1c1078c34149ab763cb8bc9c0a0764e Mon Sep 17 00:00:00 2001 From: Josh Tsai Date: Thu, 29 Sep 2022 14:49:35 +0800 Subject: ec_commands: modified the ec_motion_sense_activity struct to __ec_todo_packed Resolved the zmake error when CONFIG_GESTURE_HOST_DETECTION is enabled BRANCH=none BUG=none TEST=zmake build winterhold Signed-off-by: Josh Tsai Change-Id: Icd68003dd1e3ec4a297af65b175dccb80c38b573 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3928571 Code-Coverage: Zoss Reviewed-by: Yuval Peress Reviewed-by: Tim Van Patten Reviewed-by: Raul Rangel Reviewed-by: Elthan Huang --- include/ec_commands.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ec_commands.h b/include/ec_commands.h index 5384fb70ae..6c30528d44 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -2840,8 +2840,8 @@ struct ec_motion_sense_activity { uint8_t activity; /* one of enum motionsensor_activity */ uint8_t enable; /* 1: enable, 0: disable */ uint8_t reserved; - uint16_t parameters[3]; /* activity dependent parameters */ -} __ec_todo_unpacked; + uint16_t parameters[4]; /* activity dependent parameters */ +} __ec_todo_packed; /* Module flag masks used for the dump sub-command. */ #define MOTIONSENSE_MODULE_FLAG_ACTIVE BIT(0) -- cgit v1.2.1 From 80d7bbf0c263f526a9651168a6e4013a9b28cfff Mon Sep 17 00:00:00 2001 From: Josh Tsai Date: Mon, 3 Oct 2022 08:52:30 +0800 Subject: Zephyr: winterhold: use base accelerometer for on-body sensor Add the base accelerometer for on-body sensor BRANCH=none BUG=b:236668095;b:232946420 TEST=zmake build winterhold Signed-off-by: Josh Tsai Change-Id: I799508688f2f2cf255802ffd17bf99806b922630 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3929900 Code-Coverage: Zoss Reviewed-by: Elthan Huang Reviewed-by: Diana Z --- zephyr/program/skyrim/motionsense_winterhold.dts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zephyr/program/skyrim/motionsense_winterhold.dts b/zephyr/program/skyrim/motionsense_winterhold.dts index 514687da79..60d345c0a2 100644 --- a/zephyr/program/skyrim/motionsense_winterhold.dts +++ b/zephyr/program/skyrim/motionsense_winterhold.dts @@ -15,6 +15,9 @@ */ bmi3xx-int = &base_accel; lis2dw12-int = &base_accel; + + /* Use base accelerometer for on-body sensor */ + on-body-sensor = &base_accel; }; /* -- cgit v1.2.1 From 55c28482456a53f14e8709c9a9953157f605562f Mon Sep 17 00:00:00 2001 From: Josh Tsai Date: Mon, 3 Oct 2022 08:54:41 +0800 Subject: Winterhold: enable the body detection function Enable the body detection related configuration for winterhold BRANCH=none BUG=b:236668095;b:232946420 TEST=zmake build winterhold Signed-off-by: Josh Tsai Change-Id: I867fc4734ec144486eb2b4335d22ec27fa1a46ae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3928572 Reviewed-by: Elthan Huang Reviewed-by: Diana Z Code-Coverage: Zoss --- zephyr/program/skyrim/prj_winterhold.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zephyr/program/skyrim/prj_winterhold.conf b/zephyr/program/skyrim/prj_winterhold.conf index 0703a50b14..84be72ec0e 100644 --- a/zephyr/program/skyrim/prj_winterhold.conf +++ b/zephyr/program/skyrim/prj_winterhold.conf @@ -39,3 +39,9 @@ CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n # Battery CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y + +# Body detection configuration +CONFIG_PLATFORM_EC_BODY_DETECTION=y +CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0=y +CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE=y +CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION=y -- cgit v1.2.1 From 17cab71f7615dde39adcbc9cdc0b5933da763a0e Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Mon, 21 Nov 2022 15:11:56 +0800 Subject: xivu: add 2nd source for motionsensors Follow the SSFC to setup the motionsensor chip. BUG=b:258749706 BRANCH=none TEST=zmake build xivu Signed-off-by: Matt Wang Change-Id: I346a819ac510a77fbb3a90a34ff22c9b51abe66c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4040430 Reviewed-by: Peter Marheine Code-Coverage: Andrew McRae Commit-Queue: Andrew McRae Reviewed-by: SamSP Liu Tested-by: Andrew McRae --- zephyr/program/nissa/CMakeLists.txt | 1 + zephyr/program/nissa/xivu/cbi.dtsi | 56 +++++++++++++++++ zephyr/program/nissa/xivu/motionsense.dtsi | 96 +++++++++++++++++++++++++++++ zephyr/program/nissa/xivu/overlay.dtsi | 7 ++- zephyr/program/nissa/xivu/project.conf | 8 ++- zephyr/program/nissa/xivu/src/form_factor.c | 79 ++++++++++++++++++++++++ 6 files changed, 245 insertions(+), 2 deletions(-) create mode 100644 zephyr/program/nissa/xivu/src/form_factor.c diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index 7088092ae6..0aeaf1a82b 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -57,6 +57,7 @@ endif() if(DEFINED CONFIG_BOARD_XIVU) project(xivu) zephyr_library_sources( + "xivu/src/form_factor.c" "xivu/src/keyboard.c" ) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "xivu/src/usbc.c") diff --git a/zephyr/program/nissa/xivu/cbi.dtsi b/zephyr/program/nissa/xivu/cbi.dtsi index 4149ea291c..72f83c28a4 100644 --- a/zephyr/program/nissa/xivu/cbi.dtsi +++ b/zephyr/program/nissa/xivu/cbi.dtsi @@ -74,4 +74,60 @@ /delete-node/ fan; }; + /* Xivu-specific ssfc fields. */ + cbi-ssfc { + compatible = "cros-ec,cbi-ssfc"; + /* + * SSFC field to identify LID motion sensor. + */ + lid-sensor { + enum-name = "LID_SENSOR"; + size = <2>; + + lid_sensor_none: none { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <0>; + default; + }; + + lid_sensor_lis2dw12: lis2dw12 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + lid_sensor_bma422: bma422 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + /* + * SSFC field to identify BASE motion sensor. + */ + base-sensor { + enum-name = "BASE_SENSOR"; + size = <2>; + + base_sensor_none: none { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <0>; + default; + }; + base_sensor_lsm6dso: lsm6dso { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + base_sensor_bmi323: bmi323 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + }; + }; diff --git a/zephyr/program/nissa/xivu/motionsense.dtsi b/zephyr/program/nissa/xivu/motionsense.dtsi index 332252c4ef..e5c1f3d2e2 100644 --- a/zephyr/program/nissa/xivu/motionsense.dtsi +++ b/zephyr/program/nissa/xivu/motionsense.dtsi @@ -13,6 +13,8 @@ */ lsm6dso-int = &base_accel; lis2dw12-int = &lid_accel; + bmi3xx-int = &base_accel; + bma4xx-int = &lid_accel; }; /* @@ -27,8 +29,14 @@ lid_mutex: lid-mutex { }; + lid_mutex_bma422: bma422-mutex { + }; + base_mutex: base-mutex { }; + + base_mutex_bmi323: bmi323-mutex { + }; }; /* Rotation matrix used by drivers. */ @@ -45,6 +53,18 @@ 1 0 0 0 0 1>; }; + + lid_rot_bma422: lid-rotation-bma { + mat33 = <(-1) 0 0 + 0 1 0 + 0 0 (-1)>; + }; + + base_rot_ref_bmi: base-rotation-ref-bmi { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; }; /* @@ -71,6 +91,16 @@ compatible = "cros-ec,drvdata-lis2dw12"; status = "okay"; }; + + bma422_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; }; /* @@ -142,6 +172,72 @@ }; }; + motionsense-sensor-alt { + alt_lid_accel: alt-lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex_bma422>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_bma422>; + default-range = <2>; + drv-data = <&bma422_data>; + i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; + alternate-for = <&lid_accel>; + alternate-ssfc-indicator = <&lid_sensor_bma422>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_accel: alt-base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_accel>; + alternate-ssfc-indicator = <&base_sensor_bmi323>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_gyro>; + alternate-ssfc-indicator = <&base_sensor_bmi323>; + }; + }; + motionsense-sensor-info { compatible = "cros-ec,motionsense-sensor-info"; diff --git a/zephyr/program/nissa/xivu/overlay.dtsi b/zephyr/program/nissa/xivu/overlay.dtsi index de45db75e7..73cc10e801 100644 --- a/zephyr/program/nissa/xivu/overlay.dtsi +++ b/zephyr/program/nissa/xivu/overlay.dtsi @@ -58,7 +58,12 @@ int_imu: ec_imu { irq-pin = <&gpio_imu_int_l>; flags = ; - handler = "lsm6dso_interrupt"; + handler = "motion_interrupt"; + }; + int_lid_accel: ec_lid_accel { + irq-pin = <&gpio_acc_int_l>; + flags = ; + handler = "lid_accel_interrupt"; }; int_vol_down: vol_down { irq-pin = <&gpio_voldn_btn_odl>; diff --git a/zephyr/program/nissa/xivu/project.conf b/zephyr/program/nissa/xivu/project.conf index d686f5bd0b..d20c490c20 100644 --- a/zephyr/program/nissa/xivu/project.conf +++ b/zephyr/program/nissa/xivu/project.conf @@ -4,7 +4,6 @@ CONFIG_BOARD_XIVU=y CONFIG_PLATFORM_EC_OCPC=y -CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10 @@ -17,3 +16,10 @@ CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 # Battery CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y + +# Montionsense +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y diff --git a/zephyr/program/nissa/xivu/src/form_factor.c b/zephyr/program/nissa/xivu/src/form_factor.c new file mode 100644 index 0000000000..9a55dacd53 --- /dev/null +++ b/zephyr/program/nissa/xivu/src/form_factor.c @@ -0,0 +1,79 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "accelgyro.h" +#include "button.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/accel_bma4xx.h" +#include "driver/accel_lis2dw12_public.h" +#include "driver/accelgyro_bmi323.h" +#include "driver/accelgyro_lsm6dso.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "motionsense_sensors.h" +#include "motion_sense.h" +#include "tablet_mode.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +static bool use_alt_sensor; +static bool use_alt_lid_accel; + +void motion_interrupt(enum gpio_signal signal) +{ + if (use_alt_sensor) + bmi3xx_interrupt(signal); + else + lsm6dso_interrupt(signal); +} + +void lid_accel_interrupt(enum gpio_signal signal) +{ + if (use_alt_lid_accel) + bma4xx_interrupt(signal); + else + lis2dw12_interrupt(signal); +} + +static void form_factor_init(void) +{ + if (cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_bmi323)))) { + use_alt_sensor = true; + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro); + ccprints("BASE ACCEL IS BMI323"); + } else if (cros_cbi_ssfc_check_match(CBI_SSFC_VALUE_ID( + DT_NODELABEL(base_sensor_lsm6dso)))) { + use_alt_sensor = false; + ccprints("BASE ACCEL IS LSM6DSO"); + } else { + use_alt_sensor = false; + ccprints("no motionsense"); + } + + if (cros_cbi_ssfc_check_match( + CBI_SSFC_VALUE_ID(DT_NODELABEL(lid_sensor_bma422)))) { + use_alt_lid_accel = true; + MOTIONSENSE_ENABLE_ALTERNATE(alt_lid_accel); + ccprints("LID SENSOR IS BMA422"); + } else if (cros_cbi_ssfc_check_match(CBI_SSFC_VALUE_ID( + DT_NODELABEL(lid_sensor_lis2dw12)))) { + use_alt_lid_accel = false; + ccprints("LID SENSOR IS LIS2DW12"); + } else { + use_alt_lid_accel = false; + ccprints("no lid sensor"); + } + + motion_sensors_check_ssfc(); +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); -- cgit v1.2.1 From 9e03f318c58dbd9944db627accead18b5d11c5a0 Mon Sep 17 00:00:00 2001 From: Zhuohao Lee Date: Fri, 18 Nov 2022 10:27:27 +0800 Subject: power_button: change the power_button_simulate_press implementation Prior to this patch, if a task calls the power_button_simulate_press(), that task will be suspended until msleep(duration) timeout. There are two cases here: 1. If the priority of the task is higher than the hook task, the power press simulation will work correctly. 2. However, If it is hook task, the power_button_simulate_press() will be unexpected because the hook task will be sleep until timeout and the power_button_change_deferred() will only be called once. To fix 2, we modify power_button_simulate_press and add a deferred function power_button_simulate_deferred() to release the power button. BUG=b:256052830 BRANCH=None TEST=flashed the ec.bin to the device and checked the command powerbtn is working. Change-Id: I002b1939ca1fad27bfba595ba32c3b6b06c214b7 Signed-off-by: Zhuohao Lee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4037228 Reviewed-by: Jameson Thies Tested-by: Scott Chao Code-Coverage: Zoss --- common/power_button.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/common/power_button.c b/common/power_button.c index 36d7e510d2..484d25154a 100644 --- a/common/power_button.c +++ b/common/power_button.c @@ -184,6 +184,15 @@ static void power_button_change_deferred(void) } DECLARE_DEFERRED(power_button_change_deferred); +static void power_button_simulate_deferred(void) +{ + ccprintf("Simulating %s release.\n", power_button.name); + simulate_power_pressed = 0; + power_button_is_stable = 0; + power_button_change_deferred(); +} +DECLARE_DEFERRED(power_button_simulate_deferred); + void power_button_interrupt(enum gpio_signal signal) { /* @@ -205,15 +214,9 @@ void power_button_simulate_press(unsigned int duration) ccprintf("Simulating %d ms %s press.\n", duration, power_button.name); simulate_power_pressed = 1; power_button_is_stable = 0; - hook_call_deferred(&power_button_change_deferred_data, 0); - - if (duration > 0) - msleep(duration); - - ccprintf("Simulating %s release.\n", power_button.name); - simulate_power_pressed = 0; - power_button_is_stable = 0; - hook_call_deferred(&power_button_change_deferred_data, 0); + power_button_change_deferred(); + hook_call_deferred(&power_button_simulate_deferred_data, + duration * MSEC); } /*****************************************************************************/ -- cgit v1.2.1 From 6ff9e40f0574d45989b072c2909d7301a5722fbb Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Tue, 15 Nov 2022 16:15:13 +0800 Subject: corsola: steelix: uses npcx_*.dtsi Merge the .dtsi files to steelix/project.overlay cbi.dtsi and interrupts.dtsi are the exceptions which are shared with the tests. BUG=b:254097516 TEST=zmake compare-builds; Note, only the npcx_gpio.dtsi makes the build difference due to the GPIO sequence changed. BRANCH=none Change-Id: I5a6a4a54ac6d0cc6bfbfb1eb671947d95e56cf0e Signed-off-by: Eric Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4037127 Auto-Submit: Eric Yilun Lin Tested-by: Eric Yilun Lin Reviewed-by: Ting Shen Code-Coverage: Zoss Commit-Queue: Ting Shen --- zephyr/program/corsola/battery_kingler.dtsi | 15 -- zephyr/program/corsola/battery_steelix.dtsi | 24 -- zephyr/program/corsola/cbi_steelix.dtsi | 95 -------- zephyr/program/corsola/gpio_steelix.dtsi | 255 --------------------- zephyr/program/corsola/interrupts_steelix.dtsi | 10 - zephyr/program/corsola/keyboard_steelix.dtsi | 29 --- zephyr/program/corsola/kingler/project.overlay | 79 ++++++- zephyr/program/corsola/led_kingler.dtsi | 71 ------ zephyr/program/corsola/led_steelix.dtsi | 55 ----- zephyr/program/corsola/motionsense_steelix.dtsi | 133 ----------- zephyr/program/corsola/steelix/cbi.dtsi | 95 ++++++++ zephyr/program/corsola/steelix/interrupts.dtsi | 12 + zephyr/program/corsola/steelix/project.overlay | 288 +++++++++++++++++++++++- zephyr/program/corsola/usba_steelix.dtsi | 10 - zephyr/test/kingler/testcase.yaml | 14 +- 15 files changed, 471 insertions(+), 714 deletions(-) delete mode 100644 zephyr/program/corsola/battery_kingler.dtsi delete mode 100644 zephyr/program/corsola/battery_steelix.dtsi delete mode 100644 zephyr/program/corsola/cbi_steelix.dtsi delete mode 100644 zephyr/program/corsola/gpio_steelix.dtsi delete mode 100644 zephyr/program/corsola/interrupts_steelix.dtsi delete mode 100644 zephyr/program/corsola/keyboard_steelix.dtsi delete mode 100644 zephyr/program/corsola/led_kingler.dtsi delete mode 100644 zephyr/program/corsola/led_steelix.dtsi delete mode 100644 zephyr/program/corsola/motionsense_steelix.dtsi create mode 100644 zephyr/program/corsola/steelix/cbi.dtsi create mode 100644 zephyr/program/corsola/steelix/interrupts.dtsi delete mode 100644 zephyr/program/corsola/usba_steelix.dtsi diff --git a/zephyr/program/corsola/battery_kingler.dtsi b/zephyr/program/corsola/battery_kingler.dtsi deleted file mode 100644 index b01fb8a46d..0000000000 --- a/zephyr/program/corsola/battery_kingler.dtsi +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: smp_l20m3pg2 { - compatible = "smp,l20m3pg2", "battery-smart"; - }; - lgc_l20l3pg2 { - compatible = "lgc,l20l3pg2", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/corsola/battery_steelix.dtsi b/zephyr/program/corsola/battery_steelix.dtsi deleted file mode 100644 index 594c83478c..0000000000 --- a/zephyr/program/corsola/battery_steelix.dtsi +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: byd_l22b3pg0 { - compatible = "byd,l22b3pg0", "battery-smart"; - }; - celxpert_l22c3pg0 { - compatible = "celxpert,l22c3pg0", "battery-smart"; - }; - cosmx_l22x3pg0 { - compatible = "cosmx,l22x3pg0", "battery-smart"; - }; - smp_l22m3pg0 { - compatible = "smp,l22m3pg0", "battery-smart"; - }; - sunwoda_l22d3pg0 { - compatible = "sunwoda,l22d3pg0", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/corsola/cbi_steelix.dtsi b/zephyr/program/corsola/cbi_steelix.dtsi deleted file mode 100644 index 6636b53a96..0000000000 --- a/zephyr/program/corsola/cbi_steelix.dtsi +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - steelix-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - /* - * FW_CONFIG field to indicate the device is clamshell - * or convertible. - */ - form_factor { - enum-name = "FORM_FACTOR"; - start = <13>; - size = <3>; - - convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "CONVERTIBLE"; - value = <1>; - }; - clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "CLAMSHELL"; - value = <0>; - }; - }; - - /* FW_CONFIG field to indicate which DB is attached. */ - db_config: db { - enum-name = "DB"; - start = <0>; - size = <4>; - - sub-board-1 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_NONE"; - value = <0>; - }; - sub-board-2 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_USBA_HDMI"; - value = <1>; - }; - sub-board-3 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "DB_USBA_HDMI_LTE"; - value = <2>; - }; - }; - }; - - /* Steelix-specific ssfc fields. */ - steelix-ssfc { - compatible = "cros-ec,cbi-ssfc"; - - /* SSFC field to identify BASE motion sensor. */ - base-sensor { - enum-name = "BASE_SENSOR"; - size = <3>; - - base_sensor_0: bmi323 { - compatible = "cros-ec,cbi-ssfc-value"; - status = "okay"; - value = <1>; - default; - }; - base_sensor_1: lsm6dsm { - compatible = "cros-ec,cbi-ssfc-value"; - status = "okay"; - value = <2>; - }; - }; - - /* SSFC field to identify LID motion sensor. */ - lid-sensor { - enum-name = "LID_SENSOR"; - size = <3>; - - lid_sensor_0: bma422 { - compatible = "cros-ec,cbi-ssfc-value"; - status = "okay"; - value = <1>; - default; - }; - lid_sensor_1: lis2dw12 { - compatible = "cros-ec,cbi-ssfc-value"; - status = "okay"; - value = <2>; - }; - }; - }; -}; diff --git a/zephyr/program/corsola/gpio_steelix.dtsi b/zephyr/program/corsola/gpio_steelix.dtsi deleted file mode 100644 index 14120e6d7d..0000000000 --- a/zephyr/program/corsola/gpio_steelix.dtsi +++ /dev/null @@ -1,255 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-cbi-wp = &gpio_ec_cbi_wp; - gpio-wp = &gpio_ec_wp_l; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - named-gpios { - compatible = "named-gpios"; - - /* - * In npcx9 series, gpio46, gpio47, and the whole gpio5 port - * belong to VHIF power well. On steelix, it is connencted to - * 1.8V. - */ - base_imu_int_l: base_imu_int_l { - gpios = <&gpio5 6 GPIO_INPUT>; - }; - spi_ap_clk_ec { - gpios = <&gpio5 5 GPIO_INPUT>; - }; - spi_ap_cs_ec_l { - gpios = <&gpio5 3 GPIO_INPUT>; - }; - spi_ap_do_ec_di { - gpios = <&gpio4 6 GPIO_INPUT>; - }; - spi_ap_di_ec_do { - gpios = <&gpio4 7 GPIO_INPUT>; - }; - ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; - enum-name = "GPIO_AP_EC_WARM_RST_REQ"; - }; - ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_WDTRST_L"; - }; - ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_IN_SLEEP_L"; - }; - gpio_en_ulp: en_ulp { - gpios = <&gpioc 6 GPIO_OUTPUT_LOW>; - }; - en_ec_id_odl { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - }; - sys_rst_odl { - gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_SYS_RST_ODL"; - }; - ec_i2c_sensor_scl { - gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_sensor_sda { - gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_usb_c0_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_c0_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_usb_c1_scl { - gpios = <&gpio9 2 GPIO_INPUT>; - }; - ec_i2c_usb_c1_sda { - gpios = <&gpio9 1 GPIO_INPUT>; - }; - ec_i2c_pwr_cbi_scl { - gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_pwr_cbi_sda { - gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_batt_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_batt_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x { - gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; - }; - usb_a1_fault_odl { - gpios = <&gpiof 4 GPIO_INPUT>; - }; - ec_pen_chg_dis_odl { - gpios = <&gpioe 4 GPIO_INPUT>; - }; - gpio_ec_cbi_wp: ec_cbi_wp { - gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; - }; - gpio_ec_wp_l: ec_wp_odl { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | - GPIO_VOLTAGE_1P8)>; - }; - lid_accel_int_l { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - gpio_tablet_mode_l: tablet_mode_l { - gpios = <&gpiob 2 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ec_ap_int_odl { - gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpio8 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - ec_entering_rw { - gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; - }; - charger_prochot_odl { - gpios = <&gpiob 1 GPIO_INPUT>; - }; - ec_rst_odl { - gpios = <&gpio7 7 GPIO_INPUT>; - }; - gpio_lid_open: lid_open { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { - gpios = <&gpio0 1 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_en_5v_usm: en_5v_usm { - gpios = <&gpio0 2 GPIO_OUTPUT_LOW>; - }; - packet_mode_en { - gpios = <&gpio7 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_x_ec_gpio2: x_ec_gpio2 { - gpios = <&gpiod 4 GPIO_INPUT>; - }; - /* - * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 - * belong to VSPI power well. On steelix, it is connencted to - * 1.8V. - */ - ap_sysrst_odl_r: ap_sysrst_odl_r { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - enum-name = "GPIO_AP_EC_SYSRST_ODL"; - }; - gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio6 7 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - pg_pp5000_z2_od { - gpios = <&gpio7 0 GPIO_INPUT>; - }; - gpio_ec_x_gpio1: ec_x_gpio1 { - gpios = <&gpio6 2 GPIO_OUTPUT_LOW>; - }; - dp_aux_path_sel: dp_aux_path_sel { - gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>; - }; - gpio_ec_bl_en_od: ec_bl_en_od { - gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; - }; - gpio_ec_x_gpio3: ec_x_gpio3 { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpio7 3 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { - gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; - }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - }; - gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { - gpios = <&gpio3 7 GPIO_INPUT>; - }; - en_pp5000_z2 { - gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioe 1 GPIO_INPUT>; - }; - ec_batt_pres_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - usb_a0_fault_odl { - gpios = <&gpioc 7 GPIO_INPUT>; - }; - ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpio6 1 GPIO_ODR_HIGH>; - }; - ec_pmic_en_odl { - gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - enum-name = "GPIO_EC_PMIC_EN_ODL"; - }; - gpio_ec_volup_btn_odl: ec_volup_btn_odl { - gpios = <&gpiod 5 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { - gpios = <&gpioe 2 GPIO_INPUT>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - gpio_ccd_mode_odl: ccd_mode_odl { - gpios = <&gpioe 5 GPIO_INPUT>; - enum-name = "GPIO_CCD_MODE_ODL"; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - }; - - /* - * aliases for sub-board GPIOs - */ - aliases { - gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; - gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; - gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; - gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; - gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; - gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; - }; - - hibernate-wake-pins { - compatible = "cros-ec,hibernate-wake-pins"; - wakeup-irqs = < - &int_ac_present - &int_power_button - &int_lid_open - >; - }; -}; diff --git a/zephyr/program/corsola/interrupts_steelix.dtsi b/zephyr/program/corsola/interrupts_steelix.dtsi deleted file mode 100644 index 816beb95f4..0000000000 --- a/zephyr/program/corsola/interrupts_steelix.dtsi +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -&int_base_imu { - irq-pin = <&base_imu_int_l>; - flags = ; - handler = "motion_interrupt"; -}; diff --git a/zephyr/program/corsola/keyboard_steelix.dtsi b/zephyr/program/corsola/keyboard_steelix.dtsi deleted file mode 100644 index 951389448a..0000000000 --- a/zephyr/program/corsola/keyboard_steelix.dtsi +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - cros-keyscan { - compatible = "cros-ec,keyscan"; - - debounce-down = <15000>; - debounce-up = <15000>; - - actual-key-mask = < - 0x1c /* C0 */ - 0xff /* C1 */ - 0xff /* C2 */ - 0xff /* C3 */ - 0xff /* C4 */ - 0xf5 /* C5 */ - 0xff /* C6 */ - 0xa4 /* C7 */ - 0xff /* C8 */ - 0xfe /* C9 */ - 0x55 /* C10 */ - 0xfa /* C11 */ - 0xca /* C12 */ - >; - }; -}; diff --git a/zephyr/program/corsola/kingler/project.overlay b/zephyr/program/corsola/kingler/project.overlay index baa3185616..93f06d94e2 100644 --- a/zephyr/program/corsola/kingler/project.overlay +++ b/zephyr/program/corsola/kingler/project.overlay @@ -9,13 +9,88 @@ #include "../power_signal.dtsi" #include "../usba.dtsi" #include "../npcx_adc.dtsi" -#include "../battery_kingler.dtsi" #include "../npcx_host_interface.dtsi" #include "../npcx_i2c.dtsi" #include "../npcx_interrupts.dtsi" #include "../npcx_gpio.dtsi" #include "../npcx_keyboard.dtsi" -#include "../led_kingler.dtsi" #include "../npcx_motionsense.dtsi" #include "../npcx_usbc.dtsi" #include "../npcx_default_gpio_pinctrl.dtsi" + +/* board override */ +/ { + batteries { + default_battery: smp_l20m3pg2 { + compatible = "smp,l20m3pg2", "battery-smart"; + }; + lgc_l20l3pg2 { + compatible = "lgc,l20l3pg2", "battery-smart"; + }; + }; + + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED + &pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED + &pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0>; + + color-map-red = <100 0 0>; + color-map-green = < 0 100 0>; + color-map-amber = <100 20 0>; + + brightness-range = <255 255 0 0 0 255>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + }; +}; + +/* Red LED */ +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* Green LED */ +&pwm1_gpc2 { + drive-open-drain; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* Blue LED */ +&pwm2_gpc4 { + drive-open-drain; +}; + +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/corsola/led_kingler.dtsi b/zephyr/program/corsola/led_kingler.dtsi deleted file mode 100644 index 92f6c4d4fe..0000000000 --- a/zephyr/program/corsola/led_kingler.dtsi +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_led0: pwm_led_0 { - pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED - &pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED - &pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - cros-pwmleds { - compatible = "cros-ec,pwm-leds"; - - leds = <&pwm_led0>; - - color-map-red = <100 0 0>; - color-map-green = < 0 100 0>; - color-map-amber = <100 20 0>; - - brightness-range = <255 255 0 0 0 255>; - - #address-cells = <1>; - #size-cells = <0>; - - pwm_led_0@0 { - reg = <0>; - ec-led-name = "EC_LED_ID_BATTERY_LED"; - }; - }; -}; - -/* Red LED */ -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -/* Green LED */ -&pwm1_gpc2 { - drive-open-drain; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -/* Blue LED */ -&pwm2_gpc4 { - drive-open-drain; -}; - -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/corsola/led_steelix.dtsi b/zephyr/program/corsola/led_steelix.dtsi deleted file mode 100644 index 6a25929327..0000000000 --- a/zephyr/program/corsola/led_steelix.dtsi +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - led_battery_red: ec_led1_odl { - pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - led_battery_green: ec_led2_odl { - pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - led_power_white: ec_led3_odl { - pwms = <&pwm4 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; -}; - -/* Red LED */ -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; - -/* Green LED */ -&pwm1_gpc2 { - drive-open-drain; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -/* White LED */ -&pwm4_gpb6 { - drive-open-drain; -}; - -&pwm4 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm4_gpb6>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/corsola/motionsense_steelix.dtsi b/zephyr/program/corsola/motionsense_steelix.dtsi deleted file mode 100644 index df96fc2e42..0000000000 --- a/zephyr/program/corsola/motionsense_steelix.dtsi +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/* inherit the rot_ref from Kingler and overwrite it */ -&lid_rot_ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; -}; - -&base_rot_ref { - mat33 = <1 0 0 - 0 (-1) 0 - 0 0 (-1)>; -}; - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - lsm6dsm-int = &base_accel; - }; - - /* Rotation matrix used by drivers. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - base_rot_ref_lsm6dsm: base-rotation-ref-lsm6dsm { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - lsm6dsm_data_accel: lsm6dsm-accel-drv-data { - compatible = "cros-ec,drvdata-lsm6dsm"; - status = "okay"; - }; - lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data { - compatible = "cros-ec,drvdata-lsm6dsm"; - status = "okay"; - }; - }; - - motionsense-sensor-alt { - alt_lid_accel: alt-lid-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; - alternate-for = <&lid_accel>; - alternate-ssfc-indicator = <&lid_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - alt_base_accel: alt-base-accel { - compatible = "cros-ec,lsm6dsm-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_lsm6dsm>; - drv-data = <&lsm6dsm_data_accel>; - alternate-for = <&base_accel>; - alternate-ssfc-indicator = <&base_sensor_1>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <(100 * USEC_PER_MSEC)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <0>; - }; - }; - }; - - alt_base_gyro: alt-base-gyro { - compatible = "cros-ec,lsm6dsm-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&base_mutex>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref_lsm6dsm>; - default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ - drv-data = <&lsm6dsm_data_gyro>; - alternate-for = <&base_gyro>; - alternate-ssfc-indicator = <&base_sensor_1>; - }; - }; -}; diff --git a/zephyr/program/corsola/steelix/cbi.dtsi b/zephyr/program/corsola/steelix/cbi.dtsi new file mode 100644 index 0000000000..6636b53a96 --- /dev/null +++ b/zephyr/program/corsola/steelix/cbi.dtsi @@ -0,0 +1,95 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + steelix-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to indicate the device is clamshell + * or convertible. + */ + form_factor { + enum-name = "FORM_FACTOR"; + start = <13>; + size = <3>; + + convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CONVERTIBLE"; + value = <1>; + }; + clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CLAMSHELL"; + value = <0>; + }; + }; + + /* FW_CONFIG field to indicate which DB is attached. */ + db_config: db { + enum-name = "DB"; + start = <0>; + size = <4>; + + sub-board-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_NONE"; + value = <0>; + }; + sub-board-2 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_USBA_HDMI"; + value = <1>; + }; + sub-board-3 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_USBA_HDMI_LTE"; + value = <2>; + }; + }; + }; + + /* Steelix-specific ssfc fields. */ + steelix-ssfc { + compatible = "cros-ec,cbi-ssfc"; + + /* SSFC field to identify BASE motion sensor. */ + base-sensor { + enum-name = "BASE_SENSOR"; + size = <3>; + + base_sensor_0: bmi323 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + base_sensor_1: lsm6dsm { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + + /* SSFC field to identify LID motion sensor. */ + lid-sensor { + enum-name = "LID_SENSOR"; + size = <3>; + + lid_sensor_0: bma422 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + lid_sensor_1: lis2dw12 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/program/corsola/steelix/interrupts.dtsi b/zephyr/program/corsola/steelix/interrupts.dtsi new file mode 100644 index 0000000000..b212cd9496 --- /dev/null +++ b/zephyr/program/corsola/steelix/interrupts.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + /* This file should only be included in the project.overlay. */ +&int_base_imu { + irq-pin = <&base_imu_int_l>; + flags = ; + handler = "motion_interrupt"; +}; + diff --git a/zephyr/program/corsola/steelix/project.overlay b/zephyr/program/corsola/steelix/project.overlay index 3feea490be..f850a51563 100644 --- a/zephyr/program/corsola/steelix/project.overlay +++ b/zephyr/program/corsola/steelix/project.overlay @@ -9,18 +9,290 @@ #include "../power_signal.dtsi" #include "../usba.dtsi" #include "../npcx_adc.dtsi" -#include "../battery_steelix.dtsi" +#include "../npcx_gpio.dtsi" #include "../npcx_host_interface.dtsi" #include "../npcx_i2c.dtsi" #include "../npcx_interrupts.dtsi" -#include "../interrupts_steelix.dtsi" -#include "../cbi_steelix.dtsi" -#include "../gpio_steelix.dtsi" #include "../npcx_keyboard.dtsi" -#include "../keyboard_steelix.dtsi" -#include "../led_steelix.dtsi" #include "../npcx_motionsense.dtsi" -#include "../motionsense_steelix.dtsi" -#include "../usba_steelix.dtsi" #include "../npcx_usbc.dtsi" #include "../npcx_default_gpio_pinctrl.dtsi" + +/* Projrect level DTS shared with tests */ +#include "./cbi.dtsi" +#include "./interrupts.dtsi" + +/* board override */ +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + lsm6dsm-int = &base_accel; + }; + + named-gpios { + en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x { + gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; + }; + usb_a1_fault_odl { + gpios = <&gpiof 4 GPIO_INPUT>; + }; + }; + + batteries { + default_battery: byd_l22b3pg0 { + compatible = "byd,l22b3pg0", "battery-smart"; + }; + celxpert_l22c3pg0 { + compatible = "celxpert,l22c3pg0", "battery-smart"; + }; + cosmx_l22x3pg0 { + compatible = "cosmx,l22x3pg0", "battery-smart"; + }; + smp_l22m3pg0 { + compatible = "smp,l22m3pg0", "battery-smart"; + }; + sunwoda_l22d3pg0 { + compatible = "sunwoda,l22d3pg0", "battery-smart"; + }; + }; + + + /* Steelix-specific ssfc fields. */ + steelix-ssfc { + compatible = "cros-ec,cbi-ssfc"; + + /* SSFC field to identify BASE motion sensor. */ + base-sensor { + enum-name = "BASE_SENSOR"; + size = <3>; + + base_sensor_0: bmi323 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + base_sensor_1: lsm6dsm { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + + /* SSFC field to identify LID motion sensor. */ + lid-sensor { + enum-name = "LID_SENSOR"; + size = <3>; + + lid_sensor_0: bma422 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <1>; + default; + }; + lid_sensor_1: lis2dw12 { + compatible = "cros-ec,cbi-ssfc-value"; + status = "okay"; + value = <2>; + }; + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + base_rot_ref_lsm6dsm: base-rotation-ref-lsm6dsm { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + lsm6dsm_data_accel: lsm6dsm-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dsm"; + status = "okay"; + }; + lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dsm"; + status = "okay"; + }; + }; + + motionsense-sensor-alt { + alt_lid_accel: alt-lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + alternate-for = <&lid_accel>; + alternate-ssfc-indicator = <&lid_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_accel: alt-base-accel { + compatible = "cros-ec,lsm6dsm-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_lsm6dsm>; + drv-data = <&lsm6dsm_data_accel>; + alternate-for = <&base_accel>; + alternate-ssfc-indicator = <&base_sensor_1>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <(100 * USEC_PER_MSEC)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <0>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,lsm6dsm-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_lsm6dsm>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dsm_data_gyro>; + alternate-for = <&base_gyro>; + alternate-ssfc-indicator = <&base_sensor_1>; + }; + }; + + cros-keyscan { + compatible = "cros-ec,keyscan"; + + debounce-down = <15000>; + debounce-up = <15000>; + + actual-key-mask = < + 0x1c /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; + + pwmleds { + compatible = "pwm-leds"; + led_battery_red: ec_led1_odl { + pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + led_battery_green: ec_led2_odl { + pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + led_power_white: ec_led3_odl { + pwms = <&pwm4 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; +}; + +/* Red LED */ +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* Green LED */ +&pwm1_gpc2 { + drive-open-drain; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* White LED */ +&pwm4_gpb6 { + drive-open-drain; +}; + +&pwm4 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm4_gpb6>; + pinctrl-names = "default"; +}; + +/* inherit the rot_ref from Kingler and overwrite it */ +&lid_rot_ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; +}; + +&base_rot_ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; +}; + +/* steelix usba port enable config */ +&usba_port_enable_list { + enable-pins = <&en_pp5000_usb_a0_vbus + &en_pp5000_usb_a1_vbus>; +}; diff --git a/zephyr/program/corsola/usba_steelix.dtsi b/zephyr/program/corsola/usba_steelix.dtsi deleted file mode 100644 index 0ddd67f664..0000000000 --- a/zephyr/program/corsola/usba_steelix.dtsi +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* steelix usba port enable config */ -&usba_port_enable_list { - enable-pins = <&en_pp5000_usb_a0_vbus - &en_pp5000_usb_a1_vbus>; -}; diff --git a/zephyr/test/kingler/testcase.yaml b/zephyr/test/kingler/testcase.yaml index 2b1051a510..282ece6e63 100644 --- a/zephyr/test/kingler/testcase.yaml +++ b/zephyr/test/kingler/testcase.yaml @@ -6,36 +6,36 @@ common: platform_allow: native_posix tests: kingler.steelix: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_FORM_FACTOR_CONVERTIBLE=y kingler.rusty: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_FORM_FACTOR_CLAMSHELL=y kingler.db_detect_typec: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/gpio_steelix.dtsi;" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/npcx_gpio.dtsi;" extra_configs: - CONFIG_TEST_DB_DETECT_TYPEC=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.db_detect_hdmi: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/gpio_steelix.dtsi" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/npcx_gpio.dtsi" extra_configs: - CONFIG_TEST_DB_DETECT_HDMI=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.db_detect_none: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi" extra_configs: - CONFIG_TEST_DB_DETECT_NONE=y - CONFIG_VARIANT_CORSOLA_DB_DETECTION=y kingler.ccd: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi" extra_configs: - CONFIG_TEST_KINGLER_CCD=y kingler.alt_sensor: - extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/interrupts_steelix.dtsi;../program/corsola/cbi_steelix.dtsi;../program/corsola/gpio_steelix.dtsi" + extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi" extra_configs: - CONFIG_TEST_STEELIX_RUSTY=y - CONFIG_TEST_ALT_SENSOR_PROBE=y -- cgit v1.2.1 From 7d01b1e58dc8a4dc316964028ea8ebb512f0ee0b Mon Sep 17 00:00:00 2001 From: Tommy Chung Date: Thu, 3 Nov 2022 10:31:21 +0800 Subject: driver/retimer/ps8818.h: Add I2C ADDR FLAGS 0x30, 0x58, 0x70 BUG=b:259354679 BRANCH=none TEST=make buildall -j Signed-off-by: Tommy Chung Change-Id: Ia93b7fb6c927e2d527186e0d59d3e37da01ed820 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4001240 Code-Coverage: Zoss Reviewed-by: Zhuohao Lee --- baseboard/goroh/usbc_config.c | 2 +- baseboard/guybrush/baseboard.c | 2 +- baseboard/zork/variant_trembyle.c | 2 +- board/agah/usbc_config.c | 2 +- board/woomax/board.c | 2 +- include/driver/retimer/ps8818_public.h | 5 ++++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/baseboard/goroh/usbc_config.c b/baseboard/goroh/usbc_config.c index 9d162ca783..3df1e47fbd 100644 --- a/baseboard/goroh/usbc_config.c +++ b/baseboard/goroh/usbc_config.c @@ -81,7 +81,7 @@ static const struct usb_mux_chain goroh_usb_c1_ps8818_retimer = { &(const struct usb_mux){ .usb_port = USBC_PORT_C1, .i2c_port = I2C_PORT_USB_C1, - .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS, + .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS, .driver = &ps8818_usb_retimer_driver, }, .next = NULL, diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c index 780aa28e74..8afcb09fb4 100644 --- a/baseboard/guybrush/baseboard.c +++ b/baseboard/guybrush/baseboard.c @@ -246,7 +246,7 @@ const struct usb_mux usbc1_ps8818 = { .usb_port = USBC_PORT_C1, .i2c_port = I2C_PORT_TCPC1, .flags = USB_MUX_FLAG_RESETS_IN_G3, - .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS, + .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS, .driver = &ps8818_usb_retimer_driver, .board_set = &board_c1_ps8818_mux_set, }; diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c index 9c29e057cc..4542ea562c 100644 --- a/baseboard/zork/variant_trembyle.c +++ b/baseboard/zork/variant_trembyle.c @@ -499,7 +499,7 @@ struct usb_mux usbc1_ps8802 = { const struct usb_mux usbc1_ps8818 = { .usb_port = USBC_PORT_C1, .i2c_port = I2C_PORT_TCPC1, - .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS, + .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS, .driver = &ps8818_usb_retimer_driver, .board_set = &board_ps8818_mux_set, }; diff --git a/board/agah/usbc_config.c b/board/agah/usbc_config.c index a8bad0f121..d078ef59ac 100644 --- a/board/agah/usbc_config.c +++ b/board/agah/usbc_config.c @@ -149,7 +149,7 @@ const static struct usb_mux_chain usbc2_ps8818 = { &(const struct usb_mux){ .usb_port = USBC_PORT_C2, .i2c_port = I2C_PORT_USB_C2_TCPC, - .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS, + .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS, .driver = &ps8818_usb_retimer_driver, .board_set = &board_ps8818_mux_set, }, diff --git a/board/woomax/board.c b/board/woomax/board.c index 747c576fc2..7e9fbd224f 100644 --- a/board/woomax/board.c +++ b/board/woomax/board.c @@ -451,7 +451,7 @@ static int woomax_ps8802_mux_set(const struct usb_mux *me, const struct usb_mux usbc1_woomax_ps8818 = { .usb_port = USBC_PORT_C1, .i2c_port = I2C_PORT_TCPC1, - .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS, + .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS, .driver = &ps8818_usb_retimer_driver, .board_set = &woomax_ps8818_mux_set, }; diff --git a/include/driver/retimer/ps8818_public.h b/include/driver/retimer/ps8818_public.h index 3f0aba963b..bdecb7a0d4 100644 --- a/include/driver/retimer/ps8818_public.h +++ b/include/driver/retimer/ps8818_public.h @@ -9,7 +9,10 @@ #ifndef __CROS_EC_USB_RETIMER_PS8818_H #define __CROS_EC_USB_RETIMER_PS8818_H -#define PS8818_I2C_ADDR_FLAGS 0x28 +#define PS8818_I2C_ADDR0_FLAGS 0x28 +#define PS8818_I2C_ADDR1_FLAGS 0x30 +#define PS8818_I2C_ADDR2_FLAGS 0x58 +#define PS8818_I2C_ADDR3_FLAGS 0x70 /* * PAGE 0 Register Definitions -- cgit v1.2.1 From a8db5c378ec265b5a30aaa3fe2150dc12efc73a5 Mon Sep 17 00:00:00 2001 From: johnwc_yeh Date: Tue, 22 Nov 2022 10:49:27 +0800 Subject: Xivu : Adjust LED PWM duty cycle Adjust the LED PWM duty cycle to 50. BUG=b:255871229 BRANCH=none TEST=zmake build xivu Signed-off-by: johnwc_yeh Change-Id: Idcb3f97a92ada163a7f1bf294c40a79f7ef1d651 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4044804 Reviewed-by: SamSP Liu Reviewed-by: Andrew McRae Code-Coverage: Zoss --- zephyr/program/nissa/xivu/led_pins.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/program/nissa/xivu/led_pins.dtsi b/zephyr/program/nissa/xivu/led_pins.dtsi index e8c0738efd..e7efa3e96c 100644 --- a/zephyr/program/nissa/xivu/led_pins.dtsi +++ b/zephyr/program/nissa/xivu/led_pins.dtsi @@ -37,7 +37,7 @@ br-color = "EC_LED_COLOR_AMBER"; led-pwms = <&pwm_led_y_c0 &pwm_led_y_c1 &pwm_led_w_c0 &pwm_led_w_c1>; - led-values = <1 1 0 0>; + led-values = <50 50 0 0>; }; color_white: color-white { @@ -46,7 +46,7 @@ br-color = "EC_LED_COLOR_WHITE"; led-pwms = <&pwm_led_y_c0 &pwm_led_y_c1 &pwm_led_w_c0 &pwm_led_w_c1>; - led-values = <0 0 1 1>; + led-values = <0 0 50 50>; }; }; }; -- cgit v1.2.1 From 88a3e796ae3653069bac5d107914e37ad628f1c7 Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Tue, 22 Nov 2022 16:17:33 +0800 Subject: Kconfig: fix typo SHA25 -> SHA256 BUG=none TEST=zmake build krabby, no warning message about unsatisfied dependencies BRANCH=none Signed-off-by: Ting Shen Change-Id: I954f29f291d3a9a7ea5aeb5a7bdcdbdc6226d229 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045297 Auto-Submit: Ting Shen Tested-by: Ting Shen Commit-Queue: Eric Yilun Lin Reviewed-by: Eric Yilun Lin Code-Coverage: Zoss --- zephyr/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index dcb0de3cf9..9e04f4a679 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -609,7 +609,7 @@ endchoice # PLATFORM_EC_SHA256_MODE config PLATFORM_EC_SHA256_UNROLLED bool "Manually unroll sha256 transform" - depends on PLATFORM_EC_SHA25_SW + depends on PLATFORM_EC_SHA256_SW default n help Enable loop unroll to improve the performance of sha256 software -- cgit v1.2.1 From 3da772ea2ee46cf14befa8d160aaa1b9109b6338 Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Mon, 21 Nov 2022 15:39:17 -0700 Subject: twister: Check '.config' file for selected configs Use '.config' file instead of 'autoconf.h' for selected configs BUG=b:239952573 BRANCH=None TEST=./twister -T zephyr/test/ Signed-off-by: Al Semjonovs Change-Id: Ia981aafec6902c47e6abf2a9ec5ee6c189e94fe6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043738 Reviewed-by: Yuval Peress --- util/zephyr_to_resultdb.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py index 722c5b0323..6c378bde5c 100755 --- a/util/zephyr_to_resultdb.py +++ b/util/zephyr_to_resultdb.py @@ -137,15 +137,17 @@ def get_testsuite_config_tags(twister_dir, testsuite): """Creates config tags from the testsuite""" config_tags = [] suite_path = f"{twister_dir}/{testsuite['platform']}/{testsuite['name']}" - autoconf_h = f"{suite_path}/zephyr/include/generated/autoconf.h" + dot_config = f"{suite_path}/zephyr/.config" - if pathlib.Path(autoconf_h).exists(): - with open(autoconf_h) as file: + if pathlib.Path(dot_config).exists(): + with open(dot_config) as file: lines = file.readlines() for line in lines: - result = re.search(r"#define\s*(\w+)\s*(.+$)", line) - config_tags.append((result.group(1), result.group(2))) + # Ignore empty lines and comments + if line.strip() and not line.startswith("#"): + result = re.search(r"(\w+)=(.+$)", line) + config_tags.append((result.group(1), result.group(2))) else: print(f"Can't find config file for {testsuite['name']}") -- cgit v1.2.1 From 05c088702242600fa4878cd3a6057d6dfd74bdfb Mon Sep 17 00:00:00 2001 From: Keith Short Date: Mon, 21 Nov 2022 11:30:11 -0700 Subject: test: i2c: convert to ZTEST Update the i2c tests to use the ZTEST API. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I53176f1aa8250fbe31a970a2efddb2e914d720c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045148 Reviewed-by: Al Semjonovs Code-Coverage: Zoss --- zephyr/test/i2c/prj.conf | 1 + zephyr/test/i2c/src/main.c | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/zephyr/test/i2c/prj.conf b/zephyr/test/i2c/prj.conf index 0232fb33a9..8c2a8fed3d 100644 --- a/zephyr/test/i2c/prj.conf +++ b/zephyr/test/i2c/prj.conf @@ -3,6 +3,7 @@ # found in the LICENSE file. CONFIG_ZTEST=y +CONFIG_ZTEST_NEW_API=y CONFIG_EMUL=y CONFIG_I2C_EMUL=y diff --git a/zephyr/test/i2c/src/main.c b/zephyr/test/i2c/src/main.c index eb4724d5a7..fc5dad2eb5 100644 --- a/zephyr/test/i2c/src/main.c +++ b/zephyr/test/i2c/src/main.c @@ -15,14 +15,14 @@ void watchdog_reload(void) { } -static void test_i2c_port_count(void) +ZTEST_USER(i2c, test_i2c_port_count) { zassert_equal(I2C_PORT_COUNT, 2, "I2C_PORT_COUNT expected to be 2 but was %d", I2C_PORT_COUNT); } -static void test_i2c_lock(void) +ZTEST_USER(i2c, test_i2c_lock) { i2c_lock(I2C_PORT_ACCEL, 1); zassert_equal(i2c_port_is_locked(I2C_PORT_EEPROM), 1, @@ -54,10 +54,4 @@ static void test_i2c_lock(void) i2c_lock(I2C_PORT_EEPROM, 0); } -/* Test case main entry. */ -void test_main(void) -{ - ztest_test_suite(test_i2c, ztest_user_unit_test(test_i2c_port_count), - ztest_user_unit_test(test_i2c_lock)); - ztest_run_test_suite(test_i2c); -} +ZTEST_SUITE(i2c, NULL, NULL, NULL, NULL, NULL); -- cgit v1.2.1 From 5d893f998d936f16d8894225ec44a58abf31f7e9 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 08:57:44 -0700 Subject: extra: Sort header files Sort all includes in extra with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I407b20fbc45280c7593fe46e6014f7944068cb85 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047097 Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Reviewed-by: Simon Glass Commit-Queue: Jeremy Bettis Code-Coverage: Zoss Commit-Queue: Simon Glass --- extra/ftdi_hostcmd/test_cmds.c | 8 ++++---- extra/lightbar/input.c | 6 +++--- extra/lightbar/main.c | 9 +++++---- extra/lightbar/simulation.h | 7 ++++--- extra/lightbar/windows.c | 7 ++++--- extra/rma_reset/rma_reset.c | 23 ++++++++++++----------- extra/sps_errs/prog.c | 8 ++++---- extra/touchpad_updater/touchpad_updater.c | 8 ++++---- extra/usb_console/usb_console.c | 8 ++++---- extra/usb_gpio/usb_gpio.c | 3 ++- extra/usb_updater/desc_parser.c | 7 ++++--- extra/usb_updater/usb_updater2.c | 14 +++++++------- 12 files changed, 57 insertions(+), 51 deletions(-) diff --git a/extra/ftdi_hostcmd/test_cmds.c b/extra/ftdi_hostcmd/test_cmds.c index 748b862b56..ba985717bf 100644 --- a/extra/ftdi_hostcmd/test_cmds.c +++ b/extra/ftdi_hostcmd/test_cmds.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ +#include "ec_commands.h" +#include "mpsse.h" + #include #include #include #include #include -#include -#include "mpsse.h" - -#include "ec_commands.h" +#include static int opt_verbose; diff --git a/extra/lightbar/input.c b/extra/lightbar/input.c index 5b605600ea..1ddfe2e1b3 100644 --- a/extra/lightbar/input.c +++ b/extra/lightbar/input.c @@ -3,17 +3,17 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ +#include "simulation.h" + #include #include #include #include #include -#include "simulation.h" - #ifdef HAS_GNU_READLINE -#include #include +#include char *get_input(const char *prompt) { diff --git a/extra/lightbar/main.c b/extra/lightbar/main.c index 321c0c73d2..e08aefc114 100644 --- a/extra/lightbar/main.c +++ b/extra/lightbar/main.c @@ -3,18 +3,19 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ +#include "simulation.h" + #include #include #include -#include +#include #include -#include #include #include -#include +#include #include -#include "simulation.h" +#include static void *(*thread_fns[])(void *) = { entry_windows, diff --git a/extra/lightbar/simulation.h b/extra/lightbar/simulation.h index c77583e6c9..93f0a957c0 100644 --- a/extra/lightbar/simulation.h +++ b/extra/lightbar/simulation.h @@ -6,15 +6,16 @@ #ifndef __EXTRA_SIMULATION_H #define __EXTRA_SIMULATION_H +#include "lb_common.h" +#include "lightbar.h" + #include #include #include #include #include -#include -#include "lb_common.h" -#include "lightbar.h" +#include /* Functions specific to our simulation environment */ void *entry_windows(void *); diff --git a/extra/lightbar/windows.c b/extra/lightbar/windows.c index e0b14fae42..3371cd42f5 100644 --- a/extra/lightbar/windows.c +++ b/extra/lightbar/windows.c @@ -3,16 +3,17 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ +#include "simulation.h" + #include -#include #include #include #include #include #include -#include -#include "simulation.h" +#include +#include /*****************************************************************************/ /* Window drawing stuff */ diff --git a/extra/rma_reset/rma_reset.c b/extra/rma_reset/rma_reset.c index d437b63f1a..4c2ce76803 100644 --- a/extra/rma_reset/rma_reset.c +++ b/extra/rma_reset/rma_reset.c @@ -3,27 +3,28 @@ * found in the LICENSE file. */ +#include "base32.h" +#include "curve25519.h" +#include "rma_auth.h" +#include "sha256.h" + #include -#include #include +#include +#include +#include +#include +#include + +#include #include #include #include #include #include #include -#include -#include -#include -#include -#include #include -#include "rma_auth.h" -#include "curve25519.h" -#include "sha256.h" -#include "base32.h" - #define EC_COORDINATE_SZ 32 #define EC_PRIV_KEY_SZ 32 #define EC_P256_UNCOMPRESSED_PUB_KEY_SZ (EC_COORDINATE_SZ * 2 + 1) diff --git a/extra/sps_errs/prog.c b/extra/sps_errs/prog.c index bf44dd182c..5c614ec55d 100644 --- a/extra/sps_errs/prog.c +++ b/extra/sps_errs/prog.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ +#include "ec_commands.h" +#include "mpsse.h" + #include #include #include #include #include -#include -#include "mpsse.h" - -#include "ec_commands.h" +#include static int opt_verbose; static size_t stop_after = -1; diff --git a/extra/touchpad_updater/touchpad_updater.c b/extra/touchpad_updater/touchpad_updater.c index fee898ca06..608a847cd6 100644 --- a/extra/touchpad_updater/touchpad_updater.c +++ b/extra/touchpad_updater/touchpad_updater.c @@ -5,17 +5,17 @@ */ #include -#include -#include #include #include #include #include #include -#include -#include +#include #include +#include +#include +#include /* Command line options */ static uint16_t vid = 0x18d1; /* Google */ diff --git a/extra/usb_console/usb_console.c b/extra/usb_console/usb_console.c index aea9eb8293..db1f2a4bec 100644 --- a/extra/usb_console/usb_console.c +++ b/extra/usb_console/usb_console.c @@ -5,17 +5,17 @@ */ #include -#include -#include #include #include #include #include #include -#include -#include +#include #include +#include +#include +#include /* Options */ static uint16_t vid = 0x18d1; /* Google */ diff --git a/extra/usb_gpio/usb_gpio.c b/extra/usb_gpio/usb_gpio.c index 7f2121d2b0..41810a6a0e 100644 --- a/extra/usb_gpio/usb_gpio.c +++ b/extra/usb_gpio/usb_gpio.c @@ -4,11 +4,12 @@ * found in the LICENSE file. */ -#include #include #include #include #include + +#include #include #define CHECK(expression) \ diff --git a/extra/usb_updater/desc_parser.c b/extra/usb_updater/desc_parser.c index 7e9f583902..d75677f0e0 100644 --- a/extra/usb_updater/desc_parser.c +++ b/extra/usb_updater/desc_parser.c @@ -4,15 +4,16 @@ * found in the LICENSE file. */ +#include "desc_parser.h" + #include #include -#include #include #include #include -#include -#include "desc_parser.h" +#include +#include static FILE *hash_file_; static int line_count_; diff --git a/extra/usb_updater/usb_updater2.c b/extra/usb_updater/usb_updater2.c index d591811a2b..744bf94b30 100644 --- a/extra/usb_updater/usb_updater2.c +++ b/extra/usb_updater/usb_updater2.c @@ -4,29 +4,29 @@ * found in the LICENSE file. */ +#include +#include +#include +#include + #include #include #include +#include #include #include -#include -#include -#include #include #include -#include #include -#include - #ifndef __packed #define __packed __attribute__((packed)) #endif #include "compile_time_macros.h" #include "misc_util.h" -#include "usb_descriptor.h" #include "update_fw.h" +#include "usb_descriptor.h" #include "vb21_struct.h" #ifdef DEBUG -- cgit v1.2.1 From 877f7514dd7c67498410b4bf7612e2c3c0a73c4b Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 16 Nov 2022 15:51:04 +0000 Subject: zephyr: kblight, displight, fan: update pwm api to use pwm_set_pulse_dt Update the kblight, displight and fan drivers to use pwm_dt_spec and the pwm_set_pulse_dt API, makes the code a bit more compact. BRANCH=none BUG=none TEST=cq dry run TEST=poking around with gdb to the data structures Signed-off-by: Fabio Baltieri Change-Id: Ib14095d9810575f6371cdd6b8ae91787adddcc6a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031189 Code-Coverage: Zoss Reviewed-by: Keith Short Reviewed-by: Tristan Honscheid --- zephyr/drivers/cros_displight/cros_displight.c | 14 +++++------- zephyr/drivers/cros_kblight/pwm_kblight.c | 14 +++++------- zephyr/shim/src/fan.c | 4 ++-- .../drivers/keyboard_scan/src/keyboard_backlight.c | 26 ++++++++++++++++++++++ 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/zephyr/drivers/cros_displight/cros_displight.c b/zephyr/drivers/cros_displight/cros_displight.c index 998c2a4407..850b0d7c90 100644 --- a/zephyr/drivers/cros_displight/cros_displight.c +++ b/zephyr/drivers/cros_displight/cros_displight.c @@ -19,16 +19,13 @@ LOG_MODULE_REGISTER(displight, LOG_LEVEL_ERR); BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, "Exactly one instance of cros-ec,displight should be defined."); -#define DISPLIGHT_PWM_NODE DT_INST_PWMS_CTLR(0) -#define DISPLIGHT_PWM_CHANNEL DT_INST_PWMS_CHANNEL(0) -#define DISPLIGHT_PWM_FLAGS DT_INST_PWMS_FLAGS(0) -#define DISPLIGHT_PWM_PERIOD_NS DT_INST_PWMS_PERIOD(0) +static const struct pwm_dt_spec displight_pwm = PWM_DT_SPEC_INST_GET(0); static int displight_percent; static void displight_set_duty(int percent) { - const struct device *pwm_dev = DEVICE_DT_GET(DISPLIGHT_PWM_NODE); + const struct device *pwm_dev = displight_pwm.dev; uint32_t pulse_ns; int rv; @@ -37,15 +34,14 @@ static void displight_set_duty(int percent) return; } - pulse_ns = DIV_ROUND_NEAREST(DISPLIGHT_PWM_PERIOD_NS * percent, 100); + pulse_ns = DIV_ROUND_NEAREST(displight_pwm.period * percent, 100); LOG_DBG("displight PWM %s set percent (%d), pulse %d", pwm_dev->name, percent, pulse_ns); - rv = pwm_set(pwm_dev, DISPLIGHT_PWM_CHANNEL, DISPLIGHT_PWM_PERIOD_NS, - pulse_ns, DISPLIGHT_PWM_FLAGS); + rv = pwm_set_pulse_dt(&displight_pwm, pulse_ns); if (rv) { - LOG_ERR("pwm_set() failed %s (%d)", pwm_dev->name, rv); + LOG_ERR("pwm_set_pulse_dt failed %s (%d)", pwm_dev->name, rv); } } diff --git a/zephyr/drivers/cros_kblight/pwm_kblight.c b/zephyr/drivers/cros_kblight/pwm_kblight.c index cc4af1d757..ca395f8dba 100644 --- a/zephyr/drivers/cros_kblight/pwm_kblight.c +++ b/zephyr/drivers/cros_kblight/pwm_kblight.c @@ -18,17 +18,14 @@ LOG_MODULE_REGISTER(kblight, LOG_LEVEL_ERR); BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, "Exactly one instance of cros-ec,kblight-pwm should be defined."); -#define KBLIGHT_PWM_NODE DT_INST_PWMS_CTLR(0) -#define KBLIGHT_PWM_CHANNEL DT_INST_PWMS_CHANNEL(0) -#define KBLIGHT_PWM_FLAGS DT_INST_PWMS_FLAGS(0) -#define KBLIGHT_PWM_PERIOD_NS DT_INST_PWMS_PERIOD(0) +static const struct pwm_dt_spec kblight_pwm_dt = PWM_DT_SPEC_INST_GET(0); static bool kblight_enabled; static int kblight_percent; static void kblight_pwm_set_duty(int percent) { - const struct device *pwm_dev = DEVICE_DT_GET(KBLIGHT_PWM_NODE); + const struct device *pwm_dev = kblight_pwm_dt.dev; uint32_t pulse_ns; int rv; @@ -37,15 +34,14 @@ static void kblight_pwm_set_duty(int percent) return; } - pulse_ns = DIV_ROUND_NEAREST(KBLIGHT_PWM_PERIOD_NS * percent, 100); + pulse_ns = DIV_ROUND_NEAREST(kblight_pwm_dt.period * percent, 100); LOG_DBG("kblight PWM %s set percent (%d), pulse %d", pwm_dev->name, percent, pulse_ns); - rv = pwm_set(pwm_dev, KBLIGHT_PWM_CHANNEL, KBLIGHT_PWM_PERIOD_NS, - pulse_ns, KBLIGHT_PWM_FLAGS); + rv = pwm_set_pulse_dt(&kblight_pwm_dt, pulse_ns); if (rv) { - LOG_ERR("pwm_set() failed %s (%d)", pwm_dev->name, rv); + LOG_ERR("pwm_set_pulse_dt failed %s (%d)", pwm_dev->name, rv); } } diff --git a/zephyr/shim/src/fan.c b/zephyr/shim/src/fan.c index 9bc36f878f..9978e6f4ca 100644 --- a/zephyr/shim/src/fan.c +++ b/zephyr/shim/src/fan.c @@ -125,9 +125,9 @@ static void fan_pwm_update(int ch) LOG_DBG("FAN PWM %s set percent (%d), pulse %d", pwm_dev->name, data->pwm_percent, pulse_ns); - ret = pwm_set_dt(&cfg->pwm, cfg->pwm.period, pulse_ns); + ret = pwm_set_pulse_dt(&cfg->pwm, pulse_ns); if (ret) { - LOG_ERR("pwm_set() failed %s (%d)", pwm_dev->name, ret); + LOG_ERR("pwm_set_pulse_dt failed %s (%d)", pwm_dev->name, ret); } } diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c index 6ced5c81bd..2865d7efc3 100644 --- a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c +++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c @@ -6,16 +6,22 @@ #include "console.h" #include "host_command.h" #include "keyboard_backlight.h" +#include "pwm_mock.h" #include "test/drivers/test_state.h" #include #include +#include #include #include #include #include +#define KBLIGHT_PWM_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_kblight_pwm) + +extern const struct kblight_drv kblight_pwm; + /** * @brief Send host command to set the backlight percentage * @@ -122,6 +128,26 @@ ZTEST(keyboard_backlight, console_command__bad_params) shell_execute_cmd(get_ec_shell(), "kblight 101"), NULL); } +ZTEST(keyboard_backlight, set_backlight__device_not_ready) +{ + const struct pwm_dt_spec kblight_pwm_dt = + PWM_DT_SPEC_GET(KBLIGHT_PWM_NODE); + const struct device *pwm_dev = kblight_pwm_dt.dev; + int initial_duty; + int initialized_saved; + + initial_duty = pwm_mock_get_duty(pwm_dev, kblight_pwm_dt.channel); + + initialized_saved = pwm_dev->state->initialized; + pwm_dev->state->initialized = 0; + + zassert_ok(kblight_pwm.set(initial_duty + 10), NULL); + zassert_equal(initial_duty, + pwm_mock_get_duty(pwm_dev, kblight_pwm_dt.channel), NULL); + + pwm_dev->state->initialized = initialized_saved; +} + static void reset(void *data) { ARG_UNUSED(data); -- cgit v1.2.1 From 8a60c32f3a2695d4fe2be88df025868808e057a3 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 17 Nov 2022 16:47:04 +0000 Subject: zephyr: leds: use INST macros for finding the device nodes Use compatible and INST based macros to setup the LED nodes so that the driver does not depend on a specific path. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I6b8c929ecf5b02d5a44e70b5358943b215d76d1e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032163 Code-Coverage: Zoss Reviewed-by: Jeremy Bettis --- zephyr/shim/src/led_driver/led.c | 15 ++++++++++----- zephyr/shim/src/led_driver/led.h | 3 --- zephyr/shim/src/led_driver/led_gpio.c | 11 +++++++---- zephyr/shim/src/led_driver/led_pwm.c | 11 +++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/zephyr/shim/src/led_driver/led.c b/zephyr/shim/src/led_driver/led.c index 279e889993..9a1c07b310 100644 --- a/zephyr/shim/src/led_driver/led.c +++ b/zephyr/shim/src/led_driver/led.c @@ -5,6 +5,8 @@ * Power and battery LED control. */ +#define DT_DRV_COMPAT cros_ec_led_policy + #include "battery.h" #include "charge_manager.h" #include "charge_state.h" @@ -23,7 +25,8 @@ #include LOG_MODULE_REGISTER(led, LOG_LEVEL_ERR); -#define LED_COLOR_NODE DT_PATH(led_colors) +BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, + "Exactly one instance of cros-ec,led-policy should be defined."); struct led_color_node_t { struct led_pins_node_t *pins_node; @@ -33,9 +36,11 @@ struct led_color_node_t { #define DECLARE_PINS_NODE(id) extern struct led_pins_node_t PINS_NODE(id); #if CONFIG_PLATFORM_EC_LED_DT_PWM -DT_FOREACH_CHILD(PWM_LED_PINS_NODE, DECLARE_PINS_NODE) +DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_pwm_led_pins), + DECLARE_PINS_NODE) #elif CONFIG_PLATFORM_EC_LED_DT_GPIO -DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, DECLARE_PINS_NODE) +DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_gpio_led_pins), + DECLARE_PINS_NODE) #endif /* @@ -112,8 +117,8 @@ struct node_prop_t { LED_COLOR_INIT(3, 4, state_id), \ } }, -static const struct node_prop_t node_array[] = { DT_FOREACH_CHILD( - LED_COLOR_NODE, SET_LED_VALUES) }; +static const struct node_prop_t node_array[] = { DT_INST_FOREACH_CHILD( + 0, SET_LED_VALUES) }; test_export_static enum power_state get_chipset_state(void) { diff --git a/zephyr/shim/src/led_driver/led.h b/zephyr/shim/src/led_driver/led.h index 43ee672bdc..a186d97da9 100644 --- a/zephyr/shim/src/led_driver/led.h +++ b/zephyr/shim/src/led_driver/led.h @@ -32,9 +32,6 @@ COND_CODE_1(DT_NODE_HAS_PROP(id, enum_name), \ (LED_ENUM(id, enum_name), ), ()) -#define GPIO_LED_PINS_NODE DT_PATH(gpio_led_pins) -#define PWM_LED_PINS_NODE DT_PATH(pwm_led_pins) - enum led_color { LED_OFF, LED_RED, diff --git a/zephyr/shim/src/led_driver/led_gpio.c b/zephyr/shim/src/led_driver/led_gpio.c index 9ca429e3d1..d6af1772c2 100644 --- a/zephyr/shim/src/led_driver/led_gpio.c +++ b/zephyr/shim/src/led_driver/led_gpio.c @@ -17,6 +17,9 @@ LOG_MODULE_REGISTER(gpio_led, LOG_LEVEL_ERR); +BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, + "Exactly one instance of cros-ec,gpio-led-pins should be defined."); + #define SET_PIN(node_id, prop, i) \ { .signal = GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, i)), \ .val = DT_PROP_BY_IDX(node_id, led_values, i) }, @@ -26,7 +29,7 @@ LOG_MODULE_REGISTER(gpio_led, LOG_LEVEL_ERR); #define GEN_PINS_ARRAY(id) struct gpio_pin_t PINS_ARRAY(id)[] = SET_GPIO_PIN(id) -DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, GEN_PINS_ARRAY) +DT_INST_FOREACH_CHILD(0, GEN_PINS_ARRAY) #define SET_PIN_NODE(node_id) \ { .led_color = GET_PROP(node_id, led_color), \ @@ -41,14 +44,14 @@ DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, GEN_PINS_ARRAY) #define GEN_PINS_NODES(id) \ const struct led_pins_node_t PINS_NODE(id) = SET_PIN_NODE(id) -DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, GEN_PINS_NODES) +DT_INST_FOREACH_CHILD(0, GEN_PINS_NODES) /* * Array of pointers to each pin node */ #define PINS_NODE_PTR(id) &PINS_NODE(id), -const struct led_pins_node_t *pins_node[] = { DT_FOREACH_CHILD( - GPIO_LED_PINS_NODE, PINS_NODE_PTR) }; +const struct led_pins_node_t *pins_node[] = { DT_INST_FOREACH_CHILD( + 0, PINS_NODE_PTR) }; /* * Set all the GPIO pins defined in the node to the defined value, diff --git a/zephyr/shim/src/led_driver/led_pwm.c b/zephyr/shim/src/led_driver/led_pwm.c index dbf98bc3b4..9fcafeea53 100644 --- a/zephyr/shim/src/led_driver/led_pwm.c +++ b/zephyr/shim/src/led_driver/led_pwm.c @@ -17,6 +17,9 @@ LOG_MODULE_REGISTER(pwm_led, LOG_LEVEL_ERR); +BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1, + "Exactly one instance of cros-ec,pwm-led-pins should be defined."); + /* * Period in ns from frequency(Hz) defined in pins node * period in sec = 1/freq @@ -42,7 +45,7 @@ LOG_MODULE_REGISTER(pwm_led, LOG_LEVEL_ERR); #define GEN_PINS_ARRAY(id) struct pwm_pin_t PINS_ARRAY(id)[] = SET_PWM_PIN(id) -DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_ARRAY) +DT_INST_FOREACH_CHILD(0, GEN_PINS_ARRAY) #define SET_PIN_NODE(node_id) \ { .led_color = GET_PROP(node_id, led_color), \ @@ -57,14 +60,14 @@ DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_ARRAY) #define GEN_PINS_NODES(id) \ const struct led_pins_node_t PINS_NODE(id) = SET_PIN_NODE(id) -DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_NODES) +DT_INST_FOREACH_CHILD(0, GEN_PINS_NODES) /* * Array of pointers to each pin node */ #define PINS_NODE_PTR(id) &PINS_NODE(id), -const struct led_pins_node_t *pins_node[] = { DT_FOREACH_CHILD( - PWM_LED_PINS_NODE, PINS_NODE_PTR) }; +const struct led_pins_node_t *pins_node[] = { DT_INST_FOREACH_CHILD( + 0, PINS_NODE_PTR) }; /* * Set all the PWM channels defined in the node to the defined value, -- cgit v1.2.1 From 65325e63bf7c96268508363248b7734c8b45d67d Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 09:12:50 -0700 Subject: fuzz: Sort header files Sort all includes in fuzz with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I9c9170f9ffa1b56e692ba74205250b1be234c70e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047098 Tested-by: Jeremy Bettis Commit-Queue: Jeremy Bettis Commit-Queue: Tristan Honscheid Reviewed-by: Tristan Honscheid Auto-Submit: Jeremy Bettis Code-Coverage: Zoss --- fuzz/host_command_fuzz.c | 6 +++--- fuzz/pchg_fuzz.c | 3 ++- fuzz/span.h | 3 +-- fuzz/usb_pd_fuzz.c | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fuzz/host_command_fuzz.c b/fuzz/host_command_fuzz.c index 0a648f602c..2875c687dd 100644 --- a/fuzz/host_command_fuzz.c +++ b/fuzz/host_command_fuzz.c @@ -5,9 +5,6 @@ * Fuzz host command. */ -#include -#include - #include "builtin/assert.h" #include "common.h" #include "console.h" @@ -19,6 +16,9 @@ #include "timer.h" #include "util.h" +#include +#include + /* Only test requests with valid size and checksum (makes fuzzing faster) */ #define VALID_REQUEST_ONLY diff --git a/fuzz/pchg_fuzz.c b/fuzz/pchg_fuzz.c index 4ef5f28b74..06c94a2d83 100644 --- a/fuzz/pchg_fuzz.c +++ b/fuzz/pchg_fuzz.c @@ -14,10 +14,11 @@ #include "timer.h" #include "util.h" -#include #include #include +#include + #define TASK_EVENT_FUZZ TASK_EVENT_CUSTOM_BIT(0) extern struct pchg_drv ctn730_drv; diff --git a/fuzz/span.h b/fuzz/span.h index 9cb08f9461..de144efe60 100644 --- a/fuzz/span.h +++ b/fuzz/span.h @@ -5,9 +5,8 @@ #ifndef __FUZZ_SPAN_H #define __FUZZ_SPAN_H -#include - #include +#include namespace fuzz { diff --git a/fuzz/usb_pd_fuzz.c b/fuzz/usb_pd_fuzz.c index 23f0ce6884..809e09cdbb 100644 --- a/fuzz/usb_pd_fuzz.c +++ b/fuzz/usb_pd_fuzz.c @@ -13,10 +13,11 @@ #include "usb_pd_tcpm.h" #include "util.h" -#include #include #include +#include + #define TASK_EVENT_FUZZ TASK_EVENT_CUSTOM_BIT(0) #define PORT0 0 -- cgit v1.2.1 From 9b2ac6721fc26c8cafd367329d3ac57fc7470177 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 17:07:15 -0700 Subject: cts: Sort header files Sort all headers in cts with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I8e4e195d77d9d66db9f08418aeb6e474368d097b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047096 Auto-Submit: Jeremy Bettis Code-Coverage: Zoss Reviewed-by: Abe Levkoy Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Commit-Queue: Abe Levkoy --- cts/common/th_common.c | 2 +- cts/gpio/dut.c | 5 ++--- cts/gpio/th.c | 5 ++--- cts/i2c/th.c | 3 ++- cts/interrupt/dut.c | 3 ++- cts/mutex/dut.c | 2 +- cts/mutex/th.c | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cts/common/th_common.c b/cts/common/th_common.c index 3084579b99..cc9c6be75f 100644 --- a/cts/common/th_common.c +++ b/cts/common/th_common.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ +#include "cts_common.h" #include "gpio.h" #include "timer.h" #include "watchdog.h" -#include "cts_common.h" /* Return SUCCESS if and only if we reach end of function * Returning success here means sync was successful diff --git a/cts/gpio/dut.c b/cts/gpio/dut.c index 92ae893a48..ef609cf4a8 100644 --- a/cts/gpio/dut.c +++ b/cts/gpio/dut.c @@ -4,13 +4,12 @@ */ #include "common.h" +#include "cts_common.h" #include "gpio.h" -#include "watchdog.h" -#include "uart.h" #include "task.h" #include "timer.h" +#include "uart.h" #include "watchdog.h" -#include "cts_common.h" enum cts_rc sync_test(void) { diff --git a/cts/gpio/th.c b/cts/gpio/th.c index 98fc232d1c..54a083cef9 100644 --- a/cts/gpio/th.c +++ b/cts/gpio/th.c @@ -4,13 +4,12 @@ */ #include "common.h" +#include "cts_common.h" #include "gpio.h" -#include "watchdog.h" -#include "uart.h" #include "task.h" #include "timer.h" +#include "uart.h" #include "watchdog.h" -#include "cts_common.h" enum cts_rc sync_test(void) { diff --git a/cts/i2c/th.c b/cts/i2c/th.c index ef57f6300c..b613f2d25d 100644 --- a/cts/i2c/th.c +++ b/cts/i2c/th.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include #include "common.h" #include "cts_common.h" #include "cts_i2c.h" @@ -14,6 +13,8 @@ #include "uart.h" #include "watchdog.h" +#include + static uint8_t inbox[I2C_MAX_HOST_PACKET_SIZE + 2]; static char data_received; diff --git a/cts/interrupt/dut.c b/cts/interrupt/dut.c index c2e0af0f81..15bba740f0 100644 --- a/cts/interrupt/dut.c +++ b/cts/interrupt/dut.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include #include "common.h" #include "cts_common.h" #include "gpio.h" @@ -12,6 +11,8 @@ #include "timer.h" #include "watchdog.h" +#include + static int got_interrupt; static int wake_me_up; static int state_index; diff --git a/cts/mutex/dut.c b/cts/mutex/dut.c index c48dfcaa64..c4778de957 100644 --- a/cts/mutex/dut.c +++ b/cts/mutex/dut.c @@ -6,8 +6,8 @@ * Tasks for mutexes basic tests. */ -#include "console.h" #include "common.h" +#include "console.h" #include "cts_common.h" #include "task.h" #include "test_util.h" diff --git a/cts/mutex/th.c b/cts/mutex/th.c index c48dfcaa64..c4778de957 100644 --- a/cts/mutex/th.c +++ b/cts/mutex/th.c @@ -6,8 +6,8 @@ * Tasks for mutexes basic tests. */ -#include "console.h" #include "common.h" +#include "console.h" #include "cts_common.h" #include "task.h" #include "test_util.h" -- cgit v1.2.1 From 968ff0109f7565b410c2c9b286e13ab7911a6164 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 16:35:49 -0700 Subject: builtin: Sort header files Sort all headers in builtin with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I7bd1597256ffb1b6839eda4a2d202b0008d84f5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047094 Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Commit-Queue: Tomasz Michalec Code-Coverage: Zoss Reviewed-by: Tomasz Michalec --- builtin/math.h | 3 ++- builtin/stdio.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/builtin/math.h b/builtin/math.h index c015d9d18d..aa07a0286d 100644 --- a/builtin/math.h +++ b/builtin/math.h @@ -6,9 +6,10 @@ #ifndef __CROS_EC_MATH_H__ #define __CROS_EC_MATH_H__ -#include #include "fpu.h" +#include + static inline bool isnan(float a) { return __builtin_isnan(a); diff --git a/builtin/stdio.h b/builtin/stdio.h index 7536499feb..bd75c01f53 100644 --- a/builtin/stdio.h +++ b/builtin/stdio.h @@ -6,11 +6,11 @@ #ifndef __CROS_EC_STDIO_H__ #define __CROS_EC_STDIO_H__ -#include -#include - #include "common.h" +#include +#include + /** * Print formatted outut to a string. * -- cgit v1.2.1 From 7586bc780ecb59a22ebeda815ac43039770d5ddc Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 14:37:56 -0700 Subject: util: Redirect stdin for clang_format If the pattern passed to check_clang_format.py has no files, clang-format will wait for a file on stdin, so redirect stdin from /dev/null instead. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ia2634f60d85e963686158e79dd352694b3b45a84 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043734 Code-Coverage: Zoss Commit-Queue: Tomasz Michalec Tested-by: Jeremy Bettis Reviewed-by: Tomasz Michalec Auto-Submit: Jeremy Bettis --- util/check_clang_format.py | 1 + 1 file changed, 1 insertion(+) diff --git a/util/check_clang_format.py b/util/check_clang_format.py index 783cce9e33..5862c02a3d 100755 --- a/util/check_clang_format.py +++ b/util/check_clang_format.py @@ -69,6 +69,7 @@ def main(argv=None): cwd=ec_dir, stderr=subprocess.PIPE, encoding="utf-8", + stdin=subprocess.DEVNULL, ) if result.stderr: logging.error("All C source must be formatted with clang-format!") -- cgit v1.2.1 From f4b1364e580059bba294f4ece3c59eb5b3ce924a Mon Sep 17 00:00:00 2001 From: Keith Short Date: Mon, 21 Nov 2022 16:32:03 -0700 Subject: test: emul_common_i2c: fix access fail logic Calling i2c_common_emul_set_read_fail_reg() or i2c_common_emul_set_write_fail_reg() with an emulator that registers custom read/write routines doesn't' actually fail the transfer. Move the register checks before the custom user handler is invoked. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I7097e3204bc5e7e466fa1ca52f32516c4910158a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045149 Code-Coverage: Zoss Reviewed-by: Simon Glass --- zephyr/emul/emul_common_i2c.c | 44 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/zephyr/emul/emul_common_i2c.c b/zephyr/emul/emul_common_i2c.c index 3af150ddfc..327188cb48 100644 --- a/zephyr/emul/emul_common_i2c.c +++ b/zephyr/emul/emul_common_i2c.c @@ -172,16 +172,6 @@ static int i2c_common_emul_write_byte(const struct emul *target, { int reg, ret; - /* Custom user handler */ - if (data->write_func) { - ret = data->write_func(target, data->cur_reg, val, - data->msg_byte, data->write_func_data); - if (ret < 0) { - return -EIO; - } else if (ret == 0) { - return 0; - } - } /* Check if user wants to fail on accessed register */ if (data->access_reg) { reg = data->access_reg(target, data->cur_reg, data->msg_byte, @@ -195,6 +185,18 @@ static int i2c_common_emul_write_byte(const struct emul *target, data->write_fail_reg == I2C_COMMON_EMUL_FAIL_ALL_REG) { return -EIO; } + + /* Custom user handler */ + if (data->write_func) { + ret = data->write_func(target, data->cur_reg, val, + data->msg_byte, data->write_func_data); + if (ret < 0) { + return -EIO; + } else if (ret == 0) { + return 0; + } + } + /* Emulator handler */ if (data->write_byte) { k_mutex_lock(&data->data_mtx, K_FOREVER); @@ -228,16 +230,6 @@ static int i2c_common_emul_read_byte(const struct emul *target, { int reg, ret; - /* Custom user handler */ - if (data->read_func) { - ret = data->read_func(target, data->cur_reg, val, - data->msg_byte, data->read_func_data); - if (ret < 0) { - return -EIO; - } else if (ret == 0) { - return 0; - } - } /* Check if user wants to fail on accessed register */ if (data->access_reg) { reg = data->access_reg(target, data->cur_reg, data->msg_byte, @@ -250,6 +242,18 @@ static int i2c_common_emul_read_byte(const struct emul *target, data->read_fail_reg == I2C_COMMON_EMUL_FAIL_ALL_REG) { return -EIO; } + + /* Custom user handler */ + if (data->read_func) { + ret = data->read_func(target, data->cur_reg, val, + data->msg_byte, data->read_func_data); + if (ret < 0) { + return -EIO; + } else if (ret == 0) { + return 0; + } + } + /* Emulator handler */ if (data->read_byte) { k_mutex_lock(&data->data_mtx, K_FOREVER); -- cgit v1.2.1 From 32e4539b702f078a663e82234d6cbaec6e379416 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Mon, 21 Nov 2022 14:41:40 -0700 Subject: test: i2c: verify I2C lock with invalid port Verify I2C locks fail for an invalid port. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: Ide8066e3a01ff7112973c0a34fe337fdb306e2f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045150 Code-Coverage: Zoss Reviewed-by: Tomasz Michalec --- zephyr/test/i2c/src/main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zephyr/test/i2c/src/main.c b/zephyr/test/i2c/src/main.c index fc5dad2eb5..759fe01151 100644 --- a/zephyr/test/i2c/src/main.c +++ b/zephyr/test/i2c/src/main.c @@ -22,6 +22,17 @@ ZTEST_USER(i2c, test_i2c_port_count) I2C_PORT_COUNT); } +ZTEST_USER(i2c, test_i2c_lock_invalid_port) +{ + i2c_lock(-1, 1); + zassert_equal(i2c_port_is_locked(-1), 0, + "Negative I2C port locked, but should have failed"); + + i2c_lock(INT_MAX, 1); + zassert_equal(i2c_port_is_locked(INT_MAX), 0, + "MAX_INT I2C port locked, but should have failed"); +} + ZTEST_USER(i2c, test_i2c_lock) { i2c_lock(I2C_PORT_ACCEL, 1); -- cgit v1.2.1 From 6bc39225233dc44537393334ab780aadad4ed6bd Mon Sep 17 00:00:00 2001 From: Keith Short Date: Mon, 21 Nov 2022 15:33:51 -0700 Subject: test: i2c_controller: Test unlocked transfers Verify the error paths for unlocked transfers. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I6a4fddb74e77f524744d6457f2a4d46cefba2f61 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045151 Code-Coverage: Zoss Reviewed-by: Simon Glass --- .../drivers/i2c_controller/src/i2c_controller.c | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c index 4c00043e11..987e4ca042 100644 --- a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c +++ b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c @@ -273,6 +273,47 @@ ZTEST_F(i2c_controller, write_offset16_block) expected); } +ZTEST_F(i2c_controller, i2c_xfer_unlocked__error_paths) +{ + uint8_t out_buffer[1]; + int out_size; + uint8_t in_buffer[1]; + int in_size; + int flags; + + /* First confirm i2c_xfer_unlocked() works with a lock. */ + out_buffer[0] = 0; + out_size = 1; + in_size = 1; + flags = I2C_XFER_STOP; + + i2c_lock(fixture->port, 1); + zassert_equal(i2c_port_is_locked(fixture->port), 1, + "Port %d not locked", fixture->port); + zassert_ok(i2c_xfer_unlocked(fixture->port, fixture->addr, out_buffer, + out_size, in_buffer, in_size, flags)); + i2c_lock(fixture->port, 0); + zassert_equal(i2c_port_is_locked(fixture->port), 0, "Port %d is locked", + fixture->port); + + /* Try the transfer without a lock. */ + zassert_equal(i2c_xfer_unlocked(fixture->port, fixture->addr, + out_buffer, out_size, in_buffer, + in_size, flags), + EC_ERROR_INVAL); + + /* Set an invalid flag on the transfer, expected to still pass */ + i2c_lock(fixture->port, 1); + zassert_equal(i2c_port_is_locked(fixture->port), 1, + "Port %d not locked", fixture->port); + zassert_ok(i2c_xfer_unlocked( + fixture->port, fixture->addr | I2C_FLAG_ADDR_IS_SPI, out_buffer, + out_size, in_buffer, in_size, flags)); + i2c_lock(fixture->port, 0); + zassert_equal(i2c_port_is_locked(fixture->port), 0, "Port %d is locked", + fixture->port); +} + static struct i2c_controller_fixture i2c_controller_fixture; static void *setup(void) -- cgit v1.2.1 From fad59b7b2fe34f6fd659142dcfc557e5891f74c2 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 09:21:41 -0700 Subject: power: Sort header files Sort all includes in power with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I8578ad71df08dea1881658e02738ec41220d4666 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047099 Reviewed-by: Al Semjonovs Code-Coverage: Zoss Commit-Queue: Al Semjonovs Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis --- power/amd_x86.c | 4 ++-- power/hibernate.c | 12 ++++++------ power/rk3288.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/power/amd_x86.c b/power/amd_x86.c index e5b44a313f..ca40ef9f3b 100644 --- a/power/amd_x86.c +++ b/power/amd_x86.c @@ -13,15 +13,15 @@ #include "hooks.h" #include "lid_switch.h" #include "lpc.h" -#include "power/amd_x86.h" #include "power.h" +#include "power/amd_x86.h" #include "power_button.h" +#include "registers.h" #include "system.h" #include "timer.h" #include "usb_charge.h" #include "util.h" #include "wireless.h" -#include "registers.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_CHIPSET, outstr) diff --git a/power/hibernate.c b/power/hibernate.c index 322adca3ea..46c842bce6 100644 --- a/power/hibernate.c +++ b/power/hibernate.c @@ -3,12 +3,6 @@ * found in the LICENSE file. */ -#include -#include - -#include -#include - #include "console.h" #include "extpower.h" #include "hooks.h" @@ -16,6 +10,12 @@ #include "system.h" #include "util.h" +#include +#include + +#include +#include + LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL); /* diff --git a/power/rk3288.c b/power/rk3288.c index e4e4ac9d69..8aea147391 100644 --- a/power/rk3288.c +++ b/power/rk3288.c @@ -32,8 +32,8 @@ #include "console.h" #include "gpio.h" #include "hooks.h" -#include "lid_switch.h" #include "keyboard_scan.h" +#include "lid_switch.h" #include "power.h" #include "power_button.h" #include "power_led.h" -- cgit v1.2.1 From b1e998a489ac779cedb986cefa42450e342af01f Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 09:30:25 -0700 Subject: zephyr/program: Sort header files Sort all includes in zephyr/program with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I684a34734184e6fe1465211d30bcae4eaabbe9e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047100 Reviewed-by: Al Semjonovs Tested-by: Jeremy Bettis Auto-Submit: Jeremy Bettis Code-Coverage: Zoss Commit-Queue: Al Semjonovs --- zephyr/program/skyrim/src/crystaldrift/alt_charger.c | 6 +++--- zephyr/program/skyrim/src/crystaldrift/fan.c | 8 ++++---- zephyr/program/skyrim/src/crystaldrift/form_factor.c | 7 ++++--- zephyr/program/skyrim/src/crystaldrift/ppc_config.c | 6 +++--- zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/zephyr/program/skyrim/src/crystaldrift/alt_charger.c b/zephyr/program/skyrim/src/crystaldrift/alt_charger.c index 992215161c..a429457136 100644 --- a/zephyr/program/skyrim/src/crystaldrift/alt_charger.c +++ b/zephyr/program/skyrim/src/crystaldrift/alt_charger.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include -#include - #include "charger_chips.h" #include "common.h" #include "cros_board_info.h" #include "cros_cbi.h" #include "hooks.h" +#include +#include + LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); static void alt_charger_init(void) diff --git a/zephyr/program/skyrim/src/crystaldrift/fan.c b/zephyr/program/skyrim/src/crystaldrift/fan.c index 01416616c2..6645e2a495 100644 --- a/zephyr/program/skyrim/src/crystaldrift/fan.c +++ b/zephyr/program/skyrim/src/crystaldrift/fan.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "cros_board_info.h" #include "cros_cbi.h" #include "fan.h" #include "gpio/gpio.h" #include "hooks.h" +#include +#include +#include + LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); /* diff --git a/zephyr/program/skyrim/src/crystaldrift/form_factor.c b/zephyr/program/skyrim/src/crystaldrift/form_factor.c index b9cfe9890e..688765617b 100644 --- a/zephyr/program/skyrim/src/crystaldrift/form_factor.c +++ b/zephyr/program/skyrim/src/crystaldrift/form_factor.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include -#include -#include "common.h" #include "accelgyro.h" +#include "common.h" #include "cros_board_info.h" #include "hooks.h" #include "motionsense_sensors.h" +#include +#include + LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); /* diff --git a/zephyr/program/skyrim/src/crystaldrift/ppc_config.c b/zephyr/program/skyrim/src/crystaldrift/ppc_config.c index 423824b1a6..3913fda4dc 100644 --- a/zephyr/program/skyrim/src/crystaldrift/ppc_config.c +++ b/zephyr/program/skyrim/src/crystaldrift/ppc_config.c @@ -5,12 +5,12 @@ /* Crystaldrift board-specific PPC code */ -#include - -#include "driver/ppc/nx20p348x.h" #include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" #include "usbc_ppc.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) diff --git a/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c b/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c index 9ea3df3e39..0e08431360 100644 --- a/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c +++ b/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c @@ -5,8 +5,6 @@ /* Crystaldrift board-specific USB-C mux configuration */ -#include - #include "console.h" #include "cros_board_info.h" #include "cros_cbi.h" @@ -16,6 +14,8 @@ #include "usb_mux.h" #include "usbc/usb_muxes.h" +#include + #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) -- cgit v1.2.1 From 50aa616c3c893d68770cec95f880ff67a981e61f Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 14:36:44 -0700 Subject: ec/util: Sort header files Sort all headers in ec/util with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I0d733569f765f2a339a694b2d4e5720820e7aaa8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043733 Commit-Queue: Jeremy Bettis Reviewed-by: Simon Glass Tested-by: Jeremy Bettis Code-Coverage: Zoss --- util/cbi-util.c | 15 ++++++++------- util/cros_ec_dev.h | 3 ++- util/ecst.h | 3 ++- util/export_taskinfo.c | 4 ++-- util/gen_emmc_transfer_data.c | 4 ++-- util/gen_touchpad_hash.c | 12 ++++++------ util/genvif.c | 24 ++++++++++++------------ util/gpios_to_zephyr_dts.c | 2 +- util/iteflash.c | 21 +++++++++++---------- util/usb_if.c | 4 ++-- util/uut/com_port.h | 1 + 11 files changed, 49 insertions(+), 44 deletions(-) diff --git a/util/cbi-util.c b/util/cbi-util.c index 5bea9a04b9..2c262c181b 100644 --- a/util/cbi-util.c +++ b/util/cbi-util.c @@ -5,20 +5,21 @@ * Cros Board Info utility */ -#include +#include "crc8.h" +#include "cros_board_info.h" + #include -#include -#include #include #include #include #include -#include #include -#include +#include -#include "cros_board_info.h" -#include "crc8.h" +#include +#include +#include +#include #define ARGS_MASK_BOARD_VERSION BIT(0) #define ARGS_MASK_FILENAME BIT(1) diff --git a/util/cros_ec_dev.h b/util/cros_ec_dev.h index 3ffed56632..6421afc601 100644 --- a/util/cros_ec_dev.h +++ b/util/cros_ec_dev.h @@ -6,9 +6,10 @@ #ifndef __UTIL_CROS_EC_DEV_H #define __UTIL_CROS_EC_DEV_H +#include "ec_commands.h" + #include #include -#include "ec_commands.h" #ifdef __cplusplus extern "C" { diff --git a/util/ecst.h b/util/ecst.h index 7d3dbbe153..fed160e22a 100644 --- a/util/ecst.h +++ b/util/ecst.h @@ -11,9 +11,10 @@ Includes --------------------------------------------------------------------------*/ +#include #include #include -#include + #include /*--------------------------------------------------------------------------- diff --git a/util/export_taskinfo.c b/util/export_taskinfo.c index af40ef8de6..0fe8644792 100644 --- a/util/export_taskinfo.c +++ b/util/export_taskinfo.c @@ -6,11 +6,11 @@ * section definitions to export different tasklists. */ -#include - #include "config.h" #include "task_id.h" +#include + #ifdef SECTION_IS_RO #define GET_TASKINFOS_FUNC get_ro_taskinfos #elif defined(SECTION_IS_RW) diff --git a/util/gen_emmc_transfer_data.c b/util/gen_emmc_transfer_data.c index 3c80724594..1de9d6b5a0 100644 --- a/util/gen_emmc_transfer_data.c +++ b/util/gen_emmc_transfer_data.c @@ -6,14 +6,14 @@ * eMMC protocol. */ -#include #include -#include #include #include #include #include +#include +#include /* eMMC transfer block size */ #define BLOCK_SIZE 512 diff --git a/util/gen_touchpad_hash.c b/util/gen_touchpad_hash.c index 98370038b7..edf1022bf9 100644 --- a/util/gen_touchpad_hash.c +++ b/util/gen_touchpad_hash.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include +#include "config.h" + #include +#include #include -#include +#include +#include #include - -#include "config.h" +#include static void print_hex(FILE *out, uint8_t *digest, int len, int last) { diff --git a/util/genvif.c b/util/genvif.c index 543577cb11..892bf14367 100644 --- a/util/genvif.c +++ b/util/genvif.c @@ -5,25 +5,25 @@ #define _GNU_SOURCE /* for asprintf */ +#include "charge_manager.h" +#include "config.h" +#include "genvif.h" +#include "usb_pd.h" +#include "usb_pd_pdo.h" +#include "usb_pd_tcpm.h" + +#include #include +#include #include #include #include #include -#include #include -#include -#include -#include -#include - -#include "config.h" -#include "usb_pd.h" -#include "usb_pd_pdo.h" -#include "usb_pd_tcpm.h" -#include "charge_manager.h" +#include -#include "genvif.h" +#include +#include #define VIF_APP_VENDOR_VALUE "Google" #define VIF_APP_NAME_VALUE "EC GENVIF" diff --git a/util/gpios_to_zephyr_dts.c b/util/gpios_to_zephyr_dts.c index d0e51b3e46..7efcd67ceb 100644 --- a/util/gpios_to_zephyr_dts.c +++ b/util/gpios_to_zephyr_dts.c @@ -32,8 +32,8 @@ #define _POSIX_C_SOURCE 200809L #include -#include #include +#include #include /* diff --git a/util/iteflash.c b/util/iteflash.c index 9085365135..8b03c2e4cb 100644 --- a/util/iteflash.c +++ b/util/iteflash.c @@ -8,25 +8,26 @@ /* remove when ftdi_usb_purge_buffers has been replaced to follow libftdi */ #define _FTDI_DISABLE_DEPRECATED +#include "compile_time_macros.h" +#include "usb_if.h" + #include -#include -#include -#include -#include -#include #include #include #include #include #include #include -#include #include -#include -#include -#include "compile_time_macros.h" -#include "usb_if.h" +#include +#include +#include +#include +#include +#include +#include +#include /* Default FTDI device : Servo v2. */ #define SERVO_USB_VID 0x18d1 diff --git a/util/usb_if.c b/util/usb_if.c index 0cd642834a..eec8b22f5b 100644 --- a/util/usb_if.c +++ b/util/usb_if.c @@ -4,12 +4,12 @@ * found in the LICENSE file. */ +#include "usb_if.h" + #include #include #include -#include "usb_if.h" - /* Return 0 on error, since it's never gonna be EP 0 */ static int find_endpoint(const struct libusb_interface_descriptor *iface, uint16_t subclass, uint16_t protocol, diff --git a/util/uut/com_port.h b/util/uut/com_port.h index ca52bdd234..0a5d843e0f 100644 --- a/util/uut/com_port.h +++ b/util/uut/com_port.h @@ -10,6 +10,7 @@ #define __UTIL_UUT_COM_PORT_H #include + #include #ifdef __cplusplus -- cgit v1.2.1 From 7af686b6c1ac4130b03c2b51740c8853bc13c982 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Tue, 15 Nov 2022 17:43:47 -0700 Subject: zephyr test: Verify pd dualrole with more roles Verify that 'pd dualrole' console command outputs the actual role. BUG=b:236074634 TEST=twister -s zephyr/test/drivers/drivers.default BRANCH=none Signed-off-by: Abe Levkoy Change-Id: Ia8a5becd3ebfcbd70cff0fa7382434d9cfe531a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029599 Code-Coverage: Zoss Reviewed-by: Yuval Peress --- .../drivers/default/src/console_cmd/usb_pd_console.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c index ac3ece0082..0cb04dec67 100644 --- a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c +++ b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c @@ -268,6 +268,22 @@ ZTEST_USER(console_cmd_usb_pd, test_dualrole) rv = shell_execute_cmd(get_ec_shell(), "pd 0 dualrole x"); zassert_equal(rv, EC_ERROR_PARAM4, "Expected %d, but got %d", EC_ERROR_PARAM4, rv); + + pd_set_dual_role(0, PD_DRP_TOGGLE_OFF); + CHECK_CONSOLE_CMD("pd 0 dualrole", "dual-role toggling: off", + EC_SUCCESS); + + pd_set_dual_role(0, PD_DRP_FREEZE); + CHECK_CONSOLE_CMD("pd 0 dualrole", "dual-role toggling: freeze", + EC_SUCCESS); + + pd_set_dual_role(0, PD_DRP_FORCE_SINK); + CHECK_CONSOLE_CMD("pd 0 dualrole", "dual-role toggling: force sink", + EC_SUCCESS); + + pd_set_dual_role(0, PD_DRP_FORCE_SOURCE); + CHECK_CONSOLE_CMD("pd 0 dualrole", "dual-role toggling: force source", + EC_SUCCESS); } ZTEST_USER(console_cmd_usb_pd, test_state) -- cgit v1.2.1 From 183762adb11d9a9a95f027d968e4592329cf8c6f Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Tue, 15 Nov 2022 17:51:02 -0700 Subject: zephyr test: Verify 'pd 0 cc' Verify that 'pd 0 cc' outputs the correct CC state. BUG=b:236074634 TEST=twister -s zephyr/test/drivers/drivers.default BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I8331fda76ca8d013794659c47090b3dca547be3c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029601 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c index 0cb04dec67..859205f403 100644 --- a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c +++ b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c @@ -313,6 +313,15 @@ ZTEST_USER(console_cmd_usb_pd, test_timer) rv); } +ZTEST_USER(console_cmd_usb_pd, test_cc) +{ + char expected_output[10]; + + snprintf(expected_output, sizeof(expected_output), "C0 CC%d", + pd_get_task_cc_state(0)); + CHECK_CONSOLE_CMD("pd 0 cc", expected_output, EC_SUCCESS); +} + static void set_device_vdo(int port, enum tcpci_msg_type type) { union tbt_mode_resp_device device_resp; -- cgit v1.2.1 From ed85e67ea6fddb6bdd21f4db691700da85307959 Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Mon, 21 Nov 2022 12:10:07 -0800 Subject: util: Remove corori2 from list of boards that build with clang The CQ is failing to compile this board. Remove this board from list of boards that compile with clang. BRANCH=none BUG=b:172020503 TEST=make buildall Signed-off-by: Scott Collyer Change-Id: Ia12ddaa983601185ffc760ada9fb12bbfecd3b9a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043729 Commit-Queue: Scott Collyer Code-Coverage: Zoss Reviewed-by: Jeremy Bettis Tested-by: Scott Collyer --- util/build_with_clang.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 339384740e..1576d45216 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -122,7 +122,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "copano", "coral", "corori", - "corori2", "cret", "crota", "dalboz", @@ -294,6 +293,7 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ # Boards that use CHIP:=npcx "bobba", # overflows flash "coachz", # overflows flash + "corori2", # overflows flash "garg", # overflows flash "mushu", # overflows flash "terrador", # overflows flash -- cgit v1.2.1 From 4ba3538ac420d388a2fe81f70b8ad90a88a7eb74 Mon Sep 17 00:00:00 2001 From: Piotr Pawliczek Date: Tue, 22 Nov 2022 11:31:40 -0800 Subject: Add missing include Quick fix to unblock builds. BUG=none TEST=emerge-atlas ec-utils-test Change-Id: Iaabd657ab5c059ba00afd458b31dbed63721b867 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049442 Auto-Submit: Piotr Pawliczek Owners-Override: Piotr Pawliczek Reviewed-by: Jeremy Bettis Commit-Queue: Piotr Pawliczek Commit-Queue: Jeremy Bettis Tested-by: Piotr Pawliczek --- include/base32.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/base32.h b/include/base32.h index a1816afb60..d1acc6ab95 100644 --- a/include/base32.h +++ b/include/base32.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_BASE32_H #define __CROS_EC_BASE32_H +#include + /* Symbol map for base32 encoding */ extern const char base32_map[33]; -- cgit v1.2.1 From d4aa274081c99f3443886977f004721670cc3b35 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Mon, 21 Nov 2022 16:48:59 -0700 Subject: core: Sort header files Sort all headers in core with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ie1dafb879dca3fcb9254025da8a70b5cd169481d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047095 Code-Coverage: Zoss Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Commit-Queue: Al Semjonovs Reviewed-by: Al Semjonovs --- core/cortex-m/cpu.h | 3 ++- core/cortex-m/llsr.c | 5 +++-- core/cortex-m/mpu.c | 2 +- core/cortex-m/panic.c | 2 +- core/cortex-m/vecttable.c | 1 + core/cortex-m0/cpu.h | 3 ++- core/cortex-m0/panic.c | 2 +- core/cortex-m0/vecttable.c | 6 +++--- core/host/host_task.h | 4 ++-- core/host/panic.c | 10 +++++----- core/host/stack_trace.c | 9 +++++---- core/host/task.c | 19 ++++++++++--------- core/host/timer.c | 6 +++--- core/minute-ia/mpu.c | 2 +- core/minute-ia/task.c | 6 +++--- core/riscv-rv32i/panic.c | 2 +- 16 files changed, 44 insertions(+), 38 deletions(-) diff --git a/core/cortex-m/cpu.h b/core/cortex-m/cpu.h index 8c284d6132..4a36d63dda 100644 --- a/core/cortex-m/cpu.h +++ b/core/cortex-m/cpu.h @@ -8,10 +8,11 @@ #ifndef __CROS_EC_CPU_H #define __CROS_EC_CPU_H -#include #include "compile_time_macros.h" #include "debug.h" +#include + /* Macro to access 32-bit registers */ #define CPUREG(addr) (*(volatile uint32_t *)(addr)) diff --git a/core/cortex-m/llsr.c b/core/cortex-m/llsr.c index 0ab920f628..933382034b 100644 --- a/core/cortex-m/llsr.c +++ b/core/cortex-m/llsr.c @@ -5,10 +5,11 @@ /* Enable the use of right shift for uint64_t. */ -#include -#include #include +#include +#include + union words { uint64_t u64; uint32_t w[2]; diff --git a/core/cortex-m/mpu.c b/core/cortex-m/mpu.c index db03936dfa..953cbb7393 100644 --- a/core/cortex-m/mpu.c +++ b/core/cortex-m/mpu.c @@ -6,9 +6,9 @@ /* MPU module for Chrome EC */ #include "builtin/assert.h" -#include "mpu.h" #include "console.h" #include "cpu.h" +#include "mpu.h" #include "registers.h" #include "task.h" #include "util.h" diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c index 0f803dc8e5..1de8376cfb 100644 --- a/core/cortex-m/panic.c +++ b/core/cortex-m/panic.c @@ -7,8 +7,8 @@ #include "console.h" #include "cpu.h" #include "host_command.h" -#include "panic.h" #include "panic-internal.h" +#include "panic.h" #include "printf.h" #include "system.h" #include "task.h" diff --git a/core/cortex-m/vecttable.c b/core/cortex-m/vecttable.c index 037bc28c36..aea4bf3dc7 100644 --- a/core/cortex-m/vecttable.c +++ b/core/cortex-m/vecttable.c @@ -9,6 +9,7 @@ #define ___INIT #include "compiler.h" #include "config.h" + #include #endif diff --git a/core/cortex-m0/cpu.h b/core/cortex-m0/cpu.h index 568b16eedb..bdb7a3c6f5 100644 --- a/core/cortex-m0/cpu.h +++ b/core/cortex-m0/cpu.h @@ -8,10 +8,11 @@ #ifndef __CROS_EC_CPU_H #define __CROS_EC_CPU_H -#include #include "compile_time_macros.h" #include "debug.h" +#include + /* Macro to access 32-bit registers */ #define CPUREG(addr) (*(volatile uint32_t *)(addr)) diff --git a/core/cortex-m0/panic.c b/core/cortex-m0/panic.c index 3e4c1eb3be..533e45713d 100644 --- a/core/cortex-m0/panic.c +++ b/core/cortex-m0/panic.c @@ -7,8 +7,8 @@ #include "console.h" #include "cpu.h" #include "host_command.h" -#include "panic.h" #include "panic-internal.h" +#include "panic.h" #include "printf.h" #include "system.h" #include "task.h" diff --git a/core/cortex-m0/vecttable.c b/core/cortex-m0/vecttable.c index 7fd5c7fb8f..050a7d318a 100644 --- a/core/cortex-m0/vecttable.c +++ b/core/cortex-m0/vecttable.c @@ -7,13 +7,13 @@ #ifndef ___INIT #define ___INIT -#include -#include - #include "compiler.h" #include "config.h" #include "panic-internal.h" #include "task.h" + +#include +#include #endif /* __INIT */ typedef void (*func)(void); diff --git a/core/host/host_task.h b/core/host/host_task.h index 82b33f96c5..e79111f6f4 100644 --- a/core/host/host_task.h +++ b/core/host/host_task.h @@ -8,10 +8,10 @@ #ifndef __CROS_EC_HOST_TASK_H #define __CROS_EC_HOST_TASK_H -#include - #include "task.h" +#include + /** * Returns the thread corresponding to the task. */ diff --git a/core/host/panic.c b/core/host/panic.c index e354757d75..0dd00ac604 100644 --- a/core/host/panic.c +++ b/core/host/panic.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ +#include "config.h" +#include "panic.h" +#include "stack_trace.h" + #include +#include #include #include -#include #include -#include "config.h" -#include "panic.h" -#include "stack_trace.h" - void panic_assert_fail(const char *msg, const char *func, const char *fname, int linenum) { diff --git a/core/host/stack_trace.c b/core/host/stack_trace.c index 14d6abcab2..4f4ab380d9 100644 --- a/core/host/stack_trace.c +++ b/core/host/stack_trace.c @@ -3,14 +3,15 @@ * found in the LICENSE file. */ -#include +#include "host_task.h" +#include "host_test.h" +#include "timer.h" + #include #include #include -#include "host_task.h" -#include "host_test.h" -#include "timer.h" +#include #define SIGNAL_TRACE_DUMP SIGTERM #define MAX_TRACE 30 diff --git a/core/host/task.c b/core/host/task.c index 31ea386f2e..fa853dce60 100644 --- a/core/host/task.c +++ b/core/host/task.c @@ -5,15 +5,6 @@ /* Task scheduling / events module for Chrome EC operating system */ -#include -#include -#include -#include -#include -#include -#include -#include - #include "atomic.h" #include "common.h" #include "console.h" @@ -23,6 +14,16 @@ #include "test_util.h" #include "timer.h" +#include +#include +#include +#include +#include + +#include +#include +#include + #define SIGNAL_INTERRUPT SIGUSR1 struct emu_task_t { diff --git a/core/host/timer.c b/core/host/timer.c index 66f047cd4d..b2c9c5c478 100644 --- a/core/host/timer.c +++ b/core/host/timer.c @@ -5,15 +5,15 @@ /* Timer module */ -#include -#include - #include "builtin/assert.h" #include "task.h" #include "test_util.h" #include "timer.h" #include "util.h" +#include +#include + static timestamp_t boot_time; static int time_set; diff --git a/core/minute-ia/mpu.c b/core/minute-ia/mpu.c index d91d71f99c..6cbf4c634f 100644 --- a/core/minute-ia/mpu.c +++ b/core/minute-ia/mpu.c @@ -5,8 +5,8 @@ /* MPU module for ISH */ -#include "mpu.h" #include "console.h" +#include "mpu.h" #include "registers.h" #include "task.h" #include "util.h" diff --git a/core/minute-ia/task.c b/core/minute-ia/task.c index b4b747baa0..540e387d2a 100644 --- a/core/minute-ia/task.c +++ b/core/minute-ia/task.c @@ -16,14 +16,14 @@ #include "builtin/assert.h" #include "common.h" #include "console.h" +#include "hpet.h" +#include "interrupts.h" #include "link_defs.h" #include "panic.h" #include "task.h" +#include "task_defs.h" #include "timer.h" #include "util.h" -#include "task_defs.h" -#include "interrupts.h" -#include "hpet.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_SYSTEM, outstr) diff --git a/core/riscv-rv32i/panic.c b/core/riscv-rv32i/panic.c index 3ac34c7774..0ea86840f9 100644 --- a/core/riscv-rv32i/panic.c +++ b/core/riscv-rv32i/panic.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "cpu.h" #include "console.h" +#include "cpu.h" #include "panic.h" #include "task.h" #include "util.h" -- cgit v1.2.1 From 5d440d8b025a99953de7b751133088ade0f64d47 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 11:03:22 -0700 Subject: ec: IWYU Add missing include cbi.h needs common.h for __override_proto Zephyr's inttypes.h includes stdint.h, so do the same for ec's inttypes.h also. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I8917f1ad6a04dc35c2ef8eb437d9cf4cd5ec7fa7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049440 Commit-Queue: Tristan Honscheid Tested-by: Jeremy Bettis Reviewed-by: Tristan Honscheid Code-Coverage: Zoss Commit-Queue: Jeremy Bettis Auto-Submit: Jeremy Bettis --- baseboard/volteer/cbi.h | 2 ++ builtin/inttypes.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/baseboard/volteer/cbi.h b/baseboard/volteer/cbi.h index dc940f1edc..4b4044ea3c 100644 --- a/baseboard/volteer/cbi.h +++ b/baseboard/volteer/cbi.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_BASEBOARD_CBI_H #define __CROS_EC_BASEBOARD_CBI_H +#include "common.h" + unsigned char get_board_id(void); /** diff --git a/builtin/inttypes.h b/builtin/inttypes.h index 1ef305548b..eed80407ce 100644 --- a/builtin/inttypes.h +++ b/builtin/inttypes.h @@ -6,6 +6,8 @@ #ifndef __CROS_EC_INTTYPES_H__ #define __CROS_EC_INTTYPES_H__ +#include + #define PRIx64 "llx" #define PRId64 "lld" -- cgit v1.2.1 From a2a0c7af68c6649fd8dcccf43b33e9bcdf15e12e Mon Sep 17 00:00:00 2001 From: Diana Z Date: Tue, 22 Nov 2022 10:44:14 -0700 Subject: Skyrim: Configure mux resets for ANX7483 The ANX7483 is only turned on in S5 state and higher, and will default to a high power consumption state. Flag that this mux resets in G3 to ensure the USB mux code resets it to None. BRANCH=None BUG=b:259863457 TEST=on skyrim, ensure the contents of the control register on anx7483 is the same on first boot as it is after going to G3 and rebooting Signed-off-by: Diana Z Change-Id: I03cbee24b2849565074a7f856480e48a797db72b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4048900 Code-Coverage: Zoss Commit-Queue: Robert Zieba Reviewed-by: Robert Zieba --- zephyr/program/skyrim/crystaldrift.dts | 2 ++ zephyr/program/skyrim/morthal.dts | 2 ++ zephyr/program/skyrim/skyrim.dts | 2 ++ zephyr/program/skyrim/winterhold.dts | 2 ++ 4 files changed, 8 insertions(+) diff --git a/zephyr/program/skyrim/crystaldrift.dts b/zephyr/program/skyrim/crystaldrift.dts index b74136172a..36e5b58e13 100644 --- a/zephyr/program/skyrim/crystaldrift.dts +++ b/zephyr/program/skyrim/crystaldrift.dts @@ -149,6 +149,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "board_anx7483_c0_mux_set"; + flags = ; }; }; @@ -157,6 +158,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "board_anx7483_c1_mux_set"; + flags = ; }; ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; diff --git a/zephyr/program/skyrim/morthal.dts b/zephyr/program/skyrim/morthal.dts index 508ce23bce..a0c89e1d5c 100644 --- a/zephyr/program/skyrim/morthal.dts +++ b/zephyr/program/skyrim/morthal.dts @@ -131,6 +131,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "board_anx7483_c0_mux_set"; + flags = ; }; }; @@ -139,6 +140,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "board_anx7483_c1_mux_set"; + flags = ; }; ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; diff --git a/zephyr/program/skyrim/skyrim.dts b/zephyr/program/skyrim/skyrim.dts index 6a812a55f3..c19f8a5949 100644 --- a/zephyr/program/skyrim/skyrim.dts +++ b/zephyr/program/skyrim/skyrim.dts @@ -149,6 +149,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "board_anx7483_c0_mux_set"; + flags = ; }; }; @@ -157,6 +158,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "board_anx7483_c1_mux_set"; + flags = ; }; ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; diff --git a/zephyr/program/skyrim/winterhold.dts b/zephyr/program/skyrim/winterhold.dts index 5377403c48..356aca07e2 100644 --- a/zephyr/program/skyrim/winterhold.dts +++ b/zephyr/program/skyrim/winterhold.dts @@ -86,6 +86,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "board_anx7483_c0_mux_set"; + flags = ; }; ppc_port0: nx20p348x@71 { compatible = "nxp,nx20p348x"; @@ -99,6 +100,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "board_anx7483_c1_mux_set"; + flags = ; }; ppc_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; -- cgit v1.2.1 From 6a96283c3b07e0718588fe8742805f647f81b772 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Thu, 10 Nov 2022 17:43:04 -0700 Subject: zephyr emul: TCPC partner: Support sending VCS Support sending VCONN Swap from the partner emulator. Respond to Accept with PS_RDY and enabled VCONN if it was disabled. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.usbc_vconn_swap BRANCH=none LOW_COVERAGE_REASON=This is an emulator. Later CLs will use it. Signed-off-by: Abe Levkoy Change-Id: I011a391a2d378a637f7d8cc624addd46c4b54736 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025832 Reviewed-by: Tomasz Michalec Code-Coverage: Jeremy Bettis --- zephyr/emul/tcpc/emul_tcpci_partner_common.c | 58 ++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c index db3441716c..abc46ef0a2 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c @@ -405,11 +405,21 @@ int tcpci_partner_send_control_msg(struct tcpci_partner_data *data, msg->type = type; - if (msg->type == PD_CTRL_DR_SWAP) { - /* Remember the control request initiated, so we can - * handle the responses + switch (msg->type) { + case PD_CTRL_DR_SWAP: + case PD_CTRL_VCONN_SWAP: + /* For supported message types, remember the control request + * initiated, so the partner can handle the responses. + * (Eventually, all messages that can start an AMS should be + * supported.) */ tcpci_partner_common_set_ams_ctrl_msg(data, msg->type); + break; + default: + /* For messages that do not start an AMS, there is nothing to + * record. + */ + break; } return tcpci_partner_send_msg(data, msg, delay); @@ -941,6 +951,26 @@ tcpci_partner_common_accept_dr_swap_handler(struct tcpci_partner_data *data) return TCPCI_PARTNER_COMMON_MSG_HANDLED; } +static enum tcpci_partner_handler_res +tcpci_partner_common_accept_vconn_swap_handler(struct tcpci_partner_data *data) +{ + if (data->vconn_role == PD_ROLE_VCONN_SRC) { + /* TODO: Wait for PS_RDY. */ + } else { + /* VCONN Swap from off to VCONN Source means the partner sends + * the first PS_RDY after turning on VCONN. + */ + tcpci_partner_common_set_vconn(data, PD_ROLE_VCONN_ON); + tcpci_partner_send_control_msg(data, PD_CTRL_PS_RDY, 15); + tcpci_partner_common_clear_ams_ctrl_msg(data); + /* Strictly speaking, the AMS isn't over until the partner + * receives GoodCRC for the PS_RDY. + */ + } + + return TCPCI_PARTNER_COMMON_MSG_HANDLED; +} + static enum tcpci_partner_handler_res tcpi_drp_emul_ps_rdy_handler(struct tcpci_partner_data *data) { @@ -957,10 +987,27 @@ tcpi_drp_emul_ps_rdy_handler(struct tcpci_partner_data *data) static enum tcpci_partner_handler_res tcpi_partner_common_handle_accept(struct tcpci_partner_data *data) +{ + switch (data->cur_ams_ctrl_req) { + case PD_CTRL_VCONN_SWAP: + data->cur_ams_ctrl_req = PD_CTRL_INVALID; + return TCPCI_PARTNER_COMMON_MSG_HANDLED; + + default: + LOG_ERR("Unhandled current_req=%u in ACCEPT", + data->cur_ams_ctrl_req); + return TCPCI_PARTNER_COMMON_MSG_NOT_HANDLED; + } +} + +static enum tcpci_partner_handler_res +tcpci_partner_common_handle_reject(struct tcpci_partner_data *data) { switch (data->cur_ams_ctrl_req) { case PD_CTRL_DR_SWAP: return tcpci_partner_common_accept_dr_swap_handler(data); + case PD_CTRL_VCONN_SWAP: + return tcpci_partner_common_accept_vconn_swap_handler(data); default: LOG_ERR("Unhandled current_req=%u in ACCEPT", @@ -1073,6 +1120,10 @@ tcpci_partner_common_sop_msg_handler(struct tcpci_partner_data *data, tcpci_partner_common_send_hard_reset(data); return TCPCI_PARTNER_COMMON_MSG_HARD_RESET; + } else if (data->cur_ams_ctrl_req != PD_CTRL_INVALID) { + if (tcpci_partner_common_handle_reject(data) == + TCPCI_PARTNER_COMMON_MSG_HANDLED) + return TCPCI_PARTNER_COMMON_MSG_HANDLED; } tcpci_partner_common_clear_ams_ctrl_msg(data); @@ -1317,7 +1368,6 @@ void tcpci_partner_received_msg_status(struct tcpci_partner_data *data, if (data->received_msg_status == NULL) { return; } - /* * Status of each received message should be reported to TCPCI emulator * only once -- cgit v1.2.1 From 34be701febda42a32d9c98a21f008fbb292fd885 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Mon, 21 Nov 2022 13:47:05 -0700 Subject: zephyr emul: TCPC partner: Expose CC to extensions Implement a callback in the TCPC partner common code for changes to control registers in the TCPCI TCPC emulator. Specifically, when the TCPC changes ROLE_CONTROL, record the new CC "voltages" exposed by the TCPC emulator in the partner emulator. Then call any partner extension callbacks for control changes. This change does not cause the partner to react to other changes to TCPCI control registers. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.usbc_ctvpd BRANCH=none LOW_COVERAGE_REASON=This is an emulator. Later tests will use it. Signed-off-by: Abe Levkoy Change-Id: Id27a156ed5db6d805c439a33a157ae13706d541a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043735 Reviewed-by: Tomasz Michalec Code-Coverage: Zoss --- zephyr/emul/tcpc/emul_tcpci_partner_common.c | 29 +++++++++++++++++++++- .../include/emul/tcpc/emul_tcpci_partner_common.h | 6 +++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c index abc46ef0a2..cb12d37b63 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c @@ -4,6 +4,7 @@ */ #include "common.h" +#include "driver/tcpm/tcpci.h" #include "emul/tcpc/emul_tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "usb_pd.h" @@ -1193,6 +1194,16 @@ void tcpci_partner_set_discovery_info(struct tcpci_partner_data *data, memcpy(data->modes_vdm, modes_vdm, modes_vdos * sizeof(*modes_vdm)); } +static void tcpci_partner_common_control_change(struct tcpci_partner_data *data) +{ + const struct emul *tcpci_emul = data->tcpci_emul; + uint16_t role_control; + + tcpci_emul_get_reg(tcpci_emul, TCPC_REG_ROLE_CTRL, &role_control); + data->tcpm_cc1 = TCPC_REG_ROLE_CTRL_CC1(role_control); + data->tcpm_cc1 = TCPC_REG_ROLE_CTRL_CC2(role_control); +} + void tcpci_partner_common_disconnect(struct tcpci_partner_data *data) { tcpci_partner_clear_msg_queue(data); @@ -1491,6 +1502,22 @@ tcpci_partner_rx_consumed_op(const struct emul *emul, tcpci_partner_free_msg(msg); } +static void +tcpci_partner_control_change_op(const struct emul *emul, + const struct tcpci_emul_partner_ops *ops) +{ + struct tcpci_partner_data *data = + CONTAINER_OF(ops, struct tcpci_partner_data, ops); + struct tcpci_partner_extension *ext; + + tcpci_partner_common_control_change(data); + for (ext = data->extensions; ext != NULL; ext = ext->next) { + if (ext->ops->control_change) { + ext->ops->control_change(ext, data); + } + } +} + /** * @brief Function called when emulator is disconnected from TCPCI * @@ -1582,7 +1609,7 @@ void tcpci_partner_init(struct tcpci_partner_data *data, enum pd_rev_type rev) data->ops.transmit = tcpci_partner_transmit_op; data->ops.rx_consumed = tcpci_partner_rx_consumed_op; - data->ops.control_change = NULL; + data->ops.control_change = tcpci_partner_control_change_op; data->ops.disconnect = tcpci_partner_disconnect_op; data->displayport_configured = false; data->entered_svid = 0; diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h index 36071bc7d3..d0d0a2d183 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h @@ -148,6 +148,9 @@ struct tcpci_partner_data { /* SVID of entered mode (0 if no mode is entered) */ uint16_t entered_svid; + enum tcpc_cc_voltage_status tcpm_cc1; + enum tcpc_cc_voltage_status tcpm_cc2; + /* VDMs with which the partner responds to discovery REQs. The VDM * buffers include the VDM header, and the VDO counts include 1 for the * VDM header. This structure has space for the mode response for a @@ -312,6 +315,9 @@ struct tcpci_partner_extension_ops { void (*soft_reset)(struct tcpci_partner_extension *ext, struct tcpci_partner_data *common_data); + void (*control_change)(struct tcpci_partner_extension *ext, + struct tcpci_partner_data *common_data); + /** * @brief Function called when partner emulator is disconnected from * TCPM -- cgit v1.2.1 From d645e2e2ab3a8bf2ef88b4fa1e8382d13014c55d Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Tue, 22 Nov 2022 16:48:12 +1100 Subject: nissa: adjust PD power and voltage limits In discussion with the hardware designers, we have determined that 45W is the maximum input power that can be supported across all expected configurations while keeping internal current within the design range. Limit PD power to 45W to ensure good reliability. In addition, we find that 15V input is slightly more efficient than 20V, so we can improve efficiency slightly by limiting charger input to 15V without compromising overall system power (because USB-PD Source Power Rules require that 45W sources support 15V@3A so a charger will never require higher voltage to achieve this power). BUG=b:259859051 TEST=craask does not negotiate 20V input from a charger with 20V PDOs BRANCH=nissa Signed-off-by: Peter Marheine Change-Id: I2ade55ac3e63f6c6b4c9a19c54d39ce6ba88d194 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4044792 Commit-Queue: Andrew McRae Reviewed-by: Andrew McRae Code-Coverage: Zoss --- zephyr/program/nissa/program.conf | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 05c6c326a5..170b6ad39c 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -129,9 +129,16 @@ CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS=200 # Assume 4% overdraw, which could be changed with actual characterization CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=4 -# Dynamically select PD voltage to maximize charger efficiency -# TODO(b:259859051) re-enable after writing dps_config -CONFIG_PLATFORM_EC_USB_PD_DPS=n # Reduce logging so that state transitions do not cause protocol issues # pd dump [1-3] can be used to increase the debugging level CONFIG_PLATFORM_EC_USB_PD_INITIAL_DEBUG_LEVEL=0 + +# System-side power distribution is designed to be robust up to about 45W, and +# higher input power may have negative reliability implications (especially for +# systems with 2S batteries). Most devices can't exceed 45W sinking anyway, so +# limit charger power to keep system input current within the design range. +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 +# 15V input is slightly more efficient than 20V for all supported chargers, and +# because power is limited to 45W for other reasons (see above) limiting input +# voltage like this does not compromise the total power capacity of the system. +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=15000 \ No newline at end of file -- cgit v1.2.1 From 304ef5697ba59ac66247fe02ce4a76fc74df054c Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Wed, 23 Nov 2022 10:15:39 +1100 Subject: nissa: enable PD_REQUIRE_AP_MODE_ENTRY This corrects some behavior around docking stations and mode entry when the AP is powered off. BUG=b:258143457 TEST=display still works with Startech DK30C2DAGPD dock BRANCH=nissa Signed-off-by: Peter Marheine Change-Id: Idbd56fc0a0c44def2226b26530ffcd87a719311b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050000 Code-Coverage: Zoss Reviewed-by: Andrew McRae --- zephyr/program/nissa/program.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 170b6ad39c..8fd87c94b5 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -96,6 +96,7 @@ CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y # ADL integrated muxes are slow: unblock PD CONFIG_PLATFORM_EC_USB_MUX_TASK=y CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -- cgit v1.2.1 From b2b0dc824ace6e8718f08a0499845109206575f7 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 16:49:10 -0700 Subject: ec: Don't build jacuzzi with clang It runs out of flash space, even though gcc has 4k free. BRANCH=None BUG=b:256761895 TEST=cq Signed-off-by: Jeremy Bettis Change-Id: I2eef09da98a05a1aaae9f788c4f732e45725b200 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049890 Commit-Queue: Piotr Pawliczek Tested-by: Jeremy Bettis Code-Coverage: Zoss Commit-Queue: Jeremy Bettis Reviewed-by: Piotr Pawliczek Auto-Submit: Jeremy Bettis --- util/build_with_clang.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 1576d45216..0f1093c8a0 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -61,7 +61,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ "gelatin", "hammer", "hoho", - "jacuzzi", "kakadu", "kappa", "katsu", @@ -286,6 +285,7 @@ BOARDS_THAT_FAIL_WITH_CLANG = [ "burnet", # overflows flash "chocodile_vpdmcu", # compilation error: b/254710459 "fennel", # overflows flash + "jacuzzi", # overflows flash "juniper", # overflows flash "kodama", # overflows flash "makomo", # overflows flash -- cgit v1.2.1 From b7083a507efb13630b15e2c9bbc927aa7f7cdcfb Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Tue, 15 Nov 2022 14:25:18 -0700 Subject: zephyr emul: Add VPD partner extension Add a USB PD partner emulator extension with the behavior of a VCONN-powered device. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.default BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I9bce8bcecab238173cd55f202ba0debbfb9564c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025833 Reviewed-by: Tomasz Michalec Commit-Queue: Tomasz Michalec Code-Coverage: Zoss --- zephyr/emul/tcpc/CMakeLists.txt | 1 + zephyr/emul/tcpc/Kconfig | 10 ++ zephyr/emul/tcpc/emul_tcpci_partner_vpd.c | 125 ++++++++++++++++++++++ zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h | 49 +++++++++ 4 files changed, 185 insertions(+) create mode 100644 zephyr/emul/tcpc/emul_tcpci_partner_vpd.c create mode 100644 zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h diff --git a/zephyr/emul/tcpc/CMakeLists.txt b/zephyr/emul/tcpc/CMakeLists.txt index 8c011229f2..25031ad658 100644 --- a/zephyr/emul/tcpc/CMakeLists.txt +++ b/zephyr/emul/tcpc/CMakeLists.txt @@ -10,4 +10,5 @@ zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_DRP emul_tcpci_partner_dr zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_SNK emul_tcpci_partner_snk.c) zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_SRC emul_tcpci_partner_src.c) zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_FAULTY_EXT emul_tcpci_partner_faulty_ext.c) +zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_VPD emul_tcpci_partner_vpd.c) zephyr_library_sources_ifdef(CONFIG_EMUL_ANX7447 emul_anx7447.c) diff --git a/zephyr/emul/tcpc/Kconfig b/zephyr/emul/tcpc/Kconfig index 03b432f0a6..898664e557 100644 --- a/zephyr/emul/tcpc/Kconfig +++ b/zephyr/emul/tcpc/Kconfig @@ -76,4 +76,14 @@ config EMUL_TCPCI_PARTNER_FAULTY_EXT to TCPCI emulator. API of malfunctioning device emulator is available in zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h +config EMUL_TCPCI_PARTNER_VPD + bool "USB-C VCONN-powered device emulator" + select EMUL_TCPCI_PARTNER_COMMON + # select EMUL_TCPCI_PARTNER_SRC + help + Enable USB-C VCONN-powered device (VPD) emulator, which may be + attached to TCPCI emulator. API of VPD is available in + zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h. This emulation is + specifically for the host port side of the VPD. + endif # EMUL_TCPCI diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c b/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c new file mode 100644 index 0000000000..596dc45ef9 --- /dev/null +++ b/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c @@ -0,0 +1,125 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "driver/tcpm/tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_common.h" +#include "emul/tcpc/emul_tcpci_partner_faulty_ext.h" +#include "emul/tcpc/emul_tcpci_partner_snk.h" +#include "emul/tcpc/emul_tcpci_partner_src.h" +#include "emul/tcpc/emul_tcpci_partner_vpd.h" + +LOG_MODULE_REGISTER(tcpci_vpd_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); + +static enum tcpci_partner_handler_res +tcpci_vpd_emul_handle_sop_msg(struct tcpci_partner_extension *ext, + struct tcpci_partner_data *common_data, + const struct tcpci_emul_msg *msg) +{ + struct tcpci_vpd_emul_data *data = + CONTAINER_OF(ext, struct tcpci_vpd_emul_data, ext); + + /* Do not respond to SOP messages until charge-through is connected. */ + if (!data->charge_through_connected) + return TCPCI_PARTNER_COMMON_MSG_NO_GOODCRC; + + /* Once charge-through is connected, let the charger (later extension) + * handle SOP messages. + */ + return TCPCI_PARTNER_COMMON_MSG_NOT_HANDLED; +} + +static int tcpci_vpd_emul_connect(struct tcpci_partner_extension *ext, + struct tcpci_partner_data *common_data) +{ + struct tcpci_vpd_emul_data *data = + CONTAINER_OF(ext, struct tcpci_vpd_emul_data, ext); + + /* Strictly speaking, the VPD shouldn't GoodCRC anything on SOP, Source + * Capabilities is the first message it will receive, so that's good + * enough. + */ + if (common_data->power_role == PD_ROLE_SOURCE) { + tcpci_faulty_ext_clear_actions_list(&data->fault_ext); + } else { + data->fault_actions[0].action_mask = + TCPCI_FAULTY_EXT_FAIL_SRC_CAP; + data->fault_actions[0].count = TCPCI_FAULTY_EXT_INFINITE_ACTION; + tcpci_faulty_ext_append_action(&data->fault_ext, + &data->fault_actions[0]); + } + + return 0; +} + +static void +tcpci_vpd_emul_control_change(struct tcpci_partner_extension *ext, + struct tcpci_partner_data *common_data) +{ + struct tcpci_vpd_emul_data *data = + CONTAINER_OF(ext, struct tcpci_vpd_emul_data, ext); + enum pd_cc_states tcpm_cc_state = + pd_get_cc_state(common_data->tcpm_cc1, common_data->tcpm_cc2); + + LOG_DBG("TCPM changed control register; TCPM CC1 %u, CC2 %u", + common_data->tcpm_cc1, common_data->tcpm_cc2); + if (!data->charge_through_connected && + tcpm_cc_state == PD_CC_UFP_ATTACHED) { + LOG_INF("Connecting charge-through port as Source"); + data->charge_through_connected = true; + tcpci_partner_common_hard_reset_as_role(common_data, + PD_ROLE_SOURCE); + tcpci_partner_connect_to_tcpci(common_data, + common_data->tcpci_emul); + } +} + +void tcpci_vpd_emul_disconnect(struct tcpci_partner_extension *ext, + struct tcpci_partner_data *common_data) +{ + struct tcpci_vpd_emul_data *data = + CONTAINER_OF(ext, struct tcpci_vpd_emul_data, ext); + + data->charge_through_connected = false; + tcpci_partner_common_hard_reset_as_role(common_data, PD_ROLE_SINK); +} + +static struct tcpci_partner_extension_ops vpd_emul_ops = { + .sop_msg_handler = tcpci_vpd_emul_handle_sop_msg, + .connect = tcpci_vpd_emul_connect, + .control_change = tcpci_vpd_emul_control_change, + .disconnect = tcpci_vpd_emul_disconnect, +}; + +struct tcpci_partner_extension * +tcpci_vpd_emul_init(struct tcpci_vpd_emul_data *data, + struct tcpci_partner_data *common_data, + struct tcpci_partner_extension *ext) +{ + struct tcpci_partner_extension *vpd_ext = &data->ext; + struct tcpci_partner_extension *snk_ext; + struct tcpci_partner_extension *src_ext; + + /* A VPD host port initially attaches as a Sink and responds to SOP' + * Discover Identity while ignoring SOP traffic. Then, when a Source is + * connected to the charge-through port, the CT-VPD acts as a Source. + * This extension therefore contains a faulty extension, a sink + * extension, and a source extension, in that order. Due to the + * linked-list extension structure, the initialization order is the + * reverse of that. + */ + src_ext = tcpci_src_emul_init(&data->src_ext, common_data, ext); + snk_ext = tcpci_snk_emul_init(&data->snk_ext, common_data, src_ext); + vpd_ext->next = + tcpci_faulty_ext_init(&data->fault_ext, common_data, snk_ext); + + vpd_ext->ops = &vpd_emul_ops; + + data->charge_through_connected = false; + + return vpd_ext; +} diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h new file mode 100644 index 0000000000..4f0c600927 --- /dev/null +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h @@ -0,0 +1,49 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * @file + * + * @brief Backend API for USB-C VCONN-powered device emulator + */ + +#ifndef __EMUL_TCPCI_PARTNER_VPD_H +#define __EMUL_TCPCI_PARTNER_VPD_H + +#include + +#include "emul/tcpc/emul_tcpci_partner_common.h" +#include "emul/tcpc/emul_tcpci_partner_faulty_ext.h" +#include "emul/tcpc/emul_tcpci_partner_snk.h" +#include "emul/tcpc/emul_tcpci_partner_src.h" + +/** + * @brief USB-C VCONN-powered device extension backend API + * @defgroup tcpci_src_emul USB-C source device extension + * @{ + */ + +struct tcpci_vpd_emul_data { + /** Common extension structure */ + struct tcpci_partner_extension ext; + /** Pointer to common TCPCI partner data */ + struct tcpci_partner_data *common_data; + struct tcpci_faulty_ext_data fault_ext; + struct tcpci_faulty_ext_action fault_actions[1]; + struct tcpci_snk_emul_data snk_ext; + struct tcpci_src_emul_data src_ext; + bool charge_through_connected; +}; + +struct tcpci_partner_extension * +tcpci_vpd_emul_init(struct tcpci_vpd_emul_data *data, + struct tcpci_partner_data *common_data, + struct tcpci_partner_extension *ext); + +/** + * @} + */ + +#endif /* __EMUL_TCPCI_PARTNER_VPD_H */ -- cgit v1.2.1 From c24ebcfa71fa763284e54e1ce41df4a70d147065 Mon Sep 17 00:00:00 2001 From: Elsie Shih Date: Mon, 31 Oct 2022 19:53:38 +0800 Subject: moli: separate fw_config from the board.* - Add power on by monitor config - Re-locate barrel-jack power config BUG=b:239767485, b:241207167 BRANCH=none TEST=make BOARD=moli Signed-off-by: Elsie Shih Change-Id: I4b5f3f6599817069a6f1bdb633bdd9e4a1a34241 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3993602 Reviewed-by: Boris Mittelberg Code-Coverage: Zoss Tested-by: Scott Chao Reviewed-by: Zhuohao Lee --- board/moli/board.c | 36 +++---------------------- board/moli/board.h | 10 ------- board/moli/build.mk | 1 + board/moli/fw_config.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ board/moli/fw_config.h | 53 ++++++++++++++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 43 deletions(-) create mode 100644 board/moli/fw_config.c create mode 100644 board/moli/fw_config.h diff --git a/board/moli/board.c b/board/moli/board.c index acc12f9831..c995fe6ef7 100644 --- a/board/moli/board.c +++ b/board/moli/board.c @@ -13,6 +13,7 @@ #include "console.h" #include "cros_board_info.h" #include "driver/tcpm/tcpci.h" +#include "fw_config.h" #include "gpio.h" #include "gpio_signal.h" #include "hooks.h" @@ -116,34 +117,6 @@ static uint8_t usbc_overcurrent; * only do that if the system is off since it might still brown out. */ -/* - * Barrel-jack power adapter ratings. - */ -static const struct { - int voltage; - int current; -} bj_power[] = { - { /* 0 - 90W (also default) */ - .voltage = 19000, - .current = 4740 }, - { /* 1 - 135W */ - .voltage = 19500, - .current = 6920 }, -}; - -static unsigned int ec_config_get_bj_power(void) -{ - uint32_t fw_config; - unsigned int bj; - - cbi_get_fw_config(&fw_config); - bj = (fw_config & EC_CFG_BJ_POWER_MASK) >> EC_CFG_BJ_POWER_L; - /* Out of range value defaults to 0 */ - if (bj >= ARRAY_SIZE(bj_power)) - bj = 0; - return bj; -} - #define ADP_DEBOUNCE_MS 1000 /* Debounce time for BJ plug/unplug */ /* Debounced connection state of the barrel jack */ static int8_t adp_connected = -1; @@ -155,12 +128,9 @@ static void adp_connect_deferred(void) /* Debounce */ if (connected == adp_connected) return; - if (connected) { - unsigned int bj = ec_config_get_bj_power(); + if (connected) + ec_bj_power(&pi.voltage, &pi.current); - pi.voltage = bj_power[bj].voltage; - pi.current = bj_power[bj].current; - } charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED, DEDICATED_CHARGE_PORT, &pi); adp_connected = connected; diff --git a/board/moli/board.h b/board/moli/board.h index e7aa7855e7..aa2a2bc354 100644 --- a/board/moli/board.h +++ b/board/moli/board.h @@ -181,16 +181,6 @@ enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT }; enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT }; -/* - * firmware config fields - */ -/* - * Barrel-jack power (2 bits). - */ -#define EC_CFG_BJ_POWER_L 0 -#define EC_CFG_BJ_POWER_H 1 -#define EC_CFG_BJ_POWER_MASK GENMASK(EC_CFG_BJ_POWER_H, EC_CFG_BJ_POWER_L) - extern void adp_connect_interrupt(enum gpio_signal signal); #endif /* !__ASSEMBLER__ */ diff --git a/board/moli/build.mk b/board/moli/build.mk index 4897d446b2..4ddfaaf181 100644 --- a/board/moli/build.mk +++ b/board/moli/build.mk @@ -20,3 +20,4 @@ board-y+=pwm.o board-y+=sensors.o board-y+=thermal.o board-y+=usbc_config.o +board-y+=fw_config.o diff --git a/board/moli/fw_config.c b/board/moli/fw_config.c new file mode 100644 index 0000000000..5807ee9111 --- /dev/null +++ b/board/moli/fw_config.c @@ -0,0 +1,73 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "cbi.h" +#include "common.h" +#include "compile_time_macros.h" +#include "console.h" +#include "cros_board_info.h" +#include "fw_config.h" + +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) + +static union moli_cbi_fw_config fw_config; +BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t)); + +/* + * FW_CONFIG defaults for moli if the CBI.FW_CONFIG data is not + * initialized. + */ +static const union moli_cbi_fw_config fw_config_defaults = { + .bj_power = BJ_90W, + .po_mon = POWER_ON_MONITOR_ENABLE, +}; + +/* + * Barrel-jack power adapter ratings. + */ +static const struct { + int voltage; + int current; +} bj_power[] = { + [BJ_90W] = { /* 0 - 90W (also default) */ + .voltage = 19000, + .current = 4740 }, + [BJ_135W] = { /* 1 - 135W */ + .voltage = 19500, + .current = 6920 }, +}; + +/**************************************************************************** + * Moli FW_CONFIG access + */ +void board_init_fw_config(void) +{ + if (cbi_get_fw_config(&fw_config.raw_value)) { + CPRINTS("CBI: Read FW_CONFIG failed, using board defaults"); + fw_config = fw_config_defaults; + } +} + +union moli_cbi_fw_config get_fw_config(void) +{ + return fw_config; +} + +void ec_bj_power(uint32_t *voltage, uint32_t *current) +{ + unsigned int bj; + + bj = fw_config.bj_power; + /* Out of range value defaults to 0 */ + if (bj >= ARRAY_SIZE(bj_power)) + bj = 0; + *voltage = bj_power[bj].voltage; + *current = bj_power[bj].current; +} + +enum ec_cfg_power_on_monitor ec_cfg_power_on_monitor(void) +{ + return fw_config.po_mon; +} diff --git a/board/moli/fw_config.h b/board/moli/fw_config.h new file mode 100644 index 0000000000..ee3dcd274d --- /dev/null +++ b/board/moli/fw_config.h @@ -0,0 +1,53 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __BOARD_MOLI_FW_CONFIG_H_ +#define __BOARD_MOLI_FW_CONFIG_H_ + +#include + +/**************************************************************************** + * CBI FW_CONFIG layout for Moli board. + * + * Source of truth is the project/brask/moli/config.star configuration file. + */ + +enum ec_cfg_bj_power { BJ_90W = 0, BJ_135W = 1 }; + +enum ec_cfg_power_on_monitor { + POWER_ON_MONITOR_ENABLE = 0, + POWER_ON_MONITOR_DISABLE = 1 +}; + +union moli_cbi_fw_config { + struct { + uint32_t bj_power : 2; + uint32_t mlb_usb_tbt : 2; + uint32_t storage : 2; + uint32_t audio : 1; + enum ec_cfg_power_on_monitor po_mon : 1; + uint32_t reserved_1 : 24; + }; + uint32_t raw_value; +}; + +/** + * Read the cached FW_CONFIG. Guaranteed to have valid values. + * + * @return the FW_CONFIG for the board. + */ +union moli_cbi_fw_config get_fw_config(void); + +/** + * Get the barrel-jack power from FW_CONFIG. + */ +void ec_bj_power(uint32_t *voltage, uint32_t *current); + +/** + * Get enable/disable power on by monitor from FW_CONFIG. + */ +enum ec_cfg_power_on_monitor ec_cfg_power_on_monitor(void); + +#endif /* __BOARD_MOLI_FW_CONFIG_H_ */ -- cgit v1.2.1 From cb77fd22364bad47e3b04687f43f5292f1568dbd Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Tue, 15 Nov 2022 10:13:00 -0800 Subject: test: Use benchmark library in aes test BUG=b:235476822 TEST=test/run_device_tests.py -b bloonchipper -t aes TEST=make run-aes BRANCH=none Signed-off-by: Andrea Grandi Change-Id: Iae7e144d39ad34571a8f0a4f328feb42d08b09c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032315 Code-Coverage: Zoss Reviewed-by: Bobby Casey --- test/aes.cc | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/test/aes.cc b/test/aes.cc index 659f9ec971..b5fda52d93 100644 --- a/test/aes.cc +++ b/test/aes.cc @@ -14,6 +14,7 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "benchmark.h" #include "common.h" #include "test_util.h" @@ -424,7 +425,7 @@ static int test_aes_gcm(void) static void test_aes_gcm_speed(void) { - int i; + Benchmark benchmark({ .num_iterations = 1000 }); static const uint8_t key[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -443,21 +444,18 @@ static void test_aes_gcm_speed(void) uint8_t *out = tmp; static AES_KEY aes_key; static GCM128_CONTEXT ctx; - timestamp_t t0, t1; assert(plaintext_size <= sizeof(tmp)); - t0 = get_time(); - for (i = 0; i < 1000; i++) { + benchmark.run("AES-GCM", [&]() { AES_set_encrypt_key(key, 8 * key_size, &aes_key); CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, out, plaintext_size); CRYPTO_gcm128_tag(&ctx, tag, tag_size); - } - t1 = get_time(); - ccprintf("AES-GCM duration %lld us\n", (long long)(t1.val - t0.val)); + }); + benchmark.print_results(); } static int test_aes_raw(const uint8_t *key, int key_size, @@ -547,7 +545,7 @@ static int test_aes(void) static void test_aes_speed(void) { - int i; + Benchmark benchmark({ .num_iterations = 1000 }); /* Test vectors from FIPS-197, Appendix C. */ static const uint8_t key[] __aligned(4) = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, @@ -561,15 +559,13 @@ static void test_aes_speed(void) AES_KEY aes_key; uint8_t block[AES_BLOCK_SIZE]; - timestamp_t t0, t1; AES_set_encrypt_key(key, 8 * key_size, &aes_key); AES_encrypt(plaintext, block, &aes_key); - t0 = get_time(); - for (i = 0; i < 1000; i++) + benchmark.run("AES", [&block, &aes_key]() { AES_encrypt(block, block, &aes_key); - t1 = get_time(); - ccprintf("AES duration %lld us\n", (long long)(t1.val - t0.val)); + }); + benchmark.print_results(); } void run_test(int argc, const char **argv) -- cgit v1.2.1 From e1889643c5ee339920add2b9cb9b34912d6c232d Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Wed, 16 Nov 2022 14:19:44 -0800 Subject: test: Add AES-GCM decrypt benchmark BUG=b:235476822 TEST=test/run_device_tests.py -b bloonchipper -t aes TEST=make run-aes BRANCH=none Signed-off-by: Andrea Grandi Change-Id: Ic117d7a137065729e284b3c435062d4ce473e8d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032755 Code-Coverage: Zoss Reviewed-by: Bobby Casey --- test/aes.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/aes.cc b/test/aes.cc index b5fda52d93..6986abd148 100644 --- a/test/aes.cc +++ b/test/aes.cc @@ -431,7 +431,7 @@ static void test_aes_gcm_speed(void) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const int key_size = sizeof(key); - static const uint8_t plaintext[512] = { 0 }; + static uint8_t plaintext[512] = { 0 }; const auto plaintext_size = sizeof(plaintext); static const uint8_t nonce[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -441,20 +441,33 @@ static void test_aes_gcm_speed(void) uint8_t tag[16] = { 0 }; const int tag_size = sizeof(tag); - uint8_t *out = tmp; + uint8_t *encrypted_data = tmp; static AES_KEY aes_key; static GCM128_CONTEXT ctx; assert(plaintext_size <= sizeof(tmp)); - benchmark.run("AES-GCM", [&]() { + benchmark.run("AES-GCM encrypt", [&]() { AES_set_encrypt_key(key, 8 * key_size, &aes_key); CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); - CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, out, + CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, encrypted_data, plaintext_size); CRYPTO_gcm128_tag(&ctx, tag, tag_size); }); + + benchmark.run("AES-GCM decrypt", [&]() { + AES_set_encrypt_key(key, 8 * key_size, &aes_key); + CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0); + CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size); + auto decrypt_res = + CRYPTO_gcm128_decrypt(&ctx, &aes_key, encrypted_data, + plaintext, plaintext_size); + + auto finish_res = CRYPTO_gcm128_finish(&ctx, tag, tag_size); + assert(decrypt_res); + assert(finish_res); + }); benchmark.print_results(); } -- cgit v1.2.1 From f1b563c350acf6a1b687c682f07770aa8210dc01 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 11:38:48 -0700 Subject: baseboard: Sort header files Sort all includes in baseboard with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I259d3bae478d1f649623bc56339e2f8423ede0dc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049441 Tested-by: Jeremy Bettis Commit-Queue: Simon Glass Code-Coverage: Zoss Reviewed-by: Simon Glass Auto-Submit: Jeremy Bettis --- baseboard/asurada/baseboard.c | 8 ++++---- baseboard/asurada/baseboard.h | 2 +- baseboard/asurada/regulator.c | 2 +- baseboard/asurada/usbc_config.c | 11 +++++------ baseboard/brask/baseboard.c | 1 - baseboard/brask/baseboard.h | 8 ++++---- baseboard/brask/cbi.c | 6 +++--- baseboard/brask/usb_pd_policy.c | 9 ++++----- baseboard/brya/baseboard.h | 8 ++++---- baseboard/brya/battery_presence.c | 4 ++-- baseboard/brya/cbi.c | 6 +++--- baseboard/brya/charger_bq25720.c | 5 ++--- baseboard/brya/usb_pd_policy.c | 9 ++++----- baseboard/cherry/baseboard.c | 6 +++--- baseboard/cherry/baseboard.h | 2 +- baseboard/goroh/baseboard.c | 11 +++++------ baseboard/goroh/baseboard.h | 2 +- baseboard/goroh/usbc_config.c | 14 +++++++------- baseboard/guybrush/baseboard.c | 6 +++--- baseboard/guybrush/cbi.c | 2 +- baseboard/herobrine/usbc_config.c | 2 +- baseboard/honeybuns/baseboard.c | 4 ++-- baseboard/honeybuns/usb_pd_policy.c | 3 +-- baseboard/honeybuns/usbc_support.c | 10 +++++----- baseboard/intelrvp/adlrvp.c | 4 ++-- baseboard/intelrvp/chg_usb_pd_mecc_1_0.c | 2 +- baseboard/ite_evb/baseboard.c | 2 ++ baseboard/ite_evb/usb_pd_policy.c | 4 ++-- baseboard/kalista/baseboard.c | 3 +-- baseboard/kalista/usb_pd_policy.c | 4 ++-- baseboard/kukui/emmc.c | 3 +-- baseboard/kukui/emmc_ite.c | 3 +-- baseboard/octopus/variant_usbc_ec_tcpcs.c | 2 +- baseboard/volteer/baseboard.c | 2 +- baseboard/volteer/baseboard.h | 4 ++-- baseboard/volteer/battery_presence.c | 4 ++-- baseboard/volteer/cbi_ec_fw_config.c | 2 +- baseboard/volteer/charger.c | 4 ++-- baseboard/volteer/usb_pd_policy.c | 4 ++-- baseboard/volteer/usbc_config.c | 10 +++++----- baseboard/zork/baseboard.c | 2 +- baseboard/zork/cbi_ec_fw_config.c | 2 +- 42 files changed, 97 insertions(+), 105 deletions(-) diff --git a/baseboard/asurada/baseboard.c b/baseboard/asurada/baseboard.c index 3a881c275a..c315841a6a 100644 --- a/baseboard/asurada/baseboard.c +++ b/baseboard/asurada/baseboard.c @@ -8,15 +8,14 @@ #include "adc.h" #include "button.h" #include "charge_manager.h" -#include "charger.h" -#include "charger.h" #include "charge_state.h" #include "charge_state_v2.h" +#include "charger.h" #include "chipset.h" #include "common.h" #include "console.h" -#include "driver/accelgyro_bmi_common.h" #include "driver/accel_lis2dw12.h" +#include "driver/accelgyro_bmi_common.h" #include "driver/als_tcs3400.h" #include "driver/bc12/mt6360.h" #include "driver/charger/isl923x.h" @@ -31,8 +30,8 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "motion_sense.h" -#include "power_button.h" #include "power.h" +#include "power_button.h" #include "regulator.h" #include "spi.h" #include "switch.h" @@ -42,6 +41,7 @@ #include "timer.h" #include "uart.h" +/* This must be last. */ #include "gpio_list.h" /* Wake-up pins for hibernate */ diff --git a/baseboard/asurada/baseboard.h b/baseboard/asurada/baseboard.h index 62f74e1f57..b40f2f50de 100644 --- a/baseboard/asurada/baseboard.h +++ b/baseboard/asurada/baseboard.h @@ -183,8 +183,8 @@ #ifndef __ASSEMBLER__ #include "gpio_signal.h" -#include "registers.h" #include "power/mt8192.h" +#include "registers.h" void board_reset_pd_mcu(void); enum board_sub_board board_get_sub_board(void); diff --git a/baseboard/asurada/regulator.c b/baseboard/asurada/regulator.c index e2731c8385..0487f8faa6 100644 --- a/baseboard/asurada/regulator.c +++ b/baseboard/asurada/regulator.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "common.h" #include "bc12/mt6360_public.h" +#include "common.h" /* SD Card */ int board_regulator_get_info(uint32_t index, char *name, uint16_t *num_voltages, diff --git a/baseboard/asurada/usbc_config.c b/baseboard/asurada/usbc_config.c index 0be43d343a..ecc882659f 100644 --- a/baseboard/asurada/usbc_config.c +++ b/baseboard/asurada/usbc_config.c @@ -7,11 +7,11 @@ #include "adc.h" #include "baseboard_common.h" -#include "bc12/pi3usb9201_public.h" #include "bc12/mt6360_public.h" +#include "bc12/pi3usb9201_public.h" #include "button.h" -#include "charger.h" #include "charge_state_v2.h" +#include "charger.h" #include "charger/isl923x_public.h" #include "console.h" #include "ec_commands.h" @@ -20,20 +20,19 @@ #include "hooks.h" #include "i2c.h" #include "lid_switch.h" -#include "task.h" -#include "ppc/syv682x_public.h" #include "power.h" #include "power_button.h" +#include "ppc/syv682x_public.h" #include "spi.h" #include "switch.h" #include "tablet_mode.h" +#include "task.h" #include "tcpm/it8xxx2_pd_public.h" #include "uart.h" -#include "usbc_ppc.h" #include "usb_charge.h" #include "usb_mux.h" -#include "usb_mux/ps8743_public.h" #include "usb_mux/it5205_public.h" +#include "usb_mux/ps8743_public.h" #include "usb_pd_tcpm.h" #include "usbc_ppc.h" diff --git a/baseboard/brask/baseboard.c b/baseboard/brask/baseboard.c index 5a96ba49ca..33a3d9acf4 100644 --- a/baseboard/brask/baseboard.c +++ b/baseboard/brask/baseboard.c @@ -5,7 +5,6 @@ #include "common.h" #include "compile_time_macros.h" - #include "gpio_signal.h" /* Wake up pins */ diff --git a/baseboard/brask/baseboard.h b/baseboard/brask/baseboard.h index 3fb3a5955f..8f10ebb8aa 100644 --- a/baseboard/brask/baseboard.h +++ b/baseboard/brask/baseboard.h @@ -189,13 +189,13 @@ #ifndef __ASSEMBLER__ -#include -#include - -#include "common.h" #include "baseboard_usbc_config.h" +#include "common.h" #include "extpower.h" +#include +#include + /* * Configure run-time data structures and operation based on CBI data. This * typically includes customization for changes in the BOARD_VERSION and diff --git a/baseboard/brask/cbi.c b/baseboard/brask/cbi.c index 0dcfcca253..0ff0e4c7f7 100644 --- a/baseboard/brask/cbi.c +++ b/baseboard/brask/cbi.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - -#include "console.h" #include "common.h" +#include "console.h" #include "cros_board_info.h" #include "hooks.h" +#include + #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) diff --git a/baseboard/brask/usb_pd_policy.c b/baseboard/brask/usb_pd_policy.c index 0503415a9d..e20ad13f98 100644 --- a/baseboard/brask/usb_pd_policy.c +++ b/baseboard/brask/usb_pd_policy.c @@ -5,9 +5,6 @@ /* Shared USB-C policy for Brask boards */ -#include -#include - #include "charge_manager.h" #include "chipset.h" #include "common.h" @@ -16,15 +13,17 @@ #include "ec_commands.h" #include "gpio.h" #include "timer.h" -#include "usbc_ppc.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd.h" #include "usb_pd_tbt.h" #include "usb_pd_tcpm.h" #include "usb_pd_vdo.h" +#include "usbc_ppc.h" #include "util.h" +#include +#include + #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h index 84fefa9b53..6748a8a777 100644 --- a/baseboard/brya/baseboard.h +++ b/baseboard/brya/baseboard.h @@ -240,14 +240,14 @@ #ifndef __ASSEMBLER__ -#include -#include - +#include "baseboard_usbc_config.h" #include "cbi.h" #include "common.h" -#include "baseboard_usbc_config.h" #include "extpower.h" +#include +#include + /* * Check battery disconnect state. * This function will return if battery is initialized or not. diff --git a/baseboard/brya/battery_presence.c b/baseboard/brya/battery_presence.c index 1e4ab4ed44..ad055c1d12 100644 --- a/baseboard/brya/battery_presence.c +++ b/baseboard/brya/battery_presence.c @@ -6,12 +6,12 @@ * Each board should implement board_battery_info[] to define the specific * battery packs supported. */ -#include - #include "battery.h" #include "battery_smart.h" #include "common.h" +#include + static enum battery_present batt_pres_prev = BP_NOT_SURE; __overridable bool board_battery_is_initialized(void) diff --git a/baseboard/brya/cbi.c b/baseboard/brya/cbi.c index 7bc8dad117..f6e5034561 100644 --- a/baseboard/brya/cbi.c +++ b/baseboard/brya/cbi.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - -#include "console.h" #include "common.h" +#include "console.h" #include "cros_board_info.h" #include "hooks.h" +#include + #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) diff --git a/baseboard/brya/charger_bq25720.c b/baseboard/brya/charger_bq25720.c index 7fabd2082e..4976abdea6 100644 --- a/baseboard/brya/charger_bq25720.c +++ b/baseboard/brya/charger_bq25720.c @@ -3,16 +3,15 @@ * found in the LICENSE file. */ -#include "common.h" - #include "charge_manager.h" #include "charge_state_v2.h" #include "charger.h" +#include "common.h" #include "compile_time_macros.h" #include "console.h" #include "driver/charger/bq25710.h" -#include "usbc_ppc.h" #include "usb_pd.h" +#include "usbc_ppc.h" #include "util.h" #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) diff --git a/baseboard/brya/usb_pd_policy.c b/baseboard/brya/usb_pd_policy.c index e902fbc4a6..377ef0462e 100644 --- a/baseboard/brya/usb_pd_policy.c +++ b/baseboard/brya/usb_pd_policy.c @@ -5,9 +5,6 @@ /* Shared USB-C policy for Brya boards */ -#include -#include - #include "charge_manager.h" #include "chipset.h" #include "common.h" @@ -16,15 +13,17 @@ #include "ec_commands.h" #include "gpio.h" #include "timer.h" -#include "usbc_ppc.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd.h" #include "usb_pd_tbt.h" #include "usb_pd_tcpm.h" #include "usb_pd_vdo.h" +#include "usbc_ppc.h" #include "util.h" +#include +#include + #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/baseboard/cherry/baseboard.c b/baseboard/cherry/baseboard.c index 3f5f5c0e64..4e0a00e1ad 100644 --- a/baseboard/cherry/baseboard.c +++ b/baseboard/cherry/baseboard.c @@ -8,9 +8,9 @@ #include "adc.h" #include "button.h" #include "charge_manager.h" -#include "charger.h" #include "charge_state.h" #include "charge_state_v2.h" +#include "charger.h" #include "chipset.h" #include "common.h" #include "console.h" @@ -29,8 +29,8 @@ #include "i2c.h" #include "keyboard_scan.h" #include "lid_switch.h" -#include "power_button.h" #include "power.h" +#include "power_button.h" #include "regulator.h" #include "spi.h" #include "switch.h" @@ -41,10 +41,10 @@ #include "timer.h" #include "uart.h" #include "usb_charge.h" -#include "usbc_ppc.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" #include "usb_tc_sm.h" +#include "usbc_ppc.h" static void bc12_interrupt(enum gpio_signal signal); static void ppc_interrupt(enum gpio_signal signal); diff --git a/baseboard/cherry/baseboard.h b/baseboard/cherry/baseboard.h index 2b0d03a436..de3acda1d3 100644 --- a/baseboard/cherry/baseboard.h +++ b/baseboard/cherry/baseboard.h @@ -212,8 +212,8 @@ #ifndef __ASSEMBLER__ #include "gpio_signal.h" -#include "registers.h" #include "power/mt8192.h" +#include "registers.h" enum adc_channel { ADC_VBUS, /* ADC 0 */ diff --git a/baseboard/goroh/baseboard.c b/baseboard/goroh/baseboard.c index f70f070fac..8422030619 100644 --- a/baseboard/goroh/baseboard.c +++ b/baseboard/goroh/baseboard.c @@ -10,15 +10,14 @@ #include "baseboard_usbc_config.h" #include "button.h" #include "charge_manager.h" -#include "charger.h" -#include "charger.h" #include "charge_state.h" #include "charge_state_v2.h" +#include "charger.h" #include "chipset.h" #include "common.h" #include "console.h" -#include "driver/accelgyro_bmi_common.h" #include "driver/accel_lis2dw12.h" +#include "driver/accelgyro_bmi_common.h" #include "driver/als_tcs3400.h" #include "driver/charger/isl923x.h" #include "driver/ppc/syv682x.h" @@ -31,9 +30,8 @@ #include "keyboard_scan.h" #include "lid_switch.h" #include "motion_sense.h" -#include "power_button.h" -#include "power.h" #include "power.h" +#include "power_button.h" #include "spi.h" #include "switch.h" #include "tablet_mode.h" @@ -41,11 +39,12 @@ #include "temp_sensor.h" #include "timer.h" #include "uart.h" -#include "usbc_ppc.h" #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usbc_ppc.h" +/* Must be last. */ #include "gpio_list.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) diff --git a/baseboard/goroh/baseboard.h b/baseboard/goroh/baseboard.h index 1488bb6fcf..05c26d74a0 100644 --- a/baseboard/goroh/baseboard.h +++ b/baseboard/goroh/baseboard.h @@ -185,8 +185,8 @@ #ifndef __ASSEMBLER__ #include "gpio_signal.h" -#include "registers.h" #include "power/falconlite.h" +#include "registers.h" int board_get_version(void); void board_reset_pd_mcu(void); diff --git a/baseboard/goroh/usbc_config.c b/baseboard/goroh/usbc_config.c index 3df1e47fbd..f604a090d1 100644 --- a/baseboard/goroh/usbc_config.c +++ b/baseboard/goroh/usbc_config.c @@ -4,22 +4,22 @@ */ /* Goroh family-specific USB-C configuration */ -#include -#include - #include "common.h" #include "compile_time_macros.h" #include "config.h" #include "console.h" -#include "hooks.h" -#include "driver/tcpm/it8xxx2_pd_public.h" #include "driver/ppc/syv682x_public.h" #include "driver/retimer/ps8818_public.h" +#include "driver/tcpm/it8xxx2_pd_public.h" #include "driver/tcpm/tcpci.h" -#include "usb_pd.h" -#include "usbc_ppc.h" #include "gpio.h" #include "gpio_signal.h" +#include "hooks.h" +#include "usb_pd.h" +#include "usbc_ppc.h" + +#include +#include #define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ##args) diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c index 8afcb09fb4..654f73e7fe 100644 --- a/baseboard/guybrush/baseboard.c +++ b/baseboard/guybrush/baseboard.c @@ -5,25 +5,25 @@ /* Guybrush family-specific configuration */ -#include "cros_board_info.h" #include "base_fw_config.h" #include "battery_fuel_gauge.h" #include "charge_manager.h" #include "charge_ramp.h" -#include "charge_state_v2.h" #include "charge_state.h" +#include "charge_state_v2.h" #include "charger.h" #include "chip/npcx/ps2_chip.h" #include "chip/npcx/pwm_chip.h" #include "chipset.h" +#include "cros_board_info.h" #include "driver/ppc/aoz1380_public.h" #include "driver/ppc/nx20p348x.h" #include "driver/retimer/anx7491.h" #include "driver/retimer/ps8811.h" #include "driver/retimer/ps8818_public.h" #include "driver/tcpm/nct38xx.h" -#include "driver/usb_mux/anx7451.h" #include "driver/usb_mux/amd_fp6.h" +#include "driver/usb_mux/anx7451.h" #include "fan.h" #include "fan_chip.h" #include "gpio.h" diff --git a/baseboard/guybrush/cbi.c b/baseboard/guybrush/cbi.c index 6ce6fe0eb7..1baf506297 100644 --- a/baseboard/guybrush/cbi.c +++ b/baseboard/guybrush/cbi.c @@ -6,8 +6,8 @@ /* Guybrush CrOS Board Info(CBI) utilities */ #include "base_fw_config.h" -#include "console.h" #include "common.h" +#include "console.h" #include "cros_board_info.h" #include "hooks.h" diff --git a/baseboard/herobrine/usbc_config.c b/baseboard/herobrine/usbc_config.c index 2ebb8ae029..a5df0a0d4c 100644 --- a/baseboard/herobrine/usbc_config.c +++ b/baseboard/herobrine/usbc_config.c @@ -5,9 +5,9 @@ /* Herobrine family-specific USB-C configuration */ +#include "charge_state.h" #include "charger.h" #include "charger/isl923x_public.h" -#include "charge_state.h" #include "console.h" #include "usb_pd.h" diff --git a/baseboard/honeybuns/baseboard.c b/baseboard/honeybuns/baseboard.c index 506eb6f265..430eb488e7 100644 --- a/baseboard/honeybuns/baseboard.c +++ b/baseboard/honeybuns/baseboard.c @@ -7,15 +7,15 @@ #include "console.h" #include "cros_board_info.h" #include "driver/mp4245.h" +#include "driver/tcpm/tcpm.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" -#include "usb_pd.h" #include "system.h" #include "task.h" #include "timer.h" +#include "usb_pd.h" #include "usbc_ppc.h" -#include "driver/tcpm/tcpm.h" #include "util.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) diff --git a/baseboard/honeybuns/usb_pd_policy.c b/baseboard/honeybuns/usb_pd_policy.c index 956a73e7fb..f2e13d9ed9 100644 --- a/baseboard/honeybuns/usb_pd_policy.c +++ b/baseboard/honeybuns/usb_pd_policy.c @@ -3,13 +3,12 @@ * found in the LICENSE file. */ +#include "chip/stm32/ucpd-stm32gx.h" #include "common.h" #include "console.h" -#include "chip/stm32/ucpd-stm32gx.h" #include "cros_board_info.h" #include "driver/mp4245.h" #include "driver/tcpm/tcpci.h" -#include "driver/mp4245.h" #include "gpio.h" #include "hooks.h" #include "task.h" diff --git a/baseboard/honeybuns/usbc_support.c b/baseboard/honeybuns/usbc_support.c index db68ad527c..9c94f3f0ba 100644 --- a/baseboard/honeybuns/usbc_support.c +++ b/baseboard/honeybuns/usbc_support.c @@ -7,21 +7,21 @@ #include "common.h" #include "console.h" -#include "driver/tcpm/tcpci.h" #include "driver/tcpm/ps8xxx.h" -#include "sn5s330.h" +#include "driver/tcpm/tcpci.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" +#include "registers.h" +#include "sn5s330.h" #include "system.h" #include "timer.h" +#include "ucpd-stm32gx.h" #include "usb_charge.h" -#include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" #include "usbc_ppc.h" #include "util.h" -#include "registers.h" -#include "ucpd-stm32gx.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) diff --git a/baseboard/intelrvp/adlrvp.c b/baseboard/intelrvp/adlrvp.c index 35ed0edf32..5f307ac066 100644 --- a/baseboard/intelrvp/adlrvp.c +++ b/baseboard/intelrvp/adlrvp.c @@ -5,10 +5,10 @@ /* Intel ADLRVP board-specific common configuration */ -#include "battery_fuel_gauge.h" -#include "charger.h" #include "battery.h" +#include "battery_fuel_gauge.h" #include "bq25710.h" +#include "charger.h" #include "common.h" #include "driver/retimer/bb_retimer_public.h" #include "extpower.h" diff --git a/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c b/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c index cbc61e8402..ee8c67c7b6 100644 --- a/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c +++ b/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c @@ -11,8 +11,8 @@ #include "driver/ppc/sn5s330.h" #include "gpio.h" #include "hooks.h" -#include "tcpm/tcpci.h" #include "system.h" +#include "tcpm/tcpci.h" #include "usbc_ppc.h" #ifdef CONFIG_ZEPHYR diff --git a/baseboard/ite_evb/baseboard.c b/baseboard/ite_evb/baseboard.c index 70f50f054b..4c82a91d4b 100644 --- a/baseboard/ite_evb/baseboard.c +++ b/baseboard/ite_evb/baseboard.c @@ -25,6 +25,8 @@ #include "timer.h" #include "uart.h" #include "util.h" + +/* Must be last. */ #include "gpio_list.h" #if defined(CONFIG_FANS) || defined(CONFIG_PWM) diff --git a/baseboard/ite_evb/usb_pd_policy.c b/baseboard/ite_evb/usb_pd_policy.c index 71af9d2b1c..c7d10787bb 100644 --- a/baseboard/ite_evb/usb_pd_policy.c +++ b/baseboard/ite_evb/usb_pd_policy.c @@ -6,8 +6,8 @@ /* Shared USB-C policy for ite_evb baseboard */ #include "adc.h" -#include "config.h" #include "common.h" +#include "config.h" #include "console.h" #include "gpio.h" #include "hooks.h" @@ -16,9 +16,9 @@ #include "system.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_mux.h" #include "usb_pd_pdo.h" +#include "util.h" #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c index e929e5449c..7b20ea6a43 100644 --- a/baseboard/kalista/baseboard.c +++ b/baseboard/kalista/baseboard.c @@ -15,13 +15,12 @@ #include "console.h" #include "cros_board_info.h" #include "driver/pmic_tps650x30.h" -#include "driver/temp_sensor/tmp432.h" #include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/tcpci.h" #include "driver/tcpm/tcpm.h" +#include "driver/temp_sensor/tmp432.h" #include "espi.h" #include "extpower.h" -#include "espi.h" #include "fan.h" #include "fan_chip.h" #include "gpio.h" diff --git a/baseboard/kalista/usb_pd_policy.c b/baseboard/kalista/usb_pd_policy.c index 017c340a1b..b2f4656519 100644 --- a/baseboard/kalista/usb_pd_policy.c +++ b/baseboard/kalista/usb_pd_policy.c @@ -4,12 +4,12 @@ */ #include "atomic.h" -#include "extpower.h" #include "charge_manager.h" #include "common.h" #include "console.h" #include "driver/tcpm/anx74xx.h" #include "driver/tcpm/ps8xxx.h" +#include "extpower.h" #include "gpio.h" #include "hooks.h" #include "host_command.h" @@ -17,11 +17,11 @@ #include "system.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_pdo.h" #include "usb_pd_tcpm.h" +#include "util.h" #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/baseboard/kukui/emmc.c b/baseboard/kukui/emmc.c index 8731d7259c..416d44c634 100644 --- a/baseboard/kukui/emmc.c +++ b/baseboard/kukui/emmc.c @@ -28,6 +28,7 @@ * case we interrupt the transfer, and the BootROM will try again. */ +#include "bootblock_data.h" #include "chipset.h" #include "clock.h" #include "console.h" @@ -41,8 +42,6 @@ #include "timer.h" #include "util.h" -#include "bootblock_data.h" - #define CPRINTS(format, args...) cprints(CC_SPI, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SPI, format, ##args) diff --git a/baseboard/kukui/emmc_ite.c b/baseboard/kukui/emmc_ite.c index 2767199be0..6ac0200c1d 100644 --- a/baseboard/kukui/emmc_ite.c +++ b/baseboard/kukui/emmc_ite.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ +#include "bootblock_data.h" #include "chipset.h" #include "console.h" #include "endian.h" @@ -15,8 +16,6 @@ #include "timer.h" #include "util.h" -#include "bootblock_data.h" - #define CPRINTS(format, args...) cprints(CC_SPI, format, ##args) enum emmc_cmd { diff --git a/baseboard/octopus/variant_usbc_ec_tcpcs.c b/baseboard/octopus/variant_usbc_ec_tcpcs.c index 983887bc08..a93dfe3535 100644 --- a/baseboard/octopus/variant_usbc_ec_tcpcs.c +++ b/baseboard/octopus/variant_usbc_ec_tcpcs.c @@ -10,10 +10,10 @@ #include "console.h" #include "driver/ppc/sn5s330.h" #include "driver/tcpm/it83xx_pd.h" -#include "driver/usb_mux/it5205.h" #include "driver/tcpm/ps8xxx.h" #include "driver/tcpm/tcpci.h" #include "driver/tcpm/tcpm.h" +#include "driver/usb_mux/it5205.h" #include "gpio.h" #include "hooks.h" #include "system.h" diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c index fd36aef81f..b9f10fd360 100644 --- a/baseboard/volteer/baseboard.c +++ b/baseboard/volteer/baseboard.c @@ -7,8 +7,8 @@ #include "adc.h" #include "button.h" #include "cbi_ec_fw_config.h" -#include "charger.h" #include "charge_ramp.h" +#include "charger.h" #include "cros_board_info.h" #include "driver/charger/isl9241.h" #include "driver/tcpm/ps8xxx.h" diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h index 3b8e475fe5..10bea07eeb 100644 --- a/baseboard/volteer/baseboard.h +++ b/baseboard/volteer/baseboard.h @@ -243,10 +243,10 @@ #ifndef __ASSEMBLER__ -#include "gpio_signal.h" -#include "common.h" #include "baseboard_usbc_config.h" #include "cbi.h" +#include "common.h" +#include "gpio_signal.h" enum adc_channel { ADC_TEMP_SENSOR_1_CHARGER, diff --git a/baseboard/volteer/battery_presence.c b/baseboard/volteer/battery_presence.c index f143b67c91..d656b7b626 100644 --- a/baseboard/volteer/battery_presence.c +++ b/baseboard/volteer/battery_presence.c @@ -6,12 +6,12 @@ * Each board should implement board_battery_info[] to define the specific * battery packs supported. */ -#include - #include "battery.h" #include "battery_smart.h" #include "gpio.h" +#include + static enum battery_present batt_pres_prev = BP_NOT_SURE; enum battery_present battery_hw_present(void) diff --git a/baseboard/volteer/cbi_ec_fw_config.c b/baseboard/volteer/cbi_ec_fw_config.c index 7506278e16..f925498774 100644 --- a/baseboard/volteer/cbi_ec_fw_config.c +++ b/baseboard/volteer/cbi_ec_fw_config.c @@ -3,9 +3,9 @@ * found in the LICENSE file. */ +#include "cbi_ec_fw_config.h" #include "common.h" #include "console.h" -#include "cbi_ec_fw_config.h" #include "cros_board_info.h" #define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ##args) diff --git a/baseboard/volteer/charger.c b/baseboard/volteer/charger.c index 84fa4e037c..73b80e17b8 100644 --- a/baseboard/volteer/charger.c +++ b/baseboard/volteer/charger.c @@ -4,10 +4,10 @@ */ /* Volteer family-specific configuration */ -#include "common.h" -#include "charger.h" #include "charge_manager.h" #include "charge_state.h" +#include "charger.h" +#include "common.h" #include "driver/charger/isl9241_public.h" #include "gpio.h" #ifdef CONFIG_ZEPHYR diff --git a/baseboard/volteer/usb_pd_policy.c b/baseboard/volteer/usb_pd_policy.c index 81e02b769f..18c24b64ef 100644 --- a/baseboard/volteer/usb_pd_policy.c +++ b/baseboard/volteer/usb_pd_policy.c @@ -8,11 +8,11 @@ #include "compile_time_macros.h" #include "console.h" #include "gpio.h" +#include "system.h" #include "usb_common.h" #include "usb_mux.h" -#include "usbc_ppc.h" #include "usb_pd.h" -#include "system.h" +#include "usbc_ppc.h" #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/baseboard/volteer/usbc_config.c b/baseboard/volteer/usbc_config.c index 001f47e45f..1d1181ee41 100644 --- a/baseboard/volteer/usbc_config.c +++ b/baseboard/volteer/usbc_config.c @@ -5,21 +5,21 @@ /* Volteer family-specific USB-C configuration */ -#include "common.h" #include "charge_manager.h" #include "charge_ramp.h" #include "charge_state.h" +#include "common.h" #include "gpio.h" #include "task.h" #ifdef CONFIG_ZEPHYR -#include "usbc_config.h" #include "baseboard_usbc_config.h" +#include "usbc_config.h" #endif -#include "usbc_ppc.h" -#include "usb_pd.h" +#include "driver/charger/isl9241_public.h" #include "usb_charge.h" +#include "usb_pd.h" +#include "usbc_ppc.h" #include "util.h" -#include "driver/charger/isl9241_public.h" /******************************************************************************/ void tcpc_alert_event(enum gpio_signal signal) diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c index 593bcf1168..a9e4324aad 100644 --- a/baseboard/zork/baseboard.c +++ b/baseboard/zork/baseboard.c @@ -24,8 +24,8 @@ #include "extpower.h" #include "gpio.h" #include "hooks.h" -#include "ioexpander.h" #include "i2c.h" +#include "ioexpander.h" #include "keyboard_scan.h" #include "lid_switch.h" #include "motion_sense.h" diff --git a/baseboard/zork/cbi_ec_fw_config.c b/baseboard/zork/cbi_ec_fw_config.c index 4482a5cf40..555aeab9d7 100644 --- a/baseboard/zork/cbi_ec_fw_config.c +++ b/baseboard/zork/cbi_ec_fw_config.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "common.h" #include "cbi_ec_fw_config.h" +#include "common.h" #include "cros_board_info.h" /**************************************************************************** -- cgit v1.2.1 From b75dc90677f29424e6f0d63f294dce4b39782135 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Thu, 10 Nov 2022 16:37:09 +1100 Subject: Add CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT This splits the dual use of CONFIG_CHARGER_INPUT_CURRENT into two different symbols, changing the uses of that which are used to set a minimum current limit to be CONFIG_CHARGER_MAX_INPUT_CURRENT_LIMIT. Most boards implement this in the same way within either the board or baseboard, so handling of the new option is moved into charge_set_input_current_limit (which is called by every user of the option) and every board which repeated this pattern has the new symbol set to the same value as the old one, with the duplicated code deleted. One functional change to the charge manager is made: when charging stops, the input current limit is set to the default value (CONFIG_CHARGER_INPUT_CURRENT) rather than 0. This captures the intent that the default current is appropriate at any time, which was previously configured by individual boards' implementation of board_set_charge_limit() while still allowing the limit to be set lower as needed. To verify that all changes are appropriate, the following has been manually checked: * All boards with a change to a .c file also have a .h change * All boards without a changed .h file have a changed baseboard.h * For Zephyr projects, those with a changed .c file have config added for the minimum limit and others (only corsola) are unchanged to leave it off. This is intended to verify that each board that duplicated the MAX() logic has its configuration updated to use the shared copy, and that boards with that code in the baseboard also update their configuration. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none LOW_COVERAGE_REASON=added lines will soon be deleted Change-Id: Ia460a16293c1fb82aac3784fd9be57ba0985f2fe Signed-off-by: Peter Marheine Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019703 Reviewed-by: Keith Short Code-Coverage: Zoss --- baseboard/asurada/baseboard.h | 1 + baseboard/asurada/usbc_config.c | 3 +-- baseboard/brya/baseboard.h | 1 + baseboard/cherry/baseboard.h | 1 + baseboard/dedede/baseboard.h | 1 + baseboard/goroh/baseboard.c | 3 +-- baseboard/goroh/baseboard.h | 1 + baseboard/grunt/baseboard.c | 3 +-- baseboard/grunt/baseboard.h | 1 + baseboard/guybrush/baseboard.c | 3 +-- baseboard/guybrush/baseboard.h | 1 + baseboard/hatch/baseboard.c | 3 +-- baseboard/hatch/baseboard.h | 1 + baseboard/herobrine/baseboard.h | 1 + baseboard/intelrvp/baseboard.h | 1 + baseboard/intelrvp/chg_usb_pd.c | 3 +-- baseboard/kukui/baseboard.h | 1 + baseboard/octopus/baseboard.c | 3 +-- baseboard/octopus/baseboard.h | 1 + baseboard/trogdor/baseboard.h | 1 + baseboard/volteer/baseboard.h | 1 + baseboard/volteer/charger.c | 3 +-- baseboard/zork/baseboard.c | 3 +-- baseboard/zork/baseboard.h | 1 + board/agah/charger_isl9241.c | 3 +-- board/anahera/charger.c | 3 +-- board/atlas/board.c | 3 +-- board/atlas/board.h | 1 + board/banshee/charger.c | 3 +-- board/beadrix/board.c | 4 +--- board/beetley/board.c | 4 +--- board/bellis/board.c | 3 +-- board/blipper/board.c | 3 +-- board/boten/board.c | 3 +-- board/brya/charger.c | 3 +-- board/bugzzy/board.c | 3 +-- board/burnet/board.c | 3 +-- board/cappy2/board.c | 3 +-- board/cerise/board.c | 3 +-- board/cherry/board.c | 3 +-- board/coachz/board.c | 3 +-- board/coral/board.c | 3 +-- board/coral/board.h | 1 + board/corori/board.c | 3 +-- board/corori2/board.c | 3 +-- board/cret/board.c | 3 +-- board/crota/charger.c | 3 +-- board/damu/board.c | 3 +-- board/dibbi/board.c | 4 +--- board/dojo/board.c | 3 +-- board/drawcia/board.c | 6 ++---- board/drawcia_riscv/board.c | 6 ++---- board/driblee/board.c | 3 +-- board/drobit/board.c | 3 +-- board/eldrid/board.c | 3 +-- board/elm/board.c | 3 +-- board/elm/board.h | 1 + board/eve/board.c | 3 +-- board/eve/board.h | 1 + board/ezkinil/board.c | 3 +-- board/felwinter/charger_isl9241.c | 3 +-- board/fennel/board.c | 3 +-- board/galtic/board.c | 4 +--- board/gelarshie/board.c | 3 +-- board/gimble/charger.c | 3 +-- board/gooey/board.c | 3 +-- board/haboki/board.c | 6 ++---- board/herobrine/usbc_config.c | 3 +-- board/homestar/board.c | 3 +-- board/icarus/board.c | 3 +-- board/jacuzzi/board.c | 3 +-- board/kano/charger.c | 3 +-- board/kappa/board.c | 3 +-- board/kingoftown/usbc_config.c | 3 +-- board/kracko/board.c | 6 ++---- board/lalala/board.c | 3 +-- board/lantis/board.c | 4 +--- board/lazor/usbc_config.c | 3 +-- board/madoo/board.c | 3 +-- board/magolor/board.c | 3 +-- board/makomo/board.c | 3 +-- board/marzipan/board.c | 3 +-- board/mchpevb1/board.c | 3 +-- board/mchpevb1/board.h | 1 + board/metaknight/board.c | 3 +-- board/mithrax/charger_isl9241.c | 3 +-- board/mrbland/board.c | 3 +-- board/munna/board.c | 3 +-- board/nami/board.c | 3 +-- board/nami/board.h | 1 + board/nautilus/board.c | 3 +-- board/nautilus/board.h | 1 + board/nocturne/board.c | 3 +-- board/nocturne/board.h | 1 + board/oak/board.c | 3 +-- board/oak/board.h | 1 + board/osiris/charger.c | 3 +-- board/pazquel/board.c | 3 +-- board/pico/board.c | 3 +-- board/pirika/board.c | 4 +--- board/pompom/board.c | 3 +-- board/poppy/board.c | 5 +---- board/poppy/board.h | 1 + board/primus/board.c | 7 ++---- board/quackingstick/board.c | 3 +-- board/rammus/board.c | 3 +-- board/rammus/board.h | 1 + board/redrix/charger.c | 3 +-- board/reef/board.c | 3 +-- board/reef/board.h | 1 + board/reef_it8320/board.c | 3 +-- board/reef_it8320/board.h | 1 + board/reef_mchp/board.c | 3 +-- board/reef_mchp/board.h | 1 + board/sasuke/board.c | 3 +-- board/sasukette/board.c | 3 +-- board/scarlet/board.c | 3 +-- board/scarlet/board.h | 1 + board/stern/board.c | 3 +-- board/storo/board.c | 3 +-- board/taeko/charger.c | 3 +-- board/taniks/charger.c | 3 +-- board/trogdor/usbc_config.c | 3 +-- board/vell/charger.c | 3 +-- board/vilboz/board.c | 3 +-- board/volmar/charger.c | 3 +-- board/waddledee/board.c | 4 +--- board/waddledoo/board.c | 3 +-- board/waddledoo2/board.c | 3 +-- board/wheelie/board.c | 4 +--- board/willow/board.c | 3 +-- board/wormdingler/board.c | 3 +-- common/charge_manager.c | 6 +++++- common/charge_state_v2.c | 5 +++++ docs/low_battery_startup.md | 25 +++++++++++++++------- include/charge_state_v2.h | 3 ++- include/config.h | 19 ++++++++++++++-- zephyr/Kconfig.usbc | 20 +++++++++++++++++ zephyr/program/brya/prj.conf | 1 + zephyr/program/herobrine/program.conf | 1 + zephyr/program/herobrine/src/usbc_config.c | 3 +-- zephyr/program/intelrvp/prj.conf | 1 + zephyr/program/intelrvp/src/chg_usb_pd.c | 3 +-- zephyr/program/nissa/program.conf | 1 + zephyr/program/nissa/src/common.c | 3 +-- zephyr/program/rex/prj.conf | 1 + zephyr/program/rex/src/usbc_config.c | 3 +-- zephyr/program/skyrim/prj.conf | 1 + zephyr/program/skyrim/src/usbc_config.c | 3 +-- zephyr/program/trogdor/lazor/prj.conf | 1 + zephyr/program/trogdor/lazor/src/usbc_config.c | 3 +-- zephyr/shim/include/config_chip.h | 6 ++++++ .../test/drivers/bc12_pi3usb9201/src/pi3usb9201.c | 8 +++++-- zephyr/test/drivers/common/src/stubs.c | 3 +-- .../common_charger/src/test_charge_state_v2.c | 13 +++++++++++ zephyr/test/drivers/testcase.yaml | 1 + 156 files changed, 243 insertions(+), 253 deletions(-) diff --git a/baseboard/asurada/baseboard.h b/baseboard/asurada/baseboard.h index b40f2f50de..597515363c 100644 --- a/baseboard/asurada/baseboard.h +++ b/baseboard/asurada/baseboard.h @@ -61,6 +61,7 @@ #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9238C #define CONFIG_CHARGER_MAINTAIN_VBAT #define CONFIG_CHARGER_OTG diff --git a/baseboard/asurada/usbc_config.c b/baseboard/asurada/usbc_config.c index ecc882659f..57396121f5 100644 --- a/baseboard/asurada/usbc_config.c +++ b/baseboard/asurada/usbc_config.c @@ -311,8 +311,7 @@ void board_reset_pd_mcu(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h index 6748a8a777..b2d722fcd9 100644 --- a/baseboard/brya/baseboard.h +++ b/baseboard/brya/baseboard.h @@ -69,6 +69,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CMD_CHARGER_DUMP diff --git a/baseboard/cherry/baseboard.h b/baseboard/cherry/baseboard.h index de3acda1d3..8cd2aacd1f 100644 --- a/baseboard/cherry/baseboard.h +++ b/baseboard/cherry/baseboard.h @@ -71,6 +71,7 @@ #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9238C #define CONFIG_CHARGER_MAINTAIN_VBAT /* Not used in boot flow, set to 0 to suppress system_can_boot_ap warning */ diff --git a/baseboard/dedede/baseboard.h b/baseboard/dedede/baseboard.h index e581a0e8d0..e03d41ae21 100644 --- a/baseboard/dedede/baseboard.h +++ b/baseboard/dedede/baseboard.h @@ -165,6 +165,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 256 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 256 #define CONFIG_USB_CHARGER #define CONFIG_TRICKLE_CHARGING diff --git a/baseboard/goroh/baseboard.c b/baseboard/goroh/baseboard.c index 8422030619..d1474f78a7 100644 --- a/baseboard/goroh/baseboard.c +++ b/baseboard/goroh/baseboard.c @@ -163,8 +163,7 @@ const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) diff --git a/baseboard/goroh/baseboard.h b/baseboard/goroh/baseboard.h index 05c26d74a0..205621e040 100644 --- a/baseboard/goroh/baseboard.h +++ b/baseboard/goroh/baseboard.h @@ -58,6 +58,7 @@ #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9238C #define CONFIG_CHARGER_MAINTAIN_VBAT #define CONFIG_CHARGER_OTG diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c index 50db1887f1..aef91f5e30 100644 --- a/baseboard/grunt/baseboard.c +++ b/baseboard/grunt/baseboard.c @@ -467,8 +467,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /* Keyboard scan setting */ diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h index b83b274d49..e385b11b86 100644 --- a/baseboard/grunt/baseboard.h +++ b/baseboard/grunt/baseboard.h @@ -73,6 +73,7 @@ * See also b/111214767 */ #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c index 654f73e7fe..b8b4b775a6 100644 --- a/baseboard/guybrush/baseboard.c +++ b/baseboard/guybrush/baseboard.c @@ -537,8 +537,7 @@ int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void sbu_fault_interrupt(enum ioex_signal signal) diff --git a/baseboard/guybrush/baseboard.h b/baseboard/guybrush/baseboard.h index 04b1e10c97..883bf27847 100644 --- a/baseboard/guybrush/baseboard.h +++ b/baseboard/guybrush/baseboard.h @@ -163,6 +163,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9241 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c index f5376700c5..9910f21880 100644 --- a/baseboard/hatch/baseboard.c +++ b/baseboard/hatch/baseboard.c @@ -351,8 +351,7 @@ int ppc_get_alert_status(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } #ifdef USB_PD_PORT_TCPC_MST diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h index d5d680e7bf..9ba148e91e 100644 --- a/baseboard/hatch/baseboard.h +++ b/baseboard/hatch/baseboard.h @@ -97,6 +97,7 @@ #define CONFIG_CHARGER_BQ25710 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */ +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 #define CONFIG_CHARGE_RAMP_HW diff --git a/baseboard/herobrine/baseboard.h b/baseboard/herobrine/baseboard.h index 0782612cb8..b1aabc6bd6 100644 --- a/baseboard/herobrine/baseboard.h +++ b/baseboard/herobrine/baseboard.h @@ -89,6 +89,7 @@ #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/baseboard/intelrvp/baseboard.h b/baseboard/intelrvp/baseboard.h index b927632fc5..96acf8c562 100644 --- a/baseboard/intelrvp/baseboard.h +++ b/baseboard/intelrvp/baseboard.h @@ -69,6 +69,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_SENSE_RESISTOR 5 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 #undef CONFIG_EXTPOWER_DEBOUNCE_MS diff --git a/baseboard/intelrvp/chg_usb_pd.c b/baseboard/intelrvp/chg_usb_pd.c index 95aeea0441..9fa7c60f44 100644 --- a/baseboard/intelrvp/chg_usb_pd.c +++ b/baseboard/intelrvp/chg_usb_pd.c @@ -129,6 +129,5 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h index 9afc726861..4a5562fb04 100644 --- a/baseboard/kukui/baseboard.h +++ b/baseboard/kukui/baseboard.h @@ -62,6 +62,7 @@ #define CONFIG_CHARGER_SENSE_RESISTOR 10 /* BOARD_RS2 */ #define CONFIG_CHARGER_OTG #define CONFIG_CHARGE_RAMP_HW +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 /* TCPC FUSB302 */ #define PD_POWER_SUPPLY_TURN_ON_DELAY 160000 /* us */ diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c index b35bbcd67b..c852d1fad5 100644 --- a/baseboard/octopus/baseboard.c +++ b/baseboard/octopus/baseboard.c @@ -301,8 +301,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_hibernate(void) diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h index 8662749c98..9c6e2a14e6 100644 --- a/baseboard/octopus/baseboard.h +++ b/baseboard/octopus/baseboard.h @@ -155,6 +155,7 @@ #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER #define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */ +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_USB_CHARGER diff --git a/baseboard/trogdor/baseboard.h b/baseboard/trogdor/baseboard.h index 2dedf8f330..901466fec1 100644 --- a/baseboard/trogdor/baseboard.h +++ b/baseboard/trogdor/baseboard.h @@ -93,6 +93,7 @@ #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h index 10bea07eeb..4df7d5fc73 100644 --- a/baseboard/volteer/baseboard.h +++ b/baseboard/volteer/baseboard.h @@ -108,6 +108,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 /* * Hardware based charge ramp is broken in the ISL9241 (b/169350714). diff --git a/baseboard/volteer/charger.c b/baseboard/volteer/charger.c index 73b80e17b8..252e8795d3 100644 --- a/baseboard/volteer/charger.c +++ b/baseboard/volteer/charger.c @@ -83,8 +83,7 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_overcurrent_event(int port, int is_overcurrented) diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c index a9e4324aad..0ad8339591 100644 --- a/baseboard/zork/baseboard.c +++ b/baseboard/zork/baseboard.c @@ -99,8 +99,7 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, baseboard_chipset_resume, HOOK_PRIO_DEFAULT); __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /* Keyboard scan setting */ diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h index 2289c1891b..528aa44a91 100644 --- a/baseboard/zork/baseboard.h +++ b/baseboard/zork/baseboard.h @@ -77,6 +77,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9241 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/board/agah/charger_isl9241.c b/board/agah/charger_isl9241.c index 47e8261f78..64ad9ae7f7 100644 --- a/board/agah/charger_isl9241.c +++ b/board/agah/charger_isl9241.c @@ -199,8 +199,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } static const struct charge_port_info bj_power = { diff --git a/board/anahera/charger.c b/board/anahera/charger.c index 29211bc033..6b45881b99 100644 --- a/board/anahera/charger.c +++ b/board/anahera/charger.c @@ -85,6 +85,5 @@ int board_set_active_charge_port(int port) __override void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/atlas/board.c b/board/atlas/board.c index 633543b51f..685afb3e0e 100644 --- a/board/atlas/board.c +++ b/board/atlas/board.c @@ -551,8 +551,7 @@ DECLARE_HOOK(HOOK_INIT, board_charger_init, HOOK_PRIO_DEFAULT); void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } static void board_chipset_suspend(void) diff --git a/board/atlas/board.h b/board/atlas/board.h index 97f6d67e49..f5cef8d582 100644 --- a/board/atlas/board.h +++ b/board/atlas/board.h @@ -78,6 +78,7 @@ #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGER_PSYS diff --git a/board/banshee/charger.c b/board/banshee/charger.c index 88f5b85a41..8edcb00e31 100644 --- a/board/banshee/charger.c +++ b/board/banshee/charger.c @@ -83,6 +83,5 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/beadrix/board.c b/board/beadrix/board.c index 5cea32f90c..14467a66a1 100644 --- a/board/beadrix/board.c +++ b/board/beadrix/board.c @@ -478,13 +478,11 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/beetley/board.c b/board/beetley/board.c index e0ba900a70..28ae90fc9b 100644 --- a/board/beetley/board.c +++ b/board/beetley/board.c @@ -387,9 +387,7 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/bellis/board.c b/board/bellis/board.c index fc960749f3..fb9701e4e7 100644 --- a/board/bellis/board.c +++ b/board/bellis/board.c @@ -239,8 +239,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/blipper/board.c b/board/blipper/board.c index b7782a8af9..b31c5cde38 100644 --- a/board/blipper/board.c +++ b/board/blipper/board.c @@ -539,8 +539,7 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/boten/board.c b/board/boten/board.c index 9a54a4a341..14899b0a3a 100644 --- a/board/boten/board.c +++ b/board/boten/board.c @@ -247,8 +247,7 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/brya/charger.c b/board/brya/charger.c index b1a29c725b..937a48590c 100644 --- a/board/brya/charger.c +++ b/board/brya/charger.c @@ -85,6 +85,5 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/bugzzy/board.c b/board/bugzzy/board.c index b6a015999e..6d30dba966 100644 --- a/board/bugzzy/board.c +++ b/board/bugzzy/board.c @@ -396,8 +396,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/burnet/board.c b/board/burnet/board.c index 923a7a76ce..b4a8860cf1 100644 --- a/board/burnet/board.c +++ b/board/burnet/board.c @@ -225,8 +225,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/cappy2/board.c b/board/cappy2/board.c index d81e731ebf..eb33499eb0 100644 --- a/board/cappy2/board.c +++ b/board/cappy2/board.c @@ -232,8 +232,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/cerise/board.c b/board/cerise/board.c index 62fbc69254..03c31b3ec9 100644 --- a/board/cerise/board.c +++ b/board/cerise/board.c @@ -239,8 +239,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/cherry/board.c b/board/cherry/board.c index c2ad54acb2..2f2f242b48 100644 --- a/board/cherry/board.c +++ b/board/cherry/board.c @@ -265,8 +265,7 @@ const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /* Initialize board. */ diff --git a/board/coachz/board.c b/board/coachz/board.c index 96ed26b819..a0f6dc74fc 100644 --- a/board/coachz/board.c +++ b/board/coachz/board.c @@ -697,8 +697,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/coral/board.c b/board/coral/board.c index 922a19e97c..612ec180ae 100644 --- a/board/coral/board.c +++ b/board/coral/board.c @@ -566,8 +566,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /** diff --git a/board/coral/board.h b/board/coral/board.h index eee201669c..9b45db2cf3 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -61,6 +61,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MAINTAIN_VBAT #undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 diff --git a/board/corori/board.c b/board/corori/board.c index 09baf1eabf..11d4ad8169 100644 --- a/board/corori/board.c +++ b/board/corori/board.c @@ -314,8 +314,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/corori2/board.c b/board/corori2/board.c index c06ccbb15b..bc41f397ad 100644 --- a/board/corori2/board.c +++ b/board/corori2/board.c @@ -457,8 +457,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/cret/board.c b/board/cret/board.c index 90bfc7d41a..17ecb3e7da 100644 --- a/board/cret/board.c +++ b/board/cret/board.c @@ -307,8 +307,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/crota/charger.c b/board/crota/charger.c index c7dcf7b0c1..e46364ee6d 100644 --- a/board/crota/charger.c +++ b/board/crota/charger.c @@ -83,6 +83,5 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/damu/board.c b/board/damu/board.c index a2415f228d..7c82182ce4 100644 --- a/board/damu/board.c +++ b/board/damu/board.c @@ -239,8 +239,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/dibbi/board.c b/board/dibbi/board.c index 467e238d8a..f546c92c87 100644 --- a/board/dibbi/board.c +++ b/board/dibbi/board.c @@ -235,13 +235,11 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_set_active_charge_port(int port) diff --git a/board/dojo/board.c b/board/dojo/board.c index 62f2e6ac09..fcc924770c 100644 --- a/board/dojo/board.c +++ b/board/dojo/board.c @@ -473,8 +473,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, /* Limit input current lower than 2944 mA for safety */ charge_ma = MIN(charge_ma, 2944); - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /* NVME */ diff --git a/board/drawcia/board.c b/board/drawcia/board.c index 118b3178be..325de31f5e 100644 --- a/board/drawcia/board.c +++ b/board/drawcia/board.c @@ -613,16 +613,14 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* Limit C1 on board version 0 to 2.0 A */ if ((board_version == 0) && (port == 1)) - icl = MIN(icl, 2000); + charge_ma = MIN(charge_ma, 2000); /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_set_active_charge_port(int port) diff --git a/board/drawcia_riscv/board.c b/board/drawcia_riscv/board.c index cbc977d64b..f44be9ed7c 100644 --- a/board/drawcia_riscv/board.c +++ b/board/drawcia_riscv/board.c @@ -545,16 +545,14 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* Limit C1 on board version 0 to 2.0 A */ if ((board_version == 0) && (port == 1)) - icl = MIN(icl, 2000); + charge_ma = MIN(charge_ma, 2000); /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_set_active_charge_port(int port) diff --git a/board/driblee/board.c b/board/driblee/board.c index 5c78dbda06..fd4c4bb573 100644 --- a/board/driblee/board.c +++ b/board/driblee/board.c @@ -341,8 +341,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/drobit/board.c b/board/drobit/board.c index c2bdbec773..b07e01d0fb 100644 --- a/board/drobit/board.c +++ b/board/drobit/board.c @@ -481,6 +481,5 @@ DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/eldrid/board.c b/board/eldrid/board.c index 6212c6a375..1abf9c6acd 100644 --- a/board/eldrid/board.c +++ b/board/eldrid/board.c @@ -182,8 +182,7 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma, else isl9241_set_ac_prochot(0, 3328); - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /******************************************************************************/ diff --git a/board/elm/board.c b/board/elm/board.c index 329c411c8a..2e99a42b7c 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -340,8 +340,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); pd_send_host_event(PD_EVENT_POWER_CHANGE); } diff --git a/board/elm/board.h b/board/elm/board.h index 31a6ec7b61..ba542754b5 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -38,6 +38,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_ISL9237 #define CONFIG_CHARGER_MAX_INPUT_CURRENT 3000 diff --git a/board/eve/board.c b/board/eve/board.c index 77e5b403a0..9f89792818 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -646,8 +646,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /** diff --git a/board/eve/board.h b/board/eve/board.h index 361f2ddd53..b9de20896d 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -101,6 +101,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_MAINTAIN_VBAT #define CONFIG_CHARGER_PROFILE_OVERRIDE diff --git a/board/ezkinil/board.c b/board/ezkinil/board.c index 2173a2062d..d9ea2c0ecb 100644 --- a/board/ezkinil/board.c +++ b/board/ezkinil/board.c @@ -869,6 +869,5 @@ int fan_percent_to_rpm(int fan, int pct) __override void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/felwinter/charger_isl9241.c b/board/felwinter/charger_isl9241.c index 7d4026b818..552436824a 100644 --- a/board/felwinter/charger_isl9241.c +++ b/board/felwinter/charger_isl9241.c @@ -83,6 +83,5 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/fennel/board.c b/board/fennel/board.c index e583a21285..95f865a20c 100644 --- a/board/fennel/board.c +++ b/board/fennel/board.c @@ -240,8 +240,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/galtic/board.c b/board/galtic/board.c index af0638be20..787b8877ab 100644 --- a/board/galtic/board.c +++ b/board/galtic/board.c @@ -505,13 +505,11 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_is_sourcing_vbus(int port) diff --git a/board/gelarshie/board.c b/board/gelarshie/board.c index dfa85037a2..5ce8030560 100644 --- a/board/gelarshie/board.c +++ b/board/gelarshie/board.c @@ -696,8 +696,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/gimble/charger.c b/board/gimble/charger.c index b1a29c725b..937a48590c 100644 --- a/board/gimble/charger.c +++ b/board/gimble/charger.c @@ -85,6 +85,5 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/gooey/board.c b/board/gooey/board.c index 9acbadd10d..80748b29de 100644 --- a/board/gooey/board.c +++ b/board/gooey/board.c @@ -262,8 +262,7 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/haboki/board.c b/board/haboki/board.c index d7509115b5..1c48955cbc 100644 --- a/board/haboki/board.c +++ b/board/haboki/board.c @@ -529,16 +529,14 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* Limit C1 on board version 0 to 2.0 A */ if ((board_version == 0) && (port == 1)) - icl = MIN(icl, 2000); + charge_ma = MIN(charge_ma, 2000); /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_set_active_charge_port(int port) diff --git a/board/herobrine/usbc_config.c b/board/herobrine/usbc_config.c index 18033e0b3c..5d5d57d8bc 100644 --- a/board/herobrine/usbc_config.c +++ b/board/herobrine/usbc_config.c @@ -299,8 +299,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/homestar/board.c b/board/homestar/board.c index b1a136dd67..3c63fd7f81 100644 --- a/board/homestar/board.c +++ b/board/homestar/board.c @@ -644,8 +644,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/icarus/board.c b/board/icarus/board.c index d0a98c901e..e11e763f10 100644 --- a/board/icarus/board.c +++ b/board/icarus/board.c @@ -207,8 +207,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c index 6df0b8dc82..5a3f34d273 100644 --- a/board/jacuzzi/board.c +++ b/board/jacuzzi/board.c @@ -247,8 +247,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/kano/charger.c b/board/kano/charger.c index ab48a7338c..4ad9b41deb 100644 --- a/board/kano/charger.c +++ b/board/kano/charger.c @@ -83,6 +83,5 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/kappa/board.c b/board/kappa/board.c index e3e374e18d..f99d11f063 100644 --- a/board/kappa/board.c +++ b/board/kappa/board.c @@ -220,8 +220,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/kingoftown/usbc_config.c b/board/kingoftown/usbc_config.c index 5cd1f81818..3e4179904c 100644 --- a/board/kingoftown/usbc_config.c +++ b/board/kingoftown/usbc_config.c @@ -347,8 +347,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/kracko/board.c b/board/kracko/board.c index 136b05ea1e..6ac215b1fb 100644 --- a/board/kracko/board.c +++ b/board/kracko/board.c @@ -585,16 +585,14 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* Limit C1 on board version 0 to 2.0 A */ if ((board_version == 0) && (port == 1)) - icl = MIN(icl, 2000); + charge_ma = MIN(charge_ma, 2000); /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_set_active_charge_port(int port) diff --git a/board/lalala/board.c b/board/lalala/board.c index feedfe0262..b06e6760db 100644 --- a/board/lalala/board.c +++ b/board/lalala/board.c @@ -400,8 +400,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/lantis/board.c b/board/lantis/board.c index 08fc84e222..8d20b61673 100644 --- a/board/lantis/board.c +++ b/board/lantis/board.c @@ -722,13 +722,11 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_set_active_charge_port(int port) diff --git a/board/lazor/usbc_config.c b/board/lazor/usbc_config.c index 9b9504a44a..6d4351ab64 100644 --- a/board/lazor/usbc_config.c +++ b/board/lazor/usbc_config.c @@ -384,8 +384,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/madoo/board.c b/board/madoo/board.c index 9f2021cf99..e7294150b0 100644 --- a/board/madoo/board.c +++ b/board/madoo/board.c @@ -315,8 +315,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/magolor/board.c b/board/magolor/board.c index 57f6791ae3..e09eb31abf 100644 --- a/board/magolor/board.c +++ b/board/magolor/board.c @@ -596,8 +596,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/makomo/board.c b/board/makomo/board.c index 09fe5fdd74..dcf7d671b2 100644 --- a/board/makomo/board.c +++ b/board/makomo/board.c @@ -238,8 +238,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/marzipan/board.c b/board/marzipan/board.c index 94b7c444d5..18a02799cc 100644 --- a/board/marzipan/board.c +++ b/board/marzipan/board.c @@ -639,8 +639,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c index 23135108f6..b51f6be876 100644 --- a/board/mchpevb1/board.c +++ b/board/mchpevb1/board.c @@ -602,8 +602,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } #endif diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h index 10208ca736..ae8982f939 100644 --- a/board/mchpevb1/board.h +++ b/board/mchpevb1/board.h @@ -151,6 +151,7 @@ /* #define CONFIG_CHARGER_ISL9237 */ /* #define CONFIG_CHARGER_ILIM_PIN_DISABLED */ /* #define CONFIG_CHARGER_INPUT_CURRENT 512 */ +/* #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 */ /* #define CONFIG_CHARGER_NARROW_VDC */ /* #define CONFIG_CHARGER_PROFILE_OVERRIDE */ diff --git a/board/metaknight/board.c b/board/metaknight/board.c index f075f58ee4..b142740c1e 100644 --- a/board/metaknight/board.c +++ b/board/metaknight/board.c @@ -399,8 +399,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/mithrax/charger_isl9241.c b/board/mithrax/charger_isl9241.c index 88f5b85a41..8edcb00e31 100644 --- a/board/mithrax/charger_isl9241.c +++ b/board/mithrax/charger_isl9241.c @@ -83,6 +83,5 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/mrbland/board.c b/board/mrbland/board.c index 04fef6ec82..9b42b15e23 100644 --- a/board/mrbland/board.c +++ b/board/mrbland/board.c @@ -598,8 +598,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/munna/board.c b/board/munna/board.c index 408a81d47d..76445f4bd3 100644 --- a/board/munna/board.c +++ b/board/munna/board.c @@ -239,8 +239,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/nami/board.c b/board/nami/board.c index 02fb27a283..b02b33fdd8 100644 --- a/board/nami/board.c +++ b/board/nami/board.c @@ -760,8 +760,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, (model == MODEL_EKKO || model == MODEL_BARD)) factor = 95; charge_ma = charge_ma * factor / 100; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_hibernate(void) diff --git a/board/nami/board.h b/board/nami/board.h index 51cde41acb..1a71e83c4f 100644 --- a/board/nami/board.h +++ b/board/nami/board.h @@ -97,6 +97,7 @@ #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 27000 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000 /* AP's thresholds. */ diff --git a/board/nautilus/board.c b/board/nautilus/board.c index 36b79aa0c7..2f69158b9f 100644 --- a/board/nautilus/board.c +++ b/board/nautilus/board.c @@ -538,8 +538,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /** diff --git a/board/nautilus/board.h b/board/nautilus/board.h index f40b2f00b5..882b5d74f4 100644 --- a/board/nautilus/board.h +++ b/board/nautilus/board.h @@ -80,6 +80,7 @@ #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/board/nocturne/board.c b/board/nocturne/board.c index dbe5f50b68..13fa259276 100644 --- a/board/nocturne/board.c +++ b/board/nocturne/board.c @@ -763,8 +763,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } static void board_chipset_reset(void) diff --git a/board/nocturne/board.h b/board/nocturne/board.h index 7c38e48ee3..828c9a2087 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -71,6 +71,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 128 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 128 #define CONFIG_CHARGER_ISL9238 /* * Nocturne seems to overdraw its set input current limit by about 5%. diff --git a/board/oak/board.c b/board/oak/board.c index 468b6e6677..3e370c8fa6 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -360,8 +360,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); pd_send_host_event(PD_EVENT_POWER_CHANGE); } diff --git a/board/oak/board.h b/board/oak/board.h index e40e16bccf..ca9e16cf23 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -41,6 +41,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #if BOARD_REV == OAK_REV1 #define CONFIG_CHARGER_BQ24773 diff --git a/board/osiris/charger.c b/board/osiris/charger.c index 88f5b85a41..8edcb00e31 100644 --- a/board/osiris/charger.c +++ b/board/osiris/charger.c @@ -83,6 +83,5 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/pazquel/board.c b/board/pazquel/board.c index 8fdd4a5325..f2d4685154 100644 --- a/board/pazquel/board.c +++ b/board/pazquel/board.c @@ -547,8 +547,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/pico/board.c b/board/pico/board.c index 8dbfcdec12..5326f17283 100644 --- a/board/pico/board.c +++ b/board/pico/board.c @@ -323,8 +323,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/pirika/board.c b/board/pirika/board.c index f7c5c0d19b..bbe6deab48 100644 --- a/board/pirika/board.c +++ b/board/pirika/board.c @@ -494,13 +494,11 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_is_sourcing_vbus(int port) diff --git a/board/pompom/board.c b/board/pompom/board.c index 2f1de29013..e922244721 100644 --- a/board/pompom/board.c +++ b/board/pompom/board.c @@ -450,8 +450,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/poppy/board.c b/board/poppy/board.c index 38183c0da0..c870bffb4f 100644 --- a/board/poppy/board.c +++ b/board/poppy/board.c @@ -58,9 +58,6 @@ #define USB_PD_PORT_ANX74XX 0 -/* Minimum input current limit. */ -#define ILIM_MIN_MA 472 - static void tcpc_alert_event(enum gpio_signal signal) { if ((signal == GPIO_USB_C0_PD_INT_ODL) && @@ -688,7 +685,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (charge_mv > 5000) charge_ma -= 52; - charge_set_input_current_limit(MAX(charge_ma, ILIM_MIN_MA), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_hibernate(void) diff --git a/board/poppy/board.h b/board/poppy/board.h index b55dc1d818..c06f96c438 100644 --- a/board/poppy/board.h +++ b/board/poppy/board.h @@ -90,6 +90,7 @@ #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 472 #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/board/primus/board.c b/board/primus/board.c index 8b5f1a86fc..3f438cee00 100644 --- a/board/primus/board.c +++ b/board/primus/board.c @@ -137,8 +137,7 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma, else charge_ma = charge_ma * 93 / 100; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } static void configure_input_current_limit(void) @@ -159,9 +158,7 @@ static void configure_input_current_limit(void) else adapter_current_ma = adapter_current_ma * 97 / 100; - charge_set_input_current_limit(MAX(adapter_current_ma, - CONFIG_CHARGER_INPUT_CURRENT), - adapter_current_mv); + charge_set_input_current_limit(adapter_current_ma, adapter_current_mv); } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, configure_input_current_limit, HOOK_PRIO_DEFAULT); diff --git a/board/quackingstick/board.c b/board/quackingstick/board.c index 8985254a23..2ccdc1c097 100644 --- a/board/quackingstick/board.c +++ b/board/quackingstick/board.c @@ -625,8 +625,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /** diff --git a/board/rammus/board.c b/board/rammus/board.c index 3696733047..be1f3d9110 100644 --- a/board/rammus/board.c +++ b/board/rammus/board.c @@ -569,8 +569,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void board_hibernate(void) diff --git a/board/rammus/board.h b/board/rammus/board.h index 83f0f35c57..2de783e247 100644 --- a/board/rammus/board.h +++ b/board/rammus/board.h @@ -85,6 +85,7 @@ #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/board/redrix/charger.c b/board/redrix/charger.c index a4fa209246..4f52a06d7e 100644 --- a/board/redrix/charger.c +++ b/board/redrix/charger.c @@ -85,6 +85,5 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/reef/board.c b/board/reef/board.c index b3732f6be9..4ee0f75b25 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -555,8 +555,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /** diff --git a/board/reef/board.h b/board/reef/board.h index bce20f4645..16f40c2f4a 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -51,6 +51,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000 diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c index 6196f1967a..54a0995e85 100644 --- a/board/reef_it8320/board.c +++ b/board/reef_it8320/board.c @@ -311,8 +311,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /** diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h index fc1ca0079d..558b10152a 100644 --- a/board/reef_it8320/board.h +++ b/board/reef_it8320/board.h @@ -49,6 +49,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000 diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c index 67cbfa5aa9..55b5ab25c7 100644 --- a/board/reef_mchp/board.c +++ b/board/reef_mchp/board.c @@ -748,8 +748,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, if (bd9995x_bc12_enable_charging(port, bc12_enable)) return; - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } /** diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h index 3cc3d2b77f..d570f50142 100644 --- a/board/reef_mchp/board.h +++ b/board/reef_mchp/board.h @@ -54,6 +54,7 @@ #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000 diff --git a/board/sasuke/board.c b/board/sasuke/board.c index 567dc8cee7..07dd0ddb79 100644 --- a/board/sasuke/board.c +++ b/board/sasuke/board.c @@ -398,8 +398,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/sasukette/board.c b/board/sasukette/board.c index 019df9348a..9d7e0470ff 100644 --- a/board/sasukette/board.c +++ b/board/sasukette/board.c @@ -254,8 +254,7 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_is_sourcing_vbus(int port) diff --git a/board/scarlet/board.c b/board/scarlet/board.c index 34e5cc456c..b423e5f79a 100644 --- a/board/scarlet/board.c +++ b/board/scarlet/board.c @@ -215,8 +215,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int extpower_is_present(void) diff --git a/board/scarlet/board.h b/board/scarlet/board.h index 0f96e0208a..aba5819516 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -70,6 +70,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_RT9467 #define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000 #define CONFIG_CHARGER_PROFILE_OVERRIDE diff --git a/board/stern/board.c b/board/stern/board.c index 41f63d40a4..ec3c7e66d5 100644 --- a/board/stern/board.c +++ b/board/stern/board.c @@ -239,8 +239,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/storo/board.c b/board/storo/board.c index e4f2ad2fb9..65fa6c917f 100644 --- a/board/storo/board.c +++ b/board/storo/board.c @@ -434,8 +434,7 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_is_sourcing_vbus(int port) diff --git a/board/taeko/charger.c b/board/taeko/charger.c index 29211bc033..6b45881b99 100644 --- a/board/taeko/charger.c +++ b/board/taeko/charger.c @@ -85,6 +85,5 @@ int board_set_active_charge_port(int port) __override void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/taniks/charger.c b/board/taniks/charger.c index b1a29c725b..937a48590c 100644 --- a/board/taniks/charger.c +++ b/board/taniks/charger.c @@ -85,6 +85,5 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/trogdor/usbc_config.c b/board/trogdor/usbc_config.c index 34c37edf1a..7abe04651b 100644 --- a/board/trogdor/usbc_config.c +++ b/board/trogdor/usbc_config.c @@ -347,8 +347,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/board/vell/charger.c b/board/vell/charger.c index a153d57704..757f545d80 100644 --- a/board/vell/charger.c +++ b/board/vell/charger.c @@ -84,8 +84,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } static void set_ac_prochot(void) diff --git a/board/vilboz/board.c b/board/vilboz/board.c index fe0b8ee32e..dbbe3a64ca 100644 --- a/board/vilboz/board.c +++ b/board/vilboz/board.c @@ -508,6 +508,5 @@ const int usb_port_enable[USBA_PORT_COUNT] = { __override void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/volmar/charger.c b/board/volmar/charger.c index 88f5b85a41..8edcb00e31 100644 --- a/board/volmar/charger.c +++ b/board/volmar/charger.c @@ -83,6 +83,5 @@ int board_set_active_charge_port(int port) __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/board/waddledee/board.c b/board/waddledee/board.c index d7abda740c..ab71aa0680 100644 --- a/board/waddledee/board.c +++ b/board/waddledee/board.c @@ -345,13 +345,11 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_set_active_charge_port(int port) diff --git a/board/waddledoo/board.c b/board/waddledoo/board.c index e71151f6b5..8658397d9d 100644 --- a/board/waddledoo/board.c +++ b/board/waddledoo/board.c @@ -393,8 +393,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/waddledoo2/board.c b/board/waddledoo2/board.c index b1417d8ee2..6f8a48abe6 100644 --- a/board/waddledoo2/board.c +++ b/board/waddledoo2/board.c @@ -400,8 +400,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) diff --git a/board/wheelie/board.c b/board/wheelie/board.c index 9708dcca82..922d6cde52 100644 --- a/board/wheelie/board.c +++ b/board/wheelie/board.c @@ -232,13 +232,11 @@ uint16_t tcpc_get_alert_status(void) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - /* * TODO(b/151955431): Characterize the input current limit in case a * scaling needs to be applied here */ - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_set_active_charge_port(int port) diff --git a/board/willow/board.c b/board/willow/board.c index 3bd5c4633b..370b79e4c8 100644 --- a/board/willow/board.c +++ b/board/willow/board.c @@ -237,8 +237,7 @@ int board_set_active_charge_port(int charge_port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int board_discharge_on_ac(int enable) diff --git a/board/wormdingler/board.c b/board/wormdingler/board.c index 8705e0d2cb..8a106ca965 100644 --- a/board/wormdingler/board.c +++ b/board/wormdingler/board.c @@ -643,8 +643,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/common/charge_manager.c b/common/charge_manager.c index b28a186ef8..c67656b122 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -835,8 +835,12 @@ static void charge_manager_refresh(void) override_port = OVERRIDE_OFF; if (new_supplier == CHARGE_SUPPLIER_NONE) { +#ifdef CONFIG_CHARGER_INPUT_CURRENT + new_charge_current = CONFIG_CHARGER_INPUT_CURRENT; +#else new_charge_current = 0; - new_charge_current_uncapped = 0; +#endif + new_charge_current_uncapped = new_charge_current; new_charge_voltage = 0; } else { new_charge_current_uncapped = diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 6967cf5333..1e1353a639 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -2336,6 +2336,11 @@ int charge_set_input_current_limit(int ma, int mv) 100; } #endif +#ifdef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT + if (CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT > 0) { + ma = MAX(ma, CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT); + } +#endif if (IS_ENABLED(CONFIG_OCPC)) chgnum = charge_get_active_chg_chip(); diff --git a/docs/low_battery_startup.md b/docs/low_battery_startup.md index 48f9c28f49..83aae054b5 100644 --- a/docs/low_battery_startup.md +++ b/docs/low_battery_startup.md @@ -77,8 +77,7 @@ analog signaling alone. Via digital communication in the PD protocol, much higher power states may be negotiated. However, higher power states also usually run at a higher voltage state as well. Any time the voltage level is changing, the power sink (the ChromeOS device) must lower its power consumption during the -transient. The standby current level is governed by -`CONFIG_CHARGER_INPUT_CURRENT`. +transient. PD port partners are capable of both soft and hard resets. Hard resets will cause a dead-bus state for a brief interval before PD can renegotiate, from @@ -341,13 +340,23 @@ Example configuration: Required. -The lowest current limit programmed into the charger. This determines both the -default level used on startup, and the value used during the voltage transients -in PD negotiation. +The default charger current limit used on startup and for inactive ports. It +should not be higher than 512 mA unless the device ships with a discrete power +supply. Raising this term above 512 mA is contrary to USB-PD. It may be lowered +in order to improve compatibility with marginal BC1.2 chargers. -It should not be higher than 512 mA unless the device ships with a discrete -power supply. Raising this term above 512 mA is contrary to USB-PD. It may be -lowered in order to improve compatibility with marginal BC1.2 chargers. +### `CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT` + +Optional. + +If set, charger input current limits will never be set lower than this value. +Historically most boards used the same value as `CONFIG_CHARGER_INPUT_CURRENT`, +but doing so violates USB-PD standby power requirements when voltages greater +than 5V are used with the default 512 mA value. Configuring this option to a +nonzero value may be useful if a board needs extra headroom (possibly at the +cost of drawing excess standby power), but boards should prefer to +override `board_set_charge_limit()` instead to limit situations with excess +power draw to only occur when that extra power is needed. ### `CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON` diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h index 5f886257d3..c7a5cbc995 100644 --- a/include/charge_state_v2.h +++ b/include/charge_state_v2.h @@ -72,7 +72,8 @@ int charge_set_output_current_limit(int chgnum, int ma, int mv); * time AC is applied. * * The input current limit is automatically derated by - * CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT, if configured. + * CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT (if configured), and is clamped to + * no less than CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT mA (if configured). * * @param ma New input current limit in mA * @param mv Negotiated charge voltage in mV. diff --git a/include/config.h b/include/config.h index 74ac859dc3..a9a346c464 100644 --- a/include/config.h +++ b/include/config.h @@ -1033,8 +1033,7 @@ #undef CONFIG_CHARGER_ILIM_PIN_DISABLED /* - * Default input current for the board, in mA. Many boards also use this as the - * least maximum input current during transients. + * Default input current for the board, in mA. * * This value should depend on external power adapter, designed charging * voltage, and the maximum power of the running system. For type-C chargers, @@ -1043,6 +1042,22 @@ */ #undef CONFIG_CHARGER_INPUT_CURRENT +/* + * Minimum current limit that will ever be set for chargers, even if a lower + * limit is requested. This will allow the charger to draw more power than + * the requested limit. + * + * If set, this should usually be set to no more than 2.5W divided by the + * maximum supported input voltage in order to satisfy USB-PD pSnkStdby + * requirements. Higher values may help devices stay alive under low-battery + * conditions at the cost of violating standby power limits. + * + * Many boards set this to large values, since historically this number was + * usually equal to CONFIG_CHARGER_INPUT_CURRENT. New boards should avoid doing + * so if possible. + */ +#undef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT + /* * Percentage derating factor applied to charger input current limits. * diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc index 5350c1cbbf..7f65419a4b 100644 --- a/zephyr/Kconfig.usbc +++ b/zephyr/Kconfig.usbc @@ -44,6 +44,26 @@ config PLATFORM_EC_CHARGER_INPUT_CURRENT chargers, this should be set to 512 mA in order to not brown-out low-current USB charge ports in accordance with USB-PD r3.0 Sec. 7.3 +config PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT + int "Minimum charger input current limit in mA" + default 0 + depends on PLATFORM_EC_CHARGE_MANAGER + help + Minimum current limit in mA that will ever be set for chargers, even if a + lower limit is requested. + + If set, this should usually be set to no more than 2.5W divided by the + maximum supported input voltage in order to satisfy USB-PD pSnkStdby + requirements. Higher values may help devices stay alive under low-battery + conditions at the cost of violating standby power limits. + + Many boards set this to large values, since historically this number was + usually equal to the default current limit. New boards should avoid doing + so if possible, and usually leave this unset: customization of + board_set_charge_limit() should be considered instead if a device sometimes + requires amounts of power in violation of specs, to limit those violations + only to situations where they are necessary. + config PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT int "Charger input current derating percentage" default 0 diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index e9d35dc0e2..0d248c6487 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -105,6 +105,7 @@ CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70 CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=3 CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC=1 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index 60b78f6758..d97919cce1 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -70,6 +70,7 @@ CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=12500 +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y CONFIG_PLATFORM_EC_CHARGER_PSYS=y CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y diff --git a/zephyr/program/herobrine/src/usbc_config.c b/zephyr/program/herobrine/src/usbc_config.c index e757e3f2e1..95301120d8 100644 --- a/zephyr/program/herobrine/src/usbc_config.c +++ b/zephyr/program/herobrine/src/usbc_config.c @@ -262,8 +262,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/zephyr/program/intelrvp/prj.conf b/zephyr/program/intelrvp/prj.conf index 890122f510..9ca19c5071 100644 --- a/zephyr/program/intelrvp/prj.conf +++ b/zephyr/program/intelrvp/prj.conf @@ -20,6 +20,7 @@ CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001 +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 #Power Sequencing CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y diff --git a/zephyr/program/intelrvp/src/chg_usb_pd.c b/zephyr/program/intelrvp/src/chg_usb_pd.c index 63a1853b4d..81a44238e4 100644 --- a/zephyr/program/intelrvp/src/chg_usb_pd.c +++ b/zephyr/program/intelrvp/src/chg_usb_pd.c @@ -124,6 +124,5 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index 8fd87c94b5..b445c60b6f 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -129,6 +129,7 @@ CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS=200 # Assume 4% overdraw, which could be changed with actual characterization CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=4 +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 # Reduce logging so that state transitions do not cause protocol issues # pd dump [1-3] can be used to increase the debugging level diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c index bfcbabcbaa..3600005ae1 100644 --- a/zephyr/program/nissa/src/common.c +++ b/zephyr/program/nissa/src/common.c @@ -83,8 +83,7 @@ DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_INIT_I2C); __overridable void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT); - charge_set_input_current_limit(icl, charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } int pd_check_vconn_swap(int port) diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index e5900afd54..8b99cc373c 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -77,6 +77,7 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=30000 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000 +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 # USBC CONFIG_PLATFORM_EC_USBC_PPC=y diff --git a/zephyr/program/rex/src/usbc_config.c b/zephyr/program/rex/src/usbc_config.c index 6f09887eed..ed51be6160 100644 --- a/zephyr/program/rex/src/usbc_config.c +++ b/zephyr/program/rex/src/usbc_config.c @@ -195,8 +195,7 @@ void bc12_interrupt(enum gpio_signal signal) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } static void board_disable_charger_ports(void) diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 951926f537..4d0ed48e6f 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -70,6 +70,7 @@ CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y # Charger CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512 +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 CONFIG_PLATFORM_EC_CHARGER_ISL9241=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 diff --git a/zephyr/program/skyrim/src/usbc_config.c b/zephyr/program/skyrim/src/usbc_config.c index 1b728f1cf0..eaa327ff4e 100644 --- a/zephyr/program/skyrim/src/usbc_config.c +++ b/zephyr/program/skyrim/src/usbc_config.c @@ -193,8 +193,7 @@ int board_set_active_charge_port(int port) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } void sbu_fault_interrupt(enum gpio_signal signal) diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index d8cf4009ea..5f29c3f5c2 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -73,6 +73,7 @@ CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=10000 +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y CONFIG_PLATFORM_EC_CHARGER_PSYS=y CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y diff --git a/zephyr/program/trogdor/lazor/src/usbc_config.c b/zephyr/program/trogdor/lazor/src/usbc_config.c index 9639b556a0..c3860dc005 100644 --- a/zephyr/program/trogdor/lazor/src/usbc_config.c +++ b/zephyr/program/trogdor/lazor/src/usbc_config.c @@ -314,8 +314,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, charge_ma = max_ma; } - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } uint16_t tcpc_get_alert_status(void) diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index b0c0aa2a47..c0d388b60b 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1083,6 +1083,12 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; #define CONFIG_CHARGER_INPUT_CURRENT CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT #endif +#undef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT +#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT +#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT \ + CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT +#endif + #undef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT #ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT \ diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c index 5d143dcbdb..a384fb1e0a 100644 --- a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c +++ b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c @@ -73,7 +73,9 @@ static const struct bc12_status bc12_chg_limits[] = { [CHG_1_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY, .current_limit = 1000 }, [CHG_RESERVED] = { .supplier = CHARGE_SUPPLIER_NONE, - .current_limit = 0 }, + /* Not charging, limit is set to default */ + .current_limit = + CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT }, [CHG_CDP] = { .supplier = CHARGE_SUPPLIER_BC12_CDP, .current_limit = USB_CHARGER_MAX_CURR_MA }, [CHG_SDP] = { .supplier = CHARGE_SUPPLIER_BC12_SDP, @@ -209,7 +211,8 @@ test_bc12_pi3usb9201_client_mode(enum pi3usb9201_client_sts detect_result, NULL); zassert_equal(charge_manager_get_supplier(), CHARGE_SUPPLIER_NONE, NULL); - zassert_equal(charge_manager_get_charger_current(), 0); + zassert_equal(charge_manager_get_charger_current(), + CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT); zassert_equal(charge_manager_get_charger_voltage(), 0); } @@ -258,6 +261,7 @@ ZTEST_USER(bc12, test_bc12_pi3usb9201) test_bc12_pi3usb9201_host_mode(); for (int c = CHG_OTHER; c <= CHG_DCP; c++) { + LOG_INF("Test client mode supplier %d", c); test_bc12_pi3usb9201_client_mode( c, bc12_chg_limits[c].supplier, bc12_chg_limits[c].current_limit); diff --git a/zephyr/test/drivers/common/src/stubs.c b/zephyr/test/drivers/common/src/stubs.c index 3cddc5cdfe..2f8ec7a43f 100644 --- a/zephyr/test/drivers/common/src/stubs.c +++ b/zephyr/test/drivers/common/src/stubs.c @@ -101,8 +101,7 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, int charge_mv) { - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); + charge_set_input_current_limit(charge_ma, charge_mv); } BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT); diff --git a/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c index e1c602e86d..9dfeb5e734 100644 --- a/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c +++ b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c @@ -114,3 +114,16 @@ ZTEST(charge_state_v2, test_current_limit_derating) CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT, charger_current_limit); } + +ZTEST(charge_state_v2, test_minimum_current_limit) +{ + int charger_current_limit; + + charge_set_input_current_limit(50, 5000); + zassert_ok(charger_get_input_current_limit(0, &charger_current_limit)); + zassert_equal(charger_current_limit, 96, + "Minimum input current limit should be %d mA," + " but current limit is %d (capped to %d)", + 96, charger_current_limit, + CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT); +} diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index db341b3048..59456ac5f0 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -63,6 +63,7 @@ tests: drivers.common_charger: extra_configs: - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=5 + - CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=100 - CONFIG_LINK_TEST_SUITE_COMMON_CHARGER=y # Set to focus testing for Herobrine # Config is y only in nissa -- cgit v1.2.1 From 3440d8c818b74b35c3a7bb78f9af775f59625d69 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 12:48:02 -0700 Subject: cq: Build extra/rma_reset in CQ The ebuild chromeos-base/ec-utils-test depends on extra/rma_reset but the EC CQ doesn't build it. Add make commands to CQ script to build extra/rma_reset. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis Change-Id: I540593056de9fdbea231eefa7dab27b4ad8d5f09 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049882 Tested-by: Jeremy Bettis Reviewed-by: Jack Rosenthal Auto-Submit: Jeremy Bettis Commit-Queue: Jack Rosenthal Code-Coverage: Zoss --- firmware_builder.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/firmware_builder.py b/firmware_builder.py index ff7f524d78..06bf9beec6 100755 --- a/firmware_builder.py +++ b/firmware_builder.py @@ -82,6 +82,15 @@ def build(opts): print(f"# Running {' '.join(cmd)}.") subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) + # extra/rma_reset is used in chromeos-base/ec-utils-test + cmd = ["make", "-C", "extra/rma_reset", "clean"] + print(f"# Running {' '.join(cmd)}.") + subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) + + cmd = ["make", "-C", "extra/rma_reset", f"-j{opts.cpus}"] + print(f"# Running {' '.join(cmd)}.") + subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True) + ec_dir = os.path.dirname(__file__) build_dir = os.path.join(ec_dir, "build") for build_target in sorted(os.listdir(build_dir)): -- cgit v1.2.1 From c5d3eb4a6bd65eb78fe01ebddadac73b2cab3233 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Tue, 22 Nov 2022 17:02:06 +1100 Subject: dps: improve option documentation DPS can behave badly (and is likely to do so) if the configuration doesn't match actual system characteristics. Existing platforms using DPS seems to all use the same configuration (possibly because they use the same charger), but the need for correct configuration could be made clearer. This rewords the kconfig help for DPS enablement to better describe what it will do, and what is necessary for a platform to make it work well. BUG=b:259859051 TEST=zmake build -a BRANCH=none Signed-off-by: Peter Marheine Change-Id: I481be89d8a00b90e15d01a5c7c8eedbbf057589e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4044793 Reviewed-by: Edward Hill Code-Coverage: Zoss --- zephyr/Kconfig.pd | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/zephyr/Kconfig.pd b/zephyr/Kconfig.pd index 1b104382ad..c84c57d3c0 100644 --- a/zephyr/Kconfig.pd +++ b/zephyr/Kconfig.pd @@ -161,11 +161,15 @@ menuconfig PLATFORM_EC_USB_PD_DPS default n select HAS_TASK_DPS help - Enable this if the board needs dynamic PDO selection. - DPS picks a power efficient PDO regarding to the underlying battery - configuration and the system loading. - Default configuration can be overridden by `dps_config` to adapt - to each board's need. + Enable this to permit dynamic PDO selection (DPS). DPS can select different + USB PDOs depending on system load and battery configuration to select input + characteristics (particularly voltage) that allow the system to operate more + efficiently. + + This should not be enabled without evaluating charger efficiency against + input voltage and overriding `dps_config` as necessary to accurately reflect + actual platform behavior: untuned behavior is likely to be worse than + leaving DPS disabled. config PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE bool "Board can use TCPC-controlled DRP toggle" -- cgit v1.2.1 From 75beb51819aa90f110ff32a1bef54b97205a7c9a Mon Sep 17 00:00:00 2001 From: Bernardo Perez Priego Date: Mon, 21 Nov 2022 18:29:11 -0800 Subject: zephyr: mtlrvp: Add DC jack present GPIO interrupt When DC jack is providing power, it takes higher supplier priority and inhibits system from charging using any other Type-C port. This CL will enable detecting DC jack connection during run time and not only initialization time. BUG=None BRANCH=None TEST=Boot MTL RVP with DC jack connected Disconnect DC jack Connect Type-C charger Type-C should charge MTL RVP Signed-off-by: Bernardo Perez Priego Change-Id: I13b292658bbcc28e11585679f60d5c014d3da302 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045034 Reviewed-by: Abe Levkoy Code-Coverage: Abe Levkoy Commit-Queue: Abe Levkoy --- zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts | 5 +++++ zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts index b120f6c05e..ad928fd593 100644 --- a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts +++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts @@ -56,5 +56,10 @@ flags = ; handler = "board_connect_c0_sbu"; }; + int_dc_jack_present: dc_jack_present { + irq-pin = <&std_adp_prsnt>; + flags = ; + handler = "board_dc_jack_interrupt"; + }; }; }; diff --git a/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c b/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c index d6bd0f85b7..e73995337a 100644 --- a/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c +++ b/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c @@ -275,6 +275,9 @@ static void board_int_init(void) /* Enable CCD Mode interrupt */ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode)); + + /* Enable DC jack interrupt */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_dc_jack_present)); } static int board_pre_task_peripheral_init(const struct device *unused) -- cgit v1.2.1 From 743d81374a2eafc48e2b92851634fe52fae30f10 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Mon, 14 Nov 2022 16:53:47 -0700 Subject: zephyr: test: Test apreset and apshutdown console commands Test the console commands `apreset` and `apshutdown` and confirm a reset/shutdown occurred. BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: I63fccfdc07a940d172c70a8d24500e89004a32f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4027085 Code-Coverage: Zoss Reviewed-by: Abe Levkoy --- zephyr/test/drivers/default/CMakeLists.txt | 5 +++- zephyr/test/drivers/default/src/chipset.c | 42 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt index 8f1c2ddf84..07688db4f2 100644 --- a/zephyr/test/drivers/default/CMakeLists.txt +++ b/zephyr/test/drivers/default/CMakeLists.txt @@ -7,7 +7,6 @@ target_sources(app PRIVATE src/bmi260.c src/charge_manager.c src/charge_state_prevent_power_on.c - src/chipset.c src/console.c src/console_cmd/adc.c src/console_cmd/battery.c @@ -97,3 +96,7 @@ target_sources(app PRIVATE src/vstore.c src/watchdog.c ) + +# This test does not work when power functions are mocked, so only run it for +# the plain `drivers.default` test case. +zephyr_library_sources_ifndef(CONFIG_POWER_SEQUENCE_MOCK src/chipset.c) diff --git a/zephyr/test/drivers/default/src/chipset.c b/zephyr/test/drivers/default/src/chipset.c index fc62135622..89ba761c23 100644 --- a/zephyr/test/drivers/default/src/chipset.c +++ b/zephyr/test/drivers/default/src/chipset.c @@ -4,12 +4,18 @@ */ #include "chipset.h" +#include "console.h" #include "test/drivers/test_state.h" #include +#include +#include #include +#include +#include + ZTEST(chipset, test_get_ap_reset_stats__bad_pointers) { zassert_equal(EC_ERROR_INVAL, get_ap_reset_stats(NULL, 0, NULL)); @@ -48,6 +54,42 @@ ZTEST(chipset, test_get_ap_reset_stats__happy_path) actual_reset_count); } +ZTEST(chipset, test_console_cmd_apreset) +{ + struct ap_reset_log_entry reset_log_entries[4]; + uint32_t reset_count; + + zassert_ok(shell_execute_cmd(get_ec_shell(), "apreset")); + + /* Make sure an AP reset happened. The expected reset log entry is at + * index 3 because we read out 3 empty slots first. + */ + zassert_ok(get_ap_reset_stats(reset_log_entries, + ARRAY_SIZE(reset_log_entries), + &reset_count)); + + zassert_equal(CHIPSET_RESET_CONSOLE_CMD, + reset_log_entries[3].reset_cause); +} + +ZTEST(chipset, test_console_cmd_apshutdown) +{ + struct ap_reset_log_entry reset_log_entries[4]; + uint32_t reset_count; + + zassert_ok(shell_execute_cmd(get_ec_shell(), "apshutdown")); + + /* Make sure an AP reset happened. The expected reset log entry is at + * index 3 because we read out 3 empty slots first. + */ + zassert_ok(get_ap_reset_stats(reset_log_entries, + ARRAY_SIZE(reset_log_entries), + &reset_count)); + + zassert_equal(CHIPSET_SHUTDOWN_CONSOLE_CMD, + reset_log_entries[3].reset_cause); +} + static void reset(void *arg) { ARG_UNUSED(arg); -- cgit v1.2.1 From ae8e704c19e7f1259677c4b8c76ebb78149e7789 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Tue, 22 Nov 2022 11:15:49 +0000 Subject: zephyr: tests, emul: add a bunch of automatic configs Rework various emul drivers to use an automatic Kconfig and drop few explicitly prj.conf entries, plus some that were already redundant from upstream. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I1e81e310248070dc619012f69663d044f329f249 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047461 Reviewed-by: Keith Short Code-Coverage: Zoss --- zephyr/Kconfig.defaults | 3 --- zephyr/emul/Kconfig | 22 ++++++++++++++++++++++ zephyr/emul/tcpc/Kconfig | 6 ++++++ zephyr/test/ap_power/prj.conf | 1 - zephyr/test/drivers/anx7447/prj.conf | 1 - zephyr/test/drivers/prj.conf | 15 --------------- zephyr/test/drivers/rt9490/prj.conf | 1 - zephyr/test/drivers/testcase.yaml | 1 - zephyr/test/ec_app/prj.conf | 1 - zephyr/test/i2c/prj.conf | 1 - zephyr/test/i2c_dts/prj.conf | 1 - zephyr/test/jump_tags/prj.conf | 1 - zephyr/test/krabby/prj.conf | 6 ------ zephyr/test/krabby/testcase.yaml | 1 - zephyr/test/qcom_power/prj.conf | 2 -- zephyr/test/vboot_efs2/prj.conf | 5 ----- 16 files changed, 28 insertions(+), 40 deletions(-) diff --git a/zephyr/Kconfig.defaults b/zephyr/Kconfig.defaults index 6eaa34c727..a7497ca9a4 100644 --- a/zephyr/Kconfig.defaults +++ b/zephyr/Kconfig.defaults @@ -13,9 +13,6 @@ config LOG default y imply LOG_DEFAULT_MINIMAL -config GPIO_EMUL - default y if ARCH_POSIX - config GPIO default y if ARCH_POSIX diff --git a/zephyr/emul/Kconfig b/zephyr/emul/Kconfig index 94bc4ecc0d..5c85f6dc5a 100644 --- a/zephyr/emul/Kconfig +++ b/zephyr/emul/Kconfig @@ -13,12 +13,16 @@ config EMUL_COMMON_I2C config EMUL_SMART_BATTERY bool "Smart Battery emulator" + default y + depends on DT_HAS_ZEPHYR_SMART_BATTERY_ENABLED select EMUL_COMMON_I2C help Enable the Smart Battery emulator. This driver use emulated I2C bus. config EMUL_BMA255 bool "BMA255 emulator" + default y + depends on DT_HAS_ZEPHYR_BMA255_ENABLED select EMUL_COMMON_I2C help Enable the BMA255 emulator. This driver use emulated I2C bus. @@ -34,6 +38,8 @@ config EMUL_BC12_DETECT_PI3USB9201 config EMUL_PPC_SYV682X bool "Silergy SYV682x PPC emulator" + default y + depends on DT_HAS_ZEPHYR_SYV682X_EMUL_ENABLED select PLATFORM_EC_USBC_PPC_SYV682X help Enable the SYV682x emulator. SYV682 is a USB Type-C PPC. This driver @@ -41,6 +47,8 @@ config EMUL_PPC_SYV682X config EMUL_BMI bool "BMI emulator" + default y + depends on DT_HAS_ZEPHYR_BMI_ENABLED select EMUL_COMMON_I2C help Enable the BMI emulator. This driver use emulated I2C bus. @@ -49,6 +57,8 @@ config EMUL_BMI config EMUL_TCS3400 bool "TCS3400 emulator" + default y + depends on DT_HAS_ZEPHYR_TCS3400_ENABLED select EMUL_COMMON_I2C help Enable the TCS3400 light sensor. This driver use emulated I2C bus. @@ -62,6 +72,8 @@ config EMUL_TCS3400 config EMUL_TUSB1064 bool "TCS3400 emulator" + default y + depends on DT_HAS_ZEPHYR_TUSB1064_EMUL_ENABLED select EMUL_COMMON_I2C help Enable the TUSB1064 usb mux. This driver use emulated I2C bus. @@ -78,11 +90,15 @@ config EMUL_BB_RETIMER config EMUL_KB_RAW bool "Raw keyboard emulator" + default y + depends on DT_HAS_CROS_EC_KB_RAW_EMUL_ENABLED help Enable the raw keyboard emulator. config EMUL_CROS_FLASH bool "Emulated flash driver for the Zephyr shim" + default y + depends on DT_HAS_CROS_EC_FLASH_EMUL_ENABLED select PLATFORM_EC_FLASH_CROS imply SYSTEM_FAKE help @@ -90,11 +106,15 @@ config EMUL_CROS_FLASH config EMUL_RTC bool "Emulated RTC driver for Zephyr shim" + default y + depends on DT_HAS_CROS_EC_RTC_EMUL_ENABLED help This options enables the RTC emulator for testing. config EMUL_RT9490 bool "Rt9490 charger emulator" + default y + depends on DT_HAS_ZEPHYR_RT9490_EMUL_ENABLED select EMUL_COMMON_I2C help Enable the RT9490 light sensor emulator. This driver use emulated I2C @@ -102,6 +122,8 @@ config EMUL_RT9490 config PWM_MOCK bool "Mock implementation of an PWM device" + default y + depends on DT_HAS_CROS_PWM_MOCK_ENABLED help Enable the PWM mock. This driver is a pure mock and does nothing by default. diff --git a/zephyr/emul/tcpc/Kconfig b/zephyr/emul/tcpc/Kconfig index 898664e557..6d6c8cba00 100644 --- a/zephyr/emul/tcpc/Kconfig +++ b/zephyr/emul/tcpc/Kconfig @@ -4,6 +4,8 @@ menuconfig EMUL_TCPCI bool "TCPCI common functionality" + default y + depends on DT_HAS_CROS_TCPCI_GENERIC_EMUL_ENABLED depends on I2C_EMUL help Enable the TCPCI emulator. This driver uses the emulated I2C bus. @@ -21,6 +23,8 @@ source "subsys/logging/Kconfig.template.log_config" config EMUL_ANX7447 bool "Analogix ANX7447 emulator" + default y + depends on DT_HAS_CROS_ANX7447_EMUL_ENABLED help Enable emulator for ANX7447 of TCPM. This emulator is extension for TCPCI emulator. ANX7447 specific API is available in @@ -36,6 +40,8 @@ config EMUL_TCPCI_PARTNER_COMMON config EMUL_PS8XXX bool "Parade PS8XXX emulator" + default y + depends on DT_HAS_CROS_PS8XXX_EMUL_ENABLED help Enable emulator for PS8XXX family of TCPC. This emulator is extenstion for TCPCI emulator. PS8XXX specific API is available in diff --git a/zephyr/test/ap_power/prj.conf b/zephyr/test/ap_power/prj.conf index 2d7e478e29..53c6accdd3 100644 --- a/zephyr/test/ap_power/prj.conf +++ b/zephyr/test/ap_power/prj.conf @@ -36,7 +36,6 @@ CONFIG_CROS_EC=y CONFIG_SHIMMED_TASKS=y CONFIG_EMUL=y CONFIG_GPIO=y -CONFIG_GPIO_EMUL=y CONFIG_HEAP_MEM_POOL_SIZE=1024 CONFIG_AP_PWRSEQ=y diff --git a/zephyr/test/drivers/anx7447/prj.conf b/zephyr/test/drivers/anx7447/prj.conf index d297ee0725..18d953d0c6 100644 --- a/zephyr/test/drivers/anx7447/prj.conf +++ b/zephyr/test/drivers/anx7447/prj.conf @@ -2,6 +2,5 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -CONFIG_EMUL_ANX7447=y CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 8b113777b2..49382d65d4 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -44,24 +44,13 @@ CONFIG_PLATFORM_EC=y CONFIG_CROS_EC=y CONFIG_SHIMMED_TASKS=y CONFIG_EMUL=y -CONFIG_I2C_EMUL=y CONFIG_GPIO=y -CONFIG_GPIO_EMUL=y CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY=49 CONFIG_EEPROM=y CONFIG_EEPROM_SIMULATOR=n CONFIG_EMUL_EEPROM_AT2X=y -CONFIG_EMUL_SMART_BATTERY=y CONFIG_EMUL_BC12_DETECT_PI3USB9201=y -CONFIG_EMUL_PPC_SYV682X=y -CONFIG_ADC_EMUL=y -CONFIG_EMUL_BMA255=y -CONFIG_EMUL_BMI=y -CONFIG_EMUL_TCS3400=y CONFIG_EMUL_BB_RETIMER=y -CONFIG_EMUL_TCPCI=y -CONFIG_EMUL_PS8XXX=y -CONFIG_EMUL_RTC=y CONFIG_EMUL_TCPCI_PARTNER_DRP=y CONFIG_EMUL_TCPCI_PARTNER_FAULTY_EXT=y CONFIG_EMUL_PCT2075=y @@ -163,9 +152,7 @@ CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y CONFIG_PLATFORM_EC_MKBP_EVENT=y CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_EMUL_KB_RAW=y CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y -CONFIG_EMUL_CROS_FLASH=y CONFIG_FLASH_SIMULATOR=y CONFIG_FLASH=y CONFIG_PLATFORM_EC_VBOOT_HASH=y @@ -187,5 +174,3 @@ CONFIG_PLATFORM_EC_TABLET_MODE=y # Power Management (Herobrine arch enables this) CONFIG_PM=y - -CONFIG_PWM_MOCK=y diff --git a/zephyr/test/drivers/rt9490/prj.conf b/zephyr/test/drivers/rt9490/prj.conf index 4ee5b96518..1d1b6c4c71 100644 --- a/zephyr/test/drivers/rt9490/prj.conf +++ b/zephyr/test/drivers/rt9490/prj.conf @@ -2,7 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -CONFIG_EMUL_RT9490=y CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n CONFIG_PLATFORM_EC_CHARGER_OTG=y CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 59456ac5f0..2dc85d4afd 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -154,7 +154,6 @@ tests: - CONFIG_PLATFORM_EC_RTC=y - CONFIG_PLATFORM_EC_HOSTCMD=y - CONFIG_PLATFORM_EC_HOSTCMD_RTC=y - - CONFIG_EMUL_RTC=y drivers.system: tags: common diff --git a/zephyr/test/ec_app/prj.conf b/zephyr/test/ec_app/prj.conf index 3b44c56b6b..502f5bbdc6 100644 --- a/zephyr/test/ec_app/prj.conf +++ b/zephyr/test/ec_app/prj.conf @@ -13,7 +13,6 @@ CONFIG_SHELL_BACKEND_SERIAL=n CONFIG_SERIAL=y CONFIG_RING_BUFFER=y -CONFIG_EMUL_CROS_FLASH=y CONFIG_PLATFORM_EC_VBOOT_EFS2=y CONFIG_PLATFORM_EC_VBOOT_HASH=y CONFIG_PLATFORM_EC_HOSTCMD=y diff --git a/zephyr/test/i2c/prj.conf b/zephyr/test/i2c/prj.conf index 8c2a8fed3d..fbf4b53cc3 100644 --- a/zephyr/test/i2c/prj.conf +++ b/zephyr/test/i2c/prj.conf @@ -6,7 +6,6 @@ CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y CONFIG_EMUL=y -CONFIG_I2C_EMUL=y CONFIG_BMI160=y CONFIG_EMUL_BMI160=y CONFIG_SENSOR=y diff --git a/zephyr/test/i2c_dts/prj.conf b/zephyr/test/i2c_dts/prj.conf index 8449e32d32..75a6e70ff7 100644 --- a/zephyr/test/i2c_dts/prj.conf +++ b/zephyr/test/i2c_dts/prj.conf @@ -6,7 +6,6 @@ CONFIG_ZTEST=y CONFIG_ZTEST_NEW_API=y CONFIG_EMUL=y -CONFIG_I2C_EMUL=y CONFIG_BMI160=y CONFIG_EMUL_BMI160=y CONFIG_SENSOR=y diff --git a/zephyr/test/jump_tags/prj.conf b/zephyr/test/jump_tags/prj.conf index 9a2a537b89..4e39830c0a 100644 --- a/zephyr/test/jump_tags/prj.conf +++ b/zephyr/test/jump_tags/prj.conf @@ -3,7 +3,6 @@ # found in the LICENSE file. CONFIG_CROS_EC=y -CONFIG_EMUL_CROS_FLASH=y CONFIG_FLASH=y CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGEN=n CONFIG_PLATFORM_EC=y diff --git a/zephyr/test/krabby/prj.conf b/zephyr/test/krabby/prj.conf index c5af7e2cec..2f2a03923b 100644 --- a/zephyr/test/krabby/prj.conf +++ b/zephyr/test/krabby/prj.conf @@ -10,11 +10,6 @@ CONFIG_ASSERT=y CONFIG_ADC=y CONFIG_CROS_EC=y CONFIG_EMUL=y -CONFIG_EMUL_RT9490=y -CONFIG_EMUL_SMART_BATTERY=y -CONFIG_EMUL_TCPCI=y -CONFIG_EMUL_TUSB1064=y -CONFIG_I2C_EMUL=y CONFIG_PLATFORM_EC=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n @@ -41,5 +36,4 @@ CONFIG_PLATFORM_EC_USB_POWER_DELIVERY=y CONFIG_PLATFORM_EC_VBOOT_HASH=n CONFIG_PLATFORM_EC_USBC_PPC=y -CONFIG_EMUL_PPC_SYV682X=y CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y diff --git a/zephyr/test/krabby/testcase.yaml b/zephyr/test/krabby/testcase.yaml index 54a8ce59d4..781d82db4b 100644 --- a/zephyr/test/krabby/testcase.yaml +++ b/zephyr/test/krabby/testcase.yaml @@ -15,4 +15,3 @@ tests: extra_configs: - CONFIG_TEST_TENTACRUEL=y - CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y - - CONFIG_ADC_EMUL=y diff --git a/zephyr/test/qcom_power/prj.conf b/zephyr/test/qcom_power/prj.conf index 11aa3e6fb3..2a160bd7da 100644 --- a/zephyr/test/qcom_power/prj.conf +++ b/zephyr/test/qcom_power/prj.conf @@ -14,10 +14,8 @@ CONFIG_NATIVE_UART_0_ON_STDINOUT=y CONFIG_CROS_EC=y CONFIG_EMUL=y -CONFIG_EMUL_CROS_FLASH=y CONFIG_FLASH=y CONFIG_GPIO=y -CONFIG_GPIO_EMUL=y CONFIG_GPIO_GET_CONFIG=y CONFIG_PLATFORM_EC=y CONFIG_RING_BUFFER=y diff --git a/zephyr/test/vboot_efs2/prj.conf b/zephyr/test/vboot_efs2/prj.conf index 45d18428bd..9f1eb37972 100644 --- a/zephyr/test/vboot_efs2/prj.conf +++ b/zephyr/test/vboot_efs2/prj.conf @@ -2,14 +2,9 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -CONFIG_ADC_EMUL=y CONFIG_CROS_EC=y CONFIG_EMUL_BC12_DETECT_PI3USB9201=y -CONFIG_EMUL_CROS_FLASH=y -CONFIG_EMUL_SMART_BATTERY=y -CONFIG_EMUL_TCPCI=y CONFIG_FLASH=y -CONFIG_I2C_EMUL=y CONFIG_PLATFORM_EC=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -- cgit v1.2.1 From 057c0257d6ed34a13bd2224796383db79169072d Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Wed, 23 Nov 2022 15:19:08 +0000 Subject: zephyr: usb: enable pi3usb9201 driver and emulator automatically Enable the PLATFORM_EC_BC12_DETECT_PI3USB9201 and EMUL_BC12_DETECT_PI3USB9201 based on the devicetree configuration. The two drivers use the same compatible so the emulator one is set so it can only be enabled in testing. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Id4438d2af72c46ecf5c47c2d347dfb8bb74a0a57 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4051187 Code-Coverage: Zoss Reviewed-by: Keith Short --- zephyr/Kconfig.usb_charger | 2 ++ zephyr/emul/Kconfig | 2 ++ zephyr/program/brya/prj.conf | 1 - zephyr/program/corsola/magikarp/project.conf | 1 - zephyr/program/corsola/npcx_program.conf | 1 - zephyr/program/corsola/tentacruel/project.conf | 1 - zephyr/program/herobrine/program.conf | 1 - zephyr/program/nissa/program.conf | 1 - zephyr/program/rex/prj.conf | 3 --- zephyr/program/skyrim/prj.conf | 1 - zephyr/program/trogdor/lazor/prj.conf | 1 - zephyr/test/drivers/prj.conf | 2 -- zephyr/test/vboot_efs2/prj.conf | 2 -- 13 files changed, 4 insertions(+), 15 deletions(-) diff --git a/zephyr/Kconfig.usb_charger b/zephyr/Kconfig.usb_charger index 1c58753412..fa17f6c020 100644 --- a/zephyr/Kconfig.usb_charger +++ b/zephyr/Kconfig.usb_charger @@ -40,6 +40,8 @@ config PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201 config PLATFORM_EC_BC12_DETECT_PI3USB9201 bool "Enable support for Pericom PI3USB9201" select PLATFORM_EC_BC12_DETECT_DATA_ROLE_TRIGGER + default y + depends on DT_HAS_PERICOM_PI3USB9201_ENABLED help This is a Dual-Role USB Charging-Type Detector. It can operate in host or client mode. It supports Battery Charging Specification, rev diff --git a/zephyr/emul/Kconfig b/zephyr/emul/Kconfig index 5c85f6dc5a..20b2d984f9 100644 --- a/zephyr/emul/Kconfig +++ b/zephyr/emul/Kconfig @@ -31,6 +31,8 @@ config EMUL_BMA255 config EMUL_BC12_DETECT_PI3USB9201 bool "PI3USB9201 emulator" + default y + depends on ZTEST && DT_HAS_PERICOM_PI3USB9201_ENABLED help Enable the PI3USB9201 emulator. PI3USB9201 is a BC1.2 charger detector/advertiser. The emulator supports reading and writing the diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf index 0d248c6487..402db74994 100644 --- a/zephyr/program/brya/prj.conf +++ b/zephyr/program/brya/prj.conf @@ -113,7 +113,6 @@ CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USB_PID=0x504F CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y diff --git a/zephyr/program/corsola/magikarp/project.conf b/zephyr/program/corsola/magikarp/project.conf index 73433b242a..2fd94d6fbe 100644 --- a/zephyr/program/corsola/magikarp/project.conf +++ b/zephyr/program/corsola/magikarp/project.conf @@ -6,7 +6,6 @@ CONFIG_BOARD_MAGIKARP=y # USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n CONFIG_PLATFORM_EC_USB_MUX_PS8743=y CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 diff --git a/zephyr/program/corsola/npcx_program.conf b/zephyr/program/corsola/npcx_program.conf index d619afade1..300cbe085d 100644 --- a/zephyr/program/corsola/npcx_program.conf +++ b/zephyr/program/corsola/npcx_program.conf @@ -53,7 +53,6 @@ CONFIG_PLATFORM_EC_TABLET_MODE=y CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y # USBC -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY=15000 CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY=15000 diff --git a/zephyr/program/corsola/tentacruel/project.conf b/zephyr/program/corsola/tentacruel/project.conf index 239fc339fb..cf5f727cbc 100644 --- a/zephyr/program/corsola/tentacruel/project.conf +++ b/zephyr/program/corsola/tentacruel/project.conf @@ -6,7 +6,6 @@ CONFIG_BOARD_TENTACRUEL=y # USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n CONFIG_PLATFORM_EC_USB_MUX_PS8743=y diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf index d97919cce1..babc8483c9 100644 --- a/zephyr/program/herobrine/program.conf +++ b/zephyr/program/herobrine/program.conf @@ -80,7 +80,6 @@ CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y # USB-C CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf index b445c60b6f..ade406671a 100644 --- a/zephyr/program/nissa/program.conf +++ b/zephyr/program/nissa/program.conf @@ -99,7 +99,6 @@ CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y # ADL integrated muxes are slow: unblock PD CONFIG_PLATFORM_EC_USB_MUX_TASK=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y # USB-C TCPC and PPC standard options CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 8b99cc373c..8b783e30f7 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -106,9 +106,6 @@ CONFIG_PLATFORM_EC_USB_PD_USB4=y CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y CONFIG_PLATFORM_EC_USB_PID=0x504D -# BC 1.2 -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y - #USB Mux CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y CONFIG_PLATFORM_EC_USB_MUX_TASK=y diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 4d0ed48e6f..0c90952ceb 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -77,7 +77,6 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 # USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf index 5f29c3f5c2..7863c75917 100644 --- a/zephyr/program/trogdor/lazor/prj.conf +++ b/zephyr/program/trogdor/lazor/prj.conf @@ -82,7 +82,6 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y # USB-C -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 49382d65d4..483d3f8481 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -49,7 +49,6 @@ CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY=49 CONFIG_EEPROM=y CONFIG_EEPROM_SIMULATOR=n CONFIG_EMUL_EEPROM_AT2X=y -CONFIG_EMUL_BC12_DETECT_PI3USB9201=y CONFIG_EMUL_BB_RETIMER=y CONFIG_EMUL_TCPCI_PARTNER_DRP=y CONFIG_EMUL_TCPCI_PARTNER_FAULTY_EXT=y @@ -67,7 +66,6 @@ CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y CONFIG_PLATFORM_EC_USB_PID=0x5000 CONFIG_PLATFORM_EC_USBC=y CONFIG_PLATFORM_EC_USB_CHARGER=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_USB_POWER_DELIVERY=y CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y CONFIG_PLATFORM_EC_BATTERY_SMART=y diff --git a/zephyr/test/vboot_efs2/prj.conf b/zephyr/test/vboot_efs2/prj.conf index 9f1eb37972..0b894dd082 100644 --- a/zephyr/test/vboot_efs2/prj.conf +++ b/zephyr/test/vboot_efs2/prj.conf @@ -3,7 +3,6 @@ # found in the LICENSE file. CONFIG_CROS_EC=y -CONFIG_EMUL_BC12_DETECT_PI3USB9201=y CONFIG_FLASH=y CONFIG_PLATFORM_EC=y CONFIG_PLATFORM_EC_BACKLIGHT_LID=n @@ -11,7 +10,6 @@ CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=y -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y CONFIG_PLATFORM_EC_CHARGER_ISL9238=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 -- cgit v1.2.1 From 1063e0ff8356c09a465a9e2f4b402342e04bf83b Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Mon, 21 Nov 2022 13:32:54 -0700 Subject: TCPMv2: Disallow VCONN Swap in CTAttached.SNK In PE_VCS_Evaluate_Swap, reject a VCONN Swap when the Type-C SM does not allow it (when the Type-C state is CTAttached.SNK). Give this setting precedence over the PE logic to allow VCONN Swap if the TCPM is VCONN Source in the general case. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.usbc_ctvpd BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I2042e5ce5c7694d0efd11b6e7f3c4a14d703676d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043736 Code-Coverage: Zoss Reviewed-by: Sam Hurst --- common/usbc/usb_pe_drp_sm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 053fb96ff1..f2bc65da29 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -6514,7 +6514,7 @@ static void pe_vcs_evaluate_swap_entry(int port) */ /* DPM rejects a VCONN Swap and port is not a VCONN source*/ - if (!tc_check_vconn_swap(port) && tc_is_vconn_src(port) < 1) { + if (!tc_check_vconn_swap(port) || tc_is_vconn_src(port) < 1) { /* NOTE: PE_VCS_Reject_Swap State embedded here */ send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT); } -- cgit v1.2.1 From 20b581f68a8003c492e38c68ac76b2d2ed4cc33e Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Mon, 21 Nov 2022 13:36:24 -0700 Subject: TCPMv2: Present as Sink/UFP in CTAttached.SNK In the Type-C state machine, set the data role to UFP after attaching to the charge-through port of a CT-VPD. This keeps the data role consistent with the Sink power role and conforms to USB Type-C specification release 2.2 ss 4.10.2. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.usbc_ctvpd BRANCH=none Signed-off-by: Abe Levkoy Change-Id: Ic94145ef08c3e1ce7094891d8686ce2858a13476 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043737 Reviewed-by: Sam Hurst Code-Coverage: Zoss --- common/usbc/usb_tc_drp_acc_trysrc_sm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 47369a75d1..168490d67e 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -3749,6 +3749,13 @@ __maybe_unused static void tc_ct_attached_snk_entry(int port) /* The port shall reject a VCONN swap request. */ TC_SET_FLAG(port, TC_FLAGS_REJECT_VCONN_SWAP); + + /* + * Type-C r 2.2: The Host shall not advertise dual-role data or + * dual-role power in its SourceCapability or SinkCapability messages - + * Host changes its advertised capabilities to UFP role/sink only role. + */ + tc_set_data_role(port, PD_ROLE_UFP); } __maybe_unused static void tc_ct_attached_snk_run(int port) -- cgit v1.2.1 From 299345c9ab5c664180517151fad51768b8e717d9 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Tue, 8 Nov 2022 12:05:07 -0700 Subject: zephyr test: Exercise CT-VPD support Verify that the TCPM detects and connects to a charge-through VCONN-powered device. BUG=b:257341564 TEST=twister -s zephyr/test/drivers/drivers.usbc_ctvpd BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I2afe7b4c2a60fd7411e46345776b6a1e3d73a70e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025831 Code-Coverage: Zoss Reviewed-by: Aaron Massey Reviewed-by: Yuval Peress --- zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/Kconfig | 5 + zephyr/test/drivers/testcase.yaml | 3 + zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt | 7 + .../drivers/usbc_ctvpd/include/test_usbc_ctvpd.h | 29 ++++ zephyr/test/drivers/usbc_ctvpd/src/main.c | 168 +++++++++++++++++++++ 6 files changed, 213 insertions(+) create mode 100644 zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt create mode 100644 zephyr/test/drivers/usbc_ctvpd/include/test_usbc_ctvpd.h create mode 100644 zephyr/test/drivers/usbc_ctvpd/src/main.c diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index befbe42efb..3a1390fddf 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -38,6 +38,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USB_PORT_POWER_DUMB usb_port_power add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USB_RETIMER_FW_UPDATE usb_retimer_fw_update) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_ALT_MODE usbc_alt_mode) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_CONSOLE_PD usbc_console_pd) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_CTVPD usbc_ctvpd) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_SVDM_DFP_ONLY usbc_svdm_dfp_only) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_TBT_MODE usbc_tbt_mode) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_VCONN_SWAP usbc_vconn_swap) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index 9f80e53dd3..0994444f23 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -101,6 +101,11 @@ config LINK_TEST_SUITE_USBC_ALT_MODE config LINK_TEST_SUITE_USBC_CONSOLE_PD bool"Link and test the usbc_console_pd tests" +config LINK_TEST_SUITE_USBC_CTVPD + bool "Link tests for charge-through VCONN-powered device support" + select EMUL_TCPCI_PARTNER_VPD + select LOG + config LINK_TEST_SUITE_USBC_OCP bool "Link tests for common USBC OCP code" diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 2dc85d4afd..f3de4507cd 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -208,6 +208,9 @@ tests: drivers.usbc_console_pd: extra_configs: - CONFIG_LINK_TEST_SUITE_USBC_CONSOLE_PD=y + drivers.usbc_ctvpd: + extra_configs: + - CONFIG_LINK_TEST_SUITE_USBC_CTVPD=y drivers.usbc_ocp: extra_configs: - CONFIG_LINK_TEST_SUITE_USBC_OCP=y diff --git a/zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt b/zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt new file mode 100644 index 0000000000..36f88dfcbb --- /dev/null +++ b/zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + +target_sources(app PRIVATE src/main.c) diff --git a/zephyr/test/drivers/usbc_ctvpd/include/test_usbc_ctvpd.h b/zephyr/test/drivers/usbc_ctvpd/include/test_usbc_ctvpd.h new file mode 100644 index 0000000000..9ebb740da8 --- /dev/null +++ b/zephyr/test/drivers/usbc_ctvpd/include/test_usbc_ctvpd.h @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_DRIVERS_USBC_ALT_MODE_TEST_USBC_ALT_MODE_H_ +#define ZEPHYR_TEST_DRIVERS_USBC_ALT_MODE_TEST_USBC_ALT_MODE_H_ + +#include "compile_time_macros.h" +#include "emul/tcpc/emul_tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_snk.h" +#include "emul/tcpc/emul_tcpci_partner_src.h" +#include "emul/tcpc/emul_tcpci_partner_vpd.h" +#include "test/drivers/stubs.h" + +struct common_fixture { + const struct emul *tcpci_emul; + const struct emul *charger_emul; + struct tcpci_partner_data partner; + struct tcpci_src_emul_data src_ext; + struct tcpci_snk_emul_data snk_ext; + struct tcpci_vpd_emul_data vpd_ext; +}; + +struct usbc_ctvpd_fixture { + struct common_fixture common; +}; + +#endif /* ZEPHYR_TEST_DRIVERS_USBC_ALT_MODE_TEST_USBC_ALT_MODE_H_ */ diff --git a/zephyr/test/drivers/usbc_ctvpd/src/main.c b/zephyr/test/drivers/usbc_ctvpd/src/main.c new file mode 100644 index 0000000000..391a006370 --- /dev/null +++ b/zephyr/test/drivers/usbc_ctvpd/src/main.c @@ -0,0 +1,168 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include +#include + +#include "ec_commands.h" +#include "ec_tasks.h" +#include "emul/emul_isl923x.h" +#include "emul/tcpc/emul_tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_common.h" +#include "emul/tcpc/emul_tcpci_partner_snk.h" +#include "emul/tcpc/emul_tcpci_partner_src.h" +#include "host_command.h" +#include "test/drivers/stubs.h" +#include "tcpm/tcpci.h" +#include "test/drivers/utils.h" +#include "test/drivers/test_state.h" +#include "test_usbc_ctvpd.h" +#include "usb_pd_vdo.h" + +#define TEST_PORT 0 +BUILD_ASSERT(TEST_PORT == USBC_PORT_C0); + +struct tcpci_cable_data charge_through_vpd = { + .identity_vdm[VDO_INDEX_HDR] = + VDO(USB_SID_PD, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT), + .identity_vdm[VDO_INDEX_IDH] = VDO_IDH( + /* USB host */ false, /* USB device */ false, IDH_PTYPE_VPD, + /* modal operation */ false, USB_VID_GOOGLE), + .identity_vdm[VDO_INDEX_CSTAT] = 0xabcdabcd, + .identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0xabcd), + /* Hardware version 1, firmware version 2 */ + .identity_vdm[VDO_INDEX_PTYPE_UFP1_VDO] = + VDO_VPD(1, 2, VPD_MAX_VBUS_20V, VPD_CT_CURRENT_3A, + VPD_VBUS_IMP(10), VPD_GND_IMP(10), VPD_CTS_SUPPORTED), + .identity_vdos = VDO_INDEX_PTYPE_UFP1_VDO + 1, +}; + +static void disconnect_partner_from_port(const struct emul *tcpc_emul, + const struct emul *charger_emul) +{ + zassert_ok(tcpci_emul_disconnect_partner(tcpc_emul)); + isl923x_emul_set_adc_vbus(charger_emul, 0); + k_sleep(K_SECONDS(1)); +} + +static void add_discovery_responses(struct tcpci_partner_data *partner) +{ + partner->cable = &charge_through_vpd; + struct tcpci_cable_data *cable = partner->cable; + + /* Add Discover Identity response */ + cable->identity_vdm[VDO_INDEX_HDR] = + VDO(USB_SID_PD, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT); + cable->identity_vdm[VDO_INDEX_IDH] = VDO_IDH( + /* USB host */ false, /* USB device */ false, IDH_PTYPE_VPD, + /* modal operation */ false, USB_VID_GOOGLE); + cable->identity_vdm[VDO_INDEX_CSTAT] = 0xabcdabcd; + cable->identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0x5678); + /* Hardware version 1, firmware version 2 */ + cable->identity_vdm[VDO_INDEX_PTYPE_UFP1_VDO] = + VDO_VPD(1, 2, VPD_MAX_VBUS_20V, VPD_CT_CURRENT_3A, + VPD_VBUS_IMP(10), VPD_GND_IMP(10), VPD_CTS_SUPPORTED); + cable->identity_vdos = VDO_INDEX_PTYPE_UFP1_VDO + 1; +} + +static void common_before(struct common_fixture *common) +{ + /* Set chipset to ON, this will set TCPM to DRP */ + test_set_chipset_to_s0(); + + /* TODO(b/214401892): Check why need to give time TCPM to spin */ + k_sleep(K_SECONDS(1)); + + connect_sink_to_port(&common->partner, common->tcpci_emul, + common->charger_emul); +} + +static void common_after(struct common_fixture *common) +{ + disconnect_partner_from_port(common->tcpci_emul, common->charger_emul); +} + +static void *usbc_ctvpd_setup(void) +{ + static struct usbc_ctvpd_fixture fixture; + struct common_fixture *common = &fixture.common; + struct tcpci_partner_data *partner = &common->partner; + struct tcpci_vpd_emul_data *vpd_ext = &common->vpd_ext; + + tcpci_partner_init(partner, PD_REV30); + partner->extensions = tcpci_vpd_emul_init(vpd_ext, partner, NULL); + + /* Get references for the emulators */ + common->tcpci_emul = EMUL_GET_USBC_BINDING(TEST_PORT, tcpc); + common->charger_emul = EMUL_GET_USBC_BINDING(TEST_PORT, chg); + + add_discovery_responses(partner); + + return &fixture; +} + +static void usbc_ctvpd_before(void *data) +{ + struct usbc_ctvpd_fixture *fixture = data; + + common_before(&fixture->common); +} + +static void usbc_ctvpd_after(void *data) +{ + struct usbc_ctvpd_fixture *fixture = data; + + common_after(&fixture->common); +} + +ZTEST_SUITE(usbc_ctvpd, drivers_predicate_post_main, usbc_ctvpd_setup, + usbc_ctvpd_before, usbc_ctvpd_after, NULL); + +ZTEST_USER_F(usbc_ctvpd, verify_discovery) +{ + uint8_t response_buffer[EC_LPC_HOST_PACKET_SIZE]; + struct ec_response_typec_discovery *discovery = + (struct ec_response_typec_discovery *)response_buffer; + struct common_fixture *common = &fixture->common; + + host_cmd_typec_discovery(TEST_PORT, TYPEC_PARTNER_SOP_PRIME, + response_buffer, sizeof(response_buffer)); + + /* The host command does not count the VDM header in identity_count. */ + zassert_equal(discovery->identity_count, + common->partner.cable->identity_vdos - 1, + "Expected %d identity VDOs, got %d", + common->partner.cable->identity_vdos - 1, + discovery->identity_count); + zassert_mem_equal(discovery->discovery_vdo, + common->partner.cable->identity_vdm + 1, + discovery->identity_count * + sizeof(*discovery->discovery_vdo), + "Discovered SOP identity ACK did not match"); +} + +ZTEST_USER_F(usbc_ctvpd, verify_no_vconn_swap) +{ + struct ec_response_typec_status status = + host_cmd_typec_status(TEST_PORT); + enum pd_vconn_role initial_vconn_role = status.vconn_role; + + /* Upon initial attachment to the host port of a CT-VPD, the host (TCPM) + * should be Source and thus VCONN Source. After entry into + * CTAttached.SNK, the host should remain VCONN Source. + */ + zassert_equal(initial_vconn_role, PD_ROLE_VCONN_SRC); + + /* The TCPM should refuse to VCONN Swap while in CTAttached.SNK. */ + zassert_ok(tcpci_partner_send_control_msg(&fixture->common.partner, + PD_CTRL_VCONN_SWAP, 0)); + k_sleep(K_SECONDS(1)); + status = host_cmd_typec_status(TEST_PORT); + zassert_equal(status.vconn_role, initial_vconn_role); +} -- cgit v1.2.1 From 09da235c9cf169a22ab8711262a8cc7401271802 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Mon, 21 Nov 2022 14:10:35 -0700 Subject: tcpm_header: add more driver call-through tests These functions call the driver's implementation only if present. Added tests for both cases where the driver does and does not implement these functions. Functions tested: - tcpm_debug_accessory - tcpm_debug_detach - tcpm_hard_reset_reinit BUG=none TEST=twister, verify lines are now covered BRANCH=none Signed-off-by: Clayton Whitelaw Change-Id: I26e1cdb74f1ed3f08065a301081561a764322bc3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4048912 Code-Coverage: Zoss Reviewed-by: Yuval Peress --- zephyr/test/drivers/default/src/tcpm_header.c | 73 ++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c index affaa9d99a..9fe80da15b 100644 --- a/zephyr/test/drivers/default/src/tcpm_header.c +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include "tcpm/tcpci.h" #include "tcpm/tcpm.h" #include "test/drivers/stubs.h" #include "test/drivers/test_state.h" @@ -15,6 +14,9 @@ FAKE_VALUE_FUNC(int, set_vconn, int, int); FAKE_VALUE_FUNC(int, reset_bist_type_2, int); +FAKE_VALUE_FUNC(int, debug_accessory, int, bool); +FAKE_VALUE_FUNC(int, debug_detach, int); +FAKE_VALUE_FUNC(int, hard_reset_reinit, int); struct tcpm_header_fixture { /* The original driver pointer that gets restored after the tests */ @@ -42,11 +44,7 @@ ZTEST_F(tcpm_header, test_tcpm_header_drv_set_vconn_failure) ZTEST_F(tcpm_header, test_tcpm_header_reset_bist_type_2__unimplemented) { - int res; - - res = tcpm_reset_bist_type_2(TCPM_TEST_PORT); - - zassert_equal(EC_SUCCESS, res); + zassert_ok(tcpm_reset_bist_type_2(TCPM_TEST_PORT)); } ZTEST_F(tcpm_header, test_tcpm_header_reset_bist_type_2__implemented) @@ -63,6 +61,69 @@ ZTEST_F(tcpm_header, test_tcpm_header_reset_bist_type_2__implemented) zassert_equal(driver_return_code, res); } +ZTEST_F(tcpm_header, test_tcpm_header_debug_accessory__unimplemented) +{ + zassert_ok(tcpm_debug_accessory(TCPM_TEST_PORT, true)); + zassert_ok(tcpm_debug_accessory(TCPM_TEST_PORT, false)); +} + +ZTEST_F(tcpm_header, test_tcpm_header_debug_accessory__implemented) +{ + int res; + const int driver_return_code = 7458; /* arbitrary */ + + fixture->mock_driver.debug_accessory = debug_accessory; + debug_accessory_fake.return_val = driver_return_code; + res = tcpm_debug_accessory(TCPM_TEST_PORT, true); + + zassert_equal(1, debug_accessory_fake.call_count); + zassert_equal(TCPM_TEST_PORT, debug_accessory_fake.arg0_history[0]); + zassert_true(debug_accessory_fake.arg1_history[0]); + zassert_equal(driver_return_code, res); +} + +ZTEST_F(tcpm_header, test_tcpm_header_debug_detach__unimplemented) +{ + zassert_ok(tcpm_debug_detach(TCPM_TEST_PORT)); +} + +ZTEST_F(tcpm_header, test_tcpm_header_debug_detach__implemented) +{ + int res; + const int driver_return_code = 7458; /* arbitrary */ + + fixture->mock_driver.debug_detach = debug_detach; + debug_detach_fake.return_val = driver_return_code; + res = tcpm_debug_detach(TCPM_TEST_PORT); + + zassert_equal(1, debug_detach_fake.call_count); + zassert_equal(TCPM_TEST_PORT, debug_detach_fake.arg0_history[0]); + zassert_equal(driver_return_code, res); +} + +ZTEST_F(tcpm_header, test_tcpm_header_hard_reset_reinit__unimplemented) +{ + int res; + + res = tcpm_hard_reset_reinit(TCPM_TEST_PORT); + + zassert_equal(EC_ERROR_UNIMPLEMENTED, res); +} + +ZTEST_F(tcpm_header, test_tcpm_header_hard_reset_reinit__implemented) +{ + int res; + const int driver_return_code = 7458; /* arbitrary */ + + fixture->mock_driver.hard_reset_reinit = hard_reset_reinit; + hard_reset_reinit_fake.return_val = driver_return_code; + res = tcpm_hard_reset_reinit(TCPM_TEST_PORT); + + zassert_equal(1, hard_reset_reinit_fake.call_count); + zassert_equal(TCPM_TEST_PORT, hard_reset_reinit_fake.arg0_history[0]); + zassert_equal(driver_return_code, res); +} + static void *tcpm_header_setup(void) { static struct tcpm_header_fixture fixture; -- cgit v1.2.1 From c4b5de8ca4f5edeb1cc8ee820434c5ab3eb05ac8 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 12:49:27 -0700 Subject: baseboard: Move conditional includes to end Move the zephyr only headers to be last, so the others will sort correctly with clang-format. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I88211638be6ee1d3558a42e641d7c1882d7294cc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049880 Reviewed-by: Aaron Massey Commit-Queue: Jeremy Bettis Code-Coverage: Zoss Tested-by: Jeremy Bettis --- baseboard/volteer/usbc_config.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/baseboard/volteer/usbc_config.c b/baseboard/volteer/usbc_config.c index 1d1181ee41..d77e275282 100644 --- a/baseboard/volteer/usbc_config.c +++ b/baseboard/volteer/usbc_config.c @@ -9,18 +9,19 @@ #include "charge_ramp.h" #include "charge_state.h" #include "common.h" +#include "driver/charger/isl9241_public.h" #include "gpio.h" #include "task.h" -#ifdef CONFIG_ZEPHYR -#include "baseboard_usbc_config.h" -#include "usbc_config.h" -#endif -#include "driver/charger/isl9241_public.h" #include "usb_charge.h" #include "usb_pd.h" #include "usbc_ppc.h" #include "util.h" +#ifdef CONFIG_ZEPHYR +#include "baseboard_usbc_config.h" +#include "usbc_config.h" +#endif + /******************************************************************************/ void tcpc_alert_event(enum gpio_signal signal) { -- cgit v1.2.1 From e5fc200fd3d6523d87227f9654b891ce387892ba Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Thu, 17 Nov 2022 17:19:14 -0700 Subject: zephyr: test: Bring virtual_battery_handler() to 100% coverage Cover all remaining code paths in virtual_battery_handler() in common/virtual_battery.c BRANCH=None BUG=None TEST=./twister Signed-off-by: Tristan Honscheid Change-Id: Ib510b7c76eca7daf8e9824c486afd391ad1b5d87 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4036107 Commit-Queue: Aaron Massey Reviewed-by: Aaron Massey Code-Coverage: Zoss --- common/virtual_battery.c | 8 +- zephyr/test/drivers/default/src/virtual_battery.c | 145 ++++++++++++++++++++++ 2 files changed, 150 insertions(+), 3 deletions(-) diff --git a/common/virtual_battery.c b/common/virtual_battery.c index adb4e96d7f..743f2a8801 100644 --- a/common/virtual_battery.c +++ b/common/virtual_battery.c @@ -103,9 +103,6 @@ int virtual_battery_handler(struct ec_response_i2c_passthru *resp, int in_len, if (cache_hit) *err_code = 0; break; - default: - reset_parse_state(); - return EC_ERROR_INVAL; } acc_write_len += write_len; @@ -129,10 +126,15 @@ int virtual_battery_handler(struct ec_response_i2c_passthru *resp, int in_len, read_len, 0); } break; + /* LCOV_EXCL_START - Unreachable in IDLE state and remaining + * states covered above. + */ default: reset_parse_state(); return EC_ERROR_INVAL; } + /* LCOV_EXCL_STOP */ + /* Reset the state in the end of messages */ reset_parse_state(); } diff --git a/zephyr/test/drivers/default/src/virtual_battery.c b/zephyr/test/drivers/default/src/virtual_battery.c index ee3eab217c..3b265443e8 100644 --- a/zephyr/test/drivers/default/src/virtual_battery.c +++ b/zephyr/test/drivers/default/src/virtual_battery.c @@ -7,9 +7,13 @@ #include "battery_smart.h" #include "ec_commands.h" #include "emul/emul_smart_battery.h" +#include "gpio.h" #include "host_command.h" #include "test/drivers/test_state.h" +#include "virtual_battery.h" +#include +#include #include #include @@ -285,3 +289,144 @@ ZTEST(virtual_battery, test_read_data_from_host_memmap) ZTEST_SUITE(virtual_battery, drivers_predicate_post_main, NULL, NULL, NULL, NULL); + +ZTEST(virtual_battery_direct, test_bad_reg_write) +{ + struct ec_response_i2c_passthru resp; + + /* Start with a zero-length write. The state machine is expecting a + * register address to be written, so this will fail. + */ + zassert_equal(EC_ERROR_INVAL, + virtual_battery_handler(&resp, 0, NULL, 0, 0, + /* write_len = */ 0, NULL)); + + zassert_equal(EC_I2C_STATUS_NAK, resp.i2c_status); +} + +ZTEST(virtual_battery_direct, test_aborted_write) +{ + struct ec_response_i2c_passthru resp; + int error_code; + + /* Arbitrary packet of bytes */ + const uint8_t packet[] = { 0xAA, 0xBB, 0xCC }; + + /* Start with a length 1 write to set a register address. */ + zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0, + /* write_len = */ 1, &packet[0])); + + /* Now write two more bytes successfully... */ + zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0, + /* write_len = */ 1, &packet[1])); + zassert_ok(error_code); + + zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0, + /* write_len = */ 1, &packet[2])); + zassert_ok(error_code); + + /* ...and abruptly write 0 bytes. This will cause an error */ + zassert_equal(EC_ERROR_INVAL, + virtual_battery_handler(&resp, 0, &error_code, 0, 0, + /* write_len = */ 0, NULL)); + + zassert_equal(EC_I2C_STATUS_NAK, resp.i2c_status); +} + +ZTEST(virtual_battery_direct, test_aborted_read) +{ + struct ec_response_i2c_passthru resp; + int error_code; + + /* Arbitrary packet to set a register plus a buffer to read to */ + const uint8_t write_packet[] = { SB_MANUFACTURER_NAME }; + uint8_t read_packet[3] = { 0 }; + + /* Start with a length 1 write to set a register address. */ + zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0, + /* write_len = */ 1, + &write_packet[0])); + + /* Now read two bytes successfully... */ + zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, + /* read_len = */ 1, 0, + &read_packet[0])); + zassert_ok(error_code); + + zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, + /* read_len = */ 1, 0, + &read_packet[1])); + zassert_ok(error_code); + + /* ...and abruptly read 0 bytes. This will cause an error */ + zassert_equal(EC_ERROR_INVAL, + virtual_battery_handler(&resp, 0, &error_code, 0, + /* read_len = */ 0, 0, + &read_packet[2])); + + zassert_equal(EC_I2C_STATUS_NAK, resp.i2c_status); +} + +ZTEST(virtual_battery_direct, test_read_bad_reg) +{ + struct ec_response_i2c_passthru resp; + int error_code; + + /* Try to read from an invalid register */ + const uint8_t write_packet[] = { 0xFF }; + uint8_t read_packet[3] = { 0 }; + + /* Start with a length 1 write to set a register address. */ + zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0, + /* write_len = */ 1, + &write_packet[0])); + + /* Now try to read */ + zassert_equal(EC_ERROR_INVAL, + virtual_battery_handler(&resp, 0, &error_code, 0, + /* read_len = */ 1, 0, + &read_packet[0])); + zassert_equal(EC_ERROR_INVAL, error_code); +} + +#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) +#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) + +static int set_battery_present(bool batt_present) +{ + const struct device *batt_pres_dev = + DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios)); + + return gpio_emul_input_set(batt_pres_dev, GPIO_BATT_PRES_ODL_PORT, + !batt_present); +} + +ZTEST(virtual_battery_direct, test_no_battery) +{ + struct ec_response_i2c_passthru resp; + + set_battery_present(false); + + /* Arbitrary packet of bytes */ + const uint8_t packet[] = { 0xAA, 0xBB, 0xCC }; + + /* Attempt a valid write operation, which will fail due to no battery */ + zassert_equal(EC_ERROR_INVAL, + virtual_battery_handler(&resp, 0, NULL, 0, 0, + /* write_len = */ 1, &packet[0])); + + zassert_equal(EC_I2C_STATUS_NAK, resp.i2c_status); +} + +static void virtual_battery_direct_reset(void *arg) +{ + reset_parse_state(); + + set_battery_present(true); +} + +/* The virtual_battery_direct suite tests the virtual battery handler directly + * without performing I2C ops. This makes it easier to test certain corner-cases + */ +ZTEST_SUITE(virtual_battery_direct, drivers_predicate_post_main, NULL, + virtual_battery_direct_reset, virtual_battery_direct_reset, NULL); -- cgit v1.2.1 From e04250319d222ef8505d9111ba4f03eddcaf5521 Mon Sep 17 00:00:00 2001 From: Mark Hasemeyer Date: Wed, 23 Nov 2022 09:58:21 -0700 Subject: zephyr: Remove CONFIG_PLATFORM_EC_WATCHDOG Remove CONFIG_PLATFORM_EC_WATCHDOG. Use Zephyr's CONFIG_WATCHDOG option instead. BUG=b:217926701 BRANCH=none TEST=twister -T zephyr/test/ TEST=zmake compare-builds -a LOW_COVERAGE_REASON=watchdog_init test not yet implemented Signed-off-by: Mark Hasemeyer Change-Id: I7d5fedfc72ed886f94a94df9d3db14224bc6fb75 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050634 Reviewed-by: Keith Short Reviewed-by: Aaron Massey Tested-by: Mark Hasemeyer Commit-Queue: Mark Hasemeyer --- zephyr/Kconfig | 17 ----------------- zephyr/Kconfig.watchdog | 4 ++-- zephyr/app/ec/ec_app_main.c | 2 +- zephyr/drivers/cros_flash/cros_flash_it8xxx2.c | 4 ++-- zephyr/shim/src/CMakeLists.txt | 2 +- zephyr/test/ec_app/src/main.c | 2 +- 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 9e04f4a679..b60e87d10e 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -741,23 +741,6 @@ config PLATFORM_EC_VSTORE_SLOT_COUNT used only for recording a hash of the read-write AP firmware for checking on resume. For this, one slot is enough. -menuconfig PLATFORM_EC_WATCHDOG - bool "Watchdog" - depends on WATCHDOG - default y - help - Enable the watchdog functionality. The watchdog timer will reboot the - system if the hook task (which is the lowest-priority task on the - system) gets starved for CPU time and isn't able to fire its - HOOK_TICK event. - - Chromium EC system uses an auxiliary timer to handle the system - warning event. This leaves some time to the system for preparing & - printing the debug information. The interval between reloads of the - watchdog timer should be less than half of the auxiliary timer - (PLATFORM_EC_WATCHDOG_PERIOD_MS - - PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS). - config PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API bool "Workaround needed for npcx9 ES1 chip" depends on SOC_SERIES_NPCX9 diff --git a/zephyr/Kconfig.watchdog b/zephyr/Kconfig.watchdog index f6c9002233..653cc58e22 100644 --- a/zephyr/Kconfig.watchdog +++ b/zephyr/Kconfig.watchdog @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -if PLATFORM_EC_WATCHDOG +if WATCHDOG config PLATFORM_EC_WATCHDOG_PERIOD_MS int "Watchdog timeout in ms" @@ -27,4 +27,4 @@ config PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS For the ITE chip, use CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS instead of this config. -endif # PLATFORM_EC_WATCHDOG +endif # WATCHDOG diff --git a/zephyr/app/ec/ec_app_main.c b/zephyr/app/ec/ec_app_main.c index 4ab5fd3a44..961e4f5ce2 100644 --- a/zephyr/app/ec/ec_app_main.c +++ b/zephyr/app/ec/ec_app_main.c @@ -37,7 +37,7 @@ void ec_app_main(void) system_print_banner(); - if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG) && + if (IS_ENABLED(CONFIG_WATCHDOG) && !IS_ENABLED(CONFIG_WDT_DISABLE_AT_BOOT)) { watchdog_init(); } diff --git a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c index 79ef0c36b2..2d34a21523 100644 --- a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c +++ b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c @@ -180,7 +180,7 @@ static int cros_flash_it8xxx2_write(const struct device *dev, int offset, * chance to go back to hook task to touch watchdog. Reload watchdog * on each flash write to prevent the reset. */ - if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG)) + if (IS_ENABLED(CONFIG_WATCHDOG)) watchdog_reload(); return flash_write(flash_controller, offset, src_data, size); @@ -223,7 +223,7 @@ static int cros_flash_it8xxx2_erase(const struct device *dev, int offset, * If requested erase size is too large at one time on KGD * flash, we need to reload watchdog to prevent the reset. */ - if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG) && (size > 0x10000)) + if (IS_ENABLED(CONFIG_WATCHDOG) && (size > 0x10000)) watchdog_reload(); } /* Restore interrupts */ diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 543c2b2303..62697db096 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -63,7 +63,7 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR temp_sensors.c zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TIMER hwtimer.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C i2c.c) zephyr_library_sources_ifdef(CONFIG_SHIMMED_TASKS tasks.c) -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_WATCHDOG watchdog.c) +zephyr_library_sources_ifdef(CONFIG_WATCHDOG watchdog.c) zephyr_library_sources_ifndef(CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER bc12.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201 diff --git a/zephyr/test/ec_app/src/main.c b/zephyr/test/ec_app/src/main.c index 3c317d2a08..52a19f131c 100644 --- a/zephyr/test/ec_app/src/main.c +++ b/zephyr/test/ec_app/src/main.c @@ -46,7 +46,7 @@ ZTEST(ec_app_tests, test_setup_espi) } #endif -#ifdef CONFIG_PLATFORM_EC_WATCHDOG +#ifdef CONFIG_WATCHDOG ZTEST(ec_app_tests, test_watchdog_init) { zassert_unreachable("TODO: Implement this test."); -- cgit v1.2.1 From aec4e7f6221c0d34f63a63b23f7bd7660b91460a Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 14:13:00 -0700 Subject: baseboard: Remove unused externs The symbols zork_base_standard_ref and grunt_base_standard_ref are never actually defined or used anywhere. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j$(nproc) buildall_only runtests TEST=zmake compare-builds Change-Id: I1425ceb38f1de45e50c98f86f4df4221602120e0 Signed-off-by: Jeremy Bettis Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049881 Code-Coverage: Zoss Auto-Submit: Jeremy Bettis Commit-Queue: Simon Glass Tested-by: Jeremy Bettis Reviewed-by: Simon Glass --- baseboard/grunt/baseboard.h | 18 ------------------ baseboard/zork/baseboard.h | 18 ------------------ 2 files changed, 36 deletions(-) diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h index e385b11b86..b9ddd32861 100644 --- a/baseboard/grunt/baseboard.h +++ b/baseboard/grunt/baseboard.h @@ -191,7 +191,6 @@ #ifndef __ASSEMBLER__ #include "gpio_signal.h" -#include "math_util.h" #include "registers.h" enum adc_channel { @@ -225,23 +224,6 @@ enum sensor_id { SENSOR_COUNT, }; -/* - * Matrix to rotate accelerators into the standard reference frame. The default - * is the identity which is correct for the reference design. Variations of - * Grunt may need to change it for manufacturability. - * For the lid: - * +x to the right - * +y up - * +z out of the page - * - * The principle axes of the body are aligned with the lid when the lid is in - * the 180 degree position (open, flat). - * - * Boards within the Grunt family may need to modify this definition at - * board_init() time. - */ -extern mat33_fp_t grunt_base_standard_ref; - /* Sensors without hardware FIFO are in forced mode */ #define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL) diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h index 528aa44a91..5af8f254a0 100644 --- a/baseboard/zork/baseboard.h +++ b/baseboard/zork/baseboard.h @@ -291,7 +291,6 @@ #ifndef __ASSEMBLER__ #include "gpio_signal.h" -#include "math_util.h" #include "registers.h" enum power_signal { @@ -319,23 +318,6 @@ enum sensor_id { SENSOR_COUNT, }; -/* - * Matrix to rotate accelerators into the standard reference frame. The default - * is the identity which is correct for the reference design. Variations of - * Zork may need to change it for manufacturability. - * For the lid: - * +x to the right - * +y up - * +z out of the page - * - * The principle axes of the body are aligned with the lid when the lid is in - * the 180 degree position (open, flat). - * - * Boards within the Zork family may need to modify this definition at - * board_init() time. - */ -extern mat33_fp_t zork_base_standard_ref; - extern const struct thermistor_info thermistor_info; /* Sensors without hardware FIFO are in forced mode */ -- cgit v1.2.1 From 000e9d5229b4fb74ed8cc3b2989aac100db712d7 Mon Sep 17 00:00:00 2001 From: Tristan Honscheid Date: Wed, 16 Nov 2022 14:00:12 -0700 Subject: zephyr: twister: Optimization - Reduce test search scope Currently we ask twister to search the entire EC directory for testcase.yaml files, which takes nearly 3 seconds according to the profiler (this figure is also influenced by how many build artifacts and other stuff a developer may have in that directory). This CL limits the search scope to directories we know have testcase.yaml files. The os.walk() phase now takes negligible time. BRANCH=None BUG=b:259442204 TEST=./twister and checking that 89 scenarios are run Signed-off-by: Tristan Honscheid Change-Id: Ibfc5ce9aa976cc3527d7c168bd0b29ff531ef46c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4031147 Reviewed-by: Yuval Peress Code-Coverage: Zoss --- util/twister_launcher.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util/twister_launcher.py b/util/twister_launcher.py index f0e49c5298..400aabbcd1 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -319,9 +319,12 @@ def main(): for arg in intercepted_args.testsuite_root: twister_cli.extend(["-T", arg]) else: - # Use EC base dir when no -T args specified. This will cause all - # Twister-compatible EC tests to run. - twister_cli.extend(["-T", str(ec_base)]) + # Use this set of test suite roots when no -T args are present. This + # should encompass all current Zephyr EC tests. The paths are meant to + # be as specific as possible to limit Twister's search scope. This saves + # significant time when starting Twister. + twister_cli.extend(["-T", str(ec_base / "common")]) + twister_cli.extend(["-T", str(ec_base / "zephyr/test")]) twister_cli.extend(["-T", str(zephyr_base / "tests/subsys/shell")]) if intercepted_args.platform: -- cgit v1.2.1 From a9f4d1e3b8ce901217a1b8730d7b66aa3a86449a Mon Sep 17 00:00:00 2001 From: Bobby Casey Date: Fri, 30 Sep 2022 15:02:00 -0400 Subject: run_device_tests.py: Resolve error in type hint Resolve the error in find_section_offset's type hint, it should be Tuple(int, int) rather than (int, int) BUG=b:250028913 TEST=./test/run_device_tests.py -b bloonchipper --flasher=servo_micro BRANCH=none Signed-off-by: Bobby Casey Change-Id: I88e86b14efb0fc6f7a39d0c19c83a44d8eb0b975 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3931127 Reviewed-by: Andrea Grandi Code-Coverage: Zoss --- test/run_device_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/run_device_tests.py b/test/run_device_tests.py index fcf9a99651..15f160a53b 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -52,7 +52,7 @@ from concurrent.futures.thread import ThreadPoolExecutor from dataclasses import dataclass, field from enum import Enum from pathlib import Path -from typing import BinaryIO, Dict, List, Optional +from typing import BinaryIO, Dict, List, Optional, Tuple # pylint: disable=import-error import colorama # type: ignore[import] @@ -397,7 +397,7 @@ def read_file_gsutil(path: str) -> bytes: return gsutil.stdout -def find_section_offset_size(section: str, image: bytes) -> (int, int): +def find_section_offset_size(section: str, image: bytes) -> Tuple(int, int): """Get offset and size of the section in image""" areas = fmap.fmap_decode(image)["areas"] area = next(area for area in areas if area["name"] == section) -- cgit v1.2.1 From 5873fd3836b28d954d2024ab8a14563bf209f5a3 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Wed, 23 Nov 2022 13:43:38 -0700 Subject: tcpm_header: add missing RESET_FAKE calls Each mock should be reset before each test to guarantee its state. That was missing from some of these fakes. BUG=none BRANCH=none TEST=twister Signed-off-by: Clayton Whitelaw Change-Id: Ie10fe951d07d278147c4fda2c46da5c922eb8af3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052765 Code-Coverage: Zoss Reviewed-by: Simon Glass --- zephyr/test/drivers/default/src/tcpm_header.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c index 9fe80da15b..e84a3e7ad4 100644 --- a/zephyr/test/drivers/default/src/tcpm_header.c +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -137,6 +137,9 @@ static void tcpm_header_before(void *state) RESET_FAKE(set_vconn); RESET_FAKE(reset_bist_type_2); + RESET_FAKE(debug_accessory); + RESET_FAKE(debug_detach); + RESET_FAKE(hard_reset_reinit); fixture->mock_driver = (struct tcpm_drv){ 0 }; fixture->saved_driver_ptr = tcpc_config[TCPM_TEST_PORT].drv; -- cgit v1.2.1 From 2e3437828d0b50f8934f5e9bda94e5d29a7c4460 Mon Sep 17 00:00:00 2001 From: Andrew McRae Date: Wed, 23 Nov 2022 11:29:46 +1100 Subject: nissa: Configure mux resets for ANX7483 The ANX7483 is only turned on in S5 state and higher, and will default to a high power consumption state. Following the skyrim change, set the flag to indicate that the mux resets in G3 to ensure the USB mux code resets it to None. BUG=none TEST=Check on nivviks that the control register is set to the correct value (same as at startup) after the AP goes to G3 and is then rebooted. BRANCH=none Signed-off-by: Andrew McRae Change-Id: I011bcb32028de85153e4c738da999e40624a22ef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050001 Code-Coverage: Zoss Reviewed-by: Peter Marheine --- zephyr/program/nissa/craask/overlay.dtsi | 2 ++ zephyr/program/nissa/nivviks/overlay.dtsi | 2 ++ zephyr/program/nissa/xivu/overlay.dtsi | 2 ++ 3 files changed, 6 insertions(+) diff --git a/zephyr/program/nissa/craask/overlay.dtsi b/zephyr/program/nissa/craask/overlay.dtsi index cbfda0263e..59a85d818e 100644 --- a/zephyr/program/nissa/craask/overlay.dtsi +++ b/zephyr/program/nissa/craask/overlay.dtsi @@ -4,6 +4,7 @@ */ #include +#include / { aliases { @@ -356,6 +357,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "anx7483_set_default_tuning"; + flags = ; }; }; diff --git a/zephyr/program/nissa/nivviks/overlay.dtsi b/zephyr/program/nissa/nivviks/overlay.dtsi index c2d5e3f24b..0875b8891d 100644 --- a/zephyr/program/nissa/nivviks/overlay.dtsi +++ b/zephyr/program/nissa/nivviks/overlay.dtsi @@ -4,6 +4,7 @@ */ #include +#include / { aliases { @@ -371,6 +372,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "anx7483_set_default_tuning"; + flags = ; }; }; diff --git a/zephyr/program/nissa/xivu/overlay.dtsi b/zephyr/program/nissa/xivu/overlay.dtsi index 73cc10e801..f5ea6bc258 100644 --- a/zephyr/program/nissa/xivu/overlay.dtsi +++ b/zephyr/program/nissa/xivu/overlay.dtsi @@ -4,6 +4,7 @@ */ #include +#include / { aliases { @@ -340,6 +341,7 @@ compatible = "analogix,anx7483"; reg = <0x3e>; board-set = "anx7483_set_default_tuning"; + flags = ; }; }; -- cgit v1.2.1 From b750641442105d9e5c0a08148d80965d628716a0 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Mon, 21 Nov 2022 15:43:36 -0700 Subject: test: i2c_controller: i2c_write16 Add a test for the big-endian path for the i2c_write16() function. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I08cae4b3fdedfe9516d3846dd01085c9fb2d3757 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045152 Code-Coverage: Zoss Reviewed-by: Aaron Massey --- .../drivers/i2c_controller/src/i2c_controller.c | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c index 987e4ca042..44ee197576 100644 --- a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c +++ b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c @@ -61,6 +61,29 @@ ZTEST_F(i2c_controller, write_read32_be) expected); } +ZTEST_F(i2c_controller, write_read16_be) +{ + uint16_t expected = 0x1122; + int actual; + + zassert_ok(i2c_write16(fixture->port, + fixture->addr | I2C_FLAG_BIG_ENDIAN, 0, + expected)); + + /* Get the first two bytes of the register space as a uint16_t */ + actual = __bswap_16(*((uint16_t *)&fixture->emul_data->regs[0])); + + zassert_equal(expected, actual, "got %04x, expected %08x", actual, + expected); + + /* Now read back through I2C API */ + zassert_ok(i2c_read16(fixture->port, + fixture->addr | I2C_FLAG_BIG_ENDIAN, 0, &actual)); + + zassert_equal(expected, actual, "got %04x, expected %04x", + (uint16_t)actual, expected); +} + ZTEST_F(i2c_controller, read32_fail) { int ret; -- cgit v1.2.1 From 5b567a785489cd28c4ef585e1a4fb6ece46bf3f4 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Mon, 21 Nov 2022 16:38:11 -0700 Subject: test: i2c_controller: Verify i2c_field_update16() errors Verify the error path for i2c_field_update16(). BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I6efb4742baafa881066e910a3fcbc16341874332 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045153 Code-Coverage: Zoss Reviewed-by: Yuval Peress --- zephyr/test/drivers/i2c_controller/src/i2c_controller.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c index 44ee197576..e58aad0903 100644 --- a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c +++ b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c @@ -121,6 +121,14 @@ ZTEST_F(i2c_controller, field_update16) zassert_equal(set_value, actual, "got %04x, expected %04x", actual, set_value); + + /* Force a failure */ + set_value = 0x0001; + mask = 0x0001; + i2c_common_emul_set_read_fail_reg(&fixture->emul_data->common, 0); + zassert_equal(i2c_field_update16(fixture->port, fixture->addr, 0, mask, + set_value), + EC_ERROR_INVAL); } ZTEST_F(i2c_controller, read_offset16__one_byte) -- cgit v1.2.1 From 5dd8dc90c1e8cb099a42eaa87d71774980b1a6ad Mon Sep 17 00:00:00 2001 From: Keith Short Date: Tue, 22 Nov 2022 10:45:21 -0700 Subject: i2c_controller: Add guard for PEC transfers One path in the code was missing a guard checking CONFIG_SMBUS_PEC before checking the I2C_USE_PEC. The gcc optimizer already removed this code when CONFIG_SMBUS_PEC=n, but the coverage tool thought this path was executable. BUG=none BRANCH=none TEST=twister TEST=zmake compare-builds herobrine Signed-off-by: Keith Short Change-Id: I9c5f95982ba7428fd190f98e16801886bc8aedeb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049220 Reviewed-by: Sam Hurst Code-Coverage: Zoss --- common/i2c_controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/i2c_controller.c b/common/i2c_controller.c index b51f726369..e938dc0f8f 100644 --- a/common/i2c_controller.c +++ b/common/i2c_controller.c @@ -833,7 +833,7 @@ int i2c_write_block(const int port, const uint16_t addr_flags, int offset, if (rv) continue; - if (I2C_USE_PEC(addr_flags)) { + if (IS_ENABLED(CONFIG_SMBUS_PEC) && I2C_USE_PEC(addr_flags)) { rv = i2c_xfer_unlocked(port, addr_flags, data, len, NULL, 0, 0); if (rv) -- cgit v1.2.1 From c137fc572c065f5b484729d95b63c5f88bc2bb83 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Tue, 22 Nov 2022 12:15:09 -0700 Subject: test: i2c_passthru: Verify CONFIG_I2C_PASSTHRU_RESTRICTED Verify I2C passthru commands are rejected when the CONFIG_I2C_PASSTHRU_RESTRICTED option is enabled. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: If6a5e024d91a65d87362025da6c1bc0e70b212f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4048915 Reviewed-by: Simon Glass Code-Coverage: Zoss Reviewed-by: Tristan Honscheid --- zephyr/test/drivers/default/src/i2c_passthru.c | 123 ++++++++++++++++++++++++- zephyr/test/drivers/testcase.yaml | 3 + 2 files changed, 124 insertions(+), 2 deletions(-) diff --git a/zephyr/test/drivers/default/src/i2c_passthru.c b/zephyr/test/drivers/default/src/i2c_passthru.c index d06e0ffffa..afefc4b553 100644 --- a/zephyr/test/drivers/default/src/i2c_passthru.c +++ b/zephyr/test/drivers/default/src/i2c_passthru.c @@ -13,6 +13,15 @@ #include #include +FAKE_VALUE_FUNC(int, board_allow_i2c_passthru, const struct i2c_cmd_desc_t *); + +int board_allow_i2c_passthru_custom_fake(const struct i2c_cmd_desc_t *cmd_desc) +{ + /* Only allow passthru on I2C_PORT_USB_C0 */ + return i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_USB_C0); +} + ZTEST_USER(i2c_passthru, test_read_without_write) { uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) + @@ -209,11 +218,121 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs) EC_RES_ACCESS_DENIED); } +ZTEST_USER(i2c_passthru, test_passthru_restricted) +{ + uint16_t tcpc_addr = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)); + uint16_t ps8xxx_addr = DT_REG_ADDR(DT_NODELABEL(ps8xxx_emul)); + uint8_t *out_data; + uint8_t tcpc_param_buf[sizeof(struct ec_params_i2c_passthru) + + 2 * sizeof(struct ec_params_i2c_passthru_msg) + + 1]; + uint8_t tcpc_rsp_buf[sizeof(struct ec_response_i2c_passthru) + 2]; + struct ec_params_i2c_passthru *tcpc_params = + (struct ec_params_i2c_passthru *)&tcpc_param_buf; + struct ec_response_i2c_passthru *tcpc_response = + (struct ec_response_i2c_passthru *)&tcpc_rsp_buf; + struct host_cmd_handler_args tcpc_args = + BUILD_HOST_COMMAND_SIMPLE(EC_CMD_I2C_PASSTHRU, 0); + + uint8_t ps8xxx_param_buf[sizeof(struct ec_params_i2c_passthru) + + 2 * sizeof(struct ec_params_i2c_passthru_msg) + + 1]; + uint8_t ps8xxx_rsp_buf[sizeof(struct ec_response_i2c_passthru) + 2]; + struct ec_params_i2c_passthru *ps8xxx_params = + (struct ec_params_i2c_passthru *)&ps8xxx_param_buf; + struct ec_response_i2c_passthru *ps8xxx_response = + (struct ec_response_i2c_passthru *)&ps8xxx_rsp_buf; + struct host_cmd_handler_args ps8xxx_args = + BUILD_HOST_COMMAND_SIMPLE(EC_CMD_I2C_PASSTHRU, 0); + + if (!IS_ENABLED(CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED)) { + ztest_test_skip(); + return; + } + + /* + * Setup passthru command to the TCPCI emulator - which is always + * permitted by our board_allow_i2c_passthru() fake. + */ + tcpc_params->port = I2C_PORT_USB_C0; + tcpc_params->num_msgs = 2; + tcpc_params->msg[0].addr_flags = tcpc_addr; + tcpc_params->msg[0].len = 1; + tcpc_params->msg[1].addr_flags = tcpc_addr | EC_I2C_FLAG_READ; + tcpc_params->msg[1].len = 2; /* 2 byte vendor ID */ + + /* Write data follows the passthru messages */ + out_data = (uint8_t *)&tcpc_params->msg[2]; + out_data[0] = 0; /* TCPC_REG_VENDOR_ID 0x0 */ + + tcpc_args.params = &tcpc_param_buf; + tcpc_args.params_size = sizeof(tcpc_param_buf); + tcpc_args.response = &tcpc_rsp_buf; + tcpc_args.response_max = sizeof(tcpc_rsp_buf); + + /* + * Setup passthru command to the PS8xxx emulator, which should be + * rejected when the system is locked. + */ + ps8xxx_params->port = I2C_PORT_USB_C1; + ps8xxx_params->num_msgs = 2; + ps8xxx_params->msg[0].addr_flags = ps8xxx_addr; + ps8xxx_params->msg[0].len = 1; + ps8xxx_params->msg[1].addr_flags = ps8xxx_addr | EC_I2C_FLAG_READ; + ps8xxx_params->msg[1].len = 2; /* 2-byte vendor ID */ + + /* Write data follows the passthru messages */ + out_data = (uint8_t *)&ps8xxx_params->msg[2]; + out_data[0] = 0; /* TCPC_REG_VENDOR_ID 0x0 */ + + ps8xxx_args.params = &ps8xxx_param_buf; + ps8xxx_args.params_size = sizeof(ps8xxx_param_buf); + ps8xxx_args.response = &ps8xxx_rsp_buf; + ps8xxx_args.response_max = sizeof(ps8xxx_rsp_buf); + + /* Install our board_allow_i2c_passthru() handler */ + board_allow_i2c_passthru_fake.custom_fake = + board_allow_i2c_passthru_custom_fake; + + /* When the system is unlocked, no restrictions apply */ + system_is_locked_fake.return_val = false; + + zassert_ok(host_command_process(&tcpc_args)); + zassert_ok(tcpc_args.result); + zassert_ok(tcpc_response->i2c_status); + zassert_equal(tcpc_args.response_size, + sizeof(struct ec_response_i2c_passthru) + 2, NULL); + + zassert_ok(host_command_process(&ps8xxx_args)); + zassert_ok(ps8xxx_args.result); + zassert_ok(ps8xxx_response->i2c_status); + zassert_equal(ps8xxx_args.response_size, + sizeof(struct ec_response_i2c_passthru) + 2, NULL); + + /* Lock the system which enables board_allow_i2c_passthru() */ + system_is_locked_fake.return_val = true; + + zassert_ok(host_command_process(&tcpc_args)); + zassert_ok(tcpc_args.result); + zassert_ok(tcpc_response->i2c_status); + zassert_equal(tcpc_args.response_size, + sizeof(struct ec_response_i2c_passthru) + 2, NULL); + + zassert_equal(host_command_process(&ps8xxx_args), EC_RES_ACCESS_DENIED); +} + +static void i2c_passthru_before(void *state) +{ + ARG_UNUSED(state); + RESET_FAKE(board_allow_i2c_passthru); + board_allow_i2c_passthru_fake.return_val = 1; +} + static void i2c_passthru_after(void *state) { ARG_UNUSED(state); i2c_passthru_protect_reset(); } -ZTEST_SUITE(i2c_passthru, drivers_predicate_post_main, NULL, NULL, - i2c_passthru_after, NULL); +ZTEST_SUITE(i2c_passthru, drivers_predicate_post_main, NULL, + i2c_passthru_before, i2c_passthru_after, NULL); diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index f3de4507cd..f74289086a 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -11,6 +11,7 @@ tests: - CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y - CONFIG_PLATFORM_EC_USB_PD_DPS=y + - CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y drivers.default.bring_up: timeout: 240 extra_args: CONF_FILE="prj.conf;default/prj.conf" @@ -22,6 +23,7 @@ tests: - CONFIG_PLATFORM_EC_BRINGUP=y - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y - CONFIG_PLATFORM_EC_USB_PD_DPS=y + - CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y drivers.default.mock_power: timeout: 240 extra_args: CONF_FILE="prj.conf;default/prj.conf" @@ -33,6 +35,7 @@ tests: - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y - CONFIG_POWER_SEQUENCE_MOCK=y - CONFIG_PLATFORM_EC_USB_PD_DPS=y + - CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y drivers.anx7447: extra_args: CONF_FILE="prj.conf;anx7447/prj.conf" DTC_OVERLAY_FILE="./boards/native_posix.overlay;./anx7447/tcpc_policy.dts" extra_configs: -- cgit v1.2.1 From 9b5fb3a59f1f062c74846676aa23e8e5ed8bb940 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Tue, 22 Nov 2022 12:59:29 -0700 Subject: test: i2c: Verify I2C transfers with PEC rejected Verify that I2C transfers with PEC (packet error checking) are rejected when CONFIG_PLATFORM_EC_SMBUS_PEC=n. BUG=none BRANCH=none TEST=twister Signed-off-by: Keith Short Change-Id: I6897ba3f65f28356a91f84bd872fcd013fa7b358 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4048916 Reviewed-by: Jeremy Bettis Code-Coverage: Zoss --- .../drivers/i2c_controller/src/i2c_controller.c | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c index e58aad0903..594c3e6888 100644 --- a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c +++ b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c @@ -304,6 +304,48 @@ ZTEST_F(i2c_controller, write_offset16_block) expected); } +ZTEST_F(i2c_controller, pec_disabled) +{ + uint16_t addr_flags; + uint8_t write_data[] = { + 0xAA, + 0xBB, + 0xCC, + 0xDD, + }; + int write_data32 = 0x11223344; + uint8_t read_data[4]; + int actual_read_len; + uint16_t reg = 0x01; + + /* + * Verify I2C reads and writes through the various APIs fail when + * CONFIG_PLATFORM_EC_SMBUS_PEC=n + */ + if (IS_ENABLED(CONFIG_PLATFORM_EC_SMBUS_PEC)) { + ztest_test_skip(); + return; + } + + addr_flags = fixture->addr | I2C_FLAG_PEC; + + zassert_equal(i2c_read32(fixture->port, addr_flags, reg, + (int *)read_data), + EC_ERROR_UNIMPLEMENTED); + zassert_equal(i2c_write32(fixture->port, addr_flags, reg, write_data32), + EC_ERROR_UNIMPLEMENTED); + zassert_equal(i2c_read_sized_block(fixture->port, addr_flags, reg, + read_data, sizeof(read_data), + &actual_read_len), + EC_ERROR_UNIMPLEMENTED); + zassert_equal(i2c_read_sized_block(fixture->port, addr_flags, reg, + read_data, 0, &actual_read_len), + EC_ERROR_INVAL); + zassert_equal(i2c_write_block(fixture->port, addr_flags, reg, + write_data, sizeof(write_data)), + EC_ERROR_UNIMPLEMENTED); +} + ZTEST_F(i2c_controller, i2c_xfer_unlocked__error_paths) { uint8_t out_buffer[1]; -- cgit v1.2.1 From d6a129f6bff2021ad787f7bf298252b2407edbb7 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Wed, 23 Nov 2022 23:33:43 +0000 Subject: Revert "zephyr: Remove CONFIG_PLATFORM_EC_WATCHDOG" This reverts commit e04250319d222ef8505d9111ba4f03eddcaf5521. Reason for revert: Breaks drallion builds. b:260270232 Original change's description: > zephyr: Remove CONFIG_PLATFORM_EC_WATCHDOG > > Remove CONFIG_PLATFORM_EC_WATCHDOG. Use Zephyr's CONFIG_WATCHDOG option > instead. > > BUG=b:217926701 > BRANCH=none > TEST=twister -T zephyr/test/ > TEST=zmake compare-builds -a > LOW_COVERAGE_REASON=watchdog_init test not yet implemented > > Signed-off-by: Mark Hasemeyer > > Change-Id: I7d5fedfc72ed886f94a94df9d3db14224bc6fb75 > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050634 > Reviewed-by: Keith Short > Reviewed-by: Aaron Massey > Tested-by: Mark Hasemeyer > Commit-Queue: Mark Hasemeyer Bug: b:217926701 Change-Id: I01471b9544cc0792427b3ca6761fb07ee0432dc6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4053682 Commit-Queue: Piotr Pawliczek Commit-Queue: Keith Short Reviewed-by: Piotr Pawliczek Tested-by: Keith Short Owners-Override: Piotr Pawliczek --- zephyr/Kconfig | 17 +++++++++++++++++ zephyr/Kconfig.watchdog | 4 ++-- zephyr/app/ec/ec_app_main.c | 2 +- zephyr/drivers/cros_flash/cros_flash_it8xxx2.c | 4 ++-- zephyr/shim/src/CMakeLists.txt | 2 +- zephyr/test/ec_app/src/main.c | 2 +- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index b60e87d10e..9e04f4a679 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -741,6 +741,23 @@ config PLATFORM_EC_VSTORE_SLOT_COUNT used only for recording a hash of the read-write AP firmware for checking on resume. For this, one slot is enough. +menuconfig PLATFORM_EC_WATCHDOG + bool "Watchdog" + depends on WATCHDOG + default y + help + Enable the watchdog functionality. The watchdog timer will reboot the + system if the hook task (which is the lowest-priority task on the + system) gets starved for CPU time and isn't able to fire its + HOOK_TICK event. + + Chromium EC system uses an auxiliary timer to handle the system + warning event. This leaves some time to the system for preparing & + printing the debug information. The interval between reloads of the + watchdog timer should be less than half of the auxiliary timer + (PLATFORM_EC_WATCHDOG_PERIOD_MS - + PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS). + config PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API bool "Workaround needed for npcx9 ES1 chip" depends on SOC_SERIES_NPCX9 diff --git a/zephyr/Kconfig.watchdog b/zephyr/Kconfig.watchdog index 653cc58e22..f6c9002233 100644 --- a/zephyr/Kconfig.watchdog +++ b/zephyr/Kconfig.watchdog @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -if WATCHDOG +if PLATFORM_EC_WATCHDOG config PLATFORM_EC_WATCHDOG_PERIOD_MS int "Watchdog timeout in ms" @@ -27,4 +27,4 @@ config PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS For the ITE chip, use CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS instead of this config. -endif # WATCHDOG +endif # PLATFORM_EC_WATCHDOG diff --git a/zephyr/app/ec/ec_app_main.c b/zephyr/app/ec/ec_app_main.c index 961e4f5ce2..4ab5fd3a44 100644 --- a/zephyr/app/ec/ec_app_main.c +++ b/zephyr/app/ec/ec_app_main.c @@ -37,7 +37,7 @@ void ec_app_main(void) system_print_banner(); - if (IS_ENABLED(CONFIG_WATCHDOG) && + if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG) && !IS_ENABLED(CONFIG_WDT_DISABLE_AT_BOOT)) { watchdog_init(); } diff --git a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c index 2d34a21523..79ef0c36b2 100644 --- a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c +++ b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c @@ -180,7 +180,7 @@ static int cros_flash_it8xxx2_write(const struct device *dev, int offset, * chance to go back to hook task to touch watchdog. Reload watchdog * on each flash write to prevent the reset. */ - if (IS_ENABLED(CONFIG_WATCHDOG)) + if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG)) watchdog_reload(); return flash_write(flash_controller, offset, src_data, size); @@ -223,7 +223,7 @@ static int cros_flash_it8xxx2_erase(const struct device *dev, int offset, * If requested erase size is too large at one time on KGD * flash, we need to reload watchdog to prevent the reset. */ - if (IS_ENABLED(CONFIG_WATCHDOG) && (size > 0x10000)) + if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG) && (size > 0x10000)) watchdog_reload(); } /* Restore interrupts */ diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 62697db096..543c2b2303 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -63,7 +63,7 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR temp_sensors.c zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TIMER hwtimer.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C i2c.c) zephyr_library_sources_ifdef(CONFIG_SHIMMED_TASKS tasks.c) -zephyr_library_sources_ifdef(CONFIG_WATCHDOG watchdog.c) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_WATCHDOG watchdog.c) zephyr_library_sources_ifndef(CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER bc12.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201 diff --git a/zephyr/test/ec_app/src/main.c b/zephyr/test/ec_app/src/main.c index 52a19f131c..3c317d2a08 100644 --- a/zephyr/test/ec_app/src/main.c +++ b/zephyr/test/ec_app/src/main.c @@ -46,7 +46,7 @@ ZTEST(ec_app_tests, test_setup_espi) } #endif -#ifdef CONFIG_WATCHDOG +#ifdef CONFIG_PLATFORM_EC_WATCHDOG ZTEST(ec_app_tests, test_watchdog_init) { zassert_unreachable("TODO: Implement this test."); -- cgit v1.2.1 From 667d7d7129a1d3d7b33046755030ec5fdce1ac32 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 9 Nov 2022 15:54:10 -0800 Subject: dp-alt-mode: add safety check Prevent possible NULL dereference BUG=b:64477774 BRANCH=none TEST=make buildall LOW_COVERAGE_REASON=No unit test infrastructure for this module Signed-off-by: Boris Mittelberg Change-Id: I1e42037d09ae41b8fc9acc611dd9fe2811e7f620 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4018490 Code-Coverage: Zoss Reviewed-by: Diana Z --- common/usbc/dp_alt_mode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/usbc/dp_alt_mode.c b/common/usbc/dp_alt_mode.c index f53d212b91..1fb99fd797 100644 --- a/common/usbc/dp_alt_mode.c +++ b/common/usbc/dp_alt_mode.c @@ -306,13 +306,13 @@ enum dpm_msg_setup_status dp_setup_next_vdm(int port, int *vdo_count, * this doesn't set up the VDM, it clears state. * TODO(b/159856063): Clean up the API to the fx functions. */ - if (!(modep && modep->opos)) - return MSG_SETUP_ERROR; - usb_mux_set_safe_mode_exit(port); dp_state[port] = DP_PREPARE_EXIT; return MSG_SETUP_MUX_WAIT; case DP_PREPARE_EXIT: + if (!(modep && modep->opos)) + return MSG_SETUP_ERROR; + /* DPM should call setup only after safe state is set */ vdm[0] = VDO(USB_SID_DISPLAYPORT, 1, /* structured */ CMD_EXIT_MODE); -- cgit v1.2.1 From 43b53e004573a56a255ca57d4a6d04ac4bed44d7 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Mon, 14 Nov 2022 11:53:32 +1100 Subject: Add default implementation of board_set_charge_limit The majority of boards simply call charge_set_input_current_limit() from board_set_charge_limit() now that the minimum current limit and derating are available as config options. Make this the default behavior of the charge manager, overridable by boards as needed. Boards that have existing custom behavior retain it, with their versions of board_set_charge_limit() marked as __override as necessary. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none Signed-off-by: Peter Marheine Change-Id: I72475ca0e8381596cafbcda4b042c7f884ae0432 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022857 Reviewed-by: Keith Short --- baseboard/asurada/usbc_config.c | 6 ------ baseboard/goroh/baseboard.c | 6 ------ baseboard/grunt/baseboard.c | 6 ------ baseboard/guybrush/baseboard.c | 6 ------ baseboard/hatch/baseboard.c | 6 ------ baseboard/intelrvp/chg_usb_pd.c | 6 ------ baseboard/kukui/charger_mt6370.c | 4 ++-- baseboard/octopus/baseboard.c | 6 ------ baseboard/volteer/charger.c | 6 ------ baseboard/zork/baseboard.c | 6 ------ board/agah/charger_isl9241.c | 6 ------ board/ambassador/board.c | 4 ++-- board/anahera/charger.c | 6 ------ board/atlas/board.c | 14 -------------- board/banshee/charger.c | 6 ------ board/beadrix/board.c | 11 ----------- board/beetley/board.c | 6 ------ board/bellis/board.c | 6 ------ board/blipper/board.c | 6 ------ board/boten/board.c | 6 ------ board/brask/led.c | 4 ++-- board/brya/charger.c | 6 ------ board/bugzzy/board.c | 6 ------ board/burnet/board.c | 6 ------ board/cappy2/board.c | 6 ------ board/cerise/board.c | 6 ------ board/cherry/board.c | 6 ------ board/coachz/board.c | 4 ++-- board/coral/board.c | 4 ++-- board/corori/board.c | 6 ------ board/corori2/board.c | 6 ------ board/cret/board.c | 6 ------ board/crota/charger.c | 6 ------ board/damu/board.c | 6 ------ board/dibbi/board.c | 10 ---------- board/dojo/board.c | 4 ++-- board/dooly/board.c | 4 ++-- board/drawcia/board.c | 4 ++-- board/drawcia_riscv/board.c | 4 ++-- board/driblee/board.c | 6 ------ board/drobit/board.c | 8 -------- board/elm/board.c | 4 ++-- board/eve/board.c | 4 ++-- board/ezkinil/board.c | 6 ------ board/felwinter/charger_isl9241.c | 6 ------ board/fennel/board.c | 6 ------ board/fizz/board.c | 4 ++-- board/gaelin/led.c | 4 ++-- board/galtic/board.c | 10 ---------- board/gelarshie/board.c | 4 ++-- board/gimble/charger.c | 6 ------ board/gooey/board.c | 6 ------ board/haboki/board.c | 4 ++-- board/herobrine/usbc_config.c | 4 ++-- board/homestar/board.c | 4 ++-- board/icarus/board.c | 6 ------ board/jacuzzi/board.c | 6 ------ board/kano/charger.c | 6 ------ board/kappa/board.c | 6 ------ board/kingoftown/usbc_config.c | 4 ++-- board/kinox/board.c | 4 ++-- board/kracko/board.c | 4 ++-- board/kuldax/led.c | 4 ++-- board/lalala/board.c | 6 ------ board/lantis/board.c | 10 ---------- board/lazor/usbc_config.c | 4 ++-- board/lisbon/led.c | 4 ++-- board/madoo/board.c | 6 ------ board/magolor/board.c | 6 ------ board/makomo/board.c | 6 ------ board/marzipan/board.c | 4 ++-- board/mchpevb1/board.c | 14 -------------- board/metaknight/board.c | 6 ------ board/mithrax/charger_isl9241.c | 6 ------ board/moli/led.c | 4 ++-- board/mrbland/board.c | 4 ++-- board/munna/board.c | 6 ------ board/nami/board.c | 4 ++-- board/nautilus/board.c | 14 -------------- board/nocturne/board.c | 6 ------ board/oak/board.c | 4 ++-- board/osiris/charger.c | 6 ------ board/pazquel/board.c | 4 ++-- board/pico/board.c | 6 ------ board/pirika/board.c | 10 ---------- board/pompom/board.c | 4 ++-- board/poppy/board.c | 4 ++-- board/puff/board.c | 4 ++-- board/quackingstick/board.c | 4 ++-- board/rainier/board.c | 4 ++-- board/rammus/board.c | 14 -------------- board/redrix/charger.c | 6 ------ board/reef/board.c | 4 ++-- board/reef_it8320/board.c | 4 ++-- board/reef_mchp/board.c | 4 ++-- board/sasuke/board.c | 6 ------ board/sasukette/board.c | 6 ------ board/scarlet/board.c | 6 ------ board/servo_v4/usb_pd_policy.c | 4 ++-- board/servo_v4p1/usb_pd_policy.c | 4 ++-- board/shotzo/board.c | 4 ++-- board/stern/board.c | 6 ------ board/storo/board.c | 6 ------ board/taeko/charger.c | 6 ------ board/taniks/charger.c | 6 ------ board/trogdor/usbc_config.c | 4 ++-- board/vell/charger.c | 6 ------ board/vilboz/board.c | 6 ------ board/volmar/charger.c | 6 ------ board/waddledee/board.c | 10 ---------- board/waddledoo/board.c | 6 ------ board/waddledoo2/board.c | 6 ------ board/wheelie/board.c | 10 ---------- board/willow/board.c | 6 ------ board/wormdingler/board.c | 4 ++-- common/charge_manager.c | 8 ++++++++ include/charge_manager.h | 9 +++++++-- test/charge_manager.c | 4 ++-- test/charge_ramp.c | 4 ++-- zephyr/program/corsola/src/usbc_config.c | 6 ------ zephyr/program/herobrine/src/usbc_config.c | 4 ++-- zephyr/program/intelrvp/src/chg_usb_pd.c | 6 ------ zephyr/program/nissa/src/common.c | 6 ------ zephyr/program/rex/src/usbc_config.c | 6 ------ zephyr/program/skyrim/src/usbc_config.c | 6 ------ zephyr/program/trogdor/lazor/src/usbc_config.c | 4 ++-- zephyr/test/drivers/common/src/stubs.c | 6 ------ zephyr/test/krabby/src/stubs.c | 4 ++-- zephyr/test/vboot_efs2/src/main.c | 4 ++-- 129 files changed, 111 insertions(+), 635 deletions(-) diff --git a/baseboard/asurada/usbc_config.c b/baseboard/asurada/usbc_config.c index 57396121f5..89b027124e 100644 --- a/baseboard/asurada/usbc_config.c +++ b/baseboard/asurada/usbc_config.c @@ -308,12 +308,6 @@ void board_reset_pd_mcu(void) */ } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) { /* diff --git a/baseboard/goroh/baseboard.c b/baseboard/goroh/baseboard.c index d1474f78a7..3ad5eda917 100644 --- a/baseboard/goroh/baseboard.c +++ b/baseboard/goroh/baseboard.c @@ -160,12 +160,6 @@ const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port) return &cc_parameter[port]; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) { /* diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c index aef91f5e30..6c2fbc2046 100644 --- a/baseboard/grunt/baseboard.c +++ b/baseboard/grunt/baseboard.c @@ -464,12 +464,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - /* Keyboard scan setting */ __override struct keyboard_scan_config keyscan_config = { /* diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c index b8b4b775a6..c79d14cf6d 100644 --- a/baseboard/guybrush/baseboard.c +++ b/baseboard/guybrush/baseboard.c @@ -534,12 +534,6 @@ int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) return rv; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - void sbu_fault_interrupt(enum ioex_signal signal) { int port = (signal == IOEX_USB_C0_SBU_FAULT_ODL) ? 0 : 1; diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c index 9910f21880..b4e37e6bc8 100644 --- a/baseboard/hatch/baseboard.c +++ b/baseboard/hatch/baseboard.c @@ -348,12 +348,6 @@ int ppc_get_alert_status(int port) #endif } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - #ifdef USB_PD_PORT_TCPC_MST void baseboard_mst_enable_control(enum mst_source src, int level) { diff --git a/baseboard/intelrvp/chg_usb_pd.c b/baseboard/intelrvp/chg_usb_pd.c index 9fa7c60f44..c4ae3ea72d 100644 --- a/baseboard/intelrvp/chg_usb_pd.c +++ b/baseboard/intelrvp/chg_usb_pd.c @@ -125,9 +125,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/baseboard/kukui/charger_mt6370.c b/baseboard/kukui/charger_mt6370.c index 398473bfc8..eb94397fdb 100644 --- a/baseboard/kukui/charger_mt6370.c +++ b/baseboard/kukui/charger_mt6370.c @@ -355,8 +355,8 @@ DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE, board_charge_termination, HOOK_PRIO_DEFAULT); #endif -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { prev_charge_limit = charge_ma; prev_charge_mv = charge_mv; diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c index c852d1fad5..164e28b480 100644 --- a/baseboard/octopus/baseboard.c +++ b/baseboard/octopus/baseboard.c @@ -298,12 +298,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - void board_hibernate(void) { int port; diff --git a/baseboard/volteer/charger.c b/baseboard/volteer/charger.c index 252e8795d3..17f1fe5f7d 100644 --- a/baseboard/volteer/charger.c +++ b/baseboard/volteer/charger.c @@ -80,12 +80,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - void board_overcurrent_event(int port, int is_overcurrented) { /* Note that the level is inverted because the pin is active low. */ diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c index 0ad8339591..dcf16cf7c6 100644 --- a/baseboard/zork/baseboard.c +++ b/baseboard/zork/baseboard.c @@ -96,12 +96,6 @@ static void baseboard_chipset_resume(void) } DECLARE_HOOK(HOOK_CHIPSET_RESUME, baseboard_chipset_resume, HOOK_PRIO_DEFAULT); -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - /* Keyboard scan setting */ __override struct keyboard_scan_config keyscan_config = { /* diff --git a/board/agah/charger_isl9241.c b/board/agah/charger_isl9241.c index 64ad9ae7f7..d5f3d1a0b4 100644 --- a/board/agah/charger_isl9241.c +++ b/board/agah/charger_isl9241.c @@ -196,12 +196,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - static const struct charge_port_info bj_power = { /* 150W (also default) */ .voltage = 19500, diff --git a/board/ambassador/board.c b/board/ambassador/board.c index f2bc7557ec..3eff9215bc 100644 --- a/board/ambassador/board.c +++ b/board/ambassador/board.c @@ -88,8 +88,8 @@ uint16_t tcpc_get_alert_status(void) } /* Called when the charge manager has switched to a new port. */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Blink alert if insufficient power per system_can_boot_ap(). */ int insufficient_power = diff --git a/board/anahera/charger.c b/board/anahera/charger.c index 6b45881b99..7fabd2082e 100644 --- a/board/anahera/charger.c +++ b/board/anahera/charger.c @@ -81,9 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/atlas/board.c b/board/atlas/board.c index 685afb3e0e..d2562d43d3 100644 --- a/board/atlas/board.c +++ b/board/atlas/board.c @@ -540,20 +540,6 @@ static void board_charger_init(void) } DECLARE_HOOK(HOOK_INIT, board_charger_init, HOOK_PRIO_DEFAULT); -/** - * Set the charge limit based upon desired maximum. - * - * @param port Port number. - * @param supplier Charge supplier type. - * @param charge_ma Desired charge limit (mA). - * @param charge_mv Negotiated charge voltage (mV). - */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - static void board_chipset_suspend(void) { gpio_set_level(GPIO_KBD_BL_EN, 0); diff --git a/board/banshee/charger.c b/board/banshee/charger.c index 8edcb00e31..7a16fcd5cb 100644 --- a/board/banshee/charger.c +++ b/board/banshee/charger.c @@ -79,9 +79,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/beadrix/board.c b/board/beadrix/board.c index 14467a66a1..24c6cb960e 100644 --- a/board/beadrix/board.c +++ b/board/beadrix/board.c @@ -474,17 +474,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -/* Vconn control for integrated ITE TCPC */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * TODO(b/151955431): Characterize the input current limit in case a - * scaling needs to be applied here - */ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT) diff --git a/board/beetley/board.c b/board/beetley/board.c index 28ae90fc9b..89a1d6b13f 100644 --- a/board/beetley/board.c +++ b/board/beetley/board.c @@ -384,12 +384,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/bellis/board.c b/board/bellis/board.c index fb9701e4e7..3acdb66e4f 100644 --- a/board/bellis/board.c +++ b/board/bellis/board.c @@ -236,12 +236,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/blipper/board.c b/board/blipper/board.c index b31c5cde38..ce1bc27700 100644 --- a/board/blipper/board.c +++ b/board/blipper/board.c @@ -536,12 +536,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/boten/board.c b/board/boten/board.c index 14899b0a3a..fc70b11ada 100644 --- a/board/boten/board.c +++ b/board/boten/board.c @@ -244,12 +244,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/brask/led.c b/board/brask/led.c index 0a57994ca0..b86a291625 100644 --- a/board/brask/led.c +++ b/board/brask/led.c @@ -249,8 +249,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness) else return set_color(id, LED_OFF, 0); } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Blink alert if insufficient power per system_can_boot_ap(). */ int insufficient_power = diff --git a/board/brya/charger.c b/board/brya/charger.c index 937a48590c..7fabd2082e 100644 --- a/board/brya/charger.c +++ b/board/brya/charger.c @@ -81,9 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/bugzzy/board.c b/board/bugzzy/board.c index 6d30dba966..443f5f6d2f 100644 --- a/board/bugzzy/board.c +++ b/board/bugzzy/board.c @@ -393,12 +393,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/burnet/board.c b/board/burnet/board.c index b4a8860cf1..a89250ae34 100644 --- a/board/burnet/board.c +++ b/board/burnet/board.c @@ -222,12 +222,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/cappy2/board.c b/board/cappy2/board.c index eb33499eb0..7956ae77f5 100644 --- a/board/cappy2/board.c +++ b/board/cappy2/board.c @@ -229,12 +229,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/cerise/board.c b/board/cerise/board.c index 03c31b3ec9..9b214f2dae 100644 --- a/board/cerise/board.c +++ b/board/cerise/board.c @@ -236,12 +236,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/cherry/board.c b/board/cherry/board.c index 2f2f242b48..f8700404ed 100644 --- a/board/cherry/board.c +++ b/board/cherry/board.c @@ -262,12 +262,6 @@ const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { }, }; -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - /* Initialize board. */ static void board_init(void) { diff --git a/board/coachz/board.c b/board/coachz/board.c index a0f6dc74fc..4863cd94c9 100644 --- a/board/coachz/board.c +++ b/board/coachz/board.c @@ -684,8 +684,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/coral/board.c b/board/coral/board.c index 612ec180ae..a2a99ed42b 100644 --- a/board/coral/board.c +++ b/board/coral/board.c @@ -554,8 +554,8 @@ int board_set_active_charge_port(int charge_port) * @param charge_ma Desired charge limit (mA). * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Enable charging trigger by BC1.2 detection */ int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP || diff --git a/board/corori/board.c b/board/corori/board.c index 11d4ad8169..52ef76a19c 100644 --- a/board/corori/board.c +++ b/board/corori/board.c @@ -311,12 +311,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/corori2/board.c b/board/corori2/board.c index bc41f397ad..e3103f65ff 100644 --- a/board/corori2/board.c +++ b/board/corori2/board.c @@ -454,12 +454,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/cret/board.c b/board/cret/board.c index 17ecb3e7da..3c56757ef7 100644 --- a/board/cret/board.c +++ b/board/cret/board.c @@ -304,12 +304,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/crota/charger.c b/board/crota/charger.c index e46364ee6d..9f044790e0 100644 --- a/board/crota/charger.c +++ b/board/crota/charger.c @@ -79,9 +79,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/damu/board.c b/board/damu/board.c index 7c82182ce4..717276e768 100644 --- a/board/damu/board.c +++ b/board/damu/board.c @@ -236,12 +236,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/dibbi/board.c b/board/dibbi/board.c index f546c92c87..cba8bc64a4 100644 --- a/board/dibbi/board.c +++ b/board/dibbi/board.c @@ -232,16 +232,6 @@ uint16_t tcpc_get_alert_status(void) return 0; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * TODO(b/151955431): Characterize the input current limit in case a - * scaling needs to be applied here - */ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_set_active_charge_port(int port) { /* diff --git a/board/dojo/board.c b/board/dojo/board.c index fcc924770c..5c7db8b443 100644 --- a/board/dojo/board.c +++ b/board/dojo/board.c @@ -467,8 +467,8 @@ const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { }, }; -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Limit input current lower than 2944 mA for safety */ charge_ma = MIN(charge_ma, 2944); diff --git a/board/dooly/board.c b/board/dooly/board.c index 6e1f6ebbeb..9652de72c0 100644 --- a/board/dooly/board.c +++ b/board/dooly/board.c @@ -323,8 +323,8 @@ uint16_t tcpc_get_alert_status(void) } /* Called when the charge manager has switched to a new port. */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Blink alert if insufficient power per system_can_boot_ap(). */ int insufficient_power = diff --git a/board/drawcia/board.c b/board/drawcia/board.c index 325de31f5e..58def569be 100644 --- a/board/drawcia/board.c +++ b/board/drawcia/board.c @@ -610,8 +610,8 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Limit C1 on board version 0 to 2.0 A */ if ((board_version == 0) && (port == 1)) diff --git a/board/drawcia_riscv/board.c b/board/drawcia_riscv/board.c index f44be9ed7c..ba325aedc6 100644 --- a/board/drawcia_riscv/board.c +++ b/board/drawcia_riscv/board.c @@ -542,8 +542,8 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Limit C1 on board version 0 to 2.0 A */ if ((board_version == 0) && (port == 1)) diff --git a/board/driblee/board.c b/board/driblee/board.c index fd4c4bb573..05ec708ac5 100644 --- a/board/driblee/board.c +++ b/board/driblee/board.c @@ -338,12 +338,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/drobit/board.c b/board/drobit/board.c index b07e01d0fb..1d881d9a2c 100644 --- a/board/drobit/board.c +++ b/board/drobit/board.c @@ -475,11 +475,3 @@ static void board_chipset_suspend(void) gpio_set_level(GPIO_EC_KB_BL_EN, 0); } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); - -/******************************************************************************/ -/* Set the charge limit based upon desired maximum. */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/elm/board.c b/board/elm/board.c index 2e99a42b7c..f8621d086e 100644 --- a/board/elm/board.c +++ b/board/elm/board.c @@ -337,8 +337,8 @@ int board_set_active_charge_port(int charge_port) * @param charge_ma Desired charge limit (mA). * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { charge_set_input_current_limit(charge_ma, charge_mv); pd_send_host_event(PD_EVENT_POWER_CHANGE); diff --git a/board/eve/board.c b/board/eve/board.c index 9f89792818..96534f62c7 100644 --- a/board/eve/board.c +++ b/board/eve/board.c @@ -634,8 +634,8 @@ int board_set_active_charge_port(int charge_port) * @param charge_ma Desired charge limit (mA). * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Enable charging trigger by BC1.2 detection */ int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP || diff --git a/board/ezkinil/board.c b/board/ezkinil/board.c index d9ea2c0ecb..5e15b458cc 100644 --- a/board/ezkinil/board.c +++ b/board/ezkinil/board.c @@ -865,9 +865,3 @@ int fan_percent_to_rpm(int fan, int pct) return fan_table[current_level].rpm; } - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/felwinter/charger_isl9241.c b/board/felwinter/charger_isl9241.c index 552436824a..95227f753a 100644 --- a/board/felwinter/charger_isl9241.c +++ b/board/felwinter/charger_isl9241.c @@ -79,9 +79,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/fennel/board.c b/board/fennel/board.c index 95f865a20c..6d864252b6 100644 --- a/board/fennel/board.c +++ b/board/fennel/board.c @@ -237,12 +237,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/fizz/board.c b/board/fizz/board.c index f58083c6ed..296ddca5a7 100644 --- a/board/fizz/board.c +++ b/board/fizz/board.c @@ -512,8 +512,8 @@ static void set_charge_limit(int charge_ma) } } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { int p87w = 0, p65w = 0, p60w = 0; diff --git a/board/gaelin/led.c b/board/gaelin/led.c index 842cee0530..a4b9a0d094 100644 --- a/board/gaelin/led.c +++ b/board/gaelin/led.c @@ -249,8 +249,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness) else return set_color(id, LED_OFF, 0); } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Blink alert if insufficient power per system_can_boot_ap(). */ int insufficient_power = diff --git a/board/galtic/board.c b/board/galtic/board.c index 787b8877ab..9800c1150c 100644 --- a/board/galtic/board.c +++ b/board/galtic/board.c @@ -502,16 +502,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * TODO(b/151955431): Characterize the input current limit in case a - * scaling needs to be applied here - */ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_is_sourcing_vbus(int port) { int regval; diff --git a/board/gelarshie/board.c b/board/gelarshie/board.c index 5ce8030560..174e4b0764 100644 --- a/board/gelarshie/board.c +++ b/board/gelarshie/board.c @@ -683,8 +683,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/gimble/charger.c b/board/gimble/charger.c index 937a48590c..7fabd2082e 100644 --- a/board/gimble/charger.c +++ b/board/gimble/charger.c @@ -81,9 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/gooey/board.c b/board/gooey/board.c index 80748b29de..544117f9c6 100644 --- a/board/gooey/board.c +++ b/board/gooey/board.c @@ -259,12 +259,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/haboki/board.c b/board/haboki/board.c index 1c48955cbc..8814871ed7 100644 --- a/board/haboki/board.c +++ b/board/haboki/board.c @@ -526,8 +526,8 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Limit C1 on board version 0 to 2.0 A */ if ((board_version == 0) && (port == 1)) diff --git a/board/herobrine/usbc_config.c b/board/herobrine/usbc_config.c index 5d5d57d8bc..c80b00f0de 100644 --- a/board/herobrine/usbc_config.c +++ b/board/herobrine/usbc_config.c @@ -286,8 +286,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/homestar/board.c b/board/homestar/board.c index 3c63fd7f81..11035d2034 100644 --- a/board/homestar/board.c +++ b/board/homestar/board.c @@ -631,8 +631,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/icarus/board.c b/board/icarus/board.c index e11e763f10..4d145287a4 100644 --- a/board/icarus/board.c +++ b/board/icarus/board.c @@ -204,12 +204,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c index 5a3f34d273..d9e88d3f80 100644 --- a/board/jacuzzi/board.c +++ b/board/jacuzzi/board.c @@ -244,12 +244,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/kano/charger.c b/board/kano/charger.c index 4ad9b41deb..95227f753a 100644 --- a/board/kano/charger.c +++ b/board/kano/charger.c @@ -79,9 +79,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/kappa/board.c b/board/kappa/board.c index f99d11f063..c00e375560 100644 --- a/board/kappa/board.c +++ b/board/kappa/board.c @@ -217,12 +217,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/kingoftown/usbc_config.c b/board/kingoftown/usbc_config.c index 3e4179904c..eafd55bcf2 100644 --- a/board/kingoftown/usbc_config.c +++ b/board/kingoftown/usbc_config.c @@ -334,8 +334,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/kinox/board.c b/board/kinox/board.c index 7c55fba876..7d9955e05f 100644 --- a/board/kinox/board.c +++ b/board/kinox/board.c @@ -100,8 +100,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { } diff --git a/board/kracko/board.c b/board/kracko/board.c index 6ac215b1fb..47bf6a7687 100644 --- a/board/kracko/board.c +++ b/board/kracko/board.c @@ -582,8 +582,8 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Limit C1 on board version 0 to 2.0 A */ if ((board_version == 0) && (port == 1)) diff --git a/board/kuldax/led.c b/board/kuldax/led.c index 39b79e2196..2fabc26a9a 100644 --- a/board/kuldax/led.c +++ b/board/kuldax/led.c @@ -259,8 +259,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness) else return set_color(id, LED_OFF, 0); } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Blink alert if insufficient power per system_can_boot_ap(). */ int insufficient_power = diff --git a/board/lalala/board.c b/board/lalala/board.c index b06e6760db..f0f354fcf3 100644 --- a/board/lalala/board.c +++ b/board/lalala/board.c @@ -397,12 +397,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/lantis/board.c b/board/lantis/board.c index 8d20b61673..9917231474 100644 --- a/board/lantis/board.c +++ b/board/lantis/board.c @@ -719,16 +719,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * TODO(b/151955431): Characterize the input current limit in case a - * scaling needs to be applied here - */ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_set_active_charge_port(int port) { int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count()); diff --git a/board/lazor/usbc_config.c b/board/lazor/usbc_config.c index 6d4351ab64..26a8a5692d 100644 --- a/board/lazor/usbc_config.c +++ b/board/lazor/usbc_config.c @@ -371,8 +371,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/lisbon/led.c b/board/lisbon/led.c index 842cee0530..a4b9a0d094 100644 --- a/board/lisbon/led.c +++ b/board/lisbon/led.c @@ -249,8 +249,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness) else return set_color(id, LED_OFF, 0); } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Blink alert if insufficient power per system_can_boot_ap(). */ int insufficient_power = diff --git a/board/madoo/board.c b/board/madoo/board.c index e7294150b0..77c939143a 100644 --- a/board/madoo/board.c +++ b/board/madoo/board.c @@ -312,12 +312,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/magolor/board.c b/board/magolor/board.c index e09eb31abf..a8c043ccbb 100644 --- a/board/magolor/board.c +++ b/board/magolor/board.c @@ -593,12 +593,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/makomo/board.c b/board/makomo/board.c index dcf7d671b2..5a7158b58a 100644 --- a/board/makomo/board.c +++ b/board/makomo/board.c @@ -235,12 +235,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/marzipan/board.c b/board/marzipan/board.c index 18a02799cc..cf59f133e7 100644 --- a/board/marzipan/board.c +++ b/board/marzipan/board.c @@ -626,8 +626,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c index b51f6be876..3b7b34843b 100644 --- a/board/mchpevb1/board.c +++ b/board/mchpevb1/board.c @@ -590,20 +590,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } - -/** - * Set the charge limit based upon desired maximum. - * - * @param port Port number. - * @param supplier Charge supplier type. - * @param charge_ma Desired charge limit (mA). - * @param charge_mv Negotiated charge voltage (mV). - */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} #endif /* diff --git a/board/metaknight/board.c b/board/metaknight/board.c index b142740c1e..e5d86aba63 100644 --- a/board/metaknight/board.c +++ b/board/metaknight/board.c @@ -396,12 +396,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/mithrax/charger_isl9241.c b/board/mithrax/charger_isl9241.c index 8edcb00e31..7a16fcd5cb 100644 --- a/board/mithrax/charger_isl9241.c +++ b/board/mithrax/charger_isl9241.c @@ -79,9 +79,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/moli/led.c b/board/moli/led.c index f2ab214418..edb429e530 100644 --- a/board/moli/led.c +++ b/board/moli/led.c @@ -270,8 +270,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness) return set_color(id, LED_OFF, 0); } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Blink alert if insufficient power per system_can_boot_ap(). */ int insufficient_power = diff --git a/board/mrbland/board.c b/board/mrbland/board.c index 9b42b15e23..52b1c50a1b 100644 --- a/board/mrbland/board.c +++ b/board/mrbland/board.c @@ -585,8 +585,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/munna/board.c b/board/munna/board.c index 76445f4bd3..6d7b35da1c 100644 --- a/board/munna/board.c +++ b/board/munna/board.c @@ -236,12 +236,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/nami/board.c b/board/nami/board.c index b02b33fdd8..2ab66ab951 100644 --- a/board/nami/board.c +++ b/board/nami/board.c @@ -747,8 +747,8 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Limit the input current to 96% negotiated limit, diff --git a/board/nautilus/board.c b/board/nautilus/board.c index 2f69158b9f..af7d7f48d4 100644 --- a/board/nautilus/board.c +++ b/board/nautilus/board.c @@ -527,20 +527,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -/** - * Set the charge limit based upon desired maximum. - * - * @param port Port number. - * @param supplier Charge supplier type. - * @param charge_ma Desired charge limit (mA). - * @param charge_mv Negotiated charge voltage (mV). - */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - /** * Return the maximum allowed input current */ diff --git a/board/nocturne/board.c b/board/nocturne/board.c index 13fa259276..1c0b2b3397 100644 --- a/board/nocturne/board.c +++ b/board/nocturne/board.c @@ -760,12 +760,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - static void board_chipset_reset(void) { board_report_pmic_fault("CHIPSET RESET"); diff --git a/board/oak/board.c b/board/oak/board.c index 3e370c8fa6..17908caa7a 100644 --- a/board/oak/board.c +++ b/board/oak/board.c @@ -357,8 +357,8 @@ int board_set_active_charge_port(int charge_port) * @param charge_ma Desired charge limit (mA). * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { charge_set_input_current_limit(charge_ma, charge_mv); pd_send_host_event(PD_EVENT_POWER_CHANGE); diff --git a/board/osiris/charger.c b/board/osiris/charger.c index 8edcb00e31..7a16fcd5cb 100644 --- a/board/osiris/charger.c +++ b/board/osiris/charger.c @@ -79,9 +79,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/pazquel/board.c b/board/pazquel/board.c index f2d4685154..1efad2255f 100644 --- a/board/pazquel/board.c +++ b/board/pazquel/board.c @@ -534,8 +534,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/pico/board.c b/board/pico/board.c index 5326f17283..801c344a69 100644 --- a/board/pico/board.c +++ b/board/pico/board.c @@ -320,12 +320,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/pirika/board.c b/board/pirika/board.c index bbe6deab48..ae1c74bdfc 100644 --- a/board/pirika/board.c +++ b/board/pirika/board.c @@ -491,16 +491,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * TODO(b/151955431): Characterize the input current limit in case a - * scaling needs to be applied here - */ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_is_sourcing_vbus(int port) { int regval; diff --git a/board/pompom/board.c b/board/pompom/board.c index e922244721..ccaff4f55f 100644 --- a/board/pompom/board.c +++ b/board/pompom/board.c @@ -437,8 +437,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/poppy/board.c b/board/poppy/board.c index c870bffb4f..ab3f3b40b0 100644 --- a/board/poppy/board.c +++ b/board/poppy/board.c @@ -676,8 +676,8 @@ int board_set_active_charge_port(int charge_port) * @param charge_ma Desired charge limit (mA). * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Adjust ILIM according to measurements to eliminate overshoot. */ charge_ma = (charge_ma - 500) * 31 / 32 + 472; diff --git a/board/puff/board.c b/board/puff/board.c index d863b5fc0b..5475773aa0 100644 --- a/board/puff/board.c +++ b/board/puff/board.c @@ -88,8 +88,8 @@ uint16_t tcpc_get_alert_status(void) } /* Called when the charge manager has switched to a new port. */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Blink alert if insufficient power per system_can_boot_ap(). */ int insufficient_power = diff --git a/board/quackingstick/board.c b/board/quackingstick/board.c index 2ccdc1c097..7002a62e03 100644 --- a/board/quackingstick/board.c +++ b/board/quackingstick/board.c @@ -612,8 +612,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/rainier/board.c b/board/rainier/board.c index 07a006b671..05142a3936 100644 --- a/board/rainier/board.c +++ b/board/rainier/board.c @@ -173,8 +173,8 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * NOP because there is no internal power therefore no charging. diff --git a/board/rammus/board.c b/board/rammus/board.c index be1f3d9110..e4abed4afb 100644 --- a/board/rammus/board.c +++ b/board/rammus/board.c @@ -558,20 +558,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -/** - * Set the charge limit based upon desired maximum. - * - * @param port Port number. - * @param supplier Charge supplier type. - * @param charge_ma Desired charge limit (mA). - * @param charge_mv Negotiated charge voltage (mV). - */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - void board_hibernate(void) { CPRINTS("Triggering PMIC shutdown."); diff --git a/board/redrix/charger.c b/board/redrix/charger.c index 4f52a06d7e..7fabd2082e 100644 --- a/board/redrix/charger.c +++ b/board/redrix/charger.c @@ -81,9 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/reef/board.c b/board/reef/board.c index 4ee0f75b25..ad92334c2b 100644 --- a/board/reef/board.c +++ b/board/reef/board.c @@ -543,8 +543,8 @@ int board_set_active_charge_port(int charge_port) * @param charge_ma Desired charge limit (mA). * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Enable charging trigger by BC1.2 detection */ int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP || diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c index 54a0995e85..1e222a4ed4 100644 --- a/board/reef_it8320/board.c +++ b/board/reef_it8320/board.c @@ -299,8 +299,8 @@ int board_set_active_charge_port(int charge_port) * @param charge_ma Desired charge limit (mA). * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Enable charging trigger by BC1.2 detection */ int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP || diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c index 55b5ab25c7..c50a4feb8a 100644 --- a/board/reef_mchp/board.c +++ b/board/reef_mchp/board.c @@ -736,8 +736,8 @@ int board_set_active_charge_port(int charge_port) * @param charge_ma Desired charge limit (mA). * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* Enable charging trigger by BC1.2 detection */ int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP || diff --git a/board/sasuke/board.c b/board/sasuke/board.c index 07dd0ddb79..e6767d8126 100644 --- a/board/sasuke/board.c +++ b/board/sasuke/board.c @@ -395,12 +395,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/sasukette/board.c b/board/sasukette/board.c index 9d7e0470ff..f6786c1441 100644 --- a/board/sasukette/board.c +++ b/board/sasukette/board.c @@ -251,12 +251,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_is_sourcing_vbus(int port) { int regval; diff --git a/board/scarlet/board.c b/board/scarlet/board.c index b423e5f79a..66017e172d 100644 --- a/board/scarlet/board.c +++ b/board/scarlet/board.c @@ -212,12 +212,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int extpower_is_present(void) { /* diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c index 4fcded6842..e3eba6104a 100644 --- a/board/servo_v4/usb_pd_policy.c +++ b/board/servo_v4/usb_pd_policy.c @@ -364,8 +364,8 @@ int board_set_active_charge_port(int charge_port) return 0; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { if (port != CHG) return; diff --git a/board/servo_v4p1/usb_pd_policy.c b/board/servo_v4p1/usb_pd_policy.c index 7f5b6f35bf..fc79bf84da 100644 --- a/board/servo_v4p1/usb_pd_policy.c +++ b/board/servo_v4p1/usb_pd_policy.c @@ -391,8 +391,8 @@ int board_set_active_charge_port(int charge_port) return 0; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { if (port != CHG) return; diff --git a/board/shotzo/board.c b/board/shotzo/board.c index dea75ee7d2..5d96e164cf 100644 --- a/board/shotzo/board.c +++ b/board/shotzo/board.c @@ -351,8 +351,8 @@ uint16_t tcpc_get_alert_status(void) return 0; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { if (port == CHARGER_SOLO) { charger_set_input_current_limit(CHARGER_SOLO, max_ma); diff --git a/board/stern/board.c b/board/stern/board.c index ec3c7e66d5..a6d488aaf6 100644 --- a/board/stern/board.c +++ b/board/stern/board.c @@ -236,12 +236,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/storo/board.c b/board/storo/board.c index 65fa6c917f..83d9ef4c72 100644 --- a/board/storo/board.c +++ b/board/storo/board.c @@ -431,12 +431,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_is_sourcing_vbus(int port) { int regval; diff --git a/board/taeko/charger.c b/board/taeko/charger.c index 6b45881b99..7fabd2082e 100644 --- a/board/taeko/charger.c +++ b/board/taeko/charger.c @@ -81,9 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/taniks/charger.c b/board/taniks/charger.c index 937a48590c..7fabd2082e 100644 --- a/board/taniks/charger.c +++ b/board/taniks/charger.c @@ -81,9 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/trogdor/usbc_config.c b/board/trogdor/usbc_config.c index 7abe04651b..b9c37a04fd 100644 --- a/board/trogdor/usbc_config.c +++ b/board/trogdor/usbc_config.c @@ -334,8 +334,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/board/vell/charger.c b/board/vell/charger.c index 757f545d80..53b14381cd 100644 --- a/board/vell/charger.c +++ b/board/vell/charger.c @@ -81,12 +81,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - static void set_ac_prochot(void) { isl9241_set_ac_prochot(CHARGER_SOLO, PD_MAX_CURRENT_MA); diff --git a/board/vilboz/board.c b/board/vilboz/board.c index dbbe3a64ca..1ba266f145 100644 --- a/board/vilboz/board.c +++ b/board/vilboz/board.c @@ -504,9 +504,3 @@ const int usb_port_enable[USBA_PORT_COUNT] = { IOEX_EN_USB_A0_5V, GPIO_EN_USB_A1_5V, }; - -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/volmar/charger.c b/board/volmar/charger.c index 8edcb00e31..7a16fcd5cb 100644 --- a/board/volmar/charger.c +++ b/board/volmar/charger.c @@ -79,9 +79,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/board/waddledee/board.c b/board/waddledee/board.c index ab71aa0680..4dfb3048ca 100644 --- a/board/waddledee/board.c +++ b/board/waddledee/board.c @@ -342,16 +342,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * TODO(b/151955431): Characterize the input current limit in case a - * scaling needs to be applied here - */ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_set_active_charge_port(int port) { int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count()); diff --git a/board/waddledoo/board.c b/board/waddledoo/board.c index 8658397d9d..3cdb71cc5e 100644 --- a/board/waddledoo/board.c +++ b/board/waddledoo/board.c @@ -390,12 +390,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/waddledoo2/board.c b/board/waddledoo2/board.c index 6f8a48abe6..98c061d9af 100644 --- a/board/waddledoo2/board.c +++ b/board/waddledoo2/board.c @@ -397,12 +397,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { if (port < 0 || port > board_get_usb_pd_port_count()) diff --git a/board/wheelie/board.c b/board/wheelie/board.c index 922d6cde52..e8852a0b5a 100644 --- a/board/wheelie/board.c +++ b/board/wheelie/board.c @@ -229,16 +229,6 @@ uint16_t tcpc_get_alert_status(void) return status; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - /* - * TODO(b/151955431): Characterize the input current limit in case a - * scaling needs to be applied here - */ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_set_active_charge_port(int port) { int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); diff --git a/board/willow/board.c b/board/willow/board.c index 370b79e4c8..1fdcc37492 100644 --- a/board/willow/board.c +++ b/board/willow/board.c @@ -234,12 +234,6 @@ int board_set_active_charge_port(int charge_port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int board_discharge_on_ac(int enable) { int ret, port; diff --git a/board/wormdingler/board.c b/board/wormdingler/board.c index 8a106ca965..e9e929de53 100644 --- a/board/wormdingler/board.c +++ b/board/wormdingler/board.c @@ -630,8 +630,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/common/charge_manager.c b/common/charge_manager.c index c67656b122..683daaccf6 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -1711,3 +1711,11 @@ board_fill_source_power_info(int port, struct ec_response_usb_pd_power_info *r) r->meas.current_lim = 0; r->max_power = 0; } + +__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ +#if defined(CONFIG_CHARGER) && defined(CONFIG_BATTERY) + charge_set_input_current_limit(charge_ma, charge_mv); +#endif +} diff --git a/include/charge_manager.h b/include/charge_manager.h index 459673a630..2d4155f09d 100644 --- a/include/charge_manager.h +++ b/include/charge_manager.h @@ -300,14 +300,19 @@ int board_set_active_charge_port(int charge_port); /** * Set the charge current limit. * + * The default implementation of this function derates charge_ma by + * CONFIG_CHARGER_INPUT_CURRENT_PCT (if configured), and clamps charge_ma to + * a lower bound of CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT (if configured). + * * @param port PD port. * @param supplier Identified CHARGE_SUPPLIER_*. * @param charge_ma Desired charge current limit, <= max_ma. * @param max_ma Maximum charge current limit, >= charge_ma. * @param charge_mv Negotiated charge voltage (mV). */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv); +__override_proto void board_set_charge_limit(int port, int supplier, + int charge_ma, int max_ma, + int charge_mv); /** * Get whether the port is sourcing power on VBUS. diff --git a/test/charge_manager.c b/test/charge_manager.c index 9a27a419d0..9d1c888e9d 100644 --- a/test/charge_manager.c +++ b/test/charge_manager.c @@ -34,8 +34,8 @@ static int new_power_request[CONFIG_USB_PD_PORT_MAX_COUNT]; static enum pd_power_role power_role[CONFIG_USB_PD_PORT_MAX_COUNT]; /* Callback functions called by CM on state change */ -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { active_charge_limit = charge_ma; } diff --git a/test/charge_ramp.c b/test/charge_ramp.c index a4d53b31d6..056fa67c21 100644 --- a/test/charge_ramp.c +++ b/test/charge_ramp.c @@ -73,8 +73,8 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) vbus_low_current_ma; } -void board_set_charge_limit(int port, int supplier, int limit_ma, int max_ma, - int max_mv) +__override void board_set_charge_limit(int port, int supplier, int limit_ma, + int max_ma, int max_mv) { charge_limit_ma = limit_ma; if (charge_limit_ma > overcurrent_current_ma) diff --git a/zephyr/program/corsola/src/usbc_config.c b/zephyr/program/corsola/src/usbc_config.c index c96f3b5e32..93eb72a48f 100644 --- a/zephyr/program/corsola/src/usbc_config.c +++ b/zephyr/program/corsola/src/usbc_config.c @@ -126,12 +126,6 @@ __override enum pd_dual_role_states pd_get_drp_state_in_s0(void) } } -__override void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) { /* diff --git a/zephyr/program/herobrine/src/usbc_config.c b/zephyr/program/herobrine/src/usbc_config.c index 95301120d8..3333a110da 100644 --- a/zephyr/program/herobrine/src/usbc_config.c +++ b/zephyr/program/herobrine/src/usbc_config.c @@ -249,8 +249,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/zephyr/program/intelrvp/src/chg_usb_pd.c b/zephyr/program/intelrvp/src/chg_usb_pd.c index 81a44238e4..084617cb98 100644 --- a/zephyr/program/intelrvp/src/chg_usb_pd.c +++ b/zephyr/program/intelrvp/src/chg_usb_pd.c @@ -120,9 +120,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c index 3600005ae1..119a999736 100644 --- a/zephyr/program/nissa/src/common.c +++ b/zephyr/program/nissa/src/common.c @@ -80,12 +80,6 @@ static void board_setup_init(void) */ DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_INIT_I2C); -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - int pd_check_vconn_swap(int port) { /* Allow VCONN swaps if the AP is on. */ diff --git a/zephyr/program/rex/src/usbc_config.c b/zephyr/program/rex/src/usbc_config.c index ed51be6160..df260f6730 100644 --- a/zephyr/program/rex/src/usbc_config.c +++ b/zephyr/program/rex/src/usbc_config.c @@ -192,12 +192,6 @@ void bc12_interrupt(enum gpio_signal signal) } } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - static void board_disable_charger_ports(void) { int i; diff --git a/zephyr/program/skyrim/src/usbc_config.c b/zephyr/program/skyrim/src/usbc_config.c index eaa327ff4e..47d0ac6a29 100644 --- a/zephyr/program/skyrim/src/usbc_config.c +++ b/zephyr/program/skyrim/src/usbc_config.c @@ -190,12 +190,6 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - void sbu_fault_interrupt(enum gpio_signal signal) { int port = signal == IOEX_USB_C1_FAULT_ODL ? 1 : 0; diff --git a/zephyr/program/trogdor/lazor/src/usbc_config.c b/zephyr/program/trogdor/lazor/src/usbc_config.c index c3860dc005..d7d5ca2cc1 100644 --- a/zephyr/program/trogdor/lazor/src/usbc_config.c +++ b/zephyr/program/trogdor/lazor/src/usbc_config.c @@ -301,8 +301,8 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { /* * Ignore lower charge ceiling on PD transition if our battery is diff --git a/zephyr/test/drivers/common/src/stubs.c b/zephyr/test/drivers/common/src/stubs.c index 2f8ec7a43f..69993d8a89 100644 --- a/zephyr/test/drivers/common/src/stubs.c +++ b/zephyr/test/drivers/common/src/stubs.c @@ -98,12 +98,6 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) return 0; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) -{ - charge_set_input_current_limit(charge_ma, charge_mv); -} - BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT); static uint16_t ps8xxx_product_id = PS8805_PRODUCT_ID; diff --git a/zephyr/test/krabby/src/stubs.c b/zephyr/test/krabby/src/stubs.c index 655c59ec2c..df1613528d 100644 --- a/zephyr/test/krabby/src/stubs.c +++ b/zephyr/test/krabby/src/stubs.c @@ -8,8 +8,8 @@ #include "charge_state.h" #include "usbc_ppc.h" -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { } diff --git a/zephyr/test/vboot_efs2/src/main.c b/zephyr/test/vboot_efs2/src/main.c index f79d2dcf78..6fb9e8ba02 100644 --- a/zephyr/test/vboot_efs2/src/main.c +++ b/zephyr/test/vboot_efs2/src/main.c @@ -372,8 +372,8 @@ int board_set_active_charge_port(int port) return EC_ERROR_INVAL; } -void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, - int charge_mv) +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) { } -- cgit v1.2.1 From e414805dd4adc122218f2cf2eec4d7d9a5737dcb Mon Sep 17 00:00:00 2001 From: ben chen Date: Wed, 23 Nov 2022 14:25:30 +0800 Subject: craask: add Fw_config structure for Keyboard backlight Craask need to implement keyboard backlight fw config in bit 18 of cbi. Remove unused fw config and add the override ec feature function. BUG=b:257387315 BRANCH=none TEST=none. Change-Id: Iea0076b0024b9e387b392627fd4af337a0325830 Signed-off-by: Ben Chen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050008 Reviewed-by: Andrew McRae Commit-Queue: Andrew McRae Tested-by: Andrew McRae Code-Coverage: Andrew McRae --- zephyr/program/nissa/CMakeLists.txt | 1 + zephyr/program/nissa/craask/cbi.dtsi | 19 ++++++++++++++ zephyr/program/nissa/craask/src/kb_backlight.c | 34 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 zephyr/program/nissa/craask/src/kb_backlight.c diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index 0aeaf1a82b..a982f89b56 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -36,6 +36,7 @@ if(DEFINED CONFIG_BOARD_CRAASK) zephyr_library_sources( "craask/src/form_factor.c" "craask/src/keyboard.c" + "craask/src/kb_backlight.c" "craask/src/led.c" ) project(craask) diff --git a/zephyr/program/nissa/craask/cbi.dtsi b/zephyr/program/nissa/craask/cbi.dtsi index ef36a58d9d..203eace823 100644 --- a/zephyr/program/nissa/craask/cbi.dtsi +++ b/zephyr/program/nissa/craask/cbi.dtsi @@ -52,6 +52,25 @@ value = <1>; }; }; + /* + * FW_CONFIG field to enable KB back light or not. + */ + kb-bl { + enum-name = "FW_KB_BL"; + start = <18>; + size = <1>; + + no-kb-bl { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_NOT_PRESENT"; + value = <0>; + }; + kb-bl-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_PRESENT"; + value = <1>; + }; + }; }; /* Craask-specific ssfc fields. */ cbi-ssfc { diff --git a/zephyr/program/nissa/craask/src/kb_backlight.c b/zephyr/program/nissa/craask/src/kb_backlight.c new file mode 100644 index 0000000000..108cbb3abd --- /dev/null +++ b/zephyr/program/nissa/craask/src/kb_backlight.c @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "board_config.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" + +#include +#include + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +__override uint32_t board_override_feature_flags0(uint32_t flags0) +{ + int ret; + uint32_t val; + + /* + * Remove keyboard backlight feature for devices that don't support it. + */ + ret = cros_cbi_get_fw_config(FW_KB_BL, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL); + return flags0; + } + + if (val == FW_KB_BL_NOT_PRESENT) + return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB)); + else + return flags0; +} -- cgit v1.2.1 From e420c8ff9a765e0359ab5f73c4eef1d1207d3271 Mon Sep 17 00:00:00 2001 From: Michael5 Chen1 Date: Fri, 11 Nov 2022 16:40:25 +0800 Subject: marasov: Modify TypeC and TypeA configuration. Depend on design, 1. Remove BC1.2 (USB_CHARGE, CHARGER_RAMP). 2. Remove TypeC port 2. 3. Change PPC to SYV682 for typeC port 1. 4. Support 2 USB TypeA ports. BUG=b:259002141,b:255184961 BRANCH=none TEST=make BOARD=marasov Signed-off-by: Michael5 Chen1 Change-Id: I8dbd75ffc8666b8931ef0e486e6e6a3ba6ac0c56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022557 Reviewed-by: Boris Mittelberg Reviewed-by: Kyle Lin Code-Coverage: Zoss --- baseboard/brya/baseboard_usbc_config.h | 2 + board/marasov/board.c | 5 - board/marasov/board.h | 20 ++-- board/marasov/ec.tasklist | 7 +- board/marasov/fw_config.h | 4 +- board/marasov/generated-gpio.inc | 28 ++--- board/marasov/gpio.inc | 5 - board/marasov/i2c.c | 18 +-- board/marasov/usbc_config.c | 211 ++++----------------------------- board/marasov/usbc_config.h | 11 +- 10 files changed, 58 insertions(+), 253 deletions(-) diff --git a/baseboard/brya/baseboard_usbc_config.h b/baseboard/brya/baseboard_usbc_config.h index 6d0cf828a3..17f1fe6b06 100644 --- a/baseboard/brya/baseboard_usbc_config.h +++ b/baseboard/brya/baseboard_usbc_config.h @@ -11,7 +11,9 @@ #include "gpio_signal.h" /* Common definition for the USB PD interrupt handlers. */ +#ifdef CONFIG_USB_CHARGER void bc12_interrupt(enum gpio_signal signal); +#endif void ppc_interrupt(enum gpio_signal signal); void retimer_interrupt(enum gpio_signal signal); void tcpc_alert_event(enum gpio_signal signal); diff --git a/board/marasov/board.c b/board/marasov/board.c index 58ed5f9f12..e48dfaa163 100644 --- a/board/marasov/board.c +++ b/board/marasov/board.c @@ -31,11 +31,6 @@ #define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) #define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) -__override void board_cbi_init(void) -{ - config_usb_db_type(); -} - /* Called on AP S3 -> S0 transition */ static void board_chipset_resume(void) { diff --git a/board/marasov/board.h b/board/marasov/board.h index 7e7e140905..6cb0225edc 100644 --- a/board/marasov/board.h +++ b/board/marasov/board.h @@ -36,7 +36,7 @@ #undef CONFIG_VOLUME_BUTTONS /* USB Type A Features */ -#define USB_PORT_COUNT 1 +#define USB_PORT_COUNT 2 #define CONFIG_USB_PORT_POWER_DUMB /* USB Type C and USB PD defines */ @@ -44,13 +44,15 @@ #define CONFIG_IO_EXPANDER #define CONFIG_IO_EXPANDER_NCT38XX -#define CONFIG_IO_EXPANDER_PORT_COUNT 2 +#define CONFIG_IO_EXPANDER_PORT_COUNT 1 #define CONFIG_USB_PD_FRS_PPC #define CONFIG_USB_PD_TCPM_PS8815 #define CONFIG_USB_PD_TCPM_PS8815_FORCE_DID #define CONFIG_USBC_RETIMER_INTEL_BB +#undef CONFIG_BC12_DETECT_PI3USB9201 +#undef CONFIG_USB_CHARGER /* Battery Configuration */ #define CONFIG_SMBUS_PEC @@ -64,7 +66,6 @@ #define CONFIG_HOSTCMD_I2C_CONTROL #define CONFIG_USBC_PPC_SYV682X -#define CONFIG_USBC_PPC_NX20P3483 /* TODO: b/177608416 - measure and check these values on brya */ #define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ @@ -120,16 +121,13 @@ #define I2C_PORT_SENSOR NPCX_I2C_PORT0_0 -#define I2C_PORT_USB_C0_C2_TCPC NPCX_I2C_PORT1_0 +#define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0 #define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1 -#define I2C_PORT_USB_C0_C2_PPC NPCX_I2C_PORT2_0 +#define I2C_PORT_USB_C0_PPC NPCX_I2C_PORT2_0 #define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1 -#define I2C_PORT_USB_C0_C2_BC12 NPCX_I2C_PORT2_0 -#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT6_1 - -#define I2C_PORT_USB_C0_C2_MUX NPCX_I2C_PORT3_0 +#define I2C_PORT_USB_C0_MUX NPCX_I2C_PORT3_0 #define I2C_PORT_USB_C1_MUX NPCX_I2C_PORT6_1 #define I2C_PORT_BATTERY NPCX_I2C_PORT5_0 @@ -145,7 +143,6 @@ * see b/174768555#comment22 */ #define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x56 -#define USBC_PORT_C2_BB_RETIMER_I2C_ADDR 0x57 /* Enabling Thunderbolt-compatible mode */ #define CONFIG_USB_PD_TBT_COMPAT_MODE @@ -169,7 +166,6 @@ #define CONFIG_CHARGER_BQ25720 #define CONFIG_CHARGER_BQ25720_VSYS_TH2_CUSTOM #define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70 -#define CONFIG_CHARGE_RAMP_SW #define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10 #define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10 #define CONFIG_CHARGER_BQ25710_PSYS_SENSING @@ -202,7 +198,7 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; -enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT }; +enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_PORT_COUNT }; enum battery_type { BATTERY_C490, BATTERY_TYPE_COUNT }; diff --git a/board/marasov/ec.tasklist b/board/marasov/ec.tasklist index e3087d1d5f..a4039fc94f 100644 --- a/board/marasov/ec.tasklist +++ b/board/marasov/ec.tasklist @@ -12,10 +12,6 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, HOOKS_TASK_STACK_SIZE) \ - TASK_ALWAYS(CHG_RAMP, chg_ramp_task, NULL, BASEBOARD_CHG_RAMP_TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 0, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P2, usb_charger_task, 0, TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, BASEBOARD_CHARGER_TASK_STACK_SIZE) \ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, BASEBOARD_CHIPSET_TASK_STACK_SIZE) \ @@ -26,6 +22,5 @@ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(PD_C0, pd_task, NULL, BASEBOARD_PD_TASK_STACK_SIZE) \ TASK_ALWAYS(PD_C1, pd_task, NULL, BASEBOARD_PD_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C2, pd_task, NULL, BASEBOARD_PD_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_INT_C0, pd_shared_alert_task, (BIT(2) | BIT(0)), BASEBOARD_PD_INT_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, BASEBOARD_PD_INT_TASK_STACK_SIZE) \ TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, BASEBOARD_PD_INT_TASK_STACK_SIZE) diff --git a/board/marasov/fw_config.h b/board/marasov/fw_config.h index 573d379972..906e61fe7e 100644 --- a/board/marasov/fw_config.h +++ b/board/marasov/fw_config.h @@ -15,9 +15,7 @@ */ enum ec_cfg_usb_db_type { - DB_USB_ABSENT = 0, - DB_USB3_PS8815 = 1, - DB_USB_ABSENT2 = 15 + DB_USB3_PS8815 = 0, }; enum ec_cfg_keyboard_backlight_type { diff --git a/board/marasov/generated-gpio.inc b/board/marasov/generated-gpio.inc index c71d7dd273..f01f5b790b 100644 --- a/board/marasov/generated-gpio.inc +++ b/board/marasov/generated-gpio.inc @@ -14,16 +14,11 @@ GPIO_INT(SEQ_EC_RSMRST_ODL, PIN(E, 2), GPIO_INT_BOTH, power_signal_ GPIO_INT(SLP_S3_L, PIN(A, 5), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(SLP_SUS_L, PIN(F, 1), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(SYS_SLP_S0IX_L, PIN(D, 5), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(USB_C0_BC12_INT_ODL, PIN(C, 6), GPIO_INT_FALLING, bc12_interrupt) -GPIO_INT(USB_C0_C2_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event) +GPIO_INT(USB_C0_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event) GPIO_INT(USB_C0_PPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, ppc_interrupt) GPIO_INT(USB_C0_RT_INT_ODL, PIN(B, 1), GPIO_INT_FALLING, retimer_interrupt) -GPIO_INT(USB_C1_BC12_INT_ODL, PIN(5, 0), GPIO_INT_FALLING, bc12_interrupt) GPIO_INT(USB_C1_PPC_INT_ODL, PIN(F, 5), GPIO_INT_FALLING, ppc_interrupt) GPIO_INT(USB_C1_TCPC_INT_ODL, PIN(A, 2), GPIO_INT_FALLING, tcpc_alert_event) -GPIO_INT(USB_C2_BC12_INT_ODL, PIN(8, 3), GPIO_INT_FALLING, bc12_interrupt) -GPIO_INT(USB_C2_PPC_INT_ODL, PIN(7, 0), GPIO_INT_FALLING, ppc_interrupt) -GPIO_INT(USB_C2_RT_INT_ODL, PIN(4, 1), GPIO_INT_FALLING, retimer_interrupt) /* USED GPIOs: */ GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_INPUT) @@ -39,12 +34,12 @@ GPIO(EC_I2C_MISC_SCL_R, PIN(B, 3), GPIO_INPUT) GPIO(EC_I2C_MISC_SDA_R, PIN(B, 2), GPIO_INPUT) GPIO(EC_I2C_SENSOR_SCL, PIN(B, 5), GPIO_INPUT | GPIO_SEL_1P8V) GPIO(EC_I2C_SENSOR_SDA, PIN(B, 4), GPIO_INPUT | GPIO_SEL_1P8V) -GPIO(EC_I2C_USB_C0_C2_PPC_BC_SCL, PIN(9, 2), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_PPC_BC_SDA, PIN(9, 1), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_RT_SCL, PIN(D, 1), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_RT_SDA, PIN(D, 0), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_TCPC_SCL, PIN(9, 0), GPIO_INPUT) -GPIO(EC_I2C_USB_C0_C2_TCPC_SDA, PIN(8, 7), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_PPC_BC_SCL, PIN(9, 2), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_PPC_BC_SDA, PIN(9, 1), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_RT_SCL, PIN(D, 1), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_RT_SDA, PIN(D, 0), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_TCPC_SCL, PIN(9, 0), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_TCPC_SDA, PIN(8, 7), GPIO_INPUT) GPIO(EC_I2C_USB_C1_MIX_SCL, PIN(E, 4), GPIO_INPUT) GPIO(EC_I2C_USB_C1_MIX_SDA, PIN(E, 3), GPIO_INPUT) GPIO(EC_I2C_USB_C1_TCPC_SCL, PIN(F, 3), GPIO_INPUT) @@ -64,9 +59,9 @@ GPIO(EN_S5_RAILS, PIN(B, 6), GPIO_OUT_LOW) GPIO(IMVP9_VRRDY_OD, PIN(4, 3), GPIO_INPUT) GPIO(PCH_PWROK, PIN(7, 2), GPIO_OUT_LOW) GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH) -GPIO(USB_C0_C2_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW) +GPIO(USB_C0_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW) GPIO(USB_C1_FRS_EN, PIN(9, 4), GPIO_OUT_LOW) -GPIO(USB_C1_RST_ODL, PIN(9, 6), GPIO_ODR_LOW) +GPIO(USB_C1_OC_ODL, PIN(9, 6), GPIO_ODR_HIGH) GPIO(USB_C1_RT_INT_ODL, PIN(A, 0), GPIO_INPUT) GPIO(USB_C1_RT_RST_R_ODL, PIN(0, 2), GPIO_ODR_LOW) GPIO(VCCST_PWRGD_OD, PIN(A, 4), GPIO_ODR_LOW) @@ -123,5 +118,10 @@ UNUSED(PIN(9, 3)) /* GPIO93 */ UNUSED(PIN(9, 7)) /* GPIO97 */ UNUSED(PIN(C, 3)) /* GPIOC3 */ UNUSED(PIN(C, 4)) /* GPIOC4 */ +UNUSED(PIN(C, 6)) /* GPIOC6 */ +UNUSED(PIN(5, 0)) /* GPIO50 */ +UNUSED(PIN(8, 3)) /* GPIO83 */ +UNUSED(PIN(7, 0)) /* GPIO70 */ +UNUSED(PIN(4, 1)) /* GPIO41 */ /* Pre-configured PSL balls: J8 K6 */ diff --git a/board/marasov/gpio.inc b/board/marasov/gpio.inc index 723f258a20..d4a2ff2d67 100644 --- a/board/marasov/gpio.inc +++ b/board/marasov/gpio.inc @@ -35,9 +35,4 @@ GPIO(EC_KSO_02_INV, PIN(1, 7), GPIO_OUT_LOW) IOEX(USB_C0_OC_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 4), GPIO_ODR_HIGH) IOEX(USB_C0_FRS_EN, EXPIN(IOEX_C0_NCT38XX, 0, 6), GPIO_OUT_LOW) IOEX(USB_C0_RT_RST_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 7), GPIO_ODR_LOW) - -IOEX(USB_C2_RT_RST_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 2), GPIO_ODR_LOW) -IOEX(USB_C1_OC_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 3), GPIO_ODR_HIGH) -IOEX(USB_C2_OC_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 4), GPIO_ODR_HIGH) -IOEX(USB_C2_FRS_EN, EXPIN(IOEX_C2_NCT38XX, 0, 6), GPIO_OUT_LOW) /* GPIO07_P2 to PU */ diff --git a/board/marasov/i2c.c b/board/marasov/i2c.c index dbb8df7369..15c9b13e83 100644 --- a/board/marasov/i2c.c +++ b/board/marasov/i2c.c @@ -22,26 +22,26 @@ const struct i2c_port_t i2c_ports[] = { { /* I2C1 */ .name = "tcpc0,2", - .port = I2C_PORT_USB_C0_C2_TCPC, + .port = I2C_PORT_USB_C0_TCPC, .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C0_C2_TCPC_SCL, - .sda = GPIO_EC_I2C_USB_C0_C2_TCPC_SDA, + .scl = GPIO_EC_I2C_USB_C0_TCPC_SCL, + .sda = GPIO_EC_I2C_USB_C0_TCPC_SDA, }, { /* I2C2 */ .name = "ppc0,2", - .port = I2C_PORT_USB_C0_C2_PPC, + .port = I2C_PORT_USB_C0_PPC, .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C0_C2_PPC_BC_SCL, - .sda = GPIO_EC_I2C_USB_C0_C2_PPC_BC_SDA, + .scl = GPIO_EC_I2C_USB_C0_PPC_BC_SCL, + .sda = GPIO_EC_I2C_USB_C0_PPC_BC_SDA, }, { /* I2C3 */ .name = "retimer0,2", - .port = I2C_PORT_USB_C0_C2_MUX, + .port = I2C_PORT_USB_C0_MUX, .kbps = 1000, - .scl = GPIO_EC_I2C_USB_C0_C2_RT_SCL, - .sda = GPIO_EC_I2C_USB_C0_C2_RT_SDA, + .scl = GPIO_EC_I2C_USB_C0_RT_SCL, + .sda = GPIO_EC_I2C_USB_C0_RT_SDA, }, { /* I2C4 C1 TCPC */ diff --git a/board/marasov/usbc_config.c b/board/marasov/usbc_config.c index 7c080f4188..b974ba7509 100644 --- a/board/marasov/usbc_config.c +++ b/board/marasov/usbc_config.c @@ -8,12 +8,9 @@ #include "cbi.h" #include "charger.h" -#include "charge_ramp.h" #include "common.h" #include "compile_time_macros.h" #include "console.h" -#include "driver/bc12/pi3usb9201_public.h" -#include "driver/ppc/nx20p348x.h" #include "driver/ppc/syv682x_public.h" #include "driver/retimer/bb_retimer_public.h" #include "driver/tcpm/nct38xx.h" @@ -31,7 +28,6 @@ #include "timer.h" #include "usbc_config.h" #include "usbc_ppc.h" -#include "usb_charge.h" #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" @@ -40,7 +36,7 @@ #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) #ifdef CONFIG_ZEPHYR -enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT }; +enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_PORT_COUNT }; #endif /* CONFIG_ZEPHYR */ #ifndef CONFIG_ZEPHYR @@ -49,7 +45,7 @@ const struct tcpc_config_t tcpc_config[] = { [USBC_PORT_C0] = { .bus_type = EC_BUS_TYPE_I2C, .i2c_info = { - .port = I2C_PORT_USB_C0_C2_TCPC, + .port = I2C_PORT_USB_C0_TCPC, .addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS, }, .drv = &nct38xx_tcpm_drv, @@ -68,15 +64,6 @@ const struct tcpc_config_t tcpc_config[] = { TCPC_FLAGS_CONTROL_VCONN | TCPC_FLAGS_CONTROL_FRS, }, - [USBC_PORT_C2] = { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_C2_TCPC, - .addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS, - }, - .drv = &nct38xx_tcpm_drv, - .flags = TCPC_FLAGS_TCPCI_REV2_0, - }, }; BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT); BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT); @@ -98,7 +85,7 @@ BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT); /* USBC PPC configuration */ struct ppc_config_t ppc_chips[] = { [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_USB_C0_C2_PPC, + .i2c_port = I2C_PORT_USB_C0_PPC, .i2c_addr_flags = SYV682X_ADDR0_FLAGS, .frs_en = IOEX_USB_C0_FRS_EN, .drv = &syv682x_drv, @@ -106,13 +93,7 @@ struct ppc_config_t ppc_chips[] = { [USBC_PORT_C1] = { /* Compatible with Silicon Mitus SM5360A */ .i2c_port = I2C_PORT_USB_C1_PPC, - .i2c_addr_flags = NX20P3483_ADDR2_FLAGS, - .drv = &nx20p348x_drv, - }, - [USBC_PORT_C2] = { - .i2c_port = I2C_PORT_USB_C0_C2_PPC, - .i2c_addr_flags = SYV682X_ADDR2_FLAGS, - .frs_en = IOEX_USB_C2_FRS_EN, + .i2c_addr_flags = SYV682X_ADDR0_FLAGS, .drv = &syv682x_drv, }, }; @@ -129,14 +110,6 @@ static const struct usb_mux_chain usbc0_tcss_usb_mux = { .hpd_update = &virtual_hpd_update, }, }; -static const struct usb_mux_chain usbc2_tcss_usb_mux = { - .mux = - &(const struct usb_mux){ - .usb_port = USBC_PORT_C2, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, - }, -}; /* * USB3 DB mux configuration - the top level mux still needs to be set @@ -159,7 +132,7 @@ const struct usb_mux_chain usb_muxes[] = { .flags = USB_MUX_FLAG_CAN_IDLE, .driver = &bb_usb_retimer, .hpd_update = bb_retimer_hpd_update, - .i2c_port = I2C_PORT_USB_C0_C2_MUX, + .i2c_port = I2C_PORT_USB_C0_MUX, .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR, }, .next = &usbc0_tcss_usb_mux, @@ -173,39 +146,11 @@ const struct usb_mux_chain usb_muxes[] = { }, .next = &usbc1_usb3_db_retimer, }, - [USBC_PORT_C2] = { - .mux = &(const struct usb_mux) { - .usb_port = USBC_PORT_C2, - .flags = USB_MUX_FLAG_CAN_IDLE, - .driver = &bb_usb_retimer, - .hpd_update = bb_retimer_hpd_update, - .i2c_port = I2C_PORT_USB_C0_C2_MUX, - .i2c_addr_flags = USBC_PORT_C2_BB_RETIMER_I2C_ADDR, - }, - .next = &usbc2_tcss_usb_mux, - }, }; BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT); -/* BC1.2 charger detect configuration */ -const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { - [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_USB_C0_C2_BC12, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, - }, - [USBC_PORT_C1] = { - .i2c_port = I2C_PORT_USB_C1_BC12, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, - }, - [USBC_PORT_C2] = { - .i2c_port = I2C_PORT_USB_C0_C2_BC12, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_1_FLAGS, - }, -}; -BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT); - /* - * USB C0 and C2 uses burnside bridge chips and have their reset + * USB C0 uses burnside bridge chips and have their reset * controlled by their respective TCPC chips acting as GPIO expanders. * * ioex_init() is normally called before we take the TCPCs out of @@ -215,66 +160,15 @@ BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT); struct ioexpander_config_t ioex_config[] = { [IOEX_C0_NCT38XX] = { - .i2c_host_port = I2C_PORT_USB_C0_C2_TCPC, + .i2c_host_port = I2C_PORT_USB_C0_TCPC, .i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS, .drv = &nct38xx_ioexpander_drv, .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED, }, - [IOEX_C2_NCT38XX] = { - .i2c_host_port = I2C_PORT_USB_C0_C2_TCPC, - .i2c_addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS, - .drv = &nct38xx_ioexpander_drv, - .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED, - }, }; BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT); #endif /* !CONFIG_ZEPHYR */ -#ifdef CONFIG_CHARGE_RAMP_SW - -/* - * TODO(b/181508008): tune this threshold - */ - -#define BC12_MIN_VOLTAGE 4400 - -/** - * Return true if VBUS is too low - */ -int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) -{ - int voltage; - - if (charger_get_vbus_voltage(port, &voltage)) - voltage = 0; - - if (voltage == 0) { - CPRINTS("%s: must be disconnected", __func__); - return 1; - } - - if (voltage < BC12_MIN_VOLTAGE) { - CPRINTS("%s: port %d: vbus %d lower than %d", __func__, port, - voltage, BC12_MIN_VOLTAGE); - return 1; - } - - return 0; -} - -#endif /* CONFIG_CHARGE_RAMP_SW */ - -void config_usb_db_type(void) -{ - enum ec_cfg_usb_db_type db_type = ec_cfg_usb_db_type(); - - /* - * TODO(b/180434685): implement multiple DB types - */ - - CPRINTS("Configured USB DB type number is %d", db_type); -} - __override int bb_retimer_power_enable(const struct usb_mux *me, bool enable) { enum ioex_signal rst_signal; @@ -286,14 +180,6 @@ __override int bb_retimer_power_enable(const struct usb_mux *me, bool enable) #else /* On Zephyr use bb_controls generated from DTS */ rst_signal = bb_controls[me->usb_port].retimer_rst_gpio; -#endif /* !CONFIG_ZEPHYR */ - } else if (me->usb_port == USBC_PORT_C2) { -/* TODO: explore how to handle board id in zephyr*/ -#ifndef CONFIG_ZEPHYR - rst_signal = IOEX_USB_C2_RT_RST_ODL; -#else - /* On Zephyr use bb_controls generated from DTS */ - rst_signal = bb_controls[me->usb_port].retimer_rst_gpio; #endif /* !CONFIG_ZEPHYR */ } else { return EC_ERROR_INVAL; @@ -329,7 +215,7 @@ void board_reset_pd_mcu(void) enum gpio_signal tcpc_rst; #ifndef CONFIG_ZEPHYR - tcpc_rst = GPIO_USB_C0_C2_TCPC_RST_ODL; + tcpc_rst = GPIO_USB_C0_TCPC_RST_ODL; #else tcpc_rst = GPIO_UNIMPLEMENTED; #endif /* !CONFIG_ZEPHYR */ @@ -339,10 +225,7 @@ void board_reset_pd_mcu(void) */ gpio_set_level(tcpc_rst, 0); - if (ec_cfg_usb_db_type() != DB_USB_ABSENT) { - gpio_set_level(GPIO_USB_C1_RST_ODL, 0); - gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 0); - } + gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 0); /* * delay for power-on to reset-off and min. assertion time @@ -351,10 +234,7 @@ void board_reset_pd_mcu(void) msleep(20); gpio_set_level(tcpc_rst, 1); - if (ec_cfg_usb_db_type() != DB_USB_ABSENT) { - gpio_set_level(GPIO_USB_C1_RST_ODL, 1); - gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 1); - } + gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 1); /* wait for chips to come up */ @@ -369,37 +249,23 @@ static void board_tcpc_init(void) /* * These IO expander pins are implemented using the - * C0/C2 TCPC, so they must be set up after the TCPC has + * C0 TCPC, so they must be set up after the TCPC has * been taken out of reset. */ #ifndef CONFIG_ZEPHYR ioex_init(IOEX_C0_NCT38XX); - ioex_init(IOEX_C2_NCT38XX); #else gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_port1))); - gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_port2))); #endif /* Enable PPC interrupts. */ gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_ODL); - gpio_enable_interrupt(GPIO_USB_C2_PPC_INT_ODL); /* Enable TCPC interrupts. */ - gpio_enable_interrupt(GPIO_USB_C0_C2_TCPC_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL); -#ifndef CONFIG_ZEPHYR - /* Enable BC1.2 interrupts. */ - gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL); - gpio_enable_interrupt(GPIO_USB_C2_BC12_INT_ODL); -#endif /* !CONFIG_ZEPHYR */ - - if (ec_cfg_usb_db_type() != DB_USB_ABSENT) { - gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL); - gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL); -#ifndef CONFIG_ZEPHYR - gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_ODL); -#endif /* !CONFIG_ZEPHYR */ - } + gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL); } DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_CHIPSET); @@ -407,11 +273,10 @@ uint16_t tcpc_get_alert_status(void) { uint16_t status = 0; - if (gpio_get_level(GPIO_USB_C0_C2_TCPC_INT_ODL) == 0) - status |= PD_STATUS_TCPC_ALERT_0 | PD_STATUS_TCPC_ALERT_2; + if (gpio_get_level(GPIO_USB_C0_TCPC_INT_ODL) == 0) + status |= PD_STATUS_TCPC_ALERT_0; - if ((ec_cfg_usb_db_type() != DB_USB_ABSENT) && - gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL) == 0) + if (gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL) == 0) status |= PD_STATUS_TCPC_ALERT_1; return status; @@ -421,23 +286,18 @@ int ppc_get_alert_status(int port) { if (port == USBC_PORT_C0) return gpio_get_level(GPIO_USB_C0_PPC_INT_ODL) == 0; - else if ((port == USBC_PORT_C1) && - (ec_cfg_usb_db_type() != DB_USB_ABSENT)) + else if (port == USBC_PORT_C1) return gpio_get_level(GPIO_USB_C1_PPC_INT_ODL) == 0; - else if (port == USBC_PORT_C2) - return gpio_get_level(GPIO_USB_C2_PPC_INT_ODL) == 0; return 0; } void tcpc_alert_event(enum gpio_signal signal) { switch (signal) { - case GPIO_USB_C0_C2_TCPC_INT_ODL: + case GPIO_USB_C0_TCPC_INT_ODL: schedule_deferred_pd_interrupt(USBC_PORT_C0); break; case GPIO_USB_C1_TCPC_INT_ODL: - if (ec_cfg_usb_db_type() == DB_USB_ABSENT) - break; schedule_deferred_pd_interrupt(USBC_PORT_C1); break; default: @@ -445,25 +305,6 @@ void tcpc_alert_event(enum gpio_signal signal) } } -void bc12_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_BC12_INT_ODL: - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - break; - case GPIO_USB_C1_BC12_INT_ODL: - if (ec_cfg_usb_db_type() == DB_USB_ABSENT) - break; - usb_charger_task_set_event(1, USB_CHG_EVENT_BC12); - break; - case GPIO_USB_C2_BC12_INT_ODL: - usb_charger_task_set_event(2, USB_CHG_EVENT_BC12); - break; - default: - break; - } -} - void ppc_interrupt(enum gpio_signal signal) { switch (signal) { @@ -471,17 +312,7 @@ void ppc_interrupt(enum gpio_signal signal) syv682x_interrupt(USBC_PORT_C0); break; case GPIO_USB_C1_PPC_INT_ODL: - switch (ec_cfg_usb_db_type()) { - case DB_USB_ABSENT: - case DB_USB_ABSENT2: - break; - case DB_USB3_PS8815: - nx20p348x_interrupt(USBC_PORT_C1); - break; - } - break; - case GPIO_USB_C2_PPC_INT_ODL: - syv682x_interrupt(USBC_PORT_C2); + syv682x_interrupt(USBC_PORT_C1); break; default: break; @@ -502,7 +333,7 @@ __override bool board_is_dts_port(int port) __override bool board_is_tbt_usb4_port(int port) { - if (port == USBC_PORT_C0 || port == USBC_PORT_C2) + if (port == USBC_PORT_C0) return true; return false; diff --git a/board/marasov/usbc_config.h b/board/marasov/usbc_config.h index 06b9b992fe..1fa7ad4c7a 100644 --- a/board/marasov/usbc_config.h +++ b/board/marasov/usbc_config.h @@ -9,16 +9,9 @@ #define __CROS_EC_USBC_CONFIG_H #ifndef CONFIG_ZEPHYR -#define CONFIG_USB_PD_PORT_MAX_COUNT 3 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #endif -enum usbc_port { - USBC_PORT_C0 = 0, - USBC_PORT_C1, - USBC_PORT_C2, - USBC_PORT_COUNT -}; - -void config_usb_db_type(void); +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; #endif /* __CROS_EC_USBC_CONFIG_H */ -- cgit v1.2.1 From 5dbfddec42bf47f88b371f16660beb48de058b57 Mon Sep 17 00:00:00 2001 From: Andrew McRae Date: Thu, 24 Nov 2022 11:55:03 +1100 Subject: pujjo: Add missing gyro config default-range Add missing default-range config properties for the lsm6dsm-gyro DTS. BUG=b:259551403 TEST=./twister -T zephyr/test/drivers BRANCH=none Signed-off-by: Andrew McRae Change-Id: Idaed21d75428aae93efd8d97252c63a6cded3ac2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054384 Reviewed-by: Kazuhiro Inaba Reviewed-by: Peter Marheine Commit-Queue: Peter Marheine Code-Coverage: Zoss Reviewed-by: Tirath Ramdas --- zephyr/program/nissa/pujjo/motionsense.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/program/nissa/pujjo/motionsense.dtsi b/zephyr/program/nissa/pujjo/motionsense.dtsi index 1ca53252b6..af21e0509e 100644 --- a/zephyr/program/nissa/pujjo/motionsense.dtsi +++ b/zephyr/program/nissa/pujjo/motionsense.dtsi @@ -227,6 +227,7 @@ port = <&i2c_ec_i2c_sensor>; rot-standard-ref = <&base_rot_lsm6dsm>; drv-data = <&lsm6dsm_data_gyro>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ alternate-for = <&base_gyro>; alternate-ssfc-indicator = <&base_sensor_1>; }; -- cgit v1.2.1 From 2856f03d0c61a6fd4ba89b63cec09689c4a9004e Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Tue, 22 Nov 2022 16:16:52 +0800 Subject: kconfig: remove tablet mode config dependency Detachable device may use only GMR sensor or base attach signal to detect tablet mode. Lid angle is not required to enable tablet mode switch. Thus remove the lid angle -> table mode dependency. BUG=b:251747125 TEST=zmake build --all BRANCH=none Signed-off-by: Ting Shen Change-Id: I49993bafb3f30d5eede359f509142f1618e24629 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4045300 Reviewed-by: Keith Short Commit-Queue: Ting Shen Tested-by: Ting Shen Code-Coverage: Zoss --- zephyr/Kconfig.motionsense | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/zephyr/Kconfig.motionsense b/zephyr/Kconfig.motionsense index af859e0075..86a7fb08bc 100644 --- a/zephyr/Kconfig.motionsense +++ b/zephyr/Kconfig.motionsense @@ -93,10 +93,9 @@ config PLATFORM_EC_LID_ANGLE peripheral devices(refer "Lid Angle Update" below). # TODO(b/173507858): add more detail after .dts change -if PLATFORM_EC_LID_ANGLE - config PLATFORM_EC_LID_ANGLE_UPDATE bool "Lid Angle Update" + depends on PLATFORM_EC_LID_ANGLE help Enable this to allow using the lid angle measurement to determine if peripheral devices should be enabled or disabled, like key scanning, @@ -127,7 +126,6 @@ config PLATFORM_EC_GMR_TABLET_MODE in common/tablet_mode.c. endif # PLATFORM_EC_TABLET_MODE -endif # PLATFORM_EC_LID_ANGLE config PLATFORM_EC_CONSOLE_CMD_ACCELS bool "Console commands: accels, accelrate, accelinit, accelinfo, etc." -- cgit v1.2.1 From 0bf0c1668746e60a1681a19f7b14614714800e0e Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Thu, 24 Nov 2022 13:34:13 +1100 Subject: marasov: use default board_set_charge_limit implementation The brya baseboard already configures the minimum current limit suitable for use with the default implementation. Delete the copy from this board. BUG=b:163093572 TEST=make buildall BRANCH=none Signed-off-by: Peter Marheine Change-Id: I84a0ddae7d46e70913f7d9b6753cd134bae19072 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4055000 Reviewed-by: Kyle Lin Code-Coverage: Zoss --- board/marasov/charger.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/board/marasov/charger.c b/board/marasov/charger.c index e788aafdd0..68fff4f283 100644 --- a/board/marasov/charger.c +++ b/board/marasov/charger.c @@ -81,10 +81,3 @@ int board_set_active_charge_port(int port) return EC_SUCCESS; } - -__overridable void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - charge_set_input_current_limit( - MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} -- cgit v1.2.1 From bd967de4a3322c2539ea86287fcb8e68e3ba9cff Mon Sep 17 00:00:00 2001 From: ben chen Date: Wed, 23 Nov 2022 11:15:04 +0800 Subject: magolor: delay one second when charger enter low power mode add delay one second waiting for charger enter low power mode BUG=b:259155418 BRANCH=none TEST=checking ec console don't power on until enter hibernate Change-Id: I56b5e1f84f32dc4dea69b0c53b45980cb9b741e7 Signed-off-by: Ben Chen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050016 Reviewed-by: Aseda Aboagye Code-Coverage: Zoss --- board/magolor/board.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/board/magolor/board.c b/board/magolor/board.c index a8c043ccbb..3ddc1af3d1 100644 --- a/board/magolor/board.c +++ b/board/magolor/board.c @@ -415,6 +415,8 @@ void board_hibernate(void) if (board_get_charger_chip_count() > 1) raa489000_hibernate(1, true); raa489000_hibernate(0, true); + + msleep(1000); /* Wait for charger to enter low power mode */ } void board_reset_pd_mcu(void) -- cgit v1.2.1 From da3edd8d4ff1b62bc96ea7931f0154548be5cac6 Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Tue, 8 Nov 2022 16:10:38 +0800 Subject: zephyr: rt9490: merge charger and bc12 dt nodes Devices that using rt9490 has a warning message during build: Warning (unique_unit_address_if_enabled): /soc/i2c@f01c40/rt9490-bc12@53: duplicate unit-address (also used in node /soc/i2c@f01c40/rt9490@53) Fix the warning by merging the two conflicting nodes. BUG=none TEST=manually verified on tentacruel BRANCH=none Signed-off-by: Ting Shen Change-Id: I098607b4c7321e4182b8ed37a229ee3ed2bfd973 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4010984 Code-Coverage: Zoss Auto-Submit: Ting Shen Commit-Queue: Eric Yilun Lin Tested-by: Ting Shen Reviewed-by: Eric Yilun Lin --- zephyr/dts/bindings/charger/richtek,rt9490.yaml | 11 ++++++++--- zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml | 15 --------------- zephyr/program/corsola/adc_tentacruel.dtsi | 2 +- zephyr/program/corsola/i2c_krabby.dtsi | 3 ++- zephyr/program/corsola/i2c_magikarp.dtsi | 3 ++- zephyr/program/corsola/i2c_tentacruel.dtsi | 3 ++- zephyr/program/corsola/ite_i2c.dtsi | 7 ------- zephyr/program/corsola/ite_usbc.dtsi | 4 ++-- zephyr/program/corsola/usbc_magikarp.dtsi | 4 ++-- zephyr/program/corsola/usbc_tentacruel.dtsi | 4 ++-- zephyr/shim/include/usbc/bc12_rt9490.h | 2 +- zephyr/shim/src/bc12_rt9490.c | 2 +- zephyr/test/drivers/rt9490/charger.dts | 11 +++-------- 13 files changed, 26 insertions(+), 45 deletions(-) delete mode 100644 zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml diff --git a/zephyr/dts/bindings/charger/richtek,rt9490.yaml b/zephyr/dts/bindings/charger/richtek,rt9490.yaml index ecd25696f3..0f9acf999a 100644 --- a/zephyr/dts/bindings/charger/richtek,rt9490.yaml +++ b/zephyr/dts/bindings/charger/richtek,rt9490.yaml @@ -9,6 +9,11 @@ compatible: "richtek,rt9490" include: chg-chip.yaml properties: - thermistor: - type: phandle - description: Underlying thermistor device to measure temperature + irq: + type: phandles + description: | + GPIO interrupt from BC1.2 + + thermistor: + type: phandle + description: Underlying thermistor device to measure temperature diff --git a/zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml b/zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml deleted file mode 100644 index 38791d65bf..0000000000 --- a/zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: USBC BC1.2 - -compatible: "richtek,rt9490-bc12" - -include: base.yaml - -properties: - irq: - type: phandles - description: | - GPIO interrupt from BC1.2 diff --git a/zephyr/program/corsola/adc_tentacruel.dtsi b/zephyr/program/corsola/adc_tentacruel.dtsi index 7ab6f8817b..63ecb23a8e 100644 --- a/zephyr/program/corsola/adc_tentacruel.dtsi +++ b/zephyr/program/corsola/adc_tentacruel.dtsi @@ -62,7 +62,7 @@ temp_host_high = <68>; temp_host_halt = <90>; temp_host_release_high = <59>; - sensor = <&charger>; + sensor = <&charger_bc12_port1>; }; }; }; diff --git a/zephyr/program/corsola/i2c_krabby.dtsi b/zephyr/program/corsola/i2c_krabby.dtsi index a873210ff7..102ec4947c 100644 --- a/zephyr/program/corsola/i2c_krabby.dtsi +++ b/zephyr/program/corsola/i2c_krabby.dtsi @@ -6,10 +6,11 @@ #include "ite_i2c.dtsi" &i2c0 { - charger: rt9490@53 { + charger_bc12_port1: rt9490@53 { compatible = "richtek,rt9490"; status = "okay"; reg = <0x53>; + irq = <&int_usb_c1_bc12_charger>; }; }; diff --git a/zephyr/program/corsola/i2c_magikarp.dtsi b/zephyr/program/corsola/i2c_magikarp.dtsi index 45b7cf20fb..0dfd317b88 100644 --- a/zephyr/program/corsola/i2c_magikarp.dtsi +++ b/zephyr/program/corsola/i2c_magikarp.dtsi @@ -6,10 +6,11 @@ #include "ite_i2c.dtsi" &i2c0 { - charger: rt9490@53 { + charger_bc12_port1: rt9490@53 { compatible = "richtek,rt9490"; status = "okay"; reg = <0x53>; + irq = <&int_usb_c1_bc12_charger>; }; }; diff --git a/zephyr/program/corsola/i2c_tentacruel.dtsi b/zephyr/program/corsola/i2c_tentacruel.dtsi index e56119ff86..05203103d5 100644 --- a/zephyr/program/corsola/i2c_tentacruel.dtsi +++ b/zephyr/program/corsola/i2c_tentacruel.dtsi @@ -6,10 +6,11 @@ #include "ite_i2c.dtsi" &i2c0 { - charger: rt9490@53 { + charger_bc12_port1: rt9490@53 { compatible = "richtek,rt9490"; status = "okay"; reg = <0x53>; + irq = <&int_usb_c1_bc12_charger>; thermistor = <&thermistor_rt9490>; }; }; diff --git a/zephyr/program/corsola/ite_i2c.dtsi b/zephyr/program/corsola/ite_i2c.dtsi index 6fd153e1fa..ba8e31423a 100644 --- a/zephyr/program/corsola/ite_i2c.dtsi +++ b/zephyr/program/corsola/ite_i2c.dtsi @@ -62,13 +62,6 @@ address-width = <8>; timeout = <5>; }; - - bc12_port1: rt9490-bc12@53 { - compatible = "richtek,rt9490-bc12"; - status = "okay"; - reg = <0x53>; - irq = <&int_usb_c1_bc12_charger>; - }; }; &i2c1 { diff --git a/zephyr/program/corsola/ite_usbc.dtsi b/zephyr/program/corsola/ite_usbc.dtsi index a72864da35..f8881e437c 100644 --- a/zephyr/program/corsola/ite_usbc.dtsi +++ b/zephyr/program/corsola/ite_usbc.dtsi @@ -14,7 +14,7 @@ bc12 = <&bc12_ppc_port0>; ppc = <&bc12_ppc_port0>; tcpc = <&usbpd0>; - chg = <&charger>; + chg = <&charger_bc12_port1>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&it5205_mux_0 &virtual_mux_0>; @@ -29,7 +29,7 @@ port1@1 { compatible = "named-usbc-port"; reg = <1>; - bc12 = <&bc12_port1>; + bc12 = <&charger_bc12_port1>; ppc = <&ppc_port1>; tcpc = <&usbpd1>; usb-mux-chain-1 { diff --git a/zephyr/program/corsola/usbc_magikarp.dtsi b/zephyr/program/corsola/usbc_magikarp.dtsi index c94db15b3a..1d96f2a194 100644 --- a/zephyr/program/corsola/usbc_magikarp.dtsi +++ b/zephyr/program/corsola/usbc_magikarp.dtsi @@ -14,7 +14,7 @@ bc12 = <&bc12_port0>; ppc = <&ppc_port0>; tcpc = <&usbpd0>; - chg = <&charger>; + chg = <&charger_bc12_port1>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&it5205_mux_0 &virtual_mux_0>; @@ -29,7 +29,7 @@ port1@1 { compatible = "named-usbc-port"; reg = <1>; - bc12 = <&bc12_port1>; + bc12 = <&charger_bc12_port1>; ppc = <&ppc_port1>; tcpc = <&usbpd1>; usb-mux-chain-1 { diff --git a/zephyr/program/corsola/usbc_tentacruel.dtsi b/zephyr/program/corsola/usbc_tentacruel.dtsi index bb105a8e08..3a0ead7b3e 100644 --- a/zephyr/program/corsola/usbc_tentacruel.dtsi +++ b/zephyr/program/corsola/usbc_tentacruel.dtsi @@ -15,7 +15,7 @@ ppc = <&bc12_ppc_port0>; ppc_alt = <&ppc_port0>; tcpc = <&usbpd0>; - chg = <&charger>; + chg = <&charger_bc12_port1>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&it5205_mux_0 &virtual_mux_0>; @@ -30,7 +30,7 @@ port1@1 { compatible = "named-usbc-port"; reg = <1>; - bc12 = <&bc12_port1>; + bc12 = <&charger_bc12_port1>; ppc = <&ppc_port1>; tcpc = <&usbpd1>; usb-mux-chain-1 { diff --git a/zephyr/shim/include/usbc/bc12_rt9490.h b/zephyr/shim/include/usbc/bc12_rt9490.h index a9371ddeea..c4323728f9 100644 --- a/zephyr/shim/include/usbc/bc12_rt9490.h +++ b/zephyr/shim/include/usbc/bc12_rt9490.h @@ -5,7 +5,7 @@ #include "driver/charger/rt9490.h" -#define RT9490_BC12_COMPAT richtek_rt9490_bc12 +#define RT9490_BC12_COMPAT richtek_rt9490 #define BC12_CHIP_RT9490(id) \ { \ diff --git a/zephyr/shim/src/bc12_rt9490.c b/zephyr/shim/src/bc12_rt9490.c index 0b30a5d2da..5394069d51 100644 --- a/zephyr/shim/src/bc12_rt9490.c +++ b/zephyr/shim/src/bc12_rt9490.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#define DT_DRV_COMPAT richtek_rt9490_bc12 +#define DT_DRV_COMPAT richtek_rt9490 #include "driver/charger/rt9490.h" #include "gpio/gpio_int.h" diff --git a/zephyr/test/drivers/rt9490/charger.dts b/zephyr/test/drivers/rt9490/charger.dts index 5a3815490f..e74729aaed 100644 --- a/zephyr/test/drivers/rt9490/charger.dts +++ b/zephyr/test/drivers/rt9490/charger.dts @@ -4,26 +4,21 @@ compatible = "named-usbc-port"; reg = <0>; chg = <&rt9490>; - bc12 = <&rt9490_bc12>; + bc12 = <&rt9490>; tcpc = <&tcpci_emul>; }; port1@1 { - bc12 = <&rt9490_bc12>; + bc12 = <&rt9490>; }; }; - - rt9490_bc12: rt9490-bc12 { - compatible = "richtek,rt9490-bc12"; - status = "okay"; - }; }; &i2c0 { status="okay"; rt9490: rt9490@53 { - compatible = "zephyr,rt9490-emul"; + compatible = "zephyr,rt9490-emul", "richtek,rt9490"; status = "okay"; reg = <0x53>; }; -- cgit v1.2.1 From d4be8d3fbb61a50b0a22d56d618db54f1c36ef55 Mon Sep 17 00:00:00 2001 From: Madhurima Paruchuri Date: Thu, 24 Nov 2022 10:50:05 +0000 Subject: zephyr: skyrim: keyboard: Add KSO13 and KSO14 to pinctrl As per schematic of skyrim, the KSO13 and KSO14 are functionally KSO default pins just like KSO12. To use them as similar to other KSO pins, they needs to be configured similar to KSO12. BUG=b:241734677 BRANCH=none TEST=zmake build skyrim --clobber Change-Id: Ied233ca2552a6e192c04f51b2dca9d83fc6aa310 Signed-off-by: Madhurima Paruchuri Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4055740 Reviewed-by: Fabio Baltieri Code-Coverage: Zoss --- zephyr/program/skyrim/keyboard.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zephyr/program/skyrim/keyboard.dts b/zephyr/program/skyrim/keyboard.dts index df334ba54c..aaf305c725 100644 --- a/zephyr/program/skyrim/keyboard.dts +++ b/zephyr/program/skyrim/keyboard.dts @@ -41,6 +41,8 @@ &kso10_gp07 &kso11_gp06 &kso12_gp05 + &kso13_gp04 + &kso14_gp82 >; pinctrl-names = "default"; }; -- cgit v1.2.1 From 24b03d2cb6ee957cebbfb835445fa5c6437c7f0e Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Wed, 23 Nov 2022 14:40:36 -0700 Subject: ec: IWYU Add missing includes Add "chip/stm32/usb_hw.h" for usb_uint Add for size_t Switch from board.h to config.h BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I8d6c7cb89cd54812b90afd9ec06d81f8122fbdc7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4053345 Reviewed-by: Tomasz Michalec Commit-Queue: Tomasz Michalec Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Code-Coverage: Zoss --- chip/ish/ipc_heci.h | 2 ++ chip/max32660/wdt_chip.c | 2 +- chip/stm32/usb_hid_hw.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/chip/ish/ipc_heci.h b/chip/ish/ipc_heci.h index f9372aefa3..96b08f9c4a 100644 --- a/chip/ish/ipc_heci.h +++ b/chip/ish/ipc_heci.h @@ -7,6 +7,8 @@ #ifndef __IPC_HECI_H #define __IPC_HECI_H +#include + enum IPC_ERR { IPC_ERR_IPC_IS_NOT_READY = EC_ERROR_INTERNAL_FIRST + 0, IPC_ERR_TOO_SMALL_BUFFER = EC_ERROR_INTERNAL_FIRST + 1, diff --git a/chip/max32660/wdt_chip.c b/chip/max32660/wdt_chip.c index 03cd2bd009..af9a5d2ef4 100644 --- a/chip/max32660/wdt_chip.c +++ b/chip/max32660/wdt_chip.c @@ -7,6 +7,7 @@ #include "clock.h" #include "common.h" +#include "config.h" #include "gpio.h" #include "hooks.h" #include "task.h" @@ -14,7 +15,6 @@ #include "watchdog.h" #include "console.h" #include "registers.h" -#include "board.h" #include "wdt_regs.h" #define CPUTS(outstr) cputs(CC_COMMAND, outstr) diff --git a/chip/stm32/usb_hid_hw.h b/chip/stm32/usb_hid_hw.h index 54bfca0808..5e28a801c1 100644 --- a/chip/stm32/usb_hid_hw.h +++ b/chip/stm32/usb_hid_hw.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_USB_HID_HW_H #define __CROS_EC_USB_HID_HW_H +#include "chip/stm32/usb_hw.h" + #include struct usb_hid_config_t { -- cgit v1.2.1 From e897b9a8b8ddf22301cc726becfebe9ec1209aaa Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Fri, 25 Nov 2022 10:35:43 +1100 Subject: zephyr: Make Renesas RAA489000 TCPC chip available for Device Tree Refactoring to make RAA489000 work with DT, adding the DT binding, modifying the TCPC shim to find the chip and compat. BUG=b:213963699 TEST=zmake build -a; BRANCH=main LOW_COVERAGE_REASON=Will be covered in Nissa future tests. Change-Id: I85b252a4292755a984db5b517037f26e1e9bbd61 Signed-off-by: Adam Mills Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054312 Code-Coverage: Zoss Commit-Queue: Peter Marheine Reviewed-by: Peter Marheine --- .../dts/bindings/usbc/tcpc/renesas,raa489000.yaml | 16 ++++++++++++++++ zephyr/shim/include/usbc/tcpc_raa489000.h | 21 +++++++++++++++++++++ zephyr/shim/src/tcpc.c | 3 +++ 3 files changed, 40 insertions(+) create mode 100644 zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml create mode 100644 zephyr/shim/include/usbc/tcpc_raa489000.h diff --git a/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml b/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml new file mode 100644 index 0000000000..f8dd9807ed --- /dev/null +++ b/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml @@ -0,0 +1,16 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: Renesas RAA489000 USB TCPC binding + +compatible: "renesas,raa489000" + +include: i2c-device.yaml + +properties: + tcpc-flags: + type: int + default: 0 + description: | + TCPC configuration flags diff --git a/zephyr/shim/include/usbc/tcpc_raa489000.h b/zephyr/shim/include/usbc/tcpc_raa489000.h new file mode 100644 index 0000000000..47e7706ae1 --- /dev/null +++ b/zephyr/shim/include/usbc/tcpc_raa489000.h @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "driver/tcpm/raa489000.h" + +#include + +#define RAA489000_TCPC_COMPAT renesas_raa489000 + +#define TCPC_CONFIG_RAA489000(id) \ + { \ + .bus_type = EC_BUS_TYPE_I2C, \ + .i2c_info = { \ + .port = I2C_PORT_BY_DEV(id), \ + .addr_flags = DT_REG_ADDR(id), \ + }, \ + .drv = &raa489000_tcpm_drv, \ + .flags = DT_PROP(id, tcpc_flags), \ + }, diff --git a/zephyr/shim/src/tcpc.c b/zephyr/shim/src/tcpc.c index eecad4d6ad..6ddad71535 100644 --- a/zephyr/shim/src/tcpc.c +++ b/zephyr/shim/src/tcpc.c @@ -14,6 +14,7 @@ #include "usbc/tcpc_nct38xx.h" #include "usbc/tcpc_ps8xxx.h" #include "usbc/tcpc_ps8xxx_emul.h" +#include "usbc/tcpc_raa489000.h" #include "usbc/tcpc_rt1718s.h" #include "usbc/tcpci.h" #include "usbc/utils.h" @@ -58,6 +59,8 @@ CHECK_COMPAT(PS8XXX_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_PS8XXX) \ CHECK_COMPAT(NCT38XX_TCPC_COMPAT, usbc_id, tcpc_id, \ TCPC_CONFIG_NCT38XX) \ + CHECK_COMPAT(RAA489000_TCPC_COMPAT, usbc_id, tcpc_id, \ + TCPC_CONFIG_RAA489000) \ CHECK_COMPAT(RT1718S_TCPC_COMPAT, usbc_id, tcpc_id, \ TCPC_CONFIG_RT1718S) \ CHECK_COMPAT(TCPCI_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_TCPCI) \ -- cgit v1.2.1 From 62720a799b980f7f47a476f63b99a1d5a51af833 Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Fri, 25 Nov 2022 10:57:20 +1100 Subject: nissa: use device tree for USB-C config Enable support for USB-C configuration on Nissa boards through the device tree rather than in code. BUG=b:213963699 TEST=zmake build -a; Flashed Nereid and Craask devices and verified USB-C ports working. BRANCH=main LOW_COVERAGE_REASON=Nissa specific changes. Change-Id: I2d840da5db5291066f206d9bf3d28dc0bca98307 Signed-off-by: Adam Mills Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054313 Code-Coverage: Zoss Reviewed-by: Peter Marheine --- zephyr/program/nissa/craask/overlay.dtsi | 19 +++++++++++++++++++ zephyr/program/nissa/craask/src/usbc.c | 25 ------------------------- zephyr/program/nissa/joxer/overlay.dtsi | 9 +++++++++ zephyr/program/nissa/joxer/src/usbc.c | 24 ------------------------ zephyr/program/nissa/nereid/overlay.dtsi | 9 +++++++++ zephyr/program/nissa/nereid/src/usbc.c | 24 ------------------------ zephyr/program/nissa/nivviks/overlay.dtsi | 19 +++++++++++++++++++ zephyr/program/nissa/nivviks/src/usbc.c | 27 +-------------------------- zephyr/program/nissa/pujjo/overlay.dtsi | 10 ++++++++++ zephyr/program/nissa/pujjo/src/usbc.c | 14 -------------- zephyr/program/nissa/xivu/overlay.dtsi | 19 +++++++++++++++++++ zephyr/program/nissa/xivu/src/usbc.c | 25 ------------------------- zephyr/program/nissa/yaviks/overlay.dtsi | 9 +++++++++ zephyr/program/nissa/yaviks/src/usbc.c | 24 ------------------------ 14 files changed, 95 insertions(+), 162 deletions(-) diff --git a/zephyr/program/nissa/craask/overlay.dtsi b/zephyr/program/nissa/craask/overlay.dtsi index 59a85d818e..2607c10402 100644 --- a/zephyr/program/nissa/craask/overlay.dtsi +++ b/zephyr/program/nissa/craask/overlay.dtsi @@ -5,6 +5,7 @@ #include #include +#include / { aliases { @@ -212,6 +213,7 @@ reg = <0>; bc12 = <&bc12_port0>; chg = <&chg_port0>; + tcpc = <&tcpc_port0>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_0>; @@ -231,6 +233,7 @@ reg = <1>; bc12 = <&bc12_port1>; chg = <&chg_port1>; + tcpc = <&tcpc_port1>; usb-mux-chain-1 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; @@ -335,6 +338,14 @@ status = "okay"; reg = <0x9>; }; + + tcpc_port0: raa489000@22 { + compatible = "renesas,raa489000"; + reg = <0x22>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR)>; + }; }; &i2c5_1 { @@ -353,6 +364,14 @@ reg = <0x9>; }; + tcpc_port1: raa489000@22 { + compatible = "renesas,raa489000"; + reg = <0x22>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR)>; + }; + anx7483_mux_1: anx7483-mux-1@3e { compatible = "analogix,anx7483"; reg = <0x3e>; diff --git a/zephyr/program/nissa/craask/src/usbc.c b/zephyr/program/nissa/craask/src/usbc.c index a32cc41331..1e0c1627bb 100644 --- a/zephyr/program/nissa/craask/src/usbc.c +++ b/zephyr/program/nissa/craask/src/usbc.c @@ -18,31 +18,6 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, - { /* sub-board */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - int board_is_sourcing_vbus(int port) { int regval; diff --git a/zephyr/program/nissa/joxer/overlay.dtsi b/zephyr/program/nissa/joxer/overlay.dtsi index d0c592a717..56f1d928cf 100644 --- a/zephyr/program/nissa/joxer/overlay.dtsi +++ b/zephyr/program/nissa/joxer/overlay.dtsi @@ -4,6 +4,7 @@ */ #include +#include / { aliases { @@ -245,6 +246,7 @@ reg = <0>; bc12 = <&bc12_port0>; chg = <&chg_port0>; + tcpc = <&usbpd0>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_0>; @@ -260,6 +262,7 @@ reg = <1>; bc12 = <&bc12_port1>; chg = <&chg_port1>; + tcpc = <&tcpc_port1>; usb-mux-chain-1 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; @@ -396,6 +399,12 @@ status = "okay"; reg = <0x32>; }; + + tcpc_port1: ps8745@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; }; &i2c_ec_i2c_sub_usb_c1 { diff --git a/zephyr/program/nissa/joxer/src/usbc.c b/zephyr/program/nissa/joxer/src/usbc.c index 8c81d596dc..8e576c5673 100644 --- a/zephyr/program/nissa/joxer/src/usbc.c +++ b/zephyr/program/nissa/joxer/src/usbc.c @@ -20,30 +20,6 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_EMBEDDED, - /* TCPC is embedded within EC so no i2c config needed */ - .drv = &it8xxx2_tcpm_drv, - /* Alert is active-low, push-pull */ - .flags = 0, - }, - { - /* - * Sub-board: optional PS8745 TCPC+redriver. Behaves the same - * as PS8815. - */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, - }, - .drv = &ps8xxx_tcpm_drv, - /* PS8745 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0, - }, -}; - /* Vconn control for integrated ITE TCPC */ void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) { diff --git a/zephyr/program/nissa/nereid/overlay.dtsi b/zephyr/program/nissa/nereid/overlay.dtsi index a44a3e01bd..36d30a0fce 100644 --- a/zephyr/program/nissa/nereid/overlay.dtsi +++ b/zephyr/program/nissa/nereid/overlay.dtsi @@ -4,6 +4,7 @@ */ #include +#include / { aliases { @@ -217,6 +218,7 @@ reg = <0>; bc12 = <&bc12_port0>; chg = <&chg_port0>; + tcpc = <&usbpd0>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_0>; @@ -232,6 +234,7 @@ reg = <1>; bc12 = <&bc12_port1>; chg = <&chg_port1>; + tcpc = <&tcpc_port1>; usb-mux-chain-1 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; @@ -363,6 +366,12 @@ status = "okay"; reg = <0x32>; }; + + tcpc_port1: ps8745@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; }; &i2c_ec_i2c_sub_usb_c1 { diff --git a/zephyr/program/nissa/nereid/src/usbc.c b/zephyr/program/nissa/nereid/src/usbc.c index 01e48e79e0..1e87abfa0d 100644 --- a/zephyr/program/nissa/nereid/src/usbc.c +++ b/zephyr/program/nissa/nereid/src/usbc.c @@ -20,30 +20,6 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_EMBEDDED, - /* TCPC is embedded within EC so no i2c config needed */ - .drv = &it8xxx2_tcpm_drv, - /* Alert is active-low, push-pull */ - .flags = 0, - }, - { - /* - * Sub-board: optional PS8745 TCPC+redriver. Behaves the same - * as PS8815. - */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, - }, - .drv = &ps8xxx_tcpm_drv, - /* PS8745 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0, - }, -}; - /* Vconn control for integrated ITE TCPC */ void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) { diff --git a/zephyr/program/nissa/nivviks/overlay.dtsi b/zephyr/program/nissa/nivviks/overlay.dtsi index 0875b8891d..c3a8d7a61d 100644 --- a/zephyr/program/nissa/nivviks/overlay.dtsi +++ b/zephyr/program/nissa/nivviks/overlay.dtsi @@ -5,6 +5,7 @@ #include #include +#include / { aliases { @@ -219,6 +220,7 @@ reg = <0>; bc12 = <&bc12_port0>; chg = <&chg_port0>; + tcpc = <&tcpc_port0>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_0>; @@ -238,6 +240,7 @@ reg = <1>; bc12 = <&bc12_port1>; chg = <&chg_port1>; + tcpc = <&tcpc_port1>; usb-mux-chain-1 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; @@ -350,6 +353,14 @@ status = "okay"; reg = <0x9>; }; + + tcpc_port0: raa489000@22 { + compatible = "renesas,raa489000"; + reg = <0x22>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR)>; + }; }; &i2c5_1 { @@ -368,6 +379,14 @@ reg = <0x9>; }; + tcpc_port1: raa489000@22 { + compatible = "renesas,raa489000"; + reg = <0x22>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR)>; + }; + anx7483_mux_1: anx7483-mux-1@3e { compatible = "analogix,anx7483"; reg = <0x3e>; diff --git a/zephyr/program/nissa/nivviks/src/usbc.c b/zephyr/program/nissa/nivviks/src/usbc.c index 5b0eed5aea..1e0c1627bb 100644 --- a/zephyr/program/nissa/nivviks/src/usbc.c +++ b/zephyr/program/nissa/nivviks/src/usbc.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The ChromiumOS Authors +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -18,31 +18,6 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, - { /* sub-board */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - int board_is_sourcing_vbus(int port) { int regval; diff --git a/zephyr/program/nissa/pujjo/overlay.dtsi b/zephyr/program/nissa/pujjo/overlay.dtsi index a2c5ff4471..4916a4ec90 100644 --- a/zephyr/program/nissa/pujjo/overlay.dtsi +++ b/zephyr/program/nissa/pujjo/overlay.dtsi @@ -4,6 +4,7 @@ */ #include +#include / { aliases { @@ -213,6 +214,7 @@ reg = <0>; bc12 = <&bc12_port0>; chg = <&chg_port0>; + tcpc = <&tcpc_port0>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_0>; @@ -309,6 +311,14 @@ status = "okay"; reg = <0x9>; }; + + tcpc_port0: raa489000@22 { + compatible = "renesas,raa489000"; + reg = <0x22>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR)>; + }; }; &i2c7_0 { diff --git a/zephyr/program/nissa/pujjo/src/usbc.c b/zephyr/program/nissa/pujjo/src/usbc.c index b56e36049c..ac93edfd7a 100644 --- a/zephyr/program/nissa/pujjo/src/usbc.c +++ b/zephyr/program/nissa/pujjo/src/usbc.c @@ -18,20 +18,6 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - int board_is_sourcing_vbus(int port) { int regval; diff --git a/zephyr/program/nissa/xivu/overlay.dtsi b/zephyr/program/nissa/xivu/overlay.dtsi index f5ea6bc258..402f0e2f2f 100644 --- a/zephyr/program/nissa/xivu/overlay.dtsi +++ b/zephyr/program/nissa/xivu/overlay.dtsi @@ -5,6 +5,7 @@ #include #include +#include / { aliases { @@ -215,6 +216,7 @@ reg = <0>; bc12 = <&bc12_port0>; chg = <&chg_port0>; + tcpc = <&tcpc_port0>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_0>; @@ -234,6 +236,7 @@ reg = <1>; bc12 = <&bc12_port1>; chg = <&chg_port1>; + tcpc = <&tcpc_port1>; usb-mux-chain-1 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; @@ -319,6 +322,14 @@ status = "okay"; reg = <0x9>; }; + + tcpc_port0: raa489000@22 { + compatible = "renesas,raa489000"; + reg = <0x22>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR)>; + }; }; &i2c5_1 { @@ -337,6 +348,14 @@ reg = <0x9>; }; + tcpc_port1: raa489000@22 { + compatible = "renesas,raa489000"; + reg = <0x22>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR)>; + }; + anx7483_mux_1: anx7483-mux-1@3e { compatible = "analogix,anx7483"; reg = <0x3e>; diff --git a/zephyr/program/nissa/xivu/src/usbc.c b/zephyr/program/nissa/xivu/src/usbc.c index 54a9244ecc..174eb07c60 100644 --- a/zephyr/program/nissa/xivu/src/usbc.c +++ b/zephyr/program/nissa/xivu/src/usbc.c @@ -19,31 +19,6 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, - { /* sub-board */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = RAA489000_TCPC0_I2C_FLAGS, - }, - .drv = &raa489000_tcpm_drv, - /* RAA489000 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0 | - TCPC_FLAGS_VBUS_MONITOR, - }, -}; - int board_is_sourcing_vbus(int port) { int regval; diff --git a/zephyr/program/nissa/yaviks/overlay.dtsi b/zephyr/program/nissa/yaviks/overlay.dtsi index 2a5a8561a0..2b5f1e453d 100644 --- a/zephyr/program/nissa/yaviks/overlay.dtsi +++ b/zephyr/program/nissa/yaviks/overlay.dtsi @@ -4,6 +4,7 @@ */ #include +#include / { aliases { @@ -201,6 +202,7 @@ reg = <0>; bc12 = <&bc12_port0>; chg = <&chg_port0>; + tcpc = <&usbpd0>; usb-mux-chain-0 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_0>; @@ -216,6 +218,7 @@ reg = <1>; bc12 = <&bc12_port1>; chg = <&chg_port1>; + tcpc = <&tcpc_port1>; usb-mux-chain-1 { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&virtual_mux_1 &tcpci_mux_1>; @@ -336,6 +339,12 @@ status = "okay"; reg = <0x32>; }; + + tcpc_port1: ps8745@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; }; &i2c_ec_i2c_sub_usb_c1 { diff --git a/zephyr/program/nissa/yaviks/src/usbc.c b/zephyr/program/nissa/yaviks/src/usbc.c index 01e48e79e0..1e87abfa0d 100644 --- a/zephyr/program/nissa/yaviks/src/usbc.c +++ b/zephyr/program/nissa/yaviks/src/usbc.c @@ -20,30 +20,6 @@ LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_EMBEDDED, - /* TCPC is embedded within EC so no i2c config needed */ - .drv = &it8xxx2_tcpm_drv, - /* Alert is active-low, push-pull */ - .flags = 0, - }, - { - /* - * Sub-board: optional PS8745 TCPC+redriver. Behaves the same - * as PS8815. - */ - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1_TCPC, - .addr_flags = PS8XXX_I2C_ADDR1_FLAGS, - }, - .drv = &ps8xxx_tcpm_drv, - /* PS8745 implements TCPCI 2.0 */ - .flags = TCPC_FLAGS_TCPCI_REV2_0, - }, -}; - /* Vconn control for integrated ITE TCPC */ void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) { -- cgit v1.2.1 From ae03c203db5587bdb48768cecb3d2986fba40650 Mon Sep 17 00:00:00 2001 From: Siyu Qin Date: Mon, 31 Oct 2022 21:14:41 +0800 Subject: corsola: Initial zephyr config for Voltorb Initial EC Zephyr config for Corsola/Voltorb. Reuse most of Kingler sources. BUG=b:256573843 BRANCH=corsola TEST=zmake build voltorb Change-Id: I9bb960a4a635baf666b82db988f4a54512a30d1b Signed-off-by: Siyu Qin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3993603 Reviewed-by: Ting Shen Reviewed-by: wen zhang Code-Coverage: Zoss Reviewed-by: Mike Lee --- zephyr/program/corsola/BUILD.py | 5 + zephyr/program/corsola/CMakeLists.txt | 9 +- zephyr/program/corsola/Kconfig | 6 + zephyr/program/corsola/voltorb/project.conf | 41 ++++ zephyr/program/corsola/voltorb/project.overlay | 309 +++++++++++++++++++++++++ 5 files changed, 369 insertions(+), 1 deletion(-) create mode 100644 zephyr/program/corsola/voltorb/project.conf create mode 100644 zephyr/program/corsola/voltorb/project.overlay diff --git a/zephyr/program/corsola/BUILD.py b/zephyr/program/corsola/BUILD.py index 3b22dbe0ad..f145953e0d 100644 --- a/zephyr/program/corsola/BUILD.py +++ b/zephyr/program/corsola/BUILD.py @@ -45,3 +45,8 @@ register_corsola_project( register_corsola_project("tentacruel") register_corsola_project("magikarp") + +register_corsola_project( + project_name="voltorb", + chip="npcx9m3f", +) diff --git a/zephyr/program/corsola/CMakeLists.txt b/zephyr/program/corsola/CMakeLists.txt index fa899a0e77..33aa0804d2 100644 --- a/zephyr/program/corsola/CMakeLists.txt +++ b/zephyr/program/corsola/CMakeLists.txt @@ -77,5 +77,12 @@ elseif(DEFINED CONFIG_BOARD_MAGIKARP) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/krabby/usbc_config.c") -endif() +elseif(DEFINED CONFIG_BOARD_VOLTORB) + project(voltorb) + 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 + "src/kingler/usbc_config.c") +endif() diff --git a/zephyr/program/corsola/Kconfig b/zephyr/program/corsola/Kconfig index 4f66601c20..731de33d8b 100644 --- a/zephyr/program/corsola/Kconfig +++ b/zephyr/program/corsola/Kconfig @@ -32,6 +32,12 @@ config BOARD_MAGIKARP Build Google Magikarp variant board. Magikarp is a variant of Krabby and has MediaTek MT8186 SoC with ITE it81202-bx EC. +config BOARD_VOLTORB + bool "Google Voltorb Board" + help + Build Google Voltorb variant board. Voltorb is a variant of Kingler + and has MediaTek MT8186/MT8186T SoC with NPCX993FA0BX EC. + config VARIANT_CORSOLA_DB_DETECTION bool "Corsola Platform Runtime Daughter Board Detection" depends on PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG diff --git a/zephyr/program/corsola/voltorb/project.conf b/zephyr/program/corsola/voltorb/project.conf new file mode 100644 index 0000000000..c1be25bfc1 --- /dev/null +++ b/zephyr/program/corsola/voltorb/project.conf @@ -0,0 +1,41 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_VOLTORB=y + +# Voltorb only use D2, drop the workaround config for H1 +CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n + +# No A+Gsensor +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=n +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=n +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n +CONFIG_PLATFORM_EC_ACCEL_FIFO=n +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n +CONFIG_PLATFORM_EC_LID_ANGLE=n +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n +CONFIG_PLATFORM_EC_MOTIONSENSE=n +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n +CONFIG_PLATFORM_EC_TABLET_MODE=n +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=n +CONFIG_PLATFORM_EC_LED_ONOFF_STATES=n +CONFIG_PLATFORM_EC_LED_DT=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y + +# USBC +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250 +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 + +# AC_OK debounce time +CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 diff --git a/zephyr/program/corsola/voltorb/project.overlay b/zephyr/program/corsola/voltorb/project.overlay new file mode 100644 index 0000000000..8cd5a2bad8 --- /dev/null +++ b/zephyr/program/corsola/voltorb/project.overlay @@ -0,0 +1,309 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Corsola program common DTS includes */ + +#include "../common.dtsi" +#include "../power_signal.dtsi" +#include "../usba.dtsi" +#include "../npcx_adc.dtsi" +#include "../npcx_gpio.dtsi" +#include "../npcx_host_interface.dtsi" +#include "../npcx_i2c.dtsi" +#include "../npcx_interrupts.dtsi" +#include "../npcx_keyboard.dtsi" +#include "../npcx_usbc.dtsi" +#include "../npcx_default_gpio_pinctrl.dtsi" +#include + +/ { + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* base_imu_int_l */ + <&gpio5 6 0>, + /* ec_pen_chg_dis_odl */ + <&gpioe 4 0>, + /* lid_accel_int_l */ + <&gpiob 3 0>, + /* gpio_tablet_mode_l */ + <&gpiob 2 0>, + /* LED3 */ + <&gpioc 4 0>; + }; + + batteries { + default_battery: lgc_ap18c8k { + compatible = "lgc,ap18c8k", "battery-smart"; + }; + cosmx_ap20cbl-2 { + compatible = "cosmx,ap20cbl-2", "battery-smart"; + }; + }; + + cros-keyscan { + compatible = "cros-ec,keyscan"; + + debounce-down = <20000>; + debounce-up = <20000>; + + actual-key-mask = < + 0x1c /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; + + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + /* Voltorb LED bat charge */ + bat-power-state-charge-lvl-1 { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = ; + + color-0 { + led-color = <&color_amber>; + }; + }; + bat-power-state-charge-lvl-2 { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= 96%) */ + batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) + (BATTERY_LEVEL_NEAR_FULL - 1)>; + + color-0 { + led-color = <&color_blue>; + }; + }; + + /* Voltorb LED bat charge near full */ + bat-power-state-charge-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + /* Voltorb LED bat discharge */ + bat-power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 14%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 4) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_blue>; + }; + }; + bat-power-state-discharge-s0-bat-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 7%, <= 13%) */ + batt-lvl = <(BATTERY_LEVEL_CRITICAL + 2) + (BATTERY_LEVEL_LOW + 3)>; + + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + bat-power-state-discharge-s0-bat-critical { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= 6%) */ + batt-lvl = ; + + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + bat-power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + bat-power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + /* Voltorb LED bat error */ + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + bat-power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + bat-power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + /* Voltorb LED power idle */ + power-state-idle { + charge-state = "PWR_STATE_IDLE"; + + color-0 { + led-color = <&color_blue>; + }; + }; + + /* Voltorb LED power forced idle */ + power-state-forced-idle-right { + charge-state = "PWR_STATE_FORCED_IDLE"; + + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_blue>; + period-ms = <2000>; + }; + }; + }; + + pwmleds { + compatible = "pwm-leds"; + + led_amber: ec_led1_odl { + pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + + led_blue: ec_led2_odl { + pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&led_amber &led_blue>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&led_amber &led_blue>; + led-values = <100 0>; + }; + + color_blue: color_blue { + led-color = "LED_BLUE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_BLUE"; + led-pwms = <&led_amber &led_blue>; + led-values = <0 100>; + }; + }; +}; + +/* Amber LED */ +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +/* Blue LED */ +&pwm1_gpc2 { + drive-open-drain; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +/* gpio overrides */ +/ { + named-gpios { + /delete-node/ base_imu_int_l; + /delete-node/ ec_pen_chg_dis_odl; + /delete-node/ lid_accel_int_l; + /delete-node/ gpio_tablet_mode_l; + }; +}; + +/* interrupts overrides */ +/ { + gpio-interrupts { + /delete-node/ base_imu; + /delete-node/ tablet_mode; + }; +}; -- cgit v1.2.1 From 0fdab007bed8126649b2f29fcdb0a7f26fb1ff16 Mon Sep 17 00:00:00 2001 From: Raymond Chung Date: Tue, 22 Nov 2022 15:48:48 +0800 Subject: gaelin: Keep backlight and speaker power control for display This change adds to keep backlight and speaker always on to unlock proto 2 power on validation. We'll keep following on it to figure out the correct behavior for backlight/speaker power control and implement in EC. BUG=b:249000573, b:259321814 BRANCH=None TEST="make -j BOARD=gaelin" and normal display. Change-Id: Id4c60a26f74957e57c5ea4230f70ea02660236ed Signed-off-by: Raymond Chung Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4043947 Code-Coverage: Zoss Reviewed-by: Derek Huang Commit-Queue: Derek Huang --- board/gaelin/gpio.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/board/gaelin/gpio.inc b/board/gaelin/gpio.inc index fcd39ad8bc..6de7003743 100644 --- a/board/gaelin/gpio.inc +++ b/board/gaelin/gpio.inc @@ -46,7 +46,11 @@ GPIO(ANALOG_PPVAR_PWR_IN_IMON_EC, PIN(4, 2), GPIO_INPUT) /* Display */ GPIO(EC_OVERRIDE_SCLR_EN, PIN(D, 4), GPIO_OUT_HIGH) -GPIO(EC_12VSC_EN, PIN(D, 2), GPIO_OUT_LOW) + +/* TODO(b/260063632): the gpio pin control is wip, setting to level high + to enable the backlight by default */ +GPIO(EC_12VSC_EN, PIN(D, 2), GPIO_OUT_HIGH) + GPIO(OSD_STS, PIN(4, 1), GPIO_INPUT) GPIO(DISP_MODE, PIN(A, 0), GPIO_INPUT) GPIO(PANEL_PWR_STS, PIN(9, 5), GPIO_INPUT) @@ -57,7 +61,9 @@ GPIO(WP_EC, PIN(C, 3), GPIO_INPUT) GPIO(OSD_INT, PIN(0, 5), GPIO_INPUT) /* Audio */ -GPIO(EC_AMP_SD, PIN(5, 6), GPIO_OUT_LOW) +/* TODO(b/260063632): the gpio pin control is wip, setting to level high + to enable the speaker by default */ +GPIO(EC_AMP_SD, PIN(5, 6), GPIO_OUT_HIGH) /* BarrelJack */ GPIO(EN_PPVAR_BJ_ADP_L, PIN(0, 7), GPIO_OUT_LOW) -- cgit v1.2.1 From e10c75edd1c17eb70f7faf9add22cb7f50e2eee2 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Tue, 22 Nov 2022 22:23:18 -0700 Subject: build: update build cmake files for unit tests Adding the unittest Zephyr component now updates the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER values. This means that find_package needs to be called prior to any of the test library commands so the right compiler is set for all the libraries. Twister launcher no longer needs to set the compiler as an argument to CMake. zephyr/cmake compiler and toolchain required updates to play nice with posix/unit_testing architectures. These included: 1. Conditionally adding the -fno-PIC flag 2. Setting CMAKE_CXX_COMPILER for clang 3. Adding a unit_testing cross compile target to the llvm and host toolchain BRANCH=none BUG=none TEST=./twister Cq-Depend: chromium:4047569 Signed-off-by: Yuval Peress Change-Id: Ib1e8ddcb526a56c05ef925d4d9ab97cb65004038 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050266 Reviewed-by: Fabio Baltieri Code-Coverage: Zoss --- common/spi/flash_reg/CMakeLists.txt | 8 +++----- util/twister_launcher.py | 18 ------------------ zephyr/cmake/compiler/clang/compiler_flags.cmake | 6 +++++- zephyr/cmake/compiler/clang/generic.cmake | 1 + zephyr/cmake/toolchain/host/generic.cmake | 3 ++- zephyr/cmake/toolchain/llvm/target.cmake | 3 ++- 6 files changed, 13 insertions(+), 26 deletions(-) diff --git a/common/spi/flash_reg/CMakeLists.txt b/common/spi/flash_reg/CMakeLists.txt index fda467d2e4..55708ac57e 100644 --- a/common/spi/flash_reg/CMakeLists.txt +++ b/common/spi/flash_reg/CMakeLists.txt @@ -6,6 +6,7 @@ cmake_minimum_required(VERSION 3.20.0) # Create the library if(BOARD STREQUAL unit_testing) + find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) add_library(spi_flash_reg) else() zephyr_library_named(spi_flash_reg) @@ -45,11 +46,8 @@ target_include_directories(spi_flash_reg PUBLIC public) if(BOARD STREQUAL unit_testing) project(flash_reg) - # Set the sources for the test (must be done before find_package) - set(SOURCES src/spi_flash_reg_test.c) - - # Create the unittest libraries and binary - find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) + # Set the sources for the test + target_sources(testbinary PRIVATE src/spi_flash_reg_test.c) # Link the library being tested target_link_libraries(testbinary PRIVATE spi_flash_reg) diff --git a/util/twister_launcher.py b/util/twister_launcher.py index 400aabbcd1..ef41b7621b 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -350,26 +350,8 @@ def main(): } gcov_tool = None if intercepted_args.toolchain == "host": - append_cmake_compiler( - twister_cli, "CMAKE_C_COMPILER", ["x86_64-pc-linux-gnu-gcc", "gcc"] - ) - append_cmake_compiler( - twister_cli, - "CMAKE_CXX_COMPILER", - ["x86_64-pc-linux-gnu-g++", "g++"], - ) gcov_tool = "gcov" elif intercepted_args.toolchain == "llvm": - append_cmake_compiler( - twister_cli, - "CMAKE_C_COMPILER", - ["x86_64-pc-linux-gnu-clang", "clang"], - ) - append_cmake_compiler( - twister_cli, - "CMAKE_CXX_COMPILER", - ["x86_64-pc-linux-gnu-clang++", "clang++"], - ) gcov_tool = str(ec_base / "util" / "llvm-gcov.sh") else: print("Unknown toolchain specified:", intercepted_args.toolchain) diff --git a/zephyr/cmake/compiler/clang/compiler_flags.cmake b/zephyr/cmake/compiler/clang/compiler_flags.cmake index e1d91504ea..536540eb1e 100644 --- a/zephyr/cmake/compiler/clang/compiler_flags.cmake +++ b/zephyr/cmake/compiler/clang/compiler_flags.cmake @@ -8,7 +8,11 @@ include("${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake") set_compiler_property(PROPERTY hosted) # Disable position independent code. -add_compile_options(-fno-PIC) +if ("${ARCH}" STREQUAL "posix" OR "${ARCH}" STREQUAL "unit_testing") + add_compile_options(-fPIC) +else() + add_compile_options(-fno-PIC) +endif() # When testing, look for stack smashing add_compile_option_ifdef(CONFIG_ZTEST -fstack-protector-all) diff --git a/zephyr/cmake/compiler/clang/generic.cmake b/zephyr/cmake/compiler/clang/generic.cmake index b848c8bd03..a59b7e4a72 100644 --- a/zephyr/cmake/compiler/clang/generic.cmake +++ b/zephyr/cmake/compiler/clang/generic.cmake @@ -3,4 +3,5 @@ # found in the LICENSE file. set(CMAKE_C_COMPILER "/usr/bin/x86_64-pc-linux-gnu-clang") +set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-pc-linux-gnu-clang++") set(CMAKE_GCOV "/usr/bin/llvm-cov gcov") diff --git a/zephyr/cmake/toolchain/host/generic.cmake b/zephyr/cmake/toolchain/host/generic.cmake index 41ce729fa4..4cc0fbd352 100644 --- a/zephyr/cmake/toolchain/host/generic.cmake +++ b/zephyr/cmake/toolchain/host/generic.cmake @@ -2,7 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu) +set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu) +set(CROSS_COMPILE_TARGET_unit_testing x86_64-pc-linux-gnu) set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}}) set(CC gcc) diff --git a/zephyr/cmake/toolchain/llvm/target.cmake b/zephyr/cmake/toolchain/llvm/target.cmake index e6960dade5..00669a590b 100644 --- a/zephyr/cmake/toolchain/llvm/target.cmake +++ b/zephyr/cmake/toolchain/llvm/target.cmake @@ -8,7 +8,8 @@ set(BINTOOLS llvm) # Mapping of Zephyr architecture -> toolchain triple # Note only "posix" is supported at the moment. -set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu) +set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu) +set(CROSS_COMPILE_TARGET_unit_testing x86_64-pc-linux-gnu) set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}}) -- cgit v1.2.1 From a6dfae38361b8b63727c2ff0d3e3f17215cd773c Mon Sep 17 00:00:00 2001 From: Liam Flaherty Date: Thu, 24 Nov 2022 13:13:32 +1100 Subject: dibbi: Update board specific power implementation Removed battery and battery charging support, as dibbi does not have either of these. Added support for dual barrel-jack/USB-C power supplies and update USB PD policies accordingly. Added support for USB-C0 output load-switch. Made changes in dedede baseboard to allow alternate implementation of extpower_is_present with the absence of a charger chip. BUG=b:257377326 BRANCH=dedede TEST=make -j BOARD=dibbi Signed-off-by: Liam Flaherty Change-Id: I81d01a88caf174eb038685bf098686e8a310a9b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054386 Code-Coverage: Zoss Reviewed-by: Sam McNally Reviewed-by: Adam Mills Tested-by: Adam Mills --- baseboard/dedede/baseboard.c | 2 + board/dibbi/battery.c | 331 --------------------------------- board/dibbi/board.c | 429 ++++++++++++++++++++++++------------------- board/dibbi/board.h | 105 ++++++----- board/dibbi/build.mk | 1 - board/dibbi/ec.tasklist | 11 +- board/dibbi/gpio.inc | 27 +-- board/dibbi/led.c | 54 +----- board/dibbi/usb_pd_policy.c | 55 +++--- 9 files changed, 338 insertions(+), 677 deletions(-) delete mode 100644 board/dibbi/battery.c diff --git a/baseboard/dedede/baseboard.c b/baseboard/dedede/baseboard.c index cd55f37588..22034a09bd 100644 --- a/baseboard/dedede/baseboard.c +++ b/baseboard/dedede/baseboard.c @@ -294,6 +294,7 @@ int board_is_i2c_port_powered(int port) return chipset_in_state(CHIPSET_STATE_ANY_OFF) ? 0 : 1; } +#if defined(CONFIG_CHARGER_RAA489000) || defined(CONFIG_CHARGER_SM5803) __overridable int extpower_is_present(void) { int port; @@ -314,6 +315,7 @@ __overridable int extpower_is_present(void) return 0; } +#endif __override uint32_t board_override_feature_flags0(uint32_t flags0) { diff --git a/board/dibbi/battery.c b/board/dibbi/battery.c deleted file mode 100644 index 99f458a4aa..0000000000 --- a/board/dibbi/battery.c +++ /dev/null @@ -1,331 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery pack vendor provided charging profile - */ - -#include "battery_fuel_gauge.h" -#include "charge_state.h" -#include "common.h" - -/* - * Battery info for all waddledee battery types. Note that the fields - * start_charging_min/max and charging_min/max are not used for the charger. - * The effective temperature limits are given by discharging_min/max_c. - * - * Fuel Gauge (FG) parameters which are used for determining if the battery - * is connected, the appropriate ship mode (battery cutoff) command, and the - * charge/discharge FETs status. - * - * Ship mode (battery cutoff) requires 2 writes to the appropriate smart battery - * register. For some batteries, the charge/discharge FET bits are set when - * charging/discharging is active, in other types, these bits set mean that - * charging/discharging is disabled. Therefore, in addition to the mask for - * these bits, a disconnect value must be specified. Note that for TI fuel - * gauge, the charge/discharge FET status is found in Operation Status (0x54), - * but a read of Manufacturer Access (0x00) will return the lower 16 bits of - * Operation status which contains the FET status bits. - * - * The assumption for battery types supported is that the charge/discharge FET - * status can be read with a sb_read() command and therefore, only the register - * address, mask, and disconnect value need to be provided. - */ -const struct board_batt_params board_battery_info[] = { - /* LGC AC15A8J Battery Information */ - [BATTERY_LGC15] = { - .fuel_gauge = { - .manuf_name = "LGC", - .device_name = "AC15A8J", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .mfgacc_support = 1, - .reg_addr = 0x0, - .reg_mask = 0x0002, - .disconnect_val = 0x0, - } - }, - .batt_info = { - .voltage_max = 13200, - .voltage_normal = 11520, /* mV */ - .voltage_min = 9000, /* mV */ - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, - }, - }, - - /* Panasonic AP1505L Battery Information */ - [BATTERY_PANASONIC_AP15O5L] = { - .fuel_gauge = { - .manuf_name = "PANASONIC", - .device_name = "AP15O5L", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .reg_addr = 0x0, - .reg_mask = 0x4000, - .disconnect_val = 0x0, - } - }, - .batt_info = { - .voltage_max = 13200, - .voltage_normal = 11550, /* mV */ - .voltage_min = 9000, /* mV */ - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, - }, - }, - - /* SANYO AC15A3J Battery Information */ - [BATTERY_SANYO] = { - .fuel_gauge = { - .manuf_name = "SANYO", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .reg_addr = 0x0, - .reg_mask = 0x4000, - .disconnect_val = 0x0, - } - }, - .batt_info = { - .voltage_max = TARGET_WITH_MARGIN(13200, 5), - .voltage_normal = 11550, /* mV */ - .voltage_min = 9000, /* mV */ - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, - }, - }, - - /* Sony Ap13J4K Battery Information */ - [BATTERY_SONY] = { - .fuel_gauge = { - .manuf_name = "SONYCorp", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .reg_addr = 0x0, - .reg_mask = 0x8000, - .disconnect_val = 0x8000, - .cfet_mask = 0x4000, - .cfet_off_val = 0x4000, - } - }, - .batt_info = { - .voltage_max = TARGET_WITH_MARGIN(13200, 5), - .voltage_normal = 11400, /* mV */ - .voltage_min = 9000, /* mV */ - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, - }, - }, - - /* Simplo AP13J7K Battery Information */ - [BATTERY_SMP_AP13J7K] = { - .fuel_gauge = { - .manuf_name = "SIMPLO", - .device_name = "AP13J7K", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .mfgacc_support = 1, - .reg_addr = 0x0, - .reg_mask = 0x0002, - .disconnect_val = 0x0000, - } - }, - .batt_info = { - .voltage_max = 13050, - .voltage_normal = 11400, /* mV */ - .voltage_min = 9000, /* mV */ - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, - }, - }, - - /* Panasonic AC15A3J Battery Information */ - [BATTERY_PANASONIC_AC15A3J] = { - .fuel_gauge = { - .manuf_name = "PANASONIC", - .device_name = "AC15A3J", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .reg_addr = 0x0, - .reg_mask = 0x4000, - .disconnect_val = 0x0, - } - }, - .batt_info = { - .voltage_max = 13200, - .voltage_normal = 11550, /* mV */ - .voltage_min = 9000, /* mV */ - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, - }, - }, - - /* LGC AP18C8K Battery Information */ - [BATTERY_LGC_AP18C8K] = { - .fuel_gauge = { - .manuf_name = "LGC KT0030G020", - .device_name = "AP18C8K", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .reg_addr = 0x43, - .reg_mask = 0x0001, - .disconnect_val = 0x0, - }, - }, - .batt_info = { - .voltage_max = 13050, - .voltage_normal = 11250, - .voltage_min = 9000, - .precharge_current = 256, - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, - }, - }, - - /* Murata AP18C4K Battery Information */ - [BATTERY_MURATA_AP18C4K] = { - .fuel_gauge = { - .manuf_name = "Murata KT00304012", - .device_name = "AP18C4K", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .reg_addr = 0x0, - .reg_mask = 0x2000, - .disconnect_val = 0x2000, - }, - }, - .batt_info = { - .voltage_max = 13200, - .voltage_normal = 11400, - .voltage_min = 9000, - .precharge_current = 256, - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, - }, - }, - - /* LGC AP19A8K Battery Information */ - [BATTERY_LGC_AP19A8K] = { - .fuel_gauge = { - .manuf_name = "LGC KTxxxxGxxx", - .device_name = "AP19A8K", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .reg_addr = 0x43, - .reg_mask = 0x0001, - .disconnect_val = 0x0, - .cfet_mask = 0x0002, - .cfet_off_val = 0x0, - }, - }, - .batt_info = { - .voltage_max = 13200, - .voltage_normal = 11550, - .voltage_min = 9000, - .precharge_current = 256, - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, - }, - }, - - /* LGC KT0030G023 Battery Information */ - [BATTERY_LGC_G023] = { - .fuel_gauge = { - .manuf_name = "LGC KT0030G023", - .device_name = "AP19A8K", - .ship_mode = { - .reg_addr = 0x3A, - .reg_data = { 0xC574, 0xC574 }, - }, - .fet = { - .reg_addr = 0x43, - .reg_mask = 0x0001, - .disconnect_val = 0x0, - }, - }, - .batt_info = { - .voltage_max = 13200, - .voltage_normal = 11550, - .voltage_min = 9000, - .precharge_current = 256, - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, - }, - }, -}; -BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); - -const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_PANASONIC_AC15A3J; diff --git a/board/dibbi/board.c b/board/dibbi/board.c index cba8bc64a4..9b3207859a 100644 --- a/board/dibbi/board.c +++ b/board/dibbi/board.c @@ -3,17 +3,13 @@ * found in the LICENSE file. */ -/* Waddledee board-specific configuration */ +/* Dibbi board-specific configuration */ #include "adc_chip.h" #include "button.h" #include "charge_manager.h" #include "charge_state_v2.h" #include "charger.h" -#include "driver/accel_kionix.h" -#include "driver/accelgyro_lsm6dsm.h" -#include "driver/bc12/pi3usb9201.h" -#include "driver/charger/sm5803.h" #include "driver/temp_sensor/thermistor.h" #include "driver/tcpm/it83xx_pd.h" #include "driver/usb_mux/it5205.h" @@ -38,53 +34,6 @@ #define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define INT_RECHECK_US 5000 - -/* TODO(b/257377326) remove SM5803 references */ - -/* C0 interrupt line shared by BC 1.2 and charger */ -static void check_c0_line(void); -DECLARE_DEFERRED(check_c0_line); - -static void notify_c0_chips(void) -{ - usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); - sm5803_interrupt(0); -} - -static void check_c0_line(void) -{ - /* - * If line is still being held low, see if there's more to process from - * one of the chips - */ - if (!gpio_get_level(GPIO_USB_C0_INT_ODL)) { - notify_c0_chips(); - hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); - } -} - -static void usb_c0_interrupt(enum gpio_signal s) -{ - /* Cancel any previous calls to check the interrupt line */ - hook_call_deferred(&check_c0_line_data, -1); - - /* Notify all chips using this line that an interrupt came in */ - notify_c0_chips(); - - /* Check the line again in 5ms */ - hook_call_deferred(&check_c0_line_data, INT_RECHECK_US); -} - -static void c0_ccsbu_ovp_interrupt(enum gpio_signal s) -{ - cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event"); - pd_handle_cc_overvoltage(0); -} - -/* Must come after other header files and interrupt handler declarations */ -#include "gpio_list.h" - /* ADC channels */ const struct adc_t adc_channels[] = { [ADC_VSNS_PP3300_A] = { .name = "PP3300_A_PGOOD", @@ -102,33 +51,19 @@ const struct adc_t adc_channels[] = { .factor_div = ADC_READ_MAX + 1, .shift = 0, .channel = CHIP_ADC_CH3 }, - [ADC_SUB_ANALOG] = { .name = "SUB_ANALOG", - .factor_mul = ADC_MAX_MVOLT, - .factor_div = ADC_READ_MAX + 1, - .shift = 0, - .channel = CHIP_ADC_CH13 }, + [ADC_PPVAR_PWR_IN_IMON] = { .name = "ADC_PPVAR_PWR_IN_IMON", + .factor_mul = ADC_MAX_MVOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + .channel = CHIP_ADC_CH15 }, + [ADC_SNS_PPVAR_PWR_IN] = { .name = "ADC_SNS_PPVAR_PWR_IN", + .factor_mul = ADC_MAX_MVOLT, + .factor_div = ADC_READ_MAX + 1, + .shift = 0, + .channel = CHIP_ADC_CH16 }, }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); -/* BC 1.2 chips */ -const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { - { - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, - .flags = PI3USB9201_ALWAYS_POWERED, - }, -}; - -/* Charger chips */ -const struct charger_config_t chg_chips[] = { - [CHARGER_SOLO] = { - /* TODO(b/257377326) change - SM5803 not in use */ - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS, - .drv = &sm5803_drv, - }, -}; - /* TCPCs */ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { @@ -150,31 +85,62 @@ const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { }, }; -void board_init(void) -{ - int on; +/* USB-A ports */ +const int usb_port_enable[USB_PORT_COUNT] = { + GPIO_EN_USB_A0_VBUS, + GPIO_EN_USB_A1_VBUS, + GPIO_EN_USB_A2_VBUS, +}; + +/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */ +const struct pwm_t pwm_channels[] = { + [PWM_CH_LED_RED] = { + .channel = 1, + .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, + .freq_hz = 2400, + }, + + [PWM_CH_LED_GREEN] = { + .channel = 2, + .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, + .freq_hz = 2400, + }, - if (system_get_board_version() <= 0) { - /* TODO(b/257377326) possibly update/delete */ - pd_set_max_voltage(5000); + [PWM_CH_LED_BLUE] = { + .channel = 3, + .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, + .freq_hz = 2400, } - gpio_enable_interrupt(GPIO_USB_C0_INT_ODL); +}; +BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); - /* - * If interrupt lines are already low, schedule them to be processed - * after inits are completed. - */ - check_c0_line(); +/* Thermistors */ +const struct temp_sensor_t temp_sensors[] = { + [TEMP_SENSOR_1] = { .name = "Memory", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_1 }, + [TEMP_SENSOR_2] = { .name = "Ambient", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_2 }, +}; +BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); - gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL); +static void c0_ccsbu_ovp_interrupt(enum gpio_signal s) +{ + cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event"); + pd_handle_cc_overvoltage(0); +} - /* Charger on the MB will be outputting PROCHOT_ODL and OD CHG_DET */ - sm5803_configure_gpio0(CHARGER_SOLO, GPIO0_MODE_PROCHOT, 1); - sm5803_configure_chg_det_od(CHARGER_SOLO, 1); +void board_init(void) +{ + int on; - /* Charger on the sub-board will be a push-pull GPIO */ - sm5803_configure_gpio0(CHARGER_SOLO, GPIO0_MODE_OUTPUT, 0); + gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL); + gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_L); + gpio_enable_interrupt(GPIO_USBC_ADP_PRESENT_L); /* Turn on 5V if the system is on, otherwise turn it off */ on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND | @@ -183,27 +149,6 @@ void board_init(void) } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); -static void board_resume(void) -{ - sm5803_disable_low_power_mode(CHARGER_SOLO); -} -DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_resume, HOOK_PRIO_DEFAULT); - -static void board_suspend(void) -{ - sm5803_enable_low_power_mode(CHARGER_SOLO); -} -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_suspend, HOOK_PRIO_DEFAULT); - -void board_hibernate(void) -{ - /* - * Put all charger ICs present into low power mode before entering - * z-state. - */ - sm5803_hibernate(CHARGER_SOLO); -} - void board_reset_pd_mcu(void) { /* @@ -214,55 +159,27 @@ void board_reset_pd_mcu(void) __override void board_power_5v_enable(int enable) { /* - * Motherboard has a GPIO to turn on the 5V regulator, but the sub-board - * sets it through the charger GPIO. + * Mainboard 5V regulator activated by GPIO. + * USB-A ports are activated by usb_port_power_dumb. */ gpio_set_level(GPIO_EN_PP5000, !!enable); - gpio_set_level(GPIO_EN_USB_A0_VBUS, !!enable); - if (sm5803_set_gpio0_level(1, !!enable)) - CPRINTUSB("Failed to %sable sub rails!", enable ? "en" : "dis"); } -uint16_t tcpc_get_alert_status(void) +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) { - /* - * TCPC 0 is embedded in the EC and processes interrupts in the chip - * code (it83xx/intc.c) - */ - return 0; + int insufficient_power = + (charge_ma * charge_mv) < + (CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000); + /* TODO(b/259467280) blink LED on error */ + (void)insufficient_power; } -int board_set_active_charge_port(int port) +int board_vbus_source_enabled(int port) { - /* - * TODO(b/257377326) since this now enable/disable on one port, look - * into updating this method - */ - int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count()); - - if (!is_valid_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - if (port == CHARGE_PORT_NONE) { - CPRINTUSB("Disabling all charge ports"); - - sm5803_vbus_sink_enable(CHARGER_SOLO, 0); - - return EC_SUCCESS; - } - - CPRINTUSB("New chg p%d", port); - - /* - * Ensure other port is turned off, then enable new charge port - */ - if (port == 0) { - sm5803_vbus_sink_enable(CHARGER_SOLO, 1); - } else { - sm5803_vbus_sink_enable(CHARGER_SOLO, 0); - } - - return EC_SUCCESS; + if (port != CHARGE_PORT_TYPEC0) + return 0; + return gpio_get_level(GPIO_EN_USB_C0_VBUS); } /* Vconn control for integrated ITE TCPC */ @@ -280,54 +197,178 @@ void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled) __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) { - int current; + int ilim3A; if (port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT) return; - current = (rp == TYPEC_RP_3A0) ? 3000 : 1500; + /* Switch between 1.5A and 3A ILIM values */ + ilim3A = (rp == TYPEC_RP_3A0); + gpio_set_level(GPIO_USB_C0_VBUS_ILIM, ilim3A); +} + +/******************************************************************************/ +/* + * Since dibbi has no battery, it must source all of its power from either + * USB-C or the barrel jack (preferred). Fizz operates in continuous safe + * mode (charge_manager_leave_safe_mode() will never be called), which + * modifies port selection as follows: + * + * - Dual-role / dedicated capability of the port partner is ignored. + * - Charge ceiling on PD voltage transition is ignored. + * - CHARGE_PORT_NONE will never be selected. + */ + +/* List of BJ adapters */ +enum bj_adapter { + BJ_NONE, + BJ_65W_19V, +}; + +/* Barrel-jack power adapter ratings. */ +static const struct charge_port_info bj_adapters[] = { + [BJ_NONE] = { .current = 0, .voltage = 0 }, + [BJ_65W_19V] = { .current = 3420, .voltage = 19000 }, +}; +#define BJ_ADP_RATING_DEFAULT BJ_65W_19V /* BJ power ratings default */ +#define ADP_DEBOUNCE_MS 1000 /* Debounce time for BJ plug/unplug */ + +/* Debounced connection state of the barrel jack */ +static int8_t bj_adp_connected = -1; +static void adp_connect_deferred(void) +{ + const struct charge_port_info *pi; + int connected = !gpio_get_level(GPIO_BJ_ADP_PRESENT_L); + + /* Debounce */ + if (connected == bj_adp_connected) + return; - charger_set_otg_current_voltage(port, current, 5000); + if (connected) { + pi = &bj_adapters[BJ_ADP_RATING_DEFAULT]; + } else { + /* No barrel-jack, zero out this power supply */ + pi = &bj_adapters[BJ_NONE]; + } + /* This will result in a call to board_set_active_charge_port */ + charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED, + DEDICATED_CHARGE_PORT, pi); + bj_adp_connected = connected; } +DECLARE_DEFERRED(adp_connect_deferred); -/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */ -const struct pwm_t pwm_channels[] = { - [PWM_CH_KBLIGHT] = { - .channel = 0, - .flags = PWM_CONFIG_DSLEEP, - .freq_hz = 10000, - }, +/* IRQ for BJ plug/unplug. It shouldn't be called if BJ is the power source. */ +void adp_connect_interrupt(enum gpio_signal signal) +{ + hook_call_deferred(&adp_connect_deferred_data, ADP_DEBOUNCE_MS * MSEC); +} - [PWM_CH_LED_RED] = { - .channel = 1, - .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, - .freq_hz = 2400, - }, +/* IRQ for USB-C plug/unplug. */ +void usbc_connect_interrupt(enum gpio_signal signal) +{ + task_wake(TASK_ID_PD_C0); +} - [PWM_CH_LED_GREEN] = { - .channel = 2, - .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, - .freq_hz = 2400, - }, +int board_set_active_charge_port(int port) +{ + const int active_port = charge_manager_get_active_charge_port(); - [PWM_CH_LED_BLUE] = { - .channel = 3, - .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, - .freq_hz = 2400, + CPRINTUSB("Requested charge port change to %d", port); + + if (port < 0 || CHARGE_PORT_COUNT <= port) + return EC_ERROR_INVAL; + + if (port == active_port) + return EC_SUCCESS; + + /* Don't sink from a source port */ + if (board_vbus_source_enabled(port)) + return EC_ERROR_INVAL; + + if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) { + int bj_requested; + + if (charge_manager_get_active_charge_port() != CHARGE_PORT_NONE) + /* Change is only permitted while the system is off */ + return EC_ERROR_INVAL; + + /* + * Current setting is no charge port but the AP is on, so the + * charge manager is out of sync (probably because we're + * reinitializing after sysjump). Reject requests that aren't + * in sync with our outputs. + */ + bj_requested = port == CHARGE_PORT_BARRELJACK; + if (bj_adp_connected != bj_requested) + return EC_ERROR_INVAL; } -}; -BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); + CPRINTUSB("New charger p%d", port); + + switch (port) { + case CHARGE_PORT_TYPEC0: + gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 0); + gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 1); + gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_L); + break; + case CHARGE_PORT_BARRELJACK: + /* Make sure BJ adapter is sourcing power */ + if (gpio_get_level(GPIO_BJ_ADP_PRESENT_L)) + return EC_ERROR_INVAL; + gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 0); + gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 1); + gpio_disable_interrupt(GPIO_BJ_ADP_PRESENT_L); + break; + default: + return EC_ERROR_INVAL; + } -/* Thermistors */ -const struct temp_sensor_t temp_sensors[] = { - [TEMP_SENSOR_1] = { .name = "Memory", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_51k1_47k_4050b, - .idx = ADC_TEMP_SENSOR_1 }, - [TEMP_SENSOR_2] = { .name = "Ambient", - .type = TEMP_SENSOR_TYPE_BOARD, - .read = get_temp_3v3_51k1_47k_4050b, - .idx = ADC_TEMP_SENSOR_2 }, -}; -BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); + return EC_SUCCESS; +} + +static void board_charge_manager_init(void) +{ + enum charge_port port; + + /* + * Initialize all charge suppliers to 0. The charge manager waits until + * all ports have reported in before doing anything. + */ + for (int i = 0; i < CHARGE_PORT_COUNT; i++) { + for (int j = 0; j < CHARGE_SUPPLIER_COUNT; j++) + charge_manager_update_charge(j, i, NULL); + } + + port = gpio_get_level(GPIO_BJ_ADP_PRESENT_L) ? CHARGE_PORT_TYPEC0 : + CHARGE_PORT_BARRELJACK; + CPRINTUSB("Power source is p%d (%s)", port, + port == CHARGE_PORT_TYPEC0 ? "USB-C" : "BJ"); + + /* Initialize the power source supplier */ + switch (port) { + case CHARGE_PORT_TYPEC0: + typec_set_input_current_limit(port, 3000, 5000); + break; + case CHARGE_PORT_BARRELJACK: + charge_manager_update_charge( + CHARGE_SUPPLIER_DEDICATED, DEDICATED_CHARGE_PORT, + &bj_adapters[BJ_ADP_RATING_DEFAULT]); + break; + } + + /* Report charge state from the barrel jack. */ + adp_connect_deferred(); +} +DECLARE_HOOK(HOOK_INIT, board_charge_manager_init, + HOOK_PRIO_INIT_CHARGE_MANAGER + 1); + +__override int extpower_is_present(void) +{ + /* + * There's no battery, so running this method implies we have power. + */ + return 1; +} + +/* Must come after other header files and interrupt handler declarations */ +#include "gpio_list.h" diff --git a/board/dibbi/board.h b/board/dibbi/board.h index 166b9d6fbf..c59a540b5d 100644 --- a/board/dibbi/board.h +++ b/board/dibbi/board.h @@ -17,44 +17,67 @@ #define CONFIG_CMD_CHARGER_DUMP -/* Battery */ -#define CONFIG_BATTERY_FUEL_GAUGE - -/* BC 1.2 */ -#define CONFIG_BC12_DETECT_PI3USB9201 - -/* Charger */ -#define CONFIG_CHARGER_SM5803 /* C0: Charger */ +/* Power */ +#undef CONFIG_CHARGER +#undef CONFIG_CHARGER_DISCHARGE_ON_AC +#undef CONFIG_USB_PD_VBUS_MEASURE_CHARGER +#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 16000 #define PD_MAX_VOLTAGE_MV 15000 -#define CONFIG_USB_PD_VBUS_DETECT_CHARGER -#define CONFIG_USB_PD_5V_CHARGER_CTRL -#define CONFIG_CHARGER_OTG +#define CONFIG_USB_PD_VBUS_DETECT_GPIO +/* ADC sensors could measure VBUS on this board, but components are DNS */ +#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT -/* LED */ -#define CONFIG_LED_PWM -#define CONFIG_LED_PWM_COUNT 1 +/* Override macro for C0 only */ +#define PORT_TO_HPD(port) (GPIO_USB_C0_DP_HPD) -/* PWM */ -#define CONFIG_PWM +/* Power: Dedicated barreljack charger port */ +#undef CONFIG_DEDICATED_CHARGE_PORT_COUNT +#define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1 +#define DEDICATED_CHARGE_PORT 1 + +/* USB Type-C */ +#undef CONFIG_USB_CHARGER +#undef CONFIG_USB_MUX_PI3USB31532 /* TCPC */ #define CONFIG_USB_PD_PORT_MAX_COUNT 1 #define CONFIG_USB_PD_TCPM_ITE_ON_CHIP /* C0: ITE EC TCPC */ #define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT 1 -/* Power: Dedicated barreljack charger port */ -#undef CONFIG_DEDICATED_CHARGE_PORT_COUNT -#define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1 -#define DEDICATED_CHARGE_PORT 1 +/* USB Mux and Retimer */ +#define CONFIG_USB_MUX_IT5205 /* C0: ITE Mux */ +#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */ + +/* USB Type A Features */ +#define CONFIG_USB_PORT_POWER_DUMB +#define USB_PORT_COUNT 3 /* Type A ports */ + +/* No battery */ +#undef CONFIG_BATTERY_CUT_OFF +#undef CONFIG_BATTERY_PRESENT_GPIO +#undef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD +#undef CONFIG_BATTERY_REVIVE_DISCONNECT +#undef CONFIG_BATTERY_SMART + +/* LED */ +/* TODO(b/259467280) Determine what LED/PWM impl is needed*/ +/* #define CONFIG_LED_PWM */ +/* #define CONFIG_LED_PWM_COUNT 1 */ + +/* PWM */ +#define CONFIG_PWM /* Thermistors */ #define CONFIG_TEMP_SENSOR #define CONFIG_THERMISTOR #define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B -/* USB Mux and Retimer */ -#define CONFIG_USB_MUX_IT5205 /* C0: ITE Mux */ -#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */ +/* Buttons */ +#define CONFIG_DEDICATED_RECOVERY_BUTTON +#define CONFIG_DEDICATED_RECOVERY_BUTTON_2 +#define CONFIG_POWER_BUTTON +#define CONFIG_POWER_BUTTON_IGNORE_LID +#define CONFIG_POWER_BUTTON_X86 /* No Keyboard */ #undef CONFIG_MKBP_EVENT @@ -71,14 +94,8 @@ #undef CONFIG_BACKLIGHT_LID #undef GPIO_ENABLE_BACKLIGHT -/* Buttons */ -#define CONFIG_DEDICATED_RECOVERY_BUTTON -#define CONFIG_DEDICATED_RECOVERY_BUTTON_2 -#define CONFIG_POWER_BUTTON -#define CONFIG_POWER_BUTTON_IGNORE_LID -#define CONFIG_POWER_BUTTON_X86 - /* Unused features - Misc */ +#undef CONFIG_HIBERNATE #undef CONFIG_VOLUME_BUTTONS #undef CONFIG_LID_SWITCH #undef CONFIG_TABLET_MODE @@ -99,8 +116,12 @@ #include "gpio_signal.h" #include "registers.h" +enum charge_port { + CHARGE_PORT_TYPEC0, + CHARGE_PORT_BARRELJACK, +}; + enum pwm_channel { - PWM_CH_KBLIGHT, PWM_CH_LED_RED, PWM_CH_LED_GREEN, PWM_CH_LED_BLUE, @@ -112,31 +133,13 @@ enum adc_channel { ADC_VSNS_PP3300_A, /* ADC0 */ ADC_TEMP_SENSOR_1, /* ADC2 */ ADC_TEMP_SENSOR_2, /* ADC3 */ - ADC_SUB_ANALOG, /* ADC13 */ + ADC_PPVAR_PWR_IN_IMON, /* ADC15 */ + ADC_SNS_PPVAR_PWR_IN, /* ADC16 */ ADC_CH_COUNT }; enum temp_sensor_id { TEMP_SENSOR_1, TEMP_SENSOR_2, TEMP_SENSOR_COUNT }; -/* List of possible batteries */ -enum battery_type { - BATTERY_LGC15, - BATTERY_PANASONIC_AP15O5L, - BATTERY_SANYO, - BATTERY_SONY, - BATTERY_SMP_AP13J7K, - BATTERY_PANASONIC_AC15A3J, - BATTERY_LGC_AP18C8K, - BATTERY_MURATA_AP18C4K, - BATTERY_LGC_AP19A8K, - BATTERY_LGC_G023, - BATTERY_TYPE_COUNT, -}; - -/* Board specific handlers */ -/* TODO(b/257377326) Update this with power re-work */ -#define PORT_TO_HPD(port) (GPIO_USB_C0_DP_HPD) - #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/dibbi/build.mk b/board/dibbi/build.mk index e75f1c6725..07ea50c392 100644 --- a/board/dibbi/build.mk +++ b/board/dibbi/build.mk @@ -12,4 +12,3 @@ CHIP_VARIANT:=it8320dx BASEBOARD:=dedede board-y=board.o led.o usb_pd_policy.o -board-$(CONFIG_BATTERY_SMART)+=battery.o diff --git a/board/dibbi/ec.tasklist b/board/dibbi/ec.tasklist index ed73e778fe..768c31112a 100644 --- a/board/dibbi/ec.tasklist +++ b/board/dibbi/ec.tasklist @@ -9,17 +9,8 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(CHARGER, charger_task, NULL, TRENTA_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(POWERBTN, power_button_task, NULL, ULTRA_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C0, pd_task, NULL, ULTRA_TASK_STACK_SIZE) - -/* - * TODO(b/257377326): - * determine what tasks are required for PD power - * determine whether there should be a PD_INT_C0 (waddledee only had - * PD_INT_C1) - */ + TASK_ALWAYS(PD_C0, pd_task, NULL, ULTRA_TASK_STACK_SIZE) diff --git a/board/dibbi/gpio.inc b/board/dibbi/gpio.inc index 313eda46c9..a5c0c02a72 100644 --- a/board/dibbi/gpio.inc +++ b/board/dibbi/gpio.inc @@ -29,19 +29,16 @@ GPIO_INT(UART1_RX, PIN(B, 0), GPIO_INT_BOTH, uart_deepsleep_interrupt) /* UART_ #endif /* USB-C interrupts */ -GPIO_INT(USB_C0_INT_ODL, PIN(K, 0), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c0_interrupt) /* BC12 and charger */ GPIO_INT(USB_C0_CCSBU_OVP_ODL, PIN(K, 6), GPIO_INT_FALLING | GPIO_PULL_UP, c0_ccsbu_ovp_interrupt) /* Fault protection */ /* Other interrupts */ -/* TODO(b/257377326) PIN(A, 7) changed from LID_360_L to BJ_ADP_PRESENT_L */ -/* TODO(b/257833880) PIN(I, 6) changed from VOLDN_BTN_ODL to USB_C0_VBUS_ILIM */ -/* TODO(b/257833880) PIN(I, 7) changed from VOLUP_BTN_ODL to EN_USB_C0_VBUS */ -/* TODO(b/257377326) PIN(J, 0) changed from BASE_SIXAXIS_INT_L to EN_PVAR_BJ_ADP_L */ GPIO_INT(EC_WP_OD, PIN(A, 6), GPIO_INT_BOTH, switch_interrupt) /* Directly connected recovery button */ GPIO_INT(EC_RECOVERY_BTN_ODL, PIN(K, 7), GPIO_INT_BOTH, button_interrupt) /* Recovery button input from H1 */ GPIO_INT(H1_EC_RECOVERY_BTN_ODL, PIN(K, 4), GPIO_INT_BOTH, button_interrupt) +GPIO_INT(BJ_ADP_PRESENT_L, PIN(A, 7), GPIO_INT_BOTH | GPIO_PULL_UP, adp_connect_interrupt) +GPIO_INT(USBC_ADP_PRESENT_L, PIN(K, 3), GPIO_INT_BOTH | GPIO_PULL_UP, usbc_connect_interrupt) /* Power sequence GPIOs */ GPIO(EC_AP_RTCRST, PIN(K, 2), GPIO_OUT_LOW) @@ -61,13 +58,20 @@ GPIO(EN_VCCIO_EXT, PIN(B, 2), GPIO_OUT_LOW) GPIO(EC_PROCHOT_ODL, PIN(I, 1), GPIO_ODR_HIGH | GPIO_SEL_1P8V) GPIO(EC_AP_VCCST_PWRGD_OD, PIN(E, 5), GPIO_ODR_LOW) GPIO(ALL_SYS_PWRGD, PIN(B, 7), GPIO_OUT_LOW) -GPIO(EN_SLP_Z, PIN(K, 3), GPIO_OUT_LOW) +GPIO(EN_PPVAR_BJ_ADP_L, PIN(J, 0), GPIO_OUT_LOW) +GPIO(EN_PPVAR_USBC_ADP_L, PIN(J, 1), GPIO_OUT_LOW) +GPIO(EN_USB_C0_VBUS, PIN(I, 7), GPIO_OUT_LOW) +GPIO(USB_C0_VBUS_ILIM, PIN(I, 6), GPIO_OUT_LOW) /* Required for icelake chipset code, but implemented through other means for dedede */ UNIMPLEMENTED(AC_PRESENT) UNIMPLEMENTED(PG_EC_DSW_PWROK) UNIMPLEMENTED(PG_EC_ALL_SYS_PWRGD) +/* Required for dedede baseboard but not used in dibbi */ +UNIMPLEMENTED(USB_C0_INT_ODL) +UNIMPLEMENTED(EN_SLP_Z) + /* I2C pins - Alternate function below configures I2C module on these pins */ GPIO(EC_I2C_EEPROM_SCL, PIN(B, 3), GPIO_INPUT) GPIO(EC_I2C_EEPROM_SDA, PIN(B, 4), GPIO_INPUT) @@ -82,9 +86,9 @@ GPIO(EC_I2C_USB_C0_SDA, PIN(A, 5), GPIO_INPUT) GPIO(EN_USB_C0_CC1_VCONN, PIN(H, 4), GPIO_OUT_LOW) GPIO(EN_USB_C0_CC2_VCONN, PIN(H, 6), GPIO_OUT_LOW) GPIO(EC_AP_USB_C0_HPD, PIN(L, 4), GPIO_OUT_LOW) -GPIO(USB_C0_FRS, PIN(C, 4), GPIO_OUT_LOW) -GPIO(HDMI_SEL_L, PIN(C, 6), GPIO_OUT_HIGH) -GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW) /* Board rev 1, NC board rev 0 */ +GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW) +GPIO(EN_USB_A1_VBUS, PIN(C, 6), GPIO_OUT_LOW) +GPIO(EN_USB_A2_VBUS, PIN(C, 4), GPIO_OUT_LOW) /* MKBP event synchronization */ /* TODO(b/257833880) Check whether this pin is needed */ @@ -100,7 +104,6 @@ GPIO(EC_SUB_IO_2_2, PIN(L, 2), GPIO_INPUT) GPIO(EC_ENTERING_RW, PIN(G, 0), GPIO_OUT_LOW) GPIO(CCD_MODE_ODL, PIN(H, 5), GPIO_ODR_HIGH) GPIO(EC_BATTERY_PRES_ODL, PIN(I, 4), GPIO_INPUT) -/* TODO(b/257377326) PIN(J, 1) changed from PEN_DET_ODL to EN_PPVAR_USBC_ADP_L */ GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW) @@ -115,6 +118,8 @@ GPIO(GPIOG7_NC, PIN(G, 7), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOJ4_NC, PIN(J, 4), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOJ5_NC, PIN(J, 5), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOJ6_NC, PIN(J, 6), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOK0_NC, PIN(K, 0), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOL0_NC, PIN(L, 0), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOM6_NC, PIN(M, 6), GPIO_INPUT | GPIO_PULL_DOWN) /* TODO(b/257833880) add any new unused pins */ @@ -130,8 +135,8 @@ ALTERNATE(PIN_MASK(E, BIT(0) | BIT(7)), 0, MODULE_I2C, 0) /* I2C4 */ ALTERNATE(PIN_MASK(A, BIT(4) | BIT(5)), 0, MODULE_I2C, 0) /* I2C5 */ /* ADC */ -ALTERNATE(PIN_MASK(L, BIT(0)), 0, MODULE_ADC, 0) /* ADC13: EC_SUB_ANALOG */ ALTERNATE(PIN_MASK(I, BIT(0) | BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC0: EC_VSNS_PP3300_A, ADC2: TEMP_SENSOR_1, ADC3: TEMP_SENSOR_2 */ +ALTERNATE(PIN_MASK(L, BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC15: PPVAR_PWR_IN_IMON, ADC16: SNS_PPVAR_PWR_IN */ /* PWM */ ALTERNATE(PIN_MASK(A, BIT(1) | BIT(2) | BIT(3)), 0, MODULE_PWM, 0) /* LED_[R,G,B]_ODL */ diff --git a/board/dibbi/led.c b/board/dibbi/led.c index 74d6419aea..44cfc0b457 100644 --- a/board/dibbi/led.c +++ b/board/dibbi/led.c @@ -3,45 +3,23 @@ * found in the LICENSE file. */ -/* Waddledee specific PWM LED settings. */ +/* Dibbi specific PWM LED settings. */ #include "common.h" #include "ec_commands.h" -#include "led_pwm.h" #include "pwm.h" #include "util.h" +/* TODO(b/259467280) Implement LED logic */ + const enum ec_led_id supported_led_ids[] = { EC_LED_ID_POWER_LED, }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); -/* - * Board has one physical LED with red, green, and blue - */ -struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = { - /* Red, Green, Blue */ - [EC_LED_COLOR_RED] = { 100, 0, 0 }, - [EC_LED_COLOR_GREEN] = { 0, 100, 0 }, - [EC_LED_COLOR_BLUE] = { 0, 0, 100 }, - [EC_LED_COLOR_YELLOW] = { 50, 50, 0 }, - [EC_LED_COLOR_WHITE] = { 50, 50, 50 }, - [EC_LED_COLOR_AMBER] = { 70, 30, 0 }, -}; - -/* One logical LED with red, green, and blue channels. */ -struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { - { - .ch0 = PWM_CH_LED_RED, - .ch1 = PWM_CH_LED_GREEN, - .ch2 = PWM_CH_LED_BLUE, - .enable = &pwm_enable, - .set_duty = &pwm_set_duty, - }, -}; - void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { + /* TODO(b/259467280) check this implementation */ memset(brightness_range, '\0', sizeof(*brightness_range) * EC_LED_COLOR_COUNT); brightness_range[EC_LED_COLOR_RED] = 100; @@ -54,29 +32,7 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { - enum pwm_led_id pwm_id; - - /* Convert ec_led_id to pwm_led_id. */ - if (led_id == EC_LED_ID_POWER_LED) - pwm_id = PWM_LED0; - else - return EC_ERROR_UNKNOWN; - - if (brightness[EC_LED_COLOR_RED]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_RED); - else if (brightness[EC_LED_COLOR_GREEN]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_GREEN); - else if (brightness[EC_LED_COLOR_BLUE]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_BLUE); - else if (brightness[EC_LED_COLOR_YELLOW]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_YELLOW); - else if (brightness[EC_LED_COLOR_WHITE]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_WHITE); - else if (brightness[EC_LED_COLOR_AMBER]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER); - else - /* Otherwise, the "color" is "off". */ - set_pwm_led_color(pwm_id, -1); + /* TODO(b/259467280) fix this implementation */ return EC_SUCCESS; } diff --git a/board/dibbi/usb_pd_policy.c b/board/dibbi/usb_pd_policy.c index ad930e1862..9d573b9c61 100644 --- a/board/dibbi/usb_pd_policy.c +++ b/board/dibbi/usb_pd_policy.c @@ -3,40 +3,44 @@ * found in the LICENSE file. */ -#include "battery_smart.h" /* TODO(b/257377326) remove */ #include "charge_manager.h" #include "charger.h" #include "chipset.h" #include "common.h" #include "console.h" -#include "driver/charger/sm5803.h" /* TODO(b/257377326) remove */ #include "driver/tcpm/tcpci.h" +#include "gpio.h" #include "usb_pd.h" #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) +__override int pd_check_power_swap(int port) +{ + /* If type-c port is supplying power, we never swap PR (to source) */ + if (port == charge_manager_get_active_charge_port()) + return 0; + /* + * Allow power swap as long as we are acting as a dual role device, + * otherwise assume our role is fixed (not in S0 or console command + * to fix our role). + */ + return (pd_get_dual_role(port) == PD_DRP_TOGGLE_ON ? 1 : 0); +} + int pd_check_vconn_swap(int port) { /* Allow VCONN swaps if the AP is on */ - return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON); + return gpio_get_level(GPIO_EN_PP5000_U); } void pd_power_supply_reset(int port) { - int prev_en; - if (port < 0 || port >= board_get_usb_pd_port_count()) return; - prev_en = charger_is_sourcing_otg_power(port); - - /* Disable Vbus */ - charger_enable_otg_power(port, 0); - - /* Discharge Vbus if previously enabled */ - if (prev_en) - sm5803_set_vbus_disch(port, 1); + /* Disable VBUS source */ + gpio_set_level(GPIO_EN_USB_C0_VBUS, 0); /* Notify host of power info change. */ pd_send_host_event(PD_EVENT_POWER_CHANGE); @@ -44,18 +48,11 @@ void pd_power_supply_reset(int port) int pd_set_power_supply_ready(int port) { - enum ec_error_list rv; - - /* Disable sinking */ - rv = sm5803_vbus_sink_enable(port, 0); - if (rv) - return rv; - - /* Disable Vbus discharge */ - sm5803_set_vbus_disch(port, 0); + /* Disable charging */ + gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 1); - /* Provide Vbus */ - charger_enable_otg_power(port, 1); + /* Enable VBUS source */ + gpio_set_level(GPIO_EN_USB_C0_VBUS, 1); /* Notify host of power info change. */ pd_send_host_event(PD_EVENT_POWER_CHANGE); @@ -63,12 +60,10 @@ int pd_set_power_supply_ready(int port) return EC_SUCCESS; } -__override bool pd_check_vbus_level(int port, enum vbus_level level) +__override int pd_snk_is_vbus_provided(int port) { - return sm5803_check_vbus_level(port, level); -} + if (port != CHARGE_PORT_TYPEC0) + return 0; -int pd_snk_is_vbus_provided(int port) -{ - return sm5803_is_vbus_present(port); + return gpio_get_level(GPIO_USBC_ADP_PRESENT_L); } -- cgit v1.2.1 From 298925efabfc20c4d000b9a7d7e276f26395c249 Mon Sep 17 00:00:00 2001 From: mick_hsiao Date: Fri, 25 Nov 2022 13:59:06 +0800 Subject: Xivu: modify motionsense rotate mapping modify base rot ref rotate mapping BUG=b:259466064 BRANCH=none TEST=rotate DUT. DUT won't switches to Tablet mode in NB mode Signed-off-by: mick_hsiao Change-Id: I3d0e30c0602bf5ad2b7f4637d0222917e6e0f50e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054315 Reviewed-by: SamSP Liu Reviewed-by: Andrew McRae Reviewed-by: Peter Marheine Code-Coverage: Zoss --- zephyr/program/nissa/xivu/motionsense.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/program/nissa/xivu/motionsense.dtsi b/zephyr/program/nissa/xivu/motionsense.dtsi index e5c1f3d2e2..fd82aa6ae2 100644 --- a/zephyr/program/nissa/xivu/motionsense.dtsi +++ b/zephyr/program/nissa/xivu/motionsense.dtsi @@ -49,8 +49,8 @@ }; base_rot_ref: base-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 + mat33 = <0 1 0 + (-1) 0 0 0 0 1>; }; -- cgit v1.2.1 From f80955b5fcca49f2188b32d5ca66cc04b6031ab3 Mon Sep 17 00:00:00 2001 From: "arthur.lin" Date: Mon, 28 Nov 2022 09:25:40 +0800 Subject: pujjo: add GPIO_VOLTAGE_1P8 flag support Add GPIO_VOLTAGE_1P8 flag support reference by nivviks CL:3775793 BUG=none BRANCH=none TEST=zmake build pujjo Change-Id: Id22852e5cdbaeeb03cd22dae51e080b4e9ec93bd Signed-off-by: arthur.lin Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4060126 Reviewed-by: Andrew McRae Reviewed-by: Peter Marheine Code-Coverage: Zoss --- zephyr/program/nissa/pujjo/generated.dtsi | 4 ++-- zephyr/program/nissa/pujjo/overlay.dtsi | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/zephyr/program/nissa/pujjo/generated.dtsi b/zephyr/program/nissa/pujjo/generated.dtsi index 727d2d3d53..46da0e4a02 100644 --- a/zephyr/program/nissa/pujjo/generated.dtsi +++ b/zephyr/program/nissa/pujjo/generated.dtsi @@ -188,10 +188,10 @@ gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; }; gpio_vccin_aux_vid0: vccin_aux_vid0 { - gpios = <&gpio9 2 GPIO_INPUT>; + gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; }; gpio_vccin_aux_vid1: vccin_aux_vid1 { - gpios = <&gpioe 3 GPIO_INPUT>; + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; }; gpio_voldn_btn_odl: voldn_btn_odl { gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; diff --git a/zephyr/program/nissa/pujjo/overlay.dtsi b/zephyr/program/nissa/pujjo/overlay.dtsi index 4916a4ec90..cb20ec6554 100644 --- a/zephyr/program/nissa/pujjo/overlay.dtsi +++ b/zephyr/program/nissa/pujjo/overlay.dtsi @@ -102,17 +102,23 @@ }; gpio_sb_3: sb_3 { - gpios = <&gpiof 5 GPIO_OPEN_DRAIN>; + gpios = <&gpiof 5 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; no-auto-init; }; gpio_sb_4: sb_4 { - gpios = <&gpiof 4 GPIO_INPUT>; + gpios = <&gpiof 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; no-auto-init; }; gpio_fan_enable: fan-enable { gpios = <&gpio6 3 GPIO_OUTPUT>; no-auto-init; }; + ec-i2c-sensor-scl { + gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; gpio_power_led: power_led { gpios = <&gpioc 2 GPIO_OUTPUT_LOW>; }; -- cgit v1.2.1 From dd451d0aab9c78f0fc7cff91c39a7f5c50f2790d Mon Sep 17 00:00:00 2001 From: Elsie Shih Date: Fri, 15 Jul 2022 15:05:13 +0800 Subject: moli: add power on/wakeup by HDMI monitor After EC received interrupt from monitor on GPIOB4/ GPIOB5/ GPIO10. EC will power on the system. If EC received interrupt during s0ix, EC will trigger powr button to wake AP. BUG=b:239634608 BRANCH=none TEST=make BOARD=moli Signed-off-by: Elsie Shih Change-Id: Ia407468afc103595d33b6ce526d8e05bc66c76a2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3771361 Tested-by: Scott Chao Reviewed-by: Zhuohao Lee Code-Coverage: Zoss --- board/moli/board.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++ board/moli/board.h | 10 +++++ board/moli/gpio.inc | 12 +++--- 3 files changed, 129 insertions(+), 6 deletions(-) diff --git a/board/moli/board.c b/board/moli/board.c index c995fe6ef7..a63c93ae50 100644 --- a/board/moli/board.c +++ b/board/moli/board.c @@ -8,6 +8,7 @@ #include "button.h" #include "charge_manager.h" #include "charge_state_v2.h" +#include "chipset.h" #include "common.h" #include "compile_time_macros.h" #include "console.h" @@ -31,6 +32,32 @@ static void power_monitor(void); DECLARE_DEFERRED(power_monitor); +/******************************************************************************/ +/* Power on by HDMI/ DP monitor */ +struct monitor_config { + enum gpio_signal gpio; + uint8_t state; +}; + +static struct monitor_config monitors[MONITOR_COUNT] = { + [HDMI1_MONITOR] = { + .gpio = GPIO_HDMI1_MONITOR_ON, + .state = MONITOR_OFF, + }, + + [HDMI2_MONITOR] = { + .gpio = GPIO_HDMI2_MONITOR_ON, + .state = MONITOR_OFF, + }, + + [OPTION_MONITOR] = { + .gpio = GPIO_OPTION_MONITOR_ON, + .state = MONITOR_OFF, + }, +}; + +/******************************************************************************/ + /******************************************************************************/ /* USB-A charging control */ @@ -162,12 +189,29 @@ DECLARE_HOOK(HOOK_INIT, adp_state_init, HOOK_PRIO_INIT_CHARGE_MANAGER + 1); static void board_init(void) { + int i; + gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_ODL); gpio_enable_interrupt(GPIO_HDMI_CONN_OC_ODL); gpio_enable_interrupt(GPIO_USB_A1_OC_ODL); gpio_enable_interrupt(GPIO_USB_A2_OC_ODL); gpio_enable_interrupt(GPIO_USB_A3_OC_ODL); gpio_enable_interrupt(GPIO_USB_A4_OC_ODL); + + if (ec_cfg_power_on_monitor() == POWER_ON_MONITOR_ENABLE) { + /* + * Only enable interrupt when fw_config set it as enable. + */ + gpio_enable_interrupt(GPIO_HDMI1_MONITOR_ON); + gpio_enable_interrupt(GPIO_HDMI2_MONITOR_ON); + gpio_enable_interrupt(GPIO_OPTION_MONITOR_ON); + + /* + * Initialize the monitor state to corresponding gpio state. + */ + for (i = 0; i < MONITOR_COUNT; i++) + monitors[i].state = gpio_get_level(monitors[i].gpio); + } } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -402,3 +446,72 @@ static void power_monitor(void) * Start power monitoring after ADCs have been initialised. */ DECLARE_HOOK(HOOK_INIT, power_monitor, HOOK_PRIO_INIT_ADC + 1); + +/******************************************************************************/ +/* + * System power on and wake up by monitor power button. + * + * After pressing power button of monitor for power on, monitor will send power + * on signal with 3.3V / 200ms to DT. If DT detect that pulse, there are three + * DT behavior: + * + * - Do nothing in state S0. + * - Wake up from state S0ix. + * - Power on from state S5 and G3. + */ + +/* Debounce time for HDMI power button press */ +#define MONITOR_DEBOUNCE_MS 100 + +static void monitor_irq_deferred(void); +DECLARE_DEFERRED(monitor_irq_deferred); + +static void monitor_irq_deferred(void) +{ + int i; + + for (i = 0; i < MONITOR_COUNT; i++) { + if (monitors[i].state && gpio_get_level(monitors[i].gpio)) { + /* + * System power on from state S5 and G3. + */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + chipset_power_on(); + /* + * System wake up from state S0ix. + */ + else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) + power_button_simulate_press(200); + } + monitors[i].state = MONITOR_OFF; + } +} + +/* Power on by HDMI/ DP monitor. */ +void monitor_interrupt(enum gpio_signal signal) +{ + /* + * Power on by HDMI/ DP monitor only works + * when system is not in S0. + */ + if (chipset_in_state(CHIPSET_STATE_ON)) + return; + + if (ec_cfg_power_on_monitor() == POWER_ON_MONITOR_ENABLE) { + switch (signal) { + case GPIO_HDMI1_MONITOR_ON: + monitors[HDMI1_MONITOR].state = MONITOR_ON; + break; + case GPIO_HDMI2_MONITOR_ON: + monitors[HDMI2_MONITOR].state = MONITOR_ON; + break; + case GPIO_OPTION_MONITOR_ON: + monitors[OPTION_MONITOR].state = MONITOR_ON; + break; + default: + break; + } + hook_call_deferred(&monitor_irq_deferred_data, + MONITOR_DEBOUNCE_MS * MSEC); + } +} diff --git a/board/moli/board.h b/board/moli/board.h index aa2a2bc354..8d0ba97fb2 100644 --- a/board/moli/board.h +++ b/board/moli/board.h @@ -181,7 +181,17 @@ enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT }; enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT }; +enum monitor_port { + HDMI1_MONITOR, + HDMI2_MONITOR, + OPTION_MONITOR, + MONITOR_COUNT +}; + +enum monitor_state { MONITOR_OFF, MONITOR_ON }; + extern void adp_connect_interrupt(enum gpio_signal signal); +extern void monitor_interrupt(enum gpio_signal signal); #endif /* !__ASSEMBLER__ */ diff --git a/board/moli/gpio.inc b/board/moli/gpio.inc index fb3b508573..e8473f8c95 100644 --- a/board/moli/gpio.inc +++ b/board/moli/gpio.inc @@ -25,6 +25,9 @@ GPIO_INT(EC_RECOVERY_BTN_ODL, PIN(2, 3), GPIO_INT_BOTH, button_interrupt) GPIO_INT(USB_C1_RT_INT_ODL, PIN(4, 1), GPIO_INT_FALLING, retimer_interrupt) GPIO_INT(USB_C1_BC12_INT_ODL, PIN(8, 3), GPIO_INT_FALLING, bc12_interrupt) GPIO_INT(USB_C1_PPC_INT_ODL, PIN(7, 0), GPIO_INT_FALLING, ppc_interrupt) +GPIO_INT(HDMI1_MONITOR_ON, PIN(B, 4), GPIO_INT_RISING, monitor_interrupt) +GPIO_INT(HDMI2_MONITOR_ON, PIN(B, 5), GPIO_INT_RISING, monitor_interrupt) +GPIO_INT(OPTION_MONITOR_ON, PIN(1, 0), GPIO_INT_RISING, monitor_interrupt) /* CCD */ GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_INPUT) @@ -120,12 +123,9 @@ GPIO(LED_ORANGE_CONTROL, PIN(3, 1), GPIO_ODR_LOW) GPIO(LED_BLUE_CONTROL, PIN(2, 5), GPIO_ODR_LOW) /* Option Board */ -GPIO(HDMI1_MONITOR_ON, PIN(B, 4), GPIO_INPUT) -GPIO(HDMI1_MONON_SIO, PIN(1, 6), GPIO_ODR_LOW) -GPIO(OPTION_MONITOR_ON, PIN(1, 0), GPIO_INPUT) -GPIO(OPTION_MONON_SIO, PIN(2, 1), GPIO_ODR_LOW) -GPIO(HDMI2_MONITOR_ON, PIN(B, 5), GPIO_INPUT) -GPIO(HDMI2_MONON_SIO, PIN(1, 5), GPIO_ODR_LOW) +GPIO(HDMI1_MONON_SIO, PIN(1, 6), GPIO_INPUT) +GPIO(HDMI2_MONON_SIO, PIN(1, 5), GPIO_INPUT) +GPIO(OPTION_MONON_SIO, PIN(2, 1), GPIO_INPUT) IOEX(USB_C0_OC_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 4), GPIO_ODR_HIGH) IOEX(USB_C0_FRS_EN, EXPIN(IOEX_C0_NCT38XX, 0, 6), GPIO_LOW) -- cgit v1.2.1 From 4dee64a4c53dc954ca9695108c10ea1d0b578209 Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Thu, 15 Sep 2022 16:02:51 -0700 Subject: i8042: Send command response from priority queue This patch also makes KEYPROTO task hold sending a scancode when it receives SETLEDS command until it returns ACK to the second byte (and leaves STATE_ATKBD_SETLEDS). This patch also removes and repositions some kblog_put calls because checking OBF and writing to DBBOUT must be done as atomically as possible to minimize the race condition. BUG=b:237981131,b:247795316 BRANCH=None TEST=Taniks. Press search+alt then 'k' 100 times. Signed-off-by: Daisuke Nojiri Change-Id: I7ccfae99b3657ead5fa9e3c337db623aaffdb0bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3901253 Reviewed-by: Aseda Aboagye Commit-Queue: Aseda Aboagye Code-Coverage: Zoss --- common/keyboard_8042.c | 111 ++++++++++++++++++++++++++++++++++++++----------- test/kb_8042.c | 101 +++++++++++++++++++++++--------------------- 2 files changed, 139 insertions(+), 73 deletions(-) diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index e0371ddd5c..ce27828e1d 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -77,6 +77,15 @@ enum scancode_set_list { /* Number of bytes host can get behind before we start generating extra IRQs */ #define KB_TO_HOST_RETRIES 3 +/* + * Timeout for SETLEDS command. Kernel is supposed to send the second byte + * within this period. When timeout occurs, the second byte is received as + * 'Unsupported AT keyboard command 0x00' (or 0x04). You can evaluate your + * timeout is too long or too short by calculating the duration between 'KB + * SETLEDS' and 'Unsupported AT...'. + */ +#define SETLEDS_TIMEOUT (30 * MSEC) + /* * Mutex to control write access to the to-host buffer head. Don't need to * mutex the tail because reads are only done in one place. @@ -87,6 +96,7 @@ static mutex_t to_host_mutex; enum { CHAN_KBD = 0, CHAN_AUX, + CHAN_CMD, }; struct data_byte { uint8_t chan; @@ -94,6 +104,7 @@ struct data_byte { }; static struct queue const to_host = QUEUE_NULL(16, struct data_byte); +static struct queue const to_host_cmd = QUEUE_NULL(16, struct data_byte); /* Queue command/data from the host */ enum { @@ -162,6 +173,7 @@ static int typematic_inter_delay; static int typematic_len; /* length of typematic_scan_code */ static uint8_t typematic_scan_code[MAX_SCAN_CODE_LEN]; static timestamp_t typematic_deadline; +static timestamp_t setleds_deadline; #define KB_SYSJUMP_TAG 0x4b42 /* "KB" */ #define KB_HOOK_VERSION 2 @@ -182,18 +194,16 @@ struct kblog_t { /* * Type: * - * s = byte enqueued to send to host * a = aux byte enqueued to send to host - * t = to-host queue tail pointer before type='s' bytes enqueued - * - * d = data byte from host * c = command byte from host - * - * k = to-host queue head pointer before byte dequeued - * K = byte actually sent to host via LPC - * A = byte actually sent to host via LPC as AUX - * + * d = data byte from host + * r = typematic + * s = byte enqueued to send to host + * t = to-host queue tail pointer before type='s' bytes enqueued + * u = byte enqueued to send to host with priority * x = to_host queue was cleared + * A = byte actually sent to host via LPC as AUX + * K = byte actually sent to host via LPC * * The to-host head and tail pointers are logged pre-wrapping to the * queue size. This means that they continually increment as units @@ -265,7 +275,7 @@ static void aux_enable_irq(int enable) * host cannot read the previous byte away in time. * * @param len Number of bytes to send to the host - * @param to_host Data to send + * @param bytes Data to send * @param chan Channel to send data on */ static void i8042_send_to_host(int len, const uint8_t *bytes, uint8_t chan, @@ -281,15 +291,29 @@ static void i8042_send_to_host(int len, const uint8_t *bytes, uint8_t chan, for (i = 0; i < len; i++) kblog_put('r', bytes[i]); } else { - for (i = 0; i < len; i++) - kblog_put(chan == CHAN_AUX ? 'a' : 's', bytes[i]); + struct queue const *queue = &to_host; + + if (chan == CHAN_CMD) + queue = &to_host_cmd; - if (queue_space(&to_host) >= len) { - kblog_put('t', to_host.state->tail); + for (i = 0; i < len; i++) { + char type; + + if (chan == CHAN_AUX) + type = 'a'; + else if (chan == CHAN_CMD) + type = 'u'; + else + type = 's'; + kblog_put(type, bytes[i]); + } + + if (queue_space(queue) >= len) { + kblog_put('t', queue->state->tail); for (i = 0; i < len; i++) { data.chan = chan; data.byte = bytes[i]; - queue_add_unit(&to_host, &data); + queue_add_unit(queue, &data); } } } @@ -417,6 +441,7 @@ void keyboard_clear_buffer(void) mutex_lock(&to_host_mutex); kblog_put('x', queue_count(&to_host)); queue_init(&to_host); + queue_init(&to_host_cmd); mutex_unlock(&to_host_mutex); lpc_keyboard_clear_buffer(); } @@ -661,6 +686,8 @@ static int handle_keyboard_data(uint8_t data, uint8_t *output) /* Chrome OS doesn't have keyboard LEDs, so ignore */ output[out_len++] = ATKBD_RET_ACK; data_port_state = STATE_ATKBD_SETLEDS; + setleds_deadline.val = get_time().val + SETLEDS_TIMEOUT; + CPRINTS5("KB SETLEDS"); break; case ATKBD_CMD_EX_SETLEDS: @@ -868,20 +895,23 @@ static void i8042_handle_from_host(void) struct host_byte h; int ret_len; uint8_t output[MAX_SCAN_CODE_LEN]; - uint8_t chan = CHAN_KBD; + uint8_t chan; while (queue_remove_unit(&from_host, &h)) { if (h.type == HOST_COMMAND) { ret_len = handle_keyboard_command(h.byte, output); + chan = CHAN_KBD; } else { CPRINTS5("KB recv data: 0x%02x", h.byte); kblog_put('d', h.byte); if (IS_ENABLED(CONFIG_8042_AUX) && - handle_mouse_data(h.byte, output, &ret_len)) + handle_mouse_data(h.byte, output, &ret_len)) { chan = CHAN_AUX; - else + } else { ret_len = handle_keyboard_data(h.byte, output); + chan = CHAN_CMD; + } } i8042_send_to_host(ret_len, output, chan, 0); @@ -925,10 +955,14 @@ void keyboard_protocol_task(void *u) i8042_handle_from_host(); /* Check if we have data to send to host */ - if (queue_is_empty(&to_host)) + if (queue_is_empty(&to_host) && + queue_is_empty(&to_host_cmd)) break; - /* Handle data waiting for host */ + /* + * Check if the output buffer is full. We can't proceed + * until the host read the data. + */ if (lpc_keyboard_has_char()) { /* If interrupts disabled, nothing we can do */ if (!i8042_keyboard_irq_enabled && @@ -946,26 +980,53 @@ void keyboard_protocol_task(void *u) * data? Send it another interrupt in case it * somehow missed the first one. */ - CPRINTS("KB extra IRQ"); + CPRINTS("KB host not responding"); lpc_keyboard_resume_irq(); retries = 0; break; } + /* + * We know DBBOUT is empty but we need act quickly as + * the host might be sending a byte to DBBIN. + * + * So be cautious if you're adding any code below up to + * lpc_keyboard_put_char since that'll increase the race + * condition. For example, you don't want to add CPRINTS + * or kblog_put. + * + * We should claim OBF=1 atomically to prevent the host + * from writing to DBBIN (i.e. set-ibf-if-not-obf). It's + * not possible for NPCX because NPCX's HIKMST-IBF is + * read-only. + */ + /* Get a char from buffer. */ - kblog_put('k', to_host.state->head); - queue_remove_unit(&to_host, &entry); + if (queue_count(&to_host_cmd)) { + queue_remove_unit(&to_host_cmd, &entry); + } else if (data_port_state == STATE_ATKBD_SETLEDS) { + /* to_host_cmd is empty but in SETLEDS */ + if (!timestamp_expired(setleds_deadline, &t)) + /* Let's wait for the 2nd byte. */ + break; + /* Didn't receive 2nd byte. Go back to CMD. */ + CPRINTS("KB SETLEDS timeout"); + data_port_state = STATE_ATKBD_CMD; + } else { + /* to_host isn't empty && not in SETLEDS */ + queue_remove_unit(&to_host, &entry); + } /* Write to host. */ if (entry.chan == CHAN_AUX && IS_ENABLED(CONFIG_8042_AUX)) { - kblog_put('A', entry.byte); lpc_aux_put_char(entry.byte, i8042_aux_irq_enabled); + kblog_put('A', entry.byte); } else { - kblog_put('K', entry.byte); lpc_keyboard_put_char( entry.byte, i8042_keyboard_irq_enabled); + kblog_put('K', entry.byte); } retries = 0; } diff --git a/test/kb_8042.c b/test/kb_8042.c index e7d7690cff..eb043d5f82 100644 --- a/test/kb_8042.c +++ b/test/kb_8042.c @@ -261,6 +261,7 @@ static int _read_cmd_byte(uint8_t *cmd) void before_test(void) { /* Make sure all tests start with the controller in the same state */ + keyboard_clear_buffer(); _write_cmd_byte(I8042_XLATE | I8042_AUX_DIS | I8042_KBD_DIS); } @@ -274,7 +275,7 @@ void after_test(void) } } -static int test_8042_aux_loopback(void) +test_static int test_8042_aux_loopback(void) { /* Disable all IRQs */ WRITE_CMD_BYTE(0); @@ -293,7 +294,7 @@ static int test_8042_aux_loopback(void) return EC_SUCCESS; } -static int test_8042_aux_two_way_communication(void) +test_static int test_8042_aux_two_way_communication(void) { /* Enable AUX IRQ */ WRITE_CMD_BYTE(I8042_ENIRQ12); @@ -311,7 +312,7 @@ static int test_8042_aux_two_way_communication(void) return EC_SUCCESS; } -static int test_8042_aux_inhibit(void) +test_static int test_8042_aux_inhibit(void) { /* Enable AUX IRQ, but inhibit the AUX device from sending data. */ WRITE_CMD_BYTE(I8042_ENIRQ12 | I8042_AUX_DIS); @@ -339,7 +340,7 @@ static int test_8042_aux_inhibit(void) return EC_SUCCESS; } -static int test_8042_aux_controller_commands(void) +test_static int test_8042_aux_controller_commands(void) { uint8_t ctrl; @@ -359,7 +360,7 @@ static int test_8042_aux_controller_commands(void) return EC_SUCCESS; } -static int test_8042_aux_test_command(void) +test_static int test_8042_aux_test_command(void) { i8042_write_cmd(I8042_TEST_MOUSE); @@ -368,7 +369,7 @@ static int test_8042_aux_test_command(void) return EC_SUCCESS; } -static int test_8042_self_test(void) +test_static int test_8042_self_test(void) { i8042_write_cmd(I8042_RESET_SELF_TEST); VERIFY_LPC_CHAR("\x55"); @@ -376,7 +377,7 @@ static int test_8042_self_test(void) return EC_SUCCESS; } -static int test_8042_keyboard_test_command(void) +test_static int test_8042_keyboard_test_command(void) { i8042_write_cmd(I8042_TEST_KB_PORT); VERIFY_LPC_CHAR("\x00"); /* Data and Clock are not stuck */ @@ -384,7 +385,7 @@ static int test_8042_keyboard_test_command(void) return EC_SUCCESS; } -static int test_8042_keyboard_controller_commands(void) +test_static int test_8042_keyboard_controller_commands(void) { uint8_t ctrl; @@ -404,7 +405,7 @@ static int test_8042_keyboard_controller_commands(void) return EC_SUCCESS; } -static int test_8042_keyboard_key_pressed_while_inhibited(void) +test_static int test_8042_keyboard_key_pressed_while_inhibited(void) { ENABLE_KEYSTROKE(1); @@ -440,7 +441,8 @@ static int test_8042_keyboard_key_pressed_while_inhibited(void) return EC_SUCCESS; } -static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void) +test_static int +test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void) { ENABLE_KEYSTROKE(1); /* Simulate a keypress on the keyboard */ @@ -472,7 +474,7 @@ static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void) return EC_SUCCESS; } -static int +test_static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte_with_read(void) { uint8_t cmd; @@ -524,7 +526,7 @@ test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte_with_read(void) return EC_SUCCESS; } -static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void) +test_static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void) { ENABLE_KEYSTROKE(1); /* Simulate a keypress on the keyboard */ @@ -556,7 +558,7 @@ static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void) return EC_SUCCESS; } -static int test_single_key_press(void) +test_static int test_single_key_press(void) { ENABLE_KEYSTROKE(1); press_key(1, 1, 1); @@ -572,7 +574,7 @@ static int test_single_key_press(void) return EC_SUCCESS; } -static int test_disable_keystroke(void) +test_static int test_disable_keystroke(void) { ENABLE_KEYSTROKE(0); press_key(1, 1, 1); @@ -583,7 +585,7 @@ static int test_disable_keystroke(void) return EC_SUCCESS; } -static int test_typematic(void) +test_static int test_typematic(void) { ENABLE_KEYSTROKE(1); @@ -610,7 +612,7 @@ static int test_typematic(void) return EC_SUCCESS; } -static int test_atkbd_get_scancode(void) +test_static int test_atkbd_get_scancode(void) { SET_SCANCODE(1); @@ -635,7 +637,7 @@ static int test_atkbd_get_scancode(void) return EC_SUCCESS; } -static int test_atkbd_set_scancode_with_keystroke_disabled(void) +test_static int test_atkbd_set_scancode_with_keystroke_disabled(void) { ENABLE_KEYSTROKE(0); @@ -647,7 +649,7 @@ static int test_atkbd_set_scancode_with_keystroke_disabled(void) return EC_SUCCESS; } -static int test_atkbd_set_scancode_with_key_press_before_set(void) +test_static int test_atkbd_set_scancode_with_key_press_before_set(void) { ENABLE_KEYSTROKE(0); ENABLE_KEYSTROKE(1); @@ -660,26 +662,17 @@ static int test_atkbd_set_scancode_with_key_press_before_set(void) * ATKBD_CMD_SSCANSET should cause the keyboard to stop scanning, flush * the keyboards output queue, and reset the typematic key. */ - keyboard_host_write(ATKBD_CMD_SSCANSET, 0); - /* Read out the scan code that got pushed into the output buffer before - * the command was sent. - */ - VERIFY_LPC_CHAR("\x01"); + i8042_write_data(ATKBD_CMD_SSCANSET); + VERIFY_ATKBD_ACK(); /* * FIXME: This is wrong. The keyboard's output queue should have been * flushed when it received the `ATKBD_CMD_SSCANSET` command. */ - VERIFY_LPC_CHAR("\x81"); - - /* This is the ACK for `ATKBD_CMD_SSCANSET`. */ - VERIFY_ATKBD_ACK(); - - /* The keyboard has flushed the buffer so no more keys. */ - VERIFY_NO_CHAR(); + VERIFY_LPC_CHAR("\x01\x81"); /* Finish setting scan code 1 */ - keyboard_host_write(1, 0); + i8042_write_data(1); VERIFY_ATKBD_ACK(); /* Key scanning should be restored. */ @@ -690,7 +683,7 @@ static int test_atkbd_set_scancode_with_key_press_before_set(void) return EC_SUCCESS; } -static int test_atkbd_set_scancode_with_key_press_during_set(void) +test_static int test_atkbd_set_scancode_with_key_press_during_set(void) { ENABLE_KEYSTROKE(1); @@ -698,7 +691,7 @@ static int test_atkbd_set_scancode_with_key_press_during_set(void) * ATKBD_CMD_SSCANSET should cause the keyboard to stop scanning, flush * the keyboards output queue, and reset the typematic key. */ - keyboard_host_write(ATKBD_CMD_SSCANSET, 0); + i8042_write_data(ATKBD_CMD_SSCANSET); VERIFY_ATKBD_ACK(); /* These keypresses should be dropped. */ @@ -711,7 +704,7 @@ static int test_atkbd_set_scancode_with_key_press_during_set(void) VERIFY_LPC_CHAR("\x01\x81"); /* Finish setting scan code 1 */ - keyboard_host_write(1, 0); + i8042_write_data(1); VERIFY_ATKBD_ACK(); /* Key scanning should be restored. */ @@ -722,7 +715,7 @@ static int test_atkbd_set_scancode_with_key_press_during_set(void) return EC_SUCCESS; } -static int test_atkbd_echo(void) +test_static int test_atkbd_echo(void) { i8042_write_data(ATKBD_CMD_DIAG_ECHO); VERIFY_ATKBD_ACK(); @@ -732,7 +725,7 @@ static int test_atkbd_echo(void) return EC_SUCCESS; } -static int test_atkbd_get_id(void) +test_static int test_atkbd_get_id(void) { i8042_write_data(ATKBD_CMD_GETID); VERIFY_ATKBD_ACK(); @@ -747,8 +740,10 @@ static int test_atkbd_get_id(void) return EC_SUCCESS; } -static int test_atkbd_set_leds_keypress_during(void) +test_static int test_atkbd_set_leds_keypress_during(void) { + ENABLE_KEYSTROKE(1); + /* This should pause scanning. */ i8042_write_data(ATKBD_CMD_SETLEDS); VERIFY_ATKBD_ACK(); @@ -756,16 +751,20 @@ static int test_atkbd_set_leds_keypress_during(void) /* Simulate keypress while keyboard is waiting for option byte */ press_key(1, 1, 1); press_key(1, 1, 0); - /* FIXME: This is wrong, we shouldn't have any key strokes */ - VERIFY_LPC_CHAR("\x01\x81"); + + /* Scancode is kept in queue during SETLEDS. */ + VERIFY_NO_CHAR(); i8042_write_data(0x01); VERIFY_ATKBD_ACK(); + /* Scancode previously queued should be sent now. */ + VERIFY_LPC_CHAR("\x01\x81"); + return EC_SUCCESS; } -static int test_atkbd_set_leds_abort_set(void) +test_static int test_atkbd_set_leds_abort_set(void) { i8042_write_data(ATKBD_CMD_SETLEDS); VERIFY_ATKBD_ACK(); @@ -785,7 +784,7 @@ static int test_atkbd_set_leds_abort_set(void) return EC_SUCCESS; } -static int test_atkbd_set_ex_leds(void) +test_static int test_atkbd_set_ex_leds(void) { i8042_write_data(ATKBD_CMD_EX_SETLEDS); VERIFY_ATKBD_ACK(); @@ -801,9 +800,10 @@ static int test_atkbd_set_ex_leds(void) return EC_SUCCESS; } -static int test_scancode_set2(void) +test_static int test_scancode_set2(void) { SET_SCANCODE(2); + ENABLE_KEYSTROKE(1); WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE); press_key(1, 1, 1); @@ -820,7 +820,7 @@ static int test_scancode_set2(void) return EC_SUCCESS; } -static int test_power_button(void) +test_static int test_power_button(void) { ENABLE_KEYSTROKE(0); @@ -857,7 +857,7 @@ static int test_power_button(void) return EC_SUCCESS; } -static int test_sysjump(void) +test_static int test_sysjump(void) { SET_SCANCODE(2); ENABLE_KEYSTROKE(1); @@ -868,15 +868,17 @@ static int test_sysjump(void) return EC_ERROR_UNKNOWN; } -static int test_sysjump_cont(void) +test_static int test_sysjump_cont(void) { WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE); + press_key(1, 1, 1); VERIFY_LPC_CHAR("\x01"); press_key(1, 1, 0); VERIFY_LPC_CHAR("\x81"); WRITE_CMD_BYTE(READ_CMD_BYTE() & ~I8042_XLATE); + press_key(1, 1, 1); VERIFY_LPC_CHAR("\x76"); press_key(1, 1, 0); @@ -885,7 +887,7 @@ static int test_sysjump_cont(void) return EC_SUCCESS; } -static const struct ec_response_keybd_config keybd_config = { +test_static const struct ec_response_keybd_config keybd_config = { .num_top_row_keys = 13, .action_keys = { TK_BACK, /* T1 */ @@ -910,7 +912,7 @@ board_vivaldi_keybd_config(void) return &keybd_config; } -static int test_ec_cmd_get_keybd_config(void) +test_static int test_ec_cmd_get_keybd_config(void) { struct ec_response_keybd_config resp; int rv; @@ -931,22 +933,25 @@ static int test_ec_cmd_get_keybd_config(void) return EC_SUCCESS; } -static int test_vivaldi_top_keys(void) +test_static int test_vivaldi_top_keys(void) { SET_SCANCODE(2); /* Test REFRESH key */ WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE); + press_key(2, 3, 1); /* Press T2 */ VERIFY_LPC_CHAR("\xe0\x67"); /* Check REFRESH scancode in set-1 */ /* Test SNAPSHOT key */ WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE); + press_key(4, 3, 1); /* Press T2 */ VERIFY_LPC_CHAR("\xe0\x13"); /* Check SNAPSHOT scancode in set-1 */ /* Test VOL_UP key */ WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE); + press_key(5, 3, 1); /* Press T2 */ VERIFY_LPC_CHAR("\xe0\x30"); /* Check VOL_UP scancode in set-1 */ -- cgit v1.2.1 From cbacb3e5d0df3df0345b1a4a3462d997310340db Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Sun, 20 Nov 2022 13:56:29 -0800 Subject: tcpmv2: pe: Add mux_set call following successful DATA_RESET MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds a call to set_usb_mux_with_current_data_role after performing a successful DATA_RESET. This is being added to satisfy 6.3.14 Data_Reset Message, item #3: If the Port was operating in [USB 3.2] or [USB4] reapply the port’s Rx Terminations (see [USB 3.2]). Without this call a mode entry attempt that is either not successful, or rejected by the port partner would leave the USB3.x SS lanes disconnected. This would also be the case following an Exit_Mode request from the AP when DATA_RESET is supported. BUG=b:260095516 BRANCH=none TEST=using drivers.usbc_usb4_mode integration test to verify that the mux ends up in the correct state following a DATA_RESET. Signed-off-by: Scott Collyer Change-Id: I3b6f9d00beb5fcc5a68c44887bde03d22b61d3e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4040832 Tested-by: Scott Collyer Commit-Queue: Scott Collyer Code-Coverage: Zoss Reviewed-by: Abe Levkoy --- common/usbc/usb_pe_drp_sm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index f2bc65da29..5219b9b418 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -7686,8 +7686,7 @@ static void pe_ddr_perform_data_reset_run(int port) * interpretations are mutually exclusive. Resolve that * ambiguity and update this implementation. */ - usb_mux_set(port, USB_PD_MUX_NONE, USB_SWITCH_DISCONNECT, - polarity_rm_dts(pd_get_polarity(port))); + set_usb_mux_with_current_data_role(port); } else if (IS_ENABLED(CONFIG_USBC_VCONN) && PE_CHK_FLAG(port, PE_FLAGS_VCONN_SWAP_COMPLETE) && tc_is_vconn_src(port)) { -- cgit v1.2.1 From 95e35a602341ea363c194144b7090062589091fb Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 16 Nov 2022 16:17:57 -0800 Subject: motion_sense: avoid possible invalid memory access Returning SENSOR_CONFIG_MAX will cause out of bound read. Return one of the legal values. BUG=b:64477774 BRANCH=none TEST=make -j buildall Signed-off-by: Boris Mittelberg Change-Id: I1d2b407cb42da8b6fa78fb61be39d05ea1d64401 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4032916 Code-Coverage: Zoss Reviewed-by: Ricardo Quesada Reviewed-by: caveh jalali --- common/motion_sense.c | 5 +++-- include/motion_sense.h | 4 ++++ .../test/drivers/default/src/motion_sense/motion_sense.c | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/common/motion_sense.c b/common/motion_sense.c index ff9f186ee3..a309d29f8c 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -118,7 +118,8 @@ motion_sensor_time_to_read(const timestamp_t *ts, sensor->next_collection - motion_min_interval); } -static enum sensor_config motion_sense_get_ec_config(void) +STATIC_IF_NOT(CONFIG_ZTEST) +enum sensor_config motion_sense_get_ec_config(void) { switch (sensor_active) { case SENSOR_ACTIVE_S0: @@ -130,7 +131,7 @@ static enum sensor_config motion_sense_get_ec_config(void) default: CPRINTS("get_ec_config: Invalid active state: %x", sensor_active); - return SENSOR_CONFIG_MAX; + return SENSOR_CONFIG_EC_S5; } } /* motion_sense_set_data_rate diff --git a/include/motion_sense.h b/include/motion_sense.h index 750208d5cf..ac074055aa 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -360,4 +360,8 @@ ec_motion_sensor_fill_values(struct ec_response_motion_sensor_data *dst, dst->data[2] = v[2]; } +#ifdef CONFIG_ZTEST +enum sensor_config motion_sense_get_ec_config(void); +#endif + #endif /* __CROS_EC_MOTION_SENSE_H */ diff --git a/zephyr/test/drivers/default/src/motion_sense/motion_sense.c b/zephyr/test/drivers/default/src/motion_sense/motion_sense.c index c3f03e4ade..8291e0e1c6 100644 --- a/zephyr/test/drivers/default/src/motion_sense/motion_sense.c +++ b/zephyr/test/drivers/default/src/motion_sense/motion_sense.c @@ -8,6 +8,8 @@ #include +extern enum chipset_state_mask sensor_active; + ZTEST_SUITE(motion_sense, drivers_predicate_post_main, NULL, NULL, NULL, NULL); ZTEST_USER(motion_sense, ec_motion_sensor_fill_values) @@ -33,3 +35,17 @@ ZTEST_USER(motion_sense, ec_motion_sensor_clamp_i16) zassert_equal(ec_motion_sensor_clamp_i16(INT16_MIN - 1), INT16_MIN, NULL); } + +ZTEST_USER(motion_sense, ec_motion_sense_get_ec_config) +{ + /* illegal state, should be translated to S5 */ + sensor_active = 42; + zassert_equal(motion_sense_get_ec_config(), SENSOR_CONFIG_EC_S5); + /* all valid states */ + sensor_active = SENSOR_ACTIVE_S0; + zassert_equal(motion_sense_get_ec_config(), SENSOR_CONFIG_EC_S0); + sensor_active = SENSOR_ACTIVE_S3; + zassert_equal(motion_sense_get_ec_config(), SENSOR_CONFIG_EC_S3); + sensor_active = SENSOR_ACTIVE_S5; + zassert_equal(motion_sense_get_ec_config(), SENSOR_CONFIG_EC_S5); +} -- cgit v1.2.1 From 7340d1aade18eaad4ae3ae5407ff1a7f475ea6e0 Mon Sep 17 00:00:00 2001 From: Rajesh Kumar Date: Tue, 22 Nov 2022 17:33:51 -0800 Subject: rex: Remove unused PSL pin from PSL IO pad list EC reboots when hibernate command is triggered on EC console. Only LID_OPEN, ACOK_OD and MECH_PWR_BTN_ODL needs to be configured as PSL wake-up pins. The additional congifured signal GSC_EC_PWR_BTN_ODL which is the passthroug signal from H1 is causing reboot on hibernate. Hence removed the unused PSL signal from PSL configuration. BRANCH=None BUG=b:260129864 TEST=No reboot observed on hibernate using EC command. EC is coming out of hibernate state when Type-C charger is conncted. Signed-off-by: Rajesh Kumar Change-Id: I433519186f864ad939e4d6fb984c087899e2a3da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049896 Code-Coverage: Zoss Reviewed-by: Fabio Baltieri Reviewed-by: Vijay P Hiremath --- zephyr/program/rex/rex.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/program/rex/rex.dts b/zephyr/program/rex/rex.dts index 801ba537a0..a20bfccdfe 100644 --- a/zephyr/program/rex/rex.dts +++ b/zephyr/program/rex/rex.dts @@ -83,7 +83,7 @@ &power_ctrl_psl { status = "okay"; pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>; }; /* ADC and GPIO alt-function specifications */ -- cgit v1.2.1 From 6dd12ddff735adb9cb1c6ec2528724c87b23e76e Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Fri, 4 Nov 2022 12:25:03 -0600 Subject: tabletmode: Correctly handle HW orientation changing When the tabletmode is being forced by 'tabletmode on' or 'tabletmode off', the actual HW orientation can still change between tablet and clamshell mode. When 'tabletmode reset' is issued, the device should behave correctly based on the current HW orientation. This also updates the test drivers.default.tablet_set_mode to fix spelling errors and adds comments to explain the various zassert_equal() values being checked. BRANCH=none BUG=b:256015402 TEST=./twister -v -i --coverage -p native_posix -p unit_testing \ -s zephyr/test/drivers/drivers.host_cmd ./twister -v -i --coverage -p native_posix -p unit_testing \ -s zephyr/test/drivers/drivers.default TEST='tabletmode on' in clamshell mode, convert DUT to tablet mode, 'tabletmode reset', verify DUT is in tablet mode. Change-Id: I1039bda7790e0623b013db01e673fe43fa7d8fc8 Signed-off-by: Tim Van Patten Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4006302 Code-Coverage: Zoss Reviewed-by: Raul Rangel Reviewed-by: Diana Z --- common/tablet_mode.c | 44 ++++++++++++++++----- zephyr/test/drivers/default/src/tablet_mode.c | 56 ++++++++++++++------------- 2 files changed, 64 insertions(+), 36 deletions(-) diff --git a/common/tablet_mode.c b/common/tablet_mode.c index 1a86997eb4..18e97e91db 100644 --- a/common/tablet_mode.c +++ b/common/tablet_mode.c @@ -68,27 +68,51 @@ static void notify_tablet_mode_change(void) void tablet_set_mode(int mode, uint32_t trigger) { - uint32_t old_mode = tablet_mode; - - /* If tablet_mode is forced via a console command, ignore set. */ - if (tablet_mode_forced) - return; + uint32_t new_mode = tablet_mode_forced ? tablet_mode_store : + tablet_mode; + uint32_t old_mode = 0; if (disabled) { - CPRINTS("Tablet mode set while disabled (ignoring)!"); + /* + * If tablet mode is being forced by the user, then this logging + * would be misleading since the mode wouldn't change anyway, so + * skip it. + */ + if (!tablet_mode_forced) + CPRINTS("Tablet mode set while disabled (ignoring)!"); return; } if (gmr_sensor_at_360 && !mode) { - CPRINTS("Ignoring tablet mode exit while gmr sensor " - "reports 360-degree tablet mode."); + /* + * If tablet mode is being forced by the user, then this logging + * would be misleading since the mode wouldn't change anyway, so + * skip it. + */ + if (!tablet_mode_forced) + CPRINTS("Ignoring tablet mode exit while gmr sensor " + "reports 360-degree tablet mode."); return; } if (mode) - tablet_mode |= trigger; + new_mode |= trigger; else - tablet_mode &= ~trigger; + new_mode &= ~trigger; + + if (tablet_mode_forced) { + /* + * Save the current mode based on the HW orientation, so we + * apply the correct mode if tablet mode no longer forced in the + * future. Don't notify of the tablet mode change yet, since + * that will be done as part of handling 'tabletmode reset'. + */ + tablet_mode_store = new_mode; + return; + } + + old_mode = tablet_mode; + tablet_mode = new_mode; /* Boolean comparison */ if (!tablet_mode == !old_mode) diff --git a/zephyr/test/drivers/default/src/tablet_mode.c b/zephyr/test/drivers/default/src/tablet_mode.c index c947663239..773f2c2bf8 100644 --- a/zephyr/test/drivers/default/src/tablet_mode.c +++ b/zephyr/test/drivers/default/src/tablet_mode.c @@ -34,27 +34,31 @@ ZTEST_USER(tabletmode, test_tablet_set_mode) int ret; ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet initial mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet initial mode: %d", ret); tablet_set_mode(1, TABLET_TRIGGER_LID); - ret = tablet_get_mode(); - zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 1, "unexpected tablet mode: %d", ret); tablet_set_mode(1, TABLET_TRIGGER_BASE); - ret = tablet_get_mode(); - zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 1, "unexpected tablet mode: %d", ret); + /** + * Tablet mode should remain enabled, since both _LID and _BASE were set + * previously, and this only clears _LID. + */ tablet_set_mode(0, TABLET_TRIGGER_LID); - ret = tablet_get_mode(); - zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 1, "unexpected tablet mode: %d", ret); + /** + * Both _LID and _BASE are now cleared, so DUT is no longer in tablet + * mode. + */ tablet_set_mode(0, TABLET_TRIGGER_BASE); - ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet mode: %d", ret); } /** @@ -65,13 +69,13 @@ ZTEST_USER(tabletmode, test_tablet_disable) int ret; ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet initial mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet initial mode: %d", ret); tablet_disable(); tablet_set_mode(1, TABLET_TRIGGER_LID); ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet mode: %d", ret); } /** @@ -82,28 +86,28 @@ ZTEST_USER(tabletmode, test_settabletmode_on_off) int ret; ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet initial mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet initial mode: %d", ret); ret = shell_execute_cmd(get_ec_shell(), "tabletmode"); - zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d", + zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d", ret); ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet mode: %d", ret); ret = shell_execute_cmd(get_ec_shell(), "tabletmode on"); - zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d", + zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d", ret); ret = tablet_get_mode(); - zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 1, "unexpected tablet mode: %d", ret); ret = shell_execute_cmd(get_ec_shell(), "tabletmode off"); - zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d", + zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d", ret); ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet mode: %d", ret); } /** @@ -115,28 +119,28 @@ ZTEST_USER(tabletmode, test_settabletmode_forced) int ret; ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet initial mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet initial mode: %d", ret); ret = shell_execute_cmd(get_ec_shell(), "tabletmode on"); - zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d", + zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d", ret); ret = tablet_get_mode(); - zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 1, "unexpected tablet mode: %d", ret); tablet_set_mode(0, TABLET_TRIGGER_LID); ret = tablet_get_mode(); - zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 1, "unexpected tablet mode: %d", ret); ret = shell_execute_cmd(get_ec_shell(), "tabletmode reset"); - zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d", + zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d", ret); tablet_set_mode(0, TABLET_TRIGGER_LID); ret = tablet_get_mode(); - zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret); + zassert_equal(ret, 0, "unexpected tablet mode: %d", ret); } /** @@ -149,7 +153,7 @@ ZTEST_USER(tabletmode, test_settabletmode_too_many_args) ret = shell_execute_cmd(get_ec_shell(), "tabletmode too many arguments"); zassert_equal(ret, EC_ERROR_PARAM_COUNT, - "unexepcted command return status: %d", ret); + "unexpected command return status: %d", ret); } /** @@ -161,7 +165,7 @@ ZTEST_USER(tabletmode, test_settabletmode_unknown_arg) ret = shell_execute_cmd(get_ec_shell(), "tabletmode X"); zassert_equal(ret, EC_ERROR_PARAM1, - "unexepcted command return status: %d", ret); + "unexpected command return status: %d", ret); } ZTEST_SUITE(tabletmode, drivers_predicate_post_main, NULL, tabletmode_before, -- cgit v1.2.1 From 7fdbe139cc58304b0ed4531847ea8dafc553f7d3 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 23 Nov 2022 14:32:03 -0800 Subject: crash_analyzer: improve the assert case Detecting PC in case of assert (cause 3) from r3 BRANCH=none BUG=none TEST=manually on redrix crash reports Signed-off-by: Boris Mittelberg Change-Id: Ifab41cfd081dd61a18db9cee2cd83b5e58fa06ef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4053343 Code-Coverage: Zoss Reviewed-by: Ricardo Quesada --- util/crash_analyzer.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/util/crash_analyzer.py b/util/crash_analyzer.py index 552ed9c46c..88592f800a 100755 --- a/util/crash_analyzer.py +++ b/util/crash_analyzer.py @@ -124,18 +124,23 @@ def cm0_parse(match) -> dict: regs["ipsr"] = values[22] regs["cause"] = get_crash_cause(values[6]) # r4 - # Heuristics: try link register, then PC, then what is believed to be PC. - # When analyzing watchdogs, we try to be as close as possible to the caller - # function that caused the watchdog. - # That's why we prioritize LR (return address) over PC. - if regs["lr"] != -1: - regs["symbol"] = get_symbol(regs["lr"]) - elif regs["pc"] != -1: - regs["symbol"] = get_symbol(regs["pc"]) + + # based on crash reports in case of asserrt the PC is in R3 + if regs["cause"] == "assert": + regs["symbol"] = get_symbol(values[5]) # r3 else: - # Otherwise, if both LR and PC are empty, most probably - # PC is in R5. - regs["symbol"] = get_symbol(values[7]) # r5 + # Heuristics: try link register, then PC, then what is believed to be PC. + # When analyzing watchdogs, we try to be as close as possible to the caller + # function that caused the watchdog. + # That's why we prioritize LR (return address) over PC. + if regs["lr"] != -1: + regs["symbol"] = get_symbol(regs["lr"]) + elif regs["pc"] != -1: + regs["symbol"] = get_symbol(regs["pc"]) + else: + # Otherwise, if both LR and PC are empty, most probably + # PC is in R5. + regs["symbol"] = get_symbol(values[7]) # r5 return regs -- cgit v1.2.1 From 6bc70c3faeb404d985b4dcb5c73fb975d4132612 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Mon, 21 Nov 2022 14:10:35 -0700 Subject: tcpm_header: add tests for tcpm_set_frs_enable This function had no coverage previously. Added tests for both cases where the driver does and does not implement these functions. Since the function is conditionally included, guard the tests by checking the same configuration. BUG=none TEST=twister, verify lines are now covered BRANCH=none Signed-off-by: Clayton Whitelaw Change-Id: I287642975e05b7331333b7016af8e571c9e28676 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052580 Code-Coverage: Zoss Reviewed-by: Simon Glass --- zephyr/test/drivers/default/src/tcpm_header.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c index e84a3e7ad4..118e4676f7 100644 --- a/zephyr/test/drivers/default/src/tcpm_header.c +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -17,6 +17,7 @@ FAKE_VALUE_FUNC(int, reset_bist_type_2, int); FAKE_VALUE_FUNC(int, debug_accessory, int, bool); FAKE_VALUE_FUNC(int, debug_detach, int); FAKE_VALUE_FUNC(int, hard_reset_reinit, int); +FAKE_VALUE_FUNC(int, set_frs_enable, int, int); struct tcpm_header_fixture { /* The original driver pointer that gets restored after the tests */ @@ -124,6 +125,31 @@ ZTEST_F(tcpm_header, test_tcpm_header_hard_reset_reinit__implemented) zassert_equal(driver_return_code, res); } +ZTEST_F(tcpm_header, test_tcpm_header_set_frs_enable__unimplemented) +{ + Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_USB_PD_FRS); + + zassert_ok(tcpm_set_frs_enable(TCPM_TEST_PORT, 1)); + zassert_ok(tcpm_set_frs_enable(TCPM_TEST_PORT, 0)); +} + +ZTEST_F(tcpm_header, test_tcpm_header_set_frs_enable__implemented) +{ + int res; + const int driver_return_code = 7458; /* arbitrary */ + + Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_USB_PD_FRS); + + fixture->mock_driver.set_frs_enable = set_frs_enable; + set_frs_enable_fake.return_val = driver_return_code; + res = tcpm_set_frs_enable(TCPM_TEST_PORT, 1); + + zassert_equal(1, set_frs_enable_fake.call_count); + zassert_equal(TCPM_TEST_PORT, set_frs_enable_fake.arg0_history[0]); + zassert_equal(1, set_frs_enable_fake.arg1_history[0]); + zassert_equal(driver_return_code, res); +} + static void *tcpm_header_setup(void) { static struct tcpm_header_fixture fixture; @@ -140,6 +166,7 @@ static void tcpm_header_before(void *state) RESET_FAKE(debug_accessory); RESET_FAKE(debug_detach); RESET_FAKE(hard_reset_reinit); + RESET_FAKE(set_frs_enable); fixture->mock_driver = (struct tcpm_drv){ 0 }; fixture->saved_driver_ptr = tcpc_config[TCPM_TEST_PORT].drv; -- cgit v1.2.1 From 4ca57630ffff4182ffb4e29879d70346623650f8 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Mon, 28 Nov 2022 11:35:44 -0700 Subject: zephyr: update cmake toolchain for unittest coverage Add support for unittest coverage in our own toolchain. BRANCH=none BUG=none TEST=./twister -c -v -i --gcc -p unit_testing -C TEST=./twister -c -v -i --llvm -p unit_testing -C Change-Id: I3e7ffd7bbea809ae9c6ab1d9b6e6104627245abf Signed-off-by: Yuval Peress Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4060364 Code-Coverage: Zoss Reviewed-by: Jeremy Bettis --- util/twister_launcher.py | 4 ++++ zephyr/cmake/compiler/clang/compiler_flags.cmake | 3 +++ zephyr/cmake/compiler/gcc/compiler_flags.cmake | 3 +++ zephyr/cmake/linker/ld/clang/linker_flags.cmake | 7 +++++++ zephyr/cmake/linker/ld/gcc/linker_flags.cmake | 4 ++++ zephyr/cmake/toolchain/llvm/target.cmake | 1 - 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 zephyr/cmake/linker/ld/clang/linker_flags.cmake diff --git a/util/twister_launcher.py b/util/twister_launcher.py index ef41b7621b..11202f9343 100755 --- a/util/twister_launcher.py +++ b/util/twister_launcher.py @@ -37,6 +37,10 @@ parameters that may be used, please consult the Twister documentation. # version: "version:5.8.0.chromium.3" # > # wheel: < +# name: "infra/python/wheels/pyelftools-py2_py3" +# version: "version:0.29" +# > +# wheel: < # name: "infra/python/wheels/pykwalify-py2_py3" # version: "version:1.8.0" # > diff --git a/zephyr/cmake/compiler/clang/compiler_flags.cmake b/zephyr/cmake/compiler/clang/compiler_flags.cmake index 536540eb1e..f24e1f1f4c 100644 --- a/zephyr/cmake/compiler/clang/compiler_flags.cmake +++ b/zephyr/cmake/compiler/clang/compiler_flags.cmake @@ -21,3 +21,6 @@ check_set_compiler_property(APPEND PROPERTY warning_extended -Wunused-variable -Werror=unused-variable -Werror=missing-braces -Werror=sometimes-uninitialized -Werror=unused-function -Werror=array-bounds) + +# clang flags for coverage generation +set_property(TARGET compiler PROPERTY coverage --coverage -fno-inline) diff --git a/zephyr/cmake/compiler/gcc/compiler_flags.cmake b/zephyr/cmake/compiler/gcc/compiler_flags.cmake index adc111835e..fbc7ca1d61 100644 --- a/zephyr/cmake/compiler/gcc/compiler_flags.cmake +++ b/zephyr/cmake/compiler/gcc/compiler_flags.cmake @@ -8,3 +8,6 @@ include("${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake") # Disable position independent code. add_compile_options(-fno-PIC) + +# gcc flags for coverage generation +set_compiler_property(PROPERTY coverage -fprofile-arcs -ftest-coverage -fno-inline) diff --git a/zephyr/cmake/linker/ld/clang/linker_flags.cmake b/zephyr/cmake/linker/ld/clang/linker_flags.cmake new file mode 100644 index 0000000000..38f5428d13 --- /dev/null +++ b/zephyr/cmake/linker/ld/clang/linker_flags.cmake @@ -0,0 +1,7 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +if (NOT CONFIG_COVERAGE_GCOV) + set_property(TARGET linker PROPERTY coverage --coverage) +endif() diff --git a/zephyr/cmake/linker/ld/gcc/linker_flags.cmake b/zephyr/cmake/linker/ld/gcc/linker_flags.cmake index f71793c431..b5ec8b05ca 100644 --- a/zephyr/cmake/linker/ld/gcc/linker_flags.cmake +++ b/zephyr/cmake/linker/ld/gcc/linker_flags.cmake @@ -2,6 +2,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +if (NOT CONFIG_COVERAGE_GCOV) + set_property(TARGET linker PROPERTY coverage -lgcov) +endif() + # GCC 11 by default emits DWARF version 5 which cannot be parsed by # pyelftools. Can be removed once pyelftools supports v5. add_link_options(-gdwarf-4) diff --git a/zephyr/cmake/toolchain/llvm/target.cmake b/zephyr/cmake/toolchain/llvm/target.cmake index 00669a590b..e8e5df7be1 100644 --- a/zephyr/cmake/toolchain/llvm/target.cmake +++ b/zephyr/cmake/toolchain/llvm/target.cmake @@ -7,7 +7,6 @@ set(LINKER lld) set(BINTOOLS llvm) # Mapping of Zephyr architecture -> toolchain triple -# Note only "posix" is supported at the moment. set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu) set(CROSS_COMPILE_TARGET_unit_testing x86_64-pc-linux-gnu) -- cgit v1.2.1 From 5fa09f3889b8476e5c34df1d363b514dec0738fe Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Mon, 28 Nov 2022 11:54:06 -0800 Subject: test: Fix TypeError in run_device_tests.py BUG=b:260607990 TEST=run_device_tests.py --help BRANCH=none Signed-off-by: Andrea Grandi Change-Id: I51166b553497a20e2ba8743d2da682768a3d2cd6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062572 Reviewed-by: Tom Hughes Code-Coverage: Zoss --- test/run_device_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run_device_tests.py b/test/run_device_tests.py index 15f160a53b..8983a60b82 100755 --- a/test/run_device_tests.py +++ b/test/run_device_tests.py @@ -397,7 +397,7 @@ def read_file_gsutil(path: str) -> bytes: return gsutil.stdout -def find_section_offset_size(section: str, image: bytes) -> Tuple(int, int): +def find_section_offset_size(section: str, image: bytes) -> Tuple[int, int]: """Get offset and size of the section in image""" areas = fmap.fmap_decode(image)["areas"] area = next(area for area in areas if area["name"] == section) -- cgit v1.2.1 From 1fc2ef1334bb550a558fedf6d9ed824be3272c41 Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Thu, 24 Nov 2022 16:01:54 +1100 Subject: nissa/sm5803: avoid charging from 12V with 3S battery The combination of 12V VBUS and 3S battery is extremely inefficient with the SM5803, so completely reject 12V PD contracts when the battery design voltage is consistent with a 3S battery and the board uses SM5803. BUG=b:260271871, b:258754576 TEST=With PD max voltage limited to 12V and a charger with 12V source caps, nereid negotiates a 9V PD contract instead. BRANCH=nissa LOW_COVERAGE_REASON=no emulator for SM5803 yet Signed-off-by: Peter Marheine Change-Id: Ieb93d5ca410e8b942686c23cb4b761416f8981d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054762 Reviewed-by: Andrew McRae Commit-Queue: Andrew McRae Code-Coverage: Zoss --- zephyr/Kconfig.charger | 6 ++++++ zephyr/program/nissa/src/common.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger index 35bd8590ab..c2c6eeb3f4 100644 --- a/zephyr/Kconfig.charger +++ b/zephyr/Kconfig.charger @@ -204,6 +204,12 @@ config PLATFORM_EC_CHARGER_SM5803 Enables the driver for the SM5803. The SM5803 is the Silicon Mitus SM5803 Buck-Boost Charger. + This charger is known to be very inefficient when operating in buck-boost + mode (when input voltage is close to output voltage), such that permanent + damage may be done to the charger. Users should exercise caution around + choice of supported configurations: see b:260271871, b:258754576, and + b:230712704 for more information. + if PLATFORM_EC_OCPC diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c index 119a999736..155dc541d4 100644 --- a/zephyr/program/nissa/src/common.c +++ b/zephyr/program/nissa/src/common.c @@ -148,3 +148,42 @@ __override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki, *kd = 0; *kd_div = 1; } + +#ifdef CONFIG_PLATFORM_EC_CHARGER_SM5803 +/* + * Called by USB-PD code to determine whether a given input voltage is + * acceptable. + */ +__override int pd_is_valid_input_voltage(int mv) +{ + int battery_voltage, rv; + + rv = battery_design_voltage(&battery_voltage); + if (rv) { + LOG_ERR("Unable to get battery design voltage: %d", rv); + return true; + } + + /* + * SM5803 is extremely inefficient in buck-boost mode, when + * VBUS ~= VSYS: very high temperatures on the chip and associated + * inductor have been observed when sinking normal charge current in + * buck-boost mode (but not in buck or boost mode) so we choose to + * completely exclude some voltages that are likely to be problematic. + * + * Nissa devices use either 2S or 3S batteries, for which VBUS will + * usually only be near VSYS with a 3S battery and 12V input (picked + * from among common supported PD voltages)- 2S can get close to + * 9V, but we expect charge current to be low when a 2S battery is + * charged to that voltage (because it will be nearly full). + * + * We assume that any battery with a design voltage above 9V is 3S, and + * that other problematic PD voltages (near to, but not exactly 12V) + * will rarely occur. + */ + if (battery_voltage > 9000 && mv == 12000) { + return false; + } + return true; +} +#endif -- cgit v1.2.1 From 6df1ce73533c970762dfef6c878523d01648f846 Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Tue, 15 Nov 2022 15:11:37 -0800 Subject: zephyr: test: Add tests for USB_Enter/DATA_RESET messages This CL adds support for USB_Enter and DATA_RESET messages to the tcpc emmulator. In addition it adds a test suite for USB4 mode. The usbc_tbt_mode test suite was used as a starting reference. BUG=b:260095516 BRANCH=none TEST=manual twister -c -v -i -s /drivers/drivers.usbc_usb4_mode and verify that the tests pass. Signed-off-by: Scott Collyer Change-Id: I34e104a1e53b1540b20451fbd0631bbd9d42559b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4029517 Code-Coverage: Zoss Commit-Queue: Scott Collyer Tested-by: Scott Collyer Reviewed-by: Abe Levkoy --- zephyr/emul/tcpc/emul_tcpci_partner_common.c | 36 +++ .../include/emul/tcpc/emul_tcpci_partner_common.h | 2 + zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/Kconfig | 5 + zephyr/test/drivers/testcase.yaml | 4 + zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt | 5 + .../drivers/usbc_usb4_mode/src/usbc_usb4_mode.c | 269 +++++++++++++++++++++ 7 files changed, 322 insertions(+) create mode 100644 zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt create mode 100644 zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c index cb12d37b63..0473f967dc 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c @@ -758,6 +758,27 @@ tcpci_partner_common_vdm_handler(struct tcpci_partner_data *data, } } +static enum tcpci_partner_handler_res +tcpci_partner_enter_usb_handler(struct tcpci_partner_data *data, + const struct tcpci_emul_msg *message) +{ + /* + * Validate received Enter_USB message against EUDO contents in + * tcpci_partner_data. + * + * TODO(b/260095516): This support needs to be expanded to validate the + * message contents, in a bit field basis. Currently, using this field + * as simple ACCEPT/REJECT criteria. If this value is 0 (default case), + * then ACCEPT this message, else reject it. + */ + if (data->enter_usb_accept) + tcpci_partner_send_control_msg(data, PD_CTRL_ACCEPT, 0); + else + tcpci_partner_send_control_msg(data, PD_CTRL_REJECT, 0); + + return TCPCI_PARTNER_COMMON_MSG_HANDLED; +} + static enum tcpci_partner_handler_res tcpci_partner_common_cable_handler(struct tcpci_partner_data *data, const struct tcpci_emul_msg *message, @@ -1081,6 +1102,8 @@ tcpci_partner_common_sop_msg_handler(struct tcpci_partner_data *data, switch (PD_HEADER_TYPE(header)) { case PD_DATA_VENDOR_DEF: return tcpci_partner_common_vdm_handler(data, tx_msg); + case PD_DATA_ENTER_USB: + return tcpci_partner_enter_usb_handler(data, tx_msg); default: /* No other common handlers for data messages */ return TCPCI_PARTNER_COMMON_MSG_NOT_HANDLED; @@ -1159,6 +1182,18 @@ tcpci_partner_common_sop_msg_handler(struct tcpci_partner_data *data, /* Unexpected message - trigger soft reset */ tcpci_partner_common_send_soft_reset(data); + return TCPCI_PARTNER_COMMON_MSG_HANDLED; + case PD_CTRL_DATA_RESET: + /* + * Send Accept/Reject message + * TODO(b/260095516): To fully exercise this code path, there + * needs to be a mechanism (trigger) to either accept or reject + * this message. + */ + tcpci_partner_send_control_msg(data, PD_CTRL_ACCEPT, 0); + return TCPCI_PARTNER_COMMON_MSG_HANDLED; + case PD_CTRL_DATA_RESET_COMPLETE: + /* There is no expected reply message from the port parter */ return TCPCI_PARTNER_COMMON_MSG_HANDLED; } @@ -1599,6 +1634,7 @@ void tcpci_partner_init(struct tcpci_partner_data *data, enum pd_rev_type rev) data->identity_vdos = 0; data->svids_vdos = 0; data->modes_vdos = 0; + data->enter_usb_accept = false; tcpci_partner_common_clear_ams_ctrl_msg(data); diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h index d0d0a2d183..dd8909c2ca 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h @@ -187,6 +187,8 @@ struct tcpci_partner_data { */ bool have_response[PD_BATT_MAX]; } battery_capabilities; + /* Used to control accept/reject for partner port of Enter_USB msg */ + bool enter_usb_accept; /* * Cable which is "plugged in" to this port partner diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index 3a1390fddf..7c7ff22b31 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -41,6 +41,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_CONSOLE_PD usbc_console_pd) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_CTVPD usbc_ctvpd) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_SVDM_DFP_ONLY usbc_svdm_dfp_only) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_TBT_MODE usbc_tbt_mode) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_USB4_MODE usbc_usb4_mode) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_VCONN_SWAP usbc_vconn_swap) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_OCP usbc_ocp) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_PPC usbc_ppc) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index 0994444f23..8cc1131193 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -118,6 +118,11 @@ config LINK_TEST_SUITE_USBC_SVDM_DFP_ONLY config LINK_TEST_SUITE_USBC_TBT_MODE bool "Link and test the usbc_tbt_mode tests" +config LINK_TEST_SUITE_USBC_USB4_MODE + bool "Link and test the usbc_usb4_mode tests" + help + Include the usbc_usb4 test suite in the binary. + config LINK_TEST_SUITE_USBC_VCONN_SWAP bool "Link and test the usbc_vconn_swap tests" help diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index f74289086a..896562f4f8 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -228,6 +228,10 @@ tests: drivers.usbc_tbt_mode: extra_configs: - CONFIG_LINK_TEST_SUITE_USBC_TBT_MODE=y + drivers.usbc_usb4_mode: + extra_configs: + - CONFIG_LINK_TEST_SUITE_USBC_USB4_MODE=y + - CONFIG_PLATFORM_EC_USB_PD_DATA_RESET_MSG=y drivers.usbc_vconn_swap: extra_configs: - CONFIG_LINK_TEST_SUITE_USBC_VCONN_SWAP=y diff --git a/zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt b/zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt new file mode 100644 index 0000000000..dcf03ae2f6 --- /dev/null +++ b/zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt @@ -0,0 +1,5 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +target_sources(app PRIVATE src/usbc_usb4_mode.c) diff --git a/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c b/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c new file mode 100644 index 0000000000..536f41577e --- /dev/null +++ b/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c @@ -0,0 +1,269 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" +#include "ec_tasks.h" +#include "emul/tcpc/emul_tcpci.h" +#include "emul/tcpc/emul_tcpci_partner_snk.h" +#include "host_command.h" +#include "test/drivers/stubs.h" +#include "tcpm/tcpci.h" +#include "test/drivers/utils.h" +#include "test/drivers/test_state.h" +#include "usb_pd_vdo.h" + +#include +#include +#include + +#include + +#define TEST_PORT USBC_PORT_C0 +/* Remove polarity for any mux checks */ +#define USB_MUX_CHECK_MASK ~USB_PD_MUX_POLARITY_INVERTED + +struct usbc_usb4_mode_fixture { + const struct emul *tcpci_emul; + const struct emul *charger_emul; + struct tcpci_partner_data partner; + struct tcpci_snk_emul_data snk_ext; +}; + +/* Passive USB4 cable */ +struct tcpci_cable_data passive_usb4 = { + .identity_vdm[VDO_INDEX_HDR] = + VDO(USB_SID_PD, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT), + .identity_vdm[VDO_INDEX_IDH] = VDO_IDH( + /* USB host */ false, /* USB device */ false, IDH_PTYPE_PCABLE, + /* modal operation */ false, USB_VID_GOOGLE), + .identity_vdm[VDO_INDEX_CSTAT] = 0, + .identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0xABCD), + .identity_vdm[VDO_INDEX_PTYPE_CABLE1] = + VDO_REV30_PASSIVE(USB_R30_SS_U40_GEN3, USB_VBUS_CUR_3A, + USB_REV30_LATENCY_1m, USB_REV30_TYPE_C), + .identity_vdos = VDO_INDEX_PTYPE_CABLE1 + 1, + +}; + +static void add_sop_vdm_responses(struct tcpci_partner_data *partner) +{ + /* Add Discover Identity response */ + partner->identity_vdm[VDO_INDEX_HDR] = + VDO(USB_SID_PD, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT); + partner->identity_vdm[VDO_INDEX_IDH] = VDO_IDH_REV30( + /* USB host */ false, /* USB device */ true, + /* ptype_u */ IDH_PTYPE_HUB, /* modal */ false, + /* ptype_d */ IDH_PTYPE_UNDEF, /* ctype */ USB_TYPEC_RECEPTACLE, + USB_VID_GOOGLE); + partner->identity_vdm[VDO_INDEX_CSTAT] = 0; + partner->identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0x5678); + partner->identity_vdm[VDO_INDEX_PTYPE_UFP1_VDO] = VDO_UFP1( + /* capability */ (VDO_UFP1_CAPABILITY_USB20 | + VDO_UFP1_CAPABILITY_USB32 | + VDO_UFP1_CAPABILITY_USB4), + /* ctype */ USB_TYPEC_RECEPTACLE, + /* alt modes */ VDO_UFP1_ALT_MODE_TBT3, + /* speed */ USB_R30_SS_U40_GEN3); + partner->identity_vdm[VDO_INDEX_PTYPE_UFP2_VDO] = 0; + partner->identity_vdos = VDO_INDEX_PTYPE_UFP2_VDO + 1; + + /* Add Discover SVIDs response */ + /* + * TODO(b/260095516): USB4 entry does not depend on the contents of + * Discover SVIDs, but a valid Discover SVID response needs to to exist + * to ensure that discovery completes as that's a dependency in the DPM + * module to attempt either Enter_USB or DATA_RESET. + */ + partner->svids_vdm[VDO_INDEX_HDR] = + VDO(USB_SID_PD, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_SVID); + partner->svids_vdm[VDO_INDEX_HDR + 1] = VDO_SVID(USB_VID_INTEL, 0); + partner->svids_vdos = VDO_INDEX_HDR + 2; + + /* Add Discover Modes response */ + /* + * TODO(b/260095516): USB4 entry does not depend on the contents of + * Discover Modes, but a valid Discover Modes response needs to to exist + * to ensure that discovery completes as that's a dependency in the DPM + * module to attempt either Enter_USB or DATA_RESET. + */ + /* Support one mode for TBT (Intel) VID */ + partner->modes_vdm[VDO_INDEX_HDR] = + VDO(USB_VID_INTEL, /* structured VDM */ true, + VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_MODES); + partner->modes_vdm[VDO_INDEX_HDR + 1] = TBT_ALTERNATE_MODE; + partner->modes_vdos = VDO_INDEX_HDR + 2; +} + +static void verify_cable_found(struct tcpci_cable_data *cable) +{ + uint8_t response_buffer[EC_LPC_HOST_PACKET_SIZE]; + struct ec_response_typec_discovery *discovery = + (struct ec_response_typec_discovery *)response_buffer; + + host_cmd_typec_discovery(TEST_PORT, TYPEC_PARTNER_SOP_PRIME, + response_buffer, sizeof(response_buffer)); + + /* The host command does not count the VDM header in identity_count. */ + zassert_equal(discovery->identity_count, cable->identity_vdos - 1, + "Expected %d identity VDOs, got %d", + cable->identity_vdos - 1, discovery->identity_count); + zassert_mem_equal(discovery->discovery_vdo, cable->identity_vdm + 1, + discovery->identity_count * + sizeof(*discovery->discovery_vdo), + "Discovered SOP' identity ACK did not match"); +} + +static void *usbc_usb4_mode_setup(void) +{ + static struct usbc_usb4_mode_fixture fixture; + struct tcpci_partner_data *partner = &fixture.partner; + struct tcpci_snk_emul_data *snk_ext = &fixture.snk_ext; + + tcpci_partner_init(partner, PD_REV30); + partner->extensions = tcpci_snk_emul_init(snk_ext, partner, NULL); + + /* Get references for the emulators */ + fixture.tcpci_emul = EMUL_DT_GET(DT_NODELABEL(tcpci_emul)); + fixture.charger_emul = EMUL_DT_GET(DT_NODELABEL(isl923x_emul)); + + add_sop_vdm_responses(partner); + /* Note: cable behavior will vary by test case */ + + return &fixture; +} + +static void usbc_usb4_mode_before(void *data) +{ + struct usbc_usb4_mode_fixture *fix = data; + + /* Set chipset to ON, this will set TCPM to DRP */ + test_set_chipset_to_s0(); + + /* TODO(b/214401892): Check why need to give TCPM time to spin */ + k_sleep(K_SECONDS(1)); + + /* Enable message logging after TCPM spin */ + tcpci_partner_common_enable_pd_logging(&fix->partner, true); + + /* Initialize parter port Enter_USB msg accept/reject state */ + fix->partner.enter_usb_accept = false; +} + +static void usbc_usb4_mode_after(void *data) +{ + struct usbc_usb4_mode_fixture *fix = data; + + disconnect_sink_from_port(fix->tcpci_emul); + tcpci_partner_common_enable_pd_logging(&fix->partner, false); + tcpci_partner_common_clear_logged_msgs(&fix->partner); +} + +ZTEST_F(usbc_usb4_mode, verify_discovery) +{ + uint8_t response_buffer[EC_LPC_HOST_PACKET_SIZE]; + struct ec_response_typec_discovery *discovery = + (struct ec_response_typec_discovery *)response_buffer; + + connect_sink_to_port(&fixture->partner, fixture->tcpci_emul, + fixture->charger_emul); + + host_cmd_typec_discovery(TEST_PORT, TYPEC_PARTNER_SOP, response_buffer, + sizeof(response_buffer)); + + /* The host command does not count the VDM header in identity_count. */ + zassert_equal(discovery->identity_count, + fixture->partner.identity_vdos - 1, + "Expected %d identity VDOs, got %d", + fixture->partner.identity_vdos - 1, + discovery->identity_count); + zassert_mem_equal( + discovery->discovery_vdo, fixture->partner.identity_vdm + 1, + discovery->identity_count * sizeof(*discovery->discovery_vdo), + "Discovered SOP identity ACK did not match"); +} + +/* Without an e-marked cable, USB4 mode cannot be entered */ +ZTEST_F(usbc_usb4_mode, verify_usb4_entry_fail) +{ + struct ec_response_typec_status status; + + fixture->partner.cable = NULL; + connect_sink_to_port(&fixture->partner, fixture->tcpci_emul, + fixture->charger_emul); + + status = host_cmd_typec_status(TEST_PORT); + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x", + status.mux_state); + + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_USB4); + k_sleep(K_SECONDS(1)); + + /* + * TODO(b/260095516): Notify the AP that the enter mode request + * failed. + */ + + status = host_cmd_typec_status(TEST_PORT); + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB_ENABLED, "Failed to see USB still set"); + zassert_not_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB4_ENABLED, "Unexpected USB4 mode set"); +} + +/* With passive e-marked cable, USB4 mode can be entered on SOP only */ +ZTEST_F(usbc_usb4_mode, verify_usb4_passive_entry_exit) +{ + struct ec_response_typec_status status; + + fixture->partner.cable = &passive_usb4; + connect_sink_to_port(&fixture->partner, fixture->tcpci_emul, + fixture->charger_emul); + + /* Instruct partner port to accept Enter_USB message */ + fixture->partner.enter_usb_accept = true; + + /* Verify that we properly identify a USB4 capable passive cable */ + verify_cable_found(fixture->partner.cable); + + status = host_cmd_typec_status(TEST_PORT); + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x", + status.mux_state); + + host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_USB4); + k_sleep(K_SECONDS(2)); + + /* + * TODO(b/260095516): Notify the AP that the enter mode request + * succeeded. + */ + + /* Verify we entered USB4 mode */ + status = host_cmd_typec_status(TEST_PORT); + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB4_ENABLED, "Failed to see USB4 set"); + + /* Exit modes now */ + host_cmd_typec_control_exit_modes(TEST_PORT); + k_sleep(K_SECONDS(1)); + + /* Verify that USB4 mode was exited by checking current mux state. */ + status = host_cmd_typec_status(TEST_PORT); + zassert_equal((status.mux_state & USB_MUX_CHECK_MASK), + USB_PD_MUX_USB_ENABLED, "Failed to see USB set"); +} + +/* + * TODO(b/260095516): This test suite is only testing the default good case, and + * one error case where the cable doesn't support USB4. This suite needs to be + * expanded to cover cases where the port partner rejects Enter_USB along with + * active cable cases. + */ +ZTEST_SUITE(usbc_usb4_mode, drivers_predicate_post_main, usbc_usb4_mode_setup, + usbc_usb4_mode_before, usbc_usb4_mode_after, NULL); -- cgit v1.2.1 From da9a0ba6ada8efbadb14ceee5feef99891af1fdc Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Mon, 10 Oct 2022 12:09:21 -0700 Subject: tcpmv2: dpm: Split DPM_READY to DFP/UFP specific states This CL splits the ready state to be either DFP or UFP specific. The check for mode entry being done is moved into the DFP_READY state handler. BUG=b:194504052 BRANCH=none TEST=Verified that mode entry/exit is successful for DP, TBT, and USB4 on Voxel. ectool typeccontrol 0 -> exit mode ectool typeccontrol 2 0 -> DP ectool typeccontrol 2 1 -> TBT ectool typeccontrol 2 2 -> USB4 Signed-off-by: Scott Collyer Change-Id: I905a5c758cb5e5e71a86c54c1bace1e2f5e0da34 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3965268 Tested-by: Scott Collyer Reviewed-by: Abe Levkoy Commit-Queue: Scott Collyer Code-Coverage: Zoss --- common/usbc/usb_pd_dpm.c | 170 +++++++++++++++++++++++++++++------------------ 1 file changed, 106 insertions(+), 64 deletions(-) diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index b276dcbcad..0568f26db9 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -82,7 +82,8 @@ static struct { enum usb_dpm_state { /* Normal States */ DPM_WAITING, - DPM_READY, + DPM_DFP_READY, + DPM_UFP_READY, }; /* Forward declare the full list of states. This is indexed by usb_pd_state */ @@ -92,7 +93,8 @@ static const struct usb_state dpm_states[]; __maybe_unused static __const_data const char *const dpm_state_names[] = { /* Normal States */ [DPM_WAITING] = "DPM Waiting", - [DPM_READY] = "DPM Ready", + [DPM_DFP_READY] = "DPM DFP Ready", + [DPM_UFP_READY] = "DPM UFP Ready", }; static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT]; @@ -1013,8 +1015,10 @@ uint8_t pd_get_bist_share_mode(void) * sequence. This only happens if preconditions for mode entry are met. If * CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY is enabled, this function waits for the * AP to direct mode entry. + * + * Returns true when the DPM state is changed in this function. */ -static void dpm_dfp_enter_mode_msg(int port) +static bool dpm_dfp_enter_mode_msg(int port) { int vdo_count = 0; uint32_t vdm[VDO_MAX_SIZE]; @@ -1023,19 +1027,6 @@ static void dpm_dfp_enter_mode_msg(int port) IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true; enum dpm_msg_setup_status status = MSG_SETUP_UNSUPPORTED; - if (pd_get_data_role(port) != PD_ROLE_DFP) { - if (DPM_CHK_FLAG(port, DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT | - DPM_FLAG_ENTER_USB4)) - DPM_CLR_FLAG(port, DPM_FLAG_ENTER_DP | - DPM_FLAG_ENTER_TBT | - DPM_FLAG_ENTER_USB4); - /* - * TODO(b/168030639): Notify the AP that the enter mode request - * failed. - */ - return; - } - #ifdef CONFIG_AP_POWER_CONTROL /* * Do not try to enter mode while CPU is off. @@ -1045,7 +1036,7 @@ static void dpm_dfp_enter_mode_msg(int port) * enter the mode to fail prematurely. */ if (!chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON)) - return; + return false; #endif /* * If discovery has not occurred for modes, do not attempt to switch @@ -1053,24 +1044,16 @@ static void dpm_dfp_enter_mode_msg(int port) */ if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE || pd_get_modes_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE) - return; + return false; if (dp_entry_is_done(port) || (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && tbt_entry_is_done(port)) || (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port))) { dpm_set_mode_entry_done(port); - return; + return false; } - /* - * If muxes are still settling, then wait on our next VDM. We must - * ensure we correctly sequence actions such as USB safe state with TBT - * entry or DP configuration. - */ - if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port)) - return; - if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) && IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY) && @@ -1078,13 +1061,13 @@ static void dpm_dfp_enter_mode_msg(int port) !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { pd_dpm_request(port, DPM_REQUEST_DATA_RESET); DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); - return; + return false; } if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) && IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - return; + return false; } /* Check if port, port partner and cable support USB4. */ @@ -1102,7 +1085,7 @@ static void dpm_dfp_enter_mode_msg(int port) &tx_type); } else { pd_dpm_request(port, DPM_REQUEST_ENTER_USB); - return; + return false; } } @@ -1130,7 +1113,7 @@ static void dpm_dfp_enter_mode_msg(int port) /* Not ready to send a VDM, check again next cycle */ if (status == MSG_SETUP_MUX_WAIT) - return; + return false; /* * If the PE didn't discover any supported (requested) alternate mode, @@ -1150,13 +1133,13 @@ static void dpm_dfp_enter_mode_msg(int port) * future, but the DPM is done trying for now. */ dpm_set_mode_entry_done(port); - return; + return false; } if (status != MSG_SETUP_SUCCESS) { dpm_set_mode_entry_done(port); CPRINTS("C%d: Couldn't construct alt mode VDM", port); - return; + return false; } /* @@ -1165,13 +1148,22 @@ static void dpm_dfp_enter_mode_msg(int port) */ if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) { dpm_set_mode_entry_done(port); - return; + return false; } + /* Wait for PE to handle VDM request */ pd_dpm_request(port, DPM_REQUEST_VDM); + set_state_dpm(port, DPM_WAITING); + + return true; } -static void dpm_dfp_exit_mode_msg(int port) +/* + * Checks to see if either USB4 or ALT-DP/TBT modes need to be exited. If the + * DPM is requesting the PE to send an exit message, then this function will + * return true to indicate that the DPM state has been changed. + */ +static bool dpm_dfp_exit_mode_msg(int port) { uint32_t vdm[VDO_MAX_SIZE]; int vdo_count = ARRAY_SIZE(vdm); @@ -1187,9 +1179,9 @@ static void dpm_dfp_exit_mode_msg(int port) !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { pd_dpm_request(port, DPM_REQUEST_DATA_RESET); DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); - return; + return false; } else if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - return; + return false; } } @@ -1201,14 +1193,6 @@ static void dpm_dfp_exit_mode_msg(int port) usb4_exit_mode_request(port); } - /* - * If muxes are still settling, then wait on our next VDM. We must - * ensure we correctly sequence actions such as USB safe state with TBT - * or DP mode exit. - */ - if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port)) - return; - if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && tbt_is_active(port)) { /* * When the port is in USB4 mode and receives an exit request, @@ -1223,19 +1207,22 @@ static void dpm_dfp_exit_mode_msg(int port) } else { /* Clear exit mode request */ dpm_clear_mode_exit_request(port); - return; + return false; } /* This covers error, wait mux, and unsupported cases */ if (status != MSG_SETUP_SUCCESS) - return; + return false; if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) { dpm_clear_mode_exit_request(port); - return; + return false; } pd_dpm_request(port, DPM_REQUEST_VDM); + set_state_dpm(port, DPM_WAITING); + + return true; } void dpm_run(int port, int evt, int en) @@ -1278,40 +1265,91 @@ static void dpm_waiting_entry(const int port) static void dpm_waiting_run(const int port) { + enum pd_data_role dr = pd_get_data_role(port); + if (DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) { - set_state_dpm(port, DPM_READY); + if (dr == PD_ROLE_UFP) { + set_state_dpm(port, DPM_UFP_READY); + } else if (dr == PD_ROLE_DFP) { + set_state_dpm(port, DPM_DFP_READY); + } } } /* - * DPM_READY + * DPM_DFP_READY */ -static void dpm_ready_entry(const int port) +static void dpm_dfp_ready_entry(const int port) { print_current_state(port); } -static void dpm_ready_run(const int port) +static void dpm_dfp_ready_run(const int port) { if (!DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) { set_state_dpm(port, DPM_WAITING); return; } - if (pd_get_data_role(port) == PD_ROLE_DFP) { - /* Run DFP related DPM requests */ - if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST)) - dpm_dfp_exit_mode_msg(port); - else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) - dpm_dfp_enter_mode_msg(port); + /* Run power button state machine */ + dpm_run_pd_button_sm(port); - /* Run USB PD Power button state machine */ - dpm_run_pd_button_sm(port); + /* + * If muxes are still settling, then wait on our next VDM. We must + * ensure we correctly sequence actions such as USB safe state with TBT + * or DP mode exit. + */ + if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port)) + return; + + /* Run DFP related DPM requests */ + if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST)) { + if (dpm_dfp_exit_mode_msg(port)) + return; + } else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) { + if (dpm_dfp_enter_mode_msg(port)) + return; } /* Run any VDM REQ messages */ - if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ)) + if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ)) { dpm_send_req_vdm(port); + set_state_dpm(port, DPM_WAITING); + return; + } +} + +/* + * DPM_UFP_READY + */ +static void dpm_ufp_ready_entry(const int port) +{ + print_current_state(port); +} + +static void dpm_ufp_ready_run(const int port) +{ + if (!DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) { + set_state_dpm(port, DPM_WAITING); + return; + } + + if (DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY)) { + DPM_CLR_FLAG(port, DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT | + DPM_FLAG_ENTER_USB4); + /* + * TODO(b/168030639): Notify the AP that the + * enter mode request failed. + */ + return; + } + + /* Run any VDM REQ messages */ + if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ)) { + dpm_send_req_vdm(port); + set_state_dpm(port, DPM_WAITING); + return; + } } static __const_data const struct usb_state dpm_states[] = { @@ -1320,8 +1358,12 @@ static __const_data const struct usb_state dpm_states[] = { .entry = dpm_waiting_entry, .run = dpm_waiting_run, }, - [DPM_READY] = { - .entry = dpm_ready_entry, - .run = dpm_ready_run, + [DPM_DFP_READY] = { + .entry = dpm_dfp_ready_entry, + .run = dpm_dfp_ready_run, + }, + [DPM_UFP_READY] = { + .entry = dpm_ufp_ready_entry, + .run = dpm_ufp_ready_run, }, }; -- cgit v1.2.1 From 1497d466220fc32f5d857883c4902a43c394059c Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Tue, 29 Nov 2022 09:45:20 +1100 Subject: host_command_pd: remove ad-hoc charge current manipulation Recent changes make board_set_charge_limit the correct place to apply adjustments like the existing minimum current limit done here, so change this host command to simply call that function. Most other code that used this pattern was converted in commits b75dc90677f29424e6f0d63f294dce4b39782135 and 43b53e004573a56a255ca57d4a6d04ac4bed44d7, but this one was missed. BUG=b:163093572 TEST=make buildall, zmake build -a BRANCH=none Change-Id: I29d3dd332aa748afdee8fa3c4da53ccab85e3fd1 Signed-off-by: Peter Marheine Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4060434 Reviewed-by: Keith Short Code-Coverage: Zoss --- common/host_command_pd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/common/host_command_pd.c b/common/host_command_pd.c index 23e2710695..e7dbbc2b5f 100644 --- a/common/host_command_pd.c +++ b/common/host_command_pd.c @@ -126,10 +126,7 @@ static void pd_check_chg_status(struct ec_response_pd_status *pd_status) #endif /* Set input current limit */ - rv = charge_set_input_current_limit( - MAX(pd_status->curr_lim_ma, CONFIG_CHARGER_INPUT_CURRENT), 0); - if (rv < 0) - CPRINTS("Failed to set input curr limit from PD MCU"); + board_set_charge_limit(pd_status->curr_lim_ma, 0); } #endif /* CONFIG_HOSTCMD_PD_CHG_CTRL */ #endif /* CONFIG_HOSTCMD_PD */ -- cgit v1.2.1 From 57b32569630025bea009a13fc46d1354debe3fdc Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Mon, 14 Nov 2022 13:13:50 +1100 Subject: Rename CONFIG_CHARGER_INPUT_CURRENT to _CHARGER_DEFAULT_CURRENT_LIMIT "Default input current" is not a very clear name, so rename this option to better express its use as a default value that is set in the charger. This is made possible by splitting other uses into CHARGER_MIN_INPUT_CURRENT_LIMIT, making the only use for CHARGER_INPUT_CURRENT be as a default. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none LOW_COVERAGE_REASON=isl9241 and sm5803 currently lack emulators Signed-off-by: Peter Marheine Change-Id: Ia9c1df9061825b15477466e85343afeb2a371288 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025404 Code-Coverage: Zoss Reviewed-by: Keith Short --- baseboard/asurada/baseboard.h | 2 +- baseboard/brya/baseboard.h | 2 +- baseboard/cherry/baseboard.h | 2 +- baseboard/dedede/baseboard.h | 2 +- baseboard/goroh/baseboard.h | 2 +- baseboard/grunt/baseboard.h | 2 +- baseboard/guybrush/baseboard.h | 2 +- baseboard/hatch/baseboard.h | 3 ++- baseboard/herobrine/baseboard.h | 2 +- baseboard/intelrvp/baseboard.h | 2 +- baseboard/kukui/baseboard.h | 2 +- baseboard/kukui/charger_mt6370.c | 3 ++- baseboard/octopus/baseboard.h | 3 ++- baseboard/trogdor/baseboard.h | 2 +- baseboard/volteer/baseboard.h | 2 +- baseboard/zork/baseboard.h | 2 +- board/atlas/board.h | 2 +- board/casta/board.c | 3 ++- board/coral/board.h | 2 +- board/elm/board.h | 2 +- board/eve/board.h | 2 +- board/hammer/board.h | 2 +- board/host/charger.c | 3 ++- board/mchpevb1/board.h | 2 +- board/nami/board.h | 2 +- board/nautilus/board.h | 2 +- board/nocturne/board.h | 2 +- board/oak/board.h | 2 +- board/poppy/board.h | 2 +- board/rammus/board.h | 2 +- board/reef/board.h | 2 +- board/reef_it8320/board.h | 2 +- board/reef_mchp/board.h | 2 +- board/scarlet/board.h | 2 +- common/charge_manager.c | 4 ++-- common/charge_state_v2.c | 4 ++-- common/ec_ec_comm_server.c | 5 +++-- docs/low_battery_startup.md | 24 +++++++++++----------- driver/charger/bd9995x.c | 11 +++++----- driver/charger/bq24715.c | 4 ++-- driver/charger/isl923x.c | 2 +- driver/charger/isl9241.c | 4 ++-- driver/charger/sm5803.c | 2 +- include/config.h | 9 ++++---- test/test_config.h | 4 ++-- zephyr/Kconfig.usbc | 10 ++++----- zephyr/program/rex/prj.conf | 2 +- zephyr/program/skyrim/prj.conf | 2 +- zephyr/shim/include/config_chip.h | 7 ++++--- .../test/drivers/bc12_pi3usb9201/src/pi3usb9201.c | 4 ++-- .../common_charger/src/test_common_charger.c | 2 +- .../src/integration/usbc/usb_20v_3a_pd_charger.c | 4 ++-- .../src/integration/usbc/usb_5v_3a_pd_sink.c | 4 ++-- .../src/integration/usbc/usb_5v_3a_pd_source.c | 4 ++-- zephyr/test/drivers/default/src/isl923x.c | 4 ++-- 55 files changed, 99 insertions(+), 90 deletions(-) diff --git a/baseboard/asurada/baseboard.h b/baseboard/asurada/baseboard.h index 597515363c..a8b62ccf59 100644 --- a/baseboard/asurada/baseboard.h +++ b/baseboard/asurada/baseboard.h @@ -60,7 +60,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9238C #define CONFIG_CHARGER_MAINTAIN_VBAT diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h index b2d722fcd9..b4ba8f2d16 100644 --- a/baseboard/brya/baseboard.h +++ b/baseboard/brya/baseboard.h @@ -68,7 +68,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CMD_CHARGER_DUMP diff --git a/baseboard/cherry/baseboard.h b/baseboard/cherry/baseboard.h index 8cd2aacd1f..cfc1425d57 100644 --- a/baseboard/cherry/baseboard.h +++ b/baseboard/cherry/baseboard.h @@ -70,7 +70,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9238C #define CONFIG_CHARGER_MAINTAIN_VBAT diff --git a/baseboard/dedede/baseboard.h b/baseboard/dedede/baseboard.h index e03d41ae21..ba83b44375 100644 --- a/baseboard/dedede/baseboard.h +++ b/baseboard/dedede/baseboard.h @@ -164,7 +164,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 256 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 256 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 256 #define CONFIG_USB_CHARGER #define CONFIG_TRICKLE_CHARGING diff --git a/baseboard/goroh/baseboard.h b/baseboard/goroh/baseboard.h index 205621e040..594686f0bf 100644 --- a/baseboard/goroh/baseboard.h +++ b/baseboard/goroh/baseboard.h @@ -57,7 +57,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9238C #define CONFIG_CHARGER_MAINTAIN_VBAT diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h index b9ddd32861..bdbec1e0d2 100644 --- a/baseboard/grunt/baseboard.h +++ b/baseboard/grunt/baseboard.h @@ -72,7 +72,7 @@ * * See also b/111214767 */ -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_ISL9238 diff --git a/baseboard/guybrush/baseboard.h b/baseboard/guybrush/baseboard.h index 883bf27847..e5223abfbe 100644 --- a/baseboard/guybrush/baseboard.h +++ b/baseboard/guybrush/baseboard.h @@ -162,7 +162,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9241 #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h index 9ba148e91e..4aee5200de 100644 --- a/baseboard/hatch/baseboard.h +++ b/baseboard/hatch/baseboard.h @@ -96,7 +96,8 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_BQ25710 #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */ +/* Allow low-current USB charging */ +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 diff --git a/baseboard/herobrine/baseboard.h b/baseboard/herobrine/baseboard.h index b1aabc6bd6..72b8b02b04 100644 --- a/baseboard/herobrine/baseboard.h +++ b/baseboard/herobrine/baseboard.h @@ -88,7 +88,7 @@ #define CONFIG_CHARGER_PSYS_READ #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000 #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/baseboard/intelrvp/baseboard.h b/baseboard/intelrvp/baseboard.h index 96acf8c562..e47434c4af 100644 --- a/baseboard/intelrvp/baseboard.h +++ b/baseboard/intelrvp/baseboard.h @@ -68,7 +68,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_SENSE_RESISTOR 5 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h index 4a5562fb04..6cb18b0d4e 100644 --- a/baseboard/kukui/baseboard.h +++ b/baseboard/kukui/baseboard.h @@ -196,7 +196,7 @@ #define CONFIG_VBOOT_HASH #define CONFIG_CHARGER -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000 #define CONFIG_CHARGER_DISCHARGE_ON_AC diff --git a/baseboard/kukui/charger_mt6370.c b/baseboard/kukui/charger_mt6370.c index eb94397fdb..80587745ea 100644 --- a/baseboard/kukui/charger_mt6370.c +++ b/baseboard/kukui/charger_mt6370.c @@ -77,7 +77,8 @@ int board_cut_off_battery(void) static void board_set_charge_limit_throttle(int charge_ma, int charge_mv) { charge_set_input_current_limit( - MIN(throttled_ma, MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT)), + MIN(throttled_ma, + MAX(charge_ma, CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT)), charge_mv); } diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h index 9c6e2a14e6..42093ab771 100644 --- a/baseboard/octopus/baseboard.h +++ b/baseboard/octopus/baseboard.h @@ -154,7 +154,8 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER -#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */ +/* Allow low-current USB charging */ +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_DISCHARGE_ON_AC diff --git a/baseboard/trogdor/baseboard.h b/baseboard/trogdor/baseboard.h index 901466fec1..28cf467272 100644 --- a/baseboard/trogdor/baseboard.h +++ b/baseboard/trogdor/baseboard.h @@ -92,7 +92,7 @@ #define CONFIG_CHARGER_PSYS_READ #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000 #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h index 4df7d5fc73..d3c82f0651 100644 --- a/baseboard/volteer/baseboard.h +++ b/baseboard/volteer/baseboard.h @@ -107,7 +107,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 /* diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h index 5af8f254a0..c55ca12c76 100644 --- a/baseboard/zork/baseboard.h +++ b/baseboard/zork/baseboard.h @@ -76,7 +76,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_ISL9241 #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/board/atlas/board.h b/board/atlas/board.h index f5cef8d582..3dbce640bb 100644 --- a/board/atlas/board.h +++ b/board/atlas/board.h @@ -77,7 +77,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_PROFILE_OVERRIDE diff --git a/board/casta/board.c b/board/casta/board.c index 512a7c224b..2ae65c7d86 100644 --- a/board/casta/board.c +++ b/board/casta/board.c @@ -172,7 +172,8 @@ static void set_input_limit_on_ac_removal(void) if (get_cbi_ssfc_charger() != SSFC_CHARGER_BQ25710) return; - charger_set_input_current_limit(0, CONFIG_CHARGER_INPUT_CURRENT); + charger_set_input_current_limit(0, + CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT); } DECLARE_HOOK(HOOK_AC_CHANGE, set_input_limit_on_ac_removal, HOOK_PRIO_DEFAULT); diff --git a/board/coral/board.h b/board/coral/board.h index 9b45db2cf3..cea83ef4a5 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -60,7 +60,7 @@ #define CONFIG_CHARGER_BD9995X #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MAINTAIN_VBAT #undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON diff --git a/board/elm/board.h b/board/elm/board.h index ba542754b5..6e4e705604 100644 --- a/board/elm/board.h +++ b/board/elm/board.h @@ -37,7 +37,7 @@ #define CONFIG_BATTERY_SMART #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGE_RAMP_HW #define CONFIG_CHARGER_ISL9237 diff --git a/board/eve/board.h b/board/eve/board.h index b9de20896d..e3623979c3 100644 --- a/board/eve/board.h +++ b/board/eve/board.h @@ -100,7 +100,7 @@ #define CONFIG_CHARGER_BD9995X #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_MAINTAIN_VBAT diff --git a/board/hammer/board.h b/board/hammer/board.h index ac6131798b..dd4b337c66 100644 --- a/board/hammer/board.h +++ b/board/hammer/board.h @@ -269,7 +269,7 @@ #ifdef BOARD_WAND /* Battery and charger options. */ #define CONFIG_CHARGER -#define CONFIG_CHARGER_INPUT_CURRENT 128 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 128 #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/board/host/charger.c b/board/host/charger.c index fddadf245d..0580ddcb41 100644 --- a/board/host/charger.c +++ b/board/host/charger.c @@ -136,7 +136,8 @@ static enum ec_error_list mock_set_input_current_limit(int chgnum, int current) static enum ec_error_list mock_post_init(int chgnum) { - mock_current = mock_input_current = CONFIG_CHARGER_INPUT_CURRENT; + mock_current = mock_input_current = + CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT; return EC_SUCCESS; } diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h index ae8982f939..dd7c87fd6f 100644 --- a/board/mchpevb1/board.h +++ b/board/mchpevb1/board.h @@ -150,7 +150,7 @@ /* #define CONFIG_CHARGER_DISCHARGE_ON_AC */ /* #define CONFIG_CHARGER_ISL9237 */ /* #define CONFIG_CHARGER_ILIM_PIN_DISABLED */ -/* #define CONFIG_CHARGER_INPUT_CURRENT 512 */ +/* #define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 */ /* #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 */ /* #define CONFIG_CHARGER_NARROW_VDC */ diff --git a/board/nami/board.h b/board/nami/board.h index 1a71e83c4f..652db4826d 100644 --- a/board/nami/board.h +++ b/board/nami/board.h @@ -96,7 +96,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 27000 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000 diff --git a/board/nautilus/board.h b/board/nautilus/board.h index 882b5d74f4..2b4f25538d 100644 --- a/board/nautilus/board.h +++ b/board/nautilus/board.h @@ -79,7 +79,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGER_PSYS diff --git a/board/nocturne/board.h b/board/nocturne/board.h index 828c9a2087..73700b8480 100644 --- a/board/nocturne/board.h +++ b/board/nocturne/board.h @@ -70,7 +70,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 128 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 128 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 128 #define CONFIG_CHARGER_ISL9238 /* diff --git a/board/oak/board.h b/board/oak/board.h index ca9e16cf23..c429a655c5 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -40,7 +40,7 @@ #define CONFIG_CHARGE_MANAGER #define CONFIG_CHARGER -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #if BOARD_REV == OAK_REV1 diff --git a/board/poppy/board.h b/board/poppy/board.h index c06f96c438..5242c1d3a8 100644 --- a/board/poppy/board.h +++ b/board/poppy/board.h @@ -89,7 +89,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 472 #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/board/rammus/board.h b/board/rammus/board.h index 2de783e247..975417df9a 100644 --- a/board/rammus/board.h +++ b/board/rammus/board.h @@ -84,7 +84,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_ISL9238 #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_SENSE_RESISTOR 10 diff --git a/board/reef/board.h b/board/reef/board.h index 16f40c2f4a..cc1783e43a 100644 --- a/board/reef/board.h +++ b/board/reef/board.h @@ -50,7 +50,7 @@ #define CONFIG_CHARGER_BD9995X #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h index 558b10152a..dbccc6eeee 100644 --- a/board/reef_it8320/board.h +++ b/board/reef_it8320/board.h @@ -48,7 +48,7 @@ #define CONFIG_CHARGER_BD9995X #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h index d570f50142..925f271ffd 100644 --- a/board/reef_mchp/board.h +++ b/board/reef_mchp/board.h @@ -53,7 +53,7 @@ #define CONFIG_CHARGER_BD9995X #define CONFIG_CHARGER_BD9995X_CHGEN #define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 diff --git a/board/scarlet/board.h b/board/scarlet/board.h index aba5819516..cdc09f9114 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -69,7 +69,7 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_RT9467 -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000 diff --git a/common/charge_manager.c b/common/charge_manager.c index 683daaccf6..703b8933db 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -835,8 +835,8 @@ static void charge_manager_refresh(void) override_port = OVERRIDE_OFF; if (new_supplier == CHARGE_SUPPLIER_NONE) { -#ifdef CONFIG_CHARGER_INPUT_CURRENT - new_charge_current = CONFIG_CHARGER_INPUT_CURRENT; +#ifdef CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT + new_charge_current = CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT; #else new_charge_current = 0; #endif diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 1e1353a639..05c06cd77e 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -1507,9 +1507,9 @@ static int get_desired_input_current(enum battery_present batt_present, int ilim = charge_manager_get_charger_current(); return ilim == CHARGE_CURRENT_UNINITIALIZED ? CHARGE_CURRENT_UNINITIALIZED : - MAX(CONFIG_CHARGER_INPUT_CURRENT, ilim); + MAX(CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT, ilim); #else - return CONFIG_CHARGER_INPUT_CURRENT; + return CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT; #endif } else { #ifdef CONFIG_USB_POWER_DELIVERY diff --git a/common/ec_ec_comm_server.c b/common/ec_ec_comm_server.c index 6f37004513..976c3d6996 100644 --- a/common/ec_ec_comm_server.c +++ b/common/ec_ec_comm_server.c @@ -169,8 +169,9 @@ handle_cmd_charger_control(const struct ec_params_charger_control *params, goto out; } - /* Reset input current to minimum. */ - charge_set_input_current_limit(CONFIG_CHARGER_INPUT_CURRENT, 0); + /* Reset input current to default. */ + charge_set_input_current_limit( + CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT, 0); /* Setup and enable "OTG". */ charge_set_output_current_limit(CHARGER_SOLO, -params->max_current, diff --git a/docs/low_battery_startup.md b/docs/low_battery_startup.md index 83aae054b5..1f94d4956e 100644 --- a/docs/low_battery_startup.md +++ b/docs/low_battery_startup.md @@ -168,7 +168,7 @@ is robust enough to support the device during brief intervals of PD negotiation without browning out. ``` -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 ``` @@ -205,7 +205,7 @@ the kernel and get to the login screen. ``` /* Limit battery impact during PD voltage changes. */ -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 /* Distrust the battery SOC measurement a bit. */ #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3 @@ -256,7 +256,7 @@ less. Very briefly drawing current out of the battery does not cause a brownout. Example configuration: ``` -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15000 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 27000 @@ -300,7 +300,7 @@ performing a no-battery boot. Nami is an exemplar. Example configuration: ``` -#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1 #define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000 @@ -336,7 +336,7 @@ Example configuration: ## Configuration Option Details -### `CONFIG_CHARGER_INPUT_CURRENT` +### `CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT` Required. @@ -350,13 +350,13 @@ in order to improve compatibility with marginal BC1.2 chargers. Optional. If set, charger input current limits will never be set lower than this value. -Historically most boards used the same value as `CONFIG_CHARGER_INPUT_CURRENT`, -but doing so violates USB-PD standby power requirements when voltages greater -than 5V are used with the default 512 mA value. Configuring this option to a -nonzero value may be useful if a board needs extra headroom (possibly at the -cost of drawing excess standby power), but boards should prefer to -override `board_set_charge_limit()` instead to limit situations with excess -power draw to only occur when that extra power is needed. +Historically most boards used the same value +as `CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT`, but doing so violates USB-PD standby +power requirements when voltages greater than 5V are used with the default 512 +mA value. Configuring this option to a nonzero value may be useful if a board +needs extra headroom (possibly at the cost of drawing excess standby power), but +boards should prefer to override `board_set_charge_limit()` instead to limit +situations with excess power draw to only occur when that extra power is needed. ### `CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON` diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c index aa37bf4e8a..f7e4ffacaa 100644 --- a/driver/charger/bd9995x.c +++ b/driver/charger/bd9995x.c @@ -904,7 +904,8 @@ static void bd9995x_battery_charging_profile_settings(int chgnum) const struct battery_info *bi = battery_get_info(); /* Input Current Limit Setting */ - bd9995x_set_input_current_limit(chgnum, CONFIG_CHARGER_INPUT_CURRENT); + bd9995x_set_input_current_limit(chgnum, + CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT); /* Charge Termination Current Setting */ ch_raw_write16(chgnum, BD9995X_CMD_ITERM_SET, 0, @@ -1004,10 +1005,10 @@ static void bd9995x_init(void) * Disable the input current limit when VBAT is < VSYSREG_SET. This * needs to be done before calling * bd9995x_battery_charging_profile_settings() as in that function the - * input current limit is set to CONFIG_CHARGER_INPUT_CURRENT which is - * 512 mA. In deeply discharged battery cases, setting the input current - * limit this low can cause VSYS to collapse, which in turn can cause - * the EC's brownout detector to reset the EC. + * input current limit is set to CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT + * which is 512 mA. In deeply discharged battery cases, setting the + * input current limit this low can cause VSYS to collapse, which in + * turn can cause the EC's brownout detector to reset the EC. */ if (ch_raw_read16(CHARGER_SOLO, BD9995X_CMD_VIN_CTRL_SET, ®, BD9995X_EXTENDED_COMMAND)) diff --git a/driver/charger/bq24715.c b/driver/charger/bq24715.c index 8e8e0efd50..0847618f3c 100644 --- a/driver/charger/bq24715.c +++ b/driver/charger/bq24715.c @@ -207,8 +207,8 @@ static enum ec_error_list bq24715_post_init(int chgnum) if (rv) return rv; - rv = bq24715_set_input_current_limit(chgnum, - CONFIG_CHARGER_INPUT_CURRENT); + rv = bq24715_set_input_current_limit( + chgnum, CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT); return rv; } diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index 04db73353a..17798b113d 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -772,7 +772,7 @@ static void isl923x_init(int chgnum) * Initialize the input current limit to the board's default. */ if (isl923x_set_input_current_limit( - chgnum, CONFIG_CHARGER_INPUT_CURRENT)) + chgnum, CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT)) goto init_fail; } diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c index 9ca2e9f3e0..6ff0db26e9 100644 --- a/driver/charger/isl9241.c +++ b/driver/charger/isl9241.c @@ -893,8 +893,8 @@ static void isl9241_init(int chgnum) return; /* Initialize the input current limit to the board's default. */ - if (isl9241_set_input_current_limit(chgnum, - CONFIG_CHARGER_INPUT_CURRENT)) + if (isl9241_set_input_current_limit( + chgnum, CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT)) goto init_fail; return; diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c index f6d4e60eec..a64e541f6b 100644 --- a/driver/charger/sm5803.c +++ b/driver/charger/sm5803.c @@ -712,7 +712,7 @@ static void sm5803_init(int chgnum) rv |= chg_write8(chgnum, SM5803_REG_DPM_VL_SET_LSB, (reg & 0x7)); /* Set default input current */ - reg = SM5803_CURRENT_TO_REG(CONFIG_CHARGER_INPUT_CURRENT) & + reg = SM5803_CURRENT_TO_REG(CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT) & SM5803_CHG_ILIM_RAW; rv |= chg_write8(chgnum, SM5803_REG_CHG_ILIM, reg); diff --git a/include/config.h b/include/config.h index a9a346c464..8d78921cde 100644 --- a/include/config.h +++ b/include/config.h @@ -1033,14 +1033,15 @@ #undef CONFIG_CHARGER_ILIM_PIN_DISABLED /* - * Default input current for the board, in mA. + * Default input current for the board, in mA. Many boards also use this as the + * least maximum input current during transients. * * This value should depend on external power adapter, designed charging * voltage, and the maximum power of the running system. For type-C chargers, * this should be set to 512 mA in order to not brown-out low-current USB * charge ports in accordance with USB-PD r3.0 Sec. 7.3 */ -#undef CONFIG_CHARGER_INPUT_CURRENT +#undef CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT /* * Minimum current limit that will ever be set for chargers, even if a lower @@ -1053,8 +1054,8 @@ * conditions at the cost of violating standby power limits. * * Many boards set this to large values, since historically this number was - * usually equal to CONFIG_CHARGER_INPUT_CURRENT. New boards should avoid doing - * so if possible. + * usually equal to CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT. New boards should + * avoid doing so if possible. */ #undef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT diff --git a/test/test_config.h b/test/test_config.h index a25d8c0845..704c3b42c1 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -305,7 +305,7 @@ enum sensor_id { #define CONFIG_BATTERY_SMART #define CONFIG_CHARGER #define CONFIG_CHARGER_PROFILE_OVERRIDE -#define CONFIG_CHARGER_INPUT_CURRENT 4032 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 4032 #define CONFIG_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM #define CONFIG_I2C @@ -346,7 +346,7 @@ int ncp15wb_calculate_temp(uint16_t adc); #ifdef TEST_BATTERY_GET_PARAMS_SMART #define CONFIG_BATTERY_MOCK #define CONFIG_BATTERY_SMART -#define CONFIG_CHARGER_INPUT_CURRENT 4032 +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 4032 #define CONFIG_I2C #define CONFIG_I2C_CONTROLLER #define I2C_PORT_MASTER 0 diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc index 7f65419a4b..082f96ca7f 100644 --- a/zephyr/Kconfig.usbc +++ b/zephyr/Kconfig.usbc @@ -31,18 +31,18 @@ rsource "Kconfig.usb_charger" if PLATFORM_EC_USBC -config PLATFORM_EC_CHARGER_INPUT_CURRENT +config PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT int "Charger input current in mA" depends on PLATFORM_EC_CHARGE_MANAGER default 512 help - This is the default input current for the board in mA. Many boards - also use this as the least maximum input current during transients. + Default input current limit for the board in mA. This value should depend on external power adapter, designed charging voltage, and the maximum power of the running system. For type-C - chargers, this should be set to 512 mA in order to not brown-out - low-current USB charge ports in accordance with USB-PD r3.0 Sec. 7.3 + chargers, this should be set to no more than 512 mA in order to not + brown-out low-current USB charge ports in accordance with USB-PD r3.0 + Sec. 7.3. config PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT int "Minimum charger input current limit in mA" diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf index 8b783e30f7..221f1e712b 100644 --- a/zephyr/program/rex/prj.conf +++ b/zephyr/program/rex/prj.conf @@ -71,7 +71,7 @@ CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y # Charger CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512 +CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=512 CONFIG_PLATFORM_EC_CHARGER_ISL9241=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5 CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10 diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf index 0c90952ceb..e879e1153b 100644 --- a/zephyr/program/skyrim/prj.conf +++ b/zephyr/program/skyrim/prj.conf @@ -69,7 +69,7 @@ CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y # Charger CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512 +CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=512 CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 CONFIG_PLATFORM_EC_CHARGER_ISL9241=y CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index c0d388b60b..28a93739c5 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1078,9 +1078,10 @@ extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE]; CONFIG_PLATFORM_EC_CHARGESPLASH_MAX_REQUESTS_PER_PERIOD #endif -#undef CONFIG_CHARGER_INPUT_CURRENT -#ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT -#define CONFIG_CHARGER_INPUT_CURRENT CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT +#undef CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT +#ifdef CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT +#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT \ + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT #endif #undef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c index a384fb1e0a..0f9e7cbbeb 100644 --- a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c +++ b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c @@ -75,7 +75,7 @@ static const struct bc12_status bc12_chg_limits[] = { [CHG_RESERVED] = { .supplier = CHARGE_SUPPLIER_NONE, /* Not charging, limit is set to default */ .current_limit = - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT }, + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT }, [CHG_CDP] = { .supplier = CHARGE_SUPPLIER_BC12_CDP, .current_limit = USB_CHARGER_MAX_CURR_MA }, [CHG_SDP] = { .supplier = CHARGE_SUPPLIER_BC12_SDP, @@ -212,7 +212,7 @@ test_bc12_pi3usb9201_client_mode(enum pi3usb9201_client_sts detect_result, zassert_equal(charge_manager_get_supplier(), CHARGE_SUPPLIER_NONE, NULL); zassert_equal(charge_manager_get_charger_current(), - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT); + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT); zassert_equal(charge_manager_get_charger_voltage(), 0); } diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger.c b/zephyr/test/drivers/common_charger/src/test_common_charger.c index eb7d6f1f08..46403636d6 100644 --- a/zephyr/test/drivers/common_charger/src/test_common_charger.c +++ b/zephyr/test/drivers/common_charger/src/test_common_charger.c @@ -50,7 +50,7 @@ ZTEST(common_charger, test_chg_ramp_is_detected) ZTEST(common_charger, test_chg_ramp_get_current_limit) { zassert_equal(chg_ramp_get_current_limit(), - CONFIG_CHARGER_INPUT_CURRENT); + CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT); } ZTEST(common_charger, test_charger_get_min_bat_pct_for_power_on) diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c b/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c index 10ade25222..f2afa5be9a 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c @@ -176,9 +176,9 @@ ZTEST_F(usb_attach_20v_3a_pd_charger, test_disconnect_charge_state) "Max charge current expected 0mA, but was %dmA", charge_state.get_state.chg_current); zassert_equal(charge_state.get_state.chg_input_current, - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT, + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT, "Charge input current limit expected %dmA, but was %dmA", - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT, + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT, charge_state.get_state.chg_input_current); } diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c index 218ef9550e..6795e72c11 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c @@ -159,9 +159,9 @@ ZTEST_F(usb_attach_5v_3a_pd_sink, test_disconnect_charge_state) "Max charge current expected 0mA, but was %dmA", charge_state.get_state.chg_current); zassert_equal(charge_state.get_state.chg_input_current, - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT, + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT, "Charge input current limit expected %dmA, but was %dmA", - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT, + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT, charge_state.get_state.chg_input_current); } diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c index 325b8aee8c..c57054881d 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c @@ -172,9 +172,9 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_disconnect_charge_state) "Max charge current expected 0mA, but was %dmA", charge_state.get_state.chg_current); zassert_equal(charge_state.get_state.chg_input_current, - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT, + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT, "Charge input current limit expected %dmA, but was %dmA", - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT, + CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT, charge_state.get_state.chg_input_current); } diff --git a/zephyr/test/drivers/default/src/isl923x.c b/zephyr/test/drivers/default/src/isl923x.c index 72aad72cd9..1393466c76 100644 --- a/zephyr/test/drivers/default/src/isl923x.c +++ b/zephyr/test/drivers/default/src/isl923x.c @@ -681,9 +681,9 @@ ZTEST(isl923x, test_init_late_jump) isl923x_drv.get_input_current_limit(CHARGER_NUM, &input_current), "Could not read input current limit."); - zassert_equal(CONFIG_CHARGER_INPUT_CURRENT, input_current, + zassert_equal(CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT, input_current, "Input current (%d) not at (%d)", input_current, - CONFIG_CHARGER_INPUT_CURRENT); + CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT); } ZTEST(isl923x, test_isl923x_is_acok) -- cgit v1.2.1 From 129e85727d7174e9ff7af6cc2413399ec5ee906e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 11 Nov 2022 14:05:55 -0800 Subject: board/burnet: Free up flash space BRANCH=none BUG=b:172020503 TEST=CC=clang make BOARD=burnet Signed-off-by: Tom Hughes Change-Id: If04c6b209990822ccad384a1a6cbd66870eefcaa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4024564 Code-Coverage: Zoss Reviewed-by: Peter Marheine --- board/burnet/board.h | 3 +++ util/build_with_clang.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/board/burnet/board.h b/board/burnet/board.h index 17ca27daea..5199ae4aaf 100644 --- a/board/burnet/board.h +++ b/board/burnet/board.h @@ -8,6 +8,9 @@ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H +/* Free up flash space. */ +#undef CONFIG_CMD_KEYBOARD + #define VARIANT_KUKUI_JACUZZI #define VARIANT_KUKUI_BATTERY_SMART #define VARIANT_KUKUI_CHARGER_ISL9238 diff --git a/util/build_with_clang.py b/util/build_with_clang.py index 0f1093c8a0..ae707718e4 100755 --- a/util/build_with_clang.py +++ b/util/build_with_clang.py @@ -46,6 +46,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [ # Boards that use CHIP:=stm32 *and* CHIP_FAMILY:=stm32f0 # git grep --name-only 'CHIP:=stm32' | xargs grep -L 'CHIP_FAMILY:=stm32f0' | sed 's#board/\(.*\)/build.mk#"\1",#' "bland", + "burnet", "c2d2", "cerise", "coffeecake", @@ -282,7 +283,6 @@ RISCV_BOARDS = [ BOARDS_THAT_FAIL_WITH_CLANG = [ # Boards that use CHIP:=stm32 *and* CHIP_FAMILY:=stm32f0 - "burnet", # overflows flash "chocodile_vpdmcu", # compilation error: b/254710459 "fennel", # overflows flash "jacuzzi", # overflows flash -- cgit v1.2.1 From 7b0f44ceb3424114e949be66daf6085c66cb615d Mon Sep 17 00:00:00 2001 From: Matt Wang Date: Mon, 14 Nov 2022 10:18:39 +0800 Subject: frostflow: modify thermal setting Frostflow has different thermal settings and add the fan step function. This patch also allows the EC to manage the fan table when the unit is in clamshell or tablet mode. BUG=b:257174577, b:257149501 BRANCH=none TEST=zmake build frostflow. Thermal test pass. LOW_COVERAGE_REASON=no unit test for skyrim board yet: b/247151116 Signed-off-by: Matt Wang Change-Id: I3976bb73bf3f5867c451c90b4c553485c5e607a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4025402 Reviewed-by: Diana Z Code-Coverage: Zoss Reviewed-by: SamSP Liu --- zephyr/program/skyrim/CMakeLists.txt | 1 + zephyr/program/skyrim/frostflow.dts | 117 ++++++++++++++++++++++++-- zephyr/program/skyrim/prj_frostflow.conf | 4 + zephyr/program/skyrim/src/frostflow/thermal.c | 109 ++++++++++++++++++++++++ 4 files changed, 223 insertions(+), 8 deletions(-) create mode 100644 zephyr/program/skyrim/src/frostflow/thermal.c diff --git a/zephyr/program/skyrim/CMakeLists.txt b/zephyr/program/skyrim/CMakeLists.txt index 7291ad93ce..375099717e 100644 --- a/zephyr/program/skyrim/CMakeLists.txt +++ b/zephyr/program/skyrim/CMakeLists.txt @@ -57,6 +57,7 @@ if(DEFINED CONFIG_BOARD_FROSTFLOW) zephyr_library_sources( "src/frostflow/usb_mux_config.c" "src/frostflow/ppc_config.c" + "src/frostflow/thermal.c" ) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION "src/frostflow/keyboard.c" diff --git a/zephyr/program/skyrim/frostflow.dts b/zephyr/program/skyrim/frostflow.dts index ffc2fff237..5e4a21ae57 100644 --- a/zephyr/program/skyrim/frostflow.dts +++ b/zephyr/program/skyrim/frostflow.dts @@ -14,17 +14,21 @@ named-temp-sensors { compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <35>; - temp_fan_max = <70>; + temp_soc: soc-pct2075 { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; power-good-pin = <&gpio_pg_pwr_s5>; sensor = <&soc_pct2075>; }; - amb-pct2075 { + temp_amb: amb-pct2075 { + temp_host_high = <65>; + temp_host_halt = <70>; + temp_host_release_high = <55>; + temp_host_release_halt = <60>; + temp_fan_off = <32>; + temp_fan_max = <45>; power-good-pin = <&gpio_pg_pwr_s5>; sensor = <&amb_pct2075>; }; @@ -50,6 +54,74 @@ compatible = "aoz,aoz1380"; status = "okay"; }; + + fan_steps_clamshell: fan-steps-clamshell { + compatible = "cros-ec,fan-steps"; + level_0 { + temp_on = <(-1) (-1) (-1) (-1) 31>; + temp_off = <(-1) (-1) (-1) (-1) 99>; + rpm_target = <0>; + }; + level_1 { + temp_on = <(-1) (-1) (-1) (-1) 32>; + temp_off = <(-1) (-1) (-1) (-1) 30>; + rpm_target = <2600>; + }; + level_2 { + temp_on = <(-1) (-1) (-1) (-1) 34>; + temp_off = <(-1) (-1) (-1) (-1) 31>; + rpm_target = <2900>; + }; + level_3 { + temp_on = <(-1) (-1) (-1) (-1) 36>; + temp_off = <(-1) (-1) (-1) (-1) 33>; + rpm_target = <3600>; + }; + level_4 { + temp_on = <(-1) (-1) (-1) (-1) 38>; + temp_off = <(-1) (-1) (-1) (-1) 35>; + rpm_target = <4200>; + }; + level_5 { + temp_on = <(-1) (-1) (-1) (-1) 45>; + temp_off = <(-1) (-1) (-1) (-1) 37>; + rpm_target = <4600>; + }; + }; + + fan_steps_tablet: fan-steps-tablet { + compatible = "cros-ec,fan-steps"; + level_0 { + temp_on = <(-1) (-1) (-1) (-1) 31>; + temp_off = <(-1) (-1) (-1) (-1) 99>; + rpm_target = <0>; + }; + level_1 { + temp_on = <(-1) (-1) (-1) (-1) 32>; + temp_off = <(-1) (-1) (-1) (-1) 30>; + rpm_target = <2600>; + }; + level_2 { + temp_on = <(-1) (-1) (-1) (-1) 34>; + temp_off = <(-1) (-1) (-1) (-1) 31>; + rpm_target = <2900>; + }; + level_3 { + temp_on = <(-1) (-1) (-1) (-1) 36>; + temp_off = <(-1) (-1) (-1) (-1) 33>; + rpm_target = <3600>; + }; + level_4 { + temp_on = <(-1) (-1) (-1) (-1) 38>; + temp_off = <(-1) (-1) (-1) (-1) 35>; + rpm_target = <4200>; + }; + level_5 { + temp_on = <(-1) (-1) (-1) (-1) 45>; + temp_off = <(-1) (-1) (-1) (-1) 37>; + rpm_target = <4600>; + }; + }; }; &i2c1_0 { @@ -120,3 +192,32 @@ &kso14_gp82 >; }; + +&temp_sensor_charger { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; +}; + +&temp_sensor_memory { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; +}; + +&temp_sensor_cpu { + /delete-property/ temp_host_high; + /delete-property/ temp_host_halt; + /delete-property/ temp_host_release_high; + /delete-property/ temp_fan_off; + /delete-property/ temp_fan_max; +}; + +&fan0 { + pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + rpm_min = <2400>; + rpm_start = <2600>; + rpm_max = <4600>; +}; diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf index 675c387aae..02da02d35d 100644 --- a/zephyr/program/skyrim/prj_frostflow.conf +++ b/zephyr/program/skyrim/prj_frostflow.conf @@ -27,3 +27,7 @@ CONFIG_BOARD_USB_HUB_RESET=n # Battery CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y + +# Fan +CONFIG_PLATFORM_EC_FAN=y +CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y diff --git a/zephyr/program/skyrim/src/frostflow/thermal.c b/zephyr/program/skyrim/src/frostflow/thermal.c new file mode 100644 index 0000000000..eae8aac25d --- /dev/null +++ b/zephyr/program/skyrim/src/frostflow/thermal.c @@ -0,0 +1,109 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "chipset.h" +#include "fan.h" +#include "tablet_mode.h" +#include "temp_sensor/temp_sensor.h" +#include "thermal.h" +#include "util.h" +#include "console.h" + +#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_amb)) + +struct fan_step { + /* + * Sensor 0~4 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int on[TEMP_SENSOR_COUNT]; + /* + * Sensor 0~4 release point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int off[TEMP_SENSOR_COUNT]; + /* Fan rpm */ + uint16_t rpm[FAN_CH_COUNT]; +}; + +#define FAN_TABLE_ENTRY(nd) \ + { \ + .on = DT_PROP(nd, temp_on), \ + .off = DT_PROP(nd, temp_off), \ + .rpm = DT_PROP(nd, rpm_target), \ + }, + +static const struct fan_step fan_table_clamshell[] = { DT_FOREACH_CHILD( + DT_NODELABEL(fan_steps_clamshell), FAN_TABLE_ENTRY) }; + +static const struct fan_step fan_table_tablet[] = { DT_FOREACH_CHILD( + DT_NODELABEL(fan_steps_tablet), FAN_TABLE_ENTRY) }; + +static const struct fan_step *fan_step_table; +#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table_clamshell) + +BUILD_ASSERT(ARRAY_SIZE(fan_table_clamshell) == ARRAY_SIZE(fan_table_tablet)); + +int fan_table_to_rpm(int fan, int *temp) +{ + /* current fan level */ + static int current_level; + /* previous sensor temperature */ + static int prev_tmp[TEMP_SENSOR_COUNT]; + int i; + + if (tablet_get_mode()) + fan_step_table = fan_table_tablet; + else + fan_step_table = fan_table_clamshell; + + /* + * Compare the current and previous temperature, we have + * the three paths : + * 1. decreasing path. (check the release point) + * 2. increasing path. (check the trigger point) + * 3. invariant path. (return the current RPM) + */ + + if (temp[TEMP_AMB] < prev_tmp[TEMP_AMB]) { + for (i = current_level; i > 0; i--) { + if (temp[TEMP_AMB] < fan_step_table[i].off[TEMP_AMB]) + current_level = i - 1; + else + break; + } + } else if (temp[TEMP_AMB] > prev_tmp[TEMP_AMB]) { + for (i = current_level; i < NUM_FAN_LEVELS; i++) { + if (temp[TEMP_AMB] > fan_step_table[i].on[TEMP_AMB]) + current_level = i + 1; + else + break; + } + } + + if (current_level < 0) + current_level = 0; + + if (current_level >= NUM_FAN_LEVELS) + current_level = NUM_FAN_LEVELS - 1; + + for (i = 0; i < TEMP_SENSOR_COUNT; ++i) + prev_tmp[i] = temp[i]; + + return fan_step_table[current_level].rpm[fan]; +} + +void board_override_fan_control(int fan, int *temp) +{ + /* + * In common/fan.c pwm_fan_stop() will turn off fan + * when chipset suspend or shutdown. + */ + if (chipset_in_state(CHIPSET_STATE_ON)) { + fan_set_rpm_mode(fan, 1); + fan_set_rpm_target(fan, fan_table_to_rpm(fan, temp)); + } +} -- cgit v1.2.1 From a0d94a217900ba85232b4dfa5a13c10e13ac22ea Mon Sep 17 00:00:00 2001 From: Scott Collyer Date: Mon, 10 Oct 2022 12:10:04 -0700 Subject: tcpmv2: dpm: Add DATA_RESET state This CL adds a DATA_RESET state to the DPM state machine. The check for data reset being required remains in the mode entry/exit helper functions as the criteria is different between the 2 cases. However, data reset being handled in its own state removes the need to check if a data reset is ongoing. BUG=b:194504052 BRANCH=none TEST=Verified that mode entry/exit is successful for DP, TBT, and USB4 on Voxel. ectool typeccontrol 0 -> exit mode ectool typeccontrol 2 0 -> DP ectool typeccontrol 2 1 -> TBT ectool typeccontrol 2 2 -> USB4 Signed-off-by: Scott Collyer Change-Id: I7346d521531c800c787c9794fedd81e485b5912e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3965269 Tested-by: Scott Collyer Commit-Queue: Scott Collyer Reviewed-by: Abe Levkoy Code-Coverage: Zoss --- common/usbc/usb_pd_dpm.c | 64 +++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index 0568f26db9..9455610ea0 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -72,11 +72,10 @@ static struct { #define DPM_FLAG_ENTER_ANY \ (DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT | DPM_FLAG_ENTER_USB4) #define DPM_FLAG_SEND_VDM_REQ BIT(5) -#define DPM_FLAG_DATA_RESET_REQUESTED BIT(6) -#define DPM_FLAG_DATA_RESET_DONE BIT(7) -#define DPM_FLAG_PD_BUTTON_PRESSED BIT(8) -#define DPM_FLAG_PD_BUTTON_RELEASED BIT(9) -#define DPM_FLAG_PE_READY BIT(10) +#define DPM_FLAG_DATA_RESET_DONE BIT(6) +#define DPM_FLAG_PD_BUTTON_PRESSED BIT(7) +#define DPM_FLAG_PD_BUTTON_RELEASED BIT(8) +#define DPM_FLAG_PE_READY BIT(9) /* List of all Device Policy Manager level states */ enum usb_dpm_state { @@ -84,6 +83,7 @@ enum usb_dpm_state { DPM_WAITING, DPM_DFP_READY, DPM_UFP_READY, + DPM_DATA_RESET, }; /* Forward declare the full list of states. This is indexed by usb_pd_state */ @@ -95,6 +95,7 @@ __maybe_unused static __const_data const char *const dpm_state_names[] = { [DPM_WAITING] = "DPM Waiting", [DPM_DFP_READY] = "DPM DFP Ready", [DPM_UFP_READY] = "DPM UFP Ready", + [DPM_DATA_RESET] = "DPM Data Reset", }; static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT]; @@ -249,7 +250,6 @@ void dpm_set_mode_exit_request(int port) void dpm_data_reset_complete(int port) { - DPM_CLR_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_DONE); DPM_CLR_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE); } @@ -1054,20 +1054,16 @@ static bool dpm_dfp_enter_mode_msg(int port) return false; } + /* + * If AP mode entry is enabled, and a Data Reset has not been done, then + * first request Data Reset prior to attempting to enter any modes. + */ if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) && IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY) && - !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) && - !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - pd_dpm_request(port, DPM_REQUEST_DATA_RESET); - DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); - return false; - } - - if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) && - IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - return false; + set_state_dpm(port, DPM_DATA_RESET); + return true; } /* Check if port, port partner and cable support USB4. */ @@ -1174,15 +1170,10 @@ static bool dpm_dfp_exit_mode_msg(int port) * state checked below will reset to its inactive state. If Data Reset * is not supported, exit active modes individually. */ - if (IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG)) { - if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) && - !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - pd_dpm_request(port, DPM_REQUEST_DATA_RESET); - DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED); - return false; - } else if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { - return false; - } + if (IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) && + !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) { + set_state_dpm(port, DPM_DATA_RESET); + return true; } /* TODO(b/209625351): Data Reset is the only real way to exit from USB4 @@ -1352,6 +1343,25 @@ static void dpm_ufp_ready_run(const int port) } } +/* + * DPM_DATA_RESET + */ +static void dpm_data_reset_entry(const int port) +{ + print_current_state(port); + + pd_dpm_request(port, DPM_REQUEST_DATA_RESET); +} + +static void dpm_data_reset_run(const int port) +{ + /* Wait for Data Reset to Complete */ + if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) + return; + + set_state_dpm(port, DPM_DFP_READY); +} + static __const_data const struct usb_state dpm_states[] = { /* Normal States */ [DPM_WAITING] = { @@ -1366,4 +1376,8 @@ static __const_data const struct usb_state dpm_states[] = { .entry = dpm_ufp_ready_entry, .run = dpm_ufp_ready_run, }, + [DPM_DATA_RESET] = { + .entry = dpm_data_reset_entry, + .run = dpm_data_reset_run, + }, }; -- cgit v1.2.1 From 2e770caf3e2d8384fa4fb861a0a4e34d9f8ce852 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Fri, 4 Nov 2022 00:39:07 -0600 Subject: test: unit test uart_printf.c Add unit tests to get uart_printf.c to 100% coverage. BRANCH=none BUG=none TEST=twister LOW_COVERAGE_REASON=the lines showing up as red are tested by existing tests. I'm not sure why those tests don't count towards this CL. Signed-off-by: Yuval Peress Change-Id: I6fc4321a7a46836f212c285aca67c71613011b95 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4009401 Reviewed-by: Abe Levkoy --- common/uart_printf.c | 11 ++-- util/twister_tags.py | 1 + zephyr/test/uart_printf/CMakeLists.txt | 20 ++++++ zephyr/test/uart_printf/include/common.h | 12 ++++ zephyr/test/uart_printf/include/printf.h | 23 +++++++ zephyr/test/uart_printf/include/uart.h | 28 +++++++++ zephyr/test/uart_printf/prj.conf | 9 +++ zephyr/test/uart_printf/src/fakes.cc | 36 +++++++++++ zephyr/test/uart_printf/src/main.cc | 101 +++++++++++++++++++++++++++++++ zephyr/test/uart_printf/testcase.yaml | 8 +++ 10 files changed, 245 insertions(+), 4 deletions(-) create mode 100644 zephyr/test/uart_printf/CMakeLists.txt create mode 100644 zephyr/test/uart_printf/include/common.h create mode 100644 zephyr/test/uart_printf/include/printf.h create mode 100644 zephyr/test/uart_printf/include/uart.h create mode 100644 zephyr/test/uart_printf/prj.conf create mode 100644 zephyr/test/uart_printf/src/fakes.cc create mode 100644 zephyr/test/uart_printf/src/main.cc create mode 100644 zephyr/test/uart_printf/testcase.yaml diff --git a/common/uart_printf.c b/common/uart_printf.c index 01fd1353d2..a4fecf5c73 100644 --- a/common/uart_printf.c +++ b/common/uart_printf.c @@ -31,9 +31,10 @@ int uart_putc(int c) int uart_puts(const char *outstr) { /* Put all characters in the output buffer */ - while (*outstr) { - if (__tx_char(NULL, *outstr++) != 0) + for (; *outstr != '\0'; ++outstr) { + if (__tx_char(NULL, *outstr) != 0) { break; + } } uart_tx_start(); @@ -48,8 +49,9 @@ int uart_put(const char *out, int len) /* Put all characters in the output buffer */ for (written = 0; written < len; written++) { - if (__tx_char(NULL, *out++) != 0) + if (__tx_char(NULL, *out++) != 0) { break; + } } uart_tx_start(); @@ -63,8 +65,9 @@ int uart_put_raw(const char *out, int len) /* Put all characters in the output buffer */ for (written = 0; written < len; written++) { - if (uart_tx_char_raw(NULL, *out++) != 0) + if (uart_tx_char_raw(NULL, *out++) != 0) { break; + } } uart_tx_start(); diff --git a/util/twister_tags.py b/util/twister_tags.py index 692fdc1e99..68ac5846bd 100755 --- a/util/twister_tags.py +++ b/util/twister_tags.py @@ -29,6 +29,7 @@ TAG_TO_DESCRIPTION = { "mkbp": "Testing the MKBP (Matrix Keyboard Protocol) stack", "system": "Directly test functions in common/system.c or shim/src/system.c", "spi": "SPI related tests", + "uart": "UART related tests", } SCRIPT_PATH = os.path.realpath(__file__) diff --git a/zephyr/test/uart_printf/CMakeLists.txt b/zephyr/test/uart_printf/CMakeLists.txt new file mode 100644 index 0000000000..8844bfb7be --- /dev/null +++ b/zephyr/test/uart_printf/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(uart_printf) + +target_sources(testbinary + PRIVATE + ../../../common/uart_printf.c + src/fakes.cc + src/main.cc +) + +target_include_directories(testbinary + PRIVATE + include +) diff --git a/zephyr/test/uart_printf/include/common.h b/zephyr/test/uart_printf/include/common.h new file mode 100644 index 0000000000..79af9594b3 --- /dev/null +++ b/zephyr/test/uart_printf/include/common.h @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ +#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ + +#define EC_SUCCESS 0 +#define EC_ERROR_OVERFLOW -1 + +#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ */ diff --git a/zephyr/test/uart_printf/include/printf.h b/zephyr/test/uart_printf/include/printf.h new file mode 100644 index 0000000000..b6fcf6337d --- /dev/null +++ b/zephyr/test/uart_printf/include/printf.h @@ -0,0 +1,23 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ +#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int (*vfnprintf_addchar_t)(void *, int); +DECLARE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *, + const char *, va_list); + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ */ diff --git a/zephyr/test/uart_printf/include/uart.h b/zephyr/test/uart_printf/include/uart.h new file mode 100644 index 0000000000..51fd42a17e --- /dev/null +++ b/zephyr/test/uart_printf/include/uart.h @@ -0,0 +1,28 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ +#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int uart_putc(int c); +int uart_puts(const char *outstr); +int uart_put(const char *out, int len); +int uart_put_raw(const char *out, int len); +int uart_printf(const char *format, ...); + +DECLARE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int); +DECLARE_FAKE_VOID_FUNC(uart_tx_start); + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ */ diff --git a/zephyr/test/uart_printf/prj.conf b/zephyr/test/uart_printf/prj.conf new file mode 100644 index 0000000000..744afcce87 --- /dev/null +++ b/zephyr/test/uart_printf/prj.conf @@ -0,0 +1,9 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_ZTEST=y +CONFIG_ZTEST_NEW_API=y +CONFIG_CPLUSPLUS=y +CONFIG_STD_CPP20=y +CONFIG_LIB_CPLUSPLUS=y diff --git a/zephyr/test/uart_printf/src/fakes.cc b/zephyr/test/uart_printf/src/fakes.cc new file mode 100644 index 0000000000..0bb5fea1eb --- /dev/null +++ b/zephyr/test/uart_printf/src/fakes.cc @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "printf.h" +#include "uart.h" + +DEFINE_FFF_GLOBALS; + +/* printf.h */ +DEFINE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *, + const char *, va_list); + +/* uart.h */ +DEFINE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int); +DEFINE_FAKE_VOID_FUNC(uart_tx_start); + +static void fake_reset_rule_before(const struct ztest_unit_test *test, + void *data) +{ + ARG_UNUSED(test); + ARG_UNUSED(data); + + /* printf.h */ + RESET_FAKE(vfnprintf); + + /* uart.h */ + RESET_FAKE(uart_tx_char_raw); + RESET_FAKE(uart_tx_start); +} + +ZTEST_RULE(fake_reset, fake_reset_rule_before, nullptr); diff --git a/zephyr/test/uart_printf/src/main.cc b/zephyr/test/uart_printf/src/main.cc new file mode 100644 index 0000000000..9feb6a7ae9 --- /dev/null +++ b/zephyr/test/uart_printf/src/main.cc @@ -0,0 +1,101 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include + +#include "common.h" +#include "printf.h" +#include "uart.h" + +ZTEST_SUITE(uart_printf, nullptr, nullptr, nullptr, nullptr, nullptr); + +ZTEST(uart_printf, test_uart_putc) +{ + int return_vals[] = { 0, -1 }; + + SET_RETURN_SEQ(uart_tx_char_raw, return_vals, 2); + + zassert_ok(uart_putc(5)); + zassert_equal(EC_ERROR_OVERFLOW, uart_putc(5)); +} + +ZTEST(uart_printf, test_uart_put_success) +{ + const std::string test_string = "test string"; + std::string output_string; + + /* Print the whole string */ + zassert_equal(test_string.size(), + static_cast(uart_put(test_string.c_str(), + test_string.size()))); + zassert_equal(test_string.size(), uart_tx_char_raw_fake.call_count); + + /* Copy the history so it's easier to assert */ + for (size_t i = 0; i < test_string.size(); ++i) { + output_string += uart_tx_char_raw_fake.arg1_history[i]; + } + + /* Verify that the string was passed to uart_tx_char_raw() */ + zassert_equal(test_string, output_string); +} + +ZTEST(uart_printf, test_uart_put_fail_tx) +{ + const char test_string[] = "\n"; + + uart_tx_char_raw_fake.return_val = -1; + + /* Try printing the newline */ + zassert_equal(0, uart_put(test_string, 1)); + zassert_equal(1, uart_tx_char_raw_fake.call_count); + zassert_equal('\r', uart_tx_char_raw_fake.arg1_val); +} + +ZTEST(uart_printf, test_uart_puts_fail_tx) +{ + const char test_string[] = "\n\0"; + + uart_tx_char_raw_fake.return_val = -1; + + /* Try printing the newline */ + zassert_equal(EC_ERROR_OVERFLOW, uart_puts(test_string)); + zassert_equal(1, uart_tx_char_raw_fake.call_count); + zassert_equal('\r', uart_tx_char_raw_fake.arg1_val); +} + +ZTEST(uart_printf, test_uart_put_raw_fail_tx) +{ + const char test_string[] = "\n"; + + uart_tx_char_raw_fake.return_val = -1; + + /* Try printing the newline */ + zassert_equal(0, uart_put_raw(test_string, 1)); + zassert_equal(1, uart_tx_char_raw_fake.call_count); + zassert_equal('\n', uart_tx_char_raw_fake.arg1_val); +} + +static int vfnprintf_custom_fake_expect_int_arg; +static int vfnprintf_custom_fake(vfnprintf_addchar_t, void *, const char *, + va_list alist) +{ + zassert_equal(vfnprintf_custom_fake_expect_int_arg, va_arg(alist, int)); + return 0; +} +ZTEST(uart_printf, test_uart_printf) +{ + const char test_format[] = "d=%d"; + + vfnprintf_custom_fake_expect_int_arg = 5; + vfnprintf_fake.custom_fake = vfnprintf_custom_fake; + + zassert_ok( + uart_printf(test_format, vfnprintf_custom_fake_expect_int_arg)); + zassert_equal(1, vfnprintf_fake.call_count); + zassert_equal(test_format, vfnprintf_fake.arg2_val); +} diff --git a/zephyr/test/uart_printf/testcase.yaml b/zephyr/test/uart_printf/testcase.yaml new file mode 100644 index 0000000000..0315abab6f --- /dev/null +++ b/zephyr/test/uart_printf/testcase.yaml @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +tests: + uart.printf: + tags: uart + type: unit -- cgit v1.2.1 From d3c7fd6fdc7c47304a8b4bb543ebdc4e3664f7b9 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Mon, 21 Nov 2022 14:10:35 -0700 Subject: tcpm_header: add test for tcpc_get_bist_test_mode unimplemented This function previously had no coverage this particular path. BUG=none TEST=twister, verify lines are now covered BRANCH=none Change-Id: I7fef8ab28251c2658fba8162d1077d2e78a9479f Signed-off-by: Clayton Whitelaw Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4061754 Reviewed-by: Aaron Massey Code-Coverage: Zoss Commit-Queue: Yuval Peress --- zephyr/test/drivers/default/src/tcpm_header.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c index 118e4676f7..2c6bbaf9c2 100644 --- a/zephyr/test/drivers/default/src/tcpm_header.c +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -150,6 +150,17 @@ ZTEST_F(tcpm_header, test_tcpm_header_set_frs_enable__implemented) zassert_equal(driver_return_code, res); } +ZTEST_F(tcpm_header, test_tcpm_header_tcpc_get_bist_test_mode__unimplemented) +{ + int res; + bool enabled = true; /* Should be overwritten to false */ + + res = tcpc_get_bist_test_mode(TCPM_TEST_PORT, &enabled); + + zassert_equal(EC_ERROR_UNIMPLEMENTED, res); + zassert_false(enabled); +} + static void *tcpm_header_setup(void) { static struct tcpm_header_fixture fixture; -- cgit v1.2.1 From ed60cdc3e8e545aba4a35490eb2fb830e07c2ac8 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Mon, 21 Nov 2022 14:10:35 -0700 Subject: tcpm_header: add test for tcpm_get_chip_info unimplemented This function previously had no coverage for this particular path. BUG=none TEST=twister, verify lines are now covered BRANCH=none Change-Id: Ia09dff83a8cc9d54b93e1158d834d091feaa512c Signed-off-by: Clayton Whitelaw Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4061756 Reviewed-by: Aaron Massey Commit-Queue: Yuval Peress Code-Coverage: Zoss --- zephyr/test/drivers/default/src/tcpm_header.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c index 2c6bbaf9c2..b310770306 100644 --- a/zephyr/test/drivers/default/src/tcpm_header.c +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -161,6 +161,12 @@ ZTEST_F(tcpm_header, test_tcpm_header_tcpc_get_bist_test_mode__unimplemented) zassert_false(enabled); } +ZTEST_F(tcpm_header, test_tcpm_header_get_chip_info__unimplemented) +{ + zassert_equal(EC_ERROR_UNIMPLEMENTED, + tcpm_get_chip_info(TCPM_TEST_PORT, 0, NULL)); +} + static void *tcpm_header_setup(void) { static struct tcpm_header_fixture fixture; -- cgit v1.2.1 From a56be59ccdcc4f0d4c568b6237237b27a176f236 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Mon, 21 Nov 2022 14:10:35 -0700 Subject: tcpm_header: add test for tcpm_dump_registers This function previously had no coverage for the case where standard registers should be dumped. To support this test, mark tcpc_dump_std_registers as test_mockable. BUG=none TEST=twister, verify lines are now covered BRANCH=none Change-Id: Id7bbba6f77c1684a7eeafb1be1f990fb9176e16b Signed-off-by: Clayton Whitelaw Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062461 Commit-Queue: Yuval Peress Code-Coverage: Zoss Reviewed-by: Yuval Peress --- driver/tcpm/tcpci.c | 2 +- zephyr/test/drivers/default/src/tcpm_header.c | 17 +++++++++++++++++ zephyr/test/drivers/testcase.yaml | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 6e8a1feaf9..ffd7fa3a97 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -1848,7 +1848,7 @@ static const struct tcpc_reg_dump_map tcpc_regs[] = { /* * Dump standard TCPC registers. */ -void tcpc_dump_std_registers(int port) +test_mockable void tcpc_dump_std_registers(int port) { tcpc_dump_registers(port, tcpc_regs, ARRAY_SIZE(tcpc_regs)); } diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c index b310770306..5eceb31f6d 100644 --- a/zephyr/test/drivers/default/src/tcpm_header.c +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -18,6 +18,7 @@ FAKE_VALUE_FUNC(int, debug_accessory, int, bool); FAKE_VALUE_FUNC(int, debug_detach, int); FAKE_VALUE_FUNC(int, hard_reset_reinit, int); FAKE_VALUE_FUNC(int, set_frs_enable, int, int); +FAKE_VOID_FUNC(tcpc_dump_std_registers, int); struct tcpm_header_fixture { /* The original driver pointer that gets restored after the tests */ @@ -167,6 +168,21 @@ ZTEST_F(tcpm_header, test_tcpm_header_get_chip_info__unimplemented) tcpm_get_chip_info(TCPM_TEST_PORT, 0, NULL)); } +ZTEST_F(tcpm_header, test_tcpm_header_dump_registers__std) +{ + Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP); + + /* + * The driver does not implement dump_registers, so the + * standard ones should be dumped instead. + */ + tcpm_dump_registers(TCPM_TEST_PORT); + + zassert_equal(1, tcpc_dump_std_registers_fake.call_count); + zassert_equal(TCPM_TEST_PORT, + tcpc_dump_std_registers_fake.arg0_history[0]); +} + static void *tcpm_header_setup(void) { static struct tcpm_header_fixture fixture; @@ -184,6 +200,7 @@ static void tcpm_header_before(void *state) RESET_FAKE(debug_detach); RESET_FAKE(hard_reset_reinit); RESET_FAKE(set_frs_enable); + RESET_FAKE(tcpc_dump_std_registers); fixture->mock_driver = (struct tcpm_drv){ 0 }; fixture->saved_driver_ptr = tcpc_config[TCPM_TEST_PORT].drv; diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index 896562f4f8..f576213345 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -12,6 +12,7 @@ tests: - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y - CONFIG_PLATFORM_EC_USB_PD_DPS=y - CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y + - CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=y drivers.default.bring_up: timeout: 240 extra_args: CONF_FILE="prj.conf;default/prj.conf" -- cgit v1.2.1 From 82268e0885e89b6b7a46dc0864dc225108aa6861 Mon Sep 17 00:00:00 2001 From: Clayton Whitelaw Date: Mon, 21 Nov 2022 14:10:35 -0700 Subject: tcpm_header: add test for tcpc_has_frs_control from flags This function previously had no coverage for the case when TCPC_FLAGS_CONTROL_FRS was set. BUG=none TEST=twister, verify lines are now covered BRANCH=none Change-Id: I1b8d902fc0551388fcb12200e9c85a1f62ed7209 Signed-off-by: Clayton Whitelaw Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4063190 Code-Coverage: Zoss Commit-Queue: Yuval Peress Reviewed-by: Yuval Peress --- zephyr/test/drivers/default/src/tcpm_header.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c index 5eceb31f6d..e03e09aaa5 100644 --- a/zephyr/test/drivers/default/src/tcpm_header.c +++ b/zephyr/test/drivers/default/src/tcpm_header.c @@ -126,6 +126,20 @@ ZTEST_F(tcpm_header, test_tcpm_header_hard_reset_reinit__implemented) zassert_equal(driver_return_code, res); } +ZTEST_F(tcpm_header, test_tcpm_header_tcpc_has_frs_control__flag) +{ + Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_USB_PD_FRS); + Z_TEST_SKIP_IFDEF(CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC); + + /* Determined by tcpc flag when USB_PD_FRS_TCPC is not set. */ + + tcpc_config[TCPM_TEST_PORT].flags = 0; + zassert_equal(0, tcpm_tcpc_has_frs_control(TCPM_TEST_PORT)); + + tcpc_config[TCPM_TEST_PORT].flags = TCPC_FLAGS_CONTROL_FRS; + zassert_equal(1, tcpm_tcpc_has_frs_control(TCPM_TEST_PORT)); +} + ZTEST_F(tcpm_header, test_tcpm_header_set_frs_enable__unimplemented) { Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_USB_PD_FRS); -- cgit v1.2.1 From 591d2bed6300093b81c653ee79470cdefabe3b8a Mon Sep 17 00:00:00 2001 From: ben chen Date: Mon, 28 Nov 2022 13:58:07 +0800 Subject: craask: add Fw_config structure for FAN control Craask need to implement FW_FAN config in bit 17 of cbi fw_config.Enable/Disable fan control by FW_FAN flag. BUG=b:257387315 BRANCH=none TEST=check fan workable by FW_FAN flags setting. Change-Id: I94876d0092f713d4c29980f76338803081276503 Signed-off-by: Ben Chen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4060382 Code-Coverage: Andrew McRae Reviewed-by: Andrew McRae --- zephyr/program/nissa/CMakeLists.txt | 1 + zephyr/program/nissa/craask/cbi.dtsi | 26 ++++++++++++++++++++ zephyr/program/nissa/craask/fan.dtsi | 38 +++++++++++++++++++++++++++++ zephyr/program/nissa/craask/overlay.dtsi | 4 +++ zephyr/program/nissa/craask/project.overlay | 1 + zephyr/program/nissa/craask/src/fan.c | 37 ++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+) create mode 100644 zephyr/program/nissa/craask/fan.dtsi create mode 100644 zephyr/program/nissa/craask/src/fan.c diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index a982f89b56..c8610e488d 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -34,6 +34,7 @@ if(DEFINED CONFIG_BOARD_NEREID) endif() if(DEFINED CONFIG_BOARD_CRAASK) zephyr_library_sources( + "craask/src/fan.c" "craask/src/form_factor.c" "craask/src/keyboard.c" "craask/src/kb_backlight.c" diff --git a/zephyr/program/nissa/craask/cbi.dtsi b/zephyr/program/nissa/craask/cbi.dtsi index 203eace823..e329929227 100644 --- a/zephyr/program/nissa/craask/cbi.dtsi +++ b/zephyr/program/nissa/craask/cbi.dtsi @@ -52,6 +52,32 @@ value = <1>; }; }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <17>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + /* * FW_CONFIG field to enable KB back light or not. */ diff --git a/zephyr/program/nissa/craask/fan.dtsi b/zephyr/program/nissa/craask/fan.dtsi new file mode 100644 index 0000000000..b94b0a018c --- /dev/null +++ b/zephyr/program/nissa/craask/fan.dtsi @@ -0,0 +1,38 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +/ { + fans { + compatible = "cros-ec,fans"; + fan_0 { + pwms = <&pwm5 5 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + tach = <&tach2>; + rpm_min = <2500>; + rpm_start = <2500>; + rpm_max = <4100>; + enable_gpio = <&gpio_fan_enable>; + }; + }; +}; + +&pwm5_gpb7 { + drive-open-drain; +}; + +/* pwm for fan */ +&pwm5 { + status = "okay"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; + +/* Tachometer for fan speed measurement */ +&tach2 { + status = "okay"; + pinctrl-0 = <&ta2_1_in_gp73>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; diff --git a/zephyr/program/nissa/craask/overlay.dtsi b/zephyr/program/nissa/craask/overlay.dtsi index 2607c10402..749317cbf5 100644 --- a/zephyr/program/nissa/craask/overlay.dtsi +++ b/zephyr/program/nissa/craask/overlay.dtsi @@ -120,6 +120,10 @@ gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; no-auto-init; }; + gpio_fan_enable: fan-enable { + gpios = <&gpio6 3 GPIO_OUTPUT>; + no-auto-init; + }; ec-i2c-sensor-scl { gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; }; diff --git a/zephyr/program/nissa/craask/project.overlay b/zephyr/program/nissa/craask/project.overlay index 9ca681d979..6107b6ef15 100644 --- a/zephyr/program/nissa/craask/project.overlay +++ b/zephyr/program/nissa/craask/project.overlay @@ -6,6 +6,7 @@ #include "../cbi.dtsi" #include "cbi.dtsi" +#include "fan.dtsi" #include "generated.dtsi" #include "keyboard.dtsi" #include "motionsense.dtsi" diff --git a/zephyr/program/nissa/craask/src/fan.c b/zephyr/program/nissa/craask/src/fan.c new file mode 100644 index 0000000000..c01ee3d752 --- /dev/null +++ b/zephyr/program/nissa/craask/src/fan.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" +#include "nissa_common.h" + +#include +#include +#include +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +static void fan_init(void) +{ + int ret; + uint32_t val; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + if (val != FW_FAN_PRESENT) { + /* Disable the fan */ + fan_set_count(0); + } else { + /* Configure the fan enable GPIO */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), + GPIO_OUTPUT); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); -- cgit v1.2.1 From 4bc3db0d0d39b84dee206f63d85039ecd079359a Mon Sep 17 00:00:00 2001 From: jeffrey Date: Fri, 11 Nov 2022 10:21:09 +0800 Subject: xivur: Initial zephyr config for xivur project Initial EC Zephyr config for xivur Reuse most of nivviks sources. BUG=b:258325854 TEST=zmake build xivur --clobber BRANCH=nissa LOW_COVERAGE_REASON=Initial xivur project, board test under developement(b/258325854) Signed-off-by: jeffrey Change-Id: Iffbaed8bfe3dc292bc263ecd4fb4016941de78cc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022845 Reviewed-by: Jacky Wang Reviewed-by: Shou-Chieh Hsu Code-Coverage: Kyle Lin Commit-Queue: Kyle Lin Reviewed-by: Kyle Lin --- zephyr/program/nissa/BUILD.py | 7 +- zephyr/program/nissa/CMakeLists.txt | 11 + zephyr/program/nissa/Kconfig | 6 + zephyr/program/nissa/xivur/cbi.dtsi | 30 ++ zephyr/program/nissa/xivur/generated.dtsi | 291 ++++++++++++++++++ zephyr/program/nissa/xivur/keyboard.dtsi | 48 +++ zephyr/program/nissa/xivur/motionsense.dtsi | 166 ++++++++++ zephyr/program/nissa/xivur/overlay.dtsi | 418 ++++++++++++++++++++++++++ zephyr/program/nissa/xivur/power_signals.dtsi | 220 ++++++++++++++ zephyr/program/nissa/xivur/project.conf | 8 + zephyr/program/nissa/xivur/project.overlay | 14 + zephyr/program/nissa/xivur/pwm_leds.dtsi | 62 ++++ zephyr/program/nissa/xivur/src/charger.c | 56 ++++ zephyr/program/nissa/xivur/src/fan.c | 43 +++ zephyr/program/nissa/xivur/src/form_factor.c | 47 +++ zephyr/program/nissa/xivur/src/keyboard.c | 29 ++ zephyr/program/nissa/xivur/src/led.c | 51 ++++ zephyr/program/nissa/xivur/src/usbc.c | 277 +++++++++++++++++ 18 files changed, 1783 insertions(+), 1 deletion(-) create mode 100644 zephyr/program/nissa/xivur/cbi.dtsi create mode 100644 zephyr/program/nissa/xivur/generated.dtsi create mode 100644 zephyr/program/nissa/xivur/keyboard.dtsi create mode 100644 zephyr/program/nissa/xivur/motionsense.dtsi create mode 100644 zephyr/program/nissa/xivur/overlay.dtsi create mode 100644 zephyr/program/nissa/xivur/power_signals.dtsi create mode 100644 zephyr/program/nissa/xivur/project.conf create mode 100644 zephyr/program/nissa/xivur/project.overlay create mode 100644 zephyr/program/nissa/xivur/pwm_leds.dtsi create mode 100644 zephyr/program/nissa/xivur/src/charger.c create mode 100644 zephyr/program/nissa/xivur/src/fan.c create mode 100644 zephyr/program/nissa/xivur/src/form_factor.c create mode 100644 zephyr/program/nissa/xivur/src/keyboard.c create mode 100644 zephyr/program/nissa/xivur/src/led.c create mode 100644 zephyr/program/nissa/xivur/src/usbc.c diff --git a/zephyr/program/nissa/BUILD.py b/zephyr/program/nissa/BUILD.py index b1affe7b4c..fa5c77baf9 100644 --- a/zephyr/program/nissa/BUILD.py +++ b/zephyr/program/nissa/BUILD.py @@ -4,7 +4,7 @@ """Define zmake projects for nissa.""" -# Nivviks and Craask, Pujjo, Xivu has NPCX993F, Nereid and Joxer, Yaviks has ITE81302 +# Nivviks and Craask, Pujjo, Xivu, Xivur has NPCX993F, Nereid and Joxer, Yaviks has ITE81302 def register_nissa_project( @@ -55,6 +55,11 @@ xivu = register_nissa_project( chip="npcx9m3f", ) +xivur = register_nissa_project( + project_name="xivur", + chip="npcx9m3f", +) + joxer = register_nissa_project( project_name="joxer", chip="it81302bx", diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index c8610e488d..101146507b 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -85,4 +85,15 @@ if(DEFINED CONFIG_BOARD_YAVIKS) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "yaviks/src/usbc.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "yaviks/src/charger.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "yaviks/src/fan.c") +endif() +if(DEFINED CONFIG_BOARD_XIVUR) + project(xivur) + zephyr_library_sources( + "xivur/src/led.c" + "xivur/src/form_factor.c" + "xivur/src/keyboard.c" + ) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "xivur/src/fan.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "xivur/src/usbc.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "xivur/src/charger.c") endif() \ No newline at end of file diff --git a/zephyr/program/nissa/Kconfig b/zephyr/program/nissa/Kconfig index 9e9ffc2528..2eb694577d 100644 --- a/zephyr/program/nissa/Kconfig +++ b/zephyr/program/nissa/Kconfig @@ -32,6 +32,12 @@ config BOARD_XIVU Build Google Xivu board. Xivu has Intel ADL-N SoC with NPCX993FA0BX EC. +config BOARD_XIVUR + bool "Google Xivur Board" + help + Build Google Xivur board. Xivur has Intel ADL-N SoC + with NPCX993FA0BX EC. + config BOARD_JOXER bool "Google Joxer Board" help diff --git a/zephyr/program/nissa/xivur/cbi.dtsi b/zephyr/program/nissa/xivur/cbi.dtsi new file mode 100644 index 0000000000..112a2a885c --- /dev/null +++ b/zephyr/program/nissa/xivur/cbi.dtsi @@ -0,0 +1,30 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* Nivviks-specific fw_config fields. */ + nissa-fw-config { + /* + * FW_CONFIG field to describe mainboard orientation in chassis. + */ + base-inversion { + enum-name = "FW_BASE_INVERSION"; + start = <3>; + size = <1>; + + inverted { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_INVERTED"; + value = <0>; + }; + regular { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_REGULAR"; + value = <1>; + default; + }; + }; + }; +}; diff --git a/zephyr/program/nissa/xivur/generated.dtsi b/zephyr/program/nissa/xivur/generated.dtsi new file mode 100644 index 0000000000..91718302b4 --- /dev/null +++ b/zephyr/program/nissa/xivur/generated.dtsi @@ -0,0 +1,291 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This file is auto-generated - do not edit! + */ + +/ { + + named-adc-channels { + compatible = "named-adc-channels"; + + adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc { + enum-name = "ADC_PP1050_PROC"; + io-channels = <&adc0 4>; + }; + adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 { + enum-name = "ADC_PP3300_S5"; + io-channels = <&adc0 6>; + }; + adc_temp_sensor_1: temp_sensor_1 { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 0>; + }; + adc_temp_sensor_2: temp_sensor_2 { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 1>; + }; + adc_temp_sensor_3: temp_sensor_3 { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 10>; + }; + }; + + named-gpios { + compatible = "named-gpios"; + + gpio_acc_int_l: acc_int_l { + gpios = <&gpio5 0 GPIO_INPUT>; + }; + gpio_all_sys_pwrgd: all_sys_pwrgd { + gpios = <&gpioa 7 GPIO_INPUT>; + }; + gpio_ccd_mode_odl: ccd_mode_odl { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + gpio_cpu_c10_gate_l: cpu_c10_gate_l { + gpios = <&gpio6 7 GPIO_INPUT>; + }; + gpio_ec_battery_pres_odl: ec_battery_pres_odl { + gpios = <&gpioa 3 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio7 4 GPIO_OUTPUT>; + }; + gpio_ec_edp_bl_en_od: ec_edp_bl_en_od { + gpios = <&gpiod 3 GPIO_ODR_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT"; + }; + gpio_ec_entering_rw: ec_entering_rw { + gpios = <&gpio0 3 GPIO_OUTPUT>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_ec_gsc_packet_mode: ec_gsc_packet_mode { + gpios = <&gpio7 5 GPIO_OUTPUT>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + gpio_ec_pch_wake_odl: ec_pch_wake_odl { + gpios = <&gpiob 0 GPIO_ODR_LOW>; + }; + gpio_ec_prochot_odl: ec_prochot_odl { + gpios = <&gpiof 1 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok { + gpios = <&gpio6 1 GPIO_OUTPUT>; + }; + gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd { + gpios = <&gpioe 4 GPIO_OUTPUT>; + }; + gpio_ec_soc_int_odl: ec_soc_int_odl { + gpios = <&gpio8 0 GPIO_ODR_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od { + gpios = <&gpio7 2 GPIO_ODR_HIGH>; + }; + gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl { + gpios = <&gpioc 1 GPIO_ODR_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioa 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_rtcrst: ec_soc_rtcrst { + gpios = <&gpio7 6 GPIO_OUTPUT>; + }; + gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok { + gpios = <&gpio3 7 GPIO_OUTPUT>; + }; + gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od { + gpios = <&gpioa 4 GPIO_ODR_HIGH>; + }; + gpio_ec_wp_odl: ec_wp_odl { + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_en_kb_bl: en_kb_bl { + gpios = <&gpioa 0 GPIO_OUTPUT>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_en_pp3300_s5: en_pp3300_s5 { + gpios = <&gpiob 6 GPIO_OUTPUT>; + enum-name = "GPIO_TEMP_SENSOR_POWER"; + }; + gpio_en_pp5000_pen_x: en_pp5000_pen_x { + gpios = <&gpioe 2 GPIO_OUTPUT>; + }; + gpio_en_pp5000_s5: en_pp5000_s5 { + gpios = <&gpio4 0 GPIO_OUTPUT>; + }; + gpio_en_slp_z: en_slp_z { + gpios = <&gpioe 1 GPIO_OUTPUT>; + }; + gpio_en_usb_a0_vbus: en_usb_a0_vbus { + gpios = <&gpio9 1 GPIO_OUTPUT>; + }; + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_hdmi_sel: hdmi_sel { + gpios = <&gpioc 6 GPIO_OUTPUT>; + }; + gpio_imu_int_l: imu_int_l { + gpios = <&gpio5 6 GPIO_INPUT>; + }; + gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { + gpios = <&gpio4 3 GPIO_INPUT>; + }; + gpio_lid_open: lid_open { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_pen_detect_odl: pen_detect_odl { + gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_pg_pp5000_s5_od: pg_pp5000_s5_od { + gpios = <&gpio4 2 GPIO_INPUT>; + }; + gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l { + gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>; + }; + gpio_slp_s0_l: slp_s0_l { + gpios = <&gpio9 7 GPIO_INPUT>; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + gpio_slp_s4_l: slp_s4_l { + gpios = <&gpio7 0 GPIO_INPUT>; + }; + gpio_slp_sus_l: slp_sus_l { + gpios = <&gpio6 2 GPIO_INPUT>; + }; + gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp { + gpios = <&gpiod 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB2_ILIM_SEL"; + }; + gpio_sys_rst_odl: sys_rst_odl { + gpios = <&gpioc 5 GPIO_ODR_HIGH>; + }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpio9 5 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { + gpios = <&gpio8 5 GPIO_OUTPUT>; + enum-name = "GPIO_USB1_ILIM_SEL"; + }; + gpio_usb_c0_int_odl: usb_c0_int_odl { + gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>; + }; + gpio_vccin_aux_vid0: vccin_aux_vid0 { + gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_vccin_aux_vid1: vccin_aux_vid1 { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_ec_i2c_eeprom: ec_i2c_eeprom { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + i2c_ec_i2c_sensor: ec_i2c_sensor { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_C0_TCPC"; + }; + i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 { + i2c-port = <&i2c5_1>; + enum-names = "I2C_PORT_USB_C1_TCPC"; + }; + i2c_ec_i2c_batt: ec_i2c_batt { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_BATTERY"; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan4_gp41 + &adc0_chan6_gp34 + &adc0_chan10_gpe0>; + pinctrl-names = "default"; +}; + + +&i2c0_0 { + status = "okay"; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; +}; + +&i2c1_0 { + status = "okay"; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; +}; + +&i2c3_0 { + status = "okay"; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; +}; + +&i2c5_1 { + status = "okay"; + pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>; + pinctrl-names = "default"; +}; + +&i2c7_0 { + status = "okay"; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/nissa/xivur/keyboard.dtsi b/zephyr/program/nissa/xivur/keyboard.dtsi new file mode 100644 index 0000000000..00610e4e18 --- /dev/null +++ b/zephyr/program/nissa/xivur/keyboard.dtsi @@ -0,0 +1,48 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm6 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm6_gpc0>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/xivur/motionsense.dtsi b/zephyr/program/nissa/xivur/motionsense.dtsi new file mode 100644 index 0000000000..6297a07bf5 --- /dev/null +++ b/zephyr/program/nissa/xivur/motionsense.dtsi @@ -0,0 +1,166 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * Interrupt bindings for sensor devices. + */ + lsm6dso-int = &base_accel; + lis2dw12-int = &lid_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <(-1) 0 0 + 0 1 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rot-ref { + mat33 = <(-1) 0 0 + 0 (-1) 0 + 0 0 1>; + }; + + base_rot_inverted: base-rotation-inverted { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + lsm6dso_accel_data: lsm6dso-accel-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lsm6dso_gyro_data: lsm6dso-gyro-drv-data { + compatible = "cros-ec,drvdata-lsm6dso"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + * TODO(b/238139272): The first entries of the array must be + * accelerometers,then gyroscope. Fix this dependency in the DTS + * processing which makes the devicetree entries independent. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,lsm6dso-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + /* + * May be replaced by alternate depending + * on board config. + */ + rot-standard-ref = <&base_rot_ref>; + drv-data = <&lsm6dso_accel_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,lsm6dso-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */ + drv-data = <&lsm6dso_gyro_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu>; + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/nissa/xivur/overlay.dtsi b/zephyr/program/nissa/xivur/overlay.dtsi new file mode 100644 index 0000000000..c2d5e3f24b --- /dev/null +++ b/zephyr/program/nissa/xivur/overlay.dtsi @@ -0,0 +1,418 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &gpio_ec_wp_odl; + int-wp = &int_wp_l; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + ec-console { + compatible = "ec-console"; + disabled = "events", "lpc", "hostcmd"; + }; + + batteries { + default_battery: lgc { + compatible = "lgc,ap18c8k", "battery-smart"; + }; + lgc_ap19b8m { + compatible = "lgc,ap19b8m", "battery-smart"; + }; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = < + &int_power_button + &int_lid_open + >; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&gpio_gsc_ec_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_wp_l: wp_l { + irq-pin = <&gpio_ec_wp_odl>; + flags = ; + handler = "switch_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = ; + handler = "gmr_tablet_switch_isr"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_imu_int_l>; + flags = ; + handler = "lsm6dso_interrupt"; + }; + int_vol_down: vol_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_vol_up: vol_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_usb_c0: usb_c0 { + irq-pin = <&gpio_usb_c0_int_odl>; + flags = ; + handler = "usb_interrupt"; + }; + int_usb_c1: usb_c1 { + irq-pin = <&gpio_sb_1>; + flags = ; + handler = "usb_interrupt"; + }; + }; + + named-gpios { + gpio_sb_1: sb-1 { + gpios = <&gpio0 2 GPIO_PULL_UP>; + no-auto-init; + }; + + gpio_sb_2: sb-2 { + gpios = <&gpiod 4 GPIO_OUTPUT>; + no-auto-init; + }; + + /* + * Set I2C pins for type C sub-board to be low voltage (I2C5_1). + * We do this for all boards, since the pins are 3.3V tolerant, + * and the only 2 types of sub-boards used on nivviks both have + * type-C ports on them. + */ + gpio_sb_3: sb-3 { + gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>; + no-auto-init; + }; + gpio_sb_4: sb-4 { + gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + no-auto-init; + }; + gpio_fan_enable: fan-enable { + gpios = <&gpio6 3 GPIO_OUTPUT>; + no-auto-init; + }; + ec-i2c-sensor-scl { + gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec-i2c-sensor-sda { + gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + }; + + /* + * Aliases used for sub-board GPIOs. + */ + aliases { + /* + * Input GPIO when used with type-C port 1 + * Output when used with HDMI sub-board + */ + gpio-usb-c1-int-odl = &gpio_sb_1; + gpio-en-rails-odl = &gpio_sb_1; + /* + * Sub-board with type A USB, enable. + */ + gpio-en-usb-a1-vbus = &gpio_sb_2; + /* + * HPD pins for HDMI sub-board. + */ + gpio-hdmi-en-odl = &gpio_sb_3; + gpio-hpd-odl = &gpio_sb_4; + /* + * Enable S5 rails for LTE sub-board + */ + gpio-en-sub-s5-rails = &gpio_sb_2; + }; + + temp_memory: memory { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_1>; + }; + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_2>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_51K1_47K_4050B>; + adc = <&adc_temp_sensor_3>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + memory { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_memory>; + }; + charger { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_charger>; + }; + ambient { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <85>; + temp_host_halt = <90>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_ec_soc_dsw_pwrok>; + sensor = <&temp_ambient>; + }; + }; + + usba { + compatible = "cros-ec,usba-port-enable-pins"; + /* + * sb_2 is only configured as GPIO when USB-A1 is present, + * but it's still safe to control when disabled. + * + * ILIM_SEL pins are referred to by legacy enum name, + * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on + * sub-boards that don't have USB-A so is safe to control + * regardless of system configuration. + */ + enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>; + status = "okay"; + }; + + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + chg = <&chg_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + /* + * TODO(b:211693800): port1 may not be present on some + * sub-boards. + */ + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + chg = <&chg_port1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&virtual_mux_1 &anx7483_mux_1>; + }; + usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; + + fans { + compatible = "cros-ec,fans"; + + fan_0 { + pwms = <&pwm5 5 PWM_KHZ(1) PWM_POLARITY_NORMAL>; + rpm_min = <2200>; + rpm_start = <2200>; + rpm_max = <4200>; + tach = <&tach2>; + enable_gpio = <&gpio_fan_enable>; + }; + }; + + /* + * Declare unused GPIOs so that they are shut down + * and use minimal power + */ + unused-pins { + compatible = "unused-gpios"; + unused-gpios = + <&gpio3 2 0>, + <&gpio3 3 0>, + <&gpio3 5 0>, + <&gpio3 6 0>, + <&gpio5 7 0>, + <&gpio6 0 0>, + <&gpio6 3 0>, + <&gpio6 6 0>, + <&gpio7 3 0>, + <&gpio8 3 0>, + <&gpio8 6 0>, + <&gpiob 1 0>, + <&gpiob 7 0>, + <&gpioc 7 0>, + <&gpiof 2 0>, + <&gpiof 3 0>; + }; +}; + +&thermistor_3V3_51K1_47K_4050B { + status = "okay"; +}; + +&adc_ec_vsense_pp3300_s5 { + /* + * Voltage divider on input has 47k upper and 220k lower legs with + * 2714 mV full-scale reading on the ADC. Apply the largest possible + * multiplier (without overflowing int32) to get the best possible + * approximation of the actual ratio, but derate by a factor of two to + * ensure unexpectedly high values won't overflow. + */ + mul = <(791261 / 2)>; + div = <(651975 / 2)>; +}; + +/* Set bus speeds for I2C */ +&i2c0_0 { + label = "I2C_EEPROM"; + clock-frequency = ; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c1_0 { + label = "I2C_SENSOR"; + clock-frequency = ; +}; + +&i2c3_0 { + label = "I2C_USB_C0_TCPC"; + clock-frequency = ; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + /* + * BC1.2 interrupt is shared with TCPC, so + * IRQ is not specified here and handled by + * usb_c0_interrupt. + */ + }; + + chg_port0: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&i2c5_1 { + label = "I2C_SUB_C1_TCPC"; + clock-frequency = ; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + }; + + chg_port1: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; + + anx7483_mux_1: anx7483-mux-1@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "anx7483_set_default_tuning"; + }; +}; + +&i2c7_0 { + label = "I2C_BATTERY"; + clock-frequency = ; +}; + +&pwm5_gpb7 { + drive-open-drain; +}; + +&pwm5 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm5_gpb7>; + pinctrl-names = "default"; +}; + +/* Tachometer for fan speed measurement */ +&tach2 { + status = "okay"; + pinctrl-0 = <&ta2_1_in_gp73>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; + +/* + * Declare GPIOs that have leakage current caused by board issues here. NPCX ec + * will disable their input buffers before entering deep sleep and restore them + * after waking up automatically for better power consumption. + */ +&power_leakage_io { + leak-gpios = <&gpioa 4 0 + &gpiof 1 0>; +}; diff --git a/zephyr/program/nissa/xivur/power_signals.dtsi b/zephyr/program/nissa/xivur/power_signals.dtsi new file mode 100644 index 0000000000..1d2b23069d --- /dev/null +++ b/zephyr/program/nissa/xivur/power_signals.dtsi @@ -0,0 +1,220 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + chosen { + intel-ap-pwrseq,espi = &espi0; + }; + + common-pwrseq { + compatible = "intel,ap-pwrseq"; + + sys-pwrok-delay = <10>; + all-sys-pwrgd-timeout = <20>; + }; + + pwr-en-pp5000-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP5000_S5 enable output to regulator"; + enum-name = "PWR_EN_PP5000_A"; + gpios = <&gpio4 0 0>; + output; + }; + pwr-en-pp3300-s5 { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PP3300_S5 enable output to LS"; + enum-name = "PWR_EN_PP3300_A"; + gpios = <&gpiob 6 0>; + output; + }; + pwr-pg-ec-rsmrst-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST power good from regulator"; + enum-name = "PWR_RSMRST"; + gpios = <&gpio9 4 0>; + interrupt-flags = ; + }; + pwr-ec-pch-rsmrst-odl { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "RSMRST output to PCH"; + enum-name = "PWR_EC_PCH_RSMRST"; + gpios = <&gpioa 6 0>; + output; + }; + pwr-slp-s0-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S0_L input from PCH"; + enum-name = "PWR_SLP_S0"; + gpios = <&gpio9 7 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-s3-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_S3_L input from PCH"; + enum-name = "PWR_SLP_S3"; + gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-slp-sus-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SLP_SUS_L input from PCH"; + enum-name = "PWR_SLP_SUS"; + gpios = <&gpio6 2 GPIO_ACTIVE_LOW>; + interrupt-flags = ; + }; + pwr-ec-soc-dsw-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "DSW_PWROK output to PCH"; + enum-name = "PWR_EC_SOC_DSW_PWROK"; + gpios = <&gpio6 1 0>; + output; + }; + pwr-vccst-pwrgd-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VCCST_PWRGD output to PCH"; + enum-name = "PWR_VCCST_PWRGD"; + gpios = <&gpioa 4 GPIO_OPEN_DRAIN>; + output; + }; + pwr-imvp9-vrrdy-od { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "VRRDY input from IMVP9"; + enum-name = "PWR_IMVP9_VRRDY"; + gpios = <&gpio4 3 0>; + }; + pwr-pch-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "PCH_PWROK output to PCH"; + enum-name = "PWR_PCH_PWROK"; + gpios = <&gpio7 2 GPIO_OPEN_DRAIN>; + output; + }; + pwr-ec-pch-sys-pwrok { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_PWROK output to PCH"; + enum-name = "PWR_EC_PCH_SYS_PWROK"; + gpios = <&gpio3 7 0>; + output; + }; + pwr-sys-rst-l { + compatible = "intel,ap-pwrseq-gpio"; + dbg-label = "SYS_RESET# output to PCH"; + enum-name = "PWR_SYS_RST"; + gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>; + output; + }; + pwr-slp-s4 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S4 virtual wire input from PCH"; + enum-name = "PWR_SLP_S4"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4"; + vw-invert; + }; + pwr-slp-s5 { + compatible = "intel,ap-pwrseq-vw"; + dbg-label = "SLP_S5 virtual wire input from PCH"; + enum-name = "PWR_SLP_S5"; + virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5"; + vw-invert; + }; + pwr-all-sys-pwrgd { + compatible = "intel,ap-pwrseq-external"; + dbg-label = "Combined all power good"; + enum-name = "PWR_ALL_SYS_PWRGD"; + }; + pwr-adc-pp3300 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP3300 PWROK (from ADC)"; + enum-name = "PWR_DSW_PWROK"; + trigger-high = <&cmp_pp3300_s5_high>; + trigger-low = <&cmp_pp3300_s5_low>; + }; + pwr-adc-pp1p05 { + compatible = "intel,ap-pwrseq-adc"; + dbg-label = "PP1P05 PWROK (from ADC)"; + enum-name = "PWR_PG_PP1P05"; + trigger-high = <&cmp_pp1p05_high>; + trigger-low = <&cmp_pp1p05_low>; + }; + + adc-cmp { + cmp_pp3300_s5_high: pp3300_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* + * This is 90% of nominal voltage considering voltage + * divider on ADC input. + */ + threshold-mv = <2448>; + }; + cmp_pp3300_s5_low: pp3300_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 6>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <2448>; + }; + cmp_pp1p05_high: pp1p05_high { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_GREATER"; + /* Setting at 90% of nominal voltage */ + threshold-mv = <945>; + }; + cmp_pp1p05_low: pp1p05_low { + compatible = "nuvoton,adc-cmp"; + io-channels = <&adc0 4>; + comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL"; + threshold-mv = <945>; + }; + }; +}; + +/* + * Because the power signals directly reference the GPIOs, + * the correspinding named-gpios need to have no-auto-init set. + */ +&gpio_ec_soc_dsw_pwrok { + no-auto-init; +}; +&gpio_ec_soc_pch_pwrok_od { + no-auto-init; +}; +&gpio_ec_soc_rsmrst_l { + no-auto-init; +}; +&gpio_ec_soc_sys_pwrok { + no-auto-init; +}; +&gpio_ec_soc_vccst_pwrgd_od { + no-auto-init; +}; +&gpio_en_pp3300_s5 { + no-auto-init; +}; +&gpio_en_pp5000_s5 { + no-auto-init; +}; +&gpio_imvp91_vrrdy_od { + no-auto-init; +}; +&gpio_rsmrst_pwrgd_l { + no-auto-init; +}; +&gpio_slp_s0_l { + no-auto-init; +}; +&gpio_slp_s3_l { + no-auto-init; +}; +&gpio_slp_s4_l { + no-auto-init; +}; +&gpio_slp_sus_l { + no-auto-init; +}; +&gpio_sys_rst_odl { + no-auto-init; +}; diff --git a/zephyr/program/nissa/xivur/project.conf b/zephyr/program/nissa/xivur/project.conf new file mode 100644 index 0000000000..c63cf8b41f --- /dev/null +++ b/zephyr/program/nissa/xivur/project.conf @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_BOARD_XIVUR=y +CONFIG_PLATFORM_EC_OCPC=y + +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y diff --git a/zephyr/program/nissa/xivur/project.overlay b/zephyr/program/nissa/xivur/project.overlay new file mode 100644 index 0000000000..9ca681d979 --- /dev/null +++ b/zephyr/program/nissa/xivur/project.overlay @@ -0,0 +1,14 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "../cbi.dtsi" + +#include "cbi.dtsi" +#include "generated.dtsi" +#include "keyboard.dtsi" +#include "motionsense.dtsi" +#include "overlay.dtsi" +#include "power_signals.dtsi" +#include "pwm_leds.dtsi" diff --git a/zephyr/program/nissa/xivur/pwm_leds.dtsi b/zephyr/program/nissa/xivur/pwm_leds.dtsi new file mode 100644 index 0000000000..a265a5929e --- /dev/null +++ b/zephyr/program/nissa/xivur/pwm_leds.dtsi @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_led0: pwm_led_0 { + pwms = <&pwm2 2 PWM_HZ(324) PWM_POLARITY_INVERTED>, + <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>, + <&pwm1 1 PWM_HZ(324) PWM_POLARITY_INVERTED>; + }; + }; + + cros-pwmleds { + compatible = "cros-ec,pwm-leds"; + + leds = <&pwm_led0>; + + /**/ + color-map-red = <100 0 0>; + color-map-green = < 0 100 0>; + color-map-blue = < 0 0 100>; + color-map-yellow = < 0 50 50>; + color-map-white = <100 100 100>; + color-map-amber = <100 0 0>; + + brightness-range = <0 0 100 0 0 100>; + + #address-cells = <1>; + #size-cells = <0>; + + pwm_led_0@0 { + reg = <0>; + ec-led-name = "EC_LED_ID_BATTERY_LED"; + }; + }; +}; + +/* Enable LEDs to work while CPU suspended */ + +&pwm0 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/nissa/xivur/src/charger.c b/zephyr/program/nissa/xivur/src/charger.c new file mode 100644 index 0000000000..9dadb0f42f --- /dev/null +++ b/zephyr/program/nissa/xivur/src/charger.c @@ -0,0 +1,56 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "battery.h" +#include "charger.h" +#include "charger/isl923x_public.h" +#include "console.h" +#include "extpower.h" +#include "usb_pd.h" +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +int extpower_is_present(void) +{ + int port; + int rv; + bool acok; + + for (port = 0; port < board_get_usb_pd_port_count(); port++) { + rv = raa489000_is_acok(port, &acok); + if ((rv == EC_SUCCESS) && acok) + return 1; + } + + return 0; +} + +/* + * Nivviks does not have a GPIO indicating whether extpower is present, + * so detect using the charger(s). + */ +__override void board_check_extpower(void) +{ + static int last_extpower_present; + int extpower_present = extpower_is_present(); + + if (last_extpower_present ^ extpower_present) + extpower_handle_update(extpower_present); + + last_extpower_present = extpower_present; +} + +__override void board_hibernate(void) +{ + /* Shut down the chargers */ + if (board_get_usb_pd_port_count() == 2) + raa489000_hibernate(CHARGER_SECONDARY, true); + raa489000_hibernate(CHARGER_PRIMARY, true); + LOG_INF("Charger(s) hibernated"); + cflush(); +} diff --git a/zephyr/program/nissa/xivur/src/fan.c b/zephyr/program/nissa/xivur/src/fan.c new file mode 100644 index 0000000000..840049722c --- /dev/null +++ b/zephyr/program/nissa/xivur/src/fan.c @@ -0,0 +1,43 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include +#include + +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* + * Nirwen fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + if (val != FW_FAN_PRESENT) { + /* Disable the fan */ + fan_set_count(0); + } else { + /* Configure the fan enable GPIO */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable), + GPIO_OUTPUT); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/nissa/xivur/src/form_factor.c b/zephyr/program/nissa/xivur/src/form_factor.c new file mode 100644 index 0000000000..602b22baff --- /dev/null +++ b/zephyr/program/nissa/xivur/src/form_factor.c @@ -0,0 +1,47 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include +#include + +#include "accelgyro.h" +#include "cros_cbi.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_inverted)) +#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel)) +#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro)) + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + /* + * If the firmware config indicates + * an inverted form factor, use the alternative + * rotation matrix. + */ + ret = cros_cbi_get_fw_config(FW_BASE_INVERSION, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", + FW_BASE_INVERSION); + return; + } + if (val == FW_BASE_INVERTED) { + LOG_INF("Switching to inverted base"); + motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT; + motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/nissa/xivur/src/keyboard.c b/zephyr/program/nissa/xivur/src/keyboard.c new file mode 100644 index 0000000000..2bc1d203a7 --- /dev/null +++ b/zephyr/program/nissa/xivur/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config xivur_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &xivur_kb; +} diff --git a/zephyr/program/nissa/xivur/src/led.c b/zephyr/program/nissa/xivur/src/led.c new file mode 100644 index 0000000000..9087982604 --- /dev/null +++ b/zephyr/program/nissa/xivur/src/led.c @@ -0,0 +1,51 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery LED control for nissa + */ +#include "common.h" +#include "ec_commands.h" +#include "led_common.h" +#include "led_onoff_states.h" +#include "led_pwm.h" + +__override const int led_charge_lvl_1 = 5; +__override const int led_charge_lvl_2 = 97; +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_BLUE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_AMBER, + 2 * LED_ONE_SEC }, + { EC_LED_COLOR_BLUE, + 2 * LED_ONE_SEC } }, + }; + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_BLUE: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_BLUE); + break; + case EC_LED_COLOR_AMBER: + set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER); + break; + default: /* LED_OFF and other unsupported colors */ + set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1); + break; + } +} diff --git a/zephyr/program/nissa/xivur/src/usbc.c b/zephyr/program/nissa/xivur/src/usbc.c new file mode 100644 index 0000000000..a15460a212 --- /dev/null +++ b/zephyr/program/nissa/xivur/src/usbc.c @@ -0,0 +1,277 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "charge_state_v2.h" +#include "chipset.h" +#include "hooks.h" +#include "usb_mux.h" +#include "system.h" +#include "driver/charger/isl923x_public.h" +#include "driver/retimer/anx7483_public.h" +#include "driver/tcpm/tcpci.h" +#include "driver/tcpm/raa489000.h" + +#include "nissa_common.h" + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { + { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C0_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, + { /* sub-board */ + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_USB_C1_TCPC, + .addr_flags = RAA489000_TCPC0_I2C_FLAGS, + }, + .drv = &raa489000_tcpm_drv, + /* RAA489000 implements TCPCI 2.0 */ + .flags = TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_VBUS_MONITOR, + }, +}; + +int board_is_sourcing_vbus(int port) +{ + int regval; + + tcpc_read(port, TCPC_REG_POWER_STATUS, ®val); + return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS); +} + +int board_set_active_charge_port(int port) +{ + int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT); + int i; + int old_port; + + if (!is_real_port && port != CHARGE_PORT_NONE) + return EC_ERROR_INVAL; + + old_port = charge_manager_get_active_charge_port(); + + LOG_INF("New chg p%d", port); + + /* Disable all ports. */ + if (port == CHARGE_PORT_NONE) { + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW); + raa489000_enable_asgate(i, false); + } + + return EC_SUCCESS; + } + + /* Check if port is sourcing VBUS. */ + if (board_is_sourcing_vbus(port)) { + LOG_WRN("Skip enable p%d", port); + return EC_ERROR_INVAL; + } + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) { + if (i == port) + continue; + + if (tcpc_write(i, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_LOW)) + LOG_WRN("p%d: sink path disable failed.", i); + raa489000_enable_asgate(i, false); + } + + /* + * Stop the charger IC from switching while changing ports. Otherwise, + * we can overcurrent the adapter we're switching to. (crbug.com/926056) + */ + if (old_port != CHARGE_PORT_NONE) + charger_discharge_on_ac(1); + + /* Enable requested charge port. */ + if (raa489000_enable_asgate(port, true) || + tcpc_write(port, TCPC_REG_COMMAND, + TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { + LOG_WRN("p%d: sink path enable failed.", port); + charger_discharge_on_ac(0); + return EC_ERROR_UNKNOWN; + } + + /* Allow the charger IC to begin/continue switching. */ + charger_discharge_on_ac(0); + + return EC_SUCCESS; +} + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + int regval; + + /* + * The interrupt line is shared between the TCPC and BC1.2 detector IC. + * Therefore, go out and actually read the alert registers to report the + * alert status. + */ + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) { + if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { + /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */ + if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_0; + } + } + + if (board_get_usb_pd_port_count() == 2 && + !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) { + if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { + /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */ + if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0)) + regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); + + if (regval) + status |= PD_STATUS_TCPC_ALERT_1; + } + } + + return status; +} + +void pd_power_supply_reset(int port) +{ + /* Disable VBUS */ + tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW); + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) +{ + if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return; + + raa489000_set_output_current(port, rp); +} + +int pd_set_power_supply_ready(int port) +{ + int rv; + + if (port >= CONFIG_USB_PD_PORT_MAX_COUNT) + return EC_ERROR_INVAL; + + /* Disable charging. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); + if (rv) + return rv; + + /* Our policy is not to source VBUS when the AP is off. */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + return EC_ERROR_NOT_POWERED; + + /* Provide Vbus. */ + rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH); + if (rv) + return rv; + + rv = raa489000_enable_asgate(port, true); + if (rv) + return rv; + + /* Notify host of power info change. */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); + + return EC_SUCCESS; +} + +void board_reset_pd_mcu(void) +{ + /* + * TODO(b:147316511): could send a reset command to the TCPC here + * if needed. + */ +} + +/* + * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible + * for an interrupt to be lost if one asserts the IRQ, the other does the same + * then the first releases it: there will only be one falling edge to trigger + * the interrupt, and the line will be held low. We handle this by running a + * deferred check after a falling edge to see whether the IRQ is still being + * asserted. If it is, we assume an interrupt may have been lost and we need + * to poll each chip for events again. + */ +#define USBC_INT_POLL_DELAY_US 5000 + +static void poll_c0_int(void); +DECLARE_DEFERRED(poll_c0_int); +static void poll_c1_int(void); +DECLARE_DEFERRED(poll_c1_int); + +static void usbc_interrupt_trigger(int port) +{ + schedule_deferred_pd_interrupt(port); + usb_charger_task_set_event(port, USB_CHG_EVENT_BC12); +} + +static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio, + const struct deferred_data *ud) +{ + if (!gpio_pin_get_dt(gpio)) { + usbc_interrupt_trigger(port); + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); + } +} + +static void poll_c0_int(void) +{ + poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl), + &poll_c0_int_data); +} + +static void poll_c1_int(void) +{ + poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl), + &poll_c1_int_data); +} + +void usb_interrupt(enum gpio_signal signal) +{ + int port; + const struct deferred_data *ud; + + if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) { + port = 0; + ud = &poll_c0_int_data; + } else { + port = 1; + ud = &poll_c1_int_data; + } + /* + * We've just been called from a falling edge, so there's definitely + * no lost IRQ right now. Cancel any pending check. + */ + hook_call_deferred(ud, -1); + /* Trigger polling of TCPC and BC1.2 in respective tasks */ + usbc_interrupt_trigger(port); + /* Check for lost interrupts in a bit */ + hook_call_deferred(ud, USBC_INT_POLL_DELAY_US); +} -- cgit v1.2.1 From d5593d46a9e29115339135a5ceb23ce148df8ea5 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Tue, 22 Nov 2022 12:28:14 +0000 Subject: zephyr: emul: rename the binding to be consistent Zephyr uses a -emul suffix on all emulation bindings. Rename some of the EC emul bindings so that they are consistent with upstream and the other ones we already have. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I666b74bb243da10a79dd1d0da56028c2b142d360 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4047463 Reviewed-by: Yuval Peress Code-Coverage: Zoss --- .../dts/bindings/emul/cros,anx7447-tcpc-emul.yaml | 16 ++ zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml | 16 -- zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml | 83 +++++++++++ zephyr/dts/bindings/emul/zephyr,bma255.yaml | 83 ----------- zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml | 42 ++++++ zephyr/dts/bindings/emul/zephyr,bmi.yaml | 42 ------ .../bindings/emul/zephyr,smart-battery-emul.yaml | 161 +++++++++++++++++++++ zephyr/dts/bindings/emul/zephyr,smart-battery.yaml | 161 --------------------- zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml | 44 ++++++ zephyr/dts/bindings/emul/zephyr,tcs3400.yaml | 44 ------ zephyr/dts/bindings/emul/zephyr,tusb1064-emul.yaml | 9 ++ zephyr/dts/bindings/emul/zephyr,tusb1064.yaml | 9 -- zephyr/emul/Kconfig | 8 +- zephyr/emul/emul_bma255.c | 2 +- zephyr/emul/emul_bmi.c | 2 +- zephyr/emul/emul_bmi160.c | 2 +- zephyr/emul/emul_bmi260.c | 2 +- zephyr/emul/emul_smart_battery.c | 2 +- zephyr/emul/emul_tcs3400.c | 2 +- zephyr/emul/tcpc/Kconfig | 2 +- zephyr/emul/tcpc/emul_anx7447.c | 2 +- zephyr/shim/include/usbc/tcpc_anx7447_emul.h | 2 +- zephyr/test/drivers/anx7447/tcpc_policy.dts | 2 +- zephyr/test/drivers/boards/native_posix.overlay | 12 +- zephyr/test/krabby/common.dts | 2 +- zephyr/test/vboot_efs2/boards/native_posix.overlay | 2 +- 26 files changed, 377 insertions(+), 377 deletions(-) create mode 100644 zephyr/dts/bindings/emul/cros,anx7447-tcpc-emul.yaml delete mode 100644 zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml create mode 100644 zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml delete mode 100644 zephyr/dts/bindings/emul/zephyr,bma255.yaml create mode 100644 zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml delete mode 100644 zephyr/dts/bindings/emul/zephyr,bmi.yaml create mode 100644 zephyr/dts/bindings/emul/zephyr,smart-battery-emul.yaml delete mode 100644 zephyr/dts/bindings/emul/zephyr,smart-battery.yaml create mode 100644 zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml delete mode 100644 zephyr/dts/bindings/emul/zephyr,tcs3400.yaml create mode 100644 zephyr/dts/bindings/emul/zephyr,tusb1064-emul.yaml delete mode 100644 zephyr/dts/bindings/emul/zephyr,tusb1064.yaml diff --git a/zephyr/dts/bindings/emul/cros,anx7447-tcpc-emul.yaml b/zephyr/dts/bindings/emul/cros,anx7447-tcpc-emul.yaml new file mode 100644 index 0000000000..a4b41a0cec --- /dev/null +++ b/zephyr/dts/bindings/emul/cros,anx7447-tcpc-emul.yaml @@ -0,0 +1,16 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +description: Zephyr ANX7447 emulator + +compatible: "cros,anx7447-tcpc-emul" + +include: i2c-device.yaml + +properties: + tcpc-flags: + type: int + default: 0 + description: | + TCPC configuration flags diff --git a/zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml b/zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml deleted file mode 100644 index 562485d03d..0000000000 --- a/zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -description: Zephyr ANX7447 emulator - -compatible: "cros,anx7447-emul" - -include: i2c-device.yaml - -properties: - tcpc-flags: - type: int - default: 0 - description: | - TCPC configuration flags diff --git a/zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml b/zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml new file mode 100644 index 0000000000..7017d62667 --- /dev/null +++ b/zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml @@ -0,0 +1,83 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: Zephyr BMA255 Emulator + +compatible: "zephyr,bma255-emul" + +include: base.yaml + +properties: + nvm-off-x: + type: int + required: false + default: 0 + description: Accelerometer offset of x axis stored in NVM. + + nvm-off-y: + type: int + required: false + default: 0 + description: Accelerometer offset of y axis stored in NVM. + + nvm-off-z: + type: int + required: false + default: 0 + description: Accelerometer offset of z axis stored in NVM. + + nvm-gp0: + type: int + required: false + default: 0 + description: GP0 value stored in NVM. + + nvm-gp1: + type: int + required: false + default: 0 + description: GP1 value stored in NVM. + + nvm-acc-x: + type: int + required: false + default: 0 + description: Accelerometer value of x axis used until new value is set. + + nvm-acc-y: + type: int + required: false + default: 0 + description: Accelerometer value of y axis used until new value is set. + + nvm-acc-z: + type: int + required: false + default: 0 + description: Accelerometer value of z axis used until new value is set. + + error-on-compensation-not-ready: + type: boolean + description: + Flag indicating if error should be generated when fast compensation + is started when not ready bit is set. + + error-on-ro-write: + type: boolean + description: + Flag indicating if error should be generated when read only register + is being written. + + error-on-reserved-bit-write: + type: boolean + description: + Flag indicating if error should be generated when reserved bit + is being written. + + error-on-msb-first-access: + type: boolean + description: + Flag indicating if error should be generated when MSB register of + accelerometer value is accessed before LSB and shadowing is enabled + at the same time. diff --git a/zephyr/dts/bindings/emul/zephyr,bma255.yaml b/zephyr/dts/bindings/emul/zephyr,bma255.yaml deleted file mode 100644 index 3f504e05a5..0000000000 --- a/zephyr/dts/bindings/emul/zephyr,bma255.yaml +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: Zephyr BMA255 Emulator - -compatible: "zephyr,bma255" - -include: base.yaml - -properties: - nvm-off-x: - type: int - required: false - default: 0 - description: Accelerometer offset of x axis stored in NVM. - - nvm-off-y: - type: int - required: false - default: 0 - description: Accelerometer offset of y axis stored in NVM. - - nvm-off-z: - type: int - required: false - default: 0 - description: Accelerometer offset of z axis stored in NVM. - - nvm-gp0: - type: int - required: false - default: 0 - description: GP0 value stored in NVM. - - nvm-gp1: - type: int - required: false - default: 0 - description: GP1 value stored in NVM. - - nvm-acc-x: - type: int - required: false - default: 0 - description: Accelerometer value of x axis used until new value is set. - - nvm-acc-y: - type: int - required: false - default: 0 - description: Accelerometer value of y axis used until new value is set. - - nvm-acc-z: - type: int - required: false - default: 0 - description: Accelerometer value of z axis used until new value is set. - - error-on-compensation-not-ready: - type: boolean - description: - Flag indicating if error should be generated when fast compensation - is started when not ready bit is set. - - error-on-ro-write: - type: boolean - description: - Flag indicating if error should be generated when read only register - is being written. - - error-on-reserved-bit-write: - type: boolean - description: - Flag indicating if error should be generated when reserved bit - is being written. - - error-on-msb-first-access: - type: boolean - description: - Flag indicating if error should be generated when MSB register of - accelerometer value is accessed before LSB and shadowing is enabled - at the same time. diff --git a/zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml b/zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml new file mode 100644 index 0000000000..b8b1d2551d --- /dev/null +++ b/zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml @@ -0,0 +1,42 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: Zephyr BMI Emulator + +compatible: "zephyr,bmi-emul" + +include: base.yaml + +properties: + device-model: + type: string + required: true + enum: + - BMI_EMUL_160 + - BMI_EMUL_260 + description: Model of device that is emulated. + + error-on-ro-write: + type: boolean + description: + Flag indicating if error should be generated when read only register + is being written. + + error-on-wo-read: + type: boolean + description: + Flag indicating if error should be generated when write only register + is being read. + + error-on-reserved-bit-write: + type: boolean + description: + Flag indicating if error should be generated when reserved bit + is being written. + + simulate-command-exec-time: + type: boolean + description: + Flag indicating if emulator should wait the same amount of time before + finishing command as real device would. diff --git a/zephyr/dts/bindings/emul/zephyr,bmi.yaml b/zephyr/dts/bindings/emul/zephyr,bmi.yaml deleted file mode 100644 index 6280d5cc39..0000000000 --- a/zephyr/dts/bindings/emul/zephyr,bmi.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: Zephyr BMI Emulator - -compatible: "zephyr,bmi" - -include: base.yaml - -properties: - device-model: - type: string - required: true - enum: - - BMI_EMUL_160 - - BMI_EMUL_260 - description: Model of device that is emulated. - - error-on-ro-write: - type: boolean - description: - Flag indicating if error should be generated when read only register - is being written. - - error-on-wo-read: - type: boolean - description: - Flag indicating if error should be generated when write only register - is being read. - - error-on-reserved-bit-write: - type: boolean - description: - Flag indicating if error should be generated when reserved bit - is being written. - - simulate-command-exec-time: - type: boolean - description: - Flag indicating if emulator should wait the same amount of time before - finishing command as real device would. diff --git a/zephyr/dts/bindings/emul/zephyr,smart-battery-emul.yaml b/zephyr/dts/bindings/emul/zephyr,smart-battery-emul.yaml new file mode 100644 index 0000000000..88060b01d7 --- /dev/null +++ b/zephyr/dts/bindings/emul/zephyr,smart-battery-emul.yaml @@ -0,0 +1,161 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: Zephyr Smart Battery Emulator + +compatible: "zephyr,smart-battery-emul" + +include: base.yaml + +properties: + mf-access: + type: int + required: false + default: 0 + description: Word returned on manufacturer access command. + + at-rate-full-mw-support: + type: boolean + description: + Flag indicating if AT_RATE_TIME_TO_FULL command supports mW capacity + mode. + + version: + type: string + required: false + enum: + - BATTERY_SPEC_VER_1_0 + - BATTERY_SPEC_VER_1_1 + - BATTERY_SPEC_VER_1_1_WITH_PEC + default: BATTERY_SPEC_VER_1_1_WITH_PEC + description: Version of Smart Battery. + + vscale: + type: int + required: false + default: 0 + description: Scaling of voltage. + + ipscale: + type: int + required: false + default: 0 + description: Scaling of current. + + int-charge-controller: + type: boolean + description: Flag indicating if internal charge controller is supported. + + primary-battery: + type: boolean + description: + Flag indicating if primary battery role selection is supported. + + design-mv: + type: int + required: false + default: 5000 + description: Design battery voltage in mV. + + design-cap: + type: int + required: false + default: 5000 + description: Design battery capacity in mAh. + + temperature: + type: int + required: false + default: 2930 + description: Battery temperature in 0.1 Kelvins. + + volt: + type: int + required: false + default: 5000 + description: Battery voltage in mV. + + cur: + type: int + required: false + default: 1000 + description: Current charging (> 0) or discharging (< 0) battery in mA. + + avg-cur: + type: int + required: false + default: 1000 + description: Average current from 1 minute. + + max-error: + type: int + required: false + default: 0 + description: Maximum error of commands return value in percent. + + cap: + type: int + required: false + default: 2000 + description: Capacity of the battery in mAh. + + full-cap: + type: int + required: false + default: 4000 + description: Full capacity of the battery in mAh. + + desired-charg-cur: + type: int + required: false + default: 2000 + description: Charging current requested by battery. + + desired-charg-volt: + type: int + required: false + default: 7000 + description: Charging voltage requested by battery. + + cycle-count: + type: int + required: false + default: 125 + description: Number of cycles. + + serial-number: + type: int + required: false + default: 7 + description: Serial number of battery. + + mf-name: + type: string + required: false + default: "zephyr" + description: Manufacturer name. Length has to be smaller than 32 bytes. + + dev-name: + type: string + required: false + default: "smartbat" + description: Device name. Length has to be smaller than 32 bytes. + + dev-chem: + type: string + required: false + default: "LION" + description: Device chemistry. Length has to be smaller than 32 bytes. + + mf-data: + type: string + required: false + default: "LION" + description: Manufacturer data. Length has to be smaller than 32 bytes. + + mf-info: + type: string + required: false + default: "LION" + description: Manufacturer info. Length has to be smaller than 32 bytes. diff --git a/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml b/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml deleted file mode 100644 index 4c46fd4f64..0000000000 --- a/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml +++ /dev/null @@ -1,161 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: Zephyr Smart Battery Emulator - -compatible: "zephyr,smart-battery" - -include: base.yaml - -properties: - mf-access: - type: int - required: false - default: 0 - description: Word returned on manufacturer access command. - - at-rate-full-mw-support: - type: boolean - description: - Flag indicating if AT_RATE_TIME_TO_FULL command supports mW capacity - mode. - - version: - type: string - required: false - enum: - - BATTERY_SPEC_VER_1_0 - - BATTERY_SPEC_VER_1_1 - - BATTERY_SPEC_VER_1_1_WITH_PEC - default: BATTERY_SPEC_VER_1_1_WITH_PEC - description: Version of Smart Battery. - - vscale: - type: int - required: false - default: 0 - description: Scaling of voltage. - - ipscale: - type: int - required: false - default: 0 - description: Scaling of current. - - int-charge-controller: - type: boolean - description: Flag indicating if internal charge controller is supported. - - primary-battery: - type: boolean - description: - Flag indicating if primary battery role selection is supported. - - design-mv: - type: int - required: false - default: 5000 - description: Design battery voltage in mV. - - design-cap: - type: int - required: false - default: 5000 - description: Design battery capacity in mAh. - - temperature: - type: int - required: false - default: 2930 - description: Battery temperature in 0.1 Kelvins. - - volt: - type: int - required: false - default: 5000 - description: Battery voltage in mV. - - cur: - type: int - required: false - default: 1000 - description: Current charging (> 0) or discharging (< 0) battery in mA. - - avg-cur: - type: int - required: false - default: 1000 - description: Average current from 1 minute. - - max-error: - type: int - required: false - default: 0 - description: Maximum error of commands return value in percent. - - cap: - type: int - required: false - default: 2000 - description: Capacity of the battery in mAh. - - full-cap: - type: int - required: false - default: 4000 - description: Full capacity of the battery in mAh. - - desired-charg-cur: - type: int - required: false - default: 2000 - description: Charging current requested by battery. - - desired-charg-volt: - type: int - required: false - default: 7000 - description: Charging voltage requested by battery. - - cycle-count: - type: int - required: false - default: 125 - description: Number of cycles. - - serial-number: - type: int - required: false - default: 7 - description: Serial number of battery. - - mf-name: - type: string - required: false - default: "zephyr" - description: Manufacturer name. Length has to be smaller than 32 bytes. - - dev-name: - type: string - required: false - default: "smartbat" - description: Device name. Length has to be smaller than 32 bytes. - - dev-chem: - type: string - required: false - default: "LION" - description: Device chemistry. Length has to be smaller than 32 bytes. - - mf-data: - type: string - required: false - default: "LION" - description: Manufacturer data. Length has to be smaller than 32 bytes. - - mf-info: - type: string - required: false - default: "LION" - description: Manufacturer info. Length has to be smaller than 32 bytes. diff --git a/zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml b/zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml new file mode 100644 index 0000000000..8c33331b7a --- /dev/null +++ b/zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml @@ -0,0 +1,44 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +description: Zephyr ALS TCS3400 light sensor i2c emulator + +compatible: "zephyr,tcs3400-emul" + +include: base.yaml + +properties: + device-id: + type: string + required: false + enum: + - TCS340015_DEVICE_ID + - TCS340037_DEVICE_ID + default: TCS340015_DEVICE_ID + description: Device ID that is set in the register. + + revision: + type: int + required: false + default: 0 + description: Wafer die revision level that is set in the register. + + error-on-ro-write: + type: boolean + description: + Flag indicating if error should be generated when read only register + is being written. + + error-on-reserved-bit-write: + type: boolean + description: + Flag indicating if error should be generated when reserved bit + is being written. + + error-on-msb-first-access: + type: boolean + description: + Flag indicating if error should be generated when MSB register of + accelerometer value is accessed before LSB and shadowing is enabled + at the same time. diff --git a/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml b/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml deleted file mode 100644 index f214a21064..0000000000 --- a/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -description: Zephyr ALS TCS3400 light sensor i2c emulator - -compatible: "zephyr,tcs3400" - -include: base.yaml - -properties: - device-id: - type: string - required: false - enum: - - TCS340015_DEVICE_ID - - TCS340037_DEVICE_ID - default: TCS340015_DEVICE_ID - description: Device ID that is set in the register. - - revision: - type: int - required: false - default: 0 - description: Wafer die revision level that is set in the register. - - error-on-ro-write: - type: boolean - description: - Flag indicating if error should be generated when read only register - is being written. - - error-on-reserved-bit-write: - type: boolean - description: - Flag indicating if error should be generated when reserved bit - is being written. - - error-on-msb-first-access: - type: boolean - description: - Flag indicating if error should be generated when MSB register of - accelerometer value is accessed before LSB and shadowing is enabled - at the same time. diff --git a/zephyr/dts/bindings/emul/zephyr,tusb1064-emul.yaml b/zephyr/dts/bindings/emul/zephyr,tusb1064-emul.yaml new file mode 100644 index 0000000000..3cab1dd5a6 --- /dev/null +++ b/zephyr/dts/bindings/emul/zephyr,tusb1064-emul.yaml @@ -0,0 +1,9 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +description: Zephyr TUSB1064 Emulator + +compatible: "zephyr,tusb1064-emul" + +include: "ti,tusb1064.yaml" diff --git a/zephyr/dts/bindings/emul/zephyr,tusb1064.yaml b/zephyr/dts/bindings/emul/zephyr,tusb1064.yaml deleted file mode 100644 index 3cab1dd5a6..0000000000 --- a/zephyr/dts/bindings/emul/zephyr,tusb1064.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -description: Zephyr TUSB1064 Emulator - -compatible: "zephyr,tusb1064-emul" - -include: "ti,tusb1064.yaml" diff --git a/zephyr/emul/Kconfig b/zephyr/emul/Kconfig index 20b2d984f9..d2a0e8b4f1 100644 --- a/zephyr/emul/Kconfig +++ b/zephyr/emul/Kconfig @@ -14,7 +14,7 @@ config EMUL_COMMON_I2C config EMUL_SMART_BATTERY bool "Smart Battery emulator" default y - depends on DT_HAS_ZEPHYR_SMART_BATTERY_ENABLED + depends on DT_HAS_ZEPHYR_SMART_BATTERY_EMUL_ENABLED select EMUL_COMMON_I2C help Enable the Smart Battery emulator. This driver use emulated I2C bus. @@ -22,7 +22,7 @@ config EMUL_SMART_BATTERY config EMUL_BMA255 bool "BMA255 emulator" default y - depends on DT_HAS_ZEPHYR_BMA255_ENABLED + depends on DT_HAS_ZEPHYR_BMA255_EMUL_ENABLED select EMUL_COMMON_I2C help Enable the BMA255 emulator. This driver use emulated I2C bus. @@ -50,7 +50,7 @@ config EMUL_PPC_SYV682X config EMUL_BMI bool "BMI emulator" default y - depends on DT_HAS_ZEPHYR_BMI_ENABLED + depends on DT_HAS_ZEPHYR_BMI_EMUL_ENABLED select EMUL_COMMON_I2C help Enable the BMI emulator. This driver use emulated I2C bus. @@ -60,7 +60,7 @@ config EMUL_BMI config EMUL_TCS3400 bool "TCS3400 emulator" default y - depends on DT_HAS_ZEPHYR_TCS3400_ENABLED + depends on DT_HAS_ZEPHYR_TCS3400_EMUL_ENABLED select EMUL_COMMON_I2C help Enable the TCS3400 light sensor. This driver use emulated I2C bus. diff --git a/zephyr/emul/emul_bma255.c b/zephyr/emul/emul_bma255.c index c563937561..2afe1f722e 100644 --- a/zephyr/emul/emul_bma255.c +++ b/zephyr/emul/emul_bma255.c @@ -14,7 +14,7 @@ #include #include -#define DT_DRV_COMPAT zephyr_bma255 +#define DT_DRV_COMPAT zephyr_bma255_emul #define LOG_LEVEL CONFIG_I2C_LOG_LEVEL LOG_MODULE_REGISTER(emul_bma255); diff --git a/zephyr/emul/emul_bmi.c b/zephyr/emul/emul_bmi.c index 99a06ec00c..d0f5691402 100644 --- a/zephyr/emul/emul_bmi.c +++ b/zephyr/emul/emul_bmi.c @@ -17,7 +17,7 @@ #include #include -#define DT_DRV_COMPAT zephyr_bmi +#define DT_DRV_COMPAT zephyr_bmi_emul #define LOG_LEVEL CONFIG_I2C_LOG_LEVEL LOG_MODULE_REGISTER(emul_bmi); diff --git a/zephyr/emul/emul_bmi160.c b/zephyr/emul/emul_bmi160.c index 1b1991a24d..8b3042e2ff 100644 --- a/zephyr/emul/emul_bmi160.c +++ b/zephyr/emul/emul_bmi160.c @@ -13,7 +13,7 @@ #include #include -#define DT_DRV_COMPAT zephyr_bmi +#define DT_DRV_COMPAT zephyr_bmi_emul #define LOG_LEVEL CONFIG_I2C_LOG_LEVEL LOG_MODULE_REGISTER(emul_bmi160); diff --git a/zephyr/emul/emul_bmi260.c b/zephyr/emul/emul_bmi260.c index 2c93e1c2ea..d62b51ebfa 100644 --- a/zephyr/emul/emul_bmi260.c +++ b/zephyr/emul/emul_bmi260.c @@ -13,7 +13,7 @@ #include #include -#define DT_DRV_COMPAT zephyr_bmi +#define DT_DRV_COMPAT zephyr_bmi_emul #define LOG_LEVEL CONFIG_I2C_LOG_LEVEL LOG_MODULE_REGISTER(emul_bmi260); diff --git a/zephyr/emul/emul_smart_battery.c b/zephyr/emul/emul_smart_battery.c index 7ad4ba41bc..acada754d7 100644 --- a/zephyr/emul/emul_smart_battery.c +++ b/zephyr/emul/emul_smart_battery.c @@ -16,7 +16,7 @@ #include #include -#define DT_DRV_COMPAT zephyr_smart_battery +#define DT_DRV_COMPAT zephyr_smart_battery_emul #define LOG_LEVEL CONFIG_I2C_LOG_LEVEL LOG_MODULE_REGISTER(smart_battery); diff --git a/zephyr/emul/emul_tcs3400.c b/zephyr/emul/emul_tcs3400.c index a9cbc2a1dc..0266fe2998 100644 --- a/zephyr/emul/emul_tcs3400.c +++ b/zephyr/emul/emul_tcs3400.c @@ -15,7 +15,7 @@ #include #include -#define DT_DRV_COMPAT zephyr_tcs3400 +#define DT_DRV_COMPAT zephyr_tcs3400_emul #define LOG_LEVEL CONFIG_I2C_LOG_LEVEL LOG_MODULE_REGISTER(emul_tcs); diff --git a/zephyr/emul/tcpc/Kconfig b/zephyr/emul/tcpc/Kconfig index 6d6c8cba00..147f267113 100644 --- a/zephyr/emul/tcpc/Kconfig +++ b/zephyr/emul/tcpc/Kconfig @@ -24,7 +24,7 @@ source "subsys/logging/Kconfig.template.log_config" config EMUL_ANX7447 bool "Analogix ANX7447 emulator" default y - depends on DT_HAS_CROS_ANX7447_EMUL_ENABLED + depends on DT_HAS_CROS_ANX7447_TCPC_EMUL_ENABLED help Enable emulator for ANX7447 of TCPM. This emulator is extension for TCPCI emulator. ANX7447 specific API is available in diff --git a/zephyr/emul/tcpc/emul_anx7447.c b/zephyr/emul/tcpc/emul_anx7447.c index 9f92bf8ab1..fb15e2eb4e 100644 --- a/zephyr/emul/tcpc/emul_anx7447.c +++ b/zephyr/emul/tcpc/emul_anx7447.c @@ -15,7 +15,7 @@ #include #include -#define DT_DRV_COMPAT cros_anx7447_emul +#define DT_DRV_COMPAT cros_anx7447_tcpc_emul LOG_MODULE_REGISTER(anx7447_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); diff --git a/zephyr/shim/include/usbc/tcpc_anx7447_emul.h b/zephyr/shim/include/usbc/tcpc_anx7447_emul.h index f8ca60de6e..3367286dd9 100644 --- a/zephyr/shim/include/usbc/tcpc_anx7447_emul.h +++ b/zephyr/shim/include/usbc/tcpc_anx7447_emul.h @@ -7,7 +7,7 @@ #include -#define ANX7447_EMUL_COMPAT cros_anx7447_emul +#define ANX7447_EMUL_COMPAT cros_anx7447_tcpc_emul #define TCPC_CONFIG_ANX7447_EMUL(id) \ { \ diff --git a/zephyr/test/drivers/anx7447/tcpc_policy.dts b/zephyr/test/drivers/anx7447/tcpc_policy.dts index 9126d55e61..6bdae81e73 100644 --- a/zephyr/test/drivers/anx7447/tcpc_policy.dts +++ b/zephyr/test/drivers/anx7447/tcpc_policy.dts @@ -18,7 +18,7 @@ status="okay"; anx7447_emul: anx7447_emul@2c { - compatible = "cros,anx7447-emul"; + compatible = "cros,anx7447-tcpc-emul"; reg = <0x2c>; tcpc-flags = <( TCPC_FLAGS_VBUS_MONITOR | diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay index fa427c30f5..1f92686c33 100644 --- a/zephyr/test/drivers/boards/native_posix.overlay +++ b/zephyr/test/drivers/boards/native_posix.overlay @@ -815,7 +815,7 @@ reg = <0x400 4>; tcs_emul: tcs@39 { - compatible = "zephyr,tcs3400"; + compatible = "zephyr,tcs3400-emul"; reg = <0x39>; error-on-ro-write; error-on-reserved-bit-write; @@ -823,7 +823,7 @@ }; accel_bmi160: bmi160@68 { - compatible = "zephyr,bmi"; + compatible = "zephyr,bmi-emul"; reg = <0x68>; device-model = "BMI_EMUL_160"; error-on-ro-write; @@ -1078,7 +1078,7 @@ }; battery: sb@b { - compatible = "zephyr,smart-battery"; + compatible = "zephyr,smart-battery-emul"; reg = <0xb>; cycle-count = <99>; version = "BATTERY_SPEC_VER_1_1_WITH_PEC"; @@ -1090,7 +1090,7 @@ }; battery2: sb@3a { - compatible = "zephyr,smart-battery"; + compatible = "zephyr,smart-battery-emul"; reg = <0x3a>; cycle-count = <99>; version = "BATTERY_SPEC_VER_1_1_WITH_PEC"; @@ -1102,7 +1102,7 @@ }; bma_emul: bma@18 { - compatible = "zephyr,bma255"; + compatible = "zephyr,bma255-emul"; reg = <0x18>; error-on-compensation-not-ready; error-on-ro-write; @@ -1111,7 +1111,7 @@ }; accel_bmi260: bmi260@68 { - compatible = "zephyr,bmi"; + compatible = "zephyr,bmi-emul"; reg = <0x68>; device-model = "BMI_EMUL_260"; error-on-ro-write; diff --git a/zephyr/test/krabby/common.dts b/zephyr/test/krabby/common.dts index 8f7c6c114d..9e94392561 100644 --- a/zephyr/test/krabby/common.dts +++ b/zephyr/test/krabby/common.dts @@ -105,7 +105,7 @@ }; battery: sb@b { - compatible = "zephyr,smart-battery"; + compatible = "zephyr,smart-battery-emul"; reg = <0xb>; cycle-count = <99>; version = "BATTERY_SPEC_VER_1_1_WITH_PEC"; diff --git a/zephyr/test/vboot_efs2/boards/native_posix.overlay b/zephyr/test/vboot_efs2/boards/native_posix.overlay index fa6d46e135..83b9e9b365 100644 --- a/zephyr/test/vboot_efs2/boards/native_posix.overlay +++ b/zephyr/test/vboot_efs2/boards/native_posix.overlay @@ -126,7 +126,7 @@ &i2c0 { battery: sb@b { - compatible = "zephyr,smart-battery"; + compatible = "zephyr,smart-battery-emul"; reg = <0xb>; cycle-count = <99>; version = "BATTERY_SPEC_VER_1_1_WITH_PEC"; -- cgit v1.2.1 From a06a7867af97751cf9de0e348758fb39d8306502 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Mon, 28 Nov 2022 23:36:18 -0700 Subject: zephyr: exclude non posix logic from panic_output The code that's non posix cannot be tested with current infrastructure. Remove it from the coverage reports. BRANCH=none BUG=none TEST=twister -C Change-Id: Ic4725334ac7dad893d35bb97bed1c9757dc2bd72 Signed-off-by: Yuval Peress Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062993 Reviewed-by: Aaron Massey Commit-Queue: Aaron Massey Code-Coverage: Zoss --- common/panic_output.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/panic_output.c b/common/panic_output.c index a5bba9d184..55d551f548 100644 --- a/common/panic_output.c +++ b/common/panic_output.c @@ -175,8 +175,10 @@ uintptr_t get_panic_data_start(void) if (IS_ENABLED(CONFIG_BOARD_NATIVE_POSIX)) return (uintptr_t)pdata_ptr; + /* LCOV_EXCL_START - Can't cover non posix lines (yet) */ return ((uintptr_t)CONFIG_PANIC_DATA_BASE + CONFIG_PANIC_DATA_SIZE - pdata_ptr->struct_size); + /* LCOV_EXCL_STOP */ } static uint32_t get_panic_data_size(void) @@ -199,6 +201,7 @@ struct panic_data *get_panic_data_write(void) return pdata_ptr; } #else +/* LCOV_EXCL_START - Can't cover non posix lines (yet) */ struct panic_data *get_panic_data_write(void) { /* @@ -292,6 +295,7 @@ struct panic_data *get_panic_data_write(void) return pdata_ptr; } +/* LCOV_EXCL_STOP */ #endif /* CONFIG_BOARD_NATIVE_POSIX */ static void panic_init(void) -- cgit v1.2.1 From 234a87ae2d1f564c98df2f70f00b2b226528feaf Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Mon, 28 Nov 2022 17:08:24 -0700 Subject: tcpci: Add FRS enable to driver structure Use the generic FRS enable driver function in the generic TCPCI driver. BUG=b:260630630 TEST=twister -s zephyr/test/drivers/drivers.usbc_frs BRANCH=none Change-Id: I711fb41569d477f1dad3d14fa18a7b7f8f217ce4 Signed-off-by: Abe Levkoy Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4063186 Reviewed-by: Diana Z Code-Coverage: Zoss --- driver/tcpm/tcpci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index ffd7fa3a97..007d2aa2e6 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -1889,6 +1889,9 @@ const struct tcpm_drv tcpci_tcpm_drv = { .set_src_ctrl = &tcpci_tcpm_set_src_ctrl, #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &tcpci_enter_low_power_mode, +#endif +#ifdef CONFIG_USB_PD_FRS_TCPC + .set_frs_enable = &tcpci_tcpc_fast_role_swap_enable, #endif .set_bist_test_mode = &tcpci_set_bist_test_mode, .get_bist_test_mode = &tcpci_get_bist_test_mode, -- cgit v1.2.1 From f8ac295d745a9316f087a3b8a991e80d10103764 Mon Sep 17 00:00:00 2001 From: Andrea Grandi Date: Mon, 28 Nov 2022 11:59:29 -0800 Subject: test: Add const to functions of benchmark.h BUG=b:246366702 BRANCH=none TEST=test/run_device_tests.py -b bloonchipper -t benchmark TEST=make run-benchmark Signed-off-by: Andrea Grandi Change-Id: I73bacbd76194055d79ca3a250a4fab6d0c67ff4d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062574 Reviewed-by: Bobby Casey Code-Coverage: Zoss --- include/benchmark.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/benchmark.h b/include/benchmark.h index f9c9a1afcd..d2fcc9388c 100644 --- a/include/benchmark.h +++ b/include/benchmark.h @@ -115,7 +115,7 @@ template class Benchmark { return result; } - void print_results() + void print_results() const { print_header(); for (int i = 0; i < num_results_; ++i) @@ -128,7 +128,7 @@ template class Benchmark { int num_results_ = 0; /* Print table header with column names */ - void print_header() + void print_header() const { constexpr char kSeparator[] = "--------------------------"; @@ -142,7 +142,7 @@ template class Benchmark { } /* Print a single benchmark result */ - int print_result(const BenchmarkResult &result) + int print_result(const BenchmarkResult &result) const { ccprintf("%16s | %15u | %13u | %13u | %13u | %13u\n", result.name.data(), options_.num_iterations, -- cgit v1.2.1 From 1350988ef5d4b75366c8bd0bd54bfb7bf041c600 Mon Sep 17 00:00:00 2001 From: Mark Hasemeyer Date: Mon, 21 Nov 2022 21:40:47 -0700 Subject: test: math: Support native posix fpu tests The floating point math tests fail to build if PLATFORM_EC_FPU is enabled on a native posix board. Include the math library to support fpu tests for native posix builds. BUG=b:217926701 BRANCH=none TEST=twister -T zephyr/test/math/ Signed-off-by: Mark Hasemeyer Change-Id: I2cc5d2c22d182d8b1f6ca66fff68c0a5da0c24cd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049381 Code-Coverage: Zoss Reviewed-by: Keith Short --- zephyr/shim/include/fpu.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zephyr/shim/include/fpu.h b/zephyr/shim/include/fpu.h index d1e4460827..02e6a7c5f4 100644 --- a/zephyr/shim/include/fpu.h +++ b/zephyr/shim/include/fpu.h @@ -55,6 +55,8 @@ static inline float fabsf(float v) __asm__("fabs.s %0, %1" : "=f"(abs) : "f"(v)); return abs; } +#elif CONFIG_BOARD_NATIVE_POSIX +#include #else #error "Unsupported core: please add an implementation" #endif -- cgit v1.2.1 From b31068ff225f5e61460a4bd09c406327b91f1443 Mon Sep 17 00:00:00 2001 From: Mark Hasemeyer Date: Mon, 21 Nov 2022 15:18:01 -0700 Subject: zephyr: Remove CONFIG_PLATFORM_EC_FPU Remove CONFIG_PLATFORM_EC_FPU. Use Zephyr's CONFIG_FPU option instead. BUG=b:217926701 BRANCH=none TEST=twister -T zephyr/test/ TEST=zmake compare-builds -a Signed-off-by: Mark Hasemeyer Change-Id: Icd0fdbc440f0dd574b75bf5ca0f1750f1e858b40 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049382 Code-Coverage: Zoss Reviewed-by: Keith Short --- util/config_allowed.txt | 1 + zephyr/Kconfig | 10 ---------- zephyr/shim/include/fpu.h | 4 ++-- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/util/config_allowed.txt b/util/config_allowed.txt index 033439a022..f7e20b379c 100644 --- a/util/config_allowed.txt +++ b/util/config_allowed.txt @@ -407,6 +407,7 @@ CONFIG_FLASH_WRITE_SIZE CONFIG_FMAP CONFIG_FOO CONFIG_FORCE_CONSOLE_RESUME +CONFIG_FPU CONFIG_FPU_WARNINGS CONFIG_FP_SENSOR_ELAN515 CONFIG_FP_SENSOR_ELAN80 diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 9e04f4a679..6b0a512328 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -349,16 +349,6 @@ config PLATFORM_EC_FLASH_CROS e.g. to support auto-update. Various write-protection features are also provided. -config PLATFORM_EC_FPU - bool "Support floating point" - depends on FPU && (CPU_CORTEX_M || RISCV) && !NEWLIB_LIBC - default y - help - This enables support for floating point. This is generally already - provided in Zephyr, but the EC side expects a few functions to be - available which are not available with Zephyr's minimal lib: sqrtf() - and fabsf(). Enabling this options defines them. - config PLATFORM_EC_HOOKS bool "Hooks and deferred compatibility shim" default y diff --git a/zephyr/shim/include/fpu.h b/zephyr/shim/include/fpu.h index 02e6a7c5f4..20df108b87 100644 --- a/zephyr/shim/include/fpu.h +++ b/zephyr/shim/include/fpu.h @@ -16,7 +16,7 @@ * This code is taken from core/cortex-m/include/fpu.h */ -#ifdef CONFIG_PLATFORM_EC_FPU +#ifdef CONFIG_FPU /* Implementation for Cortex-M */ #ifdef CONFIG_CPU_CORTEX_M @@ -61,6 +61,6 @@ static inline float fabsf(float v) #error "Unsupported core: please add an implementation" #endif -#endif /* CONFIG_PLATFORM_EC_FPU */ +#endif /* CONFIG_FPU */ #endif /* __CROS_EC_MATH_H */ -- cgit v1.2.1 From 01be95eee0d625e4b8a194f6664d2bae20765355 Mon Sep 17 00:00:00 2001 From: Yu-An Chen Date: Wed, 23 Nov 2022 15:13:18 +0800 Subject: zephyr: pcf85063a: Support oscillator capacitor selection Support to select the internal oscillator capacitor to 12.5 pF for PCF85063A, default setting is 7 pF. BUG=b:260165217 BRANCH=none TEST=zmake build evoker LOW_COVERAGE_REASON=RTC driver currently has no tests Signed-off-by: Yu-An Chen Change-Id: I3418adb08fb4f56bba06a0844acec7806b2bc35d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050010 Commit-Queue: Wai-Hong Tam Reviewed-by: Bob Moragues Code-Coverage: Zoss Reviewed-by: Sam Hurst --- zephyr/drivers/cros_rtc/Kconfig | 7 +++++++ zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c | 10 ++++++++++ zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h | 1 + 3 files changed, 18 insertions(+) diff --git a/zephyr/drivers/cros_rtc/Kconfig b/zephyr/drivers/cros_rtc/Kconfig index fb84416d70..2f064b4db8 100644 --- a/zephyr/drivers/cros_rtc/Kconfig +++ b/zephyr/drivers/cros_rtc/Kconfig @@ -45,4 +45,11 @@ config CROS_RTC_RENESAS_IDT1337AG endchoice # CROS_RTC_TYPE +config PLATFORM_EC_PCF85063A_CAP_SEL + bool "Set CAP_SEL of PCF85063A" + depends on CROS_RTC_NXP_PCF85063A + help + This option select the internal oscillator capacitor to 12.5 pF, + default is 7 pF. + endif # PLATFORM_EC_RTC diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c index 34c2cbe0a7..298c8cd64f 100644 --- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c +++ b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c @@ -363,6 +363,16 @@ static int nxp_rtc_pcf85063a_init(const struct device *dev) } } +#ifdef CONFIG_PLATFORM_EC_PCF85063A_CAP_SEL + ret = pcf85063a_write_reg(dev, REG_CONTROL_1, + (CONTROL_1_DEFAULT_VALUE | CAP_SEL)); + + if (ret < 0) { + LOG_ERR("PCF85063A set CAP_SEL Fail!"); + return ret; + } +#endif + /* * Read Seconds register and check if oscillator is stopped. * If so, clear the bit. diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h index 54b1fbd2ea..c0139db631 100644 --- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h +++ b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h @@ -10,6 +10,7 @@ #define SOFT_RESET 0x58 #define CONTROL_1_DEFAULT_VALUE 0 #define OS_BIT 0x80 +#define CAP_SEL 0x01 #define DISABLE_ALARM 0x80 #define ENABLE_ALARM_INTERRUPT 0x80 #define RTC_STOP_CLOCKS 0x20 -- cgit v1.2.1 From f67381c09cbea0089fd618712aa1d2fbb0e01d7c Mon Sep 17 00:00:00 2001 From: Al Semjonovs Date: Tue, 22 Nov 2022 15:41:26 -0700 Subject: zephyr: test pd_log_recv_vdm Validate log is captured BUG=None BRANCH=NONE TEST=./twister -T zephyr/test/drivers Signed-off-by: Al Semjonovs Change-Id: Ic8edb5994bf3a6f12a9fb7a2d222d98813c7d3f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049885 Reviewed-by: Tristan Honscheid Code-Coverage: Zoss --- zephyr/test/drivers/host_cmd/src/pd_log.c | 33 ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/zephyr/test/drivers/host_cmd/src/pd_log.c b/zephyr/test/drivers/host_cmd/src/pd_log.c index 6b5ffc197d..819f020890 100644 --- a/zephyr/test/drivers/host_cmd/src/pd_log.c +++ b/zephyr/test/drivers/host_cmd/src/pd_log.c @@ -7,6 +7,7 @@ #include "host_command.h" #include "test/drivers/test_state.h" #include "usb_pd.h" +#include "util.h" #include #include @@ -19,6 +20,14 @@ */ #define MAX_EVENT_LOG_ENTRY_SIZE (sizeof(struct event_log_entry) + 16) +/** + * @brief This is the maximum size of a response pd log entry. + * + * Each entry must contain some common data + up to 16 bytes of additional type + * specific data. + */ +#define MAX_RESPONSE_PD_LOG_ENTRY_SIZE (sizeof(struct ec_response_pd_log) + 16) + /** * @brief The size of the PD log entry data * @@ -120,7 +129,7 @@ ZTEST_USER_F(pd_log, test_mcu_connect) ZTEST_USER_F(pd_log, test_read_log_entry) { - uint8_t response_buffer[sizeof(struct ec_response_pd_log) + 16]; + uint8_t response_buffer[MAX_RESPONSE_PD_LOG_ENTRY_SIZE]; struct ec_response_pd_log *response = (struct ec_response_pd_log *)response_buffer; struct host_cmd_handler_args args = @@ -133,3 +142,25 @@ ZTEST_USER_F(pd_log, test_read_log_entry) zassert_equal(sizeof(struct event_log_entry), args.response_size, NULL); zassert_equal(PD_EVENT_NO_ENTRY, response->type, NULL); } + +ZTEST_USER_F(pd_log, test_log_recv_vdm) +{ + uint8_t response_buffer[MAX_RESPONSE_PD_LOG_ENTRY_SIZE]; + uint32_t *payload = (uint32_t *)response_buffer; + struct ec_response_pd_log *response = + (struct ec_response_pd_log *)&payload[1]; + + memset(response_buffer, 0, sizeof(response_buffer)); + payload[0] |= VDO_SRC_RESPONDER; + response->type = PD_EVENT_MCU_CONNECT; + response->size_port = 8; + int cnt = DIV_ROUND_UP(response->size_port, sizeof(uint32_t)) + 2; + + pd_log_recv_vdm(0, cnt, payload); + + (void)log_dequeue_event(&fixture->log_entry); + + zassert_equal(response->type, fixture->log_entry.type, + "type=%d, received=%d", response->type, + fixture->log_entry.type); +} -- cgit v1.2.1 From 9a8d82d6dd9aadfdfb790e9af8ee3f5663bbbdeb Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Wed, 23 Nov 2022 13:30:51 -0700 Subject: ec: IWYU Add missing includes There are some circular include problems here also. Add "config.h" for CONFIG_ZEPHYR. Add for DT_NODE_EXISTS Add for size_t Add for ssize_t Add "gpio_signal.h" for enum gpio_signal BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: Ifbadcba90c2c0774713dc7ed3992e58f1d15d70d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052766 Reviewed-by: Tom Hughes Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Reviewed-by: Yuval Peress Auto-Submit: Jeremy Bettis Code-Coverage: Zoss --- driver/accel_bma4xx.h | 5 +++++ driver/fingerprint/fpc/bep/fpc_sensor_spi.h | 3 ++- driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/driver/accel_bma4xx.h b/driver/accel_bma4xx.h index 0e5c24e8aa..778150e30a 100644 --- a/driver/accel_bma4xx.h +++ b/driver/accel_bma4xx.h @@ -8,6 +8,8 @@ #ifndef __CROS_EC_ACCEL_BMA4XX_H #define __CROS_EC_ACCEL_BMA4XX_H +#include "config.h" + #define BMA4_I2C_ADDR_PRIMARY 0x18 #define BMA4_I2C_ADDR_SECONDARY 0x19 #define BMA4_I2C_BMM150_ADDR 0x10 @@ -194,6 +196,8 @@ extern const struct accelgyro_drv bma4_accel_drv; #if defined(CONFIG_ZEPHYR) +#include + #if DT_NODE_EXISTS(DT_ALIAS(bma4xx_int)) /* * Get the motion sensor ID of the BMA4xx sensor that generates the interrupt. @@ -210,6 +214,7 @@ extern const struct accelgyro_drv bma4_accel_drv; #define CONFIG_ACCEL_BMA4XX_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(bma4xx_int))) +#include "gpio_signal.h" void bma4xx_interrupt(enum gpio_signal signal); #endif /* DT_NODE_EXISTS */ #endif /* CONFIG_ZEPHYR */ diff --git a/driver/fingerprint/fpc/bep/fpc_sensor_spi.h b/driver/fingerprint/fpc/bep/fpc_sensor_spi.h index ad7e5411d8..015bc03dae 100644 --- a/driver/fingerprint/fpc/bep/fpc_sensor_spi.h +++ b/driver/fingerprint/fpc/bep/fpc_sensor_spi.h @@ -14,8 +14,9 @@ * fingerprint sensor. */ -#include #include +#include +#include typedef bool (*fpc_wfi_check_t)(void); diff --git a/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h b/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h index 7dda6d46de..834f7394e4 100644 --- a/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h +++ b/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h @@ -5,8 +5,11 @@ #ifndef BIOD_BIO_ALGORITHM_H_ #define BIOD_BIO_ALGORITHM_H_ +#include #include +#include + enum bio_algorithm_type { BIO_ALGORITHM_FINGERPRINT, BIO_ALGORITHM_IRIS, -- cgit v1.2.1 From 1b359bdd91da15ea25aaffd0d940ff63b9d72bc5 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 15:03:23 -0700 Subject: include: Sort header files Sort all includes in include with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis Change-Id: Ic23f440ebd93519e4341423cf6cb7a298620cbfe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049883 Code-Coverage: Zoss Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Reviewed-by: Tristan Honscheid --- include/accelgyro.h | 2 +- include/battery_fuel_gauge.h | 1 + include/benchmark.h | 7 ++++--- include/bluetooth_le_ll.h | 2 +- include/body_detection.h | 2 +- include/button.h | 2 +- include/charge_state.h | 2 +- include/charge_state_v2.h | 4 ++-- include/common.h | 7 ++++--- include/console.h | 1 + include/dps.h | 4 ++-- include/driver/accelgyro_bmi260.h | 2 +- include/driver/accelgyro_bmi_common.h | 2 +- include/driver/retimer/bb_retimer.h | 2 +- include/ec_ec_comm_client.h | 3 ++- include/ec_ec_comm_server.h | 3 ++- include/flash_log.h | 2 +- include/fpsensor.h | 3 ++- include/fpsensor_crypto.h | 4 ++-- include/fpsensor_state.h | 7 +++---- include/gpio.h | 3 ++- include/gpio_list.h | 4 ++-- include/host_command.h | 2 +- include/i2c_bitbang.h | 4 ++-- include/keyboard_8042.h | 2 +- include/keyboard_8042_sharedlib.h | 4 ++-- include/keyboard_protocol.h | 2 +- include/keyboard_raw.h | 4 ++-- include/mag_cal.h | 4 ++-- include/math_util.h | 4 +++- include/mock/fpsensor_state_mock.h | 6 +++--- include/mock/tcpc_mock.h | 2 +- include/mock/usb_pe_sm_mock.h | 2 +- include/mock/usb_tc_sm_mock.h | 2 +- include/newton_fit.h | 2 +- include/panic.h | 7 ++++--- include/printf.h | 5 +++-- include/pwm.h | 4 ++-- include/queue_policies.h | 2 +- include/rgb_keyboard.h | 4 ++-- include/rma_auth.h | 4 ++-- include/shared_mem.h | 1 + include/stillness_detector.h | 1 + include/system.h | 4 ++-- include/task.h | 3 ++- include/test_util.h | 3 ++- include/tests/enum_strings.h | 2 +- include/trng.h | 3 ++- include/uart.h | 3 ++- include/update_fw.h | 4 ++-- include/usb_dp_alt_mode.h | 4 ++-- include/usb_mode.h | 4 ++-- include/usb_pd.h | 5 +++-- include/usb_pd_tcpc.h | 3 ++- include/usb_pd_tcpm.h | 3 ++- include/usb_pd_timer.h | 4 ++-- include/usb_prl_sm.h | 3 +-- include/usb_tbt_alt_mode.h | 4 ++-- include/usb_tc_sm.h | 2 +- include/util.h | 1 + include/vb21_struct.h | 4 ++-- include/vboot.h | 2 +- include/watchdog.h | 4 ++-- 63 files changed, 111 insertions(+), 91 deletions(-) diff --git a/include/accelgyro.h b/include/accelgyro.h index 74824b2611..b51a0ea148 100644 --- a/include/accelgyro.h +++ b/include/accelgyro.h @@ -6,8 +6,8 @@ #ifndef __CROS_EC_ACCELGYRO_H #define __CROS_EC_ACCELGYRO_H -#include "motion_sense.h" #include "math_util.h" +#include "motion_sense.h" /* Header file for accelerometer / gyro drivers. */ diff --git a/include/battery_fuel_gauge.h b/include/battery_fuel_gauge.h index 0a2a4064bb..efcf18530c 100644 --- a/include/battery_fuel_gauge.h +++ b/include/battery_fuel_gauge.h @@ -9,6 +9,7 @@ #define __CROS_EC_BATTERY_FUEL_GAUGE_H #include "battery.h" + #include /* Number of writes needed to invoke battery cutoff command */ diff --git a/include/benchmark.h b/include/benchmark.h index d2fcc9388c..190580ebb7 100644 --- a/include/benchmark.h +++ b/include/benchmark.h @@ -8,17 +8,18 @@ #ifndef __CROS_EC_BENCHMARK_H #define __CROS_EC_BENCHMARK_H +#include + #include -#include #include -#include +#include #include extern "C" { +#include "clock.h" #include "console.h" #include "timer.h" #include "util.h" -#include "clock.h" #include "watchdog.h" } diff --git a/include/bluetooth_le_ll.h b/include/bluetooth_le_ll.h index d17aec8a57..ec2bb7f7e7 100644 --- a/include/bluetooth_le_ll.h +++ b/include/bluetooth_le_ll.h @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "common.h" #include "btle_hci_int.h" +#include "common.h" enum ll_state_t { UNINITIALIZED, diff --git a/include/body_detection.h b/include/body_detection.h index 8fea5d84e1..7ab7ab3e6d 100644 --- a/include/body_detection.h +++ b/include/body_detection.h @@ -6,8 +6,8 @@ #ifndef __CROS_EC_BODY_DETECTION_H #define __CROS_EC_BODY_DETECTION_H -#include #include +#include enum body_detect_states { BODY_DETECTION_OFF_BODY, BODY_DETECTION_ON_BODY }; diff --git a/include/button.h b/include/button.h index f0c71d7f3f..b38191aaf5 100644 --- a/include/button.h +++ b/include/button.h @@ -10,8 +10,8 @@ #include "common.h" #include "compile_time_macros.h" -#include "gpio_signal.h" #include "ec_commands.h" +#include "gpio_signal.h" #define BUTTON_FLAG_ACTIVE_HIGH BIT(0) #define BUTTON_FLAG_DISABLED BIT(1) /* Button disabled */ diff --git a/include/charge_state.h b/include/charge_state.h index f8edd604ea..dcf3430954 100644 --- a/include/charge_state.h +++ b/include/charge_state.h @@ -6,8 +6,8 @@ #define __CROS_EC_CHARGE_STATE_H #include "common.h" -#include "timer.h" #include "stdbool.h" +#include "timer.h" /* Stuff that's common to all charger implementations can go here. */ diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h index c7a5cbc995..6d0b936f4a 100644 --- a/include/charge_state_v2.h +++ b/include/charge_state_v2.h @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "battery.h" #include "battery_smart.h" #include "charger.h" @@ -13,6 +11,8 @@ #include "ocpc.h" #include "timer.h" +#include + #ifndef __CROS_EC_CHARGE_STATE_V2_H #define __CROS_EC_CHARGE_STATE_V2_H diff --git a/include/common.h b/include/common.h index 6f76157b6c..02f7449d81 100644 --- a/include/common.h +++ b/include/common.h @@ -8,13 +8,14 @@ #ifndef __CROS_EC_COMMON_H #define __CROS_EC_COMMON_H -#include -#include - #include "compile_time_macros.h" +#include +#include + #ifdef CONFIG_ZEPHYR #include "fpu.h" + #include #include #ifdef CONFIG_ZTEST diff --git a/include/console.h b/include/console.h index ddfba89926..03abbe5732 100644 --- a/include/console.h +++ b/include/console.h @@ -10,6 +10,7 @@ #include "common.h" #include "config.h" + #include #ifdef CONFIG_ZEPHYR diff --git a/include/dps.h b/include/dps.h index 8794220ab2..c4d2c884b1 100644 --- a/include/dps.h +++ b/include/dps.h @@ -6,10 +6,10 @@ #ifndef __CROS_EC_DPS__H #define __CROS_EC_DPS__H -#include - #include "common.h" +#include + #define DPS_FLAG_DISABLED BIT(0) #define DPS_FLAG_NO_SRCCAP BIT(1) #define DPS_FLAG_WAITING BIT(2) diff --git a/include/driver/accelgyro_bmi260.h b/include/driver/accelgyro_bmi260.h index 5d55a85acc..baf78e9e00 100644 --- a/include/driver/accelgyro_bmi260.h +++ b/include/driver/accelgyro_bmi260.h @@ -10,8 +10,8 @@ #include "accelgyro.h" #include "common.h" -#include "mag_bmm150.h" #include "driver/accelgyro_bmi260_public.h" +#include "mag_bmm150.h" #define BMI260_CHIP_ID 0x00 /* BMI260 chip identifier */ diff --git a/include/driver/accelgyro_bmi_common.h b/include/driver/accelgyro_bmi_common.h index 371d3d97ce..01a9ecffd6 100644 --- a/include/driver/accelgyro_bmi_common.h +++ b/include/driver/accelgyro_bmi_common.h @@ -10,8 +10,8 @@ #include "accelgyro.h" #include "accelgyro_bmi160.h" #include "accelgyro_bmi260.h" -#include "mag_bmm150.h" #include "accelgyro_bmi_common_public.h" +#include "mag_bmm150.h" #if !defined(CONFIG_ACCELGYRO_BMI_COMM_SPI) && \ !defined(CONFIG_ACCELGYRO_BMI_COMM_I2C) diff --git a/include/driver/retimer/bb_retimer.h b/include/driver/retimer/bb_retimer.h index 460156803e..b47743f882 100644 --- a/include/driver/retimer/bb_retimer.h +++ b/include/driver/retimer/bb_retimer.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_BB_RETIMER_H #define __CROS_EC_BB_RETIMER_H -#include "usb_mux.h" #include "driver/retimer/bb_retimer_public.h" +#include "usb_mux.h" /* Burnside Bridge I2C Configuration Space */ #define BB_RETIMER_REG_VENDOR_ID 0 diff --git a/include/ec_ec_comm_client.h b/include/ec_ec_comm_client.h index 9b506dd402..57c599a365 100644 --- a/include/ec_ec_comm_client.h +++ b/include/ec_ec_comm_client.h @@ -8,9 +8,10 @@ #ifndef EC_EC_COMM_CLIENT_H_ #define EC_EC_COMM_CLIENT_H_ -#include #include "config.h" +#include + /** * Sends EC_CMD_BATTERY_GET_DYNAMIC command to server, and writes the * battery dynamic information into battery_dynamic[BATT_IDX_BASE]. diff --git a/include/ec_ec_comm_server.h b/include/ec_ec_comm_server.h index 0eb094fea3..9728e021a8 100644 --- a/include/ec_ec_comm_server.h +++ b/include/ec_ec_comm_server.h @@ -8,10 +8,11 @@ #ifndef EC_EC_COMM_SERVER_H_ #define EC_EC_COMM_SERVER_H_ -#include #include "consumer.h" #include "queue.h" +#include + extern struct queue const ec_ec_comm_server_input; extern struct queue const ec_ec_comm_server_output; diff --git a/include/flash_log.h b/include/flash_log.h index 7141a8b67a..36e3be6738 100644 --- a/include/flash_log.h +++ b/include/flash_log.h @@ -6,9 +6,9 @@ #ifndef __CROS_EC_EVENT_LOG_H #define __CROS_EC_EVENT_LOG_H -#include "config.h" #include "common.h" #include "compile_time_macros.h" +#include "config.h" #include "stddef.h" enum flash_event_type { diff --git a/include/fpsensor.h b/include/fpsensor.h index 3963df86a7..a59eea1b89 100644 --- a/include/fpsensor.h +++ b/include/fpsensor.h @@ -8,10 +8,11 @@ #ifndef __CROS_EC_FPSENSOR_H #define __CROS_EC_FPSENSOR_H -#include #include "common.h" #include "ec_commands.h" +#include + #ifndef SPI_FP_DEVICE #define SPI_FP_DEVICE (&spi_devices[0]) #endif diff --git a/include/fpsensor_crypto.h b/include/fpsensor_crypto.h index 7dff9238fa..f000b841e4 100644 --- a/include/fpsensor_crypto.h +++ b/include/fpsensor_crypto.h @@ -8,10 +8,10 @@ #ifndef __CROS_EC_FPSENSOR_CRYPTO_H #define __CROS_EC_FPSENSOR_CRYPTO_H -#include - #include "sha256.h" +#include + #define HKDF_MAX_INFO_SIZE 128 #define HKDF_SHA256_MAX_BLOCK_COUNT 255 diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h index ce454233fa..d8f112afcd 100644 --- a/include/fpsensor_state.h +++ b/include/fpsensor_state.h @@ -8,16 +8,15 @@ #ifndef __CROS_EC_FPSENSOR_STATE_H #define __CROS_EC_FPSENSOR_STATE_H -#include -#include - #include "atomic.h" #include "common.h" +#include "driver/fingerprint/fpsensor.h" #include "ec_commands.h" #include "link_defs.h" #include "timer.h" -#include "driver/fingerprint/fpsensor.h" +#include +#include /* if no special memory regions are defined, fallback on regular SRAM */ #ifndef FP_FRAME_SECTION diff --git a/include/gpio.h b/include/gpio.h index f6729c7830..086ed9131f 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -21,8 +21,9 @@ */ #ifdef CONFIG_ZEPHYR #include -#include #include +#include + #include /* diff --git a/include/gpio_list.h b/include/gpio_list.h index 17fc0d3b09..e5a90b4e89 100644 --- a/include/gpio_list.h +++ b/include/gpio_list.h @@ -67,9 +67,9 @@ const int gpio_ih_count = ARRAY_SIZE(gpio_irq_handlers); #define PIN(a, b...) \ static const int _pin_##a##_##b \ __attribute__((unused, section(".unused"))) = __LINE__; -#include "gpio.wrap" - #include "ioexpander.h" + +#include "gpio.wrap" #define IOEX_EXPIN(ioex, port, index) (ioex), (port), BIT(index) /* diff --git a/include/host_command.h b/include/host_command.h index 59389107c7..7efd54e297 100644 --- a/include/host_command.h +++ b/include/host_command.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_HOST_COMMAND_H #define __CROS_EC_HOST_COMMAND_H -#include "compiler.h" #include "common.h" +#include "compiler.h" #include "ec_commands.h" #ifdef __cplusplus diff --git a/include/i2c_bitbang.h b/include/i2c_bitbang.h index 9c7c730518..c9b0587410 100644 --- a/include/i2c_bitbang.h +++ b/include/i2c_bitbang.h @@ -5,10 +5,10 @@ #ifndef __CROS_EC_I2C_BITBANG_H #define __CROS_EC_I2C_BITBANG_H -#include - #include "i2c.h" +#include + extern const struct i2c_drv bitbang_drv; extern const struct i2c_port_t i2c_bitbang_ports[]; diff --git a/include/keyboard_8042.h b/include/keyboard_8042.h index 34c98c2a38..bd56106f1d 100644 --- a/include/keyboard_8042.h +++ b/include/keyboard_8042.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_KEYBOARD_8042_H #define __CROS_EC_KEYBOARD_8042_H -#include "common.h" #include "button.h" +#include "common.h" /** * Called by power button handler and button interrupt handler. diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h index bd7a7b5ec7..2f8dfdc242 100644 --- a/include/keyboard_8042_sharedlib.h +++ b/include/keyboard_8042_sharedlib.h @@ -8,12 +8,12 @@ #ifndef __CROS_EC_KEYBOARD_8042_SHAREDLIB_H #define __CROS_EC_KEYBOARD_8042_SHAREDLIB_H -#include - #include "button.h" #include "keyboard_config.h" #include "keyboard_protocol.h" +#include + struct button_8042_t { uint16_t scancode; int repeat; diff --git a/include/keyboard_protocol.h b/include/keyboard_protocol.h index 7b9006fcc0..8f10c7bd0e 100644 --- a/include/keyboard_protocol.h +++ b/include/keyboard_protocol.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_KEYBOARD_PROTOCOL_H #define __CROS_EC_KEYBOARD_PROTOCOL_H -#include "common.h" #include "button.h" +#include "common.h" /* Routines common to all protocols */ diff --git a/include/keyboard_raw.h b/include/keyboard_raw.h index 2b2254e56c..350791998f 100644 --- a/include/keyboard_raw.h +++ b/include/keyboard_raw.h @@ -11,13 +11,13 @@ #ifndef __CROS_EC_KEYBOARD_RAW_H #define __CROS_EC_KEYBOARD_RAW_H -#include - #include "builtin/assert.h" #include "common.h" #include "gpio_signal.h" #include "keyboard_config.h" +#include + /* Column values for keyboard_raw_drive_column() */ enum keyboard_column_index { KEYBOARD_COLUMN_ALL = -2, /* Drive all columns */ diff --git a/include/mag_cal.h b/include/mag_cal.h index 66281bba4e..82453c5235 100644 --- a/include/mag_cal.h +++ b/include/mag_cal.h @@ -8,10 +8,10 @@ #ifndef __CROS_EC_MAG_CAL_H #define __CROS_EC_MAG_CAL_H -#include "math_util.h" +#include "kasa.h" #include "mat44.h" +#include "math_util.h" #include "vec4.h" -#include "kasa.h" #define MAG_CAL_MAX_SAMPLES 0xffff #define MAG_CAL_MIN_BATCH_WINDOW_US (2 * SECOND) diff --git a/include/math_util.h b/include/math_util.h index 51065d2bce..6b4b8cb3e5 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -8,9 +8,11 @@ #ifndef __CROS_EC_MATH_UTIL_H #define __CROS_EC_MATH_UTIL_H -#include +#include "config.h" #include "limits.h" +#include + #ifdef CONFIG_FPU typedef float fp_t; typedef float fp_inter_t; diff --git a/include/mock/fpsensor_state_mock.h b/include/mock/fpsensor_state_mock.h index 32450e3cc0..c683ba5deb 100644 --- a/include/mock/fpsensor_state_mock.h +++ b/include/mock/fpsensor_state_mock.h @@ -6,12 +6,12 @@ #ifndef __MOCK_FPSENSOR_STATE_MOCK_H #define __MOCK_FPSENSOR_STATE_MOCK_H -#include -#include - #include "driver/fingerprint/fpsensor.h" #include "ec_commands.h" +#include +#include + extern const uint8_t default_fake_tpm_seed[FP_CONTEXT_TPM_BYTES]; extern const uint8_t default_fake_fp_positive_match_salt[FP_MAX_FINGER_COUNT] diff --git a/include/mock/tcpc_mock.h b/include/mock/tcpc_mock.h index 2f3a78c69a..fef45b492b 100644 --- a/include/mock/tcpc_mock.h +++ b/include/mock/tcpc_mock.h @@ -4,8 +4,8 @@ */ /* Mock for the TCPC interface */ -#include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" /* Controller for TCPC state */ struct mock_tcpc_ctrl { diff --git a/include/mock/usb_pe_sm_mock.h b/include/mock/usb_pe_sm_mock.h index 819f086c5a..778e7943c4 100644 --- a/include/mock/usb_pe_sm_mock.h +++ b/include/mock/usb_pe_sm_mock.h @@ -8,8 +8,8 @@ #define __MOCK_USB_PE_SM_MOCK_H #include "common.h" -#include "usb_pe_sm.h" #include "usb_pd_tcpm.h" +#include "usb_pe_sm.h" struct mock_pe_port_t { enum tcpci_msg_type sop; diff --git a/include/mock/usb_tc_sm_mock.h b/include/mock/usb_tc_sm_mock.h index 532f2bfb54..2dc09ade8b 100644 --- a/include/mock/usb_tc_sm_mock.h +++ b/include/mock/usb_tc_sm_mock.h @@ -8,9 +8,9 @@ #define __MOCK_USB_TC_SM_MOCK_H #include "common.h" -#include "usb_tc_sm.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usb_tc_sm.h" struct mock_tc_port_t { int rev; diff --git a/include/newton_fit.h b/include/newton_fit.h index 2fb1994083..dc0a8ffe6e 100644 --- a/include/newton_fit.h +++ b/include/newton_fit.h @@ -9,8 +9,8 @@ #define __CROS_EC_NEWTON_FIT_H #include "queue.h" -#include "vec3.h" #include "stdbool.h" +#include "vec3.h" struct newton_fit_orientation { /** An orientations. */ diff --git a/include/panic.h b/include/panic.h index 8eda475f2a..25829017ea 100644 --- a/include/panic.h +++ b/include/panic.h @@ -9,12 +9,13 @@ #ifndef __CROS_EC_PANIC_H #define __CROS_EC_PANIC_H +#include "common.h" +#include "software_panic.h" + #include #include -#include -#include "common.h" -#include "software_panic.h" +#include #ifdef __cplusplus extern "C" { diff --git a/include/printf.h b/include/printf.h index f797ca593e..a06d8e1c7b 100644 --- a/include/printf.h +++ b/include/printf.h @@ -8,12 +8,13 @@ #ifndef __CROS_EC_PRINTF_H #define __CROS_EC_PRINTF_H +#include "common.h" +#include "console.h" + #include /* For va_list */ #include #include /* For size_t */ -#include "console.h" #include -#include "common.h" /** * Buffer size in bytes large enough to hold the largest possible timestamp. diff --git a/include/pwm.h b/include/pwm.h index 48963d9d3c..b56f9f8c1a 100644 --- a/include/pwm.h +++ b/include/pwm.h @@ -6,10 +6,10 @@ #ifndef __CROS_EC_PWM_H #define __CROS_EC_PWM_H -#include - #include "util.h" +#include + #define PWM_RAW_TO_PERCENT(v) DIV_ROUND_NEAREST((uint32_t)(v)*100, UINT16_MAX) #define PWM_PERCENT_TO_RAW(v) ((uint32_t)(v)*UINT16_MAX / 100) diff --git a/include/queue_policies.h b/include/queue_policies.h index aceb477ef6..eb80d3673b 100644 --- a/include/queue_policies.h +++ b/include/queue_policies.h @@ -7,9 +7,9 @@ #ifndef __CROS_EC_QUEUE_POLICIES_H #define __CROS_EC_QUEUE_POLICIES_H -#include "queue.h" #include "consumer.h" #include "producer.h" +#include "queue.h" /* * The direct notification policy manages a 1-to-1 producer consumer model. diff --git a/include/rgb_keyboard.h b/include/rgb_keyboard.h index 56a3e09a91..8c16f6f7e8 100644 --- a/include/rgb_keyboard.h +++ b/include/rgb_keyboard.h @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "ec_commands.h" #include "stddef.h" +#include + /* Use this instead of '3' for readability where applicable. */ #define SIZE_OF_RGB sizeof(struct rgb_s) diff --git a/include/rma_auth.h b/include/rma_auth.h index 2ad9299fed..0b02a1bdc6 100644 --- a/include/rma_auth.h +++ b/include/rma_auth.h @@ -8,10 +8,10 @@ #ifndef __CROS_EC_RMA_AUTH_H #define __CROS_EC_RMA_AUTH_H -#include - #include "common.h" /* For __packed. */ +#include + /* Current challenge protocol version */ #define RMA_CHALLENGE_VERSION 0 diff --git a/include/shared_mem.h b/include/shared_mem.h index 307ce9f5e5..482d3a6dec 100644 --- a/include/shared_mem.h +++ b/include/shared_mem.h @@ -18,6 +18,7 @@ #define __CROS_EC_SHARED_MEM_H #include "common.h" + #include /** diff --git a/include/stillness_detector.h b/include/stillness_detector.h index 79de2de79f..67269c6db4 100644 --- a/include/stillness_detector.h +++ b/include/stillness_detector.h @@ -9,6 +9,7 @@ #include "common.h" #include "math_util.h" #include "stdbool.h" + #include struct still_det { diff --git a/include/system.h b/include/system.h index 4d98136da5..c7884199e1 100644 --- a/include/system.h +++ b/include/system.h @@ -8,8 +8,6 @@ #ifndef __CROS_EC_SYSTEM_H #define __CROS_EC_SYSTEM_H -#include - #include "atomic.h" #include "common.h" #include "compile_time_macros.h" @@ -17,6 +15,8 @@ #include "ec_commands.h" #include "timer.h" +#include + #ifdef CONFIG_ZEPHYR #ifdef CONFIG_CPU_CORTEX_M /* diff --git a/include/task.h b/include/task.h index bc7314169e..a527ca695a 100644 --- a/include/task.h +++ b/include/task.h @@ -15,9 +15,10 @@ extern "C" { #include "atomic_t.h" #include "common.h" #include "compile_time_macros.h" -#include #include "task_id.h" +#include + /* Task event bitmasks */ /* Tasks may use the bits in TASK_EVENT_CUSTOM_BIT for their own events */ #define TASK_EVENT_CUSTOM_BIT(x) BUILD_CHECK_INLINE(BIT(x), BIT(x) & 0x0ffff) diff --git a/include/test_util.h b/include/test_util.h index 47b73605d4..efdee22cc6 100644 --- a/include/test_util.h +++ b/include/test_util.h @@ -19,8 +19,9 @@ extern "C" { #include "stack_trace.h" #ifdef CONFIG_ZTEST -#include #include "ec_tasks.h" + +#include #endif /* CONFIG_ZTEST */ /* This allows tests to be easily commented out in run_test for debugging */ diff --git a/include/tests/enum_strings.h b/include/tests/enum_strings.h index 2ad0725f8f..7654dc9377 100644 --- a/include/tests/enum_strings.h +++ b/include/tests/enum_strings.h @@ -5,8 +5,8 @@ /* Defines helper function that convert Enums to strings for prints in tests */ -#include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" #ifndef __CROS_EC_TEST_ENUM_STINGS_H #define __CROS_EC_TEST_ENUM_STINGS_H diff --git a/include/trng.h b/include/trng.h index cf8326e5bf..3b28796ed0 100644 --- a/include/trng.h +++ b/include/trng.h @@ -5,10 +5,11 @@ #ifndef __EC_INCLUDE_TRNG_H #define __EC_INCLUDE_TRNG_H -#include #include #include +#include + /** * Initialize the true random number generator. * diff --git a/include/uart.h b/include/uart.h index 5af95df98d..086c407695 100644 --- a/include/uart.h +++ b/include/uart.h @@ -8,10 +8,11 @@ #ifndef __CROS_EC_UART_H #define __CROS_EC_UART_H -#include /* For va_list */ #include "common.h" #include "gpio_signal.h" +#include /* For va_list */ + /** * Initialize the UART module. */ diff --git a/include/update_fw.h b/include/update_fw.h index dc520c2eb9..a4f56942a7 100644 --- a/include/update_fw.h +++ b/include/update_fw.h @@ -6,10 +6,10 @@ #ifndef __CROS_EC_UPDATE_FW_H #define __CROS_EC_UPDATE_FW_H -#include - #include "compile_time_macros.h" +#include + /* * This file contains structures used to facilitate EC firmware updates * over USB (and over TPM for cr50). diff --git a/include/usb_dp_alt_mode.h b/include/usb_dp_alt_mode.h index 1449b96313..275580b407 100644 --- a/include/usb_dp_alt_mode.h +++ b/include/usb_dp_alt_mode.h @@ -12,11 +12,11 @@ #ifndef __CROS_EC_USB_DP_ALT_MODE_H #define __CROS_EC_USB_DP_ALT_MODE_H -#include - #include "tcpm/tcpm.h" #include "usb_pd_dpm_sm.h" +#include + /* * Initialize DP state for the specified port. * diff --git a/include/usb_mode.h b/include/usb_mode.h index 4cf7710960..5c6f71b372 100644 --- a/include/usb_mode.h +++ b/include/usb_mode.h @@ -12,11 +12,11 @@ #ifndef __CROS_EC_USB_MODE_H #define __CROS_EC_USB_MODE_H -#include - #include "tcpm/tcpm.h" #include "usb_pd_tcpm.h" +#include + /* * Initialize USB4 state for the specified port. * diff --git a/include/usb_pd.h b/include/usb_pd.h index b2cadbc0d7..e4ab8f6432 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -8,14 +8,15 @@ #ifndef __CROS_EC_USB_PD_H #define __CROS_EC_USB_PD_H -#include -#include #include "common.h" #include "ec_commands.h" #include "usb_pd_tbt.h" #include "usb_pd_tcpm.h" #include "usb_pd_vdo.h" +#include +#include + /* PD Host command timeout */ #define PD_HOST_COMMAND_TIMEOUT_US SECOND diff --git a/include/usb_pd_tcpc.h b/include/usb_pd_tcpc.h index a89030cdb7..7af0a570e4 100644 --- a/include/usb_pd_tcpc.h +++ b/include/usb_pd_tcpc.h @@ -8,9 +8,10 @@ #ifndef __CROS_EC_USB_PD_TCPC_H #define __CROS_EC_USB_PD_TCPC_H -#include #include "usb_pd_tcpm.h" +#include + /* If we are a TCPC but not a TCPM, then we implement the peripheral TCPCI */ #if defined(CONFIG_USB_PD_TCPC) && !defined(CONFIG_USB_PD_TCPM_STUB) #define TCPCI_I2C_PERIPHERAL diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index f3f449721e..199682122c 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -8,12 +8,13 @@ #ifndef __CROS_EC_USB_PD_TCPM_H #define __CROS_EC_USB_PD_TCPM_H -#include #include "common.h" #include "compiler.h" #include "ec_commands.h" #include "i2c.h" +#include + /* Time to wait for TCPC to complete transmit */ #define PD_T_TCPC_TX_TIMEOUT (100 * MSEC) diff --git a/include/usb_pd_timer.h b/include/usb_pd_timer.h index 439b30513d..687c980243 100644 --- a/include/usb_pd_timer.h +++ b/include/usb_pd_timer.h @@ -8,11 +8,11 @@ #ifndef __CROS_EC_USB_PD_TIMER_H #define __CROS_EC_USB_PD_TIMER_H -#include - #include "atomic.h" #include "atomic_bit.h" +#include + /* * List of all timers that will be managed by usb_pd_timer */ diff --git a/include/usb_prl_sm.h b/include/usb_prl_sm.h index 99b69f156f..5671f8300e 100644 --- a/include/usb_prl_sm.h +++ b/include/usb_prl_sm.h @@ -8,11 +8,10 @@ #ifndef __CROS_EC_USB_PRL_H #define __CROS_EC_USB_PRL_H #include "common.h" +#include "timer.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" #include "usb_sm.h" -#include "timer.h" -#include "usb_pd_tcpm.h" /** * Returns TX success time stamp. diff --git a/include/usb_tbt_alt_mode.h b/include/usb_tbt_alt_mode.h index b7d7baa6a2..ff2ad44ed0 100644 --- a/include/usb_tbt_alt_mode.h +++ b/include/usb_tbt_alt_mode.h @@ -11,12 +11,12 @@ #ifndef __CROS_EC_USB_TBT_ALT_MODE_H #define __CROS_EC_USB_TBT_ALT_MODE_H -#include - #include "tcpm/tcpm.h" #include "usb_pd_dpm_sm.h" #include "usb_pd_tcpm.h" +#include + /* * Initialize Thunderbolt state for the specified port. * diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h index ec6473edfd..009e5db089 100644 --- a/include/usb_tc_sm.h +++ b/include/usb_tc_sm.h @@ -8,9 +8,9 @@ #ifndef __CROS_EC_USB_TC_H #define __CROS_EC_USB_TC_H -#include "usb_sm.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usb_sm.h" enum try_src_override_t { TRY_SRC_OVERRIDE_OFF, diff --git a/include/util.h b/include/util.h index dc2e038705..9db98f2b3f 100644 --- a/include/util.h +++ b/include/util.h @@ -16,6 +16,7 @@ #include #include #include + #include #ifdef CONFIG_ZEPHYR #include diff --git a/include/vb21_struct.h b/include/vb21_struct.h index c8b49ac05e..b23eb0cd30 100644 --- a/include/vb21_struct.h +++ b/include/vb21_struct.h @@ -14,10 +14,10 @@ #ifndef VBOOT_REFERENCE_VB21_STRUCT_H_ #define VBOOT_REFERENCE_VB21_STRUCT_H_ -#include - #include "2id.h" +#include + /* * Magic numbers used by vb21_struct_common.magic. * diff --git a/include/vboot.h b/include/vboot.h index 55359e8044..9a3013ebbc 100644 --- a/include/vboot.h +++ b/include/vboot.h @@ -7,11 +7,11 @@ #define __CROS_EC_INCLUDE_VBOOT_H #include "common.h" -#include "vb21_struct.h" #include "rsa.h" #include "sha256.h" #include "stdbool.h" #include "timer.h" +#include "vb21_struct.h" /** * Validate key contents. diff --git a/include/watchdog.h b/include/watchdog.h index d6768425ce..5e6e5626e6 100644 --- a/include/watchdog.h +++ b/include/watchdog.h @@ -8,10 +8,10 @@ #ifndef __CROS_EC_WATCHDOG_H #define __CROS_EC_WATCHDOG_H -#include - #include "config.h" +#include + /** * Initialize the watchdog. * -- cgit v1.2.1 From ec8d1ac9dee37d342d6b992e8d93b69a1b9527ca Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 24 Nov 2022 12:04:35 +0000 Subject: zephyr: emul: select few more emulator config automatically Select EMUL_BB_RETIMER and EMUL_PCT2075 when unit testing, drop the now unnecessary explicit settings. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: Idda7529476de7bc1e5e2b7dade47c8322628f16d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4055682 Code-Coverage: Zoss Reviewed-by: Al Semjonovs --- zephyr/emul/Kconfig | 4 ++++ zephyr/test/drivers/prj.conf | 3 --- zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf | 2 -- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/zephyr/emul/Kconfig b/zephyr/emul/Kconfig index d2a0e8b4f1..44d53179c3 100644 --- a/zephyr/emul/Kconfig +++ b/zephyr/emul/Kconfig @@ -83,6 +83,8 @@ config EMUL_TUSB1064 config EMUL_BB_RETIMER bool "BB retimer emulator" + default y + depends on ZTEST && DT_HAS_INTEL_JHL8040R_ENABLED select EMUL_COMMON_I2C help Enable the BB (Burnside Bridge) retimer emulator. This driver use @@ -132,6 +134,8 @@ config PWM_MOCK config EMUL_PCT2075 bool "PCT2075 emulator" + default y + depends on ZTEST && DT_HAS_NXP_PCT2075_ENABLED select EMUL_COMMON_I2C help Enable the PCT2075 temperature sensor emulator. It uses emulated I2C bus. diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf index 483d3f8481..167994a11c 100644 --- a/zephyr/test/drivers/prj.conf +++ b/zephyr/test/drivers/prj.conf @@ -49,10 +49,8 @@ CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY=49 CONFIG_EEPROM=y CONFIG_EEPROM_SIMULATOR=n CONFIG_EMUL_EEPROM_AT2X=y -CONFIG_EMUL_BB_RETIMER=y CONFIG_EMUL_TCPCI_PARTNER_DRP=y CONFIG_EMUL_TCPCI_PARTNER_FAULTY_EXT=y -CONFIG_EMUL_PCT2075=y CONFIG_PLATFORM_EC_CHARGE_MANAGER=y CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y CONFIG_PLATFORM_EC_CHARGESPLASH=y @@ -113,7 +111,6 @@ CONFIG_PLATFORM_EC_USB_PD_CLEAR_HARD_RESET_STATUS=y CONFIG_PLATFORM_EC_CONSOLE_CMD_WAITMS=y CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y -CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y CONFIG_ESPI=y CONFIG_ESPI_EMUL=y diff --git a/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf b/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf index fefe9471ca..98cac2ca80 100644 --- a/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf +++ b/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf @@ -2,8 +2,6 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - -CONFIG_EMUL_BB_RETIMER=n CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=n CONFIG_PLATFORM_EC_USB_PD_USB4=n CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -- cgit v1.2.1 From eae6dfc05ee73b7efbd5e1dfa34d39134f2a4480 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 24 Nov 2022 15:41:21 +0000 Subject: zephyr: rt9490: drop the compiler guards bc12_rt9490.c is only being built if the driver or emulators are enabled, and the emulator defines both compatibles anyway, so it's not really needed. Also fix a dts syntax thing. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I622dbf07f74f52b5c3bdbe634c5c1bcd0774845e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054624 Reviewed-by: Sam Hurst Code-Coverage: Zoss --- zephyr/shim/src/bc12_rt9490.c | 4 ---- zephyr/test/drivers/rt9490/charger.dts | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/zephyr/shim/src/bc12_rt9490.c b/zephyr/shim/src/bc12_rt9490.c index 5394069d51..a3c97e7faf 100644 --- a/zephyr/shim/src/bc12_rt9490.c +++ b/zephyr/shim/src/bc12_rt9490.c @@ -12,8 +12,6 @@ #include -#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) - static void rt9490_bc12_enable_irqs(void) { DT_INST_FOREACH_STATUS_OKAY(BC12_GPIO_ENABLE_INTERRUPT); @@ -43,5 +41,3 @@ void rt9490_bc12_dt_interrupt(enum gpio_signal signal) break; } } - -#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/zephyr/test/drivers/rt9490/charger.dts b/zephyr/test/drivers/rt9490/charger.dts index e74729aaed..4d4a2a4f35 100644 --- a/zephyr/test/drivers/rt9490/charger.dts +++ b/zephyr/test/drivers/rt9490/charger.dts @@ -15,7 +15,7 @@ }; &i2c0 { - status="okay"; + status = "okay"; rt9490: rt9490@53 { compatible = "zephyr,rt9490-emul", "richtek,rt9490"; -- cgit v1.2.1 From 5088ff8a8ce91da703c67b82443a66f5f314809f Mon Sep 17 00:00:00 2001 From: Yu-An Chen Date: Wed, 23 Nov 2022 15:16:54 +0800 Subject: evoker: Select pcf85063a oscillator capacitor to 12.5 pF Select pcf85063a oscillator capacitor to 12.5 pF BUG=b:260165217 BRANCH=none TEST=check CAP_SEL bit can set LOW_COVERAGE_REASON=RTC driver currently has no tests Signed-off-by: Yu-An Chen Change-Id: Ida74a1c3cadcc376a68d2386f60d7972ba0b8040 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050011 Reviewed-by: Sam Hurst Commit-Queue: Bob Moragues Tested-by: Bob Moragues Code-Coverage: Zoss --- zephyr/program/herobrine/evoker/project.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zephyr/program/herobrine/evoker/project.conf b/zephyr/program/herobrine/evoker/project.conf index c2fecd48b5..a57c119b90 100644 --- a/zephyr/program/herobrine/evoker/project.conf +++ b/zephyr/program/herobrine/evoker/project.conf @@ -17,3 +17,6 @@ CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y # Disable USB-A CONFIG_PLATFORM_EC_USBA=n + +# Set PCF85063A CAP_SEL +CONFIG_PLATFORM_EC_PCF85063A_CAP_SEL=y -- cgit v1.2.1 From 1940a898542fde5ec695a97ac6cace9aa19c3bc6 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Mon, 28 Nov 2022 12:18:16 -0700 Subject: test: cleanup deprecated host commands Update the deprecated host command tests to support non-X86 configurations. BUG=none BRANCH=none TEST=twister Change-Id: I4da2ff748a10b56cfb80272df5cced0ef6134016 Signed-off-by: Keith Short Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4063183 Code-Coverage: Zoss Reviewed-by: Aaron Massey --- .../host_cmd/src/host_event_commands_deprecated.c | 184 ++++++++++----------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c index 3c72bb5f51..b0ba438bbb 100644 --- a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c +++ b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c @@ -13,32 +13,22 @@ #define HOST_EVENT_TEST_MASK_VAL EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) -static void +static enum ec_status host_event_get_wake_mask_helper(struct ec_response_host_event_mask *r) { - enum ec_status ret_val; struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE( EC_CMD_HOST_EVENT_GET_WAKE_MASK, 0, *r); - ret_val = host_command_process(&args); - - /* EC_CMD_HOST_EVENT_GET_WAKE_MASK always returns success */ - zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d", - EC_RES_SUCCESS, ret_val); + return host_command_process(&args); } -static void host_event_set_wake_mask_helper(uint32_t mask) +static enum ec_status host_event_set_wake_mask_helper(uint32_t mask) { - enum ec_status ret_val; struct ec_params_host_event_mask params = { .mask = mask }; struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS( EC_CMD_HOST_EVENT_SET_WAKE_MASK, 0, params); - ret_val = host_command_process(&args); - - /* EC_CMD_HOST_EVENT_SET_WAKE_MASK always returns success */ - zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d", - EC_RES_SUCCESS, ret_val); + return host_command_process(&args); } /** @@ -46,13 +36,17 @@ static void host_event_set_wake_mask_helper(uint32_t mask) */ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask) { -#ifdef CONFIG_HOSTCMD_X86 + enum ec_status rv; struct ec_response_host_event_mask result = { 0 }; - host_event_get_wake_mask_helper(&result); -#else - ztest_test_skip(); -#endif + rv = host_event_get_wake_mask_helper(&result); + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv); + } else { + zassert_equal(EC_RES_INVALID_COMMAND, rv, + "Expected %d, returned %d", + EC_RES_INVALID_COMMAND, rv); + } } /** @@ -60,16 +54,24 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask) */ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask) { -#ifdef CONFIG_HOSTCMD_X86 + enum ec_status rv; struct ec_response_host_event_mask result = { 0 }; /* Read the current mask */ - host_event_get_wake_mask_helper(&result); + rv = host_event_get_wake_mask_helper(&result); + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv); + } else { + zassert_equal(EC_RES_INVALID_COMMAND, rv, + "Expected %d, returned %d", + EC_RES_INVALID_COMMAND, rv); + return; + } /* Default mask is expected to be clear */ zassert_false(result.mask, "Default host event wake mask is not clear"); - host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL); + zassert_ok(host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL)); /* Verify the mask changed */ host_event_get_wake_mask_helper(&result); @@ -79,38 +81,25 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask) HOST_EVENT_TEST_MASK_VAL, result.mask); /* Clean up the mask */ - host_event_set_wake_mask_helper(0); -#else - ztest_test_skip(); -#endif + zassert_ok(host_event_set_wake_mask_helper(0)); } -static void +static enum ec_status host_event_get_smi_mask_helper(struct ec_response_host_event_mask *r) { - enum ec_status ret_val; struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE( EC_CMD_HOST_EVENT_GET_SMI_MASK, 0, *r); - ret_val = host_command_process(&args); - - /* EC_CMD_HOST_EVENT_GET_SMI_MASK always returns success */ - zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d", - EC_RES_SUCCESS, ret_val); + return host_command_process(&args); } -static void host_event_set_smi_mask_helper(uint32_t mask) +static enum ec_status host_event_set_smi_mask_helper(uint32_t mask) { - enum ec_status ret_val; struct ec_params_host_event_mask params = { .mask = mask }; struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS( EC_CMD_HOST_EVENT_SET_SMI_MASK, 0, params); - ret_val = host_command_process(&args); - - /* EC_CMD_HOST_EVENT_SET_SMI_MASK always returns success */ - zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d", - EC_RES_SUCCESS, ret_val); + return host_command_process(&args); } /** @@ -118,13 +107,18 @@ static void host_event_set_smi_mask_helper(uint32_t mask) */ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask) { -#ifdef CONFIG_HOSTCMD_X86 + enum ec_status rv; struct ec_response_host_event_mask result = { 0 }; - host_event_get_smi_mask_helper(&result); -#else - ztest_test_skip(); -#endif + rv = host_event_get_smi_mask_helper(&result); + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv); + } else { + zassert_equal(EC_RES_INVALID_COMMAND, rv, + "Expected %d, returned %d", + EC_RES_INVALID_COMMAND, rv); + return; + } } /** @@ -132,42 +126,43 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask) */ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_smi_mask) { -#ifdef CONFIG_HOSTCMD_X86 + enum ec_status rv; struct ec_response_host_event_mask result = { 0 }; /* Read the current mask */ - host_event_get_smi_mask_helper(&result); + rv = host_event_get_smi_mask_helper(&result); + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv); + } else { + zassert_equal(EC_RES_INVALID_COMMAND, rv, + "Expected %d, returned %d", + EC_RES_INVALID_COMMAND, rv); + return; + } /* Default mask is expected to be clear */ zassert_false(result.mask, "Default host event SMI mask is not clear"); - host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL); + zassert_ok(host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL)); /* Verify the mask changed */ - host_event_get_smi_mask_helper(&result); + zassert_ok(host_event_get_smi_mask_helper(&result)); zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL, "Expected SMI mask 0x%08x, returned mask 0x%08x", HOST_EVENT_TEST_MASK_VAL, result.mask); /* Clean up the mask */ - host_event_set_smi_mask_helper(0); -#else - ztest_test_skip(); -#endif + zassert_ok(host_event_set_smi_mask_helper(0)); } -static void host_event_get_b_helper(struct ec_response_host_event_mask *r) +static enum ec_status +host_event_get_b_helper(struct ec_response_host_event_mask *r) { - enum ec_status ret_val; struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(EC_CMD_HOST_EVENT_GET_B, 0, *r); - ret_val = host_command_process(&args); - - /* EC_CMD_HOST_EVENT_GET_B always returns success */ - zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d", - EC_RES_SUCCESS, ret_val); + return host_command_process(&args); } /** @@ -175,41 +170,36 @@ static void host_event_get_b_helper(struct ec_response_host_event_mask *r) */ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_b) { -#ifdef CONFIG_HOSTCMD_X86 + enum ec_status rv; struct ec_response_host_event_mask result = { 0 }; - host_event_get_b_helper(&result); -#else - ztest_test_skip(); -#endif + rv = host_event_get_b_helper(&result); + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv); + } else { + zassert_equal(EC_RES_INVALID_COMMAND, rv, + "Expected %d, returned %d", + EC_RES_INVALID_COMMAND, rv); + return; + } } -static void +static enum ec_status host_event_get_sci_mask_helper(struct ec_response_host_event_mask *r) { - enum ec_status ret_val; struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE( EC_CMD_HOST_EVENT_GET_SCI_MASK, 0, *r); - ret_val = host_command_process(&args); - - /* EC_CMD_HOST_EVENT_GET_SCI_MASK always returns success */ - zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d", - EC_RES_SUCCESS, ret_val); + return host_command_process(&args); } -static void host_event_set_sci_mask_helper(uint32_t mask) +static enum ec_status host_event_set_sci_mask_helper(uint32_t mask) { - enum ec_status ret_val; struct ec_params_host_event_mask params = { .mask = mask }; struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS( EC_CMD_HOST_EVENT_SET_SCI_MASK, 0, params); - ret_val = host_command_process(&args); - - /* EC_CMD_HOST_EVENT_SET_SCI_MASK always returns success */ - zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d", - EC_RES_SUCCESS, ret_val); + return host_command_process(&args); } /** @@ -217,13 +207,18 @@ static void host_event_set_sci_mask_helper(uint32_t mask) */ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_sci_mask) { -#ifdef CONFIG_HOSTCMD_X86 + enum ec_status rv; struct ec_response_host_event_mask result = { 0 }; - host_event_get_sci_mask_helper(&result); -#else - ztest_test_skip(); -#endif + rv = host_event_get_sci_mask_helper(&result); + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv); + } else { + zassert_equal(EC_RES_INVALID_COMMAND, rv, + "Expected %d, returned %d", + EC_RES_INVALID_COMMAND, rv); + return; + } } /** @@ -231,27 +226,32 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_sci_mask) */ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_sci_mask) { -#ifdef CONFIG_HOSTCMD_X86 + enum ec_status rv; struct ec_response_host_event_mask result = { 0 }; /* Read the current mask */ - host_event_get_sci_mask_helper(&result); + rv = host_event_get_sci_mask_helper(&result); + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv); + } else { + zassert_equal(EC_RES_INVALID_COMMAND, rv, + "Expected %d, returned %d", + EC_RES_INVALID_COMMAND, rv); + return; + } /* Default mask is expected to be clear */ zassert_false(result.mask, "Default host event SCI mask is not clear"); - host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL); + zassert_ok(host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL)); /* Verify the mask changed */ - host_event_get_sci_mask_helper(&result); + zassert_ok(host_event_get_sci_mask_helper(&result)); zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL, "Expected SCI mask 0x%08x, returned mask 0x%08x", HOST_EVENT_TEST_MASK_VAL, result.mask); /* Clean up the mask */ - host_event_set_sci_mask_helper(0); -#else - ztest_test_skip(); -#endif + zassert_ok(host_event_set_sci_mask_helper(0)); } -- cgit v1.2.1 From 0a26305e5e47487a35edba5f68695a08b522643a Mon Sep 17 00:00:00 2001 From: Keith Short Date: Tue, 29 Nov 2022 08:45:56 -0700 Subject: test: host_command: EC_CMD_READ_MEMMAP Add a new test binaries to verify the EC_CMD_READ_MEMMAP command. This command is only provided when the host interface is not eSPI and not LPC. One binary verifies operation with CONFIG_PLATFORM_EC_SWITCH enabled, and one with CONFIG_PLATFORM_EC_SWITCH disabled. BUG=none BRANCH=none TEST=twister Change-Id: Ice44bb9a0c57e62231dbc3b494cb540dbd153f79 Signed-off-by: Keith Short Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4063184 Reviewed-by: Aaron Massey Code-Coverage: Zoss --- zephyr/test/drivers/CMakeLists.txt | 1 + zephyr/test/drivers/Kconfig | 3 + .../drivers/host_cmd_read_memmap/CMakeLists.txt | 7 ++ .../drivers/host_cmd_read_memmap/src/read_memmap.c | 96 ++++++++++++++++++++++ zephyr/test/drivers/testcase.yaml | 13 +++ 5 files changed, 120 insertions(+) create mode 100644 zephyr/test/drivers/host_cmd_read_memmap/CMakeLists.txt create mode 100644 zephyr/test/drivers/host_cmd_read_memmap/src/read_memmap.c diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index 7c7ff22b31..78c1274843 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -46,6 +46,7 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_VCONN_SWAP usbc_vconn_swap) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_OCP usbc_ocp) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_PPC usbc_ppc) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_COMMANDS host_cmd) +add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_COMMAND_READ_MEMMAP host_cmd_read_memmap) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_SYSTEM system) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS locate_chip) add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON button) diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig index 8cc1131193..b2a9648f21 100644 --- a/zephyr/test/drivers/Kconfig +++ b/zephyr/test/drivers/Kconfig @@ -36,6 +36,9 @@ config LINK_TEST_SUITE_HOST_COMMANDS select PLATFORM_EC_CHARGE_STATE_DEBUG bool "Link and test the host command tests" +config LINK_TEST_SUITE_HOST_COMMAND_READ_MEMMAP + bool "Link and test the host command read memmap tests" + config LINK_TEST_SUITE_ISL923X bool "Link and test the isl923x tests" diff --git a/zephyr/test/drivers/host_cmd_read_memmap/CMakeLists.txt b/zephyr/test/drivers/host_cmd_read_memmap/CMakeLists.txt new file mode 100644 index 0000000000..dedb9f801f --- /dev/null +++ b/zephyr/test/drivers/host_cmd_read_memmap/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +target_sources(app PRIVATE + src/read_memmap.c +) diff --git a/zephyr/test/drivers/host_cmd_read_memmap/src/read_memmap.c b/zephyr/test/drivers/host_cmd_read_memmap/src/read_memmap.c new file mode 100644 index 0000000000..17ae4109f9 --- /dev/null +++ b/zephyr/test/drivers/host_cmd_read_memmap/src/read_memmap.c @@ -0,0 +1,96 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" +#include "host_command.h" +#include "test/drivers/test_state.h" + +#include +#include + +#ifndef CONFIG_PLATFORM_EC_SWITCH +FAKE_VOID_FUNC(switch_interrupt, int); +#endif + +ZTEST(ec_cmd_read_memmap, id) +{ + struct ec_params_read_memmap params = { + .offset = EC_MEMMAP_ID, + .size = 2, + }; + uint8_t response[2]; + int rv; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_READ_MEMMAP, 0, response, params); + + rv = host_command_process(&args); + + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_equal(rv, EC_RES_INVALID_COMMAND, "Got %d", rv); + return; + } + + zassert_ok(rv, "Got %d", rv); + /* Response should be 'E' 'C' */ + zassert_equal('E', response[0]); + zassert_equal('C', response[1]); +} + +ZTEST(ec_cmd_read_memmap, switches) +{ + struct ec_params_read_memmap params = { + .offset = EC_MEMMAP_SWITCHES, + .size = 1, + }; + uint8_t response[1]; + int rv; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_READ_MEMMAP, 0, response, params); + + rv = host_command_process(&args); + + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_equal(rv, EC_RES_INVALID_COMMAND, "Got %d", rv); + return; + } + + /* This test suite is run with CONFIG_PLATFORM_EC_SWITCH enabled + * and disabled. + */ + if (IS_ENABLED(CONFIG_PLATFORM_EC_SWITCH)) { + zassert_ok(rv, "Got %d", rv); + } else { + zassert_equal(rv, EC_RES_UNAVAILABLE, "Got %d", rv); + } +} + +ZTEST(ec_cmd_read_memmap, invalid) +{ + struct ec_params_read_memmap params = { + .offset = EC_MEMMAP_ID, + .size = UINT8_MAX, + }; + uint8_t response[2]; + int rv; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_READ_MEMMAP, 0, response, params); + + rv = host_command_process(&args); + + if (IS_ENABLED(CONFIG_HOSTCMD_X86)) { + zassert_equal(rv, EC_RES_INVALID_COMMAND, "Got %d", rv); + return; + } + + /* Verify offset+size exceeding max fails */ + zassert_equal(rv, EC_RES_INVALID_PARAM, "Got %d", rv); + + /* Verify params.size > response_max fails */ + params.size = 4; + zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM); +} + +ZTEST_SUITE(ec_cmd_read_memmap, drivers_predicate_post_main, NULL, NULL, NULL, + NULL); diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index f576213345..68e77fab94 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -96,6 +96,19 @@ tests: - CONFIG_PLATFORM_EC_USB_PD_LOGGING=y - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y - CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y + drivers.host_cmd_read_memmap: + extra_configs: + - CONFIG_LINK_TEST_SUITE_HOST_COMMAND_READ_MEMMAP=y + - CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y + - CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI=n + - CONFIG_PLATFORM_EC_HOST_INTERFACE_SHI=y + drivers.host_cmd_read_memmap.no_switches: + extra_configs: + - CONFIG_LINK_TEST_SUITE_HOST_COMMAND_READ_MEMMAP=y + - CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y + - CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI=n + - CONFIG_PLATFORM_EC_HOST_INTERFACE_SHI=y + - CONFIG_PLATFORM_EC_SWITCH=n drivers.isl923x: extra_configs: - CONFIG_LINK_TEST_SUITE_ISL923X=y -- cgit v1.2.1 From e6da633c3840a90479a01224fcde04135408c787 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Wed, 23 Nov 2022 13:51:53 -0700 Subject: driver: Sort header files Sort all includes in driver with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis Change-Id: I675e0db416b6b7cbcfce031c97fd24ad97b66f4f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052767 Reviewed-by: Yuval Peress Commit-Queue: Jeremy Bettis Code-Coverage: Zoss Tested-by: Jeremy Bettis Reviewed-by: Tom Hughes --- driver/accel_bma2x2.c | 2 +- driver/accel_bma4xx.c | 5 +++-- driver/accel_kionix.c | 6 +++--- driver/accel_kionix.h | 2 +- driver/accel_lis2dh.c | 4 ++-- driver/accel_lis2dw12.c | 2 +- driver/accelgyro_bmi160.c | 6 +++--- driver/accelgyro_bmi260.c | 4 ++-- driver/accelgyro_bmi_common.c | 4 ++-- driver/accelgyro_icm42607.c | 2 +- driver/accelgyro_icm426xx.c | 2 +- driver/accelgyro_icm_common.c | 4 ++-- driver/accelgyro_icm_common.h | 6 +++--- driver/accelgyro_lsm6dsm.h | 4 ++-- driver/als_cm32183.c | 2 +- driver/als_tcs3400.c | 2 +- driver/amd_stt.c | 2 +- driver/battery/bq27621_g1.c | 2 +- driver/bc12/max14637.c | 2 +- driver/bc12/mt6360.c | 4 ++-- driver/bc12/pi3usb9201.c | 2 +- driver/charger/bd9995x.c | 2 +- driver/charger/bq24715.c | 2 +- driver/charger/bq24773.c | 2 +- driver/charger/bq25710.c | 6 +++--- driver/charger/isl923x.c | 2 +- driver/charger/isl9241.c | 4 ++-- driver/charger/rt946x.c | 4 ++-- driver/charger/rt9490.c | 6 +++--- driver/charger/rt9490.h | 4 ++-- driver/charger/sm5803.c | 2 +- driver/fingerprint/elan/elan_private.c | 16 ++++++++-------- driver/fingerprint/elan/elan_sensor_pal.c | 14 +++++++------- driver/fingerprint/fpc/bep/fpc_misc.c | 6 +++--- driver/fingerprint/fpc/bep/fpc_private.c | 7 +++---- driver/fingerprint/fpc/bep/fpc_sensor_spi.c | 11 +++++------ driver/fingerprint/fpc/bep/fpc_timebase.c | 4 ++-- driver/fingerprint/fpc/bep/fpc_timebase.h | 4 ++-- driver/fingerprint/fpc/fpc_sensor.c | 3 ++- driver/fingerprint/fpc/libfp/fpc_private.c | 7 ++++--- driver/fingerprint/fpc/libfp/fpc_sensor_pal.c | 2 +- driver/gl3590.c | 5 ++--- driver/ina2xx.c | 2 +- driver/ina3221.c | 2 +- driver/ioexpander/it8801.c | 2 +- driver/ioexpander/pcal6408.c | 2 +- driver/led/aw20198.c | 4 ++-- driver/led/is31fl3733b.c | 3 ++- driver/led/is31fl3743b.c | 4 ++-- driver/led/mp3385.h | 2 +- driver/led/oz554.h | 2 +- driver/led/tlc59116f.c | 4 ++-- driver/ln9310.c | 2 +- driver/mag_lis2mdl.c | 2 +- driver/mcdp28x0.c | 2 +- driver/nfc/ctn730.c | 2 +- driver/nvidia_gpu.c | 4 ++-- driver/ppc/ktu1125.c | 4 ++-- driver/ppc/ktu1125.h | 1 - driver/ppc/nx20p348x.c | 4 ++-- driver/ppc/sn5s330.c | 4 ++-- driver/ppc/sn5s330.h | 1 - driver/ppc/syv682x.c | 4 ++-- driver/retimer/anx7483.c | 2 +- driver/retimer/bb_retimer.c | 2 +- driver/retimer/nb7v904m.c | 3 ++- driver/retimer/pi3dpx1207.c | 2 +- driver/sb_rmi.c | 2 +- driver/stm_mems_common.h | 4 ++-- driver/tcpm/anx7447.c | 2 +- driver/tcpm/anx7447.h | 2 +- driver/tcpm/anx74xx.c | 2 +- driver/tcpm/fusb302.c | 2 +- driver/tcpm/it83xx.c | 4 ++-- driver/tcpm/it83xx_pd.h | 4 ++-- driver/tcpm/it8xxx2.c | 4 ++-- driver/tcpm/nct38xx.c | 3 ++- driver/tcpm/ps8xxx.h | 3 +-- driver/tcpm/rt1718s.h | 2 +- driver/tcpm/stm32gx.c | 4 ++-- driver/tcpm/tcpci.c | 2 +- driver/tcpm/tusb422.c | 2 +- driver/temp_sensor/adt7481.c | 4 ++-- driver/temp_sensor/amd_r19me4070.c | 2 +- driver/temp_sensor/f75303.c | 4 ++-- driver/temp_sensor/g753.c | 2 +- driver/temp_sensor/g78x.c | 2 +- driver/temp_sensor/oti502.c | 4 ++-- driver/temp_sensor/pct2075.c | 2 +- driver/temp_sensor/tmp112.c | 2 +- driver/temp_sensor/tmp411.c | 4 ++-- driver/temp_sensor/tmp432.c | 4 ++-- driver/temp_sensor/tmp468.c | 7 +++---- driver/touchpad_elan.c | 6 +++--- driver/touchpad_gt7288.c | 4 ++-- driver/touchpad_st.c | 4 ++-- driver/touchpad_st.h | 4 ++-- driver/usb_mux/pi3usb3x532.h | 2 +- driver/usb_mux/tusb1064.h | 3 ++- driver/usb_mux/usb_mux.c | 2 +- driver/wpc/p9221.h | 2 +- include/driver/accel_lis2dw12_public.h | 1 + 102 files changed, 178 insertions(+), 177 deletions(-) diff --git a/driver/accel_bma2x2.c b/driver/accel_bma2x2.c index 08e818cb8d..772ae64696 100644 --- a/driver/accel_bma2x2.c +++ b/driver/accel_bma2x2.c @@ -9,11 +9,11 @@ * Supported: BMA255 */ +#include "accel_bma2x2.h" #include "accelgyro.h" #include "builtin/assert.h" #include "common.h" #include "console.h" -#include "accel_bma2x2.h" #include "i2c.h" #include "math_util.h" #include "spi.h" diff --git a/driver/accel_bma4xx.c b/driver/accel_bma4xx.c index b731bca422..29d05a35d8 100644 --- a/driver/accel_bma4xx.c +++ b/driver/accel_bma4xx.c @@ -9,17 +9,18 @@ * Supported: BMA422 */ -#include "accelgyro.h" #include "accel_bma422.h" +#include "accelgyro.h" #include "builtin/assert.h" #include "common.h" #include "console.h" -#include "i2c.h" #include "hwtimer.h" +#include "i2c.h" #include "math_util.h" #include "spi.h" #include "task.h" #include "util.h" + #include #ifdef CONFIG_ACCEL_BMA4XX_INT_EVENT diff --git a/driver/accel_kionix.c b/driver/accel_kionix.c index cc12987f40..c04855c89d 100644 --- a/driver/accel_kionix.c +++ b/driver/accel_kionix.c @@ -9,12 +9,12 @@ * Supported: KX022, KXCJ9 */ -#include "accelgyro.h" -#include "common.h" -#include "console.h" #include "accel_kionix.h" #include "accel_kx022.h" #include "accel_kxcj9.h" +#include "accelgyro.h" +#include "common.h" +#include "console.h" #include "i2c.h" #include "math_util.h" #include "motion_orientation.h" diff --git a/driver/accel_kionix.h b/driver/accel_kionix.h index 8777396e01..4f5d02ee55 100644 --- a/driver/accel_kionix.h +++ b/driver/accel_kionix.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_ACCEL_KIONIX_H #define __CROS_EC_ACCEL_KIONIX_H -#include "common.h" #include "accelgyro.h" +#include "common.h" #include "driver/accel_kx022.h" #include "driver/accel_kxcj9.h" diff --git a/driver/accel_lis2dh.c b/driver/accel_lis2dh.c index eaedb216d7..26954f3c4b 100644 --- a/driver/accel_lis2dh.c +++ b/driver/accel_lis2dh.c @@ -11,14 +11,14 @@ #include "accelgyro.h" #include "common.h" #include "console.h" +#include "driver/accel_lis2dh.h" +#include "driver/stm_mems_common.h" #include "hooks.h" #include "hwtimer.h" #include "i2c.h" #include "math_util.h" #include "task.h" #include "util.h" -#include "driver/accel_lis2dh.h" -#include "driver/stm_mems_common.h" #define CPUTS(outstr) cputs(CC_ACCEL, outstr) #define CPRINTS(format, args...) cprints(CC_ACCEL, format, ##args) diff --git a/driver/accel_lis2dw12.c b/driver/accel_lis2dw12.c index 3cf3e4b64a..42d9381bda 100644 --- a/driver/accel_lis2dw12.c +++ b/driver/accel_lis2dw12.c @@ -7,10 +7,10 @@ * LIS2DW12 accelerometer module for Chrome EC 3D digital accelerometer. * For more details on LIS2DW12 device please refers to www.st.com. */ +#include "accel_lis2dw12.h" #include "accelgyro.h" #include "common.h" #include "console.h" -#include "accel_lis2dw12.h" #include "hooks.h" #include "hwtimer.h" #include "math_util.h" diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c index 0a736760d0..7a398e5f4b 100644 --- a/driver/accelgyro_bmi160.c +++ b/driver/accelgyro_bmi160.c @@ -9,14 +9,14 @@ */ #include "accelgyro.h" +#include "accelgyro_bmi160.h" +#include "accelgyro_bmi_common.h" #include "builtin/assert.h" #include "common.h" #include "console.h" -#include "accelgyro_bmi_common.h" -#include "accelgyro_bmi160.h" -#include "mag_bmm150.h" #include "hwtimer.h" #include "i2c.h" +#include "mag_bmm150.h" #include "math_util.h" #include "motion_orientation.h" #include "motion_sense_fifo.h" diff --git a/driver/accelgyro_bmi260.c b/driver/accelgyro_bmi260.c index f0b16be4d5..1b47983b80 100644 --- a/driver/accelgyro_bmi260.c +++ b/driver/accelgyro_bmi260.c @@ -9,10 +9,10 @@ */ #include "accelgyro.h" +#include "accelgyro_bmi260.h" +#include "accelgyro_bmi_common.h" #include "builtin/assert.h" #include "console.h" -#include "accelgyro_bmi_common.h" -#include "accelgyro_bmi260.h" #include "hwtimer.h" #include "i2c.h" #include "init_rom.h" diff --git a/driver/accelgyro_bmi_common.c b/driver/accelgyro_bmi_common.c index 73131b0aae..27aab34c3e 100644 --- a/driver/accelgyro_bmi_common.c +++ b/driver/accelgyro_bmi_common.c @@ -9,11 +9,11 @@ */ #include "accelgyro.h" -#include "console.h" #include "accelgyro_bmi_common.h" +#include "console.h" +#include "i2c.h" #include "mag_bmm150.h" #include "mag_lis2mdl.h" -#include "i2c.h" #include "math_util.h" #include "motion_sense_fifo.h" #include "spi.h" diff --git a/driver/accelgyro_icm42607.c b/driver/accelgyro_icm42607.c index 28a131d33f..f57f11fae2 100644 --- a/driver/accelgyro_icm42607.c +++ b/driver/accelgyro_icm42607.c @@ -10,8 +10,8 @@ #include "accelgyro.h" #include "console.h" -#include "driver/accelgyro_icm_common.h" #include "driver/accelgyro_icm42607.h" +#include "driver/accelgyro_icm_common.h" #include "hwtimer.h" #include "i2c.h" #include "math_util.h" diff --git a/driver/accelgyro_icm426xx.c b/driver/accelgyro_icm426xx.c index 0311ed8187..c3c9e2225f 100644 --- a/driver/accelgyro_icm426xx.c +++ b/driver/accelgyro_icm426xx.c @@ -10,8 +10,8 @@ #include "accelgyro.h" #include "console.h" -#include "driver/accelgyro_icm_common.h" #include "driver/accelgyro_icm426xx.h" +#include "driver/accelgyro_icm_common.h" #include "hwtimer.h" #include "i2c.h" #include "math_util.h" diff --git a/driver/accelgyro_icm_common.c b/driver/accelgyro_icm_common.c index 22a2b0820d..44a3b61370 100644 --- a/driver/accelgyro_icm_common.c +++ b/driver/accelgyro_icm_common.c @@ -10,10 +10,10 @@ #include "accelgyro.h" #include "console.h" +#include "driver/accelgyro_icm426xx.h" +#include "driver/accelgyro_icm_common.h" #include "i2c.h" #include "spi.h" -#include "driver/accelgyro_icm_common.h" -#include "driver/accelgyro_icm426xx.h" #define CPUTS(outstr) cputs(CC_ACCEL, outstr) #define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ##args) diff --git a/driver/accelgyro_icm_common.h b/driver/accelgyro_icm_common.h index 400c56ba6f..32adf6f5ff 100644 --- a/driver/accelgyro_icm_common.h +++ b/driver/accelgyro_icm_common.h @@ -8,12 +8,12 @@ #ifndef __CROS_EC_ACCELGYRO_ICM_COMMON_H #define __CROS_EC_ACCELGYRO_ICM_COMMON_H -#include - #include "accelgyro.h" +#include "builtin/stddef.h" #include "hwtimer.h" #include "timer.h" -#include "builtin/stddef.h" + +#include #if !defined(CONFIG_ACCELGYRO_ICM_COMM_SPI) && \ !defined(CONFIG_ACCELGYRO_ICM_COMM_I2C) diff --git a/driver/accelgyro_lsm6dsm.h b/driver/accelgyro_lsm6dsm.h index 51da2a42fb..8fa53c6a6d 100644 --- a/driver/accelgyro_lsm6dsm.h +++ b/driver/accelgyro_lsm6dsm.h @@ -8,10 +8,10 @@ #ifndef __CROS_EC_ACCELGYRO_LSM6DSM_H #define __CROS_EC_ACCELGYRO_LSM6DSM_H -#include "stm_mems_common.h" -#include "mag_cal.h" #include "mag_bmm150.h" +#include "mag_cal.h" #include "mag_lis2mdl.h" +#include "stm_mems_common.h" /* * 7-bit address is 110101xb. Where 'x' is determined diff --git a/driver/als_cm32183.c b/driver/als_cm32183.c index d97c179fe8..a2ee9f365e 100644 --- a/driver/als_cm32183.c +++ b/driver/als_cm32183.c @@ -5,10 +5,10 @@ * CAPELLA CM32183 light sensor driver */ +#include "accelgyro.h" #include "common.h" #include "driver/als_cm32183.h" #include "i2c.h" -#include "accelgyro.h" #include "math_util.h" struct cm32183_drv_data { diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c index 002e269ada..8874ce79d6 100644 --- a/driver/als_tcs3400.c +++ b/driver/als_tcs3400.c @@ -5,9 +5,9 @@ * AMS TCS3400 light sensor driver */ #include "accelgyro.h" +#include "als_tcs3400.h" #include "common.h" #include "console.h" -#include "als_tcs3400.h" #include "hooks.h" #include "hwtimer.h" #include "i2c.h" diff --git a/driver/amd_stt.c b/driver/amd_stt.c index 93da8cecb5..a80220033c 100644 --- a/driver/amd_stt.c +++ b/driver/amd_stt.c @@ -4,8 +4,8 @@ */ #include "amd_stt.h" -#include "common.h" #include "chipset.h" +#include "common.h" #include "console.h" #include "driver/sb_rmi.h" #include "hooks.h" diff --git a/driver/battery/bq27621_g1.c b/driver/battery/bq27621_g1.c index f29039f0c1..73ca8476b3 100644 --- a/driver/battery/bq27621_g1.c +++ b/driver/battery/bq27621_g1.c @@ -11,8 +11,8 @@ #include "extpower.h" #include "hooks.h" #include "i2c.h" -#include "util.h" #include "timer.h" +#include "util.h" #define BQ27621_ADDR_FLAGS 0x55 #define BQ27621_TYPE_ID 0x0621 diff --git a/driver/bc12/max14637.c b/driver/bc12/max14637.c index 09fa009c45..a2603c7973 100644 --- a/driver/bc12/max14637.c +++ b/driver/bc12/max14637.c @@ -13,13 +13,13 @@ */ #include "builtin/assert.h" -#include "max14637.h" #include "charge_manager.h" #include "chipset.h" #include "common.h" #include "console.h" #include "gpio.h" #include "hooks.h" +#include "max14637.h" #include "power.h" #include "power/cannonlake.h" #include "task.h" diff --git a/driver/bc12/mt6360.c b/driver/bc12/mt6360.c index 49ec031e09..ca4bf11794 100644 --- a/driver/bc12/mt6360.c +++ b/driver/bc12/mt6360.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include "charger.h" #include "charge_manager.h" +#include "charger.h" #include "console.h" #include "crc8.h" -#include "mt6360.h" #include "ec_commands.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" +#include "mt6360.h" #include "task.h" #include "timer.h" #include "usb_charge.h" diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c index e892c34e8c..4e39933657 100644 --- a/driver/bc12/pi3usb9201.c +++ b/driver/bc12/pi3usb9201.c @@ -5,12 +5,12 @@ /* PI3USB9201 USB BC 1.2 Charger Detector driver. */ -#include "pi3usb9201.h" #include "charge_manager.h" #include "chipset.h" #include "common.h" #include "console.h" #include "gpio.h" +#include "pi3usb9201.h" #include "power.h" #include "task.h" #include "timer.h" diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c index f7e4ffacaa..f8e426fdc3 100644 --- a/driver/charger/bd9995x.c +++ b/driver/charger/bd9995x.c @@ -18,9 +18,9 @@ #include "panic.h" #include "task.h" #include "time.h" -#include "util.h" #include "usb_charge.h" #include "usb_pd.h" +#include "util.h" #define OTPROM_LOAD_WAIT_RETRY 3 diff --git a/driver/charger/bq24715.c b/driver/charger/bq24715.c index 0847618f3c..6855d6e334 100644 --- a/driver/charger/bq24715.c +++ b/driver/charger/bq24715.c @@ -8,8 +8,8 @@ #include "battery_smart.h" #include "bq24715.h" #include "charger.h" -#include "console.h" #include "common.h" +#include "console.h" #include "i2c.h" #include "util.h" diff --git a/driver/charger/bq24773.c b/driver/charger/bq24773.c index bfa0aa36e7..d678944ceb 100644 --- a/driver/charger/bq24773.c +++ b/driver/charger/bq24773.c @@ -8,8 +8,8 @@ #include "battery_smart.h" #include "bq24773.h" #include "charger.h" -#include "console.h" #include "common.h" +#include "console.h" #include "util.h" /* diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c index 831f7e110d..222d2f58a4 100644 --- a/driver/charger/bq25710.c +++ b/driver/charger/bq25710.c @@ -5,8 +5,6 @@ * TI bq25710 battery charger driver. */ -#include - #include "battery.h" #include "battery_smart.h" #include "bq257x0_regs.h" @@ -17,11 +15,13 @@ #include "console.h" #include "hooks.h" #include "i2c.h" -#include "task.h" #include "system.h" +#include "task.h" #include "timer.h" #include "util.h" +#include + #if !defined(CONFIG_CHARGER_BQ25710) && !defined(CONFIG_CHARGER_BQ25720) #error Only the BQ25720 and BQ25710 are supported by bq25710 driver. #endif diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index 17798b113d..dac1df69a2 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -11,9 +11,9 @@ #include "builtin/assert.h" #include "charge_state_v2.h" #include "charger.h" +#include "common.h" #include "compile_time_macros.h" #include "console.h" -#include "common.h" #include "hooks.h" #include "i2c.h" #include "isl923x.h" diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c index 6ff0db26e9..445d94734c 100644 --- a/driver/charger/isl9241.c +++ b/driver/charger/isl9241.c @@ -11,11 +11,11 @@ #endif #include "battery.h" #include "battery_smart.h" -#include "charger.h" #include "charge_manager.h" #include "charge_state.h" -#include "console.h" +#include "charger.h" #include "common.h" +#include "console.h" #include "hooks.h" #include "i2c.h" #include "isl9241.h" diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c index 58b5c1adb4..0e52d8e3bb 100644 --- a/driver/charger/rt946x.c +++ b/driver/charger/rt946x.c @@ -7,17 +7,17 @@ #include "battery.h" #include "battery_smart.h" -#include "charger.h" #include "charge_manager.h" +#include "charger.h" #include "common.h" #include "compile_time_macros.h" #include "config.h" #include "console.h" +#include "driver/wpc/p9221.h" #include "extpower.h" #include "hooks.h" #include "i2c.h" #include "printf.h" -#include "driver/wpc/p9221.h" #include "rt946x.h" #include "task.h" #include "tcpm/tcpm.h" diff --git a/driver/charger/rt9490.c b/driver/charger/rt9490.c index c0bf873e43..016ef12d44 100644 --- a/driver/charger/rt9490.c +++ b/driver/charger/rt9490.c @@ -9,8 +9,8 @@ #include "battery_smart.h" #include "builtin/assert.h" #include "builtin/endian.h" -#include "charger.h" #include "charge_manager.h" +#include "charger.h" #include "common.h" #include "config.h" #include "console.h" @@ -18,11 +18,11 @@ #include "i2c.h" #include "rt9490.h" #include "task.h" +#include "temp_sensor/temp_sensor.h" +#include "temp_sensor/thermistor.h" #include "usb_charge.h" #include "usb_pd.h" #include "util.h" -#include "temp_sensor/temp_sensor.h" -#include "temp_sensor/thermistor.h" /* Console output macros */ #define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args) diff --git a/driver/charger/rt9490.h b/driver/charger/rt9490.h index 135c3271be..88f979ae5e 100644 --- a/driver/charger/rt9490.h +++ b/driver/charger/rt9490.h @@ -4,10 +4,10 @@ * * Richtek 5A 1-4 cell buck-boost switching battery charger driver. */ -#include - #include "temp_sensor.h" +#include + #ifndef __CROS_EC_RT9490_H #define __CROS_EC_RT9490_H diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c index a64e541f6b..57b1a0330f 100644 --- a/driver/charger/sm5803.c +++ b/driver/charger/sm5803.c @@ -14,8 +14,8 @@ #include "hooks.h" #include "i2c.h" #include "sm5803.h" -#include "system.h" #include "stdbool.h" +#include "system.h" #include "throttle_ap.h" #include "timer.h" #include "usb_charge.h" diff --git a/driver/fingerprint/elan/elan_private.c b/driver/fingerprint/elan/elan_private.c index fc95ceb685..a176f29f0d 100644 --- a/driver/fingerprint/elan/elan_private.c +++ b/driver/fingerprint/elan/elan_private.c @@ -3,24 +3,24 @@ * found in the LICENSE file. */ -#include #include "common.h" #include "console.h" +#include "cryptoc/util.h" +#include "elan_sensor.h" +#include "elan_sensor_pal.h" +#include "elan_setting.h" #include "endian.h" +#include "fpsensor.h" #include "gpio.h" #include "link_defs.h" +#include "math_util.h" +#include "shared_mem.h" #include "spi.h" #include "system.h" #include "timer.h" #include "util.h" -#include "shared_mem.h" -#include "math_util.h" -#include "fpsensor.h" -#include "cryptoc/util.h" -#include "elan_sensor.h" -#include "elan_setting.h" -#include "elan_sensor_pal.h" +#include static uint16_t errors; diff --git a/driver/fingerprint/elan/elan_sensor_pal.c b/driver/fingerprint/elan/elan_sensor_pal.c index 4056c52f38..2a91fe176e 100644 --- a/driver/fingerprint/elan/elan_sensor_pal.c +++ b/driver/fingerprint/elan/elan_sensor_pal.c @@ -4,24 +4,24 @@ */ /* ELAN Platform Abstraction Layer callbacks */ -#include #include "common.h" #include "console.h" +#include "cryptoc/util.h" +#include "elan_sensor.h" +#include "elan_sensor_pal.h" +#include "elan_setting.h" #include "endian.h" #include "fpsensor.h" #include "gpio.h" #include "link_defs.h" +#include "math_util.h" +#include "shared_mem.h" #include "spi.h" #include "system.h" #include "timer.h" #include "util.h" -#include "shared_mem.h" -#include "math_util.h" -#include "cryptoc/util.h" -#include "elan_setting.h" -#include "elan_sensor.h" -#include "elan_sensor_pal.h" +#include static uint8_t tx_buf[CONFIG_SPI_TX_BUF_SIZE] __uncached; static uint8_t rx_buf[CONFIG_SPI_RX_BUF_SIZE] __uncached; diff --git a/driver/fingerprint/fpc/bep/fpc_misc.c b/driver/fingerprint/fpc/bep/fpc_misc.c index f78a429233..6b716e0524 100644 --- a/driver/fingerprint/fpc/bep/fpc_misc.c +++ b/driver/fingerprint/fpc/bep/fpc_misc.c @@ -5,12 +5,12 @@ /* FPC Platform Abstraction Layer */ -#include -#include - #include "shared_mem.h" #include "uart.h" +#include +#include + void __unused *fpc_malloc(uint32_t size) { char *data; diff --git a/driver/fingerprint/fpc/bep/fpc_private.c b/driver/fingerprint/fpc/bep/fpc_private.c index ac20e10758..70aa8fe8c5 100644 --- a/driver/fingerprint/fpc/bep/fpc_private.c +++ b/driver/fingerprint/fpc/bep/fpc_private.c @@ -3,9 +3,7 @@ * found in the LICENSE file. */ -#include -#include - +#include "driver/fingerprint/fpc/fpc_sensor.h" #include "fpc_bio_algorithm.h" #include "fpsensor.h" #include "gpio.h" @@ -13,7 +11,8 @@ #include "system.h" #include "util.h" -#include "driver/fingerprint/fpc/fpc_sensor.h" +#include +#include /* Console output macros */ #define CPRINTF(format, args...) cprintf(CC_FP, format, ##args) diff --git a/driver/fingerprint/fpc/bep/fpc_sensor_spi.c b/driver/fingerprint/fpc/bep/fpc_sensor_spi.c index 752b9909bc..565b29c69d 100644 --- a/driver/fingerprint/fpc/bep/fpc_sensor_spi.c +++ b/driver/fingerprint/fpc/bep/fpc_sensor_spi.c @@ -5,18 +5,17 @@ /* FPC Platform Abstraction Layer */ -#include -#include -#include - #include "console.h" -#include "fpsensor.h" +#include "driver/fingerprint/fpc/fpc_sensor.h" #include "fpc_sensor_spi.h" +#include "fpsensor.h" #include "gpio.h" #include "spi.h" #include "util.h" -#include "driver/fingerprint/fpc/fpc_sensor.h" +#include +#include +#include /* Console output macros */ #define CPRINTF(format, args...) cprintf(CC_FP, format, ##args) diff --git a/driver/fingerprint/fpc/bep/fpc_timebase.c b/driver/fingerprint/fpc/bep/fpc_timebase.c index a63a4c3d6d..c34b9e27db 100644 --- a/driver/fingerprint/fpc/bep/fpc_timebase.c +++ b/driver/fingerprint/fpc/bep/fpc_timebase.c @@ -5,11 +5,11 @@ /* FPC Platform Abstraction Layer */ -#include - #include "fpc_timebase.h" #include "timer.h" +#include + uint32_t __unused fpc_timebase_get_tick(void) { clock_t time; diff --git a/driver/fingerprint/fpc/bep/fpc_timebase.h b/driver/fingerprint/fpc/bep/fpc_timebase.h index ce9018461b..35cf67fed2 100644 --- a/driver/fingerprint/fpc/bep/fpc_timebase.h +++ b/driver/fingerprint/fpc/bep/fpc_timebase.h @@ -13,10 +13,10 @@ * Supplies tick counter and wait operation(s). */ -#include - #include "common.h" +#include + /** * @brief Reads the system tick counter. * diff --git a/driver/fingerprint/fpc/fpc_sensor.c b/driver/fingerprint/fpc/fpc_sensor.c index bbab729b12..9cb97a9125 100644 --- a/driver/fingerprint/fpc/fpc_sensor.c +++ b/driver/fingerprint/fpc/fpc_sensor.c @@ -4,9 +4,10 @@ */ #include + +#include #include #include -#include #if defined(CONFIG_FP_SENSOR_FPC1025) || defined(CONFIG_FP_SENSOR_FPC1035) #include "bep/fpc_private.h" #elif defined(CONFIG_FP_SENSOR_FPC1145) diff --git a/driver/fingerprint/fpc/libfp/fpc_private.c b/driver/fingerprint/fpc/libfp/fpc_private.c index fcc0180784..8b1ceff405 100644 --- a/driver/fingerprint/fpc/libfp/fpc_private.c +++ b/driver/fingerprint/fpc/libfp/fpc_private.c @@ -3,10 +3,9 @@ * found in the LICENSE file. */ -#include -#include #include "common.h" #include "console.h" +#include "driver/fingerprint/fpc/fpc_sensor.h" #include "fpc_bio_algorithm.h" #include "fpc_private.h" #include "fpsensor.h" @@ -17,7 +16,9 @@ #include "timer.h" #include "util.h" -#include "driver/fingerprint/fpc/fpc_sensor.h" +#include + +#include #define CPRINTF(format, args...) cprintf(CC_FP, format, ##args) #define CPRINTS(format, args...) cprints(CC_FP, format, ##args) diff --git a/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c b/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c index c0578bc09b..a856e0afaf 100644 --- a/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c +++ b/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c @@ -6,8 +6,8 @@ #include "common.h" #include "console.h" -#include "fpsensor.h" #include "fpc_sensor_pal.h" +#include "fpsensor.h" #include "shared_mem.h" #include "spi.h" #include "timer.h" diff --git a/driver/gl3590.c b/driver/gl3590.c index da374fbc88..03af496293 100644 --- a/driver/gl3590.c +++ b/driver/gl3590.c @@ -4,13 +4,12 @@ */ #include "console.h" +#include "gl3590.h" #include "hooks.h" #include "i2c.h" +#include "pwr_defs.h" #include "system.h" #include "util.h" -#include "pwr_defs.h" - -#include "gl3590.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args) diff --git a/driver/ina2xx.c b/driver/ina2xx.c index e09c141f50..64a2dadeed 100644 --- a/driver/ina2xx.c +++ b/driver/ina2xx.c @@ -8,9 +8,9 @@ #include "console.h" #include "hooks.h" #include "i2c.h" +#include "ina2xx.h" #include "system.h" #include "timer.h" -#include "ina2xx.h" #include "util.h" /* Console output macros */ diff --git a/driver/ina3221.c b/driver/ina3221.c index 4659552497..ec28ec3f26 100644 --- a/driver/ina3221.c +++ b/driver/ina3221.c @@ -8,9 +8,9 @@ #include "console.h" #include "hooks.h" #include "i2c.h" +#include "ina3221.h" #include "system.h" #include "timer.h" -#include "ina3221.h" #include "util.h" /* Console output macros */ diff --git a/driver/ioexpander/it8801.c b/driver/ioexpander/it8801.c index f484e33284..932cbb2648 100644 --- a/driver/ioexpander/it8801.c +++ b/driver/ioexpander/it8801.c @@ -10,12 +10,12 @@ #include "i2c.h" #include "ioexpander.h" #include "it8801.h" +#include "keyboard_backlight.h" #include "keyboard_raw.h" #include "keyboard_scan.h" #include "registers.h" #include "task.h" #include "util.h" -#include "keyboard_backlight.h" #define CPRINTS(format, args...) cprints(CC_KEYSCAN, format, ##args) diff --git a/driver/ioexpander/pcal6408.c b/driver/ioexpander/pcal6408.c index 1b746bffc3..cec5e5902e 100644 --- a/driver/ioexpander/pcal6408.c +++ b/driver/ioexpander/pcal6408.c @@ -6,10 +6,10 @@ */ #include "common.h" #include "console.h" -#include "math_util.h" #include "gpio.h" #include "i2c.h" #include "ioexpander.h" +#include "math_util.h" #include "pcal6408.h" #define CPRINTF(format, args...) cprintf(CC_GPIO, format, ##args) diff --git a/driver/led/aw20198.c b/driver/led/aw20198.c index e2eea69481..eca596d62e 100644 --- a/driver/led/aw20198.c +++ b/driver/led/aw20198.c @@ -2,8 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "aw20198.h" #include "common.h" #include "console.h" @@ -13,6 +11,8 @@ #include "stddef.h" #include "timer.h" +#include + #define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "AW20198: " fmt, ##args) #define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "AW20198: " fmt, ##args) diff --git a/driver/led/is31fl3733b.c b/driver/led/is31fl3733b.c index 33004d1cec..3ff0c19655 100644 --- a/driver/led/is31fl3733b.c +++ b/driver/led/is31fl3733b.c @@ -2,7 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include #include "common.h" #include "console.h" #include "gpio.h" @@ -11,6 +10,8 @@ #include "stddef.h" #include "timer.h" +#include + #define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "RGBKBD: " fmt, ##args) #define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "RGBKBD: " fmt, ##args) diff --git a/driver/led/is31fl3743b.c b/driver/led/is31fl3743b.c index 5eef21c388..6725c1d406 100644 --- a/driver/led/is31fl3743b.c +++ b/driver/led/is31fl3743b.c @@ -2,8 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "common.h" #include "console.h" #include "gpio.h" @@ -12,6 +10,8 @@ #include "stddef.h" #include "timer.h" +#include + #define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "RGBKBD: " fmt, ##args) #define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "RGBKBD: " fmt, ##args) diff --git a/driver/led/mp3385.h b/driver/led/mp3385.h index 733a8f76cd..2f179666d8 100644 --- a/driver/led/mp3385.h +++ b/driver/led/mp3385.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_MP3385_H #define __CROS_EC_MP3385_H -#include "gpio.h" #include "common.h" +#include "gpio.h" /* * Overridable board initialization. Should be overridden by a board diff --git a/driver/led/oz554.h b/driver/led/oz554.h index c735f9f3b9..27b43a1300 100644 --- a/driver/led/oz554.h +++ b/driver/led/oz554.h @@ -8,8 +8,8 @@ #ifndef __CROS_EC_OZ554_H #define __CROS_EC_OZ554_H -#include "gpio.h" #include "common.h" +#include "gpio.h" /* * Overridable board initialization. Should be overridden by a board diff --git a/driver/led/tlc59116f.c b/driver/led/tlc59116f.c index 1350602f6f..72e51e3fb8 100644 --- a/driver/led/tlc59116f.c +++ b/driver/led/tlc59116f.c @@ -2,8 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "common.h" #include "console.h" #include "i2c.h" @@ -11,6 +9,8 @@ #include "stddef.h" #include "tlc59116f.h" +#include + #define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "TLC59116F: " fmt, ##args) #define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "TLC59116F: " fmt, ##args) diff --git a/driver/ln9310.c b/driver/ln9310.c index 4a56568eb9..f9dfedfc54 100644 --- a/driver/ln9310.c +++ b/driver/ln9310.c @@ -10,8 +10,8 @@ #include "driver/ln9310.h" #include "hooks.h" #include "i2c.h" -#include "util.h" #include "timer.h" +#include "util.h" #define CPUTS(outstr) cputs(CC_I2C, outstr) #define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args) diff --git a/driver/mag_lis2mdl.c b/driver/mag_lis2mdl.c index e8a8cb82ca..a871f9e310 100644 --- a/driver/mag_lis2mdl.c +++ b/driver/mag_lis2mdl.c @@ -10,9 +10,9 @@ */ #include "common.h" +#include "driver/accelgyro_lsm6dsm.h" #include "driver/mag_lis2mdl.h" #include "driver/sensorhub_lsm6dsm.h" -#include "driver/accelgyro_lsm6dsm.h" #include "driver/stm_mems_common.h" #include "hwtimer.h" #include "mag_cal.h" diff --git a/driver/mcdp28x0.c b/driver/mcdp28x0.c index 1b56e6d53f..791c3c519f 100644 --- a/driver/mcdp28x0.c +++ b/driver/mcdp28x0.c @@ -5,9 +5,9 @@ * Megachips DisplayPort to HDMI protocol converter / level shifter driver. */ +#include "common.h" #include "config.h" #include "console.h" -#include "common.h" #include "ec_commands.h" #include "mcdp28x0.h" #include "queue.h" diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c index 4864d43080..c19b440824 100644 --- a/driver/nfc/ctn730.c +++ b/driver/nfc/ctn730.c @@ -4,9 +4,9 @@ */ #include "chipset.h" -#include "ctn730.h" #include "common.h" #include "console.h" +#include "ctn730.h" #include "gpio.h" #include "i2c.h" #include "peripheral_charger.h" diff --git a/driver/nvidia_gpu.c b/driver/nvidia_gpu.c index e9fbd156ac..b8a2195470 100644 --- a/driver/nvidia_gpu.c +++ b/driver/nvidia_gpu.c @@ -5,8 +5,6 @@ * Nvidia GPU D-Notify driver */ -#include - #include "charge_manager.h" #include "charge_state.h" #include "compile_time_macros.h" @@ -19,6 +17,8 @@ #include "throttle_ap.h" #include "timer.h" +#include + #define CPRINTS(fmt, args...) cprints(CC_GPU, "GPU: " fmt, ##args) #define CPRINTF(fmt, args...) cprintf(CC_GPU, "GPU: " fmt, ##args) diff --git a/driver/ppc/ktu1125.c b/driver/ppc/ktu1125.c index 047d011aac..f90168adef 100644 --- a/driver/ppc/ktu1125.c +++ b/driver/ppc/ktu1125.c @@ -7,14 +7,14 @@ #include "common.h" #include "console.h" -#include "ktu1125.h" #include "hooks.h" #include "i2c.h" +#include "ktu1125.h" #include "system.h" #include "timer.h" #include "usb_charge.h" -#include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" #include "usbc_ppc.h" #include "util.h" diff --git a/driver/ppc/ktu1125.h b/driver/ppc/ktu1125.h index 229c894b8c..9957ed80ec 100644 --- a/driver/ppc/ktu1125.h +++ b/driver/ppc/ktu1125.h @@ -9,7 +9,6 @@ #define __CROS_EC_KTU1125_H #include "common.h" - #include "driver/ppc/ktu1125_public.h" #define KTU1125_ID 0x0 diff --git a/driver/ppc/nx20p348x.c b/driver/ppc/nx20p348x.c index d202898a85..14dfb88e02 100644 --- a/driver/ppc/nx20p348x.c +++ b/driver/ppc/nx20p348x.c @@ -7,15 +7,15 @@ #include "common.h" #include "console.h" -#include "nx20p348x.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" +#include "nx20p348x.h" #include "system.h" #include "tcpm/tcpm.h" #include "usb_charge.h" -#include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" #include "usbc_ppc.h" #include "util.h" diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c index 385f27fe52..9404c8df76 100644 --- a/driver/ppc/sn5s330.c +++ b/driver/ppc/sn5s330.c @@ -12,14 +12,14 @@ #include "common.h" #include "console.h" -#include "sn5s330.h" #include "hooks.h" #include "i2c.h" +#include "sn5s330.h" #include "system.h" #include "timer.h" #include "usb_charge.h" -#include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" #include "usbc_ppc.h" #include "util.h" diff --git a/driver/ppc/sn5s330.h b/driver/ppc/sn5s330.h index 70a46920ee..3748370007 100644 --- a/driver/ppc/sn5s330.h +++ b/driver/ppc/sn5s330.h @@ -9,7 +9,6 @@ #define __CROS_EC_SN5S330_H #include "common.h" - #include "driver/ppc/sn5s330_public.h" struct sn5s330_config { diff --git a/driver/ppc/syv682x.c b/driver/ppc/syv682x.c index 88c6443ad0..42488a4a26 100644 --- a/driver/ppc/syv682x.c +++ b/driver/ppc/syv682x.c @@ -8,17 +8,17 @@ #include "common.h" #include "config.h" #include "console.h" -#include "syv682x.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" #include "system.h" +#include "syv682x.h" #include "tcpm/tcpm.h" #include "timer.h" #include "usb_charge.h" +#include "usb_pd.h" #include "usb_pd_tcpm.h" #include "usbc_ppc.h" -#include "usb_pd.h" #include "util.h" #define SYV682X_FLAGS_SOURCE_ENABLED BIT(0) diff --git a/driver/retimer/anx7483.c b/driver/retimer/anx7483.c index c587bec91f..f8b11f0e85 100644 --- a/driver/retimer/anx7483.c +++ b/driver/retimer/anx7483.c @@ -6,11 +6,11 @@ */ #include "anx7483.h" -#include "retimer/anx7483_public.h" #include "chipset.h" #include "common.h" #include "console.h" #include "i2c.h" +#include "retimer/anx7483_public.h" #include "timer.h" #include "usb_mux.h" #include "util.h" diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c index cb7c58c058..3bee94bb56 100644 --- a/driver/retimer/bb_retimer.c +++ b/driver/retimer/bb_retimer.c @@ -5,10 +5,10 @@ * Driver for Intel Burnside Bridge - Thunderbolt/USB/DisplayPort Retimer */ -#include "driver/retimer/bb_retimer.h" #include "chipset.h" #include "common.h" #include "console.h" +#include "driver/retimer/bb_retimer.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" diff --git a/driver/retimer/nb7v904m.c b/driver/retimer/nb7v904m.c index 58c57e5c95..2990a906b5 100644 --- a/driver/retimer/nb7v904m.c +++ b/driver/retimer/nb7v904m.c @@ -4,7 +4,6 @@ * * ON Semiconductor NB7V904M USB Type-C DisplayPort Alt Mode Redriver */ -#include #include "common.h" #include "console.h" #include "ec_commands.h" @@ -12,6 +11,8 @@ #include "nb7v904m.h" #include "usb_mux.h" +#include + #define CPRINTS(format, args...) cprints(CC_USB, format, ##args) #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) diff --git a/driver/retimer/pi3dpx1207.c b/driver/retimer/pi3dpx1207.c index 27ea474832..e40f269e3b 100644 --- a/driver/retimer/pi3dpx1207.c +++ b/driver/retimer/pi3dpx1207.c @@ -5,12 +5,12 @@ * PI3DPX1207 retimer. */ -#include "pi3dpx1207.h" #include "common.h" #include "console.h" #include "gpio.h" #include "i2c.h" #include "ioexpander.h" +#include "pi3dpx1207.h" #include "usb_mux.h" #define I2C_MAX_RETRIES 2 diff --git a/driver/sb_rmi.c b/driver/sb_rmi.c index 420ef672ad..62c105f6ff 100644 --- a/driver/sb_rmi.c +++ b/driver/sb_rmi.c @@ -5,8 +5,8 @@ /* AMD SB-RMI (Side-band Remote Management Interface) Driver */ -#include "common.h" #include "chipset.h" +#include "common.h" #include "console.h" #include "i2c.h" #include "sb_rmi.h" diff --git a/driver/stm_mems_common.h b/driver/stm_mems_common.h index 370ce10d9c..58e039bdd2 100644 --- a/driver/stm_mems_common.h +++ b/driver/stm_mems_common.h @@ -8,11 +8,11 @@ #ifndef __CROS_EC_ST_COMMONS_H #define __CROS_EC_ST_COMMONS_H -#include "common.h" -#include "util.h" #include "accelgyro.h" +#include "common.h" #include "console.h" #include "i2c.h" +#include "util.h" /* X, Y, Z axis data len */ #define OUT_XYZ_SIZE 6 diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c index 8c21f77536..4b8d82c034 100644 --- a/driver/tcpm/anx7447.c +++ b/driver/tcpm/anx7447.c @@ -5,9 +5,9 @@ /* ANX7447 port manager */ +#include "anx7447.h" #include "builtin/assert.h" #include "common.h" -#include "anx7447.h" #include "console.h" #include "hooks.h" #include "tcpm/tcpci.h" diff --git a/driver/tcpm/anx7447.h b/driver/tcpm/anx7447.h index 42de7502f1..56d810574d 100644 --- a/driver/tcpm/anx7447.h +++ b/driver/tcpm/anx7447.h @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "usb_mux.h" #include "driver/tcpm/anx7447_public.h" +#include "usb_mux.h" /* USB Power delivery port management */ diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index 64a9271f1c..e6ad23c25a 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -7,8 +7,8 @@ /* Type-C port manager for Analogix's anx74xx chips */ -#include "console.h" #include "anx74xx.h" +#include "console.h" #include "task.h" #include "tcpm/tcpci.h" #include "tcpm/tcpm.h" diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c index 4b4a15c711..3f11e568d0 100644 --- a/driver/tcpm/fusb302.c +++ b/driver/tcpm/fusb302.c @@ -9,8 +9,8 @@ #include "console.h" #include "fusb302.h" -#include "task.h" #include "hooks.h" +#include "task.h" #include "tcpm/tcpci.h" #include "tcpm/tcpm.h" #include "timer.h" diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c index 0b636e2e89..d04cb2f597 100644 --- a/driver/tcpm/it83xx.c +++ b/driver/tcpm/it83xx.c @@ -9,17 +9,17 @@ #include "common.h" #include "config.h" #include "console.h" +#include "hooks.h" #include "it83xx_pd.h" #include "registers.h" #include "system.h" #include "task.h" #include "tcpm/tcpci.h" #include "timer.h" -#include "util.h" #include "usb_common.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" -#include "hooks.h" +#include "util.h" #ifdef CONFIG_USB_PD_TCPMV1 #if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \ diff --git a/driver/tcpm/it83xx_pd.h b/driver/tcpm/it83xx_pd.h index 1ab76e2b79..2cb63aa22f 100644 --- a/driver/tcpm/it83xx_pd.h +++ b/driver/tcpm/it83xx_pd.h @@ -7,10 +7,10 @@ #ifndef __CROS_EC_DRIVER_TCPM_IT83XX_H #define __CROS_EC_DRIVER_TCPM_IT83XX_H -#include - #include "driver/tcpm/it8xxx2_pd_public.h" +#include + /* USBPD Controller */ #if defined(CONFIG_USB_PD_TCPM_DRIVER_IT83XX) #define IT83XX_USBPD_BASE(port) (0x00F03700 + (0x100 * (port))) diff --git a/driver/tcpm/it8xxx2.c b/driver/tcpm/it8xxx2.c index 6782b528e5..9bf50e1335 100644 --- a/driver/tcpm/it8xxx2.c +++ b/driver/tcpm/it8xxx2.c @@ -9,17 +9,17 @@ #include "common.h" #include "config.h" #include "console.h" +#include "hooks.h" #include "it83xx_pd.h" #include "ite_pd_intc.h" #include "registers.h" #include "system.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_common.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" -#include "hooks.h" +#include "util.h" #ifdef CONFIG_USB_PD_TCPMV1 #if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \ diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c index e3a9fc04a2..120749fb62 100644 --- a/driver/tcpm/nct38xx.c +++ b/driver/tcpm/nct38xx.c @@ -15,9 +15,10 @@ #include "usb_common.h" #ifdef CONFIG_ZEPHYR +#include "usbc/tcpc_nct38xx.h" + #include #include -#include "usbc/tcpc_nct38xx.h" #endif #if defined(CONFIG_ZEPHYR) && defined(CONFIG_IO_EXPANDER_NCT38XX) diff --git a/driver/tcpm/ps8xxx.h b/driver/tcpm/ps8xxx.h index 7d873abc85..ed3197c822 100644 --- a/driver/tcpm/ps8xxx.h +++ b/driver/tcpm/ps8xxx.h @@ -2,9 +2,8 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "usb_mux.h" - #include "driver/tcpm/ps8xxx_public.h" +#include "usb_mux.h" /* Parade Tech Type-C port controller */ diff --git a/driver/tcpm/rt1718s.h b/driver/tcpm/rt1718s.h index f7c821ba53..8ff977e26b 100644 --- a/driver/tcpm/rt1718s.h +++ b/driver/tcpm/rt1718s.h @@ -6,9 +6,9 @@ #define __CROS_EC_USB_PD_TCPM_RT1718S_H #include "tcpm/rt1718s_public.h" -#include "util.h" #include "usb_charge.h" #include "usb_pd_tcpm.h" +#include "util.h" /* RT1718S Private RegMap */ #define RT1718S_PHYCTRL1 0x80 diff --git a/driver/tcpm/stm32gx.c b/driver/tcpm/stm32gx.c index 77a436b2ac..029570faca 100644 --- a/driver/tcpm/stm32gx.c +++ b/driver/tcpm/stm32gx.c @@ -9,16 +9,16 @@ #include "common.h" #include "config.h" #include "console.h" +#include "hooks.h" #include "registers.h" #include "stm32gx.h" #include "system.h" #include "task.h" #include "tcpm/tcpci.h" #include "timer.h" -#include "util.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" -#include "hooks.h" +#include "util.h" /* * STM32G4 UCPD peripheral does not have the ability to detect VBUS, but diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 007d2aa2e6..243ca94bd5 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -5,8 +5,8 @@ /* Type-C port manager */ -#include "atomic.h" #include "anx74xx.h" +#include "atomic.h" #include "compile_time_macros.h" #include "console.h" #include "ec_commands.h" diff --git a/driver/tcpm/tusb422.c b/driver/tcpm/tusb422.c index 6d12d1758b..79554bd0cf 100644 --- a/driver/tcpm/tusb422.c +++ b/driver/tcpm/tusb422.c @@ -6,10 +6,10 @@ /* Type-C port manager for TI TUSB422 Port Controller */ #include "common.h" -#include "tusb422.h" #include "tcpm/tcpci.h" #include "tcpm/tcpm.h" #include "timer.h" +#include "tusb422.h" #include "usb_pd.h" #ifndef CONFIG_USB_PD_TCPM_TCPCI diff --git a/driver/temp_sensor/adt7481.c b/driver/temp_sensor/adt7481.c index 0157d64b2d..f0aee1506f 100644 --- a/driver/temp_sensor/adt7481.c +++ b/driver/temp_sensor/adt7481.c @@ -5,12 +5,12 @@ /* ADT7481 temperature sensor module for Chrome EC */ +#include "adt7481.h" #include "common.h" #include "console.h" -#include "adt7481.h" #include "gpio.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" #include "util.h" static int temp_val_local; diff --git a/driver/temp_sensor/amd_r19me4070.c b/driver/temp_sensor/amd_r19me4070.c index 97868b6945..3ee230da09 100644 --- a/driver/temp_sensor/amd_r19me4070.c +++ b/driver/temp_sensor/amd_r19me4070.c @@ -5,12 +5,12 @@ /* R19ME4070 temperature sensor module for Chrome EC */ +#include "amd_r19me4070.h" #include "chipset.h" #include "common.h" #include "console.h" #include "hooks.h" #include "i2c.h" -#include "amd_r19me4070.h" #include "power.h" #define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) diff --git a/driver/temp_sensor/f75303.c b/driver/temp_sensor/f75303.c index e686537c31..d83f7bc4a6 100644 --- a/driver/temp_sensor/f75303.c +++ b/driver/temp_sensor/f75303.c @@ -6,11 +6,11 @@ /* F75303 temperature sensor module for Chrome EC */ #include "common.h" +#include "console.h" #include "f75303.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" #include "util.h" -#include "console.h" static int temps[F75303_IDX_COUNT]; static int8_t fake_temp[F75303_IDX_COUNT] = { -1, -1, -1 }; diff --git a/driver/temp_sensor/g753.c b/driver/temp_sensor/g753.c index 8d94cac4f8..f162cbf846 100644 --- a/driver/temp_sensor/g753.c +++ b/driver/temp_sensor/g753.c @@ -9,8 +9,8 @@ #include "console.h" #include "g753.h" #include "gpio.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" #include "util.h" static int temp_val_local; diff --git a/driver/temp_sensor/g78x.c b/driver/temp_sensor/g78x.c index 82cb2d26e9..413e2dda8a 100644 --- a/driver/temp_sensor/g78x.c +++ b/driver/temp_sensor/g78x.c @@ -9,8 +9,8 @@ #include "console.h" #include "g78x.h" #include "gpio.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" #include "util.h" static int temp_val_local; diff --git a/driver/temp_sensor/oti502.c b/driver/temp_sensor/oti502.c index 2051df89f6..4564ad9257 100644 --- a/driver/temp_sensor/oti502.c +++ b/driver/temp_sensor/oti502.c @@ -7,9 +7,9 @@ #include "common.h" #include "console.h" -#include "oti502.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" +#include "oti502.h" #include "util.h" static int temp_val_ambient; /* Ambient is chip temperature*/ diff --git a/driver/temp_sensor/pct2075.c b/driver/temp_sensor/pct2075.c index de951ca6b1..02150ad796 100644 --- a/driver/temp_sensor/pct2075.c +++ b/driver/temp_sensor/pct2075.c @@ -7,8 +7,8 @@ #include "common.h" #include "console.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" #include "math_util.h" #include "temp_sensor/pct2075.h" #include "util.h" diff --git a/driver/temp_sensor/tmp112.c b/driver/temp_sensor/tmp112.c index 1af8679421..267227f6f3 100644 --- a/driver/temp_sensor/tmp112.c +++ b/driver/temp_sensor/tmp112.c @@ -7,8 +7,8 @@ #include "common.h" #include "console.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" #include "math_util.h" #include "temp_sensor/tmp112.h" #include "util.h" diff --git a/driver/temp_sensor/tmp411.c b/driver/temp_sensor/tmp411.c index 8a14440671..4f8a08a181 100644 --- a/driver/temp_sensor/tmp411.c +++ b/driver/temp_sensor/tmp411.c @@ -7,10 +7,10 @@ #include "common.h" #include "console.h" -#include "tmp411.h" #include "gpio.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" +#include "tmp411.h" #include "util.h" static int temp_val_local; diff --git a/driver/temp_sensor/tmp432.c b/driver/temp_sensor/tmp432.c index fde6536536..581e33b979 100644 --- a/driver/temp_sensor/tmp432.c +++ b/driver/temp_sensor/tmp432.c @@ -7,10 +7,10 @@ #include "common.h" #include "console.h" -#include "tmp432.h" #include "gpio.h" -#include "i2c.h" #include "hooks.h" +#include "i2c.h" +#include "tmp432.h" #include "util.h" static int temp_val_local; diff --git a/driver/temp_sensor/tmp468.c b/driver/temp_sensor/tmp468.c index 87eb040460..3bfaeeedbb 100644 --- a/driver/temp_sensor/tmp468.c +++ b/driver/temp_sensor/tmp468.c @@ -7,13 +7,12 @@ #include "common.h" #include "console.h" -#include "tmp432.h" #include "gpio.h" -#include "i2c.h" #include "hooks.h" -#include "util.h" - +#include "i2c.h" +#include "tmp432.h" #include "tmp468.h" +#include "util.h" static int fake_temp[TMP468_CHANNEL_COUNT] = { -1, -1, -1, -1, -1, -1, -1, -1, -1 }; diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c index 05c081a84a..7dacf9fdb1 100644 --- a/driver/touchpad_elan.c +++ b/driver/touchpad_elan.c @@ -7,20 +7,20 @@ #include "common.h" #include "console.h" #include "gpio.h" -#include "hwtimer.h" #include "hooks.h" +#include "hwtimer.h" #include "i2c.h" #include "math_util.h" #include "sha256.h" #include "shared_mem.h" -#include "task.h" #include "tablet_mode.h" +#include "task.h" #include "timer.h" #include "touchpad.h" #include "update_fw.h" -#include "util.h" #include "usb_api.h" #include "usb_hid_touchpad.h" +#include "util.h" #include "watchdog.h" /* Console output macros */ diff --git a/driver/touchpad_gt7288.c b/driver/touchpad_gt7288.c index 9d9b31a22b..f225c5b7eb 100644 --- a/driver/touchpad_gt7288.c +++ b/driver/touchpad_gt7288.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "console.h" #include "hooks.h" @@ -13,6 +11,8 @@ #include "touchpad_gt7288.h" #include "util.h" +#include + /* Define this to enable various warning messages during report parsing. */ #undef DEBUG_CHECKS diff --git a/driver/touchpad_st.c b/driver/touchpad_st.c index f66df6ab2a..f71b952f86 100644 --- a/driver/touchpad_st.c +++ b/driver/touchpad_st.c @@ -8,14 +8,14 @@ #include "common.h" #include "console.h" #include "gpio.h" -#include "hwtimer.h" #include "hooks.h" +#include "hwtimer.h" #include "i2c.h" #include "printf.h" #include "registers.h" #include "spi.h" -#include "task.h" #include "tablet_mode.h" +#include "task.h" #include "timer.h" #include "touchpad.h" #include "touchpad_st.h" diff --git a/driver/touchpad_st.h b/driver/touchpad_st.h index 6ea3f6aeb0..1dee7f0947 100644 --- a/driver/touchpad_st.h +++ b/driver/touchpad_st.h @@ -6,10 +6,10 @@ #ifndef __CROS_EC_TOUCHPAD_ST_H #define __CROS_EC_TOUCHPAD_ST_H -#include - #include "common.h" +#include + #define ST_VENDOR_ID 0x0483 #define ST_TP_EXTRA_BYTE 1 diff --git a/driver/usb_mux/pi3usb3x532.h b/driver/usb_mux/pi3usb3x532.h index 9214d349f0..d0a7abaa89 100644 --- a/driver/usb_mux/pi3usb3x532.h +++ b/driver/usb_mux/pi3usb3x532.h @@ -12,8 +12,8 @@ #ifndef __CROS_EC_PI3USB3X532_H #define __CROS_EC_PI3USB3X532_H -#include "usb_pd.h" #include "usb_mux.h" +#include "usb_pd.h" /* I2C Addresses */ #define PI3USB3X532_I2C_ADDR0 0x54 diff --git a/driver/usb_mux/tusb1064.h b/driver/usb_mux/tusb1064.h index 1a38290174..0e366f1bc9 100644 --- a/driver/usb_mux/tusb1064.h +++ b/driver/usb_mux/tusb1064.h @@ -6,9 +6,10 @@ #ifndef __CROS_EC_TUSB1064_H #define __CROS_EC_TUSB1064_H -#include #include "usb_mux.h" +#include + /* * TUSB1064 Has 16 possible device addresses which are selected by A1|A0 lines * using 4 level inputs. diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c index edc9da5778..73c8a165bf 100644 --- a/driver/usb_mux/usb_mux.c +++ b/driver/usb_mux/usb_mux.c @@ -7,9 +7,9 @@ #include "atomic.h" #include "builtin/assert.h" +#include "chipset.h" #include "common.h" #include "console.h" -#include "chipset.h" #include "ec_commands.h" #include "hooks.h" #include "host_command.h" diff --git a/driver/wpc/p9221.h b/driver/wpc/p9221.h index 53dcc57aa7..1360c54ee7 100644 --- a/driver/wpc/p9221.h +++ b/driver/wpc/p9221.h @@ -10,9 +10,9 @@ #ifndef __P9221_R7_H #define __P9221_R7_H +#include "charge_manager.h" #include "common.h" #include "gpio.h" -#include "charge_manager.h" #include "task.h" /* ========== Variant-specific configuration ============ */ diff --git a/include/driver/accel_lis2dw12_public.h b/include/driver/accel_lis2dw12_public.h index 5596e6ba6a..163bc8ae21 100644 --- a/include/driver/accel_lis2dw12_public.h +++ b/include/driver/accel_lis2dw12_public.h @@ -8,6 +8,7 @@ #ifndef __CROS_EC_DRIVER_ACCEL_LIS2DW12_PUBLIC_H #define __CROS_EC_DRIVER_ACCEL_LIS2DW12_PUBLIC_H +#include "config.h" #include "gpio_signal.h" extern const struct accelgyro_drv lis2dw12_drv; -- cgit v1.2.1 From 599c438e80c634a580c33bfb431472cf36c1cad5 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 22 Nov 2022 16:07:09 -0700 Subject: common: Sort header files Sort all includes in common with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis Change-Id: I70c2ed7bb2ce50c968f3e2dbdc274de3a455129a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4049889 Auto-Submit: Jeremy Bettis Tested-by: Jeremy Bettis Code-Coverage: Zoss Commit-Queue: Jeremy Bettis Reviewed-by: Tomasz Michalec Reviewed-by: Tom Hughes --- common/accel_cal.c | 2 +- common/acpi.c | 2 +- common/base32.c | 2 +- common/base_state.c | 2 +- common/bluetooth_le.c | 4 ++-- common/btle_hci_controller.c | 4 ++-- common/btle_ll.c | 4 ++-- common/button.c | 2 +- common/charge_state_v2.c | 2 +- common/chargen.c | 4 ++-- common/charger.c | 2 +- common/chargesplash.c | 6 +++--- common/dps.c | 12 ++++++------ common/ec_ec_comm_server.c | 4 ++-- common/espi.c | 2 +- common/fmap.c | 4 ++-- common/fpsensor/fpsensor_crypto.c | 6 +++--- common/gesture.c | 2 +- common/gyro_cal.c | 1 + common/i2c_controller.c | 9 +++++---- common/i2c_controller_cros_ec.c | 9 ++++----- common/i2c_hid_touchpad.c | 3 +-- common/i2c_trace.c | 2 +- common/init_rom.c | 2 +- common/kasa.c | 1 + common/keyboard_8042.c | 4 ++-- common/keyboard_8042_sharedlib.c | 4 ++-- common/keyboard_vivaldi.c | 7 ++++--- common/led_policy_std.c | 6 +++--- common/lightbar.c | 2 +- common/mag_cal.c | 1 - common/mkbp_event.c | 2 +- common/mock/charge_manager_mock.c | 4 ++-- common/mock/dp_alt_mode_mock.c | 2 +- common/mock/fp_sensor_mock.c | 4 ++-- common/mock/fpsensor_crypto_mock.c | 9 +++++---- common/mock/fpsensor_state_mock.c | 6 +++--- common/mock/mkbp_events_mock.c | 4 ++-- common/mock/rollback_latest_mock.c | 6 +++--- common/mock/rollback_mock.c | 8 ++++---- common/mock/usb_mux_mock.c | 4 ++-- common/mock/usb_pd_dpm_mock.c | 4 ++-- common/mock/usb_pe_sm_mock.c | 6 +++--- common/mock/usb_prl_mock.c | 9 +++++---- common/mock/usb_tc_sm_mock.c | 4 ++-- common/motion_lid.c | 4 ++-- common/motion_sense.c | 8 ++++---- common/motion_sense_fifo.c | 6 +++--- common/newton_fit.c | 3 ++- common/online_calibration.c | 14 +++++++------- common/rgb_keyboard.c | 4 ++-- common/shmalloc.c | 4 ++-- common/spi/flash_reg/src/spi_flash_reg_test.c | 4 ++-- common/spi_flash.c | 4 ++-- common/spi_nor.c | 8 ++++---- common/stillness_detector.c | 1 + common/system.c | 2 +- common/test_util.c | 3 ++- common/timer.c | 2 +- common/uart_buffering.c | 4 ++-- common/uart_hostcmd.c | 2 +- common/uart_printf.c | 4 ++-- common/uptime.c | 6 +++--- common/usb_common.c | 2 +- common/usb_host_command.c | 4 ++-- common/usb_i2c.c | 12 +++++------- common/usb_pd_alt_mode_dfp.c | 2 +- common/usb_pd_console_cmd.c | 2 +- common/usb_pd_host_cmd.c | 6 +++--- common/usb_pd_pdo.c | 2 +- common/usb_pd_policy.c | 2 +- common/usb_pd_protocol.c | 4 ++-- common/usb_pd_tcpc.c | 2 +- common/usb_update.c | 2 +- common/usbc/dp_alt_mode.c | 5 +++-- common/usbc/tbt_alt_mode.c | 5 +++-- common/usbc/usb_mode.c | 5 +++-- common/usbc/usb_pd_console.c | 2 +- common/usbc/usb_pd_dpm.c | 4 ++-- common/usbc/usb_pd_host.c | 4 ++-- common/usbc/usb_pe_ctvpd_sm.c | 7 +++---- common/usbc/usb_pe_drp_sm.c | 10 +++++----- common/usbc/usb_prl_sm.c | 6 +++--- common/usbc/usb_retimer_fw_update.c | 6 +++--- common/usbc/usb_tc_vpd_sm.c | 2 +- common/usbc/usbc_task.c | 7 +++---- common/usbc_intr_task.c | 4 ++-- common/vboot/efs2.c | 2 +- common/vboot/vboot.c | 4 ++-- common/vec3.c | 2 +- common/version.c | 3 ++- include/mock/usb_prl_mock.h | 2 ++ 92 files changed, 200 insertions(+), 192 deletions(-) diff --git a/common/accel_cal.c b/common/accel_cal.c index 0fe9fe7656..878f3b06fa 100644 --- a/common/accel_cal.c +++ b/common/accel_cal.c @@ -3,9 +3,9 @@ * found in the LICENSE file. */ +#include "accel_cal.h" #include "common.h" #include "console.h" -#include "accel_cal.h" #define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ##args) diff --git a/common/acpi.c b/common/acpi.c index 6145cbc96a..5dd71d244e 100644 --- a/common/acpi.c +++ b/common/acpi.c @@ -18,8 +18,8 @@ #include "lpc.h" #include "printf.h" #include "pwm.h" -#include "timer.h" #include "tablet_mode.h" +#include "timer.h" #include "usb_charge.h" #include "usb_common.h" #include "util.h" diff --git a/common/base32.c b/common/base32.c index fc3fe3c8ae..e5c30c4d6f 100644 --- a/common/base32.c +++ b/common/base32.c @@ -5,8 +5,8 @@ /* Base-32 encoding/decoding */ -#include "common.h" #include "base32.h" +#include "common.h" #include "util.h" static const unsigned char crc5_table1[] = { 0x00, 0x0E, 0x1C, 0x12, 0x11, 0x1F, diff --git a/common/base_state.c b/common/base_state.c index f90a5e7ce5..7bbd14eb00 100644 --- a/common/base_state.c +++ b/common/base_state.c @@ -5,8 +5,8 @@ #include "base_state.h" #include "console.h" -#include "host_command.h" #include "hooks.h" +#include "host_command.h" #define CPRINTS(format, args...) cprints(CC_MOTION_LID, format, ##args) diff --git a/common/bluetooth_le.c b/common/bluetooth_le.c index 3108553a8b..d102740293 100644 --- a/common/bluetooth_le.c +++ b/common/bluetooth_le.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include "builtin/assert.h" #include "bluetooth_le.h" -#include "util.h" +#include "builtin/assert.h" #include "console.h" +#include "util.h" #define CPRINTF(format, args...) cprintf(CC_BLUETOOTH_LE, format, ##args) diff --git a/common/btle_hci_controller.c b/common/btle_hci_controller.c index a4dcadaccf..605b67945b 100644 --- a/common/btle_hci_controller.c +++ b/common/btle_hci_controller.c @@ -3,9 +3,9 @@ * found in the LICENSE file. */ -#include "btle_hci_int.h" -#include "btle_hci2.h" #include "bluetooth_le_ll.h" +#include "btle_hci2.h" +#include "btle_hci_int.h" #include "console.h" #ifdef CONFIG_BLUETOOTH_HCI_DEBUG diff --git a/common/btle_ll.c b/common/btle_ll.c index 71ca108565..eea9534fe3 100644 --- a/common/btle_ll.c +++ b/common/btle_ll.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include "bluetooth_le_ll.h" #include "bluetooth_le.h" +#include "bluetooth_le_ll.h" #include "btle_hci_int.h" -#include "util.h" #include "console.h" #include "radio.h" #include "radio_test.h" #include "task.h" #include "timer.h" +#include "util.h" #ifdef CONFIG_BLUETOOTH_LL_DEBUG diff --git a/common/button.c b/common/button.c index aa7bcf6b4c..284d026285 100644 --- a/common/button.c +++ b/common/button.c @@ -12,8 +12,8 @@ #include "compile_time_macros.h" #include "console.h" #include "gpio.h" -#include "host_command.h" #include "hooks.h" +#include "host_command.h" #include "keyboard_protocol.h" #include "led_common.h" #include "mkbp_input_devices.h" diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 05c06cd77e..742c94bdb6 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -9,9 +9,9 @@ #include "battery_smart.h" #include "builtin/assert.h" #include "charge_manager.h" -#include "charger_profile_override.h" #include "charge_state.h" #include "charger.h" +#include "charger_profile_override.h" #include "chipset.h" #include "common.h" #include "console.h" diff --git a/common/chargen.c b/common/chargen.c index 9b2c23ed79..626e13e71f 100644 --- a/common/chargen.c +++ b/common/chargen.c @@ -6,13 +6,13 @@ #include "common.h" #include "config.h" #include "console.h" +#include "hooks.h" +#include "task.h" #include "timer.h" #include "uart.h" #include "usb_console.h" #include "util.h" #include "watchdog.h" -#include "hooks.h" -#include "task.h" #ifndef SECTION_IS_RO diff --git a/common/charger.c b/common/charger.c index caabd547c0..af9b246adb 100644 --- a/common/charger.c +++ b/common/charger.c @@ -12,10 +12,10 @@ #include "common.h" #include "console.h" #include "dptf.h" +#include "hooks.h" #include "host_command.h" #include "printf.h" #include "util.h" -#include "hooks.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_CHARGER, outstr) diff --git a/common/chargesplash.c b/common/chargesplash.c index 17da9a5c8c..c3d93cc47b 100644 --- a/common/chargesplash.c +++ b/common/chargesplash.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "chipset.h" #include "common.h" #include "console.h" @@ -18,6 +15,9 @@ #include "timer.h" #include "util.h" +#include +#include + #define CPRINTS(format, args...) \ cprints(CC_USBCHARGE, "chargesplash: " format, ##args) diff --git a/common/dps.c b/common/dps.c index 1950b5a9bd..b0751acc39 100644 --- a/common/dps.c +++ b/common/dps.c @@ -5,16 +5,14 @@ * Dynamic PDO Selection. */ -#include - -#include "dps.h" #include "atomic.h" #include "battery.h" -#include "common.h" -#include "console.h" -#include "charger.h" #include "charge_manager.h" #include "charge_state.h" +#include "charger.h" +#include "common.h" +#include "console.h" +#include "dps.h" #include "ec_commands.h" #include "hooks.h" #include "math_util.h" @@ -24,6 +22,8 @@ #include "usb_pd.h" #include "util.h" +#include + #define K_MORE_PWR 96 #define K_LESS_PWR 93 #define K_SAMPLE 1 diff --git a/common/ec_ec_comm_server.c b/common/ec_ec_comm_server.c index 976c3d6996..174ac54757 100644 --- a/common/ec_ec_comm_server.c +++ b/common/ec_ec_comm_server.c @@ -5,16 +5,16 @@ * EC-EC communication, task and functions for server. */ -#include "common.h" #include "battery.h" #include "charge_state_v2.h" +#include "common.h" #include "console.h" #include "crc8.h" #include "ec_commands.h" #include "ec_ec_comm_server.h" #include "extpower.h" -#include "hwtimer.h" #include "hooks.h" +#include "hwtimer.h" #include "queue.h" #include "queue_policies.h" #include "system.h" diff --git a/common/espi.c b/common/espi.c index dfb1f90749..f57e13cf76 100644 --- a/common/espi.c +++ b/common/espi.c @@ -6,9 +6,9 @@ /* eSPI common functionality for Chrome EC */ #include "common.h" +#include "espi.h" #include "gpio.h" #include "registers.h" -#include "espi.h" #include "timer.h" #include "util.h" diff --git a/common/fmap.c b/common/fmap.c index 469fac0ceb..0fa77c47cd 100644 --- a/common/fmap.c +++ b/common/fmap.c @@ -4,13 +4,13 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "cros_version.h" #include "rwsig.h" #include "util.h" +#include + /* * FMAP structs. * See diff --git a/common/fpsensor/fpsensor_crypto.c b/common/fpsensor/fpsensor_crypto.c index 257042197e..aac50bb297 100644 --- a/common/fpsensor/fpsensor_crypto.c +++ b/common/fpsensor/fpsensor_crypto.c @@ -2,16 +2,16 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - -#include "aes.h" #include "aes-gcm.h" +#include "aes.h" #include "cryptoc/util.h" #include "fpsensor_crypto.h" #include "fpsensor_private.h" #include "fpsensor_state.h" #include "rollback.h" +#include + #if !defined(CONFIG_AES) || !defined(CONFIG_AES_GCM) || \ !defined(CONFIG_ROLLBACK_SECRET_SIZE) #error "fpsensor requires AES, AES_GCM and ROLLBACK_SECRET_SIZE" diff --git a/common/gesture.c b/common/gesture.c index 99d054783d..48e6af3571 100644 --- a/common/gesture.c +++ b/common/gesture.c @@ -8,8 +8,8 @@ #include "accelgyro.h" #include "common.h" #include "console.h" -#include "hooks.h" #include "gesture.h" +#include "hooks.h" #include "lid_switch.h" #include "lightbar.h" #include "motion_sense.h" diff --git a/common/gyro_cal.c b/common/gyro_cal.c index 8996b85757..e2cb8d55db 100644 --- a/common/gyro_cal.c +++ b/common/gyro_cal.c @@ -5,6 +5,7 @@ #include "gyro_cal.h" #include "string.h" + #include /* diff --git a/common/i2c_controller.c b/common/i2c_controller.c index e938dc0f8f..96809ee84c 100644 --- a/common/i2c_controller.c +++ b/common/i2c_controller.c @@ -7,12 +7,12 @@ #include "battery.h" #include "builtin/assert.h" -#include "clock.h" #include "charge_state.h" +#include "clock.h" #include "console.h" #include "crc8.h" -#include "host_command.h" #include "gpio.h" +#include "host_command.h" #include "i2c.h" #include "i2c_bitbang.h" #include "i2c_private.h" @@ -22,12 +22,13 @@ #include "usb_pd.h" #include "usb_pd_tcpm.h" #include "util.h" -#include "watchdog.h" #include "virtual_battery.h" +#include "watchdog.h" #ifdef CONFIG_ZEPHYR -#include #include "i2c/i2c.h" + +#include #endif /* CONFIG_ZEPHYR */ #define CPUTS(outstr) cputs(CC_I2C, outstr) diff --git a/common/i2c_controller_cros_ec.c b/common/i2c_controller_cros_ec.c index aafeb504ce..d68f67c60e 100644 --- a/common/i2c_controller_cros_ec.c +++ b/common/i2c_controller_cros_ec.c @@ -4,16 +4,15 @@ */ #include "builtin/assert.h" -#include "system.h" +#include "console.h" #include "gpio.h" - +#include "i2c.h" #include "i2c_bitbang.h" #include "i2c_private.h" -#include "i2c.h" -#include "console.h" -#include "watchdog.h" #include "printf.h" +#include "system.h" #include "util.h" +#include "watchdog.h" /* This source file contains I2C controller code that is used only in legacy * (CrOS EC) builds. diff --git a/common/i2c_hid_touchpad.c b/common/i2c_hid_touchpad.c index 02261d8fa4..2664dabe3e 100644 --- a/common/i2c_hid_touchpad.c +++ b/common/i2c_hid_touchpad.c @@ -3,10 +3,9 @@ * found in the LICENSE file. */ -#include "i2c_hid_touchpad.h" - #include "console.h" #include "hwtimer.h" +#include "i2c_hid_touchpad.h" #include "util.h" /* 2 bytes for length + 1 byte for report ID */ diff --git a/common/i2c_trace.c b/common/i2c_trace.c index e7dde79bc4..8532766ea8 100644 --- a/common/i2c_trace.c +++ b/common/i2c_trace.c @@ -6,8 +6,8 @@ #include "common.h" #include "console.h" #include "i2c.h" -#include "stddef.h" #include "stdbool.h" +#include "stddef.h" #include "util.h" #define CPUTS(outstr) cputs(CC_I2C, outstr) diff --git a/common/init_rom.c b/common/init_rom.c index 102c3a00ae..ad9e80f423 100644 --- a/common/init_rom.c +++ b/common/init_rom.c @@ -7,8 +7,8 @@ #include "builtin/assert.h" #include "common.h" -#include "init_rom.h" #include "flash.h" +#include "init_rom.h" #include "stdbool.h" #include "stddef.h" diff --git a/common/kasa.c b/common/kasa.c index 6b974dc574..0ab716c729 100644 --- a/common/kasa.c +++ b/common/kasa.c @@ -6,6 +6,7 @@ #include "common.h" #include "kasa.h" #include "mat44.h" + #include void kasa_reset(struct kasa_fit *kasa) diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c index ce27828e1d..6e2b14719f 100644 --- a/common/keyboard_8042.c +++ b/common/keyboard_8042.c @@ -5,8 +5,9 @@ * 8042 keyboard protocol */ -#include "button.h" +#include "atkbd_protocol.h" #include "builtin/assert.h" +#include "button.h" #include "chipset.h" #include "common.h" #include "console.h" @@ -14,7 +15,6 @@ #include "hooks.h" #include "host_command.h" #include "i8042_protocol.h" -#include "atkbd_protocol.h" #include "keyboard_8042_sharedlib.h" #include "keyboard_config.h" #include "keyboard_protocol.h" diff --git a/common/keyboard_8042_sharedlib.c b/common/keyboard_8042_sharedlib.c index 3e98c977b7..810f9873b3 100644 --- a/common/keyboard_8042_sharedlib.c +++ b/common/keyboard_8042_sharedlib.c @@ -5,8 +5,6 @@ * Objects which can be shared between RO and RW for 8042 keyboard protocol. */ -#include - #include "builtin/assert.h" #include "button.h" #include "keyboard_8042_sharedlib.h" @@ -15,6 +13,8 @@ #include "libsharedobjs.h" #include "util.h" +#include + #ifndef CONFIG_KEYBOARD_CUSTOMIZATION /* The standard Chrome OS keyboard matrix table in scan code set 2. */ static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { diff --git a/common/keyboard_vivaldi.c b/common/keyboard_vivaldi.c index 11f5b708e6..44bbff2c11 100644 --- a/common/keyboard_vivaldi.c +++ b/common/keyboard_vivaldi.c @@ -6,13 +6,14 @@ /* Vivali Keyboard code for Chrome EC */ #include "builtin/assert.h" -#include "keyboard_8042_sharedlib.h" -#include "keyboard_scan.h" #include "ec_commands.h" #include "gpio.h" +#include "keyboard_8042_sharedlib.h" +#include "keyboard_scan.h" + +#include #include #include -#include /* Console output macros */ #define CPUTS(outstr) cputs(CC_KEYBOARD, outstr) diff --git a/common/led_policy_std.c b/common/led_policy_std.c index fe8570df87..b9d95af639 100644 --- a/common/led_policy_std.c +++ b/common/led_policy_std.c @@ -6,14 +6,14 @@ * This assumes a red/green battery led and a single power led. */ -#include "gpio.h" -#include "hooks.h" #include "battery.h" #include "charge_state.h" #include "chipset.h" +#include "gpio.h" +#include "hooks.h" #include "led_common.h" -#include "util.h" #include "lid_switch.h" +#include "util.h" #ifdef CONFIG_LED_BAT_ACTIVE_LOW #define BAT_LED_ON 0 diff --git a/common/lightbar.c b/common/lightbar.c index 8a6a874b34..a705a2cbed 100644 --- a/common/lightbar.c +++ b/common/lightbar.c @@ -17,8 +17,8 @@ #include "hooks.h" #include "host_command.h" #include "lb_common.h" -#include "lightbar.h" #include "lid_switch.h" +#include "lightbar.h" #include "motion_sense.h" #include "pwm.h" #include "system.h" diff --git a/common/mag_cal.c b/common/mag_cal.c index a9ce95798c..2ad89c48df 100644 --- a/common/mag_cal.c +++ b/common/mag_cal.c @@ -8,7 +8,6 @@ #include "mag_cal.h" #include "mat33.h" #include "mat44.h" - #include "math.h" #include "math_util.h" #include "util.h" diff --git a/common/mkbp_event.c b/common/mkbp_event.c index 4282da95b9..eb57a11656 100644 --- a/common/mkbp_event.c +++ b/common/mkbp_event.c @@ -11,10 +11,10 @@ #include "host_command.h" #include "host_command_heci.h" #include "hwtimer.h" -#include "timer.h" #include "link_defs.h" #include "mkbp_event.h" #include "power.h" +#include "timer.h" #include "util.h" #define CPUTS(outstr) cputs(CC_COMMAND, outstr) diff --git a/common/mock/charge_manager_mock.c b/common/mock/charge_manager_mock.c index c800b9b9b1..745b37efa7 100644 --- a/common/mock/charge_manager_mock.c +++ b/common/mock/charge_manager_mock.c @@ -8,12 +8,12 @@ * @brief Mock charge_manager */ -#include - #include "charge_manager.h" #include "common.h" #include "mock/charge_manager_mock.h" +#include + #ifndef TEST_BUILD #error "Mocks should only be in the test build." #endif diff --git a/common/mock/dp_alt_mode_mock.c b/common/mock/dp_alt_mode_mock.c index e261415aaa..ed769ed4b5 100644 --- a/common/mock/dp_alt_mode_mock.c +++ b/common/mock/dp_alt_mode_mock.c @@ -10,8 +10,8 @@ */ #include "console.h" -#include "usb_dp_alt_mode.h" #include "mock/dp_alt_mode_mock.h" +#include "usb_dp_alt_mode.h" #ifndef TEST_BUILD #error "Mocks should only be in the test build." diff --git a/common/mock/fp_sensor_mock.c b/common/mock/fp_sensor_mock.c index 4db25a821c..57a4f42ae9 100644 --- a/common/mock/fp_sensor_mock.c +++ b/common/mock/fp_sensor_mock.c @@ -8,12 +8,12 @@ * @brief Mock fpsensor private driver */ -#include - #include "common.h" #include "fpsensor.h" #include "mock/fp_sensor_mock.h" +#include + #ifndef TEST_BUILD #error "Mocks should only be in the test build." #endif diff --git a/common/mock/fpsensor_crypto_mock.c b/common/mock/fpsensor_crypto_mock.c index f2cc425c8f..334f98300a 100644 --- a/common/mock/fpsensor_crypto_mock.c +++ b/common/mock/fpsensor_crypto_mock.c @@ -7,16 +7,17 @@ * @file fpsensor_crypto_mock.c * @brief Mock fpsensor_crypto library */ -#include "sha256.h" -#include -#include -#include #include "assert.h" #include "compile_time_macros.h" #include "console.h" #include "ec_commands.h" #include "fpsensor_private.h" #include "mock/fpsensor_crypto_mock.h" +#include "sha256.h" + +#include +#include +#include #ifndef TEST_BUILD #error "Mocks should only be in the test build." diff --git a/common/mock/fpsensor_state_mock.c b/common/mock/fpsensor_state_mock.c index cbeb29ae3c..d71285c1de 100644 --- a/common/mock/fpsensor_state_mock.c +++ b/common/mock/fpsensor_state_mock.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - #include "common.h" #include "driver/fingerprint/fpsensor.h" #include "ec_commands.h" #include "test_util.h" +#include +#include + #ifndef TEST_BUILD #error "Mocks should only be in the test build." #endif diff --git a/common/mock/mkbp_events_mock.c b/common/mock/mkbp_events_mock.c index 3f4d76b659..559cb1494d 100644 --- a/common/mock/mkbp_events_mock.c +++ b/common/mock/mkbp_events_mock.c @@ -8,11 +8,11 @@ * @brief Mock event handling for MKBP keyboard protocol */ -#include - #include "common.h" #include "mock/mkbp_events_mock.h" +#include + #ifndef TEST_BUILD #error "Mocks should only be in the test build." #endif diff --git a/common/mock/rollback_latest_mock.c b/common/mock/rollback_latest_mock.c index ab62645a1c..b3433246d7 100644 --- a/common/mock/rollback_latest_mock.c +++ b/common/mock/rollback_latest_mock.c @@ -8,13 +8,13 @@ * @brief Mock rollback block library */ -#include - #include "common.h" #include "compile_time_macros.h" -#include "util.h" #include "mock/rollback_latest_mock.h" #include "rollback_private.h" +#include "util.h" + +#include #ifndef TEST_BUILD #error "Mocks should only be in the test build." diff --git a/common/mock/rollback_mock.c b/common/mock/rollback_mock.c index e68616df53..9395248a61 100644 --- a/common/mock/rollback_mock.c +++ b/common/mock/rollback_mock.c @@ -8,13 +8,13 @@ * @brief Mock rollback block library */ -#include -#include - #include "common.h" #include "compile_time_macros.h" -#include "util.h" #include "mock/rollback_mock.h" +#include "util.h" + +#include +#include #ifndef TEST_BUILD #error "Mocks should only be in the test build." diff --git a/common/mock/usb_mux_mock.c b/common/mock/usb_mux_mock.c index 815cdf777c..b612f47d4f 100644 --- a/common/mock/usb_mux_mock.c +++ b/common/mock/usb_mux_mock.c @@ -6,9 +6,9 @@ #include "common.h" #include "console.h" -#include "usb_mux.h" -#include "mock/usb_mux_mock.h" #include "memory.h" +#include "mock/usb_mux_mock.h" +#include "usb_mux.h" #ifndef CONFIG_COMMON_RUNTIME #define cprints(format, args...) diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c index 03c18f37a1..66b7ccfc2b 100644 --- a/common/mock/usb_pd_dpm_mock.c +++ b/common/mock/usb_pd_dpm_mock.c @@ -8,9 +8,9 @@ * Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3 */ -#include "usb_pd.h" -#include "mock/usb_pd_dpm_mock.h" #include "memory.h" +#include "mock/usb_pd_dpm_mock.h" +#include "usb_pd.h" #include "usb_pd_tcpm.h" #ifndef TEST_BUILD diff --git a/common/mock/usb_pe_sm_mock.c b/common/mock/usb_pe_sm_mock.c index 24861a73f9..38df938c46 100644 --- a/common/mock/usb_pe_sm_mock.c +++ b/common/mock/usb_pe_sm_mock.c @@ -7,11 +7,11 @@ #include "common.h" #include "console.h" -#include "usb_pd.h" -#include "usb_pe_sm.h" -#include "mock/usb_pe_sm_mock.h" #include "memory.h" +#include "mock/usb_pe_sm_mock.h" +#include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usb_pe_sm.h" #ifndef CONFIG_COMMON_RUNTIME #define cprints(format, args...) diff --git a/common/mock/usb_prl_mock.c b/common/mock/usb_prl_mock.c index df61cfaf95..769cd6073c 100644 --- a/common/mock/usb_prl_mock.c +++ b/common/mock/usb_prl_mock.c @@ -4,16 +4,17 @@ * * Mock Protocol Layer module. */ -#include #include "common.h" -#include "usb_emsg.h" -#include "usb_pe_sm.h" -#include "usb_prl_sm.h" #include "mock/usb_prl_mock.h" #include "task.h" #include "test_util.h" #include "timer.h" +#include "usb_emsg.h" #include "usb_pd_tcpm.h" +#include "usb_pe_sm.h" +#include "usb_prl_sm.h" + +#include #ifndef TEST_BUILD #error "Mocks should only be in the test build." diff --git a/common/mock/usb_tc_sm_mock.c b/common/mock/usb_tc_sm_mock.c index 5badc6eba6..6adf6b3246 100644 --- a/common/mock/usb_tc_sm_mock.c +++ b/common/mock/usb_tc_sm_mock.c @@ -8,9 +8,9 @@ #include "common.h" #include "console.h" #include "ec_commands.h" -#include "usb_tc_sm.h" -#include "mock/usb_tc_sm_mock.h" #include "memory.h" +#include "mock/usb_tc_sm_mock.h" +#include "usb_tc_sm.h" #ifndef CONFIG_COMMON_RUNTIME #define cprints(format, args...) diff --git a/common/motion_lid.c b/common/motion_lid.c index d8445bb3d4..878d471ed4 100644 --- a/common/motion_lid.c +++ b/common/motion_lid.c @@ -5,8 +5,8 @@ /* Motion sense module to read from various motion sensors. */ -#include "acpi.h" #include "accelgyro.h" +#include "acpi.h" #include "chipset.h" #include "common.h" #include "console.h" @@ -20,8 +20,8 @@ #include "motion_sense.h" #include "power.h" #include "tablet_mode.h" -#include "timer.h" #include "task.h" +#include "timer.h" #include "util.h" /* Console output macros */ diff --git a/common/motion_sense.c b/common/motion_sense.c index a309d29f8c..0b72a69780 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -20,17 +20,17 @@ #include "lightbar.h" #include "math_util.h" #include "mkbp_event.h" -#include "motion_sense.h" -#include "motion_sense_fifo.h" #include "motion_lid.h" #include "motion_orientation.h" +#include "motion_sense.h" +#include "motion_sense_fifo.h" #include "online_calibration.h" -#include "printf.h" #include "power.h" +#include "printf.h" #include "queue.h" #include "tablet_mode.h" -#include "timer.h" #include "task.h" +#include "timer.h" #include "util.h" /* Console output macros */ diff --git a/common/motion_sense_fifo.c b/common/motion_sense_fifo.c index d3887fa08f..fd1bfda88c 100644 --- a/common/motion_sense_fifo.c +++ b/common/motion_sense_fifo.c @@ -6,14 +6,14 @@ #include "accelgyro.h" #include "console.h" #include "hwtimer.h" +#include "math_util.h" #include "mkbp_event.h" #include "motion_sense_fifo.h" +#include "online_calibration.h" +#include "stdbool.h" #include "tablet_mode.h" #include "task.h" #include "util.h" -#include "math_util.h" -#include "online_calibration.h" -#include "stdbool.h" #define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ##args) diff --git a/common/newton_fit.c b/common/newton_fit.c index 5d217bc63d..3ba01dbd90 100644 --- a/common/newton_fit.c +++ b/common/newton_fit.c @@ -5,9 +5,10 @@ #include "common.h" #include "console.h" -#include "newton_fit.h" #include "math.h" #include "math_util.h" +#include "newton_fit.h" + #include #define CPRINTS(fmt, args...) cprints(CC_MOTION_SENSE, fmt, ##args) diff --git a/common/online_calibration.c b/common/online_calibration.c index 2d79c6ae1d..a56aa0dce7 100644 --- a/common/online_calibration.c +++ b/common/online_calibration.c @@ -3,19 +3,19 @@ * found in the LICENSE file. */ +#include "accel_cal.h" #include "accelgyro.h" #include "atomic.h" -#include "hwtimer.h" -#include "online_calibration.h" #include "common.h" +#include "ec_commands.h" +#include "gyro_cal.h" +#include "hwtimer.h" #include "mag_cal.h" +#include "mkbp_event.h" +#include "online_calibration.h" +#include "task.h" #include "util.h" #include "vec3.h" -#include "task.h" -#include "ec_commands.h" -#include "accel_cal.h" -#include "mkbp_event.h" -#include "gyro_cal.h" #define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ##args) diff --git a/common/rgb_keyboard.c b/common/rgb_keyboard.c index c0d4dd7f3c..0036cdcd16 100644 --- a/common/rgb_keyboard.c +++ b/common/rgb_keyboard.c @@ -2,8 +2,6 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "atomic.h" #include "common.h" #include "console.h" @@ -18,6 +16,8 @@ #include "timer.h" #include "util.h" +#include + /* Console output macros */ #define CPUTS(outstr) cputs(CC_RGBKBD, outstr) #define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "RGBKBD: " fmt, ##args) diff --git a/common/shmalloc.c b/common/shmalloc.c index 6cbf213227..37b7b2c736 100644 --- a/common/shmalloc.c +++ b/common/shmalloc.c @@ -5,8 +5,6 @@ */ /* Malloc/free memory module for Chrome EC */ -#include - #include "common.h" #include "hooks.h" #include "link_defs.h" @@ -15,6 +13,8 @@ #include "task.h" #include "util.h" +#include + static struct mutex shmem_lock; #ifndef TEST_SHMALLOC diff --git a/common/spi/flash_reg/src/spi_flash_reg_test.c b/common/spi/flash_reg/src/spi_flash_reg_test.c index 4a6a7a5edf..b9a45476b1 100644 --- a/common/spi/flash_reg/src/spi_flash_reg_test.c +++ b/common/spi/flash_reg/src/spi_flash_reg_test.c @@ -3,11 +3,11 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "spi_flash_reg.h" +#include + ZTEST_SUITE(flash_reg_to_protect, NULL, NULL, NULL, NULL, NULL); ZTEST(flash_reg_to_protect, test_invalid_args) diff --git a/common/spi_flash.c b/common/spi_flash.c index 8eaf3e8406..1540c7bb33 100644 --- a/common/spi_flash.c +++ b/common/spi_flash.c @@ -9,6 +9,8 @@ #include "builtin/assert.h" #include "common.h" #include "console.h" +#include "ec_commands.h" +#include "flash.h" #include "host_command.h" #include "shared_mem.h" #include "spi.h" @@ -17,8 +19,6 @@ #include "timer.h" #include "util.h" #include "watchdog.h" -#include "ec_commands.h" -#include "flash.h" /* * Time to sleep when chip is busy diff --git a/common/spi_nor.c b/common/spi_nor.c index 015cb7077c..1eca5d806f 100644 --- a/common/spi_nor.c +++ b/common/spi_nor.c @@ -7,13 +7,13 @@ #include "common.h" #include "console.h" -#include "spi_nor.h" +#include "sfdp.h" #include "shared_mem.h" -#include "util.h" -#include "task.h" #include "spi.h" -#include "sfdp.h" +#include "spi_nor.h" +#include "task.h" #include "timer.h" +#include "util.h" #include "watchdog.h" #ifdef CONFIG_SPI_NOR_DEBUG diff --git a/common/stillness_detector.c b/common/stillness_detector.c index c43e19873e..f81c51ef3a 100644 --- a/common/stillness_detector.c +++ b/common/stillness_detector.c @@ -6,6 +6,7 @@ #include "common.h" #include "stillness_detector.h" #include "timer.h" + #include static void still_det_reset(struct still_det *still_det) diff --git a/common/system.c b/common/system.c index af5d670216..e10712259c 100644 --- a/common/system.c +++ b/common/system.c @@ -27,6 +27,7 @@ #ifdef CONFIG_MPU #include "mpu.h" #endif +#include "cros_version.h" #include "panic.h" #include "sysjump.h" #include "system.h" @@ -36,7 +37,6 @@ #include "usb_pd.h" #include "usb_pd_tcpm.h" #include "util.h" -#include "cros_version.h" #include "watchdog.h" /* Console output macros */ diff --git a/common/test_util.c b/common/test_util.c index 659476fc17..fd8caba10a 100644 --- a/common/test_util.c +++ b/common/test_util.c @@ -11,7 +11,6 @@ #include #endif -#include #include "console.h" #include "hooks.h" #include "host_command.h" @@ -20,6 +19,8 @@ #include "test_util.h" #include "util.h" +#include + struct test_util_tag { uint8_t error_count; }; diff --git a/common/timer.c b/common/timer.c index d0fd1eca6e..bf2a731a1d 100644 --- a/common/timer.c +++ b/common/timer.c @@ -12,9 +12,9 @@ #include "hooks.h" #include "hwtimer.h" #include "system.h" -#include "util.h" #include "task.h" #include "timer.h" +#include "util.h" #include "watchdog.h" #ifdef CONFIG_ZEPHYR diff --git a/common/uart_buffering.c b/common/uart_buffering.c index 1aa6e9ef35..f3d150dfda 100644 --- a/common/uart_buffering.c +++ b/common/uart_buffering.c @@ -5,8 +5,6 @@ /* Common code to do UART buffering and printing */ -#include - #include "common.h" #include "console.h" #include "hooks.h" @@ -19,6 +17,8 @@ #include "uart.h" #include "util.h" +#include + /* Macros to advance in the circular buffers */ #define TX_BUF_NEXT(i) (((i) + 1) & (CONFIG_UART_TX_BUF_SIZE - 1)) #define RX_BUF_NEXT(i) (((i) + 1) & (CONFIG_UART_RX_BUF_SIZE - 1)) diff --git a/common/uart_hostcmd.c b/common/uart_hostcmd.c index 7b4ff5b461..506a49221d 100644 --- a/common/uart_hostcmd.c +++ b/common/uart_hostcmd.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "config.h" #include "common.h" +#include "config.h" #include "ec_commands.h" #include "host_command.h" #include "uart.h" diff --git a/common/uart_printf.c b/common/uart_printf.c index a4fecf5c73..55b8a40cde 100644 --- a/common/uart_printf.c +++ b/common/uart_printf.c @@ -3,12 +3,12 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "printf.h" #include "uart.h" +#include + static int __tx_char(void *context, int c) { /* diff --git a/common/uptime.c b/common/uptime.c index 3b2c68fd34..1ce7e2a329 100644 --- a/common/uptime.c +++ b/common/uptime.c @@ -2,13 +2,13 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include - #include "chipset.h" -#include "system.h" #include "host_command.h" +#include "system.h" #include "util.h" +#include + static enum ec_status host_command_get_uptime_info(struct host_cmd_handler_args *args) { diff --git a/common/usb_common.c b/common/usb_common.c index 9d7159f81d..a92b1e380f 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -17,9 +17,9 @@ #include "ec_commands.h" #include "gpio.h" #include "hooks.h" +#include "host_command.h" #include "mkbp_event.h" #include "stdbool.h" -#include "host_command.h" #include "system.h" #include "task.h" #include "typec_control.h" diff --git a/common/usb_host_command.c b/common/usb_host_command.c index 83a6e24a7d..0aeff40d39 100644 --- a/common/usb_host_command.c +++ b/common/usb_host_command.c @@ -7,13 +7,13 @@ #include "console.h" #include "consumer.h" #include "ec_commands.h" -#include "queue_policies.h" #include "host_command.h" #include "printf.h" +#include "queue_policies.h" #include "system.h" +#include "usb-stream.h" #include "usb_api.h" #include "usb_hw.h" -#include "usb-stream.h" #include "util.h" #define CPUTS(outstr) cputs(CC_USB, outstr) diff --git a/common/usb_i2c.c b/common/usb_i2c.c index 8482ec0967..b1cd45c76a 100644 --- a/common/usb_i2c.c +++ b/common/usb_i2c.c @@ -3,22 +3,20 @@ * found in the LICENSE file. */ -#include "common.h" -#include "link_defs.h" -#include "registers.h" -#include "i2c.h" -#include "usb_descriptor.h" -#include "util.h" - #include "common.h" #include "console.h" #include "consumer.h" +#include "i2c.h" +#include "link_defs.h" #include "producer.h" #include "queue.h" #include "queue_policies.h" +#include "registers.h" #include "task.h" #include "usb-stream.h" +#include "usb_descriptor.h" #include "usb_i2c.h" +#include "util.h" #define CPRINTS(format, args...) cprints(CC_I2C, format, ##args) diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c index dc8543c920..6df0215274 100644 --- a/common/usb_pd_alt_mode_dfp.c +++ b/common/usb_pd_alt_mode_dfp.c @@ -13,8 +13,8 @@ #include "task_id.h" #include "timer.h" #include "typec_control.h" -#include "usb_common.h" #include "usb_charge.h" +#include "usb_common.h" #include "usb_dp_alt_mode.h" #include "usb_mux.h" #include "usb_pd.h" diff --git a/common/usb_pd_console_cmd.c b/common/usb_pd_console_cmd.c index 23f2a27b1e..5a1afe88a5 100644 --- a/common/usb_pd_console_cmd.c +++ b/common/usb_pd_console_cmd.c @@ -7,8 +7,8 @@ #include "console.h" #include "usb_pd.h" -#include "util.h" #include "usb_pd_tcpm.h" +#include "util.h" #ifdef CONFIG_USB_PD_ALT_MODE_DFP #ifdef CONFIG_CMD_USB_PD_PE diff --git a/common/usb_pd_host_cmd.c b/common/usb_pd_host_cmd.c index e3008d26fb..ea05de3457 100644 --- a/common/usb_pd_host_cmd.c +++ b/common/usb_pd_host_cmd.c @@ -5,8 +5,6 @@ * Host commands for USB-PD module. */ -#include - #include "atomic.h" #include "battery.h" #include "charge_manager.h" @@ -17,8 +15,10 @@ #include "tcpm/tcpm.h" #include "usb_common.h" #include "usb_mux.h" -#include "usb_pd_tcpm.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" + +#include #ifdef CONFIG_COMMON_RUNTIME #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/common/usb_pd_pdo.c b/common/usb_pd_pdo.c index 3141af34a9..66f5f3feac 100644 --- a/common/usb_pd_pdo.c +++ b/common/usb_pd_pdo.c @@ -4,8 +4,8 @@ */ #include "usb_pd.h" -#include "util.h" #include "usb_pd_pdo.h" +#include "util.h" #ifndef CONFIG_USB_PD_CUSTOM_PDO diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index c63cde6301..036e253766 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -22,13 +22,13 @@ #include "task.h" #include "tcpm/tcpm.h" #include "timer.h" -#include "util.h" #include "usb_api.h" #include "usb_common.h" #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" #include "usbc_ppc.h" +#include "util.h" #ifdef CONFIG_COMMON_RUNTIME #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 6ad8f7a9f8..c946f417f8 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -26,16 +26,16 @@ #include "tcpm/tcpm.h" #include "timer.h" #include "typec_control.h" -#include "util.h" #include "usb_charge.h" #include "usb_common.h" #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_flags.h" -#include "usb_pd_tcpm.h" #include "usb_pd_tcpc.h" +#include "usb_pd_tcpm.h" #include "usbc_ocp.h" #include "usbc_ppc.h" +#include "util.h" #include "vboot.h" /* Flags to clear on a disconnect */ diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index c8010a5005..a9a4d1d5a5 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -18,10 +18,10 @@ #include "tcpm/tcpci.h" #include "tcpm/tcpm.h" #include "timer.h" -#include "util.h" #include "usb_pd.h" #include "usb_pd_config.h" #include "usb_pd_tcpm.h" +#include "util.h" #ifdef CONFIG_COMMON_RUNTIME #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) diff --git a/common/usb_update.c b/common/usb_update.c index 444a4d6949..2e9a681fed 100644 --- a/common/usb_update.c +++ b/common/usb_update.c @@ -9,8 +9,8 @@ #include "consumer.h" #include "curve25519.h" #include "flash.h" -#include "queue_policies.h" #include "host_command.h" +#include "queue_policies.h" #include "rollback.h" #include "rwsig.h" #include "sha256.h" diff --git a/common/usbc/dp_alt_mode.c b/common/usbc/dp_alt_mode.c index 1fb99fd797..22975aff5b 100644 --- a/common/usbc/dp_alt_mode.c +++ b/common/usbc/dp_alt_mode.c @@ -9,8 +9,6 @@ * section 5.2 */ -#include -#include #include "atomic.h" #include "builtin/assert.h" #include "console.h" @@ -19,6 +17,9 @@ #include "usb_pd.h" #include "usb_pd_tcpm.h" +#include +#include + #ifdef CONFIG_COMMON_RUNTIME #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c index c0e4e172cc..fec1ee9de3 100644 --- a/common/usbc/tbt_alt_mode.c +++ b/common/usbc/tbt_alt_mode.c @@ -9,8 +9,6 @@ */ #include "atomic.h" -#include -#include #include "compile_time_macros.h" #include "console.h" #include "tcpm/tcpm.h" @@ -23,6 +21,9 @@ #include "usb_pe_sm.h" #include "usb_tbt_alt_mode.h" +#include +#include + /* * Enter/Exit TBT mode with active cable * diff --git a/common/usbc/usb_mode.c b/common/usbc/usb_mode.c index f9b50c8fae..017f89fc74 100644 --- a/common/usbc/usb_mode.c +++ b/common/usbc/usb_mode.c @@ -9,8 +9,6 @@ * USB Power Delivery Specification Revision 3.0, Version 2.0 Section 6.4.8 */ -#include -#include #include "compile_time_macros.h" #include "console.h" #include "tcpm/tcpm.h" @@ -25,6 +23,9 @@ #include "usb_tbt_alt_mode.h" #include "usbc_ppc.h" +#include +#include + #ifdef CONFIG_COMMON_RUNTIME #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/common/usbc/usb_pd_console.c b/common/usbc/usb_pd_console.c index 50f8fa8eb9..ed3d687ef4 100644 --- a/common/usbc/usb_pd_console.c +++ b/common/usbc/usb_pd_console.c @@ -6,12 +6,12 @@ #include "common.h" #include "console.h" #include "usb_common.h" +#include "usb_pd.h" #include "usb_pd_dpm_sm.h" #include "usb_pd_timer.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" #include "usb_tc_sm.h" -#include "usb_pd.h" #include "util.h" #ifndef TEST_USB_PD_CONSOLE diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index 9455610ea0..775ea0da46 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -25,13 +25,13 @@ #include "usb_mode.h" #include "usb_mux.h" #include "usb_pd.h" +#include "usb_pd_dpm_sm.h" #include "usb_pd_pdo.h" #include "usb_pd_tcpm.h" #include "usb_pd_timer.h" #include "usb_pe_sm.h" -#include "usb_pd_dpm_sm.h" -#include "usb_tc_sm.h" #include "usb_tbt_alt_mode.h" +#include "usb_tc_sm.h" #ifdef CONFIG_ZEPHYR #include "temp_sensor/temp_sensor.h" diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c index 93a8e573a0..0b3958cd47 100644 --- a/common/usbc/usb_pd_host.c +++ b/common/usbc/usb_pd_host.c @@ -5,8 +5,6 @@ * Host commands for TCPMv2 USB PD module */ -#include - #include "console.h" #include "ec_commands.h" #include "host_command.h" @@ -16,6 +14,8 @@ #include "usb_pd_tcpm.h" #include "util.h" +#include + #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/common/usbc/usb_pe_ctvpd_sm.c b/common/usbc/usb_pe_ctvpd_sm.c index dbd32a6b7d..223c40c71d 100644 --- a/common/usbc/usb_pe_ctvpd_sm.c +++ b/common/usbc/usb_pe_ctvpd_sm.c @@ -6,15 +6,14 @@ #include "common.h" #include "console.h" #include "task.h" -#include "util.h" +#include "usb_emsg.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" -#include "usb_pd_tcpm.h" -#include "usb_tc_sm.h" -#include "usb_emsg.h" #include "usb_sm.h" +#include "usb_tc_sm.h" +#include "util.h" /* USB Policy Engine Charge-Through VCONN Powered Device module */ diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 5219b9b418..0de098788a 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -21,25 +21,25 @@ #include "system.h" #include "task.h" #include "tcpm/tcpm.h" -#include "util.h" #include "usb_charge.h" #include "usb_common.h" #include "usb_dp_alt_mode.h" +#include "usb_emsg.h" #include "usb_mode.h" #include "usb_mux.h" +#include "usb_pd.h" #include "usb_pd_dpm_sm.h" #include "usb_pd_policy.h" -#include "usb_pd.h" #include "usb_pd_tcpm.h" #include "usb_pd_timer.h" #include "usb_pe_private.h" #include "usb_pe_sm.h" -#include "usb_tbt_alt_mode.h" #include "usb_prl_sm.h" -#include "usb_tc_sm.h" -#include "usb_emsg.h" #include "usb_sm.h" +#include "usb_tbt_alt_mode.h" +#include "usb_tc_sm.h" #include "usbc_ppc.h" +#include "util.h" /* * USB Policy Engine Sink / Source module diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index db9f460e61..5c17459834 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -20,16 +20,16 @@ #include "system.h" #include "task.h" #include "tcpm/tcpm.h" -#include "util.h" #include "usb_charge.h" +#include "usb_emsg.h" #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_timer.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" -#include "usb_tc_sm.h" -#include "usb_emsg.h" #include "usb_sm.h" +#include "usb_tc_sm.h" +#include "util.h" #include "vpd_api.h" #ifdef CONFIG_COMMON_RUNTIME diff --git a/common/usbc/usb_retimer_fw_update.c b/common/usbc/usb_retimer_fw_update.c index 9b581ea872..a8cabf00a2 100644 --- a/common/usbc/usb_retimer_fw_update.c +++ b/common/usbc/usb_retimer_fw_update.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "builtin/assert.h" #include "compile_time_macros.h" #include "console.h" @@ -15,6 +12,9 @@ #include "usb_mux.h" #include "usb_tc_sm.h" +#include +#include + #ifdef CONFIG_COMMON_RUNTIME #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) diff --git a/common/usbc/usb_tc_vpd_sm.c b/common/usbc/usb_tc_vpd_sm.c index 40b855db9b..1a820c4003 100644 --- a/common/usbc/usb_tc_vpd_sm.c +++ b/common/usbc/usb_tc_vpd_sm.c @@ -11,8 +11,8 @@ #include "tcpm/tcpm.h" #include "typec_control.h" #include "usb_pd.h" -#include "usb_tc_sm.h" #include "usb_sm.h" +#include "usb_tc_sm.h" #include "vpd_api.h" /* USB Type-C VCONN Powered Device module */ diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c index ae5b401283..5d68221b3e 100644 --- a/common/usbc/usbc_task.c +++ b/common/usbc/usbc_task.c @@ -19,20 +19,19 @@ #include "registers.h" #include "system.h" #include "task.h" +#include "tcpm/tcpm.h" #include "timer.h" -#include "util.h" #include "usb_charge.h" #include "usb_mux.h" #include "usb_pd.h" -#include "usb_pd_timer.h" -#include "usb_prl_sm.h" -#include "tcpm/tcpm.h" #include "usb_pd_dpm_sm.h" +#include "usb_pd_timer.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" #include "usb_sm.h" #include "usb_tc_sm.h" #include "usbc_ppc.h" +#include "util.h" #define USBC_EVENT_TIMEOUT (5 * MSEC) #define USBC_MIN_EVENT_TIMEOUT (1 * MSEC) diff --git a/common/usbc_intr_task.c b/common/usbc_intr_task.c index 6c724c1279..d1d25c6b68 100644 --- a/common/usbc_intr_task.c +++ b/common/usbc_intr_task.c @@ -5,8 +5,6 @@ /* High-priority interrupt tasks implementations */ -#include - #include "builtin/assert.h" #include "common.h" #include "compile_time_macros.h" @@ -18,6 +16,8 @@ #include "usb_pd.h" #include "usb_pd_tcpm.h" +#include + #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) diff --git a/common/vboot/efs2.c b/common/vboot/efs2.c index b45109029d..3346a2c76b 100644 --- a/common/vboot/efs2.c +++ b/common/vboot/efs2.c @@ -21,8 +21,8 @@ #include "sha256.h" #include "system.h" #include "task.h" -#include "usb_pd.h" #include "uart.h" +#include "usb_pd.h" #include "vboot.h" #include "vboot_hash.h" diff --git a/common/vboot/vboot.c b/common/vboot/vboot.c index cf449da1b8..162b396ba5 100644 --- a/common/vboot/vboot.c +++ b/common/vboot/vboot.c @@ -17,13 +17,13 @@ #include "host_command.h" #include "rsa.h" #include "rwsig.h" -#include "stdbool.h" #include "sha256.h" #include "shared_mem.h" +#include "stdbool.h" #include "system.h" #include "usb_pd.h" -#include "vboot.h" #include "vb21_struct.h" +#include "vboot.h" #define CPRINTS(format, args...) cprints(CC_VBOOT, "VB " format, ##args) #define CPRINTF(format, args...) cprintf(CC_VBOOT, "VB " format, ##args) diff --git a/common/vec3.c b/common/vec3.c index 67a6049dea..4cf26ebf4c 100644 --- a/common/vec3.c +++ b/common/vec3.c @@ -6,8 +6,8 @@ #include "common.h" #include "math.h" #include "math_util.h" -#include "vec3.h" #include "util.h" +#include "vec3.h" static fpv3_t zero_initialized_vector = { FLOAT_TO_FP(0.0f), FLOAT_TO_FP(0.0f), FLOAT_TO_FP(0.0f) }; diff --git a/common/version.c b/common/version.c index 8b1ac5e53d..fe082abbe0 100644 --- a/common/version.c +++ b/common/version.c @@ -5,7 +5,6 @@ /* Embed firmware version number in the binary */ -#include #include "common.h" #include "compile_time_macros.h" #include "cros_version.h" @@ -14,6 +13,8 @@ #include "stddef.h" #include "system.h" +#include + BUILD_ASSERT(CONFIG_ROLLBACK_VERSION >= 0); BUILD_ASSERT(CONFIG_ROLLBACK_VERSION <= INT32_MAX); diff --git a/include/mock/usb_prl_mock.h b/include/mock/usb_prl_mock.h index eef1d8de63..7758700d3a 100644 --- a/include/mock/usb_prl_mock.h +++ b/include/mock/usb_prl_mock.h @@ -9,7 +9,9 @@ #include "common.h" #include "usb_emsg.h" +#include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usb_pe_sm.h" void mock_prl_reset(void); -- cgit v1.2.1 From 88684b2a25d0349bcd57cdba2a5aadb60d7bef07 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Wed, 23 Nov 2022 15:28:01 -0700 Subject: chip: Sort header files Sort all includes in chip with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis Change-Id: I13454e38fa3766aa0ba26a058075f51965b8462e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4053346 Code-Coverage: Zoss Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis Reviewed-by: Simon Glass --- chip/host/flash.c | 4 ++-- chip/host/gpio.c | 2 -- chip/host/persistence.c | 9 +++++---- chip/host/reboot.c | 7 ++++--- chip/host/spi_controller.c | 5 ++--- chip/host/trng.c | 4 ++-- chip/host/uart.c | 13 +++++++------ chip/ish/aontaskfw/ish_aontask.c | 2 +- chip/ish/clock.c | 2 +- chip/ish/dma.c | 2 +- chip/ish/hbm.h | 6 +++--- chip/ish/heci_client.h | 6 +++--- chip/ish/hid_device.h | 6 +++--- chip/ish/hwtimer.c | 2 +- chip/ish/i2c.c | 6 +++--- chip/ish/ipc_heci.c | 10 +++++----- chip/ish/ish_i2c.h | 3 ++- chip/ish/ish_persistent_data.c | 4 ++-- chip/ish/power_mgt.c | 4 ++-- chip/ish/power_mgt.h | 4 ++-- chip/ish/system_state_subsys.c | 2 +- chip/ish/uart.c | 11 +++++------ chip/ish/uart_defs.h | 5 +++-- chip/ish/watchdog.c | 2 +- chip/it83xx/adc.c | 2 +- chip/it83xx/adc_chip.h | 4 ++-- chip/it83xx/flash.c | 8 ++++---- chip/it83xx/hwtimer.c | 2 +- chip/it83xx/i2c_peripheral.c | 3 ++- chip/it83xx/keyboard_raw.c | 2 +- chip/it83xx/peci.c | 4 ++-- chip/it83xx/pwm.c | 2 +- chip/max32660/clock_chip.c | 6 +++--- chip/max32660/flash_chip.c | 8 ++++---- chip/max32660/gpio_chip.c | 6 +++--- chip/max32660/hwtimer_chip.c | 6 +++--- chip/max32660/i2c_chip.c | 9 +++++---- chip/max32660/system_chip.c | 4 ++-- chip/max32660/uart_chip.c | 15 ++++++++------- chip/max32660/wdt_chip.c | 4 ++-- chip/mchp/adc.c | 2 +- chip/mchp/clock.c | 2 +- chip/mchp/dma.c | 2 +- chip/mchp/dma_chip.h | 2 +- chip/mchp/espi.c | 19 ++++++++----------- chip/mchp/fan.c | 2 +- chip/mchp/flash.c | 4 ++-- chip/mchp/gpio.c | 4 ++-- chip/mchp/gpio_chip.h | 6 +++--- chip/mchp/gpio_cmds.c | 4 ++-- chip/mchp/gpspi.c | 10 +++++----- chip/mchp/gpspi_chip.h | 2 +- chip/mchp/hwtimer.c | 2 +- chip/mchp/keyboard_raw.c | 2 +- chip/mchp/lfw/ec_lfw.c | 20 ++++++++++---------- chip/mchp/lfw/ec_lfw.h | 1 + chip/mchp/lpc.c | 8 ++++---- chip/mchp/pwm.c | 2 +- chip/mchp/qmspi.c | 12 ++++++------ chip/mchp/qmspi_chip.h | 2 +- chip/mchp/spi.c | 8 ++++---- chip/mchp/spi_chip.h | 2 +- chip/mchp/system.c | 6 +++--- chip/mchp/uart.c | 2 +- chip/mchp/watchdog.c | 2 +- chip/mt_scp/mt818x/ipi.c | 2 +- chip/mt_scp/mt818x/memmap.c | 2 +- chip/mt_scp/mt8192/clock.c | 6 +++--- chip/mt_scp/mt8195/clock.c | 6 +++--- chip/npcx/adc.c | 2 +- chip/npcx/espi.c | 14 +++++++------- chip/npcx/fan.c | 13 ++++++------- chip/npcx/flash.c | 6 +++--- chip/npcx/gpio.c | 12 ++++++------ chip/npcx/header.c | 4 ++-- chip/npcx/hwtimer.c | 2 +- chip/npcx/keyboard_raw.c | 4 ++-- chip/npcx/lct.c | 2 +- chip/npcx/lpc.c | 4 ++-- chip/npcx/peci.c | 2 +- chip/npcx/ps2.c | 4 ++-- chip/npcx/registers.h | 2 +- chip/npcx/shi.c | 2 +- chip/npcx/spi.c | 4 ++-- chip/npcx/spiflashfw/npcx_monitor.c | 3 ++- chip/npcx/system-npcx7.c | 8 ++++---- chip/npcx/system-npcx9.c | 8 ++++---- chip/npcx/uart.c | 2 +- chip/npcx/uartn.c | 7 ++++--- chip/npcx/watchdog.c | 8 ++++---- chip/stm32/adc-stm32l.c | 2 +- chip/stm32/bkpdata.c | 4 ++-- chip/stm32/clock-f.c | 2 +- chip/stm32/clock-stm32f0.c | 2 +- chip/stm32/clock-stm32f3.c | 2 +- chip/stm32/clock-stm32f4.c | 2 +- chip/stm32/clock-stm32g4.c | 2 +- chip/stm32/clock-stm32h7.c | 4 ++-- chip/stm32/clock-stm32l4.c | 2 +- chip/stm32/flash-f.c | 9 +++++---- chip/stm32/flash-stm32f3.c | 7 ++++--- chip/stm32/flash-stm32f4.c | 7 ++++--- chip/stm32/flash-stm32g4-l4.c | 4 ++-- chip/stm32/flash-stm32h7.c | 6 +++--- chip/stm32/hwtimer32.c | 2 +- chip/stm32/i2c-stm32l4.c | 3 +-- chip/stm32/i2c_ite_flash_support.c | 2 +- chip/stm32/pwm.c | 2 +- chip/stm32/uart.c | 4 ++-- chip/stm32/ucpd-stm32gx.c | 2 +- chip/stm32/usart-stm32f0.c | 3 +-- chip/stm32/usart-stm32f3.c | 3 +-- chip/stm32/usart-stm32f4.c | 3 +-- chip/stm32/usart-stm32l.c | 3 +-- chip/stm32/usart-stm32l5.c | 3 +-- chip/stm32/usart_host_command.c | 6 +++--- chip/stm32/usart_host_command.h | 3 ++- chip/stm32/usart_rx_dma.c | 3 +-- chip/stm32/usart_rx_dma.h | 2 +- chip/stm32/usart_rx_interrupt-stm32f0.c | 3 +-- chip/stm32/usart_rx_interrupt-stm32f3.c | 3 +-- chip/stm32/usart_rx_interrupt-stm32f4.c | 3 +-- chip/stm32/usart_rx_interrupt-stm32l.c | 3 +-- chip/stm32/usart_rx_interrupt.c | 3 +-- chip/stm32/usart_tx_dma.c | 5 ++--- chip/stm32/usart_tx_interrupt.c | 3 +-- chip/stm32/usb-stm32f3.c | 3 +-- chip/stm32/usb-stream.c | 4 ++-- chip/stm32/usb.c | 2 +- chip/stm32/usb_console.c | 2 +- chip/stm32/usb_dwc.c | 4 ++-- chip/stm32/usb_dwc_console.c | 2 +- chip/stm32/usb_dwc_stream.c | 3 +-- chip/stm32/usb_dwc_stream.h | 2 +- chip/stm32/usb_endpoints.c | 7 ++++--- chip/stm32/usb_hid.c | 4 ++-- chip/stm32/usb_hid_keyboard.c | 4 ++-- chip/stm32/usb_hid_touchpad.c | 4 ++-- chip/stm32/usb_isochronous.c | 4 ++-- chip/stm32/usb_pd_phy.c | 4 ++-- 140 files changed, 313 insertions(+), 321 deletions(-) diff --git a/chip/host/flash.c b/chip/host/flash.c index 209489162c..03a5fc777b 100644 --- a/chip/host/flash.c +++ b/chip/host/flash.c @@ -5,8 +5,6 @@ /* Flash module for emulator */ -#include - #include "builtin/assert.h" #include "common.h" #include "config_chip.h" @@ -14,6 +12,8 @@ #include "persistence.h" #include "util.h" +#include + /* This needs to be aligned to the erase bank size for NVCTR. */ __aligned(CONFIG_FLASH_ERASE_SIZE) char __host_flash[CONFIG_FLASH_SIZE_BYTES]; uint8_t __host_flash_protect[PHYSICAL_BANKS]; diff --git a/chip/host/gpio.c b/chip/host/gpio.c index b74bec52a1..d80d93dcf7 100644 --- a/chip/host/gpio.c +++ b/chip/host/gpio.c @@ -5,8 +5,6 @@ /* GPIO module for emulator */ -#include "console.h" - #include "common.h" #include "console.h" #include "gpio.h" diff --git a/chip/host/persistence.c b/chip/host/persistence.c index 4d8ef09df1..369f58034b 100644 --- a/chip/host/persistence.c +++ b/chip/host/persistence.c @@ -18,13 +18,14 @@ * this homegrown implementation of something similar-yet-different. */ -#include -#include +#include "builtin/assert.h" +#include "util.h" + #include #include -#include "builtin/assert.h" -#include "util.h" +#include +#include /* The longest path in a chroot seems to be about 280 characters (as of * April 2021) so define a cut-off instead of just hoping for the best: diff --git a/chip/host/reboot.c b/chip/host/reboot.c index 24d90d943d..59e15ee81d 100644 --- a/chip/host/reboot.c +++ b/chip/host/reboot.c @@ -5,14 +5,15 @@ /* Emulator self-reboot procedure */ -#include -#include - #include "console.h" #include "host_test.h" #include "reboot.h" #include "test_util.h" +#include + +#include + #ifdef TEST_FUZZ /* reboot breaks fuzzing, let's just not do it. */ void emulator_reboot(void) diff --git a/chip/host/spi_controller.c b/chip/host/spi_controller.c index a1df53d935..ae6e2c9346 100644 --- a/chip/host/spi_controller.c +++ b/chip/host/spi_controller.c @@ -5,13 +5,12 @@ * Mock SPI Controller driver for unit test. */ -#include - #include "common.h" #include "gpio.h" - #include "spi.h" +#include + test_mockable int spi_enable(const struct spi_device_t *spi_device, int enable) { return EC_SUCCESS; diff --git a/chip/host/trng.c b/chip/host/trng.c index ef3df1ad5f..d0def66277 100644 --- a/chip/host/trng.c +++ b/chip/host/trng.c @@ -14,11 +14,11 @@ #error "This fake trng driver must not be used in non-test builds." #endif +#include "common.h" + #include #include /* Only valid for host */ -#include "common.h" - static unsigned int seed; test_mockable void trng_init(void) diff --git a/chip/host/uart.c b/chip/host/uart.c index 9e70a6005c..71e8345196 100644 --- a/chip/host/uart.c +++ b/chip/host/uart.c @@ -5,12 +5,6 @@ /* UART driver for emulator */ -#include -#include -#include -#include -#include - #include "builtin/assert.h" #include "common.h" #include "queue.h" @@ -19,6 +13,13 @@ #include "uart.h" #include "util.h" +#include +#include + +#include +#include +#include + static int stopped = 1; static int init_done; diff --git a/chip/ish/aontaskfw/ish_aontask.c b/chip/ish/aontaskfw/ish_aontask.c index 58d62d1891..6f2d9c9f2d 100644 --- a/chip/ish/aontaskfw/ish_aontask.c +++ b/chip/ish/aontaskfw/ish_aontask.c @@ -45,8 +45,8 @@ #include "common.h" #include "ia_structs.h" -#include "ish_aon_share.h" #include "ish_aon_defs.h" +#include "ish_aon_share.h" #include "ish_dma.h" #include "power_mgt.h" diff --git a/chip/ish/clock.c b/chip/ish/clock.c index e46c4278b7..f9fec0b7d2 100644 --- a/chip/ish/clock.c +++ b/chip/ish/clock.c @@ -7,8 +7,8 @@ #include "clock.h" #include "common.h" -#include "util.h" #include "power_mgt.h" +#include "util.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_CLOCK, outstr) diff --git a/chip/ish/dma.c b/chip/ish/dma.c index e2f1aba8ed..eae6a850f1 100644 --- a/chip/ish/dma.c +++ b/chip/ish/dma.c @@ -7,8 +7,8 @@ #include "common.h" #include "console.h" -#include "registers.h" #include "ish_dma.h" +#include "registers.h" #include "util.h" static int dma_init_called; /* If ish_dma_init is called */ diff --git a/chip/ish/hbm.h b/chip/ish/hbm.h index d666f748c8..17c7853b1d 100644 --- a/chip/ish/hbm.h +++ b/chip/ish/hbm.h @@ -6,11 +6,11 @@ #ifndef __HBM_H #define __HBM_H -#include -#include - #include "heci_client.h" +#include +#include + #define HBM_MAJOR_VERSION 1 #ifdef HECI_ENABLE_DMA #define HBM_MINOR_VERSION 2 diff --git a/chip/ish/heci_client.h b/chip/ish/heci_client.h index 951b82c6d9..2ba9ea01db 100644 --- a/chip/ish/heci_client.h +++ b/chip/ish/heci_client.h @@ -6,11 +6,11 @@ #ifndef __HECI_CLIENT_H #define __HECI_CLIENT_H -#include -#include - #include "hooks.h" +#include +#include + #define HECI_MAX_NUM_OF_CLIENTS 2 #define HECI_MAX_MSG_SIZE 4960 diff --git a/chip/ish/hid_device.h b/chip/ish/hid_device.h index ba7722f5bb..07d8a77673 100644 --- a/chip/ish/hid_device.h +++ b/chip/ish/hid_device.h @@ -6,11 +6,11 @@ #ifndef __HID_DEVICE_H #define __HID_DEVICE_H -#include -#include - #include "hooks.h" +#include +#include + #define HID_SUBSYS_MAX_PAYLOAD_SIZE 4954 enum HID_SUBSYS_ERR { diff --git a/chip/ish/hwtimer.c b/chip/ish/hwtimer.c index 57049a63b3..40c3de67a8 100644 --- a/chip/ish/hwtimer.c +++ b/chip/ish/hwtimer.c @@ -8,9 +8,9 @@ #include "console.h" #include "hpet.h" #include "hwtimer.h" -#include "timer.h" #include "registers.h" #include "task.h" +#include "timer.h" #include "util.h" #define CPUTS(outstr) cputs(CC_CLOCK, outstr) diff --git a/chip/ish/i2c.c b/chip/ish/i2c.c index e26bcd70e5..230f073369 100644 --- a/chip/ish/i2c.c +++ b/chip/ish/i2c.c @@ -6,16 +6,16 @@ /* I2C port module for ISH */ #include "common.h" -#include "console.h" #include "config_chip.h" +#include "console.h" #include "gpio.h" #include "hooks.h" +#include "hwtimer.h" #include "i2c.h" -#include "registers.h" #include "ish_i2c.h" +#include "registers.h" #include "task.h" #include "timer.h" -#include "hwtimer.h" #include "util.h" #define CPUTS(outstr) cputs(CC_I2C, outstr) diff --git a/chip/ish/ipc_heci.c b/chip/ish/ipc_heci.c index 1fd81e3d3f..8ce0a258e1 100644 --- a/chip/ish/ipc_heci.c +++ b/chip/ish/ipc_heci.c @@ -24,15 +24,15 @@ */ #include "builtin/assert.h" -#include "registers.h" #include "console.h" -#include "task.h" -#include "util.h" +#include "hooks.h" +#include "hwtimer.h" #include "ipc_heci.h" #include "ish_fwst.h" #include "queue.h" -#include "hooks.h" -#include "hwtimer.h" +#include "registers.h" +#include "task.h" +#include "util.h" #define CPUTS(outstr) cputs(CC_LPC, outstr) #define CPRINTS(format, args...) cprints(CC_LPC, format, ##args) diff --git a/chip/ish/ish_i2c.h b/chip/ish/ish_i2c.h index c24f4e0cdc..7aa2977178 100644 --- a/chip/ish/ish_i2c.h +++ b/chip/ish/ish_i2c.h @@ -6,9 +6,10 @@ #ifndef __CROS_EC_ISH_I2C_H #define __CROS_EC_ISH_I2C_H -#include #include "task.h" +#include + #define I2C_TSC_TIMEOUT 2000000 #define I2C_CALIB_ADDRESS 0x3 #define I2C_INTERRUPT_TIMEOUT (TICKFREQ / 20) diff --git a/chip/ish/ish_persistent_data.c b/chip/ish/ish_persistent_data.c index 149acaeade..ed909d6f7b 100644 --- a/chip/ish/ish_persistent_data.c +++ b/chip/ish/ish_persistent_data.c @@ -4,11 +4,11 @@ */ #include "common.h" -#include "ec_commands.h" #include "config.h" +#include "ec_commands.h" #include "hooks.h" -#include "system.h" #include "ish_persistent_data.h" +#include "system.h" #define PERSISTENT_DATA_MAGIC 0x49534864 /* "ISHd" */ diff --git a/chip/ish/power_mgt.c b/chip/ish/power_mgt.c index b3e2a407ad..de9022b55a 100644 --- a/chip/ish/power_mgt.c +++ b/chip/ish/power_mgt.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "aontaskfw/ish_aon_share.h" #include "console.h" #include "hwtimer.h" @@ -17,6 +15,8 @@ #include "util.h" #include "watchdog.h" +#include + #define CPUTS(outstr) cputs(CC_SYSTEM, outstr) #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) diff --git a/chip/ish/power_mgt.h b/chip/ish/power_mgt.h index 851529ffb1..a7a702018f 100644 --- a/chip/ish/power_mgt.h +++ b/chip/ish/power_mgt.h @@ -6,11 +6,11 @@ #ifndef __CROS_EC_POWER_MGT_H #define __CROS_EC_POWER_MGT_H -#include - #include "common.h" #include "registers.h" +#include + extern void uart_port_restore(void); extern void uart_to_idle(void); extern void clear_fabric_error(void); diff --git a/chip/ish/system_state_subsys.c b/chip/ish/system_state_subsys.c index bfc120ff9b..76053dcded 100644 --- a/chip/ish/system_state_subsys.c +++ b/chip/ish/system_state_subsys.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ +#include "console.h" #include "heci_client.h" #include "registers.h" #include "system_state.h" -#include "console.h" #ifdef SS_SUBSYSTEM_DEBUG #define CPUTS(outstr) cputs(CC_LPC, outstr) diff --git a/chip/ish/uart.c b/chip/ish/uart.c index b1c9493869..0ff03da89a 100644 --- a/chip/ish/uart.c +++ b/chip/ish/uart.c @@ -4,17 +4,16 @@ */ /* UART module for ISH */ +#include "atomic.h" #include "common.h" -#include "math_util.h" #include "console.h" -#include "uart_defs.h" -#include "atomic.h" -#include "task.h" +#include "interrupts.h" +#include "math_util.h" #include "registers.h" +#include "system.h" +#include "task.h" #include "uart.h" #include "uart_defs.h" -#include "interrupts.h" -#include "system.h" #define CPUTS(outstr) cputs(CC_LPC, outstr) #define CPRINTS(format, args...) cprints(CC_LPC, format, ##args) diff --git a/chip/ish/uart_defs.h b/chip/ish/uart_defs.h index 1fc36b7adc..581a702d31 100644 --- a/chip/ish/uart_defs.h +++ b/chip/ish/uart_defs.h @@ -8,10 +8,11 @@ #ifndef __CROS_EC_UART_DEFS_H_ #define __CROS_EC_UART_DEFS_H_ -#include -#include #include "atomic.h" +#include +#include + #define UART_ERROR -1 #define UART_BUSY -2 #ifdef CHIP_VARIANT_ISH5P4 diff --git a/chip/ish/watchdog.c b/chip/ish/watchdog.c index 7b32133619..8f0ea5ddf1 100644 --- a/chip/ish/watchdog.c +++ b/chip/ish/watchdog.c @@ -23,9 +23,9 @@ #include "ec_commands.h" #include "hooks.h" #include "ish_persistent_data.h" -#include "task.h" #include "registers.h" #include "system.h" +#include "task.h" #include "watchdog.h" /* Units are hundreds of milliseconds */ diff --git a/chip/it83xx/adc.c b/chip/it83xx/adc.c index 9f9fa27f41..c666fc4e88 100644 --- a/chip/it83xx/adc.c +++ b/chip/it83xx/adc.c @@ -7,8 +7,8 @@ #include "adc.h" #include "clock.h" -#include "console.h" #include "common.h" +#include "console.h" #include "gpio.h" #include "hooks.h" #include "registers.h" diff --git a/chip/it83xx/adc_chip.h b/chip/it83xx/adc_chip.h index 99e84624e0..3804a684e5 100644 --- a/chip/it83xx/adc_chip.h +++ b/chip/it83xx/adc_chip.h @@ -8,10 +8,10 @@ #ifndef __CROS_EC_ADC_CHIP_H #define __CROS_EC_ADC_CHIP_H -#include - #include "common.h" +#include + /* * Maximum time we allow for an ADC conversion. * NOTE: diff --git a/chip/it83xx/flash.c b/chip/it83xx/flash.c index 25aefa2f66..fa8ab65292 100644 --- a/chip/it83xx/flash.c +++ b/chip/it83xx/flash.c @@ -9,13 +9,13 @@ #include "flash_chip.h" #include "host_command.h" #include "intc.h" -#include "system.h" -#include "util.h" -#include "watchdog.h" #include "registers.h" -#include "task.h" #include "shared_mem.h" +#include "system.h" +#include "task.h" #include "uart.h" +#include "util.h" +#include "watchdog.h" #define FLASH_DMA_START ((uint32_t)&__flash_dma_start) #define FLASH_DMA_CODE __attribute__((section(".flash_direct_map"))) diff --git a/chip/it83xx/hwtimer.c b/chip/it83xx/hwtimer.c index b9add82b5a..7a46f52773 100644 --- a/chip/it83xx/hwtimer.c +++ b/chip/it83xx/hwtimer.c @@ -5,8 +5,8 @@ /* Hardware timers driver */ -#include "cpu.h" #include "common.h" +#include "cpu.h" #include "hooks.h" #include "hwtimer.h" #include "hwtimer_chip.h" diff --git a/chip/it83xx/i2c_peripheral.c b/chip/it83xx/i2c_peripheral.c index 80fea907fd..dfb139514f 100644 --- a/chip/it83xx/i2c_peripheral.c +++ b/chip/it83xx/i2c_peripheral.c @@ -12,9 +12,10 @@ #include "i2c_peripheral.h" #include "printf.h" #include "registers.h" +#include "task.h" + #include #include -#include "task.h" /* Console output macros */ #define CPRINTS(format, args...) cprints(CC_I2C, format, ##args) diff --git a/chip/it83xx/keyboard_raw.c b/chip/it83xx/keyboard_raw.c index 0d2f048deb..9123a6e5e8 100644 --- a/chip/it83xx/keyboard_raw.c +++ b/chip/it83xx/keyboard_raw.c @@ -4,11 +4,11 @@ */ #include "common.h" +#include "irq_chip.h" #include "keyboard_raw.h" #include "keyboard_scan.h" #include "registers.h" #include "task.h" -#include "irq_chip.h" #define KSOH_PIN_MASK (((1 << (KEYBOARD_COLS_MAX - 8)) - 1) & 0xff) diff --git a/chip/it83xx/peci.c b/chip/it83xx/peci.c index e5f172ce80..ee94f2baac 100644 --- a/chip/it83xx/peci.c +++ b/chip/it83xx/peci.c @@ -10,9 +10,9 @@ #include "hooks.h" #include "peci.h" #include "registers.h" -#include "util.h" -#include "timer.h" #include "task.h" +#include "timer.h" +#include "util.h" enum peci_status { PECI_STATUS_NO_ERR = 0x00, diff --git a/chip/it83xx/pwm.c b/chip/it83xx/pwm.c index 07165dea77..3d0d4eaeb6 100644 --- a/chip/it83xx/pwm.c +++ b/chip/it83xx/pwm.c @@ -8,11 +8,11 @@ #include "clock.h" #include "gpio.h" #include "hooks.h" +#include "math_util.h" #include "pwm.h" #include "pwm_chip.h" #include "registers.h" #include "util.h" -#include "math_util.h" #define PWM_CTRX_MIN 100 #define PWM_EC_FREQ 8000000 diff --git a/chip/max32660/clock_chip.c b/chip/max32660/clock_chip.c index 93a5f862d8..26225401ba 100644 --- a/chip/max32660/clock_chip.c +++ b/chip/max32660/clock_chip.c @@ -9,16 +9,16 @@ #include "common.h" #include "console.h" #include "cpu.h" +#include "gcr_regs.h" #include "hooks.h" #include "hwtimer.h" +#include "pwrseq_regs.h" #include "registers.h" #include "system.h" #include "timer.h" +#include "tmr_regs.h" #include "util.h" #include "watchdog.h" -#include "tmr_regs.h" -#include "gcr_regs.h" -#include "pwrseq_regs.h" #define MAX32660_SYSTEMCLOCK SYS_CLOCK_HIRC diff --git a/chip/max32660/flash_chip.c b/chip/max32660/flash_chip.c index eb702799b0..01a26f94b5 100644 --- a/chip/max32660/flash_chip.c +++ b/chip/max32660/flash_chip.c @@ -5,16 +5,16 @@ /* MAX32660 Flash Memory Module for Chrome EC */ +#include "common.h" #include "flash.h" +#include "flc_regs.h" +#include "icc_regs.h" +#include "registers.h" #include "switch.h" #include "system.h" #include "timer.h" #include "util.h" #include "watchdog.h" -#include "registers.h" -#include "common.h" -#include "icc_regs.h" -#include "flc_regs.h" #define CPUTS(outstr) cputs(CC_SYSTEM, outstr) #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) diff --git a/chip/max32660/gpio_chip.c b/chip/max32660/gpio_chip.c index cc54f9055f..b6deaa9111 100644 --- a/chip/max32660/gpio_chip.c +++ b/chip/max32660/gpio_chip.c @@ -6,16 +6,16 @@ /* MAX32660 GPIO module for Chrome EC */ #include "clock.h" -#include "console.h" #include "common.h" +#include "console.h" #include "gpio.h" +#include "gpio_regs.h" #include "hooks.h" +#include "registers.h" #include "switch.h" #include "task.h" #include "timer.h" #include "util.h" -#include "registers.h" -#include "gpio_regs.h" #define CPRINTF(format, args...) cprintf(CC_GPIO, format, ##args) #define CPRINTS(format, args...) cprints(CC_GPIO, format, ##args) diff --git a/chip/max32660/hwtimer_chip.c b/chip/max32660/hwtimer_chip.c index a6469ae795..b6c39f4036 100644 --- a/chip/max32660/hwtimer_chip.c +++ b/chip/max32660/hwtimer_chip.c @@ -6,15 +6,15 @@ /* MAX32660 HW Timer module for Chrome EC */ #include "clock.h" -#include "console.h" #include "common.h" +#include "console.h" +#include "gcr_regs.h" #include "hooks.h" #include "hwtimer.h" +#include "registers.h" #include "task.h" #include "timer.h" -#include "registers.h" #include "tmr_regs.h" -#include "gcr_regs.h" /* Define the rollover timer */ #define TMR_ROLLOVER MXC_TMR0 diff --git a/chip/max32660/i2c_chip.c b/chip/max32660/i2c_chip.c index bb116f4d8a..a4fab91199 100644 --- a/chip/max32660/i2c_chip.c +++ b/chip/max32660/i2c_chip.c @@ -5,18 +5,19 @@ /* MAX32660 I2C port module for Chrome EC. */ -#include -#include #include "common.h" #include "config_chip.h" #include "gpio.h" #include "hooks.h" #include "i2c.h" +#include "i2c_regs.h" +#include "registers.h" #include "stdbool.h" #include "system.h" #include "task.h" -#include "registers.h" -#include "i2c_regs.h" + +#include +#include /** * Byte to use if the EC HOST requested more data diff --git a/chip/max32660/system_chip.c b/chip/max32660/system_chip.c index 8679881102..f63e22dc26 100644 --- a/chip/max32660/system_chip.c +++ b/chip/max32660/system_chip.c @@ -9,14 +9,14 @@ #include "common.h" #include "console.h" #include "cpu.h" +#include "gcr_regs.h" #include "host_command.h" #include "panic.h" +#include "registers.h" #include "system.h" #include "task.h" #include "timer.h" #include "util.h" -#include "registers.h" -#include "gcr_regs.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_SYSTEM, outstr) diff --git a/chip/max32660/uart_chip.c b/chip/max32660/uart_chip.c index 87ba59e629..ec25d9e476 100644 --- a/chip/max32660/uart_chip.c +++ b/chip/max32660/uart_chip.c @@ -5,18 +5,19 @@ /* MAX32660 Console UART Module for Chrome EC */ -#include +#include "common.h" +#include "gcr_regs.h" +#include "gpio.h" +#include "gpio_regs.h" +#include "registers.h" #include "system.h" #include "task.h" -#include "uart.h" -#include "registers.h" #include "tmr_regs.h" -#include "gpio.h" -#include "gpio_regs.h" -#include "common.h" -#include "gcr_regs.h" +#include "uart.h" #include "uart_regs.h" +#include + static int done_uart_init_yet; #ifndef UARTN diff --git a/chip/max32660/wdt_chip.c b/chip/max32660/wdt_chip.c index af9a5d2ef4..4890c34536 100644 --- a/chip/max32660/wdt_chip.c +++ b/chip/max32660/wdt_chip.c @@ -8,13 +8,13 @@ #include "clock.h" #include "common.h" #include "config.h" +#include "console.h" #include "gpio.h" #include "hooks.h" +#include "registers.h" #include "task.h" #include "util.h" #include "watchdog.h" -#include "console.h" -#include "registers.h" #include "wdt_regs.h" #define CPUTS(outstr) cputs(CC_COMMAND, outstr) diff --git a/chip/mchp/adc.c b/chip/mchp/adc.c index 621fe1f3be..f09c04d26b 100644 --- a/chip/mchp/adc.c +++ b/chip/mchp/adc.c @@ -10,9 +10,9 @@ #include "hooks.h" #include "registers.h" #include "task.h" +#include "tfdp_chip.h" #include "timer.h" #include "util.h" -#include "tfdp_chip.h" /* * Conversion on a single channel takes less than 12 ms. Set timeout to diff --git a/chip/mchp/clock.c b/chip/mchp/clock.c index 4701d43b1f..0323d16f8f 100644 --- a/chip/mchp/clock.c +++ b/chip/mchp/clock.c @@ -17,10 +17,10 @@ #include "shared_mem.h" #include "system.h" #include "task.h" +#include "tfdp_chip.h" #include "timer.h" #include "uart.h" #include "util.h" -#include "tfdp_chip.h" #include "vboot_hash.h" /* Console output macros */ diff --git a/chip/mchp/dma.c b/chip/mchp/dma.c index 8a091286a7..c921527d7f 100644 --- a/chip/mchp/dma.c +++ b/chip/mchp/dma.c @@ -9,9 +9,9 @@ #include "hooks.h" #include "registers.h" #include "task.h" +#include "tfdp_chip.h" #include "timer.h" #include "util.h" -#include "tfdp_chip.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_DMA, outstr) diff --git a/chip/mchp/dma_chip.h b/chip/mchp/dma_chip.h index 6f569a1dc7..bfdb8ab9be 100644 --- a/chip/mchp/dma_chip.h +++ b/chip/mchp/dma_chip.h @@ -13,8 +13,8 @@ #ifndef _DMA_CHIP_H #define _DMA_CHIP_H -#include #include +#include #ifdef __cplusplus extern "C" { diff --git a/chip/mchp/espi.c b/chip/mchp/espi.c index 371cf09c5e..53d17e90b2 100644 --- a/chip/mchp/espi.c +++ b/chip/mchp/espi.c @@ -5,29 +5,26 @@ /* ESPI module for Chrome EC */ -#include "common.h" #include "acpi.h" +#include "chipset.h" +#include "common.h" #include "console.h" +#include "espi.h" #include "gpio.h" #include "hooks.h" #include "host_command.h" #include "keyboard_protocol.h" -#include "port80.h" -#include "util.h" -#include "chipset.h" - -#include "registers.h" -#include "espi.h" #include "lpc.h" #include "lpc_chip.h" +#include "port80.h" +#include "power.h" +#include "registers.h" #include "system.h" #include "task.h" -#include "console.h" +#include "tfdp_chip.h" +#include "timer.h" #include "uart.h" #include "util.h" -#include "power.h" -#include "timer.h" -#include "tfdp_chip.h" /* Console output macros */ #ifdef CONFIG_MCHP_ESPI_DEBUG diff --git a/chip/mchp/fan.c b/chip/mchp/fan.c index 3f61cb4d2f..c68d71bcc8 100644 --- a/chip/mchp/fan.c +++ b/chip/mchp/fan.c @@ -9,8 +9,8 @@ #include "fan.h" #include "registers.h" -#include "util.h" #include "tfdp_chip.h" +#include "util.h" /* Maximum fan driver setting value */ #define MAX_FAN_DRIVER_SETTING 0x3ff diff --git a/chip/mchp/flash.c b/chip/mchp/flash.c index 4b0e407fb2..f0f3a5575e 100644 --- a/chip/mchp/flash.c +++ b/chip/mchp/flash.c @@ -6,14 +6,14 @@ #include "common.h" #include "console.h" #include "flash.h" +#include "hooks.h" #include "host_command.h" #include "shared_mem.h" #include "spi.h" #include "spi_flash.h" #include "system.h" -#include "util.h" -#include "hooks.h" #include "tfdp_chip.h" +#include "util.h" #define PAGE_SIZE 256 diff --git a/chip/mchp/gpio.c b/chip/mchp/gpio.c index a3cab86fcc..3ad9d7b6e4 100644 --- a/chip/mchp/gpio.c +++ b/chip/mchp/gpio.c @@ -8,13 +8,13 @@ #include "common.h" #include "gpio.h" #include "hooks.h" +#include "lpc_chip.h" #include "registers.h" #include "system.h" #include "task.h" +#include "tfdp_chip.h" #include "timer.h" #include "util.h" -#include "lpc_chip.h" -#include "tfdp_chip.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_LPC, outstr) diff --git a/chip/mchp/gpio_chip.h b/chip/mchp/gpio_chip.h index e092669b60..ec0f3d2278 100644 --- a/chip/mchp/gpio_chip.h +++ b/chip/mchp/gpio_chip.h @@ -13,11 +13,11 @@ #ifndef _GPIO_CHIP_H #define _GPIO_CHIP_H -#include -#include - #include "gpio.h" +#include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/chip/mchp/gpio_cmds.c b/chip/mchp/gpio_cmds.c index 927d6d0326..a53f8cca2a 100644 --- a/chip/mchp/gpio_cmds.c +++ b/chip/mchp/gpio_cmds.c @@ -8,12 +8,12 @@ #include "common.h" #include "console.h" #include "gpio.h" +#include "gpio_chip.h" #include "hooks.h" #include "registers.h" #include "system.h" -#include "util.h" -#include "gpio_chip.h" #include "tfdp_chip.h" +#include "util.h" /* Console output macros */ #define CPUTS(outstr) cputs(CC_LPC, outstr) diff --git a/chip/mchp/gpspi.c b/chip/mchp/gpspi.c index 0142fe0e3c..a7f7b388c4 100644 --- a/chip/mchp/gpspi.c +++ b/chip/mchp/gpspi.c @@ -9,15 +9,15 @@ #include "console.h" #include "dma.h" #include "gpio.h" +#include "gpspi_chip.h" +#include "hooks.h" #include "registers.h" #include "spi.h" -#include "timer.h" -#include "util.h" -#include "hooks.h" -#include "task.h" #include "spi_chip.h" -#include "gpspi_chip.h" +#include "task.h" #include "tfdp_chip.h" +#include "timer.h" +#include "util.h" #define CPUTS(outstr) cputs(CC_SPI, outstr) #define CPRINTS(format, args...) cprints(CC_SPI, format, ##args) diff --git a/chip/mchp/gpspi_chip.h b/chip/mchp/gpspi_chip.h index 7c1285b6cf..16c3208410 100644 --- a/chip/mchp/gpspi_chip.h +++ b/chip/mchp/gpspi_chip.h @@ -13,8 +13,8 @@ #ifndef _GPSPI_CHIP_H #define _GPSPI_CHIP_H -#include #include +#include /* struct spi_device_t */ #include "spi.h" diff --git a/chip/mchp/hwtimer.c b/chip/mchp/hwtimer.c index 2e9ff780fb..c72140b18f 100644 --- a/chip/mchp/hwtimer.c +++ b/chip/mchp/hwtimer.c @@ -11,8 +11,8 @@ #include "hwtimer.h" #include "registers.h" #include "task.h" -#include "timer.h" #include "tfdp_chip.h" +#include "timer.h" void __hw_clock_event_set(uint32_t deadline) { diff --git a/chip/mchp/keyboard_raw.c b/chip/mchp/keyboard_raw.c index daa0c8e64f..30181776fa 100644 --- a/chip/mchp/keyboard_raw.c +++ b/chip/mchp/keyboard_raw.c @@ -11,8 +11,8 @@ #include "keyboard_scan.h" #include "registers.h" #include "task.h" -#include "util.h" #include "tfdp_chip.h" +#include "util.h" /* * Using direct mode interrupt, do not enable diff --git a/chip/mchp/lfw/ec_lfw.c b/chip/mchp/lfw/ec_lfw.c index 3a9d7160dc..eb8b3370cb 100644 --- a/chip/mchp/lfw/ec_lfw.c +++ b/chip/mchp/lfw/ec_lfw.c @@ -6,23 +6,23 @@ * */ -#include - +#include "clock.h" #include "config.h" +#include "cpu.h" #include "cros_version.h" +#include "dma.h" #include "gpio.h" +#include "gpio_list.h" +#include "hwtimer.h" +#include "registers.h" #include "spi.h" #include "spi_flash.h" -#include "util.h" -#include "timer.h" -#include "dma.h" -#include "registers.h" -#include "cpu.h" -#include "clock.h" #include "system.h" -#include "hwtimer.h" -#include "gpio_list.h" #include "tfdp_chip.h" +#include "timer.h" +#include "util.h" + +#include #ifdef CONFIG_MCHP_LFW_DEBUG #include "dma_chip.h" diff --git a/chip/mchp/lfw/ec_lfw.h b/chip/mchp/lfw/ec_lfw.h index 2589638954..0c677e5d0b 100644 --- a/chip/mchp/lfw/ec_lfw.h +++ b/chip/mchp/lfw/ec_lfw.h @@ -7,6 +7,7 @@ */ #include + #include /* Why naked? This is dangerous except for diff --git a/chip/mchp/lpc.c b/chip/mchp/lpc.c index da9b045b22..e41e4b0c78 100644 --- a/chip/mchp/lpc.c +++ b/chip/mchp/lpc.c @@ -5,24 +5,24 @@ /* LPC module for MCHP MEC family */ -#include "common.h" #include "acpi.h" +#include "chipset.h" +#include "common.h" #include "console.h" +#include "espi.h" #include "gpio.h" #include "hooks.h" #include "host_command.h" #include "keyboard_protocol.h" #include "lpc.h" #include "lpc_chip.h" -#include "espi.h" #include "port80.h" #include "registers.h" #include "system.h" #include "task.h" +#include "tfdp_chip.h" #include "timer.h" #include "util.h" -#include "chipset.h" -#include "tfdp_chip.h" /* Console output macros */ #ifdef CONFIG_MCHP_DEBUG_LPC diff --git a/chip/mchp/pwm.c b/chip/mchp/pwm.c index d0e88b5175..706228fa53 100644 --- a/chip/mchp/pwm.c +++ b/chip/mchp/pwm.c @@ -12,8 +12,8 @@ #include "pwm.h" #include "pwm_chip.h" #include "registers.h" -#include "util.h" #include "tfdp_chip.h" +#include "util.h" #define CPUTS(outstr) cputs(CC_PWM, outstr) #define CPRINTS(format, args...) cprints(CC_PWM, format, ##args) diff --git a/chip/mchp/qmspi.c b/chip/mchp/qmspi.c index 6979bdae6a..a0d31b72e3 100644 --- a/chip/mchp/qmspi.c +++ b/chip/mchp/qmspi.c @@ -8,17 +8,17 @@ #include "common.h" #include "console.h" #include "dma.h" +#include "dma_chip.h" #include "gpio.h" +#include "hooks.h" +#include "qmspi_chip.h" #include "registers.h" #include "spi.h" -#include "timer.h" -#include "util.h" -#include "hooks.h" -#include "task.h" -#include "dma_chip.h" #include "spi_chip.h" -#include "qmspi_chip.h" +#include "task.h" #include "tfdp_chip.h" +#include "timer.h" +#include "util.h" #define CPUTS(outstr) cputs(CC_SPI, outstr) #define CPRINTS(format, args...) cprints(CC_SPI, format, ##args) diff --git a/chip/mchp/qmspi_chip.h b/chip/mchp/qmspi_chip.h index 5a66c34e62..899f59516f 100644 --- a/chip/mchp/qmspi_chip.h +++ b/chip/mchp/qmspi_chip.h @@ -13,8 +13,8 @@ #ifndef _QMSPI_CHIP_H #define _QMSPI_CHIP_H -#include #include +#include /* struct spi_device_t */ #include "spi.h" diff --git a/chip/mchp/spi.c b/chip/mchp/spi.c index 195c10d8a6..4445666790 100644 --- a/chip/mchp/spi.c +++ b/chip/mchp/spi.c @@ -9,14 +9,14 @@ #include "console.h" #include "dma.h" #include "gpio.h" +#include "hooks.h" +#include "qmspi_chip.h" #include "registers.h" #include "spi.h" +#include "spi_chip.h" +#include "task.h" #include "timer.h" #include "util.h" -#include "hooks.h" -#include "task.h" -#include "spi_chip.h" -#include "qmspi_chip.h" #if defined(CONFIG_MCHP_GPSPI) && !defined(LFW) #include "gpspi_chip.h" #endif diff --git a/chip/mchp/spi_chip.h b/chip/mchp/spi_chip.h index f8c4c1169c..e651901ea4 100644 --- a/chip/mchp/spi_chip.h +++ b/chip/mchp/spi_chip.h @@ -13,8 +13,8 @@ #ifndef _SPI_CHIP_H #define _SPI_CHIP_H -#include #include +#include /* struct spi_device_t */ #include "spi.h" diff --git a/chip/mchp/system.c b/chip/mchp/system.c index bb5224c455..65470c43b9 100644 --- a/chip/mchp/system.c +++ b/chip/mchp/system.c @@ -5,11 +5,9 @@ /* System module for Chrome EC : MCHP hardware specific implementation */ -#include - -#include "common.h" /* includes config.h and board.h */ #include "clock.h" #include "clock_chip.h" +#include "common.h" /* includes config.h and board.h */ #include "console.h" #include "cpu.h" #include "gpio.h" @@ -25,6 +23,8 @@ #include "timer.h" #include "util.h" +#include + #define CPUTS(outstr) cputs(CC_LPC, outstr) #define CPRINTS(format, args...) cprints(CC_LPC, format, ##args) diff --git a/chip/mchp/uart.c b/chip/mchp/uart.c index 00bfc77e14..59ea3e1c35 100644 --- a/chip/mchp/uart.c +++ b/chip/mchp/uart.c @@ -13,9 +13,9 @@ #include "registers.h" #include "system.h" #include "task.h" +#include "tfdp_chip.h" #include "uart.h" #include "util.h" -#include "tfdp_chip.h" #define TX_FIFO_SIZE 16 diff --git a/chip/mchp/watchdog.c b/chip/mchp/watchdog.c index 0de4398fdb..50edda70e0 100644 --- a/chip/mchp/watchdog.c +++ b/chip/mchp/watchdog.c @@ -8,8 +8,8 @@ #include "hooks.h" #include "registers.h" #include "task.h" -#include "watchdog.h" #include "tfdp_chip.h" +#include "watchdog.h" void watchdog_reload(void) { diff --git a/chip/mt_scp/mt818x/ipi.c b/chip/mt_scp/mt818x/ipi.c index 723137d9c9..d0d9292fd1 100644 --- a/chip/mt_scp/mt818x/ipi.c +++ b/chip/mt_scp/mt818x/ipi.c @@ -24,13 +24,13 @@ #include "console.h" #include "hooks.h" #include "host_command.h" +#include "hwtimer.h" #include "ipi_chip.h" #include "mkbp_event.h" #include "power.h" #include "system.h" #include "task.h" #include "util.h" -#include "hwtimer.h" #include "video.h" #define CPRINTF(format, args...) cprintf(CC_IPI, format, ##args) diff --git a/chip/mt_scp/mt818x/memmap.c b/chip/mt_scp/mt818x/memmap.c index 0ecb370cf3..24c0fd8f7a 100644 --- a/chip/mt_scp/mt818x/memmap.c +++ b/chip/mt_scp/mt818x/memmap.c @@ -11,8 +11,8 @@ #include "hooks.h" #include "memmap.h" #include "registers.h" -#include "util.h" #include "task.h" +#include "util.h" /* * Map SCP address (bits 31~28) to AP address diff --git a/chip/mt_scp/mt8192/clock.c b/chip/mt_scp/mt8192/clock.c index 665695a7a2..21d07d410a 100644 --- a/chip/mt_scp/mt8192/clock.c +++ b/chip/mt_scp/mt8192/clock.c @@ -5,9 +5,6 @@ /* Clocks, PLL and power settings */ -#include -#include - #include "clock.h" #include "common.h" #include "console.h" @@ -17,6 +14,9 @@ #include "registers.h" #include "timer.h" +#include +#include + #define CPRINTF(format, args...) cprintf(CC_CLOCK, format, ##args) #define CPRINTS(format, args...) cprints(CC_CLOCK, format, ##args) diff --git a/chip/mt_scp/mt8195/clock.c b/chip/mt_scp/mt8195/clock.c index 2ed3fab4a1..779f356bab 100644 --- a/chip/mt_scp/mt8195/clock.c +++ b/chip/mt_scp/mt8195/clock.c @@ -5,9 +5,6 @@ /* Clocks, PLL and power settings */ -#include -#include - #include "clock.h" #include "common.h" #include "console.h" @@ -20,6 +17,9 @@ #include "task.h" #include "timer.h" +#include +#include + #define CPRINTF(format, args...) cprintf(CC_CLOCK, format, ##args) #define CPRINTS(format, args...) cprints(CC_CLOCK, format, ##args) diff --git a/chip/npcx/adc.c b/chip/npcx/adc.c index f01419bf67..73d4ec48b3 100644 --- a/chip/npcx/adc.c +++ b/chip/npcx/adc.c @@ -9,8 +9,8 @@ #include "atomic.h" #include "clock.h" #include "clock_chip.h" -#include "console.h" #include "common.h" +#include "console.h" #include "gpio.h" #include "hooks.h" #include "registers.h" diff --git a/chip/npcx/espi.c b/chip/npcx/espi.c index 4cf5b0e80d..e73d04e988 100644 --- a/chip/npcx/espi.c +++ b/chip/npcx/espi.c @@ -5,18 +5,18 @@ /* ESPI module for Chrome EC */ -#include "registers.h" -#include "system.h" -#include "task.h" #include "chipset.h" #include "console.h" -#include "uart.h" -#include "util.h" -#include "power.h" #include "espi.h" -#include "lpc_chip.h" #include "hooks.h" +#include "lpc_chip.h" +#include "power.h" +#include "registers.h" +#include "system.h" +#include "task.h" #include "timer.h" +#include "uart.h" +#include "util.h" /* Console output macros */ #if !(DEBUG_ESPI) diff --git a/chip/npcx/fan.c b/chip/npcx/fan.c index 6a246f5c6a..9ceccaba33 100644 --- a/chip/npcx/fan.c +++ b/chip/npcx/fan.c @@ -7,20 +7,19 @@ #include "clock.h" #include "clock_chip.h" +#include "console.h" #include "fan.h" #include "fan_chip.h" #include "gpio.h" #include "hooks.h" -#include "registers.h" -#include "util.h" +#include "math_util.h" #include "pwm.h" #include "pwm_chip.h" -#include "console.h" -#include "timer.h" -#include "task.h" -#include "hooks.h" +#include "registers.h" #include "system.h" -#include "math_util.h" +#include "task.h" +#include "timer.h" +#include "util.h" #if !(DEBUG_FAN) #define CPRINTS(...) diff --git a/chip/npcx/flash.c b/chip/npcx/flash.c index 390cb1fa64..dc8de6e3ee 100644 --- a/chip/npcx/flash.c +++ b/chip/npcx/flash.c @@ -6,18 +6,18 @@ /* Flash memory module for Chrome EC */ #include "builtin/assert.h" +#include "console.h" #include "flash.h" #include "host_command.h" +#include "hwtimer_chip.h" #include "registers.h" #include "spi_flash_reg.h" #include "switch.h" #include "system.h" +#include "task.h" #include "timer.h" #include "util.h" -#include "task.h" #include "watchdog.h" -#include "console.h" -#include "hwtimer_chip.h" static int all_protected; /* Has all-flash protection been requested? */ static int addr_prot_start; diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c index 4127b79e30..a976b3b122 100644 --- a/chip/npcx/gpio.c +++ b/chip/npcx/gpio.c @@ -7,19 +7,19 @@ #include "builtin/assert.h" #include "common.h" +#include "ec_commands.h" #include "gpio.h" #include "gpio_chip.h" -#include "i2c.h" #include "hooks.h" +#include "host_command.h" +#include "hwtimer_chip.h" +#include "i2c.h" #include "registers.h" +#include "system.h" +#include "system_chip.h" #include "task.h" #include "timer.h" #include "util.h" -#include "system.h" -#include "system_chip.h" -#include "ec_commands.h" -#include "host_command.h" -#include "hwtimer_chip.h" #if !(DEBUG_GPIO) #define CPUTS(...) diff --git a/chip/npcx/header.c b/chip/npcx/header.c index 2db7d9094c..81e5e986af 100644 --- a/chip/npcx/header.c +++ b/chip/npcx/header.c @@ -10,11 +10,11 @@ * This header is used by Nuvoton EC Booter. */ -#include - #include "config.h" #include "registers.h" +#include + /* Signature used by fw header */ #define SIG_FW_EC 0x2A3B4D5E diff --git a/chip/npcx/hwtimer.c b/chip/npcx/hwtimer.c index dfa06f69b2..e2e2fe4b19 100644 --- a/chip/npcx/hwtimer.c +++ b/chip/npcx/hwtimer.c @@ -8,12 +8,12 @@ #include "clock.h" #include "clock_chip.h" #include "common.h" +#include "console.h" #include "hooks.h" #include "hwtimer.h" #include "hwtimer_chip.h" #include "math_util.h" #include "registers.h" -#include "console.h" #include "task.h" #include "timer.h" #include "util.h" diff --git a/chip/npcx/keyboard_raw.c b/chip/npcx/keyboard_raw.c index cb2be7911e..1774e7353d 100644 --- a/chip/npcx/keyboard_raw.c +++ b/chip/npcx/keyboard_raw.c @@ -5,11 +5,11 @@ /* Functions needed by keyboard scanner module for Chrome EC */ +#include "clock.h" #include "common.h" +#include "gpio.h" #include "keyboard_raw.h" #include "keyboard_scan.h" -#include "clock.h" -#include "gpio.h" #include "registers.h" #include "task.h" diff --git a/chip/npcx/lct.c b/chip/npcx/lct.c index 19568cac44..8f720e1376 100644 --- a/chip/npcx/lct.c +++ b/chip/npcx/lct.c @@ -4,9 +4,9 @@ */ /* LCT (Long Countdown Timer) module for Chrome EC */ -#include "lct_chip.h" #include "console.h" #include "hooks.h" +#include "lct_chip.h" #include "registers.h" #include "rtc.h" #include "task.h" diff --git a/chip/npcx/lpc.c b/chip/npcx/lpc.c index 48e094f3fc..b44420e025 100644 --- a/chip/npcx/lpc.c +++ b/chip/npcx/lpc.c @@ -20,12 +20,12 @@ #include "lpc_chip.h" #include "port80.h" #include "registers.h" -#include "system.h" #include "sib_chip.h" +#include "system.h" +#include "system_chip.h" #include "task.h" #include "uart.h" #include "util.h" -#include "system_chip.h" /* Console output macros */ #if !(DEBUG_LPC) diff --git a/chip/npcx/peci.c b/chip/npcx/peci.c index 7c213648f4..8a4372f7bd 100644 --- a/chip/npcx/peci.c +++ b/chip/npcx/peci.c @@ -15,8 +15,8 @@ #include "peci.h" #include "registers.h" #include "task.h" -#include "timer.h" #include "temp_sensor.h" +#include "timer.h" #include "util.h" /* Initial PECI baud rate */ diff --git a/chip/npcx/ps2.c b/chip/npcx/ps2.c index a8a65e63ea..5fc91ef241 100644 --- a/chip/npcx/ps2.c +++ b/chip/npcx/ps2.c @@ -8,11 +8,11 @@ #include "atomic.h" #include "clock.h" #include "console.h" -#include "hooks.h" #include "gpio.h" +#include "hooks.h" #include "ps2_chip.h" -#include "task.h" #include "registers.h" +#include "task.h" #include "timer.h" #include "util.h" diff --git a/chip/npcx/registers.h b/chip/npcx/registers.h index 922d787323..a583fb1c64 100644 --- a/chip/npcx/registers.h +++ b/chip/npcx/registers.h @@ -8,9 +8,9 @@ #ifndef __CROS_EC_REGISTERS_H #define __CROS_EC_REGISTERS_H +#include "clock_chip.h" #include "common.h" #include "compile_time_macros.h" -#include "clock_chip.h" /******************************************************************************/ /* diff --git a/chip/npcx/shi.c b/chip/npcx/shi.c index d5f19c9191..dde2243462 100644 --- a/chip/npcx/shi.c +++ b/chip/npcx/shi.c @@ -15,12 +15,12 @@ #include "clock.h" #include "console.h" #include "gpio.h" -#include "task.h" #include "hooks.h" #include "host_command.h" #include "registers.h" #include "spi.h" #include "system.h" +#include "task.h" #include "timer.h" #include "util.h" diff --git a/chip/npcx/spi.c b/chip/npcx/spi.c index 0161ce63ef..bbe6b33a9d 100644 --- a/chip/npcx/spi.c +++ b/chip/npcx/spi.c @@ -5,11 +5,11 @@ /* SPI module for Chrome EC */ +#include "clock.h" +#include "clock_chip.h" #include "console.h" #include "gpio.h" #include "hooks.h" -#include "clock.h" -#include "clock_chip.h" #include "registers.h" #include "spi.h" #include "task.h" diff --git a/chip/npcx/spiflashfw/npcx_monitor.c b/chip/npcx/spiflashfw/npcx_monitor.c index 5b7a767992..0d8530a456 100644 --- a/chip/npcx/spiflashfw/npcx_monitor.c +++ b/chip/npcx/spiflashfw/npcx_monitor.c @@ -5,12 +5,13 @@ * NPCX SoC spi flash update tool - monitor firmware */ -#include #include "config.h" #include "npcx_monitor.h" #include "registers.h" #include "util.h" +#include + /*****************************************************************************/ /* spi flash internal functions */ void sspi_flash_pinmux(int enable) diff --git a/chip/npcx/system-npcx7.c b/chip/npcx/system-npcx7.c index 5cacbec749..386544ed04 100644 --- a/chip/npcx/system-npcx7.c +++ b/chip/npcx/system-npcx7.c @@ -11,16 +11,16 @@ #include "console.h" #include "cpu.h" #include "ec_commands.h" +#include "gpio.h" #include "hooks.h" +#include "hwtimer_chip.h" #include "lct_chip.h" #include "registers.h" +#include "rom_chip.h" #include "system.h" +#include "system_chip.h" #include "task.h" #include "util.h" -#include "gpio.h" -#include "hwtimer_chip.h" -#include "system_chip.h" -#include "rom_chip.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) diff --git a/chip/npcx/system-npcx9.c b/chip/npcx/system-npcx9.c index 5cacbec749..386544ed04 100644 --- a/chip/npcx/system-npcx9.c +++ b/chip/npcx/system-npcx9.c @@ -11,16 +11,16 @@ #include "console.h" #include "cpu.h" #include "ec_commands.h" +#include "gpio.h" #include "hooks.h" +#include "hwtimer_chip.h" #include "lct_chip.h" #include "registers.h" +#include "rom_chip.h" #include "system.h" +#include "system_chip.h" #include "task.h" #include "util.h" -#include "gpio.h" -#include "hwtimer_chip.h" -#include "system_chip.h" -#include "rom_chip.h" #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) diff --git a/chip/npcx/uart.c b/chip/npcx/uart.c index bc87b5921e..d77c3579c5 100644 --- a/chip/npcx/uart.c +++ b/chip/npcx/uart.c @@ -6,6 +6,7 @@ /* UART module for Chrome EC */ #include "clock.h" +#include "clock_chip.h" #include "common.h" #include "console.h" #include "gpio.h" @@ -13,7 +14,6 @@ #include "hwtimer_chip.h" #include "lpc.h" #include "registers.h" -#include "clock_chip.h" #include "system.h" #include "task.h" #include "timer.h" diff --git a/chip/npcx/uartn.c b/chip/npcx/uartn.c index 9bcaccd94c..66cb30062b 100644 --- a/chip/npcx/uartn.c +++ b/chip/npcx/uartn.c @@ -6,15 +6,16 @@ /* UART module for Chrome EC */ -#include #include "common.h" -#include -#include #include "registers.h" #include "system.h" #include "task.h" #include "util.h" +#include +#include +#include + #ifdef NPCX_UART_FIFO_SUPPORT /* Enable UART Tx FIFO empty interrupt */ #define NPCX_UART_TX_EMPTY_INT_EN(n) \ diff --git a/chip/npcx/watchdog.c b/chip/npcx/watchdog.c index 8ae9ee0474..7998378565 100644 --- a/chip/npcx/watchdog.c +++ b/chip/npcx/watchdog.c @@ -8,14 +8,14 @@ #include "clock.h" #include "common.h" #include "console.h" -#include "registers.h" -#include "hwtimer_chip.h" #include "gpio.h" #include "hooks.h" -#include "timer.h" +#include "hwtimer_chip.h" +#include "registers.h" +#include "system_chip.h" #include "task.h" +#include "timer.h" #include "util.h" -#include "system_chip.h" #include "watchdog.h" /* WDCNT value for watchdog period */ diff --git a/chip/stm32/adc-stm32l.c b/chip/stm32/adc-stm32l.c index 636710f071..06b16224f7 100644 --- a/chip/stm32/adc-stm32l.c +++ b/chip/stm32/adc-stm32l.c @@ -4,9 +4,9 @@ */ #include "adc.h" +#include "clock.h" #include "common.h" #include "console.h" -#include "clock.h" #include "dma.h" #include "hooks.h" #include "registers.h" diff --git a/chip/stm32/bkpdata.c b/chip/stm32/bkpdata.c index bde026facd..ef5729d118 100644 --- a/chip/stm32/bkpdata.c +++ b/chip/stm32/bkpdata.c @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -#include - #include "bkpdata.h" #include "registers.h" #include "system.h" /* enum system_bbram_idx */ #include "task.h" +#include + uint16_t bkpdata_read(enum bkpdata_index index) { if (index < 0 || index >= STM32_BKP_ENTRIES) diff --git a/chip/stm32/clock-f.c b/chip/stm32/clock-f.c index d181397d86..0aad58ab00 100644 --- a/chip/stm32/clock-f.c +++ b/chip/stm32/clock-f.c @@ -7,8 +7,8 @@ #include "builtin/assert.h" #include "chipset.h" -#include "clock.h" #include "clock-f.h" +#include "clock.h" #include "common.h" #include "console.h" #include "cpu.h" diff --git a/chip/stm32/clock-stm32f0.c b/chip/stm32/clock-stm32f0.c index 3b56382fdb..18c089b036 100644 --- a/chip/stm32/clock-stm32f0.c +++ b/chip/stm32/clock-stm32f0.c @@ -6,8 +6,8 @@ /* Clocks and power management settings */ #include "chipset.h" -#include "clock.h" #include "clock-f.h" +#include "clock.h" #include "common.h" #include "console.h" #include "cpu.h" diff --git a/chip/stm32/clock-stm32f3.c b/chip/stm32/clock-stm32f3.c index 7d2b3de7f2..5b17fe56eb 100644 --- a/chip/stm32/clock-stm32f3.c +++ b/chip/stm32/clock-stm32f3.c @@ -6,8 +6,8 @@ /* Clocks and power management settings */ #include "chipset.h" -#include "clock.h" #include "clock-f.h" +#include "clock.h" #include "common.h" #include "console.h" #include "cpu.h" diff --git a/chip/stm32/clock-stm32f4.c b/chip/stm32/clock-stm32f4.c index 479faac7da..15cf8a45e2 100644 --- a/chip/stm32/clock-stm32f4.c +++ b/chip/stm32/clock-stm32f4.c @@ -7,8 +7,8 @@ #include "builtin/assert.h" #include "chipset.h" -#include "clock.h" #include "clock-f.h" +#include "clock.h" #include "common.h" #include "console.h" #include "cpu.h" diff --git a/chip/stm32/clock-stm32g4.c b/chip/stm32/clock-stm32g4.c index dbb8fd88cb..962fdc37f2 100644 --- a/chip/stm32/clock-stm32g4.c +++ b/chip/stm32/clock-stm32g4.c @@ -7,8 +7,8 @@ #include "builtin/assert.h" #include "chipset.h" -#include "clock.h" #include "clock-f.h" +#include "clock.h" #include "common.h" #include "console.h" #include "cpu.h" diff --git a/chip/stm32/clock-stm32h7.c b/chip/stm32/clock-stm32h7.c index 67e17f4174..3e6ba679cb 100644 --- a/chip/stm32/clock-stm32h7.c +++ b/chip/stm32/clock-stm32h7.c @@ -13,8 +13,6 @@ * but at least yields predictable behavior. */ -#include - #include "builtin/assert.h" #include "chipset.h" #include "clock.h" @@ -29,6 +27,8 @@ #include "uart.h" #include "util.h" +#include + /* Check chip family and variant for compatibility */ #ifndef CHIP_FAMILY_STM32H7 #error Source clock-stm32h7.c does not support this chip family. diff --git a/chip/stm32/clock-stm32l4.c b/chip/stm32/clock-stm32l4.c index 77e807c1ad..412771163c 100644 --- a/chip/stm32/clock-stm32l4.c +++ b/chip/stm32/clock-stm32l4.c @@ -7,8 +7,8 @@ #include "builtin/assert.h" #include "chipset.h" -#include "clock.h" #include "clock-l4.h" +#include "clock.h" #include "common.h" #include "console.h" #include "cpu.h" diff --git a/chip/stm32/flash-f.c b/chip/stm32/flash-f.c index 9bfdb1b6b7..2673201472 100644 --- a/chip/stm32/flash-f.c +++ b/chip/stm32/flash-f.c @@ -5,22 +5,23 @@ /* Common flash memory module for STM32F and STM32F0 */ -#include #include "battery.h" #include "builtin/assert.h" -#include "console.h" #include "clock.h" -#include "flash.h" +#include "console.h" #include "flash-f.h" +#include "flash.h" #include "hooks.h" -#include "registers.h" #include "panic.h" +#include "registers.h" #include "system.h" #include "task.h" #include "timer.h" #include "util.h" #include "watchdog.h" +#include + #define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) #define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) diff --git a/chip/stm32/flash-stm32f3.c b/chip/stm32/flash-stm32f3.c index 8705e4d657..c41f9c526d 100644 --- a/chip/stm32/flash-stm32f3.c +++ b/chip/stm32/flash-stm32f3.c @@ -5,15 +5,16 @@ /* Flash memory module for stm32f3 and stm32f4 */ -#include #include "common.h" -#include "flash.h" #include "flash-f.h" #include "flash-regs.h" +#include "flash.h" #include "hooks.h" +#include "panic.h" #include "registers.h" #include "system.h" -#include "panic.h" + +#include /*****************************************************************************/ /* Physical layer APIs */ diff --git a/chip/stm32/flash-stm32f4.c b/chip/stm32/flash-stm32f4.c index 8705e4d657..c41f9c526d 100644 --- a/chip/stm32/flash-stm32f4.c +++ b/chip/stm32/flash-stm32f4.c @@ -5,15 +5,16 @@ /* Flash memory module for stm32f3 and stm32f4 */ -#include #include "common.h" -#include "flash.h" #include "flash-f.h" #include "flash-regs.h" +#include "flash.h" #include "hooks.h" +#include "panic.h" #include "registers.h" #include "system.h" -#include "panic.h" + +#include /*****************************************************************************/ /* Physical layer APIs */ diff --git a/chip/stm32/flash-stm32g4-l4.c b/chip/stm32/flash-stm32g4-l4.c index 31dba5c887..ad08047c23 100644 --- a/chip/stm32/flash-stm32g4-l4.c +++ b/chip/stm32/flash-stm32g4-l4.c @@ -4,12 +4,12 @@ */ /* Flash memory module for STM32L4 family */ -#include "common.h" #include "clock.h" +#include "common.h" #include "flash.h" #include "hooks.h" -#include "registers.h" #include "panic.h" +#include "registers.h" #include "system.h" #include "task.h" #include "timer.h" diff --git a/chip/stm32/flash-stm32h7.c b/chip/stm32/flash-stm32h7.c index 445b354e57..2b9b594938 100644 --- a/chip/stm32/flash-stm32h7.c +++ b/chip/stm32/flash-stm32h7.c @@ -4,14 +4,14 @@ */ /* Flash memory module for STM32H7 family */ -#include "common.h" #include "clock.h" +#include "common.h" #include "cpu.h" -#include "flash.h" #include "flash-regs.h" +#include "flash.h" #include "hooks.h" -#include "registers.h" #include "panic.h" +#include "registers.h" #include "system.h" #include "task.h" #include "timer.h" diff --git a/chip/stm32/hwtimer32.c b/chip/stm32/hwtimer32.c index 0448d34e4b..ebe46d8316 100644 --- a/chip/stm32/hwtimer32.c +++ b/chip/stm32/hwtimer32.c @@ -6,8 +6,8 @@ /* Hardware 32-bit timer driver */ #include "builtin/assert.h" -#include "clock.h" #include "clock-f.h" +#include "clock.h" #include "common.h" #include "hooks.h" #include "hwtimer.h" diff --git a/chip/stm32/i2c-stm32l4.c b/chip/stm32/i2c-stm32l4.c index eeb87ec4e0..bb24a8a50f 100644 --- a/chip/stm32/i2c-stm32l4.c +++ b/chip/stm32/i2c-stm32l4.c @@ -4,7 +4,6 @@ */ #include "builtin/assert.h" -#include "printf.h" #include "chipset.h" #include "clock.h" #include "common.h" @@ -13,8 +12,8 @@ #include "hooks.h" #include "hwtimer.h" #include "i2c.h" +#include "printf.h" #include "registers.h" - #include "system.h" #include "task.h" #include "timer.h" diff --git a/chip/stm32/i2c_ite_flash_support.c b/chip/stm32/i2c_ite_flash_support.c index 8482065086..335064572b 100644 --- a/chip/stm32/i2c_ite_flash_support.c +++ b/chip/stm32/i2c_ite_flash_support.c @@ -4,8 +4,8 @@ */ /* STM implementation for flashing ITE-based ECs over i2c */ -#include "i2c_ite_flash_support.h" #include "i2c.h" +#include "i2c_ite_flash_support.h" #include "registers.h" #include "time.h" diff --git a/chip/stm32/pwm.c b/chip/stm32/pwm.c index 0f2e50c999..a9f266cbe0 100644 --- a/chip/stm32/pwm.c +++ b/chip/stm32/pwm.c @@ -6,8 +6,8 @@ /* PWM control module for STM32 */ #include "builtin/assert.h" -#include "clock.h" #include "clock-f.h" +#include "clock.h" #include "gpio.h" #include "hooks.h" #include "hwtimer.h" diff --git a/chip/stm32/uart.c b/chip/stm32/uart.c index 1bb961a935..916cb2257a 100644 --- a/chip/stm32/uart.c +++ b/chip/stm32/uart.c @@ -5,17 +5,17 @@ /* USART driver for Chrome EC */ -#include "common.h" #include "clock.h" +#include "common.h" #include "dma.h" #include "gpio.h" #include "hooks.h" #include "registers.h" +#include "stm32-dma.h" #include "system.h" #include "task.h" #include "uart.h" #include "util.h" -#include "stm32-dma.h" /* Console USART index */ #define UARTN CONFIG_UART_CONSOLE diff --git a/chip/stm32/ucpd-stm32gx.c b/chip/stm32/ucpd-stm32gx.c index 3fec860200..424792c5d0 100644 --- a/chip/stm32/ucpd-stm32gx.c +++ b/chip/stm32/ucpd-stm32gx.c @@ -6,8 +6,8 @@ /* STM32GX UCPD module for Chrome EC */ #include "clock.h" -#include "console.h" #include "common.h" +#include "console.h" #include "driver/tcpm/tcpm.h" #include "gpio.h" #include "hooks.h" diff --git a/chip/stm32/usart-stm32f0.c b/chip/stm32/usart-stm32f0.c index 56325cdc74..debb062473 100644 --- a/chip/stm32/usart-stm32f0.c +++ b/chip/stm32/usart-stm32f0.c @@ -2,14 +2,13 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "usart-stm32f0.h" - #include "clock.h" #include "common.h" #include "compile_time_macros.h" #include "hooks.h" #include "registers.h" #include "task.h" +#include "usart-stm32f0.h" #include "util.h" /* diff --git a/chip/stm32/usart-stm32f3.c b/chip/stm32/usart-stm32f3.c index f5a138643c..b46ac2ed8f 100644 --- a/chip/stm32/usart-stm32f3.c +++ b/chip/stm32/usart-stm32f3.c @@ -2,13 +2,12 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "usart-stm32f3.h" - #include "common.h" #include "compile_time_macros.h" #include "hooks.h" #include "registers.h" #include "task.h" +#include "usart-stm32f3.h" #include "util.h" /* diff --git a/chip/stm32/usart-stm32f4.c b/chip/stm32/usart-stm32f4.c index a710760e3a..0806cab062 100644 --- a/chip/stm32/usart-stm32f4.c +++ b/chip/stm32/usart-stm32f4.c @@ -3,14 +3,13 @@ * found in the LICENSE file. */ -#include "usart-stm32f4.h" - #include "clock.h" #include "common.h" #include "compile_time_macros.h" #include "hooks.h" #include "registers.h" #include "task.h" +#include "usart-stm32f4.h" #include "util.h" /* diff --git a/chip/stm32/usart-stm32l.c b/chip/stm32/usart-stm32l.c index dc300d598a..b6c9e21595 100644 --- a/chip/stm32/usart-stm32l.c +++ b/chip/stm32/usart-stm32l.c @@ -2,14 +2,13 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "usart-stm32l.h" - #include "clock.h" #include "common.h" #include "compile_time_macros.h" #include "hooks.h" #include "registers.h" #include "task.h" +#include "usart-stm32l.h" #include "util.h" /* diff --git a/chip/stm32/usart-stm32l5.c b/chip/stm32/usart-stm32l5.c index 30e0f009ff..5f34c37bc4 100644 --- a/chip/stm32/usart-stm32l5.c +++ b/chip/stm32/usart-stm32l5.c @@ -2,14 +2,13 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "usart-stm32l.h" - #include "clock.h" #include "common.h" #include "compile_time_macros.h" #include "hooks.h" #include "registers.h" #include "task.h" +#include "usart-stm32l.h" #include "util.h" /* diff --git a/chip/stm32/usart_host_command.c b/chip/stm32/usart_host_command.c index 437975e609..817343df98 100644 --- a/chip/stm32/usart_host_command.c +++ b/chip/stm32/usart_host_command.c @@ -3,8 +3,8 @@ * found in the LICENSE file. */ -#include "common.h" #include "clock.h" +#include "common.h" #include "dma.h" #include "gpio.h" #include "hooks.h" @@ -13,9 +13,9 @@ #include "registers.h" #include "system.h" #include "task.h" -#include "usart_rx_dma.h" -#include "usart_host_command.h" #include "usart-stm32f4.h" +#include "usart_host_command.h" +#include "usart_rx_dma.h" #include "util.h" /* Console output macros */ diff --git a/chip/stm32/usart_host_command.h b/chip/stm32/usart_host_command.h index ee4bdd88dc..ddbd5c5c99 100644 --- a/chip/stm32/usart_host_command.h +++ b/chip/stm32/usart_host_command.h @@ -6,12 +6,13 @@ #ifndef __CROS_EC_USART_HOST_COMMAND_H #define __CROS_EC_USART_HOST_COMMAND_H -#include /* For va_list */ #include "common.h" #include "gpio.h" #include "host_command.h" #include "usart.h" +#include /* For va_list */ + /* * Add data to host command layer buffer. */ diff --git a/chip/stm32/usart_rx_dma.c b/chip/stm32/usart_rx_dma.c index 21c8313c73..8997617ff3 100644 --- a/chip/stm32/usart_rx_dma.c +++ b/chip/stm32/usart_rx_dma.c @@ -3,14 +3,13 @@ * found in the LICENSE file. */ -#include "usart_rx_dma.h" - #include "atomic.h" #include "common.h" #include "console.h" #include "registers.h" #include "system.h" #include "usart_host_command.h" +#include "usart_rx_dma.h" #include "util.h" typedef size_t (*add_data_t)(struct usart_config const *config, diff --git a/chip/stm32/usart_rx_dma.h b/chip/stm32/usart_rx_dma.h index 6d273d18b9..191ccc8c7f 100644 --- a/chip/stm32/usart_rx_dma.h +++ b/chip/stm32/usart_rx_dma.h @@ -7,8 +7,8 @@ #ifndef __CROS_EC_USART_RX_DMA_H #define __CROS_EC_USART_RX_DMA_H -#include "producer.h" #include "dma.h" +#include "producer.h" #include "queue.h" #include "usart.h" diff --git a/chip/stm32/usart_rx_interrupt-stm32f0.c b/chip/stm32/usart_rx_interrupt-stm32f0.c index dfbe6ec3ff..a142bcd436 100644 --- a/chip/stm32/usart_rx_interrupt-stm32f0.c +++ b/chip/stm32/usart_rx_interrupt-stm32f0.c @@ -5,12 +5,11 @@ /* Interrupt based USART RX driver for STM32F0 and STM32F3 */ -#include "usart.h" - #include "atomic.h" #include "common.h" #include "queue.h" #include "registers.h" +#include "usart.h" static void usart_rx_init(struct usart_config const *config) { diff --git a/chip/stm32/usart_rx_interrupt-stm32f3.c b/chip/stm32/usart_rx_interrupt-stm32f3.c index dfbe6ec3ff..a142bcd436 100644 --- a/chip/stm32/usart_rx_interrupt-stm32f3.c +++ b/chip/stm32/usart_rx_interrupt-stm32f3.c @@ -5,12 +5,11 @@ /* Interrupt based USART RX driver for STM32F0 and STM32F3 */ -#include "usart.h" - #include "atomic.h" #include "common.h" #include "queue.h" #include "registers.h" +#include "usart.h" static void usart_rx_init(struct usart_config const *config) { diff --git a/chip/stm32/usart_rx_interrupt-stm32f4.c b/chip/stm32/usart_rx_interrupt-stm32f4.c index 1d86c7d5b6..80ba37e88f 100644 --- a/chip/stm32/usart_rx_interrupt-stm32f4.c +++ b/chip/stm32/usart_rx_interrupt-stm32f4.c @@ -5,12 +5,11 @@ /* Interrupt based USART RX driver for STM32F0 and STM32F4 */ -#include "usart.h" - #include "atomic.h" #include "common.h" #include "queue.h" #include "registers.h" +#include "usart.h" static void usart_rx_init(struct usart_config const *config) { diff --git a/chip/stm32/usart_rx_interrupt-stm32l.c b/chip/stm32/usart_rx_interrupt-stm32l.c index 750809307b..2c74d7dbd1 100644 --- a/chip/stm32/usart_rx_interrupt-stm32l.c +++ b/chip/stm32/usart_rx_interrupt-stm32l.c @@ -5,12 +5,11 @@ /* Interrupt based USART RX driver for STM32L */ -#include "usart.h" - #include "atomic.h" #include "common.h" #include "queue.h" #include "registers.h" +#include "usart.h" static void usart_rx_init(struct usart_config const *config) { diff --git a/chip/stm32/usart_rx_interrupt.c b/chip/stm32/usart_rx_interrupt.c index dfbe6ec3ff..a142bcd436 100644 --- a/chip/stm32/usart_rx_interrupt.c +++ b/chip/stm32/usart_rx_interrupt.c @@ -5,12 +5,11 @@ /* Interrupt based USART RX driver for STM32F0 and STM32F3 */ -#include "usart.h" - #include "atomic.h" #include "common.h" #include "queue.h" #include "registers.h" +#include "usart.h" static void usart_rx_init(struct usart_config const *config) { diff --git a/chip/stm32/usart_tx_dma.c b/chip/stm32/usart_tx_dma.c index 8128231ff7..d6469aa9e6 100644 --- a/chip/stm32/usart_tx_dma.c +++ b/chip/stm32/usart_tx_dma.c @@ -2,13 +2,12 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "usart_tx_dma.h" - -#include "usart.h" #include "common.h" #include "registers.h" #include "system.h" #include "task.h" +#include "usart.h" +#include "usart_tx_dma.h" #include "util.h" void usart_tx_dma_written(struct consumer const *consumer, size_t count) diff --git a/chip/stm32/usart_tx_interrupt.c b/chip/stm32/usart_tx_interrupt.c index 80d1d4df0f..7c99840e26 100644 --- a/chip/stm32/usart_tx_interrupt.c +++ b/chip/stm32/usart_tx_interrupt.c @@ -5,12 +5,11 @@ /* Interrupt based USART TX driver for STM32 */ -#include "usart.h" - #include "common.h" #include "registers.h" #include "system.h" #include "task.h" +#include "usart.h" #include "usart_host_command.h" #include "util.h" diff --git a/chip/stm32/usb-stm32f3.c b/chip/stm32/usb-stm32f3.c index eb48129e09..bef15db566 100644 --- a/chip/stm32/usb-stm32f3.c +++ b/chip/stm32/usb-stm32f3.c @@ -5,9 +5,8 @@ * STM32F3 Family specific USB functionality */ -#include "usb-stm32f3.h" - #include "system.h" +#include "usb-stm32f3.h" #include "usb_api.h" void usb_connect(void) diff --git a/chip/stm32/usb-stream.c b/chip/stm32/usb-stream.c index 76f7fbd340..f9cd2687bf 100644 --- a/chip/stm32/usb-stream.c +++ b/chip/stm32/usb-stream.c @@ -11,10 +11,10 @@ #include "registers.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usart.h" -#include "usb_hw.h" #include "usb-stream.h" +#include "usb_hw.h" +#include "util.h" static size_t rx_read(struct usb_stream_config const *config) { diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c index 1c621a32b3..dba9ebaba1 100644 --- a/chip/stm32/usb.c +++ b/chip/stm32/usb.c @@ -15,10 +15,10 @@ #include "system.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_api.h" #include "usb_descriptor.h" #include "usb_hw.h" +#include "util.h" /* Console output macro */ #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) diff --git a/chip/stm32/usb_console.c b/chip/stm32/usb_console.c index fdadc243c1..062ce2f484 100644 --- a/chip/stm32/usb_console.c +++ b/chip/stm32/usb_console.c @@ -12,10 +12,10 @@ #include "registers.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_api.h" #include "usb_descriptor.h" #include "usb_hw.h" +#include "util.h" /* Console output macro */ #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) diff --git a/chip/stm32/usb_dwc.c b/chip/stm32/usb_dwc.c index 67f89a5222..15ce4bff7f 100644 --- a/chip/stm32/usb_dwc.c +++ b/chip/stm32/usb_dwc.c @@ -13,12 +13,12 @@ #include "hooks.h" #include "link_defs.h" #include "registers.h" -#include "usb_hw.h" #include "system.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_descriptor.h" +#include "usb_hw.h" +#include "util.h" #include "watchdog.h" /****************************************************************************/ diff --git a/chip/stm32/usb_dwc_console.c b/chip/stm32/usb_dwc_console.c index fd66db7380..ff3c0817b6 100644 --- a/chip/stm32/usb_dwc_console.c +++ b/chip/stm32/usb_dwc_console.c @@ -12,9 +12,9 @@ #include "registers.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_descriptor.h" #include "usb_hw.h" +#include "util.h" /* Console output macro */ #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) diff --git a/chip/stm32/usb_dwc_stream.c b/chip/stm32/usb_dwc_stream.c index 670c93b437..78e0a4b484 100644 --- a/chip/stm32/usb_dwc_stream.c +++ b/chip/stm32/usb_dwc_stream.c @@ -3,12 +3,11 @@ * found in the LICENSE file. */ +#include "console.h" #include "registers.h" #include "timer.h" #include "usb_dwc_stream.h" #include "util.h" - -#include "console.h" #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) /* diff --git a/chip/stm32/usb_dwc_stream.h b/chip/stm32/usb_dwc_stream.h index 7e5e938053..bd512f5e9a 100644 --- a/chip/stm32/usb_dwc_stream.h +++ b/chip/stm32/usb_dwc_stream.h @@ -10,9 +10,9 @@ #include "compile_time_macros.h" #include "consumer.h" #include "hooks.h" -#include "registers.h" #include "producer.h" #include "queue.h" +#include "registers.h" #include "usb_descriptor.h" #include "usb_hw.h" diff --git a/chip/stm32/usb_endpoints.c b/chip/stm32/usb_endpoints.c index cf8cb17869..57ebc86eb2 100644 --- a/chip/stm32/usb_endpoints.c +++ b/chip/stm32/usb_endpoints.c @@ -5,13 +5,14 @@ * USB endpoints/interfaces callbacks declaration */ -#include -#include +#include "common.h" #include "compiler.h" #include "config.h" -#include "common.h" #include "usb_hw.h" +#include +#include + typedef void (*xfer_func)(void); typedef void (*evt_func)(enum usb_ep_event evt); diff --git a/chip/stm32/usb_hid.c b/chip/stm32/usb_hid.c index e9426b690d..321248c702 100644 --- a/chip/stm32/usb_hid.c +++ b/chip/stm32/usb_hid.c @@ -13,11 +13,11 @@ #include "registers.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_descriptor.h" -#include "usb_hw.h" #include "usb_hid.h" #include "usb_hid_hw.h" +#include "usb_hw.h" +#include "util.h" /* Console output macro */ #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c index 7f3caac960..7b40f31309 100644 --- a/chip/stm32/usb_hid_keyboard.c +++ b/chip/stm32/usb_hid_keyboard.c @@ -20,12 +20,12 @@ #include "tablet_mode.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_api.h" #include "usb_descriptor.h" -#include "usb_hw.h" #include "usb_hid.h" #include "usb_hid_hw.h" +#include "usb_hw.h" +#include "util.h" /* Console output macro */ #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) diff --git a/chip/stm32/usb_hid_touchpad.c b/chip/stm32/usb_hid_touchpad.c index 15dd38756f..8eb5ee95dc 100644 --- a/chip/stm32/usb_hid_touchpad.c +++ b/chip/stm32/usb_hid_touchpad.c @@ -15,13 +15,13 @@ #include "registers.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_api.h" #include "usb_descriptor.h" -#include "usb_hw.h" #include "usb_hid.h" #include "usb_hid_hw.h" #include "usb_hid_touchpad.h" +#include "usb_hw.h" +#include "util.h" /* Console output macro */ #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) diff --git a/chip/stm32/usb_isochronous.c b/chip/stm32/usb_isochronous.c index ad20b6d1ca..d2225991c0 100644 --- a/chip/stm32/usb_isochronous.c +++ b/chip/stm32/usb_isochronous.c @@ -3,15 +3,15 @@ * found in the LICENSE file. */ -#include "stddef.h" #include "common.h" #include "config.h" #include "link_defs.h" #include "registers.h" -#include "util.h" +#include "stddef.h" #include "usb_api.h" #include "usb_hw.h" #include "usb_isochronous.h" +#include "util.h" /* Console output macro */ #define CPRINTF(format, args...) cprintf(CC_USB, format, ##args) diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c index 9536301863..2d090293f9 100644 --- a/chip/stm32/usb_pd_phy.c +++ b/chip/stm32/usb_pd_phy.c @@ -11,15 +11,15 @@ #include "crc.h" #include "dma.h" #include "gpio.h" -#include "hwtimer.h" #include "hooks.h" +#include "hwtimer.h" #include "registers.h" #include "system.h" #include "task.h" #include "timer.h" -#include "util.h" #include "usb_pd.h" #include "usb_pd_config.h" +#include "util.h" #ifdef CONFIG_COMMON_RUNTIME #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) -- cgit v1.2.1 From f8de1825d4e008c0059f8c995b948c3ffc457423 Mon Sep 17 00:00:00 2001 From: Jason Yuan Date: Thu, 17 Nov 2022 13:30:03 -0800 Subject: zephyr: Project organization - skyrim Organized the skyrim program into folders for projects. Similar .dtsi files in project directory will be merged into program directory in a followup CL. BUG=b:254097911 TEST=Ran zmake compare-builds BRANCH=none Signed-off-by: Jason Yuan Change-Id: I1e0b9b4ea096f2e4ffa97067fe8aecdea171fc00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4035057 Tested-by: zhi cheng yuan Reviewed-by: Diana Z Reviewed-by: Keith Short Commit-Queue: zhi cheng yuan Code-Coverage: Zoss --- zephyr/program/skyrim/BUILD.py | 67 +--- zephyr/program/skyrim/CMakeLists.txt | 46 +-- zephyr/program/skyrim/adc.dts | 82 ----- zephyr/program/skyrim/adc.dtsi | 82 +++++ zephyr/program/skyrim/battery_crystaldrift.dts | 15 - zephyr/program/skyrim/battery_frostflow.dts | 12 - zephyr/program/skyrim/battery_morthal.dts | 15 - zephyr/program/skyrim/battery_skyrim.dts | 15 - zephyr/program/skyrim/battery_winterhold.dts | 33 -- zephyr/program/skyrim/crystaldrift.dts | 209 ------------ zephyr/program/skyrim/crystaldrift/CMakeLists.txt | 12 + zephyr/program/skyrim/crystaldrift/battery.dtsi | 15 + .../program/skyrim/crystaldrift/crystaldrift.dtsi | 209 ++++++++++++ zephyr/program/skyrim/crystaldrift/led_pins.dtsi | 61 ++++ zephyr/program/skyrim/crystaldrift/led_policy.dtsi | 103 ++++++ .../program/skyrim/crystaldrift/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/crystaldrift/project.conf | 26 ++ zephyr/program/skyrim/crystaldrift/project.overlay | 19 ++ .../program/skyrim/crystaldrift/src/alt_charger.c | 31 ++ zephyr/program/skyrim/crystaldrift/src/fan.c | 62 ++++ .../program/skyrim/crystaldrift/src/form_factor.c | 38 +++ .../program/skyrim/crystaldrift/src/ppc_config.c | 46 +++ .../skyrim/crystaldrift/src/usb_mux_config.c | 142 ++++++++ zephyr/program/skyrim/fan.dts | 39 --- zephyr/program/skyrim/fan.dtsi | 39 +++ zephyr/program/skyrim/frostflow.dts | 223 ------------- zephyr/program/skyrim/frostflow/CMakeLists.txt | 15 + zephyr/program/skyrim/frostflow/battery.dtsi | 12 + zephyr/program/skyrim/frostflow/frostflow.dtsi | 223 +++++++++++++ .../frostflow/include/keyboard_customization.h | 78 +++++ zephyr/program/skyrim/frostflow/led_pins.dtsi | 59 ++++ zephyr/program/skyrim/frostflow/led_policy.dtsi | 122 +++++++ zephyr/program/skyrim/frostflow/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/frostflow/project.conf | 33 ++ zephyr/program/skyrim/frostflow/project.overlay | 19 ++ zephyr/program/skyrim/frostflow/src/keyboard.c | 74 +++++ .../skyrim/frostflow/src/keyboard_customization.c | 85 +++++ zephyr/program/skyrim/frostflow/src/ppc_config.c | 46 +++ zephyr/program/skyrim/frostflow/src/thermal.c | 109 ++++++ .../program/skyrim/frostflow/src/usb_mux_config.c | 62 ++++ zephyr/program/skyrim/gpio.dts | 370 --------------------- zephyr/program/skyrim/gpio.dtsi | 370 +++++++++++++++++++++ zephyr/program/skyrim/i2c.dtsi | 294 ++++++++++++++++ zephyr/program/skyrim/i2c_common.dtsi | 294 ---------------- .../include/frostflow/keyboard_customization.h | 78 ----- .../skyrim/include/keyboard_customization.h | 78 +++++ zephyr/program/skyrim/interrupts.dts | 146 -------- zephyr/program/skyrim/interrupts.dtsi | 146 ++++++++ zephyr/program/skyrim/keyboard.dts | 48 --- zephyr/program/skyrim/keyboard.dtsi | 48 +++ zephyr/program/skyrim/led_pins_crystaldrift.dts | 61 ---- zephyr/program/skyrim/led_pins_frostflow.dts | 59 ---- zephyr/program/skyrim/led_pins_morthal.dts | 59 ---- zephyr/program/skyrim/led_pins_skyrim.dts | 59 ---- zephyr/program/skyrim/led_pins_winterhold.dts | 59 ---- zephyr/program/skyrim/led_policy_crystaldrift.dts | 103 ------ zephyr/program/skyrim/led_policy_frostflow.dts | 122 ------- zephyr/program/skyrim/led_policy_morthal.dts | 103 ------ zephyr/program/skyrim/led_policy_skyrim.dts | 103 ------ zephyr/program/skyrim/led_policy_winterhold.dts | 103 ------ zephyr/program/skyrim/morthal.dts | 185 ----------- zephyr/program/skyrim/morthal/CMakeLists.txt | 8 + zephyr/program/skyrim/morthal/battery.dtsi | 15 + zephyr/program/skyrim/morthal/led_pins.dtsi | 59 ++++ zephyr/program/skyrim/morthal/led_policy.dtsi | 103 ++++++ zephyr/program/skyrim/morthal/morthal.dtsi | 185 +++++++++++ zephyr/program/skyrim/morthal/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/morthal/project.conf | 23 ++ zephyr/program/skyrim/morthal/project.overlay | 19 ++ zephyr/program/skyrim/morthal/src/ppc_config.c | 46 +++ zephyr/program/skyrim/morthal/src/usb_mux_config.c | 142 ++++++++ zephyr/program/skyrim/motionsense.dts | 135 -------- zephyr/program/skyrim/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/motionsense_crystaldrift.dts | 135 -------- zephyr/program/skyrim/motionsense_frostflow.dts | 135 -------- zephyr/program/skyrim/motionsense_morthal.dts | 135 -------- zephyr/program/skyrim/motionsense_skyrim.dts | 135 -------- zephyr/program/skyrim/motionsense_winterhold.dts | 124 ------- zephyr/program/skyrim/prj.conf | 140 -------- zephyr/program/skyrim/prj_crystaldrift.conf | 26 -- zephyr/program/skyrim/prj_frostflow.conf | 33 -- zephyr/program/skyrim/prj_morthal.conf | 23 -- zephyr/program/skyrim/prj_skyrim.conf | 26 -- zephyr/program/skyrim/prj_winterhold.conf | 47 --- zephyr/program/skyrim/program.conf | 140 ++++++++ zephyr/program/skyrim/skyrim.dts | 209 ------------ zephyr/program/skyrim/skyrim/CMakeLists.txt | 13 + zephyr/program/skyrim/skyrim/battery.dtsi | 15 + zephyr/program/skyrim/skyrim/led_pins.dtsi | 59 ++++ zephyr/program/skyrim/skyrim/led_policy.dtsi | 103 ++++++ zephyr/program/skyrim/skyrim/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/skyrim/project.conf | 26 ++ zephyr/program/skyrim/skyrim/project.overlay | 19 ++ zephyr/program/skyrim/skyrim/skyrim.dtsi | 209 ++++++++++++ zephyr/program/skyrim/skyrim/skyrim_vif.xml | 346 +++++++++++++++++++ zephyr/program/skyrim/skyrim/src/alt_charger.c | 31 ++ zephyr/program/skyrim/skyrim/src/fan.c | 62 ++++ zephyr/program/skyrim/skyrim/src/form_factor.c | 38 +++ zephyr/program/skyrim/skyrim/src/keyboard.c | 29 ++ zephyr/program/skyrim/skyrim/src/ppc_config.c | 46 +++ zephyr/program/skyrim/skyrim/src/usb_mux_config.c | 142 ++++++++ zephyr/program/skyrim/skyrim_vif.xml | 346 ------------------- .../program/skyrim/src/crystaldrift/alt_charger.c | 31 -- zephyr/program/skyrim/src/crystaldrift/fan.c | 62 ---- .../program/skyrim/src/crystaldrift/form_factor.c | 38 --- .../program/skyrim/src/crystaldrift/ppc_config.c | 46 --- .../skyrim/src/crystaldrift/usb_mux_config.c | 142 -------- zephyr/program/skyrim/src/frostflow/keyboard.c | 74 ----- .../skyrim/src/frostflow/keyboard_customization.c | 85 ----- zephyr/program/skyrim/src/frostflow/ppc_config.c | 46 --- zephyr/program/skyrim/src/frostflow/thermal.c | 109 ------ .../program/skyrim/src/frostflow/usb_mux_config.c | 62 ---- zephyr/program/skyrim/src/morthal/ppc_config.c | 46 --- zephyr/program/skyrim/src/morthal/usb_mux_config.c | 142 -------- zephyr/program/skyrim/src/skyrim/alt_charger.c | 31 -- zephyr/program/skyrim/src/skyrim/fan.c | 62 ---- zephyr/program/skyrim/src/skyrim/form_factor.c | 38 --- zephyr/program/skyrim/src/skyrim/keyboard.c | 29 -- zephyr/program/skyrim/src/skyrim/ppc_config.c | 46 --- zephyr/program/skyrim/src/skyrim/usb_mux_config.c | 142 -------- .../skyrim/src/winterhold/battery_present.c | 81 ----- .../program/skyrim/src/winterhold/kb_backlight.c | 34 -- zephyr/program/skyrim/src/winterhold/keyboard.c | 29 -- zephyr/program/skyrim/src/winterhold/ppc_config.c | 27 -- zephyr/program/skyrim/src/winterhold/sensor.c | 37 --- .../program/skyrim/src/winterhold/usb_mux_config.c | 146 -------- zephyr/program/skyrim/usbc.dts | 26 -- zephyr/program/skyrim/usbc.dtsi | 26 ++ zephyr/program/skyrim/winterhold.dts | 168 ---------- zephyr/program/skyrim/winterhold/CMakeLists.txt | 12 + zephyr/program/skyrim/winterhold/battery.dtsi | 33 ++ zephyr/program/skyrim/winterhold/led_pins.dtsi | 59 ++++ zephyr/program/skyrim/winterhold/led_policy.dtsi | 103 ++++++ zephyr/program/skyrim/winterhold/motionsense.dtsi | 124 +++++++ zephyr/program/skyrim/winterhold/project.conf | 47 +++ zephyr/program/skyrim/winterhold/project.overlay | 19 ++ .../skyrim/winterhold/src/battery_present.c | 81 +++++ .../program/skyrim/winterhold/src/kb_backlight.c | 34 ++ zephyr/program/skyrim/winterhold/src/keyboard.c | 29 ++ zephyr/program/skyrim/winterhold/src/ppc_config.c | 27 ++ zephyr/program/skyrim/winterhold/src/sensor.c | 37 +++ .../program/skyrim/winterhold/src/usb_mux_config.c | 146 ++++++++ zephyr/program/skyrim/winterhold/winterhold.dtsi | 168 ++++++++++ 143 files changed, 6268 insertions(+), 6124 deletions(-) delete mode 100644 zephyr/program/skyrim/adc.dts create mode 100644 zephyr/program/skyrim/adc.dtsi delete mode 100644 zephyr/program/skyrim/battery_crystaldrift.dts delete mode 100644 zephyr/program/skyrim/battery_frostflow.dts delete mode 100644 zephyr/program/skyrim/battery_morthal.dts delete mode 100644 zephyr/program/skyrim/battery_skyrim.dts delete mode 100644 zephyr/program/skyrim/battery_winterhold.dts delete mode 100644 zephyr/program/skyrim/crystaldrift.dts create mode 100644 zephyr/program/skyrim/crystaldrift/CMakeLists.txt create mode 100644 zephyr/program/skyrim/crystaldrift/battery.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/led_pins.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/led_policy.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/motionsense.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/project.conf create mode 100644 zephyr/program/skyrim/crystaldrift/project.overlay create mode 100644 zephyr/program/skyrim/crystaldrift/src/alt_charger.c create mode 100644 zephyr/program/skyrim/crystaldrift/src/fan.c create mode 100644 zephyr/program/skyrim/crystaldrift/src/form_factor.c create mode 100644 zephyr/program/skyrim/crystaldrift/src/ppc_config.c create mode 100644 zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/fan.dts create mode 100644 zephyr/program/skyrim/fan.dtsi delete mode 100644 zephyr/program/skyrim/frostflow.dts create mode 100644 zephyr/program/skyrim/frostflow/CMakeLists.txt create mode 100644 zephyr/program/skyrim/frostflow/battery.dtsi create mode 100644 zephyr/program/skyrim/frostflow/frostflow.dtsi create mode 100644 zephyr/program/skyrim/frostflow/include/keyboard_customization.h create mode 100644 zephyr/program/skyrim/frostflow/led_pins.dtsi create mode 100644 zephyr/program/skyrim/frostflow/led_policy.dtsi create mode 100644 zephyr/program/skyrim/frostflow/motionsense.dtsi create mode 100644 zephyr/program/skyrim/frostflow/project.conf create mode 100644 zephyr/program/skyrim/frostflow/project.overlay create mode 100644 zephyr/program/skyrim/frostflow/src/keyboard.c create mode 100644 zephyr/program/skyrim/frostflow/src/keyboard_customization.c create mode 100644 zephyr/program/skyrim/frostflow/src/ppc_config.c create mode 100644 zephyr/program/skyrim/frostflow/src/thermal.c create mode 100644 zephyr/program/skyrim/frostflow/src/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/gpio.dts create mode 100644 zephyr/program/skyrim/gpio.dtsi create mode 100644 zephyr/program/skyrim/i2c.dtsi delete mode 100644 zephyr/program/skyrim/i2c_common.dtsi delete mode 100644 zephyr/program/skyrim/include/frostflow/keyboard_customization.h create mode 100644 zephyr/program/skyrim/include/keyboard_customization.h delete mode 100644 zephyr/program/skyrim/interrupts.dts create mode 100644 zephyr/program/skyrim/interrupts.dtsi delete mode 100644 zephyr/program/skyrim/keyboard.dts create mode 100644 zephyr/program/skyrim/keyboard.dtsi delete mode 100644 zephyr/program/skyrim/led_pins_crystaldrift.dts delete mode 100644 zephyr/program/skyrim/led_pins_frostflow.dts delete mode 100644 zephyr/program/skyrim/led_pins_morthal.dts delete mode 100644 zephyr/program/skyrim/led_pins_skyrim.dts delete mode 100644 zephyr/program/skyrim/led_pins_winterhold.dts delete mode 100644 zephyr/program/skyrim/led_policy_crystaldrift.dts delete mode 100644 zephyr/program/skyrim/led_policy_frostflow.dts delete mode 100644 zephyr/program/skyrim/led_policy_morthal.dts delete mode 100644 zephyr/program/skyrim/led_policy_skyrim.dts delete mode 100644 zephyr/program/skyrim/led_policy_winterhold.dts delete mode 100644 zephyr/program/skyrim/morthal.dts create mode 100644 zephyr/program/skyrim/morthal/CMakeLists.txt create mode 100644 zephyr/program/skyrim/morthal/battery.dtsi create mode 100644 zephyr/program/skyrim/morthal/led_pins.dtsi create mode 100644 zephyr/program/skyrim/morthal/led_policy.dtsi create mode 100644 zephyr/program/skyrim/morthal/morthal.dtsi create mode 100644 zephyr/program/skyrim/morthal/motionsense.dtsi create mode 100644 zephyr/program/skyrim/morthal/project.conf create mode 100644 zephyr/program/skyrim/morthal/project.overlay create mode 100644 zephyr/program/skyrim/morthal/src/ppc_config.c create mode 100644 zephyr/program/skyrim/morthal/src/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/motionsense.dts create mode 100644 zephyr/program/skyrim/motionsense.dtsi delete mode 100644 zephyr/program/skyrim/motionsense_crystaldrift.dts delete mode 100644 zephyr/program/skyrim/motionsense_frostflow.dts delete mode 100644 zephyr/program/skyrim/motionsense_morthal.dts delete mode 100644 zephyr/program/skyrim/motionsense_skyrim.dts delete mode 100644 zephyr/program/skyrim/motionsense_winterhold.dts delete mode 100644 zephyr/program/skyrim/prj.conf delete mode 100644 zephyr/program/skyrim/prj_crystaldrift.conf delete mode 100644 zephyr/program/skyrim/prj_frostflow.conf delete mode 100644 zephyr/program/skyrim/prj_morthal.conf delete mode 100644 zephyr/program/skyrim/prj_skyrim.conf delete mode 100644 zephyr/program/skyrim/prj_winterhold.conf create mode 100644 zephyr/program/skyrim/program.conf delete mode 100644 zephyr/program/skyrim/skyrim.dts create mode 100644 zephyr/program/skyrim/skyrim/CMakeLists.txt create mode 100644 zephyr/program/skyrim/skyrim/battery.dtsi create mode 100644 zephyr/program/skyrim/skyrim/led_pins.dtsi create mode 100644 zephyr/program/skyrim/skyrim/led_policy.dtsi create mode 100644 zephyr/program/skyrim/skyrim/motionsense.dtsi create mode 100644 zephyr/program/skyrim/skyrim/project.conf create mode 100644 zephyr/program/skyrim/skyrim/project.overlay create mode 100644 zephyr/program/skyrim/skyrim/skyrim.dtsi create mode 100644 zephyr/program/skyrim/skyrim/skyrim_vif.xml create mode 100644 zephyr/program/skyrim/skyrim/src/alt_charger.c create mode 100644 zephyr/program/skyrim/skyrim/src/fan.c create mode 100644 zephyr/program/skyrim/skyrim/src/form_factor.c create mode 100644 zephyr/program/skyrim/skyrim/src/keyboard.c create mode 100644 zephyr/program/skyrim/skyrim/src/ppc_config.c create mode 100644 zephyr/program/skyrim/skyrim/src/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/skyrim_vif.xml delete mode 100644 zephyr/program/skyrim/src/crystaldrift/alt_charger.c delete mode 100644 zephyr/program/skyrim/src/crystaldrift/fan.c delete mode 100644 zephyr/program/skyrim/src/crystaldrift/form_factor.c delete mode 100644 zephyr/program/skyrim/src/crystaldrift/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/src/frostflow/keyboard.c delete mode 100644 zephyr/program/skyrim/src/frostflow/keyboard_customization.c delete mode 100644 zephyr/program/skyrim/src/frostflow/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/frostflow/thermal.c delete mode 100644 zephyr/program/skyrim/src/frostflow/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/src/morthal/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/morthal/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/src/skyrim/alt_charger.c delete mode 100644 zephyr/program/skyrim/src/skyrim/fan.c delete mode 100644 zephyr/program/skyrim/src/skyrim/form_factor.c delete mode 100644 zephyr/program/skyrim/src/skyrim/keyboard.c delete mode 100644 zephyr/program/skyrim/src/skyrim/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/skyrim/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/src/winterhold/battery_present.c delete mode 100644 zephyr/program/skyrim/src/winterhold/kb_backlight.c delete mode 100644 zephyr/program/skyrim/src/winterhold/keyboard.c delete mode 100644 zephyr/program/skyrim/src/winterhold/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/winterhold/sensor.c delete mode 100644 zephyr/program/skyrim/src/winterhold/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/usbc.dts create mode 100644 zephyr/program/skyrim/usbc.dtsi delete mode 100644 zephyr/program/skyrim/winterhold.dts create mode 100644 zephyr/program/skyrim/winterhold/CMakeLists.txt create mode 100644 zephyr/program/skyrim/winterhold/battery.dtsi create mode 100644 zephyr/program/skyrim/winterhold/led_pins.dtsi create mode 100644 zephyr/program/skyrim/winterhold/led_policy.dtsi create mode 100644 zephyr/program/skyrim/winterhold/motionsense.dtsi create mode 100644 zephyr/program/skyrim/winterhold/project.conf create mode 100644 zephyr/program/skyrim/winterhold/project.overlay create mode 100644 zephyr/program/skyrim/winterhold/src/battery_present.c create mode 100644 zephyr/program/skyrim/winterhold/src/kb_backlight.c create mode 100644 zephyr/program/skyrim/winterhold/src/keyboard.c create mode 100644 zephyr/program/skyrim/winterhold/src/ppc_config.c create mode 100644 zephyr/program/skyrim/winterhold/src/sensor.c create mode 100644 zephyr/program/skyrim/winterhold/src/usb_mux_config.c create mode 100644 zephyr/program/skyrim/winterhold/winterhold.dtsi diff --git a/zephyr/program/skyrim/BUILD.py b/zephyr/program/skyrim/BUILD.py index 654c2bf630..08c76c1f13 100644 --- a/zephyr/program/skyrim/BUILD.py +++ b/zephyr/program/skyrim/BUILD.py @@ -7,97 +7,42 @@ def register_skyrim_project( project_name, - extra_dts_overlays=(), - extra_kconfig_files=(), ): """Register a variant of skyrim.""" register_npcx_project( project_name=project_name, zephyr_board="npcx9m3f", dts_overlays=[ + here / project_name / "project.overlay", + ], + kconfig_files=[ # Common to all projects. - here / "adc.dts", - here / "fan.dts", - here / "gpio.dts", - here / "interrupts.dts", - here / "keyboard.dts", - here / "usbc.dts", - # Project-specific DTS customizations. - *extra_dts_overlays, + here / "program.conf", + # Project-specific KConfig customization. + here / project_name / "project.conf", ], - kconfig_files=[here / "prj.conf", *extra_kconfig_files], ) register_skyrim_project( project_name="morthal", - extra_dts_overlays=[ - here / "morthal.dts", - here / "battery_morthal.dts", - here / "led_pins_morthal.dts", - here / "led_policy_morthal.dts", - here / "motionsense_morthal.dts", - ], - extra_kconfig_files=[ - here / "prj_morthal.conf", - ], ) register_skyrim_project( project_name="skyrim", - extra_dts_overlays=[ - here / "skyrim.dts", - here / "battery_skyrim.dts", - here / "led_pins_skyrim.dts", - here / "led_policy_skyrim.dts", - here / "motionsense_skyrim.dts", - ], - extra_kconfig_files=[ - here / "prj_skyrim.conf", - ], ) register_skyrim_project( project_name="winterhold", - extra_dts_overlays=[ - here / "winterhold.dts", - here / "battery_winterhold.dts", - here / "led_pins_winterhold.dts", - here / "led_policy_winterhold.dts", - here / "motionsense_winterhold.dts", - ], - extra_kconfig_files=[ - here / "prj_winterhold.conf", - ], ) register_skyrim_project( project_name="frostflow", - extra_dts_overlays=[ - here / "frostflow.dts", - here / "battery_frostflow.dts", - here / "led_pins_frostflow.dts", - here / "led_policy_frostflow.dts", - here / "motionsense_frostflow.dts", - ], - extra_kconfig_files=[ - here / "prj_frostflow.conf", - ], ) register_skyrim_project( project_name="crystaldrift", - extra_dts_overlays=[ - here / "crystaldrift.dts", - here / "battery_crystaldrift.dts", - here / "led_pins_crystaldrift.dts", - here / "led_policy_crystaldrift.dts", - here / "motionsense_crystaldrift.dts", - ], - extra_kconfig_files=[ - here / "prj_crystaldrift.conf", - ], ) diff --git a/zephyr/program/skyrim/CMakeLists.txt b/zephyr/program/skyrim/CMakeLists.txt index 375099717e..bb1bde51a8 100644 --- a/zephyr/program/skyrim/CMakeLists.txt +++ b/zephyr/program/skyrim/CMakeLists.txt @@ -19,59 +19,25 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_AMD_STT if(DEFINED CONFIG_BOARD_MORTHAL) project(morthal) - zephyr_library_sources( - "src/morthal/ppc_config.c" - "src/morthal/usb_mux_config.c" -) + add_subdirectory(morthal) endif() if(DEFINED CONFIG_BOARD_SKYRIM) project(skyrim) - cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include) - zephyr_library_sources( - "src/skyrim/usb_mux_config.c" - "src/skyrim/ppc_config.c" - "src/skyrim/form_factor.c" - "src/skyrim/alt_charger.c" - "src/skyrim/keyboard.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/skyrim/fan.c") + add_subdirectory(skyrim) endif() if(DEFINED CONFIG_BOARD_WINTERHOLD) project(winterhold) - zephyr_library_sources( - "src/winterhold/usb_mux_config.c" - "src/winterhold/ppc_config.c" - "src/winterhold/kb_backlight.c" - "src/winterhold/keyboard.c" - "src/winterhold/sensor.c" - "src/winterhold/battery_present.c" - ) + add_subdirectory(winterhold) endif() if(DEFINED CONFIG_BOARD_FROSTFLOW) project(frostflow) - cros_ec_library_include_directories_ifdef(CONFIG_BOARD_FROSTFLOW include) - zephyr_include_directories("include/frostflow") - zephyr_library_sources( - "src/frostflow/usb_mux_config.c" - "src/frostflow/ppc_config.c" - "src/frostflow/thermal.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION - "src/frostflow/keyboard.c" - "src/frostflow/keyboard_customization.c") + add_subdirectory(frostflow) endif() if(DEFINED CONFIG_BOARD_CRYSTALDRIFT) project(crystaldrift) - cros_ec_library_include_directories_ifdef(CONFIG_BOARD_CRYSTALDRIFT include) - zephyr_library_sources( - "src/crystaldrift/usb_mux_config.c" - "src/crystaldrift/ppc_config.c" - "src/crystaldrift/form_factor.c" - "src/crystaldrift/alt_charger.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/crystaldrift/fan.c") -endif() \ No newline at end of file + add_subdirectory(crystaldrift) +endif() diff --git a/zephyr/program/skyrim/adc.dts b/zephyr/program/skyrim/adc.dts deleted file mode 100644 index 952e5db1d0..0000000000 --- a/zephyr/program/skyrim/adc.dts +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_temp_charger: temp-charger { - enum-name = "ADC_TEMP_SENSOR_CHARGER"; - io-channels = <&adc0 1>; - }; - adc_temp_memory: temp-memory { - enum-name = "ADC_TEMP_SENSOR_MEMORY"; - io-channels = <&adc0 2>; - }; - adc_core_imon1: core-imon1 { - enum-name = "ADC_CORE_IMON1"; - io-channels = <&adc0 3>; - }; - adc_core_imon2: core-imon2 { - enum-name = "ADC_SOC_IMON2"; - io-channels = <&adc0 4>; - }; - }; - - temp_charger_thermistor: charger-thermistor { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_temp_charger>; - }; - - temp_memory_thermistor: memory-thermistor { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_temp_memory>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - temp_sensor_charger: charger-thermistor { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - sensor = <&temp_charger_thermistor>; - }; - - temp_sensor_memory: memory-thermistor { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&temp_memory_thermistor>; - }; - - temp_sensor_cpu: cpu { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_fan_off = <60>; - temp_fan_max = <90>; - power-good-pin = <&gpio_s0_pgood>; - sensor = <&temp_cpu>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42 - &adc0_chan4_gp41>; - pinctrl-names = "default"; -}; - -&thermistor_3V3_30K9_47K_4050B { - status = "okay"; -}; diff --git a/zephyr/program/skyrim/adc.dtsi b/zephyr/program/skyrim/adc.dtsi new file mode 100644 index 0000000000..952e5db1d0 --- /dev/null +++ b/zephyr/program/skyrim/adc.dtsi @@ -0,0 +1,82 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_temp_charger: temp-charger { + enum-name = "ADC_TEMP_SENSOR_CHARGER"; + io-channels = <&adc0 1>; + }; + adc_temp_memory: temp-memory { + enum-name = "ADC_TEMP_SENSOR_MEMORY"; + io-channels = <&adc0 2>; + }; + adc_core_imon1: core-imon1 { + enum-name = "ADC_CORE_IMON1"; + io-channels = <&adc0 3>; + }; + adc_core_imon2: core-imon2 { + enum-name = "ADC_SOC_IMON2"; + io-channels = <&adc0 4>; + }; + }; + + temp_charger_thermistor: charger-thermistor { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_temp_charger>; + }; + + temp_memory_thermistor: memory-thermistor { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_temp_memory>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + temp_sensor_charger: charger-thermistor { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + sensor = <&temp_charger_thermistor>; + }; + + temp_sensor_memory: memory-thermistor { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&temp_memory_thermistor>; + }; + + temp_sensor_cpu: cpu { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_fan_off = <60>; + temp_fan_max = <90>; + power-good-pin = <&gpio_s0_pgood>; + sensor = <&temp_cpu>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42 + &adc0_chan4_gp41>; + pinctrl-names = "default"; +}; + +&thermistor_3V3_30K9_47K_4050B { + status = "okay"; +}; diff --git a/zephyr/program/skyrim/battery_crystaldrift.dts b/zephyr/program/skyrim/battery_crystaldrift.dts deleted file mode 100644 index 6b1799c233..0000000000 --- a/zephyr/program/skyrim/battery_crystaldrift.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: aec_5477109 { - compatible = "aec,5477109", "battery-smart"; - }; - smp_l20m3pg1 { - compatible = "smp,l20m3pg1", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/battery_frostflow.dts b/zephyr/program/skyrim/battery_frostflow.dts deleted file mode 100644 index 2d6b28de70..0000000000 --- a/zephyr/program/skyrim/battery_frostflow.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: cdt_c340152 { - compatible = "cdt,c340152", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/battery_morthal.dts b/zephyr/program/skyrim/battery_morthal.dts deleted file mode 100644 index 8c87cef7f9..0000000000 --- a/zephyr/program/skyrim/battery_morthal.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: aec_5477109 { - compatible = "aec,5477109", "battery-smart"; - }; - smp_l20m3pg1 { - compatible = "smp,l20m3pg1", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/battery_skyrim.dts b/zephyr/program/skyrim/battery_skyrim.dts deleted file mode 100644 index 8c87cef7f9..0000000000 --- a/zephyr/program/skyrim/battery_skyrim.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: aec_5477109 { - compatible = "aec,5477109", "battery-smart"; - }; - smp_l20m3pg1 { - compatible = "smp,l20m3pg1", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/battery_winterhold.dts b/zephyr/program/skyrim/battery_winterhold.dts deleted file mode 100644 index 8e82e0d1f2..0000000000 --- a/zephyr/program/skyrim/battery_winterhold.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: lgc_xphx8 { - compatible = "lgc,xphx8", "battery-smart"; - }; - smp_atlxdy9k { - compatible = "smp,atlxdy9k", "battery-smart"; - }; - smp_cosxdy9k { - compatible = "smp,cosxdy9k", "battery-smart"; - }; - byd_wv3k8 { - compatible = "byd,wv3k8", "battery-smart"; - }; - cosmx_mvk11 { - compatible = "cosmx,mvk11", "battery-smart"; - }; - sunwoda_atlvkyjx { - compatible = "sunwoda,atlvkyjx", "battery-smart"; - }; - sunwoda_cosvkyjx { - compatible = "sunwoda,cosvkyjx", "battery-smart"; - }; - atl_cfd72 { - compatible = "atl,cfd72", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/crystaldrift.dts b/zephyr/program/skyrim/crystaldrift.dts deleted file mode 100644 index 36e5b58e13..0000000000 --- a/zephyr/program/skyrim/crystaldrift.dts +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Crystaldrift-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <35>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - crystaldrift-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - form-factor { - enum-name = "FW_FORM_FACTOR"; - start = <0>; - size = <1>; - - ff-clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CLAMSHELL"; - value = <0>; - }; - ff-convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CONVERTIBLE"; - value = <1>; - default; - }; - }; - io-db { - enum-name = "FW_IO_DB"; - start = <6>; - size = <2>; - - io-db-ps8811-ps8818 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_PS8811_PS8818"; - value = <0>; - }; - io-db-none-anx7483 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_NONE_ANX7483"; - value = <1>; - default; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <10>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - - charger-option { - enum-name = "FW_CHARGER"; - start = <11>; - size = <2>; - - charger-option-isl9241 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9241"; - value = <0>; - default; - }; - charger-option-isl9538 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9538"; - value = <1>; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - lid_rot_ref1: lid-rotation-ref1 { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - flags = ; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - flags = ; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; - alt_charger: isl9538@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - chg_alt = <&alt_charger>; - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; diff --git a/zephyr/program/skyrim/crystaldrift/CMakeLists.txt b/zephyr/program/skyrim/crystaldrift/CMakeLists.txt new file mode 100644 index 0000000000..6e50c3d40e --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cros_ec_library_include_directories_ifdef(CONFIG_BOARD_CRYSTALDRIFT include) +zephyr_library_sources( + "src/usb_mux_config.c" + "src/ppc_config.c" + "src/form_factor.c" + "src/alt_charger.c" +) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/fan.c") diff --git a/zephyr/program/skyrim/crystaldrift/battery.dtsi b/zephyr/program/skyrim/crystaldrift/battery.dtsi new file mode 100644 index 0000000000..6b1799c233 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi b/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi new file mode 100644 index 0000000000..812f97a7c7 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi @@ -0,0 +1,209 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Crystaldrift-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <35>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + crystaldrift-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + + charger-option { + enum-name = "FW_CHARGER"; + start = <11>; + size = <2>; + + charger-option-isl9241 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9241"; + value = <0>; + default; + }; + charger-option-isl9538 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9538"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + flags = ; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + flags = ; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + alt_charger: isl9538@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + chg_alt = <&alt_charger>; + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift/led_pins.dtsi b/zephyr/program/skyrim/crystaldrift/led_pins.dtsi new file mode 100644 index 0000000000..f778a24a51 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/led_pins.dtsi @@ -0,0 +1,61 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/crystaldrift/led_policy.dtsi b/zephyr/program/skyrim/crystaldrift/led_policy.dtsi new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/led_policy.dtsi @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift/motionsense.dtsi b/zephyr/program/skyrim/crystaldrift/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift/project.conf b/zephyr/program/skyrim/crystaldrift/project.conf new file mode 100644 index 0000000000..e9339c1c3c --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/project.conf @@ -0,0 +1,26 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Crystaldrift reference-board-specific Kconfig settings. +CONFIG_BOARD_CRYSTALDRIFT=y + +# CBI WP pin present +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Crystaldrfit is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable alternative charger chip +CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/crystaldrift/project.overlay b/zephyr/program/skyrim/crystaldrift/project.overlay new file mode 100644 index 0000000000..1192bb0d16 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* Crystaldrift project DTS includes*/ +#include "crystaldrift.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/crystaldrift/src/alt_charger.c b/zephyr/program/skyrim/crystaldrift/src/alt_charger.c new file mode 100644 index 0000000000..a429457136 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/alt_charger.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charger_chips.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "hooks.h" + +#include +#include + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +static void alt_charger_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FW_CHARGER, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); + return; + } + + if (val == FW_CHARGER_ISL9538) + CHG_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/crystaldrift/src/fan.c b/zephyr/program/skyrim/crystaldrift/src/fan.c new file mode 100644 index 0000000000..6645e2a495 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/fan.c @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include +#include +#include + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Skyrim fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + uint32_t board_version; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + + ret = cbi_get_board_version(&board_version); + if (ret != EC_SUCCESS) { + LOG_ERR("Error retrieving CBI board version"); + return; + } + + if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { + /* Disable the fan */ + fan_set_count(0); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); + +/* + * Pcore OCP support + * Note: early boards should note enable this interrupt as they are not + * correctly configured for it. + */ +__override bool board_supports_pcore_ocp(void) +{ + uint32_t board_version; + + if (cbi_get_board_version(&board_version) == EC_SUCCESS && + board_version > 3) + return true; + + return false; +} diff --git a/zephyr/program/skyrim/crystaldrift/src/form_factor.c b/zephyr/program/skyrim/crystaldrift/src/form_factor.c new file mode 100644 index 0000000000..688765617b --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/form_factor.c @@ -0,0 +1,38 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "accelgyro.h" +#include "common.h" +#include "cros_board_info.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +#include +#include + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) +#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + /* + * If the board version >=4 + * use ver1 rotation matrix. + */ + ret = cbi_get_board_version(&val); + if (ret == EC_SUCCESS && val >= 4) { + LOG_INF("Switching to ver1 lid"); + motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/crystaldrift/src/ppc_config.c b/zephyr/program/skyrim/crystaldrift/src/ppc_config.c new file mode 100644 index 0000000000..3913fda4dc --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Crystaldrift board-specific PPC code */ + +#include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c b/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c new file mode 100644 index 0000000000..0e08431360 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Crystaldrift board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/fan.dts b/zephyr/program/skyrim/fan.dts deleted file mode 100644 index dff26bcb29..0000000000 --- a/zephyr/program/skyrim/fan.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan0: fan_0 { - pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - rpm_min = <3100>; - rpm_start = <3100>; - rpm_max = <8000>; - tach = <&tach1>; - pgood_gpio = <&gpio_s0_pgood>; - }; - }; -}; - -/* Tachemeter for fan speed measurement */ -&tach1 { - status = "okay"; - pinctrl-0 = <&ta1_1_in_gp40>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/fan.dtsi b/zephyr/program/skyrim/fan.dtsi new file mode 100644 index 0000000000..dff26bcb29 --- /dev/null +++ b/zephyr/program/skyrim/fan.dtsi @@ -0,0 +1,39 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan0: fan_0 { + pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + rpm_min = <3100>; + rpm_start = <3100>; + rpm_max = <8000>; + tach = <&tach1>; + pgood_gpio = <&gpio_s0_pgood>; + }; + }; +}; + +/* Tachemeter for fan speed measurement */ +&tach1 { + status = "okay"; + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/frostflow.dts b/zephyr/program/skyrim/frostflow.dts deleted file mode 100644 index 5e4a21ae57..0000000000 --- a/zephyr/program/skyrim/frostflow.dts +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Frostflow-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - temp_soc: soc-pct2075 { - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - temp_host_release_halt = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - temp_amb: amb-pct2075 { - temp_host_high = <65>; - temp_host_halt = <70>; - temp_host_release_high = <55>; - temp_host_release_halt = <60>; - temp_fan_off = <32>; - temp_fan_max = <45>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; - - fan_steps_clamshell: fan-steps-clamshell { - compatible = "cros-ec,fan-steps"; - level_0 { - temp_on = <(-1) (-1) (-1) (-1) 31>; - temp_off = <(-1) (-1) (-1) (-1) 99>; - rpm_target = <0>; - }; - level_1 { - temp_on = <(-1) (-1) (-1) (-1) 32>; - temp_off = <(-1) (-1) (-1) (-1) 30>; - rpm_target = <2600>; - }; - level_2 { - temp_on = <(-1) (-1) (-1) (-1) 34>; - temp_off = <(-1) (-1) (-1) (-1) 31>; - rpm_target = <2900>; - }; - level_3 { - temp_on = <(-1) (-1) (-1) (-1) 36>; - temp_off = <(-1) (-1) (-1) (-1) 33>; - rpm_target = <3600>; - }; - level_4 { - temp_on = <(-1) (-1) (-1) (-1) 38>; - temp_off = <(-1) (-1) (-1) (-1) 35>; - rpm_target = <4200>; - }; - level_5 { - temp_on = <(-1) (-1) (-1) (-1) 45>; - temp_off = <(-1) (-1) (-1) (-1) 37>; - rpm_target = <4600>; - }; - }; - - fan_steps_tablet: fan-steps-tablet { - compatible = "cros-ec,fan-steps"; - level_0 { - temp_on = <(-1) (-1) (-1) (-1) 31>; - temp_off = <(-1) (-1) (-1) (-1) 99>; - rpm_target = <0>; - }; - level_1 { - temp_on = <(-1) (-1) (-1) (-1) 32>; - temp_off = <(-1) (-1) (-1) (-1) 30>; - rpm_target = <2600>; - }; - level_2 { - temp_on = <(-1) (-1) (-1) (-1) 34>; - temp_off = <(-1) (-1) (-1) (-1) 31>; - rpm_target = <2900>; - }; - level_3 { - temp_on = <(-1) (-1) (-1) (-1) 36>; - temp_off = <(-1) (-1) (-1) (-1) 33>; - rpm_target = <3600>; - }; - level_4 { - temp_on = <(-1) (-1) (-1) (-1) 38>; - temp_off = <(-1) (-1) (-1) (-1) 35>; - rpm_target = <4200>; - }; - level_5 { - temp_on = <(-1) (-1) (-1) (-1) 45>; - temp_off = <(-1) (-1) (-1) (-1) 37>; - rpm_target = <4600>; - }; - }; -}; - -&i2c1_0 { - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; -}; - -&amd_fp6_port0 { - board-set = "board_c0_amd_fp6_mux_set"; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-ps8818 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - }; -}; - -&cros_kb_raw { - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; -}; - -&temp_sensor_charger { - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - temp_host_release_halt = <70>; -}; - -&temp_sensor_memory { - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - temp_host_release_halt = <70>; -}; - -&temp_sensor_cpu { - /delete-property/ temp_host_high; - /delete-property/ temp_host_halt; - /delete-property/ temp_host_release_high; - /delete-property/ temp_fan_off; - /delete-property/ temp_fan_max; -}; - -&fan0 { - pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - rpm_min = <2400>; - rpm_start = <2600>; - rpm_max = <4600>; -}; diff --git a/zephyr/program/skyrim/frostflow/CMakeLists.txt b/zephyr/program/skyrim/frostflow/CMakeLists.txt new file mode 100644 index 0000000000..dd7eae2384 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cros_ec_library_include_directories_ifdef(CONFIG_BOARD_FROSTFLOW include) +zephyr_include_directories("include") +zephyr_library_sources( + "src/usb_mux_config.c" + "src/ppc_config.c" + "src/thermal.c" +) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION + "src/keyboard.c" + "src/keyboard_customization.c" +) diff --git a/zephyr/program/skyrim/frostflow/battery.dtsi b/zephyr/program/skyrim/frostflow/battery.dtsi new file mode 100644 index 0000000000..2d6b28de70 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/battery.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: cdt_c340152 { + compatible = "cdt,c340152", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/frostflow/frostflow.dtsi b/zephyr/program/skyrim/frostflow/frostflow.dtsi new file mode 100644 index 0000000000..1cadf7ee2d --- /dev/null +++ b/zephyr/program/skyrim/frostflow/frostflow.dtsi @@ -0,0 +1,223 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Frostflow-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + temp_soc: soc-pct2075 { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + temp_amb: amb-pct2075 { + temp_host_high = <65>; + temp_host_halt = <70>; + temp_host_release_high = <55>; + temp_host_release_halt = <60>; + temp_fan_off = <32>; + temp_fan_max = <45>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; + + fan_steps_clamshell: fan-steps-clamshell { + compatible = "cros-ec,fan-steps"; + level_0 { + temp_on = <(-1) (-1) (-1) (-1) 31>; + temp_off = <(-1) (-1) (-1) (-1) 99>; + rpm_target = <0>; + }; + level_1 { + temp_on = <(-1) (-1) (-1) (-1) 32>; + temp_off = <(-1) (-1) (-1) (-1) 30>; + rpm_target = <2600>; + }; + level_2 { + temp_on = <(-1) (-1) (-1) (-1) 34>; + temp_off = <(-1) (-1) (-1) (-1) 31>; + rpm_target = <2900>; + }; + level_3 { + temp_on = <(-1) (-1) (-1) (-1) 36>; + temp_off = <(-1) (-1) (-1) (-1) 33>; + rpm_target = <3600>; + }; + level_4 { + temp_on = <(-1) (-1) (-1) (-1) 38>; + temp_off = <(-1) (-1) (-1) (-1) 35>; + rpm_target = <4200>; + }; + level_5 { + temp_on = <(-1) (-1) (-1) (-1) 45>; + temp_off = <(-1) (-1) (-1) (-1) 37>; + rpm_target = <4600>; + }; + }; + + fan_steps_tablet: fan-steps-tablet { + compatible = "cros-ec,fan-steps"; + level_0 { + temp_on = <(-1) (-1) (-1) (-1) 31>; + temp_off = <(-1) (-1) (-1) (-1) 99>; + rpm_target = <0>; + }; + level_1 { + temp_on = <(-1) (-1) (-1) (-1) 32>; + temp_off = <(-1) (-1) (-1) (-1) 30>; + rpm_target = <2600>; + }; + level_2 { + temp_on = <(-1) (-1) (-1) (-1) 34>; + temp_off = <(-1) (-1) (-1) (-1) 31>; + rpm_target = <2900>; + }; + level_3 { + temp_on = <(-1) (-1) (-1) (-1) 36>; + temp_off = <(-1) (-1) (-1) (-1) 33>; + rpm_target = <3600>; + }; + level_4 { + temp_on = <(-1) (-1) (-1) (-1) 38>; + temp_off = <(-1) (-1) (-1) (-1) 35>; + rpm_target = <4200>; + }; + level_5 { + temp_on = <(-1) (-1) (-1) (-1) 45>; + temp_off = <(-1) (-1) (-1) (-1) 37>; + rpm_target = <4600>; + }; + }; +}; + +&i2c1_0 { + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; +}; + +&amd_fp6_port0 { + board-set = "board_c0_amd_fp6_mux_set"; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-ps8818 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + }; +}; + +&cros_kb_raw { + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; +}; + +&temp_sensor_charger { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; +}; + +&temp_sensor_memory { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; +}; + +&temp_sensor_cpu { + /delete-property/ temp_host_high; + /delete-property/ temp_host_halt; + /delete-property/ temp_host_release_high; + /delete-property/ temp_fan_off; + /delete-property/ temp_fan_max; +}; + +&fan0 { + pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + rpm_min = <2400>; + rpm_start = <2600>; + rpm_max = <4600>; +}; diff --git a/zephyr/program/skyrim/frostflow/include/keyboard_customization.h b/zephyr/program/skyrim/frostflow/include/keyboard_customization.h new file mode 100644 index 0000000000..2d2a997f91 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/include/keyboard_customization.h @@ -0,0 +1,78 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Keyboard configuration */ + +#ifndef __KEYBOARD_CUSTOMIZATION_H +#define __KEYBOARD_CUSTOMIZATION_H + +/* + * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate + * exact spaces for arrays. Actual keyboard scanning is done using + * keyboard_cols, which holds a runtime column size. + */ +#ifdef CONFIG_KEYBOARD_CUSTOMIZATION +#undef KEYBOARD_COLS_MAX +#undef KEYBOARD_ROWS + +#define KEYBOARD_COLS_MAX 15 +#define KEYBOARD_ROWS 8 +#endif + +/* + * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols, + * instead. It checks whether you're eligible or not. + */ +extern uint8_t keyboard_cols; + +#define KEYBOARD_ROW_TO_MASK(r) (1 << (r)) + +/* Columns and masks for keys we particularly care about */ +#define KEYBOARD_COL_DOWN 11 +#define KEYBOARD_ROW_DOWN 5 +#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN) +#define KEYBOARD_COL_ESC 1 +#define KEYBOARD_ROW_ESC 1 +#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC) +#define KEYBOARD_COL_KEY_H 6 +#define KEYBOARD_ROW_KEY_H 1 +#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H) +#define KEYBOARD_COL_KEY_R 3 +#define KEYBOARD_ROW_KEY_R 7 +#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R) +#define KEYBOARD_COL_LEFT_ALT 10 +#define KEYBOARD_ROW_LEFT_ALT 6 +#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT) +#define KEYBOARD_COL_REFRESH 2 +#define KEYBOARD_ROW_REFRESH 3 +#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH) +#define KEYBOARD_COL_RIGHT_ALT 10 +#define KEYBOARD_ROW_RIGHT_ALT 0 +#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT) +#define KEYBOARD_DEFAULT_COL_VOL_UP 4 +#define KEYBOARD_DEFAULT_ROW_VOL_UP 1 +#define KEYBOARD_COL_LEFT_CTRL 0 +#define KEYBOARD_ROW_LEFT_CTRL 2 +#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL) +#define KEYBOARD_COL_RIGHT_CTRL 0 +#define KEYBOARD_ROW_RIGHT_CTRL 4 +#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL) +#define KEYBOARD_COL_SEARCH 0 +#define KEYBOARD_ROW_SEARCH 3 +#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH) +#define KEYBOARD_COL_KEY_0 9 +#define KEYBOARD_ROW_KEY_0 0 +#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) +#define KEYBOARD_COL_KEY_1 1 +#define KEYBOARD_ROW_KEY_1 7 +#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1) +#define KEYBOARD_COL_KEY_2 4 +#define KEYBOARD_ROW_KEY_2 6 +#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) +#define KEYBOARD_COL_LEFT_SHIFT 7 +#define KEYBOARD_ROW_LEFT_SHIFT 1 +#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT) + +#endif /* __KEYBOARD_CUSTOMIZATION_H */ diff --git a/zephyr/program/skyrim/frostflow/led_pins.dtsi b/zephyr/program/skyrim/frostflow/led_pins.dtsi new file mode 100644 index 0000000000..78b9a59c40 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/led_pins.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/frostflow/led_policy.dtsi b/zephyr/program/skyrim/frostflow/led_policy.dtsi new file mode 100644 index 0000000000..e5875640fb --- /dev/null +++ b/zephyr/program/skyrim/frostflow/led_policy.dtsi @@ -0,0 +1,122 @@ +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = <0 94>; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-charge-lvl-2 { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Near Full) */ + batt-lvl = <95 97>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <11 100>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= 10%) */ + batt-lvl = <0 10>; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error-s0 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + /* White 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/frostflow/motionsense.dtsi b/zephyr/program/skyrim/frostflow/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/frostflow/project.conf b/zephyr/program/skyrim/frostflow/project.conf new file mode 100644 index 0000000000..02da02d35d --- /dev/null +++ b/zephyr/program/skyrim/frostflow/project.conf @@ -0,0 +1,33 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Frostflow reference-board-specific Kconfig settings. +CONFIG_BOARD_FROSTFLOW=y +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10 + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Frostflow is capable of sinking 45W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000 + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y + +# Frostflow not have the USB HUB +CONFIG_BOARD_USB_HUB_RESET=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y + +# Fan +CONFIG_PLATFORM_EC_FAN=y +CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y diff --git a/zephyr/program/skyrim/frostflow/project.overlay b/zephyr/program/skyrim/frostflow/project.overlay new file mode 100644 index 0000000000..a1bc7dbb5e --- /dev/null +++ b/zephyr/program/skyrim/frostflow/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* Frostflow project DTS includes*/ +#include "frostflow.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/frostflow/src/keyboard.c b/zephyr/program/skyrim/frostflow/src/keyboard.c new file mode 100644 index 0000000000..2905f17941 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/keyboard.c @@ -0,0 +1,74 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" +#include "keyboard_scan.h" +#include "timer.h" + +/* Keyboard scan setting */ +__override struct keyboard_scan_config keyscan_config = { + /* Increase from 50 us, because KSO_02 passes through the H1. */ + .output_settle_us = 80, + /* Other values should be the same as the default configuration. */ + .debounce_down_us = 9 * MSEC, + .debounce_up_us = 30 * MSEC, + .scan_period_us = 3 * MSEC, + .min_post_scan_delay_us = 1000, + .poll_timeout_us = 100 * MSEC, + .actual_key_mask = { + 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x86, 0xff, 0xff, 0x55, 0xff, 0xff, 0xff, 0xff, /* full set */ + }, +}; + +static const struct ec_response_keybd_config frostflow_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &frostflow_kb; +} + +/* + * Row Column info for Top row keys T1 - T15. + * on frostflow_kb keyboard Row Column is customization + * need define row col to mapping matrix layout. + */ +__override const struct key { + uint8_t row; + uint8_t col; +} vivaldi_keys[] = { + { .row = 4, .col = 2 }, /* T1 */ + { .row = 3, .col = 2 }, /* T2 */ + { .row = 2, .col = 2 }, /* T3 */ + { .row = 1, .col = 2 }, /* T4 */ + { .row = 4, .col = 4 }, /* T5 */ + { .row = 3, .col = 4 }, /* T6 */ + { .row = 2, .col = 4 }, /* T7 */ + { .row = 2, .col = 9 }, /* T8 */ + { .row = 1, .col = 9 }, /* T9 */ + { .row = 1, .col = 4 }, /* T10 */ + { .row = 0, .col = 4 }, /* T11 */ + { .row = 1, .col = 5 }, /* T12 */ + { .row = 3, .col = 5 }, /* T13 */ + { .row = 2, .col = 1 }, /* T14 */ + { .row = 0, .col = 1 }, /* T15 */ +}; +BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS); diff --git a/zephyr/program/skyrim/frostflow/src/keyboard_customization.c b/zephyr/program/skyrim/frostflow/src/keyboard_customization.c new file mode 100644 index 0000000000..bd02940e03 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/keyboard_customization.c @@ -0,0 +1,85 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "gpio.h" +#include "keyboard_customization.h" +#include "keyboard_protocol.h" +#include "keyboard_raw.h" + +#include + +static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { + { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 }, + { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 }, + { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a }, + { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d }, + { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d }, + { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 }, + { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c }, + { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 }, + { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d }, + { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a }, + { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 }, + { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 }, + { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d }, + { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 }, + { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 }, +}; + +uint16_t get_scancode_set2(uint8_t row, uint8_t col) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + return scancode_set2[col][row]; + return 0; +} + +void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + scancode_set2[col][row] = val; +} + +#ifdef CONFIG_KEYBOARD_DEBUG +static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { + { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO }, + { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' }, + { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3, + KLLI_UNKNO }, + { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC }, + { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' }, + { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' }, + { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' }, + { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' }, + { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO, + KLLI_LEFT, KLLI_UNKNO }, + { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' }, + { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' }, + { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO }, +}; + +char get_keycap_label(uint8_t row, uint8_t col) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + return keycap_label[col][row]; + return KLLI_UNKNO; +} + +void set_keycap_label(uint8_t row, uint8_t col, char val) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + keycap_label[col][row] = val; +} +#endif diff --git a/zephyr/program/skyrim/frostflow/src/ppc_config.c b/zephyr/program/skyrim/frostflow/src/ppc_config.c new file mode 100644 index 0000000000..513c025dec --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Frostflow board-specific PPC code */ + +#include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/frostflow/src/thermal.c b/zephyr/program/skyrim/frostflow/src/thermal.c new file mode 100644 index 0000000000..eae8aac25d --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/thermal.c @@ -0,0 +1,109 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "chipset.h" +#include "fan.h" +#include "tablet_mode.h" +#include "temp_sensor/temp_sensor.h" +#include "thermal.h" +#include "util.h" +#include "console.h" + +#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_amb)) + +struct fan_step { + /* + * Sensor 0~4 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int on[TEMP_SENSOR_COUNT]; + /* + * Sensor 0~4 release point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int off[TEMP_SENSOR_COUNT]; + /* Fan rpm */ + uint16_t rpm[FAN_CH_COUNT]; +}; + +#define FAN_TABLE_ENTRY(nd) \ + { \ + .on = DT_PROP(nd, temp_on), \ + .off = DT_PROP(nd, temp_off), \ + .rpm = DT_PROP(nd, rpm_target), \ + }, + +static const struct fan_step fan_table_clamshell[] = { DT_FOREACH_CHILD( + DT_NODELABEL(fan_steps_clamshell), FAN_TABLE_ENTRY) }; + +static const struct fan_step fan_table_tablet[] = { DT_FOREACH_CHILD( + DT_NODELABEL(fan_steps_tablet), FAN_TABLE_ENTRY) }; + +static const struct fan_step *fan_step_table; +#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table_clamshell) + +BUILD_ASSERT(ARRAY_SIZE(fan_table_clamshell) == ARRAY_SIZE(fan_table_tablet)); + +int fan_table_to_rpm(int fan, int *temp) +{ + /* current fan level */ + static int current_level; + /* previous sensor temperature */ + static int prev_tmp[TEMP_SENSOR_COUNT]; + int i; + + if (tablet_get_mode()) + fan_step_table = fan_table_tablet; + else + fan_step_table = fan_table_clamshell; + + /* + * Compare the current and previous temperature, we have + * the three paths : + * 1. decreasing path. (check the release point) + * 2. increasing path. (check the trigger point) + * 3. invariant path. (return the current RPM) + */ + + if (temp[TEMP_AMB] < prev_tmp[TEMP_AMB]) { + for (i = current_level; i > 0; i--) { + if (temp[TEMP_AMB] < fan_step_table[i].off[TEMP_AMB]) + current_level = i - 1; + else + break; + } + } else if (temp[TEMP_AMB] > prev_tmp[TEMP_AMB]) { + for (i = current_level; i < NUM_FAN_LEVELS; i++) { + if (temp[TEMP_AMB] > fan_step_table[i].on[TEMP_AMB]) + current_level = i + 1; + else + break; + } + } + + if (current_level < 0) + current_level = 0; + + if (current_level >= NUM_FAN_LEVELS) + current_level = NUM_FAN_LEVELS - 1; + + for (i = 0; i < TEMP_SENSOR_COUNT; ++i) + prev_tmp[i] = temp[i]; + + return fan_step_table[current_level].rpm[fan]; +} + +void board_override_fan_control(int fan, int *temp) +{ + /* + * In common/fan.c pwm_fan_stop() will turn off fan + * when chipset suspend or shutdown. + */ + if (chipset_in_state(CHIPSET_STATE_ON)) { + fan_set_rpm_mode(fan, 1); + fan_set_rpm_target(fan, fan_table_to_rpm(fan, temp)); + } +} diff --git a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c new file mode 100644 index 0000000000..2ec1dda0be --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Frostflow board-specific USB-C mux configuration */ + +#include "ioexpander.h" +#include "usbc/usb_muxes.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ps8815 DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_c0_amd_fp6_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} diff --git a/zephyr/program/skyrim/gpio.dts b/zephyr/program/skyrim/gpio.dts deleted file mode 100644 index 2b79bad222..0000000000 --- a/zephyr/program/skyrim/gpio.dts +++ /dev/null @@ -1,370 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_wp; - gpio-cbi-wp = &gpio_cbi_wp; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - /* GPIOs shared by all boards */ - named-gpios { - compatible = "named-gpios"; - - ccd_mode_odl { - gpios = <&gpioc 6 GPIO_ODR_HIGH>; - }; - ec_gsc_packet_mode { - gpios = <&gpiob 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_mech_pwr_btn_odl: mech_pwr_btn_odl { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpio6 1 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S3_L"; - alias = "GPIO_PCH_SLP_S0_L"; - }; - gpio_slp_s5_l: slp_s5_l { - gpios = <&gpio7 2 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S5_L"; - }; - gpio_pg_pwr_s5: pg_pwr_s5 { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_S5_PGOOD"; - }; - gpio_s0_pgood: pg_pcore_s0_r_od { - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_S0_PGOOD"; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_en_pwr_s5: en_pwr_s5 { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PWR_A"; - }; - gpio_en_pwr_s0_r: en_pwr_s0_r { - gpios = <&gpiof 1 GPIO_OUTPUT_LOW>; - }; - gpio_en_pwr_pcore_s0_r: en_pwr_pcore_s0_r { - gpios = <&gpioe 1 GPIO_OUTPUT_LOW>; - }; - ec_sys_rst_l { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_SYS_RESET_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_RSMRST_L"; - }; - gpio_ec_pch_wake_odl: ec_soc_wake_l { - gpios = <&gpio0 3 GPIO_OUTPUT_HIGH>; - }; - prochot_odl { - gpios = <&gpiod 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_CPU_PROCHOT"; - }; - soc_alert_ec_l { - gpios = <&gpioe 2 GPIO_INPUT>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioc 7 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio7 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { - gpios = <&gpiod 4 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PPC_INT_ODL"; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpioa 4 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { - gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_USB_C1_BC12_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst_l: usb_c0_tcpc_rst_l { - gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_USB_C0_TCPC_RST_L"; - }; - gpio_usb_c1_tcpc_rst_l: usb_c1_tcpc_rst_l { - gpios = <&gpio3 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_USB_C1_TCPC_RST_L"; - }; - usb_c0_hpd { - gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_DP_HPD"; - }; - usb_c1_hpd { - gpios = <&gpiof 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_DP_HPD"; - }; - gpio_lid_open: lid_open { - gpios = <&gpio0 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_disable_disp_bl: ec_disable_disp_bl { - gpios = <&gpioa 6 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT_L"; - }; - gpio_usb_fault_odl: usb_fault_odl { - gpios = <&gpio5 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - gpio_en_pwr_s3: en_pwr_s3 { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_pg_groupc_s0_od: pg_groupc_s0_od { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_ec_i2c_usbc_pd_int: ec_i2c_usbc_pd_int { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_soc_thermtrip_odl: soc_thermtrip_odl { - gpios = <&gpio9 5 GPIO_INPUT>; - }; - gpio_hub_rst: hub_rst { - gpios = <&gpio6 6 GPIO_OUTPUT_HIGH>; - }; - ec_soc_int_l { - gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pwr_good: ec_soc_pwr_good { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - }; - gpio_pcore_ocp_r_l: pcore_ocp_r_l { - gpios = <&gpioa 5 GPIO_INPUT>; - }; - gpio_usb_hub_fault_q_odl: usb_hub_fault_q_odl { - gpios = <&gpioe 5 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_lpddr5_s3_od: pg_lpddr5_s3_od { - gpios = <&gpio7 3 GPIO_INPUT>; - }; - 3axis_int_l { - gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; - }; - gpio_ec_soc_pwr_btn_l: ec_soc_pwr_btn_l { - gpios = <&gpioa 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpio6 7 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - ec_sc_rst { - gpios = <&gpiob 0 GPIO_OUTPUT_LOW>; - }; - gpio_cbi_wp: ec_cbi_wp { - gpios = <&gpio8 1 GPIO_OUTPUT_LOW>; - }; - gpio_wp: ec_wp_l { - gpios = <&gpiod 7 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_pg_lpddr5_s0_od: pg_lpddr5_s0_od { - gpios = <&gpio6 0 GPIO_INPUT>; - }; - ec_espi_rst_l { - gpios = <&gpio5 4 GPIO_PULL_DOWN>; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - pch-sys-prwok { - enum-name = "GPIO_PCH_SYS_PWROK"; - }; - ec_i2c_usb_a0_c0_scl { - gpios = <&gpiob 5 GPIO_INPUT>; - }; - ec_i2c_usb_a0_c0_sda { - gpios = <&gpiob 4 GPIO_INPUT>; - }; - ec_i2c_usb_a1_c1_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_a1_c1_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_batt_scl { - gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_batt_sda { - gpios = <&gpio9 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_usbc_mux_scl { - gpios = <&gpiod 1 GPIO_INPUT>; - }; - ec_i2c_usbc_mux_sda { - gpios = <&gpiod 0 GPIO_INPUT>; - }; - ec_i2c_power_scl { - gpios = <&gpiof 3 GPIO_INPUT>; - }; - ec_i2c_power_sda { - gpios = <&gpiof 2 GPIO_INPUT>; - }; - ec_i2c_cbi_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_cbi_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - ec_i2c_sensor_scl { - gpios = <&gpioe 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_sensor_sda { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_soc_sic { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_soc_sid { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - en_kb_bl { - gpios = <&gpio9 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - tablet_mode_l { - gpios = <&gpioc 1 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ec_gpio56 { - gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>; - }; - ec_flprg2 { - gpios = <&gpio8 6 GPIO_INPUT_PULL_UP>; - }; - - usb_c0_tcpc_fastsw_ctl_en { - gpios = <&ioex_c0_port0 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN"; - }; - usb_c0_ppc_en_l { - gpios = <&ioex_c0_port1 0 GPIO_OUTPUT_LOW>; - }; - ioex_usb_c0_ilim_3a_en: usb_c0_ppc_ilim_3a_en { - gpios = <&ioex_c0_port1 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_PPC_ILIM_3A_EN"; - }; - ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl { - gpios = <&ioex_c0_port1 2 GPIO_INPUT>; - }; - ioex_en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&ioex_c0_port1 5 GPIO_OUTPUT_LOW>; - }; - ioex_usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&ioex_c0_port1 6 GPIO_INPUT>; - }; - ioex_usb_c0_sbu_flip: usb_c0_sbu_flip { - gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_SBU_FLIP"; - }; - - usb_a1_retimer_en { - gpios = <&ioex_c1_port0 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_A1_RETIMER_EN"; - }; - usb_a1_retimer_rst { - gpios = <&ioex_c1_port0 1 GPIO_OUTPUT_LOW>; - }; - usb_c1_in_hpd { - gpios = <&ioex_c1_port0 3 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_HPD_IN_DB"; - }; - usb_c1_tcpc_fastsw_ctl_en { - gpios = <&ioex_c1_port0 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN"; - }; - usb_c1_ppc_en_l { - gpios = <&ioex_c1_port1 0 GPIO_OUTPUT_LOW>; - }; - usb_c1_ppc_ilim_3a_en { - gpios = <&ioex_c1_port1 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_PPC_ILIM_3A_EN"; - }; - ioex_usb_c1_sbu_fault_odl: usb_c1_sbu_fault_odl { - gpios = <&ioex_c1_port1 2 GPIO_INPUT>; - enum-name = "IOEX_USB_C1_FAULT_ODL"; - }; - ioex_en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus { - gpios = <&ioex_c1_port1 5 GPIO_OUTPUT_LOW>; - }; - ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl { - gpios = <&ioex_c1_port1 6 GPIO_INPUT>; - }; - ioex_usb_c1_sbu_flip: usb_c1_sbu_flip { - gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_SBU_FLIP"; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&ioex_en_pp5000_usb_a0_vbus - &ioex_en_pp5000_usb_a1_vbus>; - }; -}; - -/* PSL input pads*/ -&psl_in1_gpd2 { - /* MECH_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in2_gp00 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* LID_OPEN */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>; -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/gpio.dtsi b/zephyr/program/skyrim/gpio.dtsi new file mode 100644 index 0000000000..2b79bad222 --- /dev/null +++ b/zephyr/program/skyrim/gpio.dtsi @@ -0,0 +1,370 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_wp; + gpio-cbi-wp = &gpio_cbi_wp; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + /* GPIOs shared by all boards */ + named-gpios { + compatible = "named-gpios"; + + ccd_mode_odl { + gpios = <&gpioc 6 GPIO_ODR_HIGH>; + }; + ec_gsc_packet_mode { + gpios = <&gpiob 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_mech_pwr_btn_odl: mech_pwr_btn_odl { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpio6 1 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S3_L"; + alias = "GPIO_PCH_SLP_S0_L"; + }; + gpio_slp_s5_l: slp_s5_l { + gpios = <&gpio7 2 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S5_L"; + }; + gpio_pg_pwr_s5: pg_pwr_s5 { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_S5_PGOOD"; + }; + gpio_s0_pgood: pg_pcore_s0_r_od { + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_S0_PGOOD"; + }; + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_en_pwr_s5: en_pwr_s5 { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PWR_A"; + }; + gpio_en_pwr_s0_r: en_pwr_s0_r { + gpios = <&gpiof 1 GPIO_OUTPUT_LOW>; + }; + gpio_en_pwr_pcore_s0_r: en_pwr_pcore_s0_r { + gpios = <&gpioe 1 GPIO_OUTPUT_LOW>; + }; + ec_sys_rst_l { + gpios = <&gpio7 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_SYS_RESET_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_RSMRST_L"; + }; + gpio_ec_pch_wake_odl: ec_soc_wake_l { + gpios = <&gpio0 3 GPIO_OUTPUT_HIGH>; + }; + prochot_odl { + gpios = <&gpiod 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_CPU_PROCHOT"; + }; + soc_alert_ec_l { + gpios = <&gpioe 2 GPIO_INPUT>; + }; + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpioc 7 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio7 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { + gpios = <&gpiod 4 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PPC_INT_ODL"; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpioa 4 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { + gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_USB_C1_BC12_INT_ODL"; + }; + gpio_usb_c0_tcpc_rst_l: usb_c0_tcpc_rst_l { + gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_USB_C0_TCPC_RST_L"; + }; + gpio_usb_c1_tcpc_rst_l: usb_c1_tcpc_rst_l { + gpios = <&gpio3 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_USB_C1_TCPC_RST_L"; + }; + usb_c0_hpd { + gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_DP_HPD"; + }; + usb_c1_hpd { + gpios = <&gpiof 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_DP_HPD"; + }; + gpio_lid_open: lid_open { + gpios = <&gpio0 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_disable_disp_bl: ec_disable_disp_bl { + gpios = <&gpioa 6 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT_L"; + }; + gpio_usb_fault_odl: usb_fault_odl { + gpios = <&gpio5 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + gpio_en_pwr_s3: en_pwr_s3 { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_pg_groupc_s0_od: pg_groupc_s0_od { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_ec_i2c_usbc_pd_int: ec_i2c_usbc_pd_int { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_soc_thermtrip_odl: soc_thermtrip_odl { + gpios = <&gpio9 5 GPIO_INPUT>; + }; + gpio_hub_rst: hub_rst { + gpios = <&gpio6 6 GPIO_OUTPUT_HIGH>; + }; + ec_soc_int_l { + gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pwr_good: ec_soc_pwr_good { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + }; + gpio_pcore_ocp_r_l: pcore_ocp_r_l { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + gpio_usb_hub_fault_q_odl: usb_hub_fault_q_odl { + gpios = <&gpioe 5 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_lpddr5_s3_od: pg_lpddr5_s3_od { + gpios = <&gpio7 3 GPIO_INPUT>; + }; + 3axis_int_l { + gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; + }; + gpio_ec_soc_pwr_btn_l: ec_soc_pwr_btn_l { + gpios = <&gpioa 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpio6 7 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + ec_sc_rst { + gpios = <&gpiob 0 GPIO_OUTPUT_LOW>; + }; + gpio_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 1 GPIO_OUTPUT_LOW>; + }; + gpio_wp: ec_wp_l { + gpios = <&gpiod 7 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_pg_lpddr5_s0_od: pg_lpddr5_s0_od { + gpios = <&gpio6 0 GPIO_INPUT>; + }; + ec_espi_rst_l { + gpios = <&gpio5 4 GPIO_PULL_DOWN>; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + pch-sys-prwok { + enum-name = "GPIO_PCH_SYS_PWROK"; + }; + ec_i2c_usb_a0_c0_scl { + gpios = <&gpiob 5 GPIO_INPUT>; + }; + ec_i2c_usb_a0_c0_sda { + gpios = <&gpiob 4 GPIO_INPUT>; + }; + ec_i2c_usb_a1_c1_scl { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + ec_i2c_usb_a1_c1_sda { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + ec_i2c_batt_scl { + gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_batt_sda { + gpios = <&gpio9 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_usbc_mux_scl { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + ec_i2c_usbc_mux_sda { + gpios = <&gpiod 0 GPIO_INPUT>; + }; + ec_i2c_power_scl { + gpios = <&gpiof 3 GPIO_INPUT>; + }; + ec_i2c_power_sda { + gpios = <&gpiof 2 GPIO_INPUT>; + }; + ec_i2c_cbi_scl { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + ec_i2c_cbi_sda { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + ec_i2c_sensor_scl { + gpios = <&gpioe 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_sensor_sda { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_soc_sic { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_soc_sid { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + en_kb_bl { + gpios = <&gpio9 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + tablet_mode_l { + gpios = <&gpioc 1 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ec_gpio56 { + gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>; + }; + ec_flprg2 { + gpios = <&gpio8 6 GPIO_INPUT_PULL_UP>; + }; + + usb_c0_tcpc_fastsw_ctl_en { + gpios = <&ioex_c0_port0 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN"; + }; + usb_c0_ppc_en_l { + gpios = <&ioex_c0_port1 0 GPIO_OUTPUT_LOW>; + }; + ioex_usb_c0_ilim_3a_en: usb_c0_ppc_ilim_3a_en { + gpios = <&ioex_c0_port1 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_PPC_ILIM_3A_EN"; + }; + ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl { + gpios = <&ioex_c0_port1 2 GPIO_INPUT>; + }; + ioex_en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&ioex_c0_port1 5 GPIO_OUTPUT_LOW>; + }; + ioex_usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&ioex_c0_port1 6 GPIO_INPUT>; + }; + ioex_usb_c0_sbu_flip: usb_c0_sbu_flip { + gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_SBU_FLIP"; + }; + + usb_a1_retimer_en { + gpios = <&ioex_c1_port0 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_A1_RETIMER_EN"; + }; + usb_a1_retimer_rst { + gpios = <&ioex_c1_port0 1 GPIO_OUTPUT_LOW>; + }; + usb_c1_in_hpd { + gpios = <&ioex_c1_port0 3 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_HPD_IN_DB"; + }; + usb_c1_tcpc_fastsw_ctl_en { + gpios = <&ioex_c1_port0 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN"; + }; + usb_c1_ppc_en_l { + gpios = <&ioex_c1_port1 0 GPIO_OUTPUT_LOW>; + }; + usb_c1_ppc_ilim_3a_en { + gpios = <&ioex_c1_port1 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_PPC_ILIM_3A_EN"; + }; + ioex_usb_c1_sbu_fault_odl: usb_c1_sbu_fault_odl { + gpios = <&ioex_c1_port1 2 GPIO_INPUT>; + enum-name = "IOEX_USB_C1_FAULT_ODL"; + }; + ioex_en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus { + gpios = <&ioex_c1_port1 5 GPIO_OUTPUT_LOW>; + }; + ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl { + gpios = <&ioex_c1_port1 6 GPIO_INPUT>; + }; + ioex_usb_c1_sbu_flip: usb_c1_sbu_flip { + gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_SBU_FLIP"; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&ioex_en_pp5000_usb_a0_vbus + &ioex_en_pp5000_usb_a1_vbus>; + }; +}; + +/* PSL input pads*/ +&psl_in1_gpd2 { + /* MECH_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in2_gp00 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* LID_OPEN */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>; +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/i2c.dtsi b/zephyr/program/skyrim/i2c.dtsi new file mode 100644 index 0000000000..460a6bcfd2 --- /dev/null +++ b/zephyr/program/skyrim/i2c.dtsi @@ -0,0 +1,294 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + #include + +/ { + aliases { + i2c-0 = &i2c0_0; + i2c-1 = &i2c1_0; + i2c-2 = &i2c2_0; + i2c-3 = &i2c3_0; + i2c-4 = &i2c4_1; + i2c-5 = &i2c5_0; + i2c-7 = &i2c7_0; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_tcpc0: tcpc0 { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_TCPC0"; + }; + + i2c_tcpc1: tcpc1 { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_TCPC1"; + }; + + battery { + i2c-port = <&i2c2_0>; + remote-port = <0>; + enum-names = "I2C_PORT_BATTERY"; + }; + + usb-mux { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_MUX"; + }; + + i2c_charger: charger { + i2c-port = <&i2c4_1>; + enum-names = "I2C_PORT_CHARGER"; + }; + + eeprom { + i2c-port = <&i2c5_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + + i2c_sensor: sensor { + i2c-port = <&i2c6_1>; + enum-names = "I2C_PORT_SENSOR"; + }; + + i2c_soc_thermal: soc-thermal { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_THERMAL_AP"; + }; + }; + + +}; + +&i2c0_0 { + status = "okay"; + label = "I2C_TCPC0"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + tcpc_port0: nct38xx@70 { + compatible = "nuvoton,nct38xx"; + reg = <0x70>; + gpio-dev = <&nct3807_C0>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct3807_C0: nct3807_C0@70 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x70>; + label = "NCT3807_C0"; + + ioex_c0_port0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3807_C0_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + pinmux_mask = <0xf7>; + }; + ioex_c0_port1: gpio@1 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x1>; + label = "NCT3807_C0_GPIO1"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + }; + }; + + nct3808_alert_0 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct3807_C0>; + label = "NCT3807_ALERT_0"; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + status = "okay"; + label = "I2C_TCPC1"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c1_bc12>; + }; + + tcpc_port1: nct38xx@70 { + compatible = "nuvoton,nct38xx"; + reg = <0x70>; + gpio-dev = <&nct3807_C1>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct3807_C1: nct3807_C1@70 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x70>; + label = "NCT3807_C1"; + + ioex_c1_port0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3807_C1_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + pinmux_mask = <0xf7>; + }; + ioex_c1_port1: gpio@1 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x1>; + label = "NCT3807_C1_GPIO1"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + }; + }; + + nct3808_alert_1 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpioc 7 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct3807_C1>; + label = "NCT3807_ALERT_1"; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + status = "okay"; + label = "I2C_BATTERY"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + status = "okay"; + label = "I2C_USB_MUX"; + clock-frequency = ; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; + + amd_fp6_port0: amd_fp6@5c { + compatible = "amd,usbc-mux-amd-fp6"; + status = "okay"; + reg = <0x5c>; + }; + amd_fp6_port1: amd_fp6@52 { + compatible = "amd,usbc-mux-amd-fp6"; + status = "okay"; + reg = <0x52>; + }; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c4_1 { + status = "okay"; + label = "I2C_CHARGER"; + clock-frequency = ; + pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl4 { + status = "okay"; +}; + +&i2c5_0 { + status = "okay"; + label = "I2C_EEPROM"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c6_1 { + status = "okay"; + label = "I2C_SENSOR"; + clock-frequency = ; + pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; + pinctrl-names = "default"; + + soc_pct2075: soc-pct2075@48 { + compatible = "nxp,pct2075"; + reg = <0x48>; + }; + + amb_pct2075: amb-pct2075@4f { + compatible = "nxp,pct2075"; + reg = <0x4f>; + }; +}; + +&i2c_ctrl6 { + status = "okay"; +}; + +&i2c7_0 { + status = "okay"; + label = "I2C_THERMAL_AP"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; + + temp_cpu: cpu@4c { + compatible = "amd,sb-tsi"; + reg = <0x4c>; + }; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/skyrim/i2c_common.dtsi b/zephyr/program/skyrim/i2c_common.dtsi deleted file mode 100644 index 460a6bcfd2..0000000000 --- a/zephyr/program/skyrim/i2c_common.dtsi +++ /dev/null @@ -1,294 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #include - -/ { - aliases { - i2c-0 = &i2c0_0; - i2c-1 = &i2c1_0; - i2c-2 = &i2c2_0; - i2c-3 = &i2c3_0; - i2c-4 = &i2c4_1; - i2c-5 = &i2c5_0; - i2c-7 = &i2c7_0; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_tcpc0: tcpc0 { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_TCPC0"; - }; - - i2c_tcpc1: tcpc1 { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_TCPC1"; - }; - - battery { - i2c-port = <&i2c2_0>; - remote-port = <0>; - enum-names = "I2C_PORT_BATTERY"; - }; - - usb-mux { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_MUX"; - }; - - i2c_charger: charger { - i2c-port = <&i2c4_1>; - enum-names = "I2C_PORT_CHARGER"; - }; - - eeprom { - i2c-port = <&i2c5_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - - i2c_sensor: sensor { - i2c-port = <&i2c6_1>; - enum-names = "I2C_PORT_SENSOR"; - }; - - i2c_soc_thermal: soc-thermal { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_THERMAL_AP"; - }; - }; - - -}; - -&i2c0_0 { - status = "okay"; - label = "I2C_TCPC0"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - tcpc_port0: nct38xx@70 { - compatible = "nuvoton,nct38xx"; - reg = <0x70>; - gpio-dev = <&nct3807_C0>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct3807_C0: nct3807_C0@70 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x70>; - label = "NCT3807_C0"; - - ioex_c0_port0: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3807_C0_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - pinmux_mask = <0xf7>; - }; - ioex_c0_port1: gpio@1 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x1>; - label = "NCT3807_C0_GPIO1"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - }; - }; - - nct3808_alert_0 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; - nct38xx-dev = <&nct3807_C0>; - label = "NCT3807_ALERT_0"; - }; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - status = "okay"; - label = "I2C_TCPC1"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c1_bc12>; - }; - - tcpc_port1: nct38xx@70 { - compatible = "nuvoton,nct38xx"; - reg = <0x70>; - gpio-dev = <&nct3807_C1>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct3807_C1: nct3807_C1@70 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x70>; - label = "NCT3807_C1"; - - ioex_c1_port0: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3807_C1_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - pinmux_mask = <0xf7>; - }; - ioex_c1_port1: gpio@1 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x1>; - label = "NCT3807_C1_GPIO1"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - }; - }; - - nct3808_alert_1 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpioc 7 GPIO_ACTIVE_LOW>; - nct38xx-dev = <&nct3807_C1>; - label = "NCT3807_ALERT_1"; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - status = "okay"; - label = "I2C_BATTERY"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - status = "okay"; - label = "I2C_USB_MUX"; - clock-frequency = ; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; - - amd_fp6_port0: amd_fp6@5c { - compatible = "amd,usbc-mux-amd-fp6"; - status = "okay"; - reg = <0x5c>; - }; - amd_fp6_port1: amd_fp6@52 { - compatible = "amd,usbc-mux-amd-fp6"; - status = "okay"; - reg = <0x52>; - }; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c4_1 { - status = "okay"; - label = "I2C_CHARGER"; - clock-frequency = ; - pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl4 { - status = "okay"; -}; - -&i2c5_0 { - status = "okay"; - label = "I2C_EEPROM"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c6_1 { - status = "okay"; - label = "I2C_SENSOR"; - clock-frequency = ; - pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; - pinctrl-names = "default"; - - soc_pct2075: soc-pct2075@48 { - compatible = "nxp,pct2075"; - reg = <0x48>; - }; - - amb_pct2075: amb-pct2075@4f { - compatible = "nxp,pct2075"; - reg = <0x4f>; - }; -}; - -&i2c_ctrl6 { - status = "okay"; -}; - -&i2c7_0 { - status = "okay"; - label = "I2C_THERMAL_AP"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; - - temp_cpu: cpu@4c { - compatible = "amd,sb-tsi"; - reg = <0x4c>; - }; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/program/skyrim/include/frostflow/keyboard_customization.h b/zephyr/program/skyrim/include/frostflow/keyboard_customization.h deleted file mode 100644 index 2d2a997f91..0000000000 --- a/zephyr/program/skyrim/include/frostflow/keyboard_customization.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Keyboard configuration */ - -#ifndef __KEYBOARD_CUSTOMIZATION_H -#define __KEYBOARD_CUSTOMIZATION_H - -/* - * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate - * exact spaces for arrays. Actual keyboard scanning is done using - * keyboard_cols, which holds a runtime column size. - */ -#ifdef CONFIG_KEYBOARD_CUSTOMIZATION -#undef KEYBOARD_COLS_MAX -#undef KEYBOARD_ROWS - -#define KEYBOARD_COLS_MAX 15 -#define KEYBOARD_ROWS 8 -#endif - -/* - * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols, - * instead. It checks whether you're eligible or not. - */ -extern uint8_t keyboard_cols; - -#define KEYBOARD_ROW_TO_MASK(r) (1 << (r)) - -/* Columns and masks for keys we particularly care about */ -#define KEYBOARD_COL_DOWN 11 -#define KEYBOARD_ROW_DOWN 5 -#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN) -#define KEYBOARD_COL_ESC 1 -#define KEYBOARD_ROW_ESC 1 -#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC) -#define KEYBOARD_COL_KEY_H 6 -#define KEYBOARD_ROW_KEY_H 1 -#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H) -#define KEYBOARD_COL_KEY_R 3 -#define KEYBOARD_ROW_KEY_R 7 -#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R) -#define KEYBOARD_COL_LEFT_ALT 10 -#define KEYBOARD_ROW_LEFT_ALT 6 -#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT) -#define KEYBOARD_COL_REFRESH 2 -#define KEYBOARD_ROW_REFRESH 3 -#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH) -#define KEYBOARD_COL_RIGHT_ALT 10 -#define KEYBOARD_ROW_RIGHT_ALT 0 -#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT) -#define KEYBOARD_DEFAULT_COL_VOL_UP 4 -#define KEYBOARD_DEFAULT_ROW_VOL_UP 1 -#define KEYBOARD_COL_LEFT_CTRL 0 -#define KEYBOARD_ROW_LEFT_CTRL 2 -#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL) -#define KEYBOARD_COL_RIGHT_CTRL 0 -#define KEYBOARD_ROW_RIGHT_CTRL 4 -#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL) -#define KEYBOARD_COL_SEARCH 0 -#define KEYBOARD_ROW_SEARCH 3 -#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH) -#define KEYBOARD_COL_KEY_0 9 -#define KEYBOARD_ROW_KEY_0 0 -#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) -#define KEYBOARD_COL_KEY_1 1 -#define KEYBOARD_ROW_KEY_1 7 -#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1) -#define KEYBOARD_COL_KEY_2 4 -#define KEYBOARD_ROW_KEY_2 6 -#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) -#define KEYBOARD_COL_LEFT_SHIFT 7 -#define KEYBOARD_ROW_LEFT_SHIFT 1 -#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT) - -#endif /* __KEYBOARD_CUSTOMIZATION_H */ diff --git a/zephyr/program/skyrim/include/keyboard_customization.h b/zephyr/program/skyrim/include/keyboard_customization.h new file mode 100644 index 0000000000..2d2a997f91 --- /dev/null +++ b/zephyr/program/skyrim/include/keyboard_customization.h @@ -0,0 +1,78 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Keyboard configuration */ + +#ifndef __KEYBOARD_CUSTOMIZATION_H +#define __KEYBOARD_CUSTOMIZATION_H + +/* + * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate + * exact spaces for arrays. Actual keyboard scanning is done using + * keyboard_cols, which holds a runtime column size. + */ +#ifdef CONFIG_KEYBOARD_CUSTOMIZATION +#undef KEYBOARD_COLS_MAX +#undef KEYBOARD_ROWS + +#define KEYBOARD_COLS_MAX 15 +#define KEYBOARD_ROWS 8 +#endif + +/* + * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols, + * instead. It checks whether you're eligible or not. + */ +extern uint8_t keyboard_cols; + +#define KEYBOARD_ROW_TO_MASK(r) (1 << (r)) + +/* Columns and masks for keys we particularly care about */ +#define KEYBOARD_COL_DOWN 11 +#define KEYBOARD_ROW_DOWN 5 +#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN) +#define KEYBOARD_COL_ESC 1 +#define KEYBOARD_ROW_ESC 1 +#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC) +#define KEYBOARD_COL_KEY_H 6 +#define KEYBOARD_ROW_KEY_H 1 +#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H) +#define KEYBOARD_COL_KEY_R 3 +#define KEYBOARD_ROW_KEY_R 7 +#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R) +#define KEYBOARD_COL_LEFT_ALT 10 +#define KEYBOARD_ROW_LEFT_ALT 6 +#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT) +#define KEYBOARD_COL_REFRESH 2 +#define KEYBOARD_ROW_REFRESH 3 +#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH) +#define KEYBOARD_COL_RIGHT_ALT 10 +#define KEYBOARD_ROW_RIGHT_ALT 0 +#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT) +#define KEYBOARD_DEFAULT_COL_VOL_UP 4 +#define KEYBOARD_DEFAULT_ROW_VOL_UP 1 +#define KEYBOARD_COL_LEFT_CTRL 0 +#define KEYBOARD_ROW_LEFT_CTRL 2 +#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL) +#define KEYBOARD_COL_RIGHT_CTRL 0 +#define KEYBOARD_ROW_RIGHT_CTRL 4 +#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL) +#define KEYBOARD_COL_SEARCH 0 +#define KEYBOARD_ROW_SEARCH 3 +#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH) +#define KEYBOARD_COL_KEY_0 9 +#define KEYBOARD_ROW_KEY_0 0 +#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) +#define KEYBOARD_COL_KEY_1 1 +#define KEYBOARD_ROW_KEY_1 7 +#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1) +#define KEYBOARD_COL_KEY_2 4 +#define KEYBOARD_ROW_KEY_2 6 +#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) +#define KEYBOARD_COL_LEFT_SHIFT 7 +#define KEYBOARD_ROW_LEFT_SHIFT 1 +#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT) + +#endif /* __KEYBOARD_CUSTOMIZATION_H */ diff --git a/zephyr/program/skyrim/interrupts.dts b/zephyr/program/skyrim/interrupts.dts deleted file mode 100644 index de4e87986a..0000000000 --- a/zephyr/program/skyrim/interrupts.dts +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&gpio_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_mech_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_slp_s3: slp_s3 { - irq-pin = <&gpio_slp_s3_l>; - flags = ; - handler = "baseboard_en_pwr_s0"; - }; - int_slp_s5: slp_s5 { - irq-pin = <&gpio_slp_s5_l>; - flags = ; - handler = "baseboard_set_en_pwr_s3"; - }; - int_s5_pgood: s5_pgood { - irq-pin = <&gpio_pg_pwr_s5>; - flags = ; - handler = "baseboard_s5_pgood"; - }; - int_pg_groupc_s0: pg_groupc_s0 { - irq-pin = <&gpio_pg_groupc_s0_od>; - flags = ; - handler = "baseboard_set_en_pwr_pcore"; - }; - int_pg_lpddr_s3: pg_lpddr_s3 { - irq-pin = <&gpio_pg_lpddr5_s3_od>; - flags = ; - handler = "baseboard_set_en_pwr_pcore"; - }; - int_pg_lpddr_s0: pg_lpddr_s0 { - irq-pin = <&gpio_pg_lpddr5_s0_od>; - flags = ; - handler = "baseboard_set_soc_pwr_pgood"; - }; - int_s0_pgood: s0_pgood { - irq-pin = <&gpio_s0_pgood>; - flags = ; - handler = "baseboard_s0_pgood"; - }; - int_soc_thermtrip: soc_thermtrip { - irq-pin = <&gpio_soc_thermtrip_odl>; - flags = ; - handler = "baseboard_soc_thermtrip"; - }; - int_soc_pcore_ocp: soc_pcore_ocp { - irq-pin = <&gpio_pcore_ocp_r_l>; - flags = ; - handler = "baseboard_soc_pcore_ocp"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_usb_a0_fault: a0_fault { - irq-pin = <&ioex_usb_a0_fault_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_a1_fault: a1_fault { - irq-pin = <&ioex_usb_a1_fault_db_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_c0_sbu_fault: c0_sbu_fault { - irq-pin = <&ioex_usb_c0_sbu_fault_odl>; - flags = ; - handler = "sbu_fault_interrupt"; - }; - int_usb_c1_sbu_fault: c1_sbu_fault { - irq-pin = <&ioex_usb_c1_sbu_fault_odl>; - flags = ; - handler = "sbu_fault_interrupt"; - }; - int_usb_c0_tcpc: usb_c0_tcpc { - irq-pin = <&gpio_usb_c0_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_tcpc: usb_c1_tcpc { - irq-pin = <&gpio_usb_c1_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&gpio_usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_ppc: usb_c1_ppc { - irq-pin = <&gpio_usb_c1_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c1_bc12: usb_c1_bc12 { - irq-pin = <&gpio_usb_c1_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_hub_fault: hub_fault { - irq-pin = <&gpio_usb_hub_fault_q_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_pd_soc: usb_pd_soc { - irq-pin = <&gpio_ec_i2c_usbc_pd_int>; - flags = ; - handler = "usb_pd_soc_interrupt"; - }; - int_accel_gyro: accel_gyro { - irq-pin = <&gpio_accel_gyro_int_l>; - flags = ; - handler = "bmi3xx_interrupt"; - }; - }; -}; diff --git a/zephyr/program/skyrim/interrupts.dtsi b/zephyr/program/skyrim/interrupts.dtsi new file mode 100644 index 0000000000..de4e87986a --- /dev/null +++ b/zephyr/program/skyrim/interrupts.dtsi @@ -0,0 +1,146 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&gpio_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_mech_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_slp_s3: slp_s3 { + irq-pin = <&gpio_slp_s3_l>; + flags = ; + handler = "baseboard_en_pwr_s0"; + }; + int_slp_s5: slp_s5 { + irq-pin = <&gpio_slp_s5_l>; + flags = ; + handler = "baseboard_set_en_pwr_s3"; + }; + int_s5_pgood: s5_pgood { + irq-pin = <&gpio_pg_pwr_s5>; + flags = ; + handler = "baseboard_s5_pgood"; + }; + int_pg_groupc_s0: pg_groupc_s0 { + irq-pin = <&gpio_pg_groupc_s0_od>; + flags = ; + handler = "baseboard_set_en_pwr_pcore"; + }; + int_pg_lpddr_s3: pg_lpddr_s3 { + irq-pin = <&gpio_pg_lpddr5_s3_od>; + flags = ; + handler = "baseboard_set_en_pwr_pcore"; + }; + int_pg_lpddr_s0: pg_lpddr_s0 { + irq-pin = <&gpio_pg_lpddr5_s0_od>; + flags = ; + handler = "baseboard_set_soc_pwr_pgood"; + }; + int_s0_pgood: s0_pgood { + irq-pin = <&gpio_s0_pgood>; + flags = ; + handler = "baseboard_s0_pgood"; + }; + int_soc_thermtrip: soc_thermtrip { + irq-pin = <&gpio_soc_thermtrip_odl>; + flags = ; + handler = "baseboard_soc_thermtrip"; + }; + int_soc_pcore_ocp: soc_pcore_ocp { + irq-pin = <&gpio_pcore_ocp_r_l>; + flags = ; + handler = "baseboard_soc_pcore_ocp"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_usb_a0_fault: a0_fault { + irq-pin = <&ioex_usb_a0_fault_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_a1_fault: a1_fault { + irq-pin = <&ioex_usb_a1_fault_db_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_c0_sbu_fault: c0_sbu_fault { + irq-pin = <&ioex_usb_c0_sbu_fault_odl>; + flags = ; + handler = "sbu_fault_interrupt"; + }; + int_usb_c1_sbu_fault: c1_sbu_fault { + irq-pin = <&ioex_usb_c1_sbu_fault_odl>; + flags = ; + handler = "sbu_fault_interrupt"; + }; + int_usb_c0_tcpc: usb_c0_tcpc { + irq-pin = <&gpio_usb_c0_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-pin = <&gpio_usb_c1_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&gpio_usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_ppc: usb_c1_ppc { + irq-pin = <&gpio_usb_c1_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_hub_fault: hub_fault { + irq-pin = <&gpio_usb_hub_fault_q_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_pd_soc: usb_pd_soc { + irq-pin = <&gpio_ec_i2c_usbc_pd_int>; + flags = ; + handler = "usb_pd_soc_interrupt"; + }; + int_accel_gyro: accel_gyro { + irq-pin = <&gpio_accel_gyro_int_l>; + flags = ; + handler = "bmi3xx_interrupt"; + }; + }; +}; diff --git a/zephyr/program/skyrim/keyboard.dts b/zephyr/program/skyrim/keyboard.dts deleted file mode 100644 index aaf305c725..0000000000 --- a/zephyr/program/skyrim/keyboard.dts +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/keyboard.dtsi b/zephyr/program/skyrim/keyboard.dtsi new file mode 100644 index 0000000000..aaf305c725 --- /dev/null +++ b/zephyr/program/skyrim/keyboard.dtsi @@ -0,0 +1,48 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/led_pins_crystaldrift.dts b/zephyr/program/skyrim/led_pins_crystaldrift.dts deleted file mode 100644 index f778a24a51..0000000000 --- a/zephyr/program/skyrim/led_pins_crystaldrift.dts +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_pins_frostflow.dts b/zephyr/program/skyrim/led_pins_frostflow.dts deleted file mode 100644 index 78b9a59c40..0000000000 --- a/zephyr/program/skyrim/led_pins_frostflow.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_pins_morthal.dts b/zephyr/program/skyrim/led_pins_morthal.dts deleted file mode 100644 index 78b9a59c40..0000000000 --- a/zephyr/program/skyrim/led_pins_morthal.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_pins_skyrim.dts b/zephyr/program/skyrim/led_pins_skyrim.dts deleted file mode 100644 index 78b9a59c40..0000000000 --- a/zephyr/program/skyrim/led_pins_skyrim.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_pins_winterhold.dts b/zephyr/program/skyrim/led_pins_winterhold.dts deleted file mode 100644 index 78b9a59c40..0000000000 --- a/zephyr/program/skyrim/led_pins_winterhold.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_policy_crystaldrift.dts b/zephyr/program/skyrim/led_policy_crystaldrift.dts deleted file mode 100644 index a075c6b0d2..0000000000 --- a/zephyr/program/skyrim/led_policy_crystaldrift.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* White 2 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/led_policy_frostflow.dts b/zephyr/program/skyrim/led_policy_frostflow.dts deleted file mode 100644 index e5875640fb..0000000000 --- a/zephyr/program/skyrim/led_policy_frostflow.dts +++ /dev/null @@ -1,122 +0,0 @@ -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = <0 94>; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-charge-lvl-2 { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Near Full) */ - batt-lvl = <95 97>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= 11%, <= Full) */ - batt-lvl = <11 100>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= 10%) */ - batt-lvl = <0 10>; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error-s0 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S0"; - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-error-s3 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S3"; - /* White 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-error-s5 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/led_policy_morthal.dts b/zephyr/program/skyrim/led_policy_morthal.dts deleted file mode 100644 index a075c6b0d2..0000000000 --- a/zephyr/program/skyrim/led_policy_morthal.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* White 2 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/led_policy_skyrim.dts b/zephyr/program/skyrim/led_policy_skyrim.dts deleted file mode 100644 index a075c6b0d2..0000000000 --- a/zephyr/program/skyrim/led_policy_skyrim.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* White 2 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/led_policy_winterhold.dts b/zephyr/program/skyrim/led_policy_winterhold.dts deleted file mode 100644 index f1f8aa31ed..0000000000 --- a/zephyr/program/skyrim/led_policy_winterhold.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s3-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/morthal.dts b/zephyr/program/skyrim/morthal.dts deleted file mode 100644 index a0c89e1d5c..0000000000 --- a/zephyr/program/skyrim/morthal.dts +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Morthal-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <0>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - morthal-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - form-factor { - enum-name = "FW_FORM_FACTOR"; - start = <0>; - size = <1>; - - ff-clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CLAMSHELL"; - value = <0>; - }; - ff-convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CONVERTIBLE"; - value = <1>; - default; - }; - }; - io-db { - enum-name = "FW_IO_DB"; - start = <6>; - size = <2>; - - io-db-ps8811-ps8818 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_PS8811_PS8818"; - value = <0>; - }; - io-db-none-anx7483 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_NONE_ANX7483"; - value = <1>; - default; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <10>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - lid_rot_ref1: lid-rotation-ref1 { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - flags = ; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - flags = ; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; diff --git a/zephyr/program/skyrim/morthal/CMakeLists.txt b/zephyr/program/skyrim/morthal/CMakeLists.txt new file mode 100644 index 0000000000..b4819f1e73 --- /dev/null +++ b/zephyr/program/skyrim/morthal/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +zephyr_library_sources( + "src/ppc_config.c" + "src/usb_mux_config.c" +) diff --git a/zephyr/program/skyrim/morthal/battery.dtsi b/zephyr/program/skyrim/morthal/battery.dtsi new file mode 100644 index 0000000000..8c87cef7f9 --- /dev/null +++ b/zephyr/program/skyrim/morthal/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/morthal/led_pins.dtsi b/zephyr/program/skyrim/morthal/led_pins.dtsi new file mode 100644 index 0000000000..78b9a59c40 --- /dev/null +++ b/zephyr/program/skyrim/morthal/led_pins.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/morthal/led_policy.dtsi b/zephyr/program/skyrim/morthal/led_policy.dtsi new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/morthal/led_policy.dtsi @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/morthal/morthal.dtsi b/zephyr/program/skyrim/morthal/morthal.dtsi new file mode 100644 index 0000000000..99a062220d --- /dev/null +++ b/zephyr/program/skyrim/morthal/morthal.dtsi @@ -0,0 +1,185 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Morthal-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <0>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + morthal-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + flags = ; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + flags = ; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/morthal/motionsense.dtsi b/zephyr/program/skyrim/morthal/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/morthal/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/morthal/project.conf b/zephyr/program/skyrim/morthal/project.conf new file mode 100644 index 0000000000..8a22f58ab8 --- /dev/null +++ b/zephyr/program/skyrim/morthal/project.conf @@ -0,0 +1,23 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Morthal reference-board-specific Kconfig settings. +CONFIG_BOARD_MORTHAL=y + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Morthal is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/morthal/project.overlay b/zephyr/program/skyrim/morthal/project.overlay new file mode 100644 index 0000000000..a41d358cce --- /dev/null +++ b/zephyr/program/skyrim/morthal/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* Morthal project DTS includes*/ +#include "morthal.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/morthal/src/ppc_config.c b/zephyr/program/skyrim/morthal/src/ppc_config.c new file mode 100644 index 0000000000..8108742fdc --- /dev/null +++ b/zephyr/program/skyrim/morthal/src/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Morthal board-specific PPC code */ + +#include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/morthal/src/usb_mux_config.c b/zephyr/program/skyrim/morthal/src/usb_mux_config.c new file mode 100644 index 0000000000..f4b6502b35 --- /dev/null +++ b/zephyr/program/skyrim/morthal/src/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Morthal board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/motionsense.dts b/zephyr/program/skyrim/motionsense.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense.dtsi b/zephyr/program/skyrim/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/motionsense_crystaldrift.dts b/zephyr/program/skyrim/motionsense_crystaldrift.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense_crystaldrift.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense_frostflow.dts b/zephyr/program/skyrim/motionsense_frostflow.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense_frostflow.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense_morthal.dts b/zephyr/program/skyrim/motionsense_morthal.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense_morthal.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense_skyrim.dts b/zephyr/program/skyrim/motionsense_skyrim.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense_skyrim.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense_winterhold.dts b/zephyr/program/skyrim/motionsense_winterhold.dts deleted file mode 100644 index 60d345c0a2..0000000000 --- a/zephyr/program/skyrim/motionsense_winterhold.dts +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - lis2dw12-int = &base_accel; - - /* Use base accelerometer for on-body sensor */ - on-body-sensor = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - mutex_bmi3xx: bmi3xx-mutex { - }; - mutex_lis2dw12: lis2dw12-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - base_accel: base-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_lis2dw12>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS"; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - }; - - motionsense-sensor-alt { - alt_base_accel: alt-base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - alternate-for = <&base_accel>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - }; -}; diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf deleted file mode 100644 index e879e1153b..0000000000 --- a/zephyr/program/skyrim/prj.conf +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_ESPI=y - -# Shell features -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y -CONFIG_KERNEL_SHELL=y - -# Power sequencing -CONFIG_AP=y -CONFIG_AP_X86_AMD=y -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM=y -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y -CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y -CONFIG_PLATFORM_EC_PORT80=y - -# Power button -CONFIG_PLATFORM_EC_POWER_BUTTON=y - -# CBI -CONFIG_EEPROM=y -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y - -# Temperature Sensors -CONFIG_PLATFORM_EC_AMD_SB_RMI=y -CONFIG_PLATFORM_EC_AMD_STT=y -CONFIG_PLATFORM_EC_THROTTLE_AP=y - -# External power -CONFIG_PLATFORM_EC_HOSTCMD=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y - -# Sensors -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n - -# Lid switch -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_LID_SWITCH=y - -# Keyboard -CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y - -# Syscon -CONFIG_SYSCON=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=512 -CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 -CONFIG_PLATFORM_EC_CHARGER_ISL9241=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 - -# USB-C -CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y -CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y -CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811=y -CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818=y -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_MUX_AMD_FP6=y -CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_PID=0x505F -CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_USB_PD_REV30=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y -# Give ourselves enough task space to use i2ctrace -CONFIG_TASK_PD_STACK_SIZE=1280 - -# Motion sense -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y - -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y - -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -# Misc. -CONFIG_PLATFORM_EC_I2C_DEBUG=y -CONFIG_PLATFORM_EC_PORT80_4_BYTE=y - -# These are debug options that happen to be expensive in terms of flash space. -# Turn on as needed based on demand. -CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes -CONFIG_FLASH_SHELL=n # 1852 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes -# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes -CONFIG_THREAD_MONITOR=n # 1548 bytes diff --git a/zephyr/program/skyrim/prj_crystaldrift.conf b/zephyr/program/skyrim/prj_crystaldrift.conf deleted file mode 100644 index e9339c1c3c..0000000000 --- a/zephyr/program/skyrim/prj_crystaldrift.conf +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Crystaldrift reference-board-specific Kconfig settings. -CONFIG_BOARD_CRYSTALDRIFT=y - -# CBI WP pin present -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Crystaldrfit is capable of sinking 100W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Enable alternative charger chip -CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf deleted file mode 100644 index 02da02d35d..0000000000 --- a/zephyr/program/skyrim/prj_frostflow.conf +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Frostflow reference-board-specific Kconfig settings. -CONFIG_BOARD_FROSTFLOW=y -CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10 - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Frostflow is capable of sinking 45W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000 - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y - -# Frostflow not have the USB HUB -CONFIG_BOARD_USB_HUB_RESET=n - -# Battery -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y - -# Fan -CONFIG_PLATFORM_EC_FAN=y -CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y diff --git a/zephyr/program/skyrim/prj_morthal.conf b/zephyr/program/skyrim/prj_morthal.conf deleted file mode 100644 index 8a22f58ab8..0000000000 --- a/zephyr/program/skyrim/prj_morthal.conf +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Morthal reference-board-specific Kconfig settings. -CONFIG_BOARD_MORTHAL=y - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Morthal is capable of sinking 100W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_skyrim.conf b/zephyr/program/skyrim/prj_skyrim.conf deleted file mode 100644 index 67b3f0f142..0000000000 --- a/zephyr/program/skyrim/prj_skyrim.conf +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Skyrim reference-board-specific Kconfig settings. -CONFIG_BOARD_SKYRIM=y - -# CBI WP pin present -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Skyrim is capable of sinking 100W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Enable alternative charger chip -CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_winterhold.conf b/zephyr/program/skyrim/prj_winterhold.conf deleted file mode 100644 index 84be72ec0e..0000000000 --- a/zephyr/program/skyrim/prj_winterhold.conf +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Winterhold reference-board-specific Kconfig settings. -CONFIG_BOARD_WINTERHOLD=y - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Enable charger chip -CONFIG_PLATFORM_EC_CHARGER_ISL9238=y -CONFIG_PLATFORM_EC_CHARGER_ISL9241=n - -# Get the vbus voltage from TCPC -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y - -# Remove unused sensor -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n - -# Support LIS2DW12 sensor -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y - -# Disable lid configuration -CONFIG_PLATFORM_EC_LID_ANGLE=n -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n - -# Disable tablet mode configuration -CONFIG_PLATFORM_EC_TABLET_MODE=n -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n - -# Battery -CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y - -# Body detection configuration -CONFIG_PLATFORM_EC_BODY_DETECTION=y -CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0=y -CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE=y -CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION=y diff --git a/zephyr/program/skyrim/program.conf b/zephyr/program/skyrim/program.conf new file mode 100644 index 0000000000..e879e1153b --- /dev/null +++ b/zephyr/program/skyrim/program.conf @@ -0,0 +1,140 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_ESPI=y + +# Shell features +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y +CONFIG_KERNEL_SHELL=y + +# Power sequencing +CONFIG_AP=y +CONFIG_AP_X86_AMD=y +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM=y +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y +CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y +CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y +CONFIG_PLATFORM_EC_PORT80=y + +# Power button +CONFIG_PLATFORM_EC_POWER_BUTTON=y + +# CBI +CONFIG_EEPROM=y +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y + +# Temperature Sensors +CONFIG_PLATFORM_EC_AMD_SB_RMI=y +CONFIG_PLATFORM_EC_AMD_STT=y +CONFIG_PLATFORM_EC_THROTTLE_AP=y + +# External power +CONFIG_PLATFORM_EC_HOSTCMD=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y + +# Sensors +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n + +# Lid switch +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_LID_SWITCH=y + +# Keyboard +CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y + +# Syscon +CONFIG_SYSCON=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y + +# Charger +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=512 +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 +CONFIG_PLATFORM_EC_CHARGER_ISL9241=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 + +# USB-C +CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y +CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y +CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811=y +CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818=y +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_MUX_AMD_FP6=y +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_PID=0x505F +CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y +CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_REV30=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y +# Give ourselves enough task space to use i2ctrace +CONFIG_TASK_PD_STACK_SIZE=1280 + +# Motion sense +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y + +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y + +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y + +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Misc. +CONFIG_PLATFORM_EC_I2C_DEBUG=y +CONFIG_PLATFORM_EC_PORT80_4_BYTE=y + +# These are debug options that happen to be expensive in terms of flash space. +# Turn on as needed based on demand. +CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes +CONFIG_FLASH_SHELL=n # 1852 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes +# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes +CONFIG_THREAD_MONITOR=n # 1548 bytes diff --git a/zephyr/program/skyrim/skyrim.dts b/zephyr/program/skyrim/skyrim.dts deleted file mode 100644 index c19f8a5949..0000000000 --- a/zephyr/program/skyrim/skyrim.dts +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Skyrim-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <35>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - skyrim-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - form-factor { - enum-name = "FW_FORM_FACTOR"; - start = <0>; - size = <1>; - - ff-clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CLAMSHELL"; - value = <0>; - }; - ff-convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CONVERTIBLE"; - value = <1>; - default; - }; - }; - io-db { - enum-name = "FW_IO_DB"; - start = <6>; - size = <2>; - - io-db-ps8811-ps8818 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_PS8811_PS8818"; - value = <0>; - }; - io-db-none-anx7483 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_NONE_ANX7483"; - value = <1>; - default; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <10>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - - charger-option { - enum-name = "FW_CHARGER"; - start = <11>; - size = <2>; - - charger-option-isl9241 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9241"; - value = <0>; - default; - }; - charger-option-isl9538 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9538"; - value = <1>; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - lid_rot_ref1: lid-rotation-ref1 { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - flags = ; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - flags = ; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; - alt_charger: isl9538@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - chg_alt = <&alt_charger>; - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; diff --git a/zephyr/program/skyrim/skyrim/CMakeLists.txt b/zephyr/program/skyrim/skyrim/CMakeLists.txt new file mode 100644 index 0000000000..fef1c72a31 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include) +zephyr_library_sources( + "src/usb_mux_config.c" + "src/ppc_config.c" + "src/form_factor.c" + "src/alt_charger.c" + "src/keyboard.c" +) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/fan.c") diff --git a/zephyr/program/skyrim/skyrim/battery.dtsi b/zephyr/program/skyrim/skyrim/battery.dtsi new file mode 100644 index 0000000000..8c87cef7f9 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/skyrim/led_pins.dtsi b/zephyr/program/skyrim/skyrim/led_pins.dtsi new file mode 100644 index 0000000000..78b9a59c40 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/led_pins.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/skyrim/led_policy.dtsi b/zephyr/program/skyrim/skyrim/led_policy.dtsi new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/led_policy.dtsi @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/skyrim/motionsense.dtsi b/zephyr/program/skyrim/skyrim/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/skyrim/project.conf b/zephyr/program/skyrim/skyrim/project.conf new file mode 100644 index 0000000000..67b3f0f142 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/project.conf @@ -0,0 +1,26 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Skyrim reference-board-specific Kconfig settings. +CONFIG_BOARD_SKYRIM=y + +# CBI WP pin present +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Skyrim is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable alternative charger chip +CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/skyrim/project.overlay b/zephyr/program/skyrim/skyrim/project.overlay new file mode 100644 index 0000000000..9b61b2ac9b --- /dev/null +++ b/zephyr/program/skyrim/skyrim/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* Skyrim project DTS includes*/ +#include "skyrim.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/skyrim/skyrim.dtsi b/zephyr/program/skyrim/skyrim/skyrim.dtsi new file mode 100644 index 0000000000..1037df1c8c --- /dev/null +++ b/zephyr/program/skyrim/skyrim/skyrim.dtsi @@ -0,0 +1,209 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Skyrim-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <35>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + skyrim-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + + charger-option { + enum-name = "FW_CHARGER"; + start = <11>; + size = <2>; + + charger-option-isl9241 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9241"; + value = <0>; + default; + }; + charger-option-isl9538 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9538"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + flags = ; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + flags = ; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + alt_charger: isl9538@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + chg_alt = <&alt_charger>; + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/skyrim/skyrim_vif.xml b/zephyr/program/skyrim/skyrim/skyrim_vif.xml new file mode 100644 index 0000000000..28d6f19049 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/skyrim_vif.xml @@ -0,0 +1,346 @@ + + + 3.22 + + USB-IF + VIF Editor + 3.4.2.0 + + Google + skyrim + FIX-ME + 65535 + Port Product + End Product + + + + + + + + + 0 + Type-C® + + + DRP + DRP + + Both + + + + + + + + + Revision 3 + + + + + + + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 22500 mW + Shared + CPower + 22500 mW + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 1500 mW + + + + 3A @ 5V + + + + + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + + + + + + 100000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 20000 mV + + + + Variable + 4750 mV + 20000 mV + 5000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505F + 0000 + + + + + + + 1 + Type-C® + + + DRP + DRP + + Both + + + + + + + + + Revision 3 + + + + + + + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 22500 mW + Shared + CPower + 22500 mW + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + 3A @ 5V + + + + + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + + + + + + 100000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 20000 mV + + + + Variable + 4750 mV + 20000 mV + 5000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505F + 0000 + + diff --git a/zephyr/program/skyrim/skyrim/src/alt_charger.c b/zephyr/program/skyrim/skyrim/src/alt_charger.c new file mode 100644 index 0000000000..91e5af8426 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/alt_charger.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charger_chips.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "hooks.h" + +#include +#include + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +static void alt_charger_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FW_CHARGER, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); + return; + } + + if (val == FW_CHARGER_ISL9538) + CHG_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/skyrim/src/fan.c b/zephyr/program/skyrim/skyrim/src/fan.c new file mode 100644 index 0000000000..c584022a92 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/fan.c @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include +#include +#include + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Skyrim fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + uint32_t board_version; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + + ret = cbi_get_board_version(&board_version); + if (ret != EC_SUCCESS) { + LOG_ERR("Error retrieving CBI board version"); + return; + } + + if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { + /* Disable the fan */ + fan_set_count(0); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); + +/* + * Pcore OCP support + * Note: early boards should note enable this interrupt as they are not + * correctly configured for it. + */ +__override bool board_supports_pcore_ocp(void) +{ + uint32_t board_version; + + if (cbi_get_board_version(&board_version) == EC_SUCCESS && + board_version > 3) + return true; + + return false; +} diff --git a/zephyr/program/skyrim/skyrim/src/form_factor.c b/zephyr/program/skyrim/skyrim/src/form_factor.c new file mode 100644 index 0000000000..b13d905364 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/form_factor.c @@ -0,0 +1,38 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "accelgyro.h" +#include "common.h" +#include "cros_board_info.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +#include +#include + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) +#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + /* + * If the board version >=4 + * use ver1 rotation matrix. + */ + ret = cbi_get_board_version(&val); + if (ret == EC_SUCCESS && val >= 4) { + LOG_INF("Switching to ver1 lid"); + motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/skyrim/src/keyboard.c b/zephyr/program/skyrim/skyrim/src/keyboard.c new file mode 100644 index 0000000000..e261321e86 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config skyrim_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &skyrim_kb; +} diff --git a/zephyr/program/skyrim/skyrim/src/ppc_config.c b/zephyr/program/skyrim/skyrim/src/ppc_config.c new file mode 100644 index 0000000000..047103baee --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim board-specific PPC code */ + +#include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/skyrim/src/usb_mux_config.c b/zephyr/program/skyrim/skyrim/src/usb_mux_config.c new file mode 100644 index 0000000000..8d409dffdd --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/skyrim_vif.xml b/zephyr/program/skyrim/skyrim_vif.xml deleted file mode 100644 index 28d6f19049..0000000000 --- a/zephyr/program/skyrim/skyrim_vif.xml +++ /dev/null @@ -1,346 +0,0 @@ - - - 3.22 - - USB-IF - VIF Editor - 3.4.2.0 - - Google - skyrim - FIX-ME - 65535 - Port Product - End Product - - - - - - - - - 0 - Type-C® - - - DRP - DRP - - Both - - - - - - - - - Revision 3 - - - - - - - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 22500 mW - Shared - CPower - 22500 mW - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 1500 mW - - - - 3A @ 5V - - - - - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - - - - - - 100000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 20000 mV - - - - Variable - 4750 mV - 20000 mV - 5000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505F - 0000 - - - - - - - 1 - Type-C® - - - DRP - DRP - - Both - - - - - - - - - Revision 3 - - - - - - - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 22500 mW - Shared - CPower - 22500 mW - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - 3A @ 5V - - - - - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - - - - - - 100000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 20000 mV - - - - Variable - 4750 mV - 20000 mV - 5000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505F - 0000 - - diff --git a/zephyr/program/skyrim/src/crystaldrift/alt_charger.c b/zephyr/program/skyrim/src/crystaldrift/alt_charger.c deleted file mode 100644 index a429457136..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/alt_charger.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "charger_chips.h" -#include "common.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "hooks.h" - -#include -#include - -LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); - -static void alt_charger_init(void) -{ - int ret; - uint32_t val; - - ret = cros_cbi_get_fw_config(FW_CHARGER, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); - return; - } - - if (val == FW_CHARGER_ISL9538) - CHG_ENABLE_ALTERNATE(0); -} -DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/src/crystaldrift/fan.c b/zephyr/program/skyrim/src/crystaldrift/fan.c deleted file mode 100644 index 6645e2a495..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/fan.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" - -#include -#include -#include - -LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Skyrim fan support - */ -static void fan_init(void) -{ - int ret; - uint32_t val; - uint32_t board_version; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - - ret = cbi_get_board_version(&board_version); - if (ret != EC_SUCCESS) { - LOG_ERR("Error retrieving CBI board version"); - return; - } - - if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { - /* Disable the fan */ - fan_set_count(0); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); - -/* - * Pcore OCP support - * Note: early boards should note enable this interrupt as they are not - * correctly configured for it. - */ -__override bool board_supports_pcore_ocp(void) -{ - uint32_t board_version; - - if (cbi_get_board_version(&board_version) == EC_SUCCESS && - board_version > 3) - return true; - - return false; -} diff --git a/zephyr/program/skyrim/src/crystaldrift/form_factor.c b/zephyr/program/skyrim/src/crystaldrift/form_factor.c deleted file mode 100644 index 688765617b..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/form_factor.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "accelgyro.h" -#include "common.h" -#include "cros_board_info.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -#include -#include - -LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Mainboard orientation support. - */ - -#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) -#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) - -static void form_factor_init(void) -{ - int ret; - uint32_t val; - /* - * If the board version >=4 - * use ver1 rotation matrix. - */ - ret = cbi_get_board_version(&val); - if (ret == EC_SUCCESS && val >= 4) { - LOG_INF("Switching to ver1 lid"); - motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; - } -} -DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/src/crystaldrift/ppc_config.c b/zephyr/program/skyrim/src/crystaldrift/ppc_config.c deleted file mode 100644 index 3913fda4dc..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Crystaldrift board-specific PPC code */ - -#include "driver/ppc/aoz1380_public.h" -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c b/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c deleted file mode 100644 index 0e08431360..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Crystaldrift board-specific USB-C mux configuration */ - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} - -static void setup_mux(void) -{ - uint32_t val; - - if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) - CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); - /* Val will have our dts default on error, so continue setup */ - - if (val == FW_IO_DB_PS8811_PS8818) { - CPRINTSUSB("C1: Setting PS8818 mux"); - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); - } else if (val == FW_IO_DB_NONE_ANX7483) { - CPRINTSUSB("C1: Setting ANX7483 mux"); - } else { - CPRINTSUSB("Unexpected DB_IO board: %d", val); - } -} -DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/src/frostflow/keyboard.c b/zephyr/program/skyrim/src/frostflow/keyboard.c deleted file mode 100644 index 2905f17941..0000000000 --- a/zephyr/program/skyrim/src/frostflow/keyboard.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" -#include "keyboard_scan.h" -#include "timer.h" - -/* Keyboard scan setting */ -__override struct keyboard_scan_config keyscan_config = { - /* Increase from 50 us, because KSO_02 passes through the H1. */ - .output_settle_us = 80, - /* Other values should be the same as the default configuration. */ - .debounce_down_us = 9 * MSEC, - .debounce_up_us = 30 * MSEC, - .scan_period_us = 3 * MSEC, - .min_post_scan_delay_us = 1000, - .poll_timeout_us = 100 * MSEC, - .actual_key_mask = { - 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x86, 0xff, 0xff, 0x55, 0xff, 0xff, 0xff, 0xff, /* full set */ - }, -}; - -static const struct ec_response_keybd_config frostflow_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &frostflow_kb; -} - -/* - * Row Column info for Top row keys T1 - T15. - * on frostflow_kb keyboard Row Column is customization - * need define row col to mapping matrix layout. - */ -__override const struct key { - uint8_t row; - uint8_t col; -} vivaldi_keys[] = { - { .row = 4, .col = 2 }, /* T1 */ - { .row = 3, .col = 2 }, /* T2 */ - { .row = 2, .col = 2 }, /* T3 */ - { .row = 1, .col = 2 }, /* T4 */ - { .row = 4, .col = 4 }, /* T5 */ - { .row = 3, .col = 4 }, /* T6 */ - { .row = 2, .col = 4 }, /* T7 */ - { .row = 2, .col = 9 }, /* T8 */ - { .row = 1, .col = 9 }, /* T9 */ - { .row = 1, .col = 4 }, /* T10 */ - { .row = 0, .col = 4 }, /* T11 */ - { .row = 1, .col = 5 }, /* T12 */ - { .row = 3, .col = 5 }, /* T13 */ - { .row = 2, .col = 1 }, /* T14 */ - { .row = 0, .col = 1 }, /* T15 */ -}; -BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS); diff --git a/zephyr/program/skyrim/src/frostflow/keyboard_customization.c b/zephyr/program/skyrim/src/frostflow/keyboard_customization.c deleted file mode 100644 index bd02940e03..0000000000 --- a/zephyr/program/skyrim/src/frostflow/keyboard_customization.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "gpio.h" -#include "keyboard_customization.h" -#include "keyboard_protocol.h" -#include "keyboard_raw.h" - -#include - -static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { - { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 }, - { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 }, - { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a }, - { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d }, - { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d }, - { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 }, - { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c }, - { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 }, - { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d }, - { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a }, - { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 }, - { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 }, - { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d }, - { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 }, - { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 }, -}; - -uint16_t get_scancode_set2(uint8_t row, uint8_t col) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - return scancode_set2[col][row]; - return 0; -} - -void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - scancode_set2[col][row] = val; -} - -#ifdef CONFIG_KEYBOARD_DEBUG -static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { - { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO }, - { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' }, - { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3, - KLLI_UNKNO }, - { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC }, - { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' }, - { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' }, - { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' }, - { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' }, - { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO, - KLLI_LEFT, KLLI_UNKNO }, - { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' }, - { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' }, - { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO }, -}; - -char get_keycap_label(uint8_t row, uint8_t col) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - return keycap_label[col][row]; - return KLLI_UNKNO; -} - -void set_keycap_label(uint8_t row, uint8_t col, char val) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - keycap_label[col][row] = val; -} -#endif diff --git a/zephyr/program/skyrim/src/frostflow/ppc_config.c b/zephyr/program/skyrim/src/frostflow/ppc_config.c deleted file mode 100644 index 513c025dec..0000000000 --- a/zephyr/program/skyrim/src/frostflow/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Frostflow board-specific PPC code */ - -#include "driver/ppc/aoz1380_public.h" -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/frostflow/thermal.c b/zephyr/program/skyrim/src/frostflow/thermal.c deleted file mode 100644 index eae8aac25d..0000000000 --- a/zephyr/program/skyrim/src/frostflow/thermal.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "chipset.h" -#include "fan.h" -#include "tablet_mode.h" -#include "temp_sensor/temp_sensor.h" -#include "thermal.h" -#include "util.h" -#include "console.h" - -#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_amb)) - -struct fan_step { - /* - * Sensor 0~4 trigger point, set -1 if we're not using this - * sensor to determine fan speed. - */ - int on[TEMP_SENSOR_COUNT]; - /* - * Sensor 0~4 release point, set -1 if we're not using this - * sensor to determine fan speed. - */ - int off[TEMP_SENSOR_COUNT]; - /* Fan rpm */ - uint16_t rpm[FAN_CH_COUNT]; -}; - -#define FAN_TABLE_ENTRY(nd) \ - { \ - .on = DT_PROP(nd, temp_on), \ - .off = DT_PROP(nd, temp_off), \ - .rpm = DT_PROP(nd, rpm_target), \ - }, - -static const struct fan_step fan_table_clamshell[] = { DT_FOREACH_CHILD( - DT_NODELABEL(fan_steps_clamshell), FAN_TABLE_ENTRY) }; - -static const struct fan_step fan_table_tablet[] = { DT_FOREACH_CHILD( - DT_NODELABEL(fan_steps_tablet), FAN_TABLE_ENTRY) }; - -static const struct fan_step *fan_step_table; -#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table_clamshell) - -BUILD_ASSERT(ARRAY_SIZE(fan_table_clamshell) == ARRAY_SIZE(fan_table_tablet)); - -int fan_table_to_rpm(int fan, int *temp) -{ - /* current fan level */ - static int current_level; - /* previous sensor temperature */ - static int prev_tmp[TEMP_SENSOR_COUNT]; - int i; - - if (tablet_get_mode()) - fan_step_table = fan_table_tablet; - else - fan_step_table = fan_table_clamshell; - - /* - * Compare the current and previous temperature, we have - * the three paths : - * 1. decreasing path. (check the release point) - * 2. increasing path. (check the trigger point) - * 3. invariant path. (return the current RPM) - */ - - if (temp[TEMP_AMB] < prev_tmp[TEMP_AMB]) { - for (i = current_level; i > 0; i--) { - if (temp[TEMP_AMB] < fan_step_table[i].off[TEMP_AMB]) - current_level = i - 1; - else - break; - } - } else if (temp[TEMP_AMB] > prev_tmp[TEMP_AMB]) { - for (i = current_level; i < NUM_FAN_LEVELS; i++) { - if (temp[TEMP_AMB] > fan_step_table[i].on[TEMP_AMB]) - current_level = i + 1; - else - break; - } - } - - if (current_level < 0) - current_level = 0; - - if (current_level >= NUM_FAN_LEVELS) - current_level = NUM_FAN_LEVELS - 1; - - for (i = 0; i < TEMP_SENSOR_COUNT; ++i) - prev_tmp[i] = temp[i]; - - return fan_step_table[current_level].rpm[fan]; -} - -void board_override_fan_control(int fan, int *temp) -{ - /* - * In common/fan.c pwm_fan_stop() will turn off fan - * when chipset suspend or shutdown. - */ - if (chipset_in_state(CHIPSET_STATE_ON)) { - fan_set_rpm_mode(fan, 1); - fan_set_rpm_target(fan, fan_table_to_rpm(fan, temp)); - } -} diff --git a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c b/zephyr/program/skyrim/src/frostflow/usb_mux_config.c deleted file mode 100644 index 2ec1dda0be..0000000000 --- a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Frostflow board-specific USB-C mux configuration */ - -#include "ioexpander.h" -#include "usbc/usb_muxes.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ps8815 DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_c0_amd_fp6_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} diff --git a/zephyr/program/skyrim/src/morthal/ppc_config.c b/zephyr/program/skyrim/src/morthal/ppc_config.c deleted file mode 100644 index 8108742fdc..0000000000 --- a/zephyr/program/skyrim/src/morthal/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Morthal board-specific PPC code */ - -#include "driver/ppc/aoz1380_public.h" -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/morthal/usb_mux_config.c b/zephyr/program/skyrim/src/morthal/usb_mux_config.c deleted file mode 100644 index f4b6502b35..0000000000 --- a/zephyr/program/skyrim/src/morthal/usb_mux_config.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Morthal board-specific USB-C mux configuration */ - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} - -static void setup_mux(void) -{ - uint32_t val; - - if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) - CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); - /* Val will have our dts default on error, so continue setup */ - - if (val == FW_IO_DB_PS8811_PS8818) { - CPRINTSUSB("C1: Setting PS8818 mux"); - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); - } else if (val == FW_IO_DB_NONE_ANX7483) { - CPRINTSUSB("C1: Setting ANX7483 mux"); - } else { - CPRINTSUSB("Unexpected DB_IO board: %d", val); - } -} -DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/src/skyrim/alt_charger.c b/zephyr/program/skyrim/src/skyrim/alt_charger.c deleted file mode 100644 index 91e5af8426..0000000000 --- a/zephyr/program/skyrim/src/skyrim/alt_charger.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "charger_chips.h" -#include "common.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "hooks.h" - -#include -#include - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -static void alt_charger_init(void) -{ - int ret; - uint32_t val; - - ret = cros_cbi_get_fw_config(FW_CHARGER, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); - return; - } - - if (val == FW_CHARGER_ISL9538) - CHG_ENABLE_ALTERNATE(0); -} -DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/src/skyrim/fan.c b/zephyr/program/skyrim/src/skyrim/fan.c deleted file mode 100644 index c584022a92..0000000000 --- a/zephyr/program/skyrim/src/skyrim/fan.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" - -#include -#include -#include - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Skyrim fan support - */ -static void fan_init(void) -{ - int ret; - uint32_t val; - uint32_t board_version; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - - ret = cbi_get_board_version(&board_version); - if (ret != EC_SUCCESS) { - LOG_ERR("Error retrieving CBI board version"); - return; - } - - if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { - /* Disable the fan */ - fan_set_count(0); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); - -/* - * Pcore OCP support - * Note: early boards should note enable this interrupt as they are not - * correctly configured for it. - */ -__override bool board_supports_pcore_ocp(void) -{ - uint32_t board_version; - - if (cbi_get_board_version(&board_version) == EC_SUCCESS && - board_version > 3) - return true; - - return false; -} diff --git a/zephyr/program/skyrim/src/skyrim/form_factor.c b/zephyr/program/skyrim/src/skyrim/form_factor.c deleted file mode 100644 index b13d905364..0000000000 --- a/zephyr/program/skyrim/src/skyrim/form_factor.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "accelgyro.h" -#include "common.h" -#include "cros_board_info.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -#include -#include - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Mainboard orientation support. - */ - -#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) -#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) - -static void form_factor_init(void) -{ - int ret; - uint32_t val; - /* - * If the board version >=4 - * use ver1 rotation matrix. - */ - ret = cbi_get_board_version(&val); - if (ret == EC_SUCCESS && val >= 4) { - LOG_INF("Switching to ver1 lid"); - motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; - } -} -DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/src/skyrim/keyboard.c b/zephyr/program/skyrim/src/skyrim/keyboard.c deleted file mode 100644 index e261321e86..0000000000 --- a/zephyr/program/skyrim/src/skyrim/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config skyrim_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &skyrim_kb; -} diff --git a/zephyr/program/skyrim/src/skyrim/ppc_config.c b/zephyr/program/skyrim/src/skyrim/ppc_config.c deleted file mode 100644 index 047103baee..0000000000 --- a/zephyr/program/skyrim/src/skyrim/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Skyrim board-specific PPC code */ - -#include "driver/ppc/aoz1380_public.h" -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/skyrim/usb_mux_config.c b/zephyr/program/skyrim/src/skyrim/usb_mux_config.c deleted file mode 100644 index 8d409dffdd..0000000000 --- a/zephyr/program/skyrim/src/skyrim/usb_mux_config.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Skyrim board-specific USB-C mux configuration */ - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} - -static void setup_mux(void) -{ - uint32_t val; - - if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) - CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); - /* Val will have our dts default on error, so continue setup */ - - if (val == FW_IO_DB_PS8811_PS8818) { - CPRINTSUSB("C1: Setting PS8818 mux"); - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); - } else if (val == FW_IO_DB_NONE_ANX7483) { - CPRINTSUSB("C1: Setting ANX7483 mux"); - } else { - CPRINTSUSB("Unexpected DB_IO board: %d", val); - } -} -DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/src/winterhold/battery_present.c b/zephyr/program/skyrim/src/winterhold/battery_present.c deleted file mode 100644 index 290955a242..0000000000 --- a/zephyr/program/skyrim/src/winterhold/battery_present.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "battery.h" -#include "battery_smart.h" -#include "common.h" - -#include - -static enum battery_present batt_pres_prev = BP_NOT_SURE; - -__overridable bool board_battery_is_initialized(void) -{ - int batt_status; - - return battery_status(&batt_status) != EC_SUCCESS ? - false : - !!(batt_status & STATUS_INITIALIZED); -} - -/* - * Physical detection of battery. - */ -static enum battery_present battery_check_present_status(void) -{ - enum battery_present batt_pres; - - if (battery_is_cut_off()) - return BP_NO; - - /* Get the physical hardware status */ - batt_pres = battery_hw_present(); - - /* - * If the battery is not physically connected, then no need to perform - * any more checks. - */ - if (batt_pres == BP_NO) - return BP_NO; - - /* - * If the battery is present now and was present last time we checked, - * return early. - */ - if ((batt_pres == BP_YES) && (batt_pres == batt_pres_prev)) - return BP_YES; - - /* - * Check battery initialization. If the battery is not initialized, - * then return BP_NOT_SURE. Battery could be in ship - * mode and might require pre-charge current to wake it up. BP_NO is not - * returned here because charger state machine will not provide - * pre-charge current assuming that battery is not present. - */ - if (!board_battery_is_initialized()) - return BP_NOT_SURE; - - return BP_YES; -} - -enum battery_present battery_is_present(void) -{ - batt_pres_prev = battery_check_present_status(); - return batt_pres_prev; -} - -enum battery_present battery_hw_present(void) -{ - const struct gpio_dt_spec *batt_pres; - - batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl); - - /* - * The GPIO is low when the battery is physically present. - * But if battery cell voltage < 2.5V, it will not able to - * pull down EC_BATT_PRES_ODL. So we need to set pre-charge - * current even EC_BATT_PRES_ODL is high. - */ - return gpio_pin_get_dt(batt_pres) ? BP_NOT_SURE : BP_YES; -} diff --git a/zephyr/program/skyrim/src/winterhold/kb_backlight.c b/zephyr/program/skyrim/src/winterhold/kb_backlight.c deleted file mode 100644 index cbbfc0a4e9..0000000000 --- a/zephyr/program/skyrim/src/winterhold/kb_backlight.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "board_config.h" -#include "common.h" -#include "cros_board_info.h" -#include "cros_cbi.h" - -#include -#include - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -__override uint32_t board_override_feature_flags0(uint32_t flags0) -{ - int ret; - uint32_t val; - - /* - * Remove keyboard backlight feature for devices that don't support it. - */ - ret = cros_cbi_get_fw_config(FW_KB_BL, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL); - return flags0; - } - - if (val == FW_KB_BL_NOT_PRESENT) - return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB)); - else - return flags0; -} diff --git a/zephyr/program/skyrim/src/winterhold/keyboard.c b/zephyr/program/skyrim/src/winterhold/keyboard.c deleted file mode 100644 index d3aebe0f2e..0000000000 --- a/zephyr/program/skyrim/src/winterhold/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config winterhold_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &winterhold_kb; -} diff --git a/zephyr/program/skyrim/src/winterhold/ppc_config.c b/zephyr/program/skyrim/src/winterhold/ppc_config.c deleted file mode 100644 index d6adb145ff..0000000000 --- a/zephyr/program/skyrim/src/winterhold/ppc_config.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Winterhold board-specific PPC code */ - -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - nx20p348x_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/winterhold/sensor.c b/zephyr/program/skyrim/src/winterhold/sensor.c deleted file mode 100644 index 52cd201705..0000000000 --- a/zephyr/program/skyrim/src/winterhold/sensor.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "cros_board_info.h" -#include "driver/accel_lis2dw12.h" -#include "driver/accelgyro_bmi3xx.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -void base_accel_interrupt(enum gpio_signal signal) -{ - int ret; - uint32_t val; - - ret = cbi_get_board_version(&val); - - if (ret == EC_SUCCESS && val < 1) - bmi3xx_interrupt(signal); - else - lis2dw12_interrupt(signal); -} - -static void motionsense_init(void) -{ - int ret; - uint32_t val; - - ret = cbi_get_board_version(&val); - - if (ret == EC_SUCCESS && val < 1) { - MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); - } -} -DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c b/zephyr/program/skyrim/src/winterhold/usb_mux_config.c deleted file mode 100644 index 19153eb676..0000000000 --- a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Winterhold board-specific USB-C mux configuration */ - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_fg_defalut_tuning(const struct usb_mux *me) -{ - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_1_2DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_1_2DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_1_2DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_1_2DB)); - - return EC_SUCCESS; -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - /* - * Set the Flat Gain to default every time, to prevent DP only mode's - * Flat Gain change in the last plug. - */ - RETURN_ERROR(board_anx7483_c1_fg_defalut_tuning(me)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, - ANX7483_FG_SETTING_0_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, - ANX7483_FG_SETTING_0_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, - ANX7483_FG_SETTING_0_5DB)); - } - - return EC_SUCCESS; -} diff --git a/zephyr/program/skyrim/usbc.dts b/zephyr/program/skyrim/usbc.dts deleted file mode 100644 index 8486927e8d..0000000000 --- a/zephyr/program/skyrim/usbc.dts +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - usbc_port0: port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - }; - - usbc_port1: port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - tcpc = <&tcpc_port1>; - }; - }; -}; diff --git a/zephyr/program/skyrim/usbc.dtsi b/zephyr/program/skyrim/usbc.dtsi new file mode 100644 index 0000000000..8486927e8d --- /dev/null +++ b/zephyr/program/skyrim/usbc.dtsi @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + usbc_port0: port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + }; + + usbc_port1: port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + tcpc = <&tcpc_port1>; + }; + }; +}; diff --git a/zephyr/program/skyrim/winterhold.dts b/zephyr/program/skyrim/winterhold.dts deleted file mode 100644 index 356aca07e2..0000000000 --- a/zephyr/program/skyrim/winterhold.dts +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Winterhold-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <105>; - temp_host_halt = <110>; - temp_host_release_high = <95>; - temp_host_release_halt = <100>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - temp_host_warn = <50>; - temp_host_high = <105>; - temp_host_halt = <110>; - temp_host_release_warn = <45>; - temp_host_release_high = <95>; - temp_host_release_halt = <100>; - temp_fan_off = <35>; - temp_fan_max = <40>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - Winterhold-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - /* - * FW_CONFIG field to enable KB back light or not. - */ - kb-bl { - enum-name = "FW_KB_BL"; - start = <1>; - size = <1>; - - no-kb-bl { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_NOT_PRESENT"; - value = <0>; - }; - kb-bl-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_PRESENT"; - value = <1>; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - flags = ; - }; - ppc_port0: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - flags = ; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; -}; - -&i2c4_1 { - charger: isl9238@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; -}; - -&fan0 { - pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>; - rpm_min = <2100>; - rpm_start = <2600>; - rpm_max = <4800>; -}; - -&temp_sensor_charger { - temp_host_high = <100>; - temp_host_halt = <110>; - temp_host_release_high = <90>; - temp_host_release_halt = <100>; -}; - -&temp_sensor_memory { - temp_host_high = <91>; - temp_host_halt = <96>; - temp_host_release_high = <81>; - temp_host_release_halt = <86>; -}; - -&temp_sensor_cpu { - /delete-property/ temp_host_high; - /delete-property/ temp_host_halt; - /delete-property/ temp_host_release_high; - /delete-property/ temp_fan_off; - /delete-property/ temp_fan_max; -}; - -/* Override handler */ -&int_accel_gyro { - handler = "base_accel_interrupt"; -}; diff --git a/zephyr/program/skyrim/winterhold/CMakeLists.txt b/zephyr/program/skyrim/winterhold/CMakeLists.txt new file mode 100644 index 0000000000..ebd01a87e6 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +zephyr_library_sources( + "src/usb_mux_config.c" + "src/ppc_config.c" + "src/kb_backlight.c" + "src/keyboard.c" + "src/sensor.c" + "src/battery_present.c" +) diff --git a/zephyr/program/skyrim/winterhold/battery.dtsi b/zephyr/program/skyrim/winterhold/battery.dtsi new file mode 100644 index 0000000000..8e82e0d1f2 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/battery.dtsi @@ -0,0 +1,33 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: lgc_xphx8 { + compatible = "lgc,xphx8", "battery-smart"; + }; + smp_atlxdy9k { + compatible = "smp,atlxdy9k", "battery-smart"; + }; + smp_cosxdy9k { + compatible = "smp,cosxdy9k", "battery-smart"; + }; + byd_wv3k8 { + compatible = "byd,wv3k8", "battery-smart"; + }; + cosmx_mvk11 { + compatible = "cosmx,mvk11", "battery-smart"; + }; + sunwoda_atlvkyjx { + compatible = "sunwoda,atlvkyjx", "battery-smart"; + }; + sunwoda_cosvkyjx { + compatible = "sunwoda,cosvkyjx", "battery-smart"; + }; + atl_cfd72 { + compatible = "atl,cfd72", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/winterhold/led_pins.dtsi b/zephyr/program/skyrim/winterhold/led_pins.dtsi new file mode 100644 index 0000000000..78b9a59c40 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/led_pins.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/winterhold/led_policy.dtsi b/zephyr/program/skyrim/winterhold/led_policy.dtsi new file mode 100644 index 0000000000..f1f8aa31ed --- /dev/null +++ b/zephyr/program/skyrim/winterhold/led_policy.dtsi @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s3-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/winterhold/motionsense.dtsi b/zephyr/program/skyrim/winterhold/motionsense.dtsi new file mode 100644 index 0000000000..60d345c0a2 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/motionsense.dtsi @@ -0,0 +1,124 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + lis2dw12-int = &base_accel; + + /* Use base accelerometer for on-body sensor */ + on-body-sensor = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + mutex_bmi3xx: bmi3xx-mutex { + }; + mutex_lis2dw12: lis2dw12-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + base_accel: base-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_lis2dw12>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS"; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + }; + + motionsense-sensor-alt { + alt_base_accel: alt-base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + alternate-for = <&base_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + }; +}; diff --git a/zephyr/program/skyrim/winterhold/project.conf b/zephyr/program/skyrim/winterhold/project.conf new file mode 100644 index 0000000000..84be72ec0e --- /dev/null +++ b/zephyr/program/skyrim/winterhold/project.conf @@ -0,0 +1,47 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Winterhold reference-board-specific Kconfig settings. +CONFIG_BOARD_WINTERHOLD=y + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable charger chip +CONFIG_PLATFORM_EC_CHARGER_ISL9238=y +CONFIG_PLATFORM_EC_CHARGER_ISL9241=n + +# Get the vbus voltage from TCPC +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y + +# Remove unused sensor +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n + +# Support LIS2DW12 sensor +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y + +# Disable lid configuration +CONFIG_PLATFORM_EC_LID_ANGLE=n +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n + +# Disable tablet mode configuration +CONFIG_PLATFORM_EC_TABLET_MODE=n +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y + +# Body detection configuration +CONFIG_PLATFORM_EC_BODY_DETECTION=y +CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0=y +CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE=y +CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION=y diff --git a/zephyr/program/skyrim/winterhold/project.overlay b/zephyr/program/skyrim/winterhold/project.overlay new file mode 100644 index 0000000000..9a13a1a3cd --- /dev/null +++ b/zephyr/program/skyrim/winterhold/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* winterhold project DTS includes*/ +#include "winterhold.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/winterhold/src/battery_present.c b/zephyr/program/skyrim/winterhold/src/battery_present.c new file mode 100644 index 0000000000..290955a242 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/battery_present.c @@ -0,0 +1,81 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "battery.h" +#include "battery_smart.h" +#include "common.h" + +#include + +static enum battery_present batt_pres_prev = BP_NOT_SURE; + +__overridable bool board_battery_is_initialized(void) +{ + int batt_status; + + return battery_status(&batt_status) != EC_SUCCESS ? + false : + !!(batt_status & STATUS_INITIALIZED); +} + +/* + * Physical detection of battery. + */ +static enum battery_present battery_check_present_status(void) +{ + enum battery_present batt_pres; + + if (battery_is_cut_off()) + return BP_NO; + + /* Get the physical hardware status */ + batt_pres = battery_hw_present(); + + /* + * If the battery is not physically connected, then no need to perform + * any more checks. + */ + if (batt_pres == BP_NO) + return BP_NO; + + /* + * If the battery is present now and was present last time we checked, + * return early. + */ + if ((batt_pres == BP_YES) && (batt_pres == batt_pres_prev)) + return BP_YES; + + /* + * Check battery initialization. If the battery is not initialized, + * then return BP_NOT_SURE. Battery could be in ship + * mode and might require pre-charge current to wake it up. BP_NO is not + * returned here because charger state machine will not provide + * pre-charge current assuming that battery is not present. + */ + if (!board_battery_is_initialized()) + return BP_NOT_SURE; + + return BP_YES; +} + +enum battery_present battery_is_present(void) +{ + batt_pres_prev = battery_check_present_status(); + return batt_pres_prev; +} + +enum battery_present battery_hw_present(void) +{ + const struct gpio_dt_spec *batt_pres; + + batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl); + + /* + * The GPIO is low when the battery is physically present. + * But if battery cell voltage < 2.5V, it will not able to + * pull down EC_BATT_PRES_ODL. So we need to set pre-charge + * current even EC_BATT_PRES_ODL is high. + */ + return gpio_pin_get_dt(batt_pres) ? BP_NOT_SURE : BP_YES; +} diff --git a/zephyr/program/skyrim/winterhold/src/kb_backlight.c b/zephyr/program/skyrim/winterhold/src/kb_backlight.c new file mode 100644 index 0000000000..cbbfc0a4e9 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/kb_backlight.c @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "board_config.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" + +#include +#include + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +__override uint32_t board_override_feature_flags0(uint32_t flags0) +{ + int ret; + uint32_t val; + + /* + * Remove keyboard backlight feature for devices that don't support it. + */ + ret = cros_cbi_get_fw_config(FW_KB_BL, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL); + return flags0; + } + + if (val == FW_KB_BL_NOT_PRESENT) + return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB)); + else + return flags0; +} diff --git a/zephyr/program/skyrim/winterhold/src/keyboard.c b/zephyr/program/skyrim/winterhold/src/keyboard.c new file mode 100644 index 0000000000..d3aebe0f2e --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config winterhold_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &winterhold_kb; +} diff --git a/zephyr/program/skyrim/winterhold/src/ppc_config.c b/zephyr/program/skyrim/winterhold/src/ppc_config.c new file mode 100644 index 0000000000..d6adb145ff --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/ppc_config.c @@ -0,0 +1,27 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Winterhold board-specific PPC code */ + +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + nx20p348x_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/winterhold/src/sensor.c b/zephyr/program/skyrim/winterhold/src/sensor.c new file mode 100644 index 0000000000..52cd201705 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/sensor.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "cros_board_info.h" +#include "driver/accel_lis2dw12.h" +#include "driver/accelgyro_bmi3xx.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +void base_accel_interrupt(enum gpio_signal signal) +{ + int ret; + uint32_t val; + + ret = cbi_get_board_version(&val); + + if (ret == EC_SUCCESS && val < 1) + bmi3xx_interrupt(signal); + else + lis2dw12_interrupt(signal); +} + +static void motionsense_init(void) +{ + int ret; + uint32_t val; + + ret = cbi_get_board_version(&val); + + if (ret == EC_SUCCESS && val < 1) { + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); + } +} +DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/skyrim/winterhold/src/usb_mux_config.c b/zephyr/program/skyrim/winterhold/src/usb_mux_config.c new file mode 100644 index 0000000000..19153eb676 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/usb_mux_config.c @@ -0,0 +1,146 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Winterhold board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_fg_defalut_tuning(const struct usb_mux *me) +{ + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_1_2DB)); + + return EC_SUCCESS; +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + /* + * Set the Flat Gain to default every time, to prevent DP only mode's + * Flat Gain change in the last plug. + */ + RETURN_ERROR(board_anx7483_c1_fg_defalut_tuning(me)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, + ANX7483_FG_SETTING_0_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, + ANX7483_FG_SETTING_0_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, + ANX7483_FG_SETTING_0_5DB)); + } + + return EC_SUCCESS; +} diff --git a/zephyr/program/skyrim/winterhold/winterhold.dtsi b/zephyr/program/skyrim/winterhold/winterhold.dtsi new file mode 100644 index 0000000000..a831cd9500 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/winterhold.dtsi @@ -0,0 +1,168 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Winterhold-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <105>; + temp_host_halt = <110>; + temp_host_release_high = <95>; + temp_host_release_halt = <100>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + temp_host_warn = <50>; + temp_host_high = <105>; + temp_host_halt = <110>; + temp_host_release_warn = <45>; + temp_host_release_high = <95>; + temp_host_release_halt = <100>; + temp_fan_off = <35>; + temp_fan_max = <40>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + Winterhold-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to enable KB back light or not. + */ + kb-bl { + enum-name = "FW_KB_BL"; + start = <1>; + size = <1>; + + no-kb-bl { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_NOT_PRESENT"; + value = <0>; + }; + kb-bl-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_PRESENT"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + flags = ; + }; + ppc_port0: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + flags = ; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; +}; + +&i2c4_1 { + charger: isl9238@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; +}; + +&fan0 { + pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>; + rpm_min = <2100>; + rpm_start = <2600>; + rpm_max = <4800>; +}; + +&temp_sensor_charger { + temp_host_high = <100>; + temp_host_halt = <110>; + temp_host_release_high = <90>; + temp_host_release_halt = <100>; +}; + +&temp_sensor_memory { + temp_host_high = <91>; + temp_host_halt = <96>; + temp_host_release_high = <81>; + temp_host_release_halt = <86>; +}; + +&temp_sensor_cpu { + /delete-property/ temp_host_high; + /delete-property/ temp_host_halt; + /delete-property/ temp_host_release_high; + /delete-property/ temp_fan_off; + /delete-property/ temp_fan_max; +}; + +/* Override handler */ +&int_accel_gyro { + handler = "base_accel_interrupt"; +}; -- cgit v1.2.1 From ea174bbf20cd6616321c889e8106786ccca3cf88 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Tue, 29 Nov 2022 10:05:58 -0700 Subject: zephyr: Sort remaining includes This is the last of the files in platform/ec. Sort all includes with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds Signed-off-by: Jeremy Bettis Change-Id: I95e37e74d860cbb7c74ec478b543aef0b0e967e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062620 Commit-Queue: Jeremy Bettis Reviewed-by: Sam Hurst Code-Coverage: Zoss Tested-by: Jeremy Bettis --- zephyr/emul/tcpc/emul_tcpci_partner_vpd.c | 6 +++--- zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h | 4 ++-- zephyr/program/nissa/xivu/src/form_factor.c | 9 ++++----- zephyr/test/drivers/usbc_ctvpd/src/main.c | 15 ++++++++------- zephyr/test/krabby/src/usbc_config.c | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c b/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c index 596dc45ef9..f01227e913 100644 --- a/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c +++ b/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "driver/tcpm/tcpci.h" #include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci_partner_faulty_ext.h" @@ -13,6 +10,9 @@ #include "emul/tcpc/emul_tcpci_partner_src.h" #include "emul/tcpc/emul_tcpci_partner_vpd.h" +#include +#include + LOG_MODULE_REGISTER(tcpci_vpd_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL); static enum tcpci_partner_handler_res diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h index 4f0c600927..6de0452b05 100644 --- a/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h +++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h @@ -12,13 +12,13 @@ #ifndef __EMUL_TCPCI_PARTNER_VPD_H #define __EMUL_TCPCI_PARTNER_VPD_H -#include - #include "emul/tcpc/emul_tcpci_partner_common.h" #include "emul/tcpc/emul_tcpci_partner_faulty_ext.h" #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "emul/tcpc/emul_tcpci_partner_src.h" +#include + /** * @brief USB-C VCONN-powered device extension backend API * @defgroup tcpci_src_emul USB-C source device extension diff --git a/zephyr/program/nissa/xivu/src/form_factor.c b/zephyr/program/nissa/xivu/src/form_factor.c index 9a55dacd53..2ce6f5418d 100644 --- a/zephyr/program/nissa/xivu/src/form_factor.c +++ b/zephyr/program/nissa/xivu/src/form_factor.c @@ -3,9 +3,6 @@ * found in the LICENSE file. */ -#include -#include - #include "accelgyro.h" #include "button.h" #include "cros_board_info.h" @@ -16,11 +13,13 @@ #include "driver/accelgyro_lsm6dso.h" #include "gpio/gpio_int.h" #include "hooks.h" -#include "motionsense_sensors.h" #include "motion_sense.h" +#include "motionsense_sensors.h" +#include "nissa_common.h" #include "tablet_mode.h" -#include "nissa_common.h" +#include +#include LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); diff --git a/zephyr/test/drivers/usbc_ctvpd/src/main.c b/zephyr/test/drivers/usbc_ctvpd/src/main.c index 391a006370..0bd6639d83 100644 --- a/zephyr/test/drivers/usbc_ctvpd/src/main.c +++ b/zephyr/test/drivers/usbc_ctvpd/src/main.c @@ -3,11 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "ec_commands.h" #include "ec_tasks.h" #include "emul/emul_isl923x.h" @@ -16,13 +11,19 @@ #include "emul/tcpc/emul_tcpci_partner_snk.h" #include "emul/tcpc/emul_tcpci_partner_src.h" #include "host_command.h" -#include "test/drivers/stubs.h" #include "tcpm/tcpci.h" -#include "test/drivers/utils.h" +#include "test/drivers/stubs.h" #include "test/drivers/test_state.h" +#include "test/drivers/utils.h" #include "test_usbc_ctvpd.h" #include "usb_pd_vdo.h" +#include + +#include +#include +#include + #define TEST_PORT 0 BUILD_ASSERT(TEST_PORT == USBC_PORT_C0); diff --git a/zephyr/test/krabby/src/usbc_config.c b/zephyr/test/krabby/src/usbc_config.c index ea9c4b3eed..0b6c8bc80d 100644 --- a/zephyr/test/krabby/src/usbc_config.c +++ b/zephyr/test/krabby/src/usbc_config.c @@ -3,10 +3,6 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "adc.h" #include "charge_manager.h" #include "driver/ppc/syv682x.h" @@ -17,6 +13,10 @@ #include "usb_pd.h" #include "usbc_ppc.h" +#include +#include +#include + bool ppc_sink_enabled(int port) { const struct emul *emul = (port == 0) ? -- cgit v1.2.1 From 91ba2792dbe8eebedac3f921734ade520e7645d7 Mon Sep 17 00:00:00 2001 From: Aaron Massey Date: Tue, 29 Nov 2022 17:14:16 -0700 Subject: zephyr: Override LOG_PRINTK default to disabled After a downstream change LOG_PRINTK is enabled by default when PRINTK and the ZTEST_NEW_API are enabled. LOG_PRINTK seems to timeout/fail our tests. Add a KConfig override that disables LOG_PRINTK by default. BRANCH=none BUG=b:260772137 TEST=twister TEST=CQ Change-Id: Iec189124c891a53a8230a2291bc7852e44acc94e Signed-off-by: Aaron Massey Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4065008 Reviewed-by: Keith Short Code-Coverage: Zoss --- zephyr/app/ec/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zephyr/app/ec/Kconfig b/zephyr/app/ec/Kconfig index f630c252ed..72c80f5d3a 100644 --- a/zephyr/app/ec/Kconfig +++ b/zephyr/app/ec/Kconfig @@ -26,6 +26,14 @@ orsource "chip/$(ARCH)/*/Kconfig.*" config NUM_PREEMPT_PRIORITIES default 26 +# +# Override the LOG_PRINTK to be no as it currently makes multiple +# tests timeout and a few others fail in console assertions +# TODO(b/http://b/260772137) Fix LOG_PRINTK issue and remove override +# +config LOG_PRINTK + default n + # # In Zephyr, the default system workqueue thread priority level is the lowest # cooperative priority. Override its priority to the second lowest preempt -- cgit v1.2.1 From a147fd5e333e940ff831cd09964ca855b3f78755 Mon Sep 17 00:00:00 2001 From: Jeremy Bettis Date: Wed, 23 Nov 2022 11:29:10 -0700 Subject: test: Sort header files Sort all includes in test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis Change-Id: Iae52f99a3a8b5623c1c92722c325ca92816fa856 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052760 Code-Coverage: Zoss Reviewed-by: Aaron Massey Auto-Submit: Jeremy Bettis Commit-Queue: Jeremy Bettis Tested-by: Jeremy Bettis --- core/cortex-m/include/mpu_private.h | 3 +++ test/abort.c | 4 ++-- test/accel_cal.c | 5 +++-- test/always_memset.c | 5 ++--- test/base32.c | 5 +++-- test/button.c | 4 ++-- test/cec.c | 4 ++-- test/compile_time_macros.c | 2 +- test/console_edit.c | 4 ++-- test/cortexm_fpu.c | 3 +-- test/entropy.c | 2 +- test/fake_usbc.c | 2 +- test/fp.c | 1 - test/fpsensor.c | 8 ++++---- test/fpsensor_crypto.c | 4 ++-- test/fpsensor_state.c | 4 ++-- test/ftrapv.c | 4 ++-- test/gyro_cal.c | 7 ++++--- test/gyro_cal_init_for_test.c | 3 ++- test/interrupt.c | 4 ++-- test/kasa.c | 3 ++- test/kb_8042.c | 3 ++- test/libc_printf.c | 4 ++-- test/lightbar.c | 2 +- test/mag_cal.c | 1 + test/math_util.c | 5 +++-- test/motion_angle.c | 6 +++--- test/motion_angle_tablet.c | 6 +++--- test/motion_lid.c | 6 +++--- test/motion_sense_fifo.c | 11 ++++++----- test/mpu.c | 3 ++- test/mutex.c | 2 +- test/newton_fit.c | 3 ++- test/nvidia_gpu.c | 5 ++--- test/online_calibration.c | 1 + test/online_calibration_spoof.c | 5 +++-- test/panic_data.c | 3 +-- test/powerdemo.c | 2 +- test/printf.c | 8 ++++---- test/rgb_keyboard.c | 4 ++-- test/rollback.c | 3 ++- test/rollback_secret.c | 4 ++-- test/rsa.c | 2 +- test/rtc.c | 2 +- test/sha256.c | 2 +- test/shmalloc.c | 10 +++++----- test/stdlib.c | 2 +- test/stillness_detector.c | 3 ++- test/system_is_locked.c | 3 +-- test/uptime.c | 4 ++-- test/usb_pd_console.c | 4 ++-- test/usb_pd_int.c | 4 ++-- test/usb_pe_drp.c | 14 +++++++------- test/usb_pe_drp_noextended.c | 6 +++--- test/usb_pe_drp_old.c | 2 +- test/usb_prl_noextended.c | 2 +- test/usb_prl_old.c | 2 +- test/usb_sm_checks.c | 2 +- test/usb_sm_framework_h3.c | 2 +- test/usb_tcpmv2_compliance_common.c | 2 +- test/usb_tcpmv2_td_pd_ll_e3.c | 2 +- test/usb_tcpmv2_td_pd_ll_e4.c | 2 +- test/usb_tcpmv2_td_pd_ll_e5.c | 2 +- test/usb_tcpmv2_td_pd_other.c | 4 ++-- test/usb_tcpmv2_td_pd_src3_e1.c | 2 +- test/usb_tcpmv2_td_pd_src3_e7.c | 4 ++-- test/usb_tcpmv2_td_pd_src3_e8.c | 4 ++-- test/usb_tcpmv2_td_pd_src3_e9.c | 4 ++-- test/usb_tcpmv2_td_pd_src_e1.c | 2 +- test/usb_tcpmv2_td_pd_src_e2.c | 2 +- test/usb_tcpmv2_td_pd_src_e5.c | 2 +- test/usb_tcpmv2_td_pd_vndi3_e3.c | 2 +- test/usb_test/device_configuration.c | 5 +++-- test/usb_typec_ctvpd.c | 6 +++--- test/utils_str.c | 2 +- test/vboot.c | 4 ++-- test/version.c | 2 +- test/vpd_api.c | 4 ++-- 78 files changed, 152 insertions(+), 139 deletions(-) diff --git a/core/cortex-m/include/mpu_private.h b/core/cortex-m/include/mpu_private.h index eb9de4c395..fc7617da66 100644 --- a/core/cortex-m/include/mpu_private.h +++ b/core/cortex-m/include/mpu_private.h @@ -12,6 +12,9 @@ #ifndef __CROS_EC_MPU_PRIVATE_H #define __CROS_EC_MPU_PRIVATE_H +#include +#include + int mpu_num_regions(void); bool has_mpu(void); bool mpu_is_unified(void); diff --git a/test/abort.c b/test/abort.c index e0069e920f..dcc798861e 100644 --- a/test/abort.c +++ b/test/abort.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "panic.h" #include "system.h" #include "task.h" #include "test_util.h" +#include + test_static int test_abort(void) { ccprintf("Calling abort\n"); diff --git a/test/accel_cal.c b/test/accel_cal.c index 481d0615f2..5c50211bd5 100644 --- a/test/accel_cal.c +++ b/test/accel_cal.c @@ -3,10 +3,11 @@ * found in the LICENSE file. */ -#include "common.h" #include "accel_cal.h" -#include "test_util.h" +#include "common.h" #include "motion_sense.h" +#include "test_util.h" + #include struct motion_sensor_t motion_sensors[] = {}; diff --git a/test/always_memset.c b/test/always_memset.c index 40a68d883b..eed15cab27 100644 --- a/test/always_memset.c +++ b/test/always_memset.c @@ -10,12 +10,11 @@ * If optimization is disabled, the test_optimization_working test will fail. */ -#include - #include "common.h" +#include "cryptoc/util.h" #include "test_util.h" -#include "cryptoc/util.h" +#include /* 256 bytes of stack is only safe enough for a memcpy. */ #define EXTRA_STACK_SIZE 256 diff --git a/test/base32.c b/test/base32.c index c1ec489ea0..50b9d994c1 100644 --- a/test/base32.c +++ b/test/base32.c @@ -5,12 +5,13 @@ * Test Base-32 encoding/decoding */ -#include -#include "common.h" #include "base32.h" +#include "common.h" #include "test_util.h" #include "util.h" +#include + DECLARE_EC_TEST(test_crc5) { uint32_t seen; diff --git a/test/button.c b/test/button.c index c1acba7048..3a46625660 100644 --- a/test/button.c +++ b/test/button.c @@ -15,10 +15,10 @@ #include "console.h" #include "gpio.h" #include "host_command.h" -#include "test_util.h" -#include "timer.h" #include "keyboard_config.h" #include "keyboard_protocol.h" +#include "test_util.h" +#include "timer.h" #include "util.h" #define UNCHANGED -1 diff --git a/test/cec.c b/test/cec.c index 7718b7b705..6d385665a8 100644 --- a/test/cec.c +++ b/test/cec.c @@ -5,11 +5,11 @@ * Test the buffer handling of HDMI CEC */ -#include - #include "cec.h" #include "test_util.h" +#include + struct overflow_msg { struct cec_msg_transfer transfer; uint8_t overflow_detector; diff --git a/test/compile_time_macros.c b/test/compile_time_macros.c index 544da9e0d8..5e5d716627 100644 --- a/test/compile_time_macros.c +++ b/test/compile_time_macros.c @@ -5,8 +5,8 @@ * Test compile_time_macros.h */ -#include "stdbool.h" #include "common.h" +#include "stdbool.h" #include "test_util.h" static int test_BIT(void) diff --git a/test/console_edit.c b/test/console_edit.c index b9753468fd..5ec649be5f 100644 --- a/test/console_edit.c +++ b/test/console_edit.c @@ -7,11 +7,11 @@ #include "common.h" #include "console.h" +#include "ec_commands.h" #include "test_util.h" #include "timer.h" -#include "util.h" #include "uart.h" -#include "ec_commands.h" +#include "util.h" static int cmd_1_call_cnt; static int cmd_2_call_cnt; diff --git a/test/cortexm_fpu.c b/test/cortexm_fpu.c index c27edbaf40..f31ec63535 100644 --- a/test/cortexm_fpu.c +++ b/test/cortexm_fpu.c @@ -3,12 +3,11 @@ * found in the LICENSE file. */ -#include "test_util.h" - #include "cpu.h" #include "math.h" #include "registers.h" #include "task.h" +#include "test_util.h" #include "time.h" static volatile uint32_t fpscr; diff --git a/test/entropy.c b/test/entropy.c index 8fbdb9147f..abac349d76 100644 --- a/test/entropy.c +++ b/test/entropy.c @@ -5,8 +5,8 @@ * Tests entropy source. */ -#include "console.h" #include "common.h" +#include "console.h" #include "rollback.h" #include "test_util.h" #include "timer.h" diff --git a/test/fake_usbc.c b/test/fake_usbc.c index 72a208aa99..6a2cab09aa 100644 --- a/test/fake_usbc.c +++ b/test/fake_usbc.c @@ -5,9 +5,9 @@ * Test USB Type-C module. */ #include "common.h" -#include "usb_tc_sm.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usb_tc_sm.h" __overridable int pd_is_vbus_present(int port) { diff --git a/test/fp.c b/test/fp.c index ab41868578..135670f47a 100644 --- a/test/fp.c +++ b/test/fp.c @@ -8,7 +8,6 @@ * early. e.g. CONFIG_FPU, which is needed in math_util.h. */ #include "common.h" - #include "mat33.h" #include "mat44.h" #include "math.h" diff --git a/test/fpsensor.c b/test/fpsensor.c index 588374d4db..2daaa0d2cf 100644 --- a/test/fpsensor.c +++ b/test/fpsensor.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include -#include - +#include "common/fpsensor/fpsensor_private.h" #include "ec_commands.h" #include "mock/fpsensor_detect_mock.h" #include "string.h" #include "test_util.h" -#include "common/fpsensor/fpsensor_private.h" + +#include +#include static const struct ec_response_get_protocol_info expected_info[] = { [FP_TRANSPORT_TYPE_SPI] = { diff --git a/test/fpsensor_crypto.c b/test/fpsensor_crypto.c index 9265a608b4..238f2b3452 100644 --- a/test/fpsensor_crypto.c +++ b/test/fpsensor_crypto.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "builtin/assert.h" #include "common.h" #include "ec_commands.h" @@ -17,6 +15,8 @@ #include "test_util.h" #include "util.h" +#include + extern int get_ikm(uint8_t *ikm); static const uint8_t fake_positive_match_salt[] = { diff --git a/test/fpsensor_state.c b/test/fpsensor_state.c index 0b61e1c2d4..771523b33b 100644 --- a/test/fpsensor_state.c +++ b/test/fpsensor_state.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "ec_commands.h" #include "fpsensor_state.h" @@ -12,6 +10,8 @@ #include "test_util.h" #include "util.h" +#include + test_static int test_fp_enc_status_valid_flags(void) { /* Putting expected value here because test_static should take void */ diff --git a/test/ftrapv.c b/test/ftrapv.c index 60d76d25d0..1aefb8404f 100644 --- a/test/ftrapv.c +++ b/test/ftrapv.c @@ -3,14 +3,14 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "panic.h" #include "system.h" #include "task.h" #include "test_util.h" +#include + /* * trapping addition: __addvsi3. */ diff --git a/test/gyro_cal.c b/test/gyro_cal.c index c8e8d30589..cf9af0fdbc 100644 --- a/test/gyro_cal.c +++ b/test/gyro_cal.c @@ -5,14 +5,15 @@ #include "common.h" #include "gyro_cal.h" -#include "gyro_still_det.h" #include "gyro_cal_init_for_test.h" +#include "gyro_still_det.h" #include "motion_sense.h" #include "test_util.h" -#include -#include + #include #include +#include +#include float kToleranceGyroRps = 1e-6f; float kDefaultGravityMps2 = 9.81f; diff --git a/test/gyro_cal_init_for_test.c b/test/gyro_cal_init_for_test.c index 0ba1a65e6b..ebb1dd8799 100644 --- a/test/gyro_cal_init_for_test.c +++ b/test/gyro_cal_init_for_test.c @@ -4,8 +4,9 @@ */ #include "common.h" -#include "timer.h" #include "gyro_cal_init_for_test.h" +#include "timer.h" + #include #define NANO_PI (3.14159265359f) diff --git a/test/interrupt.c b/test/interrupt.c index efd8b47a34..fbd35253e8 100644 --- a/test/interrupt.c +++ b/test/interrupt.c @@ -4,8 +4,6 @@ * * Test interrupt support of EC emulator. */ -#include - #include "common.h" #include "console.h" #include "task.h" @@ -13,6 +11,8 @@ #include "timer.h" #include "util.h" +#include + static int main_count; static int has_error; static int interrupt_count; diff --git a/test/kasa.c b/test/kasa.c index 23968faf7c..222fb2a0cf 100644 --- a/test/kasa.c +++ b/test/kasa.c @@ -5,8 +5,9 @@ #include "common.h" #include "kasa.h" -#include "test_util.h" #include "motion_sense.h" +#include "test_util.h" + #include struct motion_sensor_t motion_sensors[] = {}; diff --git a/test/kb_8042.c b/test/kb_8042.c index eb043d5f82..0065319576 100644 --- a/test/kb_8042.c +++ b/test/kb_8042.c @@ -5,7 +5,6 @@ * Tests for keyboard MKBP protocol */ -#include #include "atkbd_protocol.h" #include "common.h" #include "console.h" @@ -24,6 +23,8 @@ #include "timer.h" #include "util.h" +#include + static const char *action[2] = { "release", "press" }; /* diff --git a/test/libc_printf.c b/test/libc_printf.c index b3f5f03605..8900d9ea04 100644 --- a/test/libc_printf.c +++ b/test/libc_printf.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -#include - #include "test_util.h" +#include + test_static int test_printf(void) { /* diff --git a/test/lightbar.c b/test/lightbar.c index 90400d1cf5..d51b61779e 100644 --- a/test/lightbar.c +++ b/test/lightbar.c @@ -5,8 +5,8 @@ #include "console.h" #include "ec_commands.h" -#include "lightbar.h" #include "host_command.h" +#include "lightbar.h" #include "test_util.h" #include "timer.h" #include "util.h" diff --git a/test/mag_cal.c b/test/mag_cal.c index 245bad786c..fe98318258 100644 --- a/test/mag_cal.c +++ b/test/mag_cal.c @@ -6,6 +6,7 @@ #include "common.h" #include "mag_cal.h" #include "test_util.h" + #include /** diff --git a/test/math_util.c b/test/math_util.c index 1ee9b1484b..c08bd0c561 100644 --- a/test/math_util.c +++ b/test/math_util.c @@ -5,14 +5,15 @@ * Test motion sense code. */ -#include -#include #include "common.h" #include "math_util.h" #include "motion_sense.h" #include "test_util.h" #include "util.h" +#include +#include + /*****************************************************************************/ /* * Need to define motion sensor globals just to compile. diff --git a/test/motion_angle.c b/test/motion_angle.c index 3f206de078..8eb1a775e4 100644 --- a/test/motion_angle.c +++ b/test/motion_angle.c @@ -6,9 +6,6 @@ * transition. */ -#include -#include - #include "accelgyro.h" #include "common.h" #include "gpio.h" @@ -20,6 +17,9 @@ #include "test_util.h" #include "util.h" +#include +#include + /*****************************************************************************/ /* Test utilities */ diff --git a/test/motion_angle_tablet.c b/test/motion_angle_tablet.c index 2c0c15c828..2f458381b3 100644 --- a/test/motion_angle_tablet.c +++ b/test/motion_angle_tablet.c @@ -5,9 +5,6 @@ * Test motion sense code, when in tablet mode. */ -#include -#include - #include "accelgyro.h" #include "common.h" #include "gpio.h" @@ -19,6 +16,9 @@ #include "test_util.h" #include "util.h" +#include +#include + /*****************************************************************************/ /* Test utilities */ diff --git a/test/motion_lid.c b/test/motion_lid.c index 39b83ce6fc..40e6dcb0f0 100644 --- a/test/motion_lid.c +++ b/test/motion_lid.c @@ -5,9 +5,6 @@ * Test motion sense code. */ -#include -#include - #include "accelgyro.h" #include "common.h" #include "gpio.h" @@ -20,6 +17,9 @@ #include "timer.h" #include "util.h" +#include +#include + extern enum chipset_state_mask sensor_active; extern int wait_us; diff --git a/test/motion_sense_fifo.c b/test/motion_sense_fifo.c index 5a977e94d0..3cea279bda 100644 --- a/test/motion_sense_fifo.c +++ b/test/motion_sense_fifo.c @@ -5,15 +5,16 @@ * Test motion_sense_fifo. */ +#include "accelgyro.h" #include "ec_commands.h" -#include "stdio.h" -#include "motion_sense_fifo.h" -#include "test_util.h" -#include "util.h" #include "hwtimer.h" +#include "motion_sense_fifo.h" +#include "stdio.h" #include "task.h" +#include "test_util.h" #include "timer.h" -#include "accelgyro.h" +#include "util.h" + #include mutex_t g_sensor_mutex; diff --git a/test/mpu.c b/test/mpu.c index 957111b901..dfc5877d5a 100644 --- a/test/mpu.c +++ b/test/mpu.c @@ -11,13 +11,14 @@ * 5. runtest on console */ -#include #include "mpu.h" #include "mpu_private.h" #include "string.h" #include "system.h" #include "test_util.h" +#include + struct mpu_info { bool has_mpu; int num_mpu_regions; diff --git a/test/mutex.c b/test/mutex.c index a03e504a0a..b4066c8c4f 100644 --- a/test/mutex.c +++ b/test/mutex.c @@ -6,8 +6,8 @@ * Tasks for mutexes basic tests. */ -#include "console.h" #include "common.h" +#include "console.h" #include "task.h" #include "test_util.h" #include "timer.h" diff --git a/test/newton_fit.c b/test/newton_fit.c index 07c35aad2a..62f4710f0c 100644 --- a/test/newton_fit.c +++ b/test/newton_fit.c @@ -4,9 +4,10 @@ */ #include "common.h" -#include "newton_fit.h" #include "motion_sense.h" +#include "newton_fit.h" #include "test_util.h" + #include /* diff --git a/test/nvidia_gpu.c b/test/nvidia_gpu.c index d6086cc8c4..b660943e04 100644 --- a/test/nvidia_gpu.c +++ b/test/nvidia_gpu.c @@ -4,12 +4,11 @@ * * Tests for Nvidia GPU. */ -#include - #include "charge_manager.h" #include "charge_state.h" #include "common.h" #include "console.h" +#include "driver/nvidia_gpu.h" #include "hooks.h" #include "host_command.h" #include "task.h" @@ -18,7 +17,7 @@ #include "timer.h" #include "util.h" -#include "driver/nvidia_gpu.h" +#include struct d_notify_policy d_notify_policies[] = { AC_ATLEAST_W(100), AC_ATLEAST_W(65), AC_DC, diff --git a/test/online_calibration.c b/test/online_calibration.c index cecb543eef..c845378012 100644 --- a/test/online_calibration.c +++ b/test/online_calibration.c @@ -10,6 +10,7 @@ #include "online_calibration.h" #include "test_util.h" #include "timer.h" + #include int mkbp_send_event(uint8_t event_type) diff --git a/test/online_calibration_spoof.c b/test/online_calibration_spoof.c index 44a3b812d9..31c17bb8dd 100644 --- a/test/online_calibration_spoof.c +++ b/test/online_calibration_spoof.c @@ -5,13 +5,14 @@ #include "accel_cal.h" #include "accelgyro.h" +#include "gyro_cal.h" +#include "gyro_cal_init_for_test.h" #include "hwtimer.h" #include "mag_cal.h" #include "online_calibration.h" #include "test_util.h" -#include "gyro_cal_init_for_test.h" -#include "gyro_cal.h" #include "timer.h" + #include int mkbp_send_event(uint8_t event_type) diff --git a/test/panic_data.c b/test/panic_data.c index 334b766dfc..8892c17ece 100644 --- a/test/panic_data.c +++ b/test/panic_data.c @@ -3,12 +3,11 @@ * found in the LICENSE file. */ -#include "test_util.h" - #include "builtin/assert.h" #include "panic.h" #include "system.h" #include "task.h" +#include "test_util.h" static int get_assert_line(void) { diff --git a/test/powerdemo.c b/test/powerdemo.c index 7a4f0c5ccb..2900401370 100644 --- a/test/powerdemo.c +++ b/test/powerdemo.c @@ -8,9 +8,9 @@ #include "clock.h" #include "common.h" #include "powerdemo.h" +#include "registers.h" #include "task.h" #include "timer.h" -#include "registers.h" static volatile enum { POWER_STATE_IDLE = 0, /* Idle */ diff --git a/test/printf.c b/test/printf.c index 29ffdfcea4..7c037e22da 100644 --- a/test/printf.c +++ b/test/printf.c @@ -3,16 +3,16 @@ * found in the LICENSE file. */ -#include -#include -#include - #include "common.h" #include "compiler.h" #include "printf.h" #include "test_util.h" #include "util.h" +#include +#include +#include + #ifdef USE_BUILTIN_STDLIB /* * When USE_BUILTIN_STDLIB is defined, we want to test the EC printf diff --git a/test/rgb_keyboard.c b/test/rgb_keyboard.c index d32215e649..1b6ea1bf95 100644 --- a/test/rgb_keyboard.c +++ b/test/rgb_keyboard.c @@ -4,8 +4,6 @@ * * Tests for RGB keyboard. */ -#include - #include "common.h" #include "console.h" #include "keyboard_backlight.h" @@ -15,6 +13,8 @@ #include "timer.h" #include "util.h" +#include + #define RGB_GRID0_COL 11 #define RGB_GRID0_ROW 6 #define RGB_GRID1_COL 11 diff --git a/test/rollback.c b/test/rollback.c index e2c1070ef4..6324fe86fc 100644 --- a/test/rollback.c +++ b/test/rollback.c @@ -3,12 +3,13 @@ * found in the LICENSE file. */ -#include #include "flash.h" #include "mpu.h" #include "string.h" #include "test_util.h" +#include + struct rollback_info { int region_0_offset; int region_1_offset; diff --git a/test/rollback_secret.c b/test/rollback_secret.c index 4813814f19..46ecfa587b 100644 --- a/test/rollback_secret.c +++ b/test/rollback_secret.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "mock/rollback_latest_mock.h" #include "rollback.h" #include "rollback_private.h" @@ -12,6 +10,8 @@ #include "system.h" #include "test_util.h" +#include + extern int get_latest_rollback(struct rollback_data *data); test_static int test_get_rollback_secret_latest_rollback_fail(void) diff --git a/test/rsa.c b/test/rsa.c index 2774e9edb4..a63b274711 100644 --- a/test/rsa.c +++ b/test/rsa.c @@ -5,8 +5,8 @@ * Tests RSA implementation. */ -#include "console.h" #include "common.h" +#include "console.h" #include "rsa.h" #include "test_util.h" #include "util.h" diff --git a/test/rtc.c b/test/rtc.c index 7c38c4fa6d..3a006498f2 100644 --- a/test/rtc.c +++ b/test/rtc.c @@ -5,8 +5,8 @@ * Tests for rtc time conversions */ -#include "console.h" #include "common.h" +#include "console.h" #include "rtc.h" #include "test_util.h" #include "util.h" diff --git a/test/sha256.c b/test/sha256.c index 4b5326d189..0387d23175 100644 --- a/test/sha256.c +++ b/test/sha256.c @@ -5,8 +5,8 @@ * Tests SHA256 implementation. */ -#include "console.h" #include "common.h" +#include "console.h" #include "sha256.h" #include "test_util.h" #include "util.h" diff --git a/test/shmalloc.c b/test/shmalloc.c index 899876ab43..f86efd4fa9 100644 --- a/test/shmalloc.c +++ b/test/shmalloc.c @@ -4,11 +4,6 @@ * found in the LICENSE file. */ -#include -#include -#include -#include - #include "common.h" #include "compile_time_macros.h" #include "console.h" @@ -16,6 +11,11 @@ #include "shared_mem.h" #include "test_util.h" +#include +#include +#include +#include + /* * Total size of memory in the malloc pool (shared between free and allocated * buffers. diff --git a/test/stdlib.c b/test/stdlib.c index 909502aee8..3034522c23 100644 --- a/test/stdlib.c +++ b/test/stdlib.c @@ -8,9 +8,9 @@ #include "common.h" #include "compiler.h" #include "console.h" -#include "system.h" #include "printf.h" #include "shared_mem.h" +#include "system.h" #include "test_util.h" #include "timer.h" #include "util.h" diff --git a/test/stillness_detector.c b/test/stillness_detector.c index 8858d751d7..2e82075e5e 100644 --- a/test/stillness_detector.c +++ b/test/stillness_detector.c @@ -3,10 +3,11 @@ * found in the LICENSE file. */ -#include "stillness_detector.h" #include "motion_sense.h" +#include "stillness_detector.h" #include "test_util.h" #include "timer.h" + #include /*****************************************************************************/ diff --git a/test/system_is_locked.c b/test/system_is_locked.c index 47a7977601..0a517f1509 100644 --- a/test/system_is_locked.c +++ b/test/system_is_locked.c @@ -3,12 +3,11 @@ * found in the LICENSE file. */ -#include "test_util.h" - #include "flash.h" #include "string.h" #include "system.h" #include "task.h" +#include "test_util.h" #include "write_protect.h" static bool write_protect_enabled; diff --git a/test/uptime.c b/test/uptime.c index 0b6c9b56e6..ab65820c18 100644 --- a/test/uptime.c +++ b/test/uptime.c @@ -3,8 +3,6 @@ * found in the LICENSE file. */ -#include - #include "common.h" #include "ec_commands.h" #include "host_command.h" @@ -12,6 +10,8 @@ #include "timer.h" #include "util.h" +#include + static bool get_ap_reset_stats_should_succeed = true; /* Mocks */ diff --git a/test/usb_pd_console.c b/test/usb_pd_console.c index cb2539fea4..dc574bccf0 100644 --- a/test/usb_pd_console.c +++ b/test/usb_pd_console.c @@ -10,11 +10,11 @@ #include "stdio.h" #include "stdlib.h" #include "string.h" -#include "usb_pe_sm.h" +#include "test_util.h" #include "usb_pd.h" +#include "usb_pe_sm.h" #include "usb_tc_sm.h" #include "util.h" -#include "test_util.h" /* Defined in implementation */ int command_pd(int argc, const char **argv); diff --git a/test/usb_pd_int.c b/test/usb_pd_int.c index 0072da851d..1b9336361d 100644 --- a/test/usb_pd_int.c +++ b/test/usb_pd_int.c @@ -4,11 +4,11 @@ * * Test USB-PD interrupt task. */ -#include "task.h" -#include "test_util.h" #include "mock/tcpc_mock.h" #include "mock/timer_mock.h" #include "mock/usb_mux_mock.h" +#include "task.h" +#include "test_util.h" #define PORT0 0 diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c index 8d75454c6a..c4d2c924e4 100644 --- a/test/usb_pe_drp.c +++ b/test/usb_pe_drp.c @@ -5,6 +5,13 @@ * Test USB PE module. */ #include "common.h" +#include "mock/charge_manager_mock.h" +#include "mock/dp_alt_mode_mock.h" +#include "mock/tcpc_mock.h" +#include "mock/usb_mux_mock.h" +#include "mock/usb_pd_dpm_mock.h" +#include "mock/usb_prl_mock.h" +#include "mock/usb_tc_sm_mock.h" #include "task.h" #include "test_util.h" #include "timer.h" @@ -13,13 +20,6 @@ #include "usb_pe.h" #include "usb_pe_sm.h" #include "usb_sm_checks.h" -#include "mock/charge_manager_mock.h" -#include "mock/usb_tc_sm_mock.h" -#include "mock/tcpc_mock.h" -#include "mock/usb_mux_mock.h" -#include "mock/usb_pd_dpm_mock.h" -#include "mock/dp_alt_mode_mock.h" -#include "mock/usb_prl_mock.h" /* Install Mock TCPC and MUX drivers */ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { diff --git a/test/usb_pe_drp_noextended.c b/test/usb_pe_drp_noextended.c index 6108458c9c..aa202a7dda 100644 --- a/test/usb_pe_drp_noextended.c +++ b/test/usb_pe_drp_noextended.c @@ -5,6 +5,9 @@ * Test USB PE module. */ #include "common.h" +#include "mock/tcpc_mock.h" +#include "mock/usb_mux_mock.h" +#include "mock/usb_tc_sm_mock.h" #include "task.h" #include "test_util.h" #include "timer.h" @@ -13,9 +16,6 @@ #include "usb_pe.h" #include "usb_pe_sm.h" #include "usb_sm_checks.h" -#include "mock/usb_tc_sm_mock.h" -#include "mock/tcpc_mock.h" -#include "mock/usb_mux_mock.h" /* Install Mock TCPC and MUX drivers */ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { diff --git a/test/usb_pe_drp_old.c b/test/usb_pe_drp_old.c index 0985a4cae9..4ea07c1ec9 100644 --- a/test/usb_pe_drp_old.c +++ b/test/usb_pe_drp_old.c @@ -7,6 +7,7 @@ #include "battery.h" #include "common.h" #include "gpio.h" +#include "mock/usb_prl_mock.h" #include "task.h" #include "test_util.h" #include "timer.h" @@ -19,7 +20,6 @@ #include "usb_prl_sm.h" #include "usb_sm_checks.h" #include "usb_tc_sm.h" -#include "mock/usb_prl_mock.h" #define pe_set_flag(_p, name) pe_set_fn((_p), (name##_FN)) #define pe_clr_flag(_p, name) pe_clr_fn((_p), (name##_FN)) diff --git a/test/usb_prl_noextended.c b/test/usb_prl_noextended.c index 956c0027f5..609de56d49 100644 --- a/test/usb_prl_noextended.c +++ b/test/usb_prl_noextended.c @@ -11,9 +11,9 @@ #include "test_util.h" #include "timer.h" #include "usb_emsg.h" -#include "usb_pd_test_util.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usb_pd_test_util.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" #include "usb_sm_checks.h" diff --git a/test/usb_prl_old.c b/test/usb_prl_old.c index 956c0027f5..609de56d49 100644 --- a/test/usb_prl_old.c +++ b/test/usb_prl_old.c @@ -11,9 +11,9 @@ #include "test_util.h" #include "timer.h" #include "usb_emsg.h" -#include "usb_pd_test_util.h" #include "usb_pd.h" #include "usb_pd_tcpm.h" +#include "usb_pd_test_util.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" #include "usb_sm_checks.h" diff --git a/test/usb_sm_checks.c b/test/usb_sm_checks.c index a8dbdad872..2204326d97 100644 --- a/test/usb_sm_checks.c +++ b/test/usb_sm_checks.c @@ -9,10 +9,10 @@ #include "test_util.h" #include "timer.h" #include "usb_pd.h" +#include "usb_pd_test_util.h" #include "usb_sm.h" #include "usb_tc_sm.h" #include "util.h" -#include "usb_pd_test_util.h" #include "vpd_api.h" #ifdef CONFIG_USB_TYPEC_SM diff --git a/test/usb_sm_framework_h3.c b/test/usb_sm_framework_h3.c index 20f9b706c6..704bae8f9b 100644 --- a/test/usb_sm_framework_h3.c +++ b/test/usb_sm_framework_h3.c @@ -9,10 +9,10 @@ #include "test_util.h" #include "timer.h" #include "usb_pd.h" +#include "usb_pd_test_util.h" #include "usb_sm.h" #include "usb_tc_sm.h" #include "util.h" -#include "usb_pd_test_util.h" #include "vpd_api.h" /* diff --git a/test/usb_tcpmv2_compliance_common.c b/test/usb_tcpmv2_compliance_common.c index 9f839ecf1c..ed46d7baa0 100644 --- a/test/usb_tcpmv2_compliance_common.c +++ b/test/usb_tcpmv2_compliance_common.c @@ -10,8 +10,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" uint32_t rdo = RDO_FIXED(1, 500, 500, 0); uint32_t pdo = PDO_FIXED(5000, 3000, diff --git a/test/usb_tcpmv2_td_pd_ll_e3.c b/test/usb_tcpmv2_td_pd_ll_e3.c index f239c87885..8e1d46c15e 100644 --- a/test/usb_tcpmv2_td_pd_ll_e3.c +++ b/test/usb_tcpmv2_td_pd_ll_e3.c @@ -8,8 +8,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" /***************************************************************************** * TD.PD.LL.E3. Soft Reset Usage diff --git a/test/usb_tcpmv2_td_pd_ll_e4.c b/test/usb_tcpmv2_td_pd_ll_e4.c index f315fc2a63..fea5e3dc81 100644 --- a/test/usb_tcpmv2_td_pd_ll_e4.c +++ b/test/usb_tcpmv2_td_pd_ll_e4.c @@ -8,8 +8,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" /***************************************************************************** * TD.PD.LL.E4. Hard Reset Usage diff --git a/test/usb_tcpmv2_td_pd_ll_e5.c b/test/usb_tcpmv2_td_pd_ll_e5.c index 7c7446a7b3..49b76fd44e 100644 --- a/test/usb_tcpmv2_td_pd_ll_e5.c +++ b/test/usb_tcpmv2_td_pd_ll_e5.c @@ -8,8 +8,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" /***************************************************************************** * TD.PD.LL.E5. Soft Reset diff --git a/test/usb_tcpmv2_td_pd_other.c b/test/usb_tcpmv2_td_pd_other.c index 18477ac825..62e051a7a9 100644 --- a/test/usb_tcpmv2_td_pd_other.c +++ b/test/usb_tcpmv2_td_pd_other.c @@ -8,9 +8,9 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" -#include "usb_tc_sm.h" #include "usb_prl_sm.h" +#include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" int test_connect_as_nonpd_sink(void) { diff --git a/test/usb_tcpmv2_td_pd_src3_e1.c b/test/usb_tcpmv2_td_pd_src3_e1.c index 4f5637ccd2..9c79ea741a 100644 --- a/test/usb_tcpmv2_td_pd_src3_e1.c +++ b/test/usb_tcpmv2_td_pd_src3_e1.c @@ -8,8 +8,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" #define BUFFER_SIZE 100 diff --git a/test/usb_tcpmv2_td_pd_src3_e7.c b/test/usb_tcpmv2_td_pd_src3_e7.c index 40f65f2b9a..e94b017cc6 100644 --- a/test/usb_tcpmv2_td_pd_src3_e7.c +++ b/test/usb_tcpmv2_td_pd_src3_e7.c @@ -4,13 +4,13 @@ */ #include "battery.h" +#include "driver/tcpm/tcpci.h" #include "mock/tcpci_i2c_mock.h" #include "task.h" -#include "driver/tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" #define BUFFER_SIZE 100 diff --git a/test/usb_tcpmv2_td_pd_src3_e8.c b/test/usb_tcpmv2_td_pd_src3_e8.c index 8686226a50..a19f6c8c82 100644 --- a/test/usb_tcpmv2_td_pd_src3_e8.c +++ b/test/usb_tcpmv2_td_pd_src3_e8.c @@ -4,13 +4,13 @@ */ #include "battery.h" +#include "driver/tcpm/tcpci.h" #include "mock/tcpci_i2c_mock.h" #include "task.h" -#include "driver/tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" #define BUFFER_SIZE 100 diff --git a/test/usb_tcpmv2_td_pd_src3_e9.c b/test/usb_tcpmv2_td_pd_src3_e9.c index 59b7a22d74..833a9c056f 100644 --- a/test/usb_tcpmv2_td_pd_src3_e9.c +++ b/test/usb_tcpmv2_td_pd_src3_e9.c @@ -4,13 +4,13 @@ */ #include "battery.h" +#include "driver/tcpm/tcpci.h" #include "mock/tcpci_i2c_mock.h" #include "task.h" -#include "driver/tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" #define BUFFER_SIZE 100 diff --git a/test/usb_tcpmv2_td_pd_src_e1.c b/test/usb_tcpmv2_td_pd_src_e1.c index cfb62764b2..10166c4b65 100644 --- a/test/usb_tcpmv2_td_pd_src_e1.c +++ b/test/usb_tcpmv2_td_pd_src_e1.c @@ -8,8 +8,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" /***************************************************************************** * TD.PD.SRC.E1 Source Capabilities sent timely diff --git a/test/usb_tcpmv2_td_pd_src_e2.c b/test/usb_tcpmv2_td_pd_src_e2.c index cabba40bb9..fbe3e4bce7 100644 --- a/test/usb_tcpmv2_td_pd_src_e2.c +++ b/test/usb_tcpmv2_td_pd_src_e2.c @@ -8,8 +8,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" #define BUFFER_SIZE 100 diff --git a/test/usb_tcpmv2_td_pd_src_e5.c b/test/usb_tcpmv2_td_pd_src_e5.c index ef40ee75cf..bc391104ab 100644 --- a/test/usb_tcpmv2_td_pd_src_e5.c +++ b/test/usb_tcpmv2_td_pd_src_e5.c @@ -8,8 +8,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" /***************************************************************************** * TD.PD.SRC.E5 SenderResponseTimer Timeout - Request diff --git a/test/usb_tcpmv2_td_pd_vndi3_e3.c b/test/usb_tcpmv2_td_pd_vndi3_e3.c index 8157835328..590c02a0e8 100644 --- a/test/usb_tcpmv2_td_pd_vndi3_e3.c +++ b/test/usb_tcpmv2_td_pd_vndi3_e3.c @@ -8,8 +8,8 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" -#include "usb_tcpmv2_compliance.h" #include "usb_tc_sm.h" +#include "usb_tcpmv2_compliance.h" uint32_t vdo = VDO(USB_SID_PD, 1, VDO_SVDM_VERS(VDM_VER20) | CMD_DISCOVER_IDENT); diff --git a/test/usb_test/device_configuration.c b/test/usb_test/device_configuration.c index 06c71fefd9..94496fa0fc 100644 --- a/test/usb_test/device_configuration.c +++ b/test/usb_test/device_configuration.c @@ -5,13 +5,14 @@ */ #include -#include -#include #include #include #include #include +#include +#include + /* Options */ static uint16_t vid = 0x18d1; /* Google */ static uint16_t pid = 0x5014; /* Cr50 */ diff --git a/test/usb_typec_ctvpd.c b/test/usb_typec_ctvpd.c index 71d543cec0..17c3452a62 100644 --- a/test/usb_typec_ctvpd.c +++ b/test/usb_typec_ctvpd.c @@ -10,12 +10,12 @@ #include "test_util.h" #include "timer.h" #include "usb_pd.h" -#include "usb_sm.h" -#include "usb_tc_sm.h" -#include "util.h" #include "usb_pd_tcpm.h" #include "usb_pd_test_util.h" +#include "usb_sm.h" #include "usb_sm_checks.h" +#include "usb_tc_sm.h" +#include "util.h" #include "vpd_api.h" #define PORT0 0 diff --git a/test/utils_str.c b/test/utils_str.c index 36ad63989e..4b2e3d4427 100644 --- a/test/utils_str.c +++ b/test/utils_str.c @@ -7,8 +7,8 @@ #include "common.h" #include "console.h" -#include "system.h" #include "printf.h" +#include "system.h" #include "test_util.h" #include "timer.h" #include "util.h" diff --git a/test/vboot.c b/test/vboot.c index f75208de90..caa3d2d7cb 100644 --- a/test/vboot.c +++ b/test/vboot.c @@ -7,10 +7,10 @@ #include "common.h" #include "rsa.h" -#include "test_util.h" -#include "vboot.h" #include "rsa2048-3.h" #include "rwsig.h" +#include "test_util.h" +#include "vboot.h" struct vboot_key { struct vb21_packed_key vb21_key; diff --git a/test/version.c b/test/version.c index 9731863f29..fea691eef7 100644 --- a/test/version.c +++ b/test/version.c @@ -9,8 +9,8 @@ #include "ec_commands.h" #include "stddef.h" #include "system.h" -#include "util.h" #include "test_util.h" +#include "util.h" /* * Tests that fw version adheres to the expected format. diff --git a/test/vpd_api.c b/test/vpd_api.c index 51a2e76cd6..e159dcb066 100644 --- a/test/vpd_api.c +++ b/test/vpd_api.c @@ -3,10 +3,10 @@ * found in the LICENSE file. */ +#include "console.h" +#include "driver/tcpm/tcpm.h" #include "registers.h" #include "vpd_api.h" -#include "driver/tcpm/tcpm.h" -#include "console.h" /* * Polarity based on 'DFP Perspective' (see table USB Type-C Cable and Connector * Specification) -- cgit v1.2.1 From 42c5871768555b69026135cdbfc846744ace27e8 Mon Sep 17 00:00:00 2001 From: Andrew McRae Date: Wed, 30 Nov 2022 13:09:06 +1100 Subject: nissa: Allow sub-board support to be optional Make sub-board support a config option so that variants can have fixed hardware configurations without having to deal with sub-board options. BUG=b:260779639 TEST=build nissa boards BRANCH=none Change-Id: Icac6767a9405362ba229626a1038e2bc4c42895c Signed-off-by: Andrew McRae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4059932 Reviewed-by: Peter Marheine --- zephyr/program/nissa/CMakeLists.txt | 4 ++-- zephyr/program/nissa/Kconfig | 9 +++++++++ zephyr/program/nissa/src/common.c | 10 ++++++++++ zephyr/program/nissa/src/sub_board.c | 10 ---------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index 101146507b..967fff2229 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -8,7 +8,7 @@ find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") zephyr_include_directories(include) zephyr_library_sources("src/common.c") -zephyr_library_sources("src/sub_board.c") +zephyr_library_sources_ifdef(CONFIG_NISSA_SUB_BOARD "src/sub_board.c") zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ "src/board_power.c") if(DEFINED CONFIG_BOARD_NIVVIKS) @@ -96,4 +96,4 @@ if(DEFINED CONFIG_BOARD_XIVUR) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "xivur/src/fan.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "xivur/src/usbc.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "xivur/src/charger.c") -endif() \ No newline at end of file +endif() diff --git a/zephyr/program/nissa/Kconfig b/zephyr/program/nissa/Kconfig index 2eb694577d..a7fb4c666a 100644 --- a/zephyr/program/nissa/Kconfig +++ b/zephyr/program/nissa/Kconfig @@ -2,6 +2,15 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +config NISSA_SUB_BOARD + bool "Nissa sub-board support" + default y + help + Enable the sub-board support for Nissa boards. + This uses a common fw_config bitfield to select + one of a number of option sub-boards with different + hardware configurations. + config BOARD_NIVVIKS bool "Google Nivviks Board" help diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c index 155dc541d4..d437bfca47 100644 --- a/zephyr/program/nissa/src/common.c +++ b/zephyr/program/nissa/src/common.c @@ -187,3 +187,13 @@ __override int pd_is_valid_input_voltage(int mv) return true; } #endif + +/* Trigger shutdown by enabling the Z-sleep circuit */ +__override void board_hibernate_late(void) +{ + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_slp_z), 1); + /* + * The system should hibernate, but there may be + * a small delay, so return. + */ +} diff --git a/zephyr/program/nissa/src/sub_board.c b/zephyr/program/nissa/src/sub_board.c index 830e361ac1..e8e9648ba6 100644 --- a/zephyr/program/nissa/src/sub_board.c +++ b/zephyr/program/nissa/src/sub_board.c @@ -286,13 +286,3 @@ static void board_init(void) #endif } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); - -/* Trigger shutdown by enabling the Z-sleep circuit */ -__override void board_hibernate_late(void) -{ - gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_slp_z), 1); - /* - * The system should hibernate, but there may be - * a small delay, so return. - */ -} -- cgit v1.2.1 From eea5b0dfff88ec51f23b5d4f1290dcfcc327c8df Mon Sep 17 00:00:00 2001 From: Rob Barnes Date: Tue, 29 Nov 2022 23:27:11 +0000 Subject: console: Don't call console_buf_notify_chars from isr Check if in isr before calling uart_write_char in uart_write_char. console_buf_notify_chars attempts to acquire a mutex, which isn't allowed from an isr. BUG=None BRANCH=None TEST=Pass rw_safe_mode tests Change-Id: If5a5a4c99fae9342f2e1e3c1bf0c841e5490f692 Signed-off-by: Rob Barnes Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4065004 Code-Coverage: Zoss Reviewed-by: Jack Rosenthal --- zephyr/shim/src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c index 6e78fc29c8..fa6dc5a613 100644 --- a/zephyr/shim/src/console.c +++ b/zephyr/shim/src/console.c @@ -322,7 +322,7 @@ void uart_write_char(char c) { uart_poll_out(uart_shell_dev, c); - if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE)) + if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE) && !k_is_in_isr()) console_buf_notify_chars(&c, 1); } -- cgit v1.2.1 From 2888f43dfd8b1b58021ad650888efd5af641641c Mon Sep 17 00:00:00 2001 From: Deepti Deshatty Date: Mon, 21 Nov 2022 16:26:22 +0530 Subject: common/charger: read charger parameters using primary charger when no active charger is connected to the system, retrieve charger parameters using primary charger(0). This avoids setting the 'problems_exist' flag which allows charger_task() to sleep for a period of CHARGE_POLL_PERIOD_VERY_LONG in susped scenarios. BUG=b:258613461 BRANCH=none TEST=zmake build craask, EC S0ix power is optimized Change-Id: Ic177acb74f943ec8b3eafaae7bf6b56db758d6e5 Signed-off-by: Deepti Deshatty Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4050321 Code-Coverage: Diana Z Reviewed-by: Diana Z Reviewed-by: Daisuke Nojiri --- common/charger.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/charger.c b/common/charger.c index af9b246adb..198dc0db8c 100644 --- a/common/charger.c +++ b/common/charger.c @@ -97,8 +97,12 @@ void charger_get_params(struct charger_params *chg) { int chgnum = 0; - if (IS_ENABLED(CONFIG_OCPC)) + if (IS_ENABLED(CONFIG_OCPC)) { chgnum = charge_get_active_chg_chip(); + /* set to CHARGE_PORT_NONE when no charger connected */ + if (chgnum < 0) + chgnum = 0; + } memset(chg, 0, sizeof(*chg)); -- cgit v1.2.1 From d6d1090a803313be6eaed5099a5fc3d6323db217 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Thu, 24 Nov 2022 15:54:58 +0000 Subject: zephyr: usb_muxes, bb_retimer: fix kconfig dependencies Fix Kconfig dependencies for usb_muxes and bb_retimer_usb_mux so that we can safely drop the compiler guards and the source is included only if the necessary structures are defined. BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri Change-Id: I9ab501a81549ef10b6db7f221517ff7cce619a8f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054625 Code-Coverage: Zoss Reviewed-by: Jeremy Bettis --- zephyr/Kconfig.retimer | 4 ++++ zephyr/Kconfig.usb_mux | 1 + zephyr/shim/src/bb_retimer_usb_mux.c | 8 -------- zephyr/shim/src/usb_muxes.c | 8 -------- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/zephyr/Kconfig.retimer b/zephyr/Kconfig.retimer index 9ce134dc13..3a052f1f1a 100644 --- a/zephyr/Kconfig.retimer +++ b/zephyr/Kconfig.retimer @@ -6,6 +6,8 @@ if PLATFORM_EC_USBC config PLATFORM_EC_USBC_RETIMER_INTEL_BB bool "Support Intel Burnside Bridge retimer" + depends on PLATFORM_EC_USB_MUX + depends on DT_HAS_INTEL_JHL8040R_ENABLED select PLATFORM_EC_USB_PD_USB4 select PLATFORM_EC_USB_PD_TBT_COMPAT_MODE help @@ -29,6 +31,8 @@ config PLATFORM_EC_USBC_RETIMER_INTEL_BB config PLATFORM_EC_USBC_RETIMER_INTEL_HB bool "Support Intel Hayden Bridge retimer" + depends on PLATFORM_EC_USB_MUX + depends on DT_HAS_INTEL_JHL8040R_ENABLED select PLATFORM_EC_USB_PD_USB4 select PLATFORM_EC_USB_PD_TBT_COMPAT_MODE help diff --git a/zephyr/Kconfig.usb_mux b/zephyr/Kconfig.usb_mux index 6f4e31a2cf..376a28f9b2 100644 --- a/zephyr/Kconfig.usb_mux +++ b/zephyr/Kconfig.usb_mux @@ -7,6 +7,7 @@ if PLATFORM_EC_USBC menuconfig PLATFORM_EC_USB_MUX bool "USB muxes" default y + depends on DT_HAS_CROS_EC_USB_MUX_CHAIN_ENABLED help Enables support for USB muxes. These allow multiplexing diff --git a/zephyr/shim/src/bb_retimer_usb_mux.c b/zephyr/shim/src/bb_retimer_usb_mux.c index 2f45a5ee0f..b0e3944528 100644 --- a/zephyr/shim/src/bb_retimer_usb_mux.c +++ b/zephyr/shim/src/bb_retimer_usb_mux.c @@ -9,12 +9,6 @@ #include #include -/** - * This prevents creating struct usb_mux bb_controls[] for platforms that didn't - * migrate USB mux configuration to DTS yet. - */ -#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) - BB_RETIMER_CHECK_SAME_CONTROLS(BB_RETIMER_INSTANCES_LIST) /** @@ -36,5 +30,3 @@ BB_RETIMER_CHECK_SAME_CONTROLS(BB_RETIMER_INSTANCES_LIST) BB_CONTROLS_CONST struct bb_usb_control bb_controls[] = { USB_MUX_BB_RETIMERS_CONTROLS_ARRAY }; - -#endif /* #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) */ diff --git a/zephyr/shim/src/usb_muxes.c b/zephyr/shim/src/usb_muxes.c index af86cec0cd..b3854e2ca8 100644 --- a/zephyr/shim/src/usb_muxes.c +++ b/zephyr/shim/src/usb_muxes.c @@ -9,12 +9,6 @@ #include #include -/** - * This prevents creating struct usb_mux usb_muxes[] for platforms that didn't - * migrate USB mux configuration to DTS yet. - */ -#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) - /** * @brief Check if @p mux_id is not part of @p chain_id or if @p chain_id USBC * port is the same as @p mux_port. Result ends with && to construct @@ -96,5 +90,3 @@ BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT); * MAYBE_CONST struct usb_mux USB_MUX_NODE_ = { ... }; */ USB_MUX_FOREACH_MUX(USB_MUX_DEFINE) - -#endif /* #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) */ -- cgit v1.2.1 From 48bb2e2b15c20cf647a19fb080cc54856544e1fe Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 6 Oct 2022 16:07:39 -0700 Subject: util: Use libec for EC_CMD_ADD_ENTROPY BRANCH=none BUG=b:144959033, b:116060828 TEST=rm -rf build && make BOARD=host utils TEST=tast run firmware.FpAddEntropy Force-Relevant-Builds: all Cq-Depend: chromium:3139188 Signed-off-by: Tom Hughes Change-Id: Id5cebe9dbc174d486474c5e9fd40b8f517b05e19 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3938416 Reviewed-by: Bobby Casey Reviewed-by: Andrea Grandi Code-Coverage: Zoss --- util/ectool.cc | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/util/ectool.cc b/util/ectool.cc index 8f2a1c153f..fd27105d1f 100644 --- a/util/ectool.cc +++ b/util/ectool.cc @@ -36,6 +36,8 @@ #include "tablet_mode.h" #include "usb_pd.h" +#include + /* Maximum flash size (16 MB, conservative) */ #define MAX_FLASH_SIZE 0x1000000 @@ -567,39 +569,24 @@ int cmd_adc_read(int argc, char *argv[]) int cmd_add_entropy(int argc, char *argv[]) { - struct ec_params_rollback_add_entropy p; - int rv; - int tries = 100; /* Wait for 10 seconds at most */ - + bool reset = false; if (argc >= 2 && !strcmp(argv[1], "reset")) - p.action = ADD_ENTROPY_RESET_ASYNC; - else - p.action = ADD_ENTROPY_ASYNC; - - rv = ec_command(EC_CMD_ADD_ENTROPY, 0, &p, sizeof(p), NULL, 0); - - if (rv != EC_RES_SUCCESS) - goto out; - - while (tries--) { - usleep(100000); - - p.action = ADD_ENTROPY_GET_RESULT; - rv = ec_command(EC_CMD_ADD_ENTROPY, 0, &p, sizeof(p), NULL, 0); + reset = true; - if (rv == EC_RES_SUCCESS) { - printf("Entropy added successfully\n"); - return EC_RES_SUCCESS; - } + ec::AddEntropyCommand add_entropy_command(reset); + if (!add_entropy_command.Run(comm_get_fd())) { + fprintf(stderr, "Failed to run addentropy command\n"); + return -1; + } - /* Abort if EC returns an error other than EC_RES_BUSY. */ - if (rv <= -EECRESULT && rv != -EECRESULT - EC_RES_BUSY) - goto out; + int rv = add_entropy_command.Result(); + if (rv != EC_RES_SUCCESS) { + rv = -EECRESULT - add_entropy_command.Result(); + fprintf(stderr, "Failed to add entropy: %d\n", rv); + return rv; } - rv = -EECRESULT - EC_RES_TIMEOUT; -out: - fprintf(stderr, "Failed to add entropy: %d\n", rv); + printf("Entropy added successfully\n"); return rv; } -- cgit v1.2.1 From 72d07d9ef2018cbb88757ad3b708a136d36c8a1a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 29 Sep 2022 10:05:53 -0700 Subject: cmake: Add ARMv7-M CMake toolchain file BRANCH=none BUG=b:248508087, b:254530679 TEST=Build googletest with the ARMv7-M toolchain: cmake -GNinja -Dgtest_disable_pthreads=ON \ -DCMAKE_TOOLCHAIN_FILE=~/chromiumos/src/platform/ec/cmake/toolchain-armv7m.cmake \ -DCMAKE_INSTALL_PREFIX=~/chromiumos/src/third_party/tmp .. ninja ninja install Signed-off-by: Tom Hughes Change-Id: If31e1937f444f44f153fde9c8aadcb1824e12ee8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3929249 Reviewed-by: Andrea Grandi Reviewed-by: Bobby Casey Code-Coverage: Zoss --- cmake/toolchain-armv7m.cmake | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cmake/toolchain-armv7m.cmake diff --git a/cmake/toolchain-armv7m.cmake b/cmake/toolchain-armv7m.cmake new file mode 100644 index 0000000000..641b0debf2 --- /dev/null +++ b/cmake/toolchain-armv7m.cmake @@ -0,0 +1,38 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR arm) + +set(PREFIX armv7m-cros-eabi-) +set(CMAKE_SYSROOT /usr/armv7m-cros-eabi/) + +set(CMAKE_C_COMPILER ${PREFIX}clang) +set(CMAKE_CXX_COMPILER ${PREFIX}clang++) +set(CMAKE_LINKER ${PREFIX}ld.lld) +set(CMAKE_AR ${PREFIX}ar) +set(CMAKE_NM ${PREFIX}nm) +set(CMAKE_OBJCOPY ${PREFIX}objcopy) +set(CMAKE_OBJDUMP ${PREFIX}objdump) +set(CMAKE_RANLIB ${PREFIX}ranlib) +set(CMAKE_READELF ${PREFIX}readelf) + +add_compile_options(-Oz) + +add_compile_options(-flto) +add_link_options(-flto) + +# TODO(b/234507656): Remove this include when clang is fixed. +add_compile_options(-I/usr/armv7m-cros-eabi/usr/include/c++/v1) +# TODO(b/254916723): Remove this define when clang is fixed. +add_compile_options(-D_GNU_SOURCE) +add_link_options(-lclang_rt.builtins-armv7m) +add_link_options(-lnosys) + +set(CMAKE_POSITION_INDEPENDENT_CODE OFF) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -- cgit v1.2.1 From aa40b859b3a73e5a205bc561c1a29eff38485461 Mon Sep 17 00:00:00 2001 From: Rajesh Kumar Date: Mon, 28 Nov 2022 12:43:48 -0800 Subject: mtlrvp: Enable S0ix error recovery conf This enables S0ix error recovery for intel rvp platform using native power sequencing. BUG=none BRANCH=none TEST=zmake build mtlrvpp_npcx 'powerd_dbus_suspend' on AP and observed timeout and hang detected through EC logs. Signed-off-by: Rajesh Kumar Change-Id: If2b92b5e631703efeeb6be9b88b8469a5dd9aefe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4062576 Reviewed-by: Vijay P Hiremath Code-Coverage: Zoss Reviewed-by: Fabio Baltieri --- zephyr/program/intelrvp/zephyr_ap_pwrseq.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf b/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf index 1ef365a8fa..d33b9bc963 100644 --- a/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf +++ b/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf @@ -7,3 +7,4 @@ CONFIG_AP_PWRSEQ=y CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y CONFIG_AP_PWRSEQ_S0IX=y +CONFIG_AP_PWRSEQ_S0IX_ERROR_RECOVERY=y -- cgit v1.2.1