From 84f610eec742b9f84a0b11052377847679cf9276 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Fri, 5 May 2023 09:33:28 -0600 Subject: vbus measure: cleanup config options The VBUS measure config options are mutually exclusive. For boards that enable a charger with VBUS measure support and have a FUSB302 TCPC, both CONFIG_USB_PD_VBUS_MEASURE_CHARGER and CONFIG_USB_PD_VBUS_MEASURE_TCPC options were getting set. The charge manager code gives priority to CONFIG_USB_PD_VBUS_MEASURE_CHARGER so make this the default for boards that meet the criteria above. BUG=none TEST=compare_builds.sh TEST=zmake compare-builds -a Change-Id: I2beec45436c8810cd469f791228863e041b6724e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4508664 Tested-by: Keith Short Reviewed-by: Diana Z Commit-Queue: Keith Short --- zephyr/program/intelrvp/adlrvp/prj.conf | 1 - 1 file changed, 1 deletion(-) (limited to 'zephyr/program') diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf index 9c372bc9ae..ef0584c4bd 100644 --- a/zephyr/program/intelrvp/adlrvp/prj.conf +++ b/zephyr/program/intelrvp/adlrvp/prj.conf @@ -40,7 +40,6 @@ CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y 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 -- cgit v1.2.1 From e9b1ee0e784aad16a65eeb370bcaf49d585c6666 Mon Sep 17 00:00:00 2001 From: Tommy Chung Date: Thu, 27 Apr 2023 20:50:36 +0800 Subject: yavilla: Update keyboard config Update keyboard config for yavilla, including vivaldi type, no numeric pad and 24 pins in total at connector. BUG=b:279353236 TEST=make sure all top row function keys work correctly and keyboard factory test works. Change-Id: Ia4a9d683162fcb472b3704db8f67d2315011a49b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4482505 Reviewed-by: Devin Lu Tested-by: Tommy Chung Reviewed-by: Peter Marheine Commit-Queue: Tommy Chung --- zephyr/program/nissa/yavilla/src/keyboard.c | 72 ++++++++++------------------- 1 file changed, 25 insertions(+), 47 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/nissa/yavilla/src/keyboard.c b/zephyr/program/nissa/yavilla/src/keyboard.c index 93db22132f..d942405faa 100644 --- a/zephyr/program/nissa/yavilla/src/keyboard.c +++ b/zephyr/program/nissa/yavilla/src/keyboard.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The ChromiumOS Authors +/* Copyright 2023 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -14,24 +14,8 @@ 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 yavilla_kb_w_kb_light = { - .num_top_row_keys = 13, +static const struct ec_response_keybd_config kb_tablet_present = { + .num_top_row_keys = 10, .action_keys = { TK_BACK, /* T1 */ TK_REFRESH, /* T2 */ @@ -40,18 +24,16 @@ static const struct ec_response_keybd_config yavilla_kb_w_kb_light = { 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 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ }, - .capabilities = KEYBD_CAP_NUMERIC_KEYPAD, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, + /* No function keys, no numeric keypad */ }; -static const struct ec_response_keybd_config yavilla_kb_wo_kb_light = { - .num_top_row_keys = 13, +static const struct ec_response_keybd_config kb_tablet_absent = { + .num_top_row_keys = 10, .action_keys = { TK_BACK, /* T1 */ TK_REFRESH, /* T2 */ @@ -60,14 +42,11 @@ static const struct ec_response_keybd_config yavilla_kb_wo_kb_light = { 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 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ }, - .capabilities = KEYBD_CAP_NUMERIC_KEYPAD, + /* No function keys, no numeric keypad and no screenlock key */ }; __override const struct ec_response_keybd_config * @@ -75,12 +54,12 @@ board_vivaldi_keybd_config(void) { uint32_t val; - cros_cbi_get_fw_config(FW_KB_BACKLIGHT, &val); + cros_cbi_get_fw_config(FW_TABLET, &val); - if (val == FW_KB_BACKLIGHT_OFF) - return &yavilla_kb_wo_kb_light; + if (val == FW_TABLET_PRESENT) + return &kb_tablet_present; else - return &yavilla_kb_w_kb_light; + return &kb_tablet_absent; } /* @@ -109,17 +88,16 @@ DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST); /* * Map keyboard connector pins to EC GPIO pins for factory test. * Pins mapped to {-1, -1} are skipped. - * The connector has 30 pins total, and there is no pin 0. + * The connector has 24 pins total, and there is no pin 0. */ const int keyboard_factory_scan_pins[][2] = { { -1, -1 }, { GPIO_KSOH, 4 }, { GPIO_KSOH, 0 }, { GPIO_KSOH, 1 }, - { GPIO_KSOH, 3 }, { GPIO_KSOH, 2 }, { -1, -1 }, { -1, -1 }, - { GPIO_KSOL, 5 }, { GPIO_KSOL, 6 }, { -1, -1 }, { GPIO_KSOL, 3 }, - { GPIO_KSOL, 2 }, { GPIO_KSI, 0 }, { GPIO_KSOL, 1 }, { GPIO_KSOL, 4 }, - { GPIO_KSI, 3 }, { GPIO_KSI, 2 }, { GPIO_KSOL, 0 }, { GPIO_KSI, 5 }, - { GPIO_KSI, 4 }, { GPIO_KSOL, 7 }, { GPIO_KSI, 6 }, { GPIO_KSI, 7 }, - { GPIO_KSI, 1 }, { -1, -1 }, { GPIO_KSOH, 5 }, { -1, -1 }, - { GPIO_KSOH, 6 }, { -1, -1 }, { -1, -1 }, + { GPIO_KSOH, 3 }, { GPIO_KSOH, 2 }, { GPIO_KSOL, 5 }, { GPIO_KSOL, 6 }, + { GPIO_KSOL, 3 }, { GPIO_KSOL, 2 }, { GPIO_KSI, 0 }, { GPIO_KSOL, 1 }, + { GPIO_KSOL, 4 }, { GPIO_KSI, 3 }, { GPIO_KSI, 2 }, { GPIO_KSOL, 0 }, + { GPIO_KSI, 5 }, { GPIO_KSI, 4 }, { GPIO_KSOL, 7 }, { GPIO_KSI, 6 }, + { GPIO_KSI, 7 }, { GPIO_KSI, 1 }, { -1, -1 }, { -1, -1 }, + { -1, -1 }, }; const int keyboard_factory_scan_pins_used = ARRAY_SIZE(keyboard_factory_scan_pins); -- cgit v1.2.1 From 8dc42c6e8a66e3f4252069bc993cada6b58728c9 Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Fri, 5 May 2023 16:43:31 +0800 Subject: corsola: fix auto-reload GPIO config when FRS mode enabled When FRS enabled, the GPIO config auto-reload is enabled as well. We should ensure in this period, the GPIO config auto-reload is working as expected. Sets the following accordingly: GPIO1: received VBUS SNK enabled, keep high, other commands, keep low GPIO2: received VBUS SRC enabled, keep high, other commands, keep low BUG=b:281177690 TEST=trigger S0->S5 with a FRS hub with power attached, and EN_SNK is enabled (rt1718s_gpio) BRANCH=none Change-Id: I991e779baa991dd3f1fa9d181728459cf1778461 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4507010 Commit-Queue: Eric Yilun Lin Reviewed-by: Sung-Chi Li Reviewed-by: Ting Shen Tested-by: Eric Yilun Lin --- zephyr/program/corsola/src/npcx_usbc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/corsola/src/npcx_usbc.c b/zephyr/program/corsola/src/npcx_usbc.c index 10a977696e..a03e659171 100644 --- a/zephyr/program/corsola/src/npcx_usbc.c +++ b/zephyr/program/corsola/src/npcx_usbc.c @@ -94,11 +94,18 @@ __override int board_rt1718s_init(int port) /* 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, + RT1718S_GPIO_VBUS_CTRL_FRS_RX_VBUS, 0)); - RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO2_VBUS_CTRL, - RT1718S_GPIO2_VBUS_CTRL_FRS_RX_VBUS, - 0xFF)); + /* GPIO1 EN_SNK high when received TCPCI SNK enabled command */ + RETURN_ERROR(rt1718s_update_bits8( + port, RT1718S_GPIO1_VBUS_CTRL, + RT1718S_GPIO_VBUS_CTRL_ENA_SNK_VBUS_GPIO, 0xFF)); + /* GPIO2 EN_SRC high when received TCPCI SRC enabled command */ + RETURN_ERROR(rt1718s_update_bits8( + port, RT1718S_GPIO2_VBUS_CTRL, + RT1718S_GPIO_VBUS_CTRL_FRS_RX_VBUS | + RT1718S_GPIO_VBUS_CTRL_ENA_SRC_VBUS_GPIO, + 0xFF)); /* Trigger GPIO 1/2 change when FRS signal received */ RETURN_ERROR(rt1718s_update_bits8( -- cgit v1.2.1 From 7834245c40904dafda75f5102b089aa201644171 Mon Sep 17 00:00:00 2001 From: Diana Z Date: Wed, 19 Apr 2023 14:33:16 -0600 Subject: Frostflow: Always initialize retimer when enabled The A1 retimer will be enabled anytime the board boots. Ensure that the tuning parameters are applied every time the retimer is enabled again since they clear when the retimer is disabled. BUG=b:273849234,b:280957965 TEST=on frostflow, run suspend stress test and verify retimer initialization always reports success talking to the chip, spot check tuning register contents Change-Id: I147e6e7ad09f3279a77fe3f0757cf6ed140b058c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4450966 Reviewed-by: Chao Gui Tested-by: Diana Z Commit-Queue: Diana Z Reviewed-by: Robert Zieba --- .../program/skyrim/frostflow/src/usb_mux_config.c | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c index b73c6370b8..a46668b65c 100644 --- a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c +++ b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c @@ -5,6 +5,7 @@ /* Frostflow board-specific USB-C mux configuration */ +#include "ap_power/ap_power.h" #include "chipset.h" #include "common.h" #include "console.h" @@ -175,8 +176,26 @@ void baseboard_a1_retimer_setup(void) } DECLARE_DEFERRED(baseboard_a1_retimer_setup); -void board_chipset_startup(void) +test_export_static void board_resume_change(struct ap_power_ev_callback *cb, + struct ap_power_ev_data data) { - hook_call_deferred(&baseboard_a1_retimer_setup_data, 500 * MSEC); + switch (data.event) { + default: + return; + + case AP_POWER_RESUME: + /* Any retimer tuning can be done after the retimer turns on */ + hook_call_deferred(&baseboard_a1_retimer_setup_data, 20 * MSEC); + break; + } +} + +void board_callback_init(void) +{ + static struct ap_power_ev_callback cb; + + /* Setup a resume callback */ + ap_power_ev_init_callback(&cb, board_resume_change, AP_POWER_RESUME); + ap_power_ev_add_callback(&cb); } -DECLARE_HOOK(HOOK_INIT, board_chipset_startup, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_INIT, board_callback_init, HOOK_PRIO_DEFAULT); -- cgit v1.2.1 From 1dbb4df1fb4a11c9c0b6c95c34a4b6dedbd4e32f Mon Sep 17 00:00:00 2001 From: Diana Z Date: Thu, 20 Apr 2023 10:57:48 -0600 Subject: Skyrim: Keep retimer enabled in suspend The A1 retimer needs to remain enabled in suspend in order to prevent issues with USB detection on resume. Enable and disable on the transition into/out of S5 instead. BUG=b:273849234,b:280957965 TEST=on frostflow, ensure USB file transfer is able to resume after suspend Change-Id: I0186d54a76c14f3d0141fbeec75ed5b13aa599d7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4455299 Tested-by: Diana Z Commit-Queue: Diana Z Reviewed-by: Robert Zieba --- zephyr/program/skyrim/frostflow/src/usb_mux_config.c | 4 ++-- zephyr/program/skyrim/src/power_signals.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c index a46668b65c..c7c03bc8cb 100644 --- a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c +++ b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c @@ -183,7 +183,7 @@ test_export_static void board_resume_change(struct ap_power_ev_callback *cb, default: return; - case AP_POWER_RESUME: + case AP_POWER_STARTUP: /* Any retimer tuning can be done after the retimer turns on */ hook_call_deferred(&baseboard_a1_retimer_setup_data, 20 * MSEC); break; @@ -195,7 +195,7 @@ void board_callback_init(void) static struct ap_power_ev_callback cb; /* Setup a resume callback */ - ap_power_ev_init_callback(&cb, board_resume_change, AP_POWER_RESUME); + ap_power_ev_init_callback(&cb, board_resume_change, AP_POWER_STARTUP); ap_power_ev_add_callback(&cb); } DECLARE_HOOK(HOOK_INIT, board_callback_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/skyrim/src/power_signals.c b/zephyr/program/skyrim/src/power_signals.c index 5814359606..ede5d1ec75 100644 --- a/zephyr/program/skyrim/src/power_signals.c +++ b/zephyr/program/skyrim/src/power_signals.c @@ -65,9 +65,13 @@ baseboard_suspend_change(struct ap_power_ev_callback *cb, return; case AP_POWER_SUSPEND: - /* Disable display backlight and retimer */ + /* Disable display backlight */ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl), 1); + break; + + case AP_POWER_SHUTDOWN: + /* Retimer disable */ ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0); break; @@ -75,6 +79,9 @@ baseboard_suspend_change(struct ap_power_ev_callback *cb, /* Enable retimer and display backlight */ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl), 0); + break; + + case AP_POWER_STARTUP: ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1); /* Any retimer tuning can be done after the retimer turns on */ break; @@ -106,7 +113,8 @@ test_export_static void baseboard_init(void) /* Setup a suspend/resume callback */ ap_power_ev_init_callback(&cb, baseboard_suspend_change, - AP_POWER_RESUME | AP_POWER_SUSPEND); + AP_POWER_STARTUP | AP_POWER_SHUTDOWN | + 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)); -- cgit v1.2.1 From 7e22a760d9ba3e2d255d98c2ca2163652c5003ea Mon Sep 17 00:00:00 2001 From: wangganxiang Date: Fri, 5 May 2023 16:14:05 +0800 Subject: starmie: add battery supported add new battery celxpert b300049 BUG=b:274723043 TEST=zmake build starmie The battery information is normal. Change-Id: I047e594b1143f8558bb0ddd3f0ad6afb96018421 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4509009 Tested-by: Ganxiang Wang Reviewed-by: Ruihai Zhou Commit-Queue: Ganxiang Wang Reviewed-by: Sung-Chi Li --- zephyr/program/corsola/starmie/project.overlay | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/corsola/starmie/project.overlay b/zephyr/program/corsola/starmie/project.overlay index d8c6a48631..2358026e2d 100644 --- a/zephyr/program/corsola/starmie/project.overlay +++ b/zephyr/program/corsola/starmie/project.overlay @@ -20,8 +20,8 @@ / { batteries { - default_battery: c235 { - compatible = "celxpert,c235-41", "battery-smart"; + default_battery: b300049 { + compatible = "celxpert,b300049", "battery-smart"; }; }; gpio-interrupts { -- cgit v1.2.1 From 4e47e1382ffa3f3f82291e62f0ba0315e6decbcf Mon Sep 17 00:00:00 2001 From: Tommy Chung Date: Tue, 25 Apr 2023 15:31:47 +0800 Subject: yavilla: Update led behavior Yavilla has convertible sku with power led, and the behavior of power led is described as following: Power state in S0: White on. Power state in suspend: Blink white (1 sec. on, 1 sec. off). Power state in G3/S5: Off. Also, C0/C1 port is on right/left port on Yavilla respectively. Set ports to correct ports. BUG=b:273791621 TEST=make sure power led works correctly. Change-Id: I433def8dcfddafbd5e5b3601105621d3aa041e07 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4474088 Tested-by: Tommy Chung Reviewed-by: Devin Lu Commit-Queue: Tommy Chung Reviewed-by: Peter Marheine --- zephyr/program/nissa/yavilla/gpio.dtsi | 3 + zephyr/program/nissa/yavilla/project.conf | 1 + zephyr/program/nissa/yavilla/src/led.c | 94 ++++++++++++++++++++++++++++--- 3 files changed, 90 insertions(+), 8 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/nissa/yavilla/gpio.dtsi b/zephyr/program/nissa/yavilla/gpio.dtsi index d063b897d9..a18e674b11 100644 --- a/zephyr/program/nissa/yavilla/gpio.dtsi +++ b/zephyr/program/nissa/yavilla/gpio.dtsi @@ -209,6 +209,9 @@ gpio_c0_charger_led_amber_l: c0_charger_led_amber_l { gpios = <&gpioj 7 GPIO_OUTPUT_HIGH>; }; + gpio_power_led_white_l: power_led_white_l { + gpios = <&gpioa 3 GPIO_OUTPUT_HIGH>; + }; gpio_ec_kso_02_inv: ec_kso_02_inv { gpios = <&gpioksol 2 GPIO_OUTPUT_HIGH>; enum-name = "GPIO_KBD_KSO2"; diff --git a/zephyr/program/nissa/yavilla/project.conf b/zephyr/program/nissa/yavilla/project.conf index bbabd05b37..4c89a45147 100644 --- a/zephyr/program/nissa/yavilla/project.conf +++ b/zephyr/program/nissa/yavilla/project.conf @@ -31,6 +31,7 @@ CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y # LED CONFIG_PLATFORM_EC_LED_PWM=n +CONFIG_PLATFORM_EC_LED_ONOFF_STATES=n CONFIG_NISSA_SUB_BOARD=n diff --git a/zephyr/program/nissa/yavilla/src/led.c b/zephyr/program/nissa/yavilla/src/led.c index a1ae6b24cf..5bbc9d15b1 100644 --- a/zephyr/program/nissa/yavilla/src/led.c +++ b/zephyr/program/nissa/yavilla/src/led.c @@ -7,6 +7,7 @@ #include "charge_manager.h" #include "charge_state.h" #include "chipset.h" +#include "cros_cbi.h" #include "ec_commands.h" #include "gpio.h" #include "hooks.h" @@ -15,9 +16,16 @@ #include +#include + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + #define BAT_LED_ON 0 #define BAT_LED_OFF 1 +#define PWR_LED_ON 0 +#define PWR_LED_OFF 1 + #define BATT_LOW_BCT 10 #define LED_TICKS_PER_CYCLE 4 @@ -25,8 +33,11 @@ #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 }; +static bool power_led_support; + +const enum ec_led_id supported_led_ids[] = { EC_LED_ID_RIGHT_LED, + EC_LED_ID_LEFT_LED, + EC_LED_ID_POWER_LED }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); @@ -37,16 +48,16 @@ enum led_color { LED_COLOR_COUNT /* Number of colors, not a color itself */ }; -enum led_port { LEFT_PORT = 0, RIGHT_PORT }; +enum led_port { RIGHT_PORT = 0, LEFT_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) { + if (port == RIGHT_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) { + } else if (port == LEFT_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); } @@ -69,6 +80,22 @@ static void led_set_color_battery(int port, enum led_color color) } } +static void led_set_color_power(enum led_color color) +{ + switch (color) { + case LED_OFF: + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_white_l), + PWR_LED_OFF); + break; + case LED_WHITE: + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_white_l), + PWR_LED_ON); + break; + default: + break; + } +} + void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { switch (led_id) { @@ -80,6 +107,9 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) brightness_range[EC_LED_COLOR_WHITE] = 1; brightness_range[EC_LED_COLOR_AMBER] = 1; break; + case EC_LED_ID_POWER_LED: + brightness_range[EC_LED_COLOR_WHITE] = 1; + break; default: break; } @@ -104,6 +134,12 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) else led_set_color_battery(RIGHT_PORT, LED_OFF); break; + case EC_LED_ID_POWER_LED: + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_power(LED_WHITE); + else + led_set_color_power(LED_OFF); + break; default: return EC_ERROR_PARAM1; } @@ -135,11 +171,11 @@ static void led_set_battery(void) battery_ticks++; /* - * Override battery LEDs for Yavilla, Yavilla is non-power LED - * design, blinking both two side battery white LEDs to indicate + * Override battery LEDs for Yavilla without power led support, + * blinking both two side battery white LEDs to indicate * system suspend with non-charging state. */ - if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && + if (!power_led_support && chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && charge_get_state() != PWR_STATE_CHARGE) { suspend_ticks++; @@ -223,9 +259,51 @@ static void led_set_battery(void) } } +static void led_set_power(void) +{ + static int power_ticks; + + power_ticks++; + + if (chipset_in_state(CHIPSET_STATE_ON)) + led_set_color_power(LED_WHITE); + else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) + led_set_color_power((power_ticks % LED_TICKS_PER_CYCLE_S3 < + POWER_LED_ON_S3_TICKS) ? + LED_WHITE : + LED_OFF); + else + led_set_color_power(LED_OFF); +} + +static void power_led_check(void) +{ + int ret; + uint32_t val; + + /* + * Retrieve the tablet config. + */ + 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_PRESENT) + power_led_support = true; + else /* Clameshell */ + power_led_support = false; +} +DECLARE_HOOK(HOOK_INIT, power_led_check, HOOK_PRIO_DEFAULT); + /* Called by hook task every TICK(IT83xx 500ms) */ static void led_tick(void) { led_set_battery(); + + if (power_led_support && + led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) + led_set_power(); } DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT); -- cgit v1.2.1 From 26b71ae693f63662de42d14c2d673c14b9c3e62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Dul=C4=99ba?= Date: Tue, 25 Apr 2023 14:38:54 +0000 Subject: winterhold: Move fan duty logic to a separate file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is needed for an upcoming fan test written using zephyr test suite. The test framework expects the board specific fan logic to be present in the fan.c file, move it there to make it happy. BUG=b:279493434 TEST=emerge-skyrim chromeos-zephyr TEST=./twister -i -T zephyr/test/skyrim/ Change-Id: I9d776dcf012f6c047eceebb45e4f76c40b17715f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4479371 Reviewed-by: Keith Short Reviewed-by: Diana Z Reviewed-by: Robert Zieba Commit-Queue: Kornel Dulęba Tested-by: Kornel Dulęba --- zephyr/program/skyrim/winterhold/CMakeLists.txt | 3 + zephyr/program/skyrim/winterhold/src/fan.c | 90 +++++++++++++++++++++++++ zephyr/program/skyrim/winterhold/src/thermal.c | 81 ---------------------- 3 files changed, 93 insertions(+), 81 deletions(-) create mode 100644 zephyr/program/skyrim/winterhold/src/fan.c (limited to 'zephyr/program') diff --git a/zephyr/program/skyrim/winterhold/CMakeLists.txt b/zephyr/program/skyrim/winterhold/CMakeLists.txt index 0596978c05..632f11d8f1 100644 --- a/zephyr/program/skyrim/winterhold/CMakeLists.txt +++ b/zephyr/program/skyrim/winterhold/CMakeLists.txt @@ -12,3 +12,6 @@ zephyr_library_sources( "src/alt_charger.c" "src/thermal.c" ) + +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CUSTOM_FAN_DUTY_CONTROL + "src/fan.c") diff --git a/zephyr/program/skyrim/winterhold/src/fan.c b/zephyr/program/skyrim/winterhold/src/fan.c new file mode 100644 index 0000000000..a5061a660f --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/fan.c @@ -0,0 +1,90 @@ +/* Copyright 2023 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 "fan.h" +#include "math_util.h" +#include "thermal.h" + +#include + +#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_THERMAL, format, ##args) + +K_TIMER_DEFINE(grace_period_timer, NULL, NULL); + +enum fan_status board_override_fan_control_duty(int ch) +{ + int duty, rpm_diff, deviation, duty_step; + struct fan_data *data = &fan_data[ch]; + int rpm_actual = data->rpm_actual; + int rpm_target = data->rpm_target; + + /* This works with one fan only. */ + if (ch != 0) { + CPRINTS("Only FAN0 is supported!"); + return FAN_STATUS_FRUSTRATED; + } + + /* Wait for fan RPM to catch up after its duty has been changed. */ + if (k_timer_remaining_ticks(&grace_period_timer) != 0) + return FAN_STATUS_LOCKED; + + duty = fan_get_duty(ch); + if (duty == 0 && rpm_target == 0) + return FAN_STATUS_STOPPED; + + /* + * If the current RPM is close enough to the target just leave it. + * It's always going to fluctuate a bit anyway. + */ + deviation = fans[ch].rpm->rpm_deviation * rpm_target / 100; + rpm_diff = rpm_target - rpm_actual; + if (rpm_diff > deviation) { + /* Can't set duty higher than 100%... */ + if (duty == 100) + return FAN_STATUS_FRUSTRATED; + } else if (rpm_diff < -deviation) { + /* Can't set duty lower than 1%... */ + if (duty == 1 && rpm_target != 0) + return FAN_STATUS_FRUSTRATED; + } else { + return FAN_STATUS_LOCKED; + } + + /* + * The rpm_diff -> duty_step conversion is specific to a specific + * whiterun fan. + * It has been determined empirically. + */ + if (ABS(rpm_diff) >= 2500) { + duty_step = 35; + k_timer_start(&grace_period_timer, K_MSEC(800), K_NO_WAIT); + } else if (ABS(rpm_diff) >= 2000) { + duty_step = 28; + k_timer_start(&grace_period_timer, K_MSEC(800), K_NO_WAIT); + } else if (ABS(rpm_diff) >= 1000) { + duty_step = 14; + k_timer_start(&grace_period_timer, K_MSEC(800), K_NO_WAIT); + } else if (ABS(rpm_diff) >= 500) { + duty_step = 6; + k_timer_start(&grace_period_timer, K_MSEC(800), K_NO_WAIT); + } else if (ABS(rpm_diff) >= 250) { + duty_step = 3; + k_timer_start(&grace_period_timer, K_MSEC(600), K_NO_WAIT); + } else { + duty_step = 1; + k_timer_start(&grace_period_timer, K_MSEC(600), K_NO_WAIT); + } + + if (rpm_diff > 0) + duty = MIN(duty + duty_step, 100); + else + duty = MAX(duty - duty_step, 1); + + fan_set_duty(ch, duty); + + return FAN_STATUS_CHANGING; +} diff --git a/zephyr/program/skyrim/winterhold/src/thermal.c b/zephyr/program/skyrim/winterhold/src/thermal.c index 00e162e45a..0ccd9dd9e2 100644 --- a/zephyr/program/skyrim/winterhold/src/thermal.c +++ b/zephyr/program/skyrim/winterhold/src/thermal.c @@ -4,11 +4,9 @@ */ #include "body_detection.h" -#include "fan.h" #include "hooks.h" #include "host_command.h" #include "lid_switch.h" -#include "math_util.h" #include "temp_sensor/temp_sensor.h" #include "thermal.h" @@ -211,82 +209,3 @@ static void detect_temp_change(void) } } DECLARE_HOOK(HOOK_SECOND, detect_temp_change, HOOK_PRIO_TEMP_SENSOR_DONE); - -#ifdef CONFIG_PLATFORM_EC_CUSTOM_FAN_DUTY_CONTROL - -K_TIMER_DEFINE(grace_period_timer, NULL, NULL); - -enum fan_status board_override_fan_control_duty(int ch) -{ - int duty, rpm_diff, deviation, duty_step; - struct fan_data *data = &fan_data[ch]; - int rpm_actual = data->rpm_actual; - int rpm_target = data->rpm_target; - - /* This works with one fan only. */ - if (ch != 0) { - CPRINTS("Only FAN0 is supported!"); - return FAN_STATUS_FRUSTRATED; - } - - /* Wait for fan RPM to catch up after its duty has been changed. */ - if (k_timer_remaining_ticks(&grace_period_timer) != 0) - return FAN_STATUS_LOCKED; - - duty = fan_get_duty(ch); - if (duty == 0 && rpm_target == 0) - return FAN_STATUS_STOPPED; - - /* - * If the current RPM is close enough to the target just leave it. - * It's always going to fluctuate a bit anyway. - */ - deviation = fans[ch].rpm->rpm_deviation * rpm_target / 100; - rpm_diff = rpm_target - rpm_actual; - if (rpm_diff > deviation) { - /* Can't set duty higher than 100%... */ - if (duty == 100) - return FAN_STATUS_FRUSTRATED; - } else if (rpm_diff < -deviation) { - /* Can't set duty lower than 1%... */ - if (duty == 1 && rpm_target != 0) - return FAN_STATUS_FRUSTRATED; - } else { - return FAN_STATUS_LOCKED; - } - - /* - * The rpm_diff -> duty_step conversion is specific to a specific - * whiterun fan. - * It has been determined empirically. - */ - if (ABS(rpm_diff) >= 2500) { - duty_step = 35; - k_timer_start(&grace_period_timer, K_MSEC(800), K_NO_WAIT); - } else if (ABS(rpm_diff) >= 2000) { - duty_step = 28; - k_timer_start(&grace_period_timer, K_MSEC(800), K_NO_WAIT); - } else if (ABS(rpm_diff) >= 1000) { - duty_step = 14; - k_timer_start(&grace_period_timer, K_MSEC(800), K_NO_WAIT); - } else if (ABS(rpm_diff) >= 500) { - duty_step = 6; - k_timer_start(&grace_period_timer, K_MSEC(800), K_NO_WAIT); - } else if (ABS(rpm_diff) >= 250) { - duty_step = 3; - k_timer_start(&grace_period_timer, K_MSEC(600), K_NO_WAIT); - } else { - duty_step = 1; - k_timer_start(&grace_period_timer, K_MSEC(600), K_NO_WAIT); - } - - if (rpm_diff > 0) - duty = MIN(duty + duty_step, 100); - else - duty = MAX(duty - duty_step, 1); - - fan_set_duty(ch, duty); - - return FAN_STATUS_CHANGING; -} -#endif -- cgit v1.2.1 From cd82d004731312765d64c93b78057aa38296a432 Mon Sep 17 00:00:00 2001 From: Rajesh Kumar Date: Thu, 16 Feb 2023 21:25:55 -0800 Subject: rex: Enable system boot time logging This CL enables system boot time logging support for rex platform. BUG=b:249163956 BRANCH=none TEST='ectool boottime' AP console command is used to fetch data 'reboot' on AP console to trigger warm reboot 'apshutdown' on EC console to trigger cold reboot Change-Id: Ice9e5122f69c6427a36532b6a00e3015dd06b312 Signed-off-by: Rajesh Kumar Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4263104 Reviewed-by: Vijay P Hiremath Reviewed-by: Brandon Breitenstein Reviewed-by: Tristan Honscheid Reviewed-by: Wonkyu Kim --- zephyr/program/rex/program.conf | 3 +++ 1 file changed, 3 insertions(+) (limited to 'zephyr/program') diff --git a/zephyr/program/rex/program.conf b/zephyr/program/rex/program.conf index 0e572e373c..0dd7f48994 100644 --- a/zephyr/program/rex/program.conf +++ b/zephyr/program/rex/program.conf @@ -137,3 +137,6 @@ CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y CONFIG_PLATFORM_EC_ALS_TCS3400=y + +# System Boot Time +CONFIG_SYSTEM_BOOT_TIME_LOGGING=y -- cgit v1.2.1 From 24d911de09145dcb98644e811b1cdcbf1d3f1e85 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Tue, 9 May 2023 09:24:04 -0600 Subject: zephyr: mtlrvp: Enable VBUS_MEASURE_CHARGER option The legacy config.h silently enables using the charger to measure VBUS when a compatible charger is enabled. Explicitly enable CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER to remove the hidden dependency on config.h BUG=none TEST=zmake compare-builds mtlrvpp_mchp mtlrvpp_npcx Change-Id: I34d49c09506eefa506304fee404bb699f7c655e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4518121 Auto-Submit: Keith Short Tested-by: Keith Short Reviewed-by: Diana Z Commit-Queue: Diana Z --- zephyr/program/intelrvp/mtlrvp/prj.conf | 1 + 1 file changed, 1 insertion(+) (limited to 'zephyr/program') diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf index ccc27e04f7..8fe89d712a 100644 --- a/zephyr/program/intelrvp/mtlrvp/prj.conf +++ b/zephyr/program/intelrvp/mtlrvp/prj.conf @@ -46,6 +46,7 @@ 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_VBUS_MEASURE_CHARGER=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 -- cgit v1.2.1 From ca51664045529ad6525c900e4f28ffcb3710e4db Mon Sep 17 00:00:00 2001 From: Logan_Liao Date: Fri, 28 Apr 2023 17:54:43 +0800 Subject: markarth: Modify VBUS monitor from TCPC. Due to ISL9241 have 200~300mv tolerance, cause 5V test item fail(read 4.4V, measure 4.6V). This patch modify to TCPC monitor Vbus. BUG=b:278988137 BRANCH=skyrim TEST=test monitor VBUS from TCPC success. Change-Id: I53d1fe92595ff65b5a00434c0dc20e638d0ae85c Signed-off-by: Logan_Liao Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4486661 Reviewed-by: Diana Z Reviewed-by: Josh Tsai Tested-by: Logan Liao Commit-Queue: Logan Liao Reviewed-by: Logan Liao --- zephyr/program/skyrim/markarth/project.conf | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'zephyr/program') diff --git a/zephyr/program/skyrim/markarth/project.conf b/zephyr/program/skyrim/markarth/project.conf index 4f00aa256c..4e9e437875 100644 --- a/zephyr/program/skyrim/markarth/project.conf +++ b/zephyr/program/skyrim/markarth/project.conf @@ -27,3 +27,7 @@ CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y # Fan CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y + +# Markarth modify monitor VBUS from TCPC +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y -- cgit v1.2.1 From 0fbfb5b1f045ba68eb6c15b553403325dff69de1 Mon Sep 17 00:00:00 2001 From: Devin Lu Date: Wed, 29 Mar 2023 17:08:26 +0800 Subject: yaviks: Limit C1 current with low power charger Yaviks C1 port is OCPC (One Charger IC Per Type-C) architecture, The charging current is controlled by increasing Vsys. However, the charger SM5803 is not limit current while Vsys increasing, we can see the voltage drops to ~3.48V to cause C1 port brownout with low power charger (5V). To avoid C1 port brownout at low power charger connected. Limit charge current to 2A. BUG=b:261102000 TEST=Left battery ~50% with sink device. Toggle 10 times power role swap. Yaviks c2c charging is not brownout on C1 port. Change-Id: I361eda581d3611e176c75804131b3a17343d85c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4379827 Tested-by: Devin Lu Reviewed-by: Peter Marheine Commit-Queue: Devin Lu --- zephyr/program/nissa/yaviks/project.conf | 3 +++ zephyr/program/nissa/yaviks/src/usbc.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'zephyr/program') diff --git a/zephyr/program/nissa/yaviks/project.conf b/zephyr/program/nissa/yaviks/project.conf index 2e52005cad..06c63967c6 100644 --- a/zephyr/program/nissa/yaviks/project.conf +++ b/zephyr/program/nissa/yaviks/project.conf @@ -45,3 +45,6 @@ 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 + +# Charger +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=0 diff --git a/zephyr/program/nissa/yaviks/src/usbc.c b/zephyr/program/nissa/yaviks/src/usbc.c index c9950ae73b..a4cb140059 100644 --- a/zephyr/program/nissa/yaviks/src/usbc.c +++ b/zephyr/program/nissa/yaviks/src/usbc.c @@ -235,6 +235,25 @@ __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) } } +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + /* + * b:213937755: Yaviks C1 port is OCPC (One Charger IC Per Type-C) + * architecture, The charging current is controlled by increasing Vsys. + * However, the charger SM5803 is not limit current while Vsys + * increasing, we can see the current overshoot to ~3.6A to cause + * C1 port brownout with low power charger (5V). To avoid C1 port + * brownout at low power charger connected. Limit charge current to 2A. + */ + if (charge_mv <= 5000 && port == 1) + charge_ma = MIN(charge_ma, 2000); + else + charge_ma = charge_ma * 96 / 100; + + charge_set_input_current_limit(charge_ma, charge_mv); +} + void board_reset_pd_mcu(void) { /* -- cgit v1.2.1 From be430430bbb9c28c43e3747168778be716232a67 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Fri, 28 Apr 2023 16:17:34 -0700 Subject: myst: add daughter board configs Adding devicetree for SKU A and SKU B BUG=b:275610001 BRANCH=none TEST=zmake build myst LOW_COVERAGE_REASON=this is still part of the initial image Change-Id: I5997ca139b26664e6215782c61b9bbe57262ac74 Signed-off-by: Boris Mittelberg Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4492007 Reviewed-by: caveh jalali Reviewed-by: Diana Z Reviewed-by: Robert Zieba Reviewed-by: Keith Short --- zephyr/program/myst/CMakeLists.txt | 1 + zephyr/program/myst/i2c.dtsi | 28 ++++++--- zephyr/program/myst/include/usbc_config.h | 20 +++++++ zephyr/program/myst/myst/CMakeLists.txt | 2 +- zephyr/program/myst/myst/include/usb_mux_config.h | 11 ++++ zephyr/program/myst/myst/src/ppc_config.c | 29 ---------- zephyr/program/myst/myst/src/usb_mux_config.c | 70 +++++++++++++++++++++++ zephyr/program/myst/program.conf | 3 +- zephyr/program/myst/src/usbc_config.c | 38 +++++++++--- zephyr/program/myst/usbc.dtsi | 2 - 10 files changed, 155 insertions(+), 49 deletions(-) create mode 100644 zephyr/program/myst/include/usbc_config.h create mode 100644 zephyr/program/myst/myst/include/usb_mux_config.h delete mode 100644 zephyr/program/myst/myst/src/ppc_config.c create mode 100644 zephyr/program/myst/myst/src/usb_mux_config.c (limited to 'zephyr/program') diff --git a/zephyr/program/myst/CMakeLists.txt b/zephyr/program/myst/CMakeLists.txt index c339dbeef7..ece440da75 100644 --- a/zephyr/program/myst/CMakeLists.txt +++ b/zephyr/program/myst/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.20.5) find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +cros_ec_library_include_directories(include) zephyr_library_sources("src/common.c") zephyr_library_sources("src/power_signals.c") diff --git a/zephyr/program/myst/i2c.dtsi b/zephyr/program/myst/i2c.dtsi index 58ba31911b..905cbc7f80 100644 --- a/zephyr/program/myst/i2c.dtsi +++ b/zephyr/program/myst/i2c.dtsi @@ -76,15 +76,16 @@ tcpc_port0: rt1716@70 { compatible = "richtek,rt1716"; reg = <0x70>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - /* TBD */ + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V)>; irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; }; - ppc_port0: ktu1125@78 { + ppc_port0: ktu1125@38 { compatible = "kinetic,ktu1125"; status = "okay"; - reg = <0x78>; + reg = <0x38>; }; }; @@ -105,7 +106,7 @@ reg = <0x40>; }; - tcpc_port1: rt1718s-tcpc@40 { + tcpc_rt1718_port1: rt1718s-tcpc@40 { compatible = "richtek,rt1718s-tcpc"; reg = <0x40>; tcpc-flags = <( @@ -117,15 +118,28 @@ * the "named-gpios" node will be dealt with at a later date. */ irq-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>; + is-alt; }; - ppc_port1: nx20p348x@71 { + ppc_nx20p_port1: nx20p348x@71 { compatible = "nxp,nx20p348x"; status = "okay"; reg = <0x71>; + is-alt; + }; + + tcpc_ps8815_port1: ps8xxx@b { + compatible = "parade,ps8xxx"; + reg = <0xb>; + is-alt; }; - /* TODO: add SKU-B DB b/275610001 */ + ppc_ktu1125_port1: ktu1125@38 { + compatible = "kinetic,ktu1125"; + status = "okay"; + reg = <0x38>; + is-alt; + }; }; &i2c_ctrl1 { diff --git a/zephyr/program/myst/include/usbc_config.h b/zephyr/program/myst/include/usbc_config.h new file mode 100644 index 0000000000..1c983ba8e9 --- /dev/null +++ b/zephyr/program/myst/include/usbc_config.h @@ -0,0 +1,20 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Myst type-c definitions */ + +#ifndef __CROS_EC_USBC_CONFIG_H +#define __CROS_EC_USBC_CONFIG_H + +void ppc_interrupt(enum gpio_signal signal); + +/* 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); + +#endif /* __CROS_EC_USBC_CONFIG_H */ diff --git a/zephyr/program/myst/myst/CMakeLists.txt b/zephyr/program/myst/myst/CMakeLists.txt index 9dc79f913e..09e319e8c4 100644 --- a/zephyr/program/myst/myst/CMakeLists.txt +++ b/zephyr/program/myst/myst/CMakeLists.txt @@ -4,6 +4,6 @@ cros_ec_library_include_directories_ifdef(CONFIG_BOARD_MYST include) zephyr_library_sources( - "src/ppc_config.c" "src/keyboard.c" + "src/usb_mux_config.c" ) diff --git a/zephyr/program/myst/myst/include/usb_mux_config.h b/zephyr/program/myst/myst/include/usb_mux_config.h new file mode 100644 index 0000000000..848753ba67 --- /dev/null +++ b/zephyr/program/myst/myst/include/usb_mux_config.h @@ -0,0 +1,11 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __MYST_USB_MUX_CONFIG_H +#define __MYST_USB_MUX_CONFIG_H + +uint32_t get_io_db_type_from_cached_cbi(void); + +#endif /* __MYST_USB_MUX_CONFIG_H */ diff --git a/zephyr/program/myst/myst/src/ppc_config.c b/zephyr/program/myst/myst/src/ppc_config.c deleted file mode 100644 index a16e38a25d..0000000000 --- a/zephyr/program/myst/myst/src/ppc_config.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2023 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Myst 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) - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - break; - - case GPIO_USB_C1_PPC_INT_ODL: - break; - - default: - break; - } -} diff --git a/zephyr/program/myst/myst/src/usb_mux_config.c b/zephyr/program/myst/myst/src/usb_mux_config.c new file mode 100644 index 0000000000..19eacbf989 --- /dev/null +++ b/zephyr/program/myst/myst/src/usb_mux_config.c @@ -0,0 +1,70 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Myst board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "hooks.h" +#include "usb_mux.h" +#include "usb_mux_config.h" +#include "usbc/ppc.h" +#include "usbc/tcpci.h" +#include "usbc/usb_muxes.h" +#include "usbc_config.h" + +#include +#include + +LOG_MODULE_DECLARE(myst, CONFIG_MYST_LOG_LEVEL); + +uint32_t get_io_db_type_from_cached_cbi(void) +{ + uint32_t io_db_type; + int ret = cros_cbi_get_fw_config(FW_IO_DB, &io_db_type); + + if (ret != 0) { + io_db_type = FW_IO_DB_NONE; + LOG_ERR("Failed to get IO_DB value: %d", ret); + } + + return io_db_type; +} + +__override uint8_t board_get_usb_pd_port_count(void) +{ + if (get_io_db_type_from_cached_cbi() == FW_IO_DB_NONE) + return CONFIG_USB_PD_PORT_MAX_COUNT - 1; + else + return CONFIG_USB_PD_PORT_MAX_COUNT; +} + +static void setup_mux(void) +{ + switch (get_io_db_type_from_cached_cbi()) { + default: + case FW_IO_DB_NONE: + LOG_INF("USB DB: not connected"); + break; + + case FW_IO_DB_SKU_A: + LOG_INF("USB DB: Setting SKU_A DB"); + TCPC_ENABLE_ALTERNATE_BY_NODELABEL(USBC_PORT_C1, + tcpc_rt1718_port1); + PPC_ENABLE_ALTERNATE_BY_NODELABEL(USBC_PORT_C1, + ppc_nx20p_port1); + break; + + case FW_IO_DB_SKU_B: + LOG_INF("USB DB: Setting SKU_B DB"); + TCPC_ENABLE_ALTERNATE_BY_NODELABEL(USBC_PORT_C1, + tcpc_ps8815_port1); + PPC_ENABLE_ALTERNATE_BY_NODELABEL(USBC_PORT_C1, + ppc_ktu1125_port1); + break; + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/myst/program.conf b/zephyr/program/myst/program.conf index 49d4cc00ad..0b275b16fa 100644 --- a/zephyr/program/myst/program.conf +++ b/zephyr/program/myst/program.conf @@ -78,6 +78,7 @@ CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 # USB-C CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y +CONFIG_PLATFORM_EC_USBC_PPC=y CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y @@ -90,7 +91,7 @@ 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_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=y CONFIG_PLATFORM_EC_USB_PD_USB4=n CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y diff --git a/zephyr/program/myst/src/usbc_config.c b/zephyr/program/myst/src/usbc_config.c index c3aafd9da9..bc76a66be3 100644 --- a/zephyr/program/myst/src/usbc_config.c +++ b/zephyr/program/myst/src/usbc_config.c @@ -14,14 +14,18 @@ #include "cros_board_info.h" #include "cros_cbi.h" #include "driver/charger/isl9241.h" +#include "driver/ppc/ktu1125_public.h" +#include "driver/ppc/nx20p348x.h" #include "driver/tcpm/rt1718s.h" #include "driver/usb_mux/amd_fp6.h" #include "gpio/gpio_int.h" #include "hooks.h" #include "power.h" #include "usb_mux.h" +#include "usb_mux_config.h" #include "usb_pd_tcpm.h" #include "usbc/usb_muxes.h" +#include "usbc_config.h" #include "usbc_ppc.h" #include @@ -29,13 +33,6 @@ #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 usbc_interrupt_init(void) { /* Enable PPC interrupts. */ @@ -57,7 +54,7 @@ int board_set_active_charge_port(int port) CPRINTSUSB("Disabling all charger ports"); /* Disable all ports. */ - for (i = 0; i < ppc_cnt; i++) { + for (i = 0; i < board_get_usb_pd_port_count(); i++) { /* * Do not return early if one fails otherwise we can * get into a boot loop assertion failure. @@ -83,7 +80,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_usb_pd_port_count(); i++) { if (i == port) continue; @@ -121,6 +118,29 @@ void usb_pd_soc_interrupt(enum gpio_signal signal) CPRINTSUSB("SOC PD Interrupt"); } +void ppc_interrupt(enum gpio_signal signal) +{ + uint32_t io_db_type = get_io_db_type_from_cached_cbi(); + + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + ktu1125_interrupt(USBC_PORT_C0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + if (io_db_type == FW_IO_DB_SKU_A) { + nx20p348x_interrupt(USBC_PORT_C1); + } + if (io_db_type == FW_IO_DB_SKU_B) { + ktu1125_interrupt(USBC_PORT_C1); + } + break; + + default: + break; + } +} + /* Round up 3250 max current to multiple of 128mA for ISL9241 AC prochot. */ static void charger_prochot_init_isl9241(void) { diff --git a/zephyr/program/myst/usbc.dtsi b/zephyr/program/myst/usbc.dtsi index 8e8579d328..b63c0347bd 100644 --- a/zephyr/program/myst/usbc.dtsi +++ b/zephyr/program/myst/usbc.dtsi @@ -24,8 +24,6 @@ compatible = "named-usbc-port"; reg = <1>; bc12 = <&bc12_port1>; - tcpc = <&tcpc_port1>; - ppc = <&ppc_port1>; usb-mux-chain-1-anx { compatible = "cros-ec,usb-mux-chain"; usb-muxes = <&amd_fp6_port1>; -- cgit v1.2.1 From 8d162bcda7ba68ebc0092773fcee675ed57e4ff9 Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Tue, 9 May 2023 06:50:45 -0700 Subject: myst: move all CBI fields to board-level files moving the PPC interrupt handler to be under program/myst/myst BUG=b:281645793 BRANCH=none TEST=zmake build myst Change-Id: Ia4a5daab6d280f2f8116486378925b4432a58731 Signed-off-by: Boris Mittelberg Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516860 Reviewed-by: Diana Z --- zephyr/program/myst/myst/include/usb_mux_config.h | 11 ----------- zephyr/program/myst/myst/src/usb_mux_config.c | 24 ++++++++++++++++++++++- zephyr/program/myst/src/usbc_config.c | 24 ----------------------- 3 files changed, 23 insertions(+), 36 deletions(-) delete mode 100644 zephyr/program/myst/myst/include/usb_mux_config.h (limited to 'zephyr/program') diff --git a/zephyr/program/myst/myst/include/usb_mux_config.h b/zephyr/program/myst/myst/include/usb_mux_config.h deleted file mode 100644 index 848753ba67..0000000000 --- a/zephyr/program/myst/myst/include/usb_mux_config.h +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2023 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __MYST_USB_MUX_CONFIG_H -#define __MYST_USB_MUX_CONFIG_H - -uint32_t get_io_db_type_from_cached_cbi(void); - -#endif /* __MYST_USB_MUX_CONFIG_H */ diff --git a/zephyr/program/myst/myst/src/usb_mux_config.c b/zephyr/program/myst/myst/src/usb_mux_config.c index 19eacbf989..561202fd23 100644 --- a/zephyr/program/myst/myst/src/usb_mux_config.c +++ b/zephyr/program/myst/myst/src/usb_mux_config.c @@ -10,7 +10,6 @@ #include "cros_cbi.h" #include "hooks.h" #include "usb_mux.h" -#include "usb_mux_config.h" #include "usbc/ppc.h" #include "usbc/tcpci.h" #include "usbc/usb_muxes.h" @@ -42,6 +41,29 @@ __override uint8_t board_get_usb_pd_port_count(void) return CONFIG_USB_PD_PORT_MAX_COUNT; } +void ppc_interrupt(enum gpio_signal signal) +{ + uint32_t io_db_type = get_io_db_type_from_cached_cbi(); + + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + ktu1125_interrupt(USBC_PORT_C0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + if (io_db_type == FW_IO_DB_SKU_A) { + nx20p348x_interrupt(USBC_PORT_C1); + } + if (io_db_type == FW_IO_DB_SKU_B) { + ktu1125_interrupt(USBC_PORT_C1); + } + break; + + default: + break; + } +} + static void setup_mux(void) { switch (get_io_db_type_from_cached_cbi()) { diff --git a/zephyr/program/myst/src/usbc_config.c b/zephyr/program/myst/src/usbc_config.c index bc76a66be3..8167dec2f9 100644 --- a/zephyr/program/myst/src/usbc_config.c +++ b/zephyr/program/myst/src/usbc_config.c @@ -22,7 +22,6 @@ #include "hooks.h" #include "power.h" #include "usb_mux.h" -#include "usb_mux_config.h" #include "usb_pd_tcpm.h" #include "usbc/usb_muxes.h" #include "usbc_config.h" @@ -118,29 +117,6 @@ void usb_pd_soc_interrupt(enum gpio_signal signal) CPRINTSUSB("SOC PD Interrupt"); } -void ppc_interrupt(enum gpio_signal signal) -{ - uint32_t io_db_type = get_io_db_type_from_cached_cbi(); - - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - ktu1125_interrupt(USBC_PORT_C0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - if (io_db_type == FW_IO_DB_SKU_A) { - nx20p348x_interrupt(USBC_PORT_C1); - } - if (io_db_type == FW_IO_DB_SKU_B) { - ktu1125_interrupt(USBC_PORT_C1); - } - break; - - default: - break; - } -} - /* Round up 3250 max current to multiple of 128mA for ISL9241 AC prochot. */ static void charger_prochot_init_isl9241(void) { -- cgit v1.2.1 From e2a231b82d1f137541e43b1ba761edd226235485 Mon Sep 17 00:00:00 2001 From: Logan_Liao Date: Wed, 10 May 2023 09:15:01 +0800 Subject: markarth: Modify LED behavior to meet SPEC. Base on SPEC, modify LED behavior when suspend without charge. Suspend(discharge) : Amber on 1 second, off 3 second. BUG=b:281566886 b:281566507 TEST=test LED behavior meet SPEC. Change-Id: I7ea9612dce41ac0e51bc68481750f5278727ab3b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4520276 Reviewed-by: Chao Gui Reviewed-by: Logan Liao Tested-by: Logan Liao Reviewed-by: Josh Tsai Commit-Queue: Chao Gui --- zephyr/program/skyrim/markarth/led_policy.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/skyrim/markarth/led_policy.dtsi b/zephyr/program/skyrim/markarth/led_policy.dtsi index 07354d3060..78a6488d7a 100644 --- a/zephyr/program/skyrim/markarth/led_policy.dtsi +++ b/zephyr/program/skyrim/markarth/led_policy.dtsi @@ -44,14 +44,14 @@ charge-state = "PWR_STATE_DISCHARGE"; chipset-state = "POWER_S3"; - /* Blue 1 sec, off 1 sec */ + /* Amber 1 sec, off 3 sec */ color-0 { - led-color = <&color_blue>; + led-color = <&color_amber>; period-ms = <1000>; }; color-1 { led-color = <&color_off>; - period-ms = <1000>; + period-ms = <3000>; }; }; -- cgit v1.2.1 From fe2610d0ef2feef5f7d80a1aa7ca540e854ee8aa Mon Sep 17 00:00:00 2001 From: Tommy Chung Date: Wed, 10 May 2023 15:49:06 +0800 Subject: yavilla: Limit C1 current with low power charger This follows CL:4379827 to solve C1 OCPC voltage drop with low power charger (5V). BUG=none TEST=make sure that yavilla c2c charging will not brownout on C1 port. Change-Id: I603bec0c8bcc3da7e934b8d88d791e2245ef7793 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4520738 Reviewed-by: Peter Marheine Tested-by: Tommy Chung Reviewed-by: Devin Lu Commit-Queue: Tommy Chung --- zephyr/program/nissa/yavilla/project.conf | 3 +++ zephyr/program/nissa/yavilla/src/usbc.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'zephyr/program') diff --git a/zephyr/program/nissa/yavilla/project.conf b/zephyr/program/nissa/yavilla/project.conf index 4c89a45147..30818c4419 100644 --- a/zephyr/program/nissa/yavilla/project.conf +++ b/zephyr/program/nissa/yavilla/project.conf @@ -41,3 +41,6 @@ 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 + +# Charger +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=0 diff --git a/zephyr/program/nissa/yavilla/src/usbc.c b/zephyr/program/nissa/yavilla/src/usbc.c index c9950ae73b..e3b46d6daa 100644 --- a/zephyr/program/nissa/yavilla/src/usbc.c +++ b/zephyr/program/nissa/yavilla/src/usbc.c @@ -235,6 +235,25 @@ __override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp) } } +__override void board_set_charge_limit(int port, int supplier, int charge_ma, + int max_ma, int charge_mv) +{ + /* + * b:213937755: Yavilla C1 port is OCPC (One Charger IC Per Type-C) + * architecture, The charging current is controlled by increasing Vsys. + * However, the charger SM5803 is not limit current while Vsys + * increasing, we can see the current overshoot to ~3.6A to cause + * C1 port brownout with low power charger (5V). To avoid C1 port + * brownout at low power charger connected. Limit charge current to 2A. + */ + if (charge_mv <= 5000 && port == 1) + charge_ma = MIN(charge_ma, 2000); + else + charge_ma = charge_ma * 96 / 100; + + charge_set_input_current_limit(charge_ma, charge_mv); +} + void board_reset_pd_mcu(void) { /* -- cgit v1.2.1 From 4ce5adab50925dab5384ee861ae9732062f427f0 Mon Sep 17 00:00:00 2001 From: Siyu Qin Date: Sat, 6 May 2023 15:50:53 +0800 Subject: voltorb: enable MFG FUNCTION to read battery cell voltage Enable macro CONFIG_PLATFORM_EC_SMART_BATTERY_OPTIONAL_MFG_FUNC, so that ectool can read battery cell voltage. BUG=b:281805616 TEST=use "ectool i2cxfer 1 0xb 2 0x3d" can read cell voltage Change-Id: Id446d44ef4b4ad98a7a55837e9c7428c763adf9b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4520742 Reviewed-by: Mike Lee Reviewed-by: Eric Yilun Lin Commit-Queue: Siyu Qin Tested-by: Siyu Qin --- zephyr/program/corsola/voltorb/project.conf | 1 + 1 file changed, 1 insertion(+) (limited to 'zephyr/program') diff --git a/zephyr/program/corsola/voltorb/project.conf b/zephyr/program/corsola/voltorb/project.conf index 3cb4f46e06..d2693d0de8 100644 --- a/zephyr/program/corsola/voltorb/project.conf +++ b/zephyr/program/corsola/voltorb/project.conf @@ -41,6 +41,7 @@ CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 # Battery config CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=15000 +CONFIG_PLATFORM_EC_SMART_BATTERY_OPTIONAL_MFG_FUNC=y # Remove debug options and features for FW QUAL CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n -- cgit v1.2.1 From 3aee7bb0a62128e3a7e657c8197925353198ac95 Mon Sep 17 00:00:00 2001 From: Eric Yilun Lin Date: Mon, 8 May 2023 17:50:57 +0800 Subject: corsola: do not reset TCPC if no battery connected The RT1718S controls the EN_SNK pin to the PPC. When the TCPC is reset without battery connected, this might cause the brown-out of the system due to the PPC stops sinking. BUG=b:276661970 TEST=reset EC without battery, and it first boots due to the soft-reset, and brown-out and then second boots with power-on flag. Change-Id: I79453e3625c8510818a78552c674b8887505dcb3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4506109 Reviewed-by: Sung-Chi Li Commit-Queue: Eric Yilun Lin Tested-by: Eric Yilun Lin --- zephyr/program/corsola/src/npcx_usbc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/corsola/src/npcx_usbc.c b/zephyr/program/corsola/src/npcx_usbc.c index a03e659171..2e1d8d11c5 100644 --- a/zephyr/program/corsola/src/npcx_usbc.c +++ b/zephyr/program/corsola/src/npcx_usbc.c @@ -11,6 +11,7 @@ #endif #include "baseboard_usbc_config.h" +#include "battery.h" #include "console.h" #include "driver/ppc/nx20p348x.h" #include "driver/tcpm/anx7447.h" @@ -53,8 +54,10 @@ 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()) { + /* Reset TCPC if we only we have a battery connected, or the SINK + * gpio to the PPC might be reset and cause brown-out. + */ + if (!system_jumped_late() && battery_is_present() == BP_YES) { /* TODO(crosbug.com/p/61098): How long do we need to wait? */ board_reset_pd_mcu(); } @@ -84,7 +87,13 @@ __override int board_rt1718s_init(int port) { static bool gpio_initialized; - if (!system_jumped_late() && !gpio_initialized) { + /* Reset TCPC sink/source control when it's a power-on reset or has a + * battery. Do not alter the carried GPIO status or this might stop PPC + * sinking and brown-out the system when battery disconnected. + */ + if (!system_jumped_late() && !gpio_initialized && + (battery_is_present() == BP_YES || + (system_get_reset_flags() & EC_RESET_FLAG_POWER_ON))) { /* 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); -- cgit v1.2.1 From 67debcce5555daf1c24e1eada34f7607bf041308 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 8 May 2023 15:20:07 -0600 Subject: charger: Rename enum charge_state to led_pwr_state This name is confusing, since its members start with PWR_ and the comment for enum charge_state_v2 says that these values are only used to control the LEDs, with one not-quite-correct exception, whatever that might be. We could rename it to power_state, but that is already fairly widely used as a variable in the code base. Also it seems better to match the enum PWR_ prefix. Future work may rename the members too. Rename the charge_state enum. This makes no functional change. BUG=b:218332694 TEST=make buildall Change-Id: If8a7cc73dcfb4c1e89984e57fc55e432416e8aec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516187 Commit-Queue: Simon Glass Reviewed-by: Paul Fagerburg Reviewed-by: Daisuke Nojiri Tested-by: Simon Glass --- zephyr/program/intelrvp/src/intel_rvp_led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zephyr/program') diff --git a/zephyr/program/intelrvp/src/intel_rvp_led.c b/zephyr/program/intelrvp/src/intel_rvp_led.c index 0e4d872963..22de04601b 100644 --- a/zephyr/program/intelrvp/src/intel_rvp_led.c +++ b/zephyr/program/intelrvp/src/intel_rvp_led.c @@ -80,7 +80,7 @@ static void pulse_leds(enum pwm_led_id id, int period) static void update_charger_led(enum pwm_led_id id) { - enum charge_state chg_st = charge_get_state(); + enum led_pwr_state chg_st = charge_get_state(); /* * The colors listed below are the default, but can be overridden. -- cgit v1.2.1 From 47acf64182ccc833bb590c6d307d6e7c66a93360 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 8 May 2023 16:01:39 -0600 Subject: charger: Rename charge_get_state() to led_pwr_get_state() We have a new 'charge state' in struct charge_state_data as part of the charge_state_v2.h file. This is confusing. Rename this function to match the enum it is referencing. This makes no functional change. BUG=b:218332694 TEST=make buildall Change-Id: I7f08dd4fb11e2939e0ef779018c1e3206ebc8d20 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516188 Commit-Queue: Simon Glass Tested-by: Simon Glass Reviewed-by: Aaron Massey --- zephyr/program/corsola/tentacruel/src/temp.c | 2 +- zephyr/program/intelrvp/src/intel_rvp_led.c | 2 +- zephyr/program/nissa/yaviks/src/led.c | 4 ++-- zephyr/program/nissa/yavilla/src/led.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/corsola/tentacruel/src/temp.c b/zephyr/program/corsola/tentacruel/src/temp.c index 2e584640be..72fcc526bd 100644 --- a/zephyr/program/corsola/tentacruel/src/temp.c +++ b/zephyr/program/corsola/tentacruel/src/temp.c @@ -62,7 +62,7 @@ static void current_update(void) temp = average_tempature(); #ifndef CONFIG_TEST - if (charge_get_state() == PWR_STATE_DISCHARGE) { + if (led_pwr_get_state() == PWR_STATE_DISCHARGE) { current_level = 0; uptime = 0; dntime = 0; diff --git a/zephyr/program/intelrvp/src/intel_rvp_led.c b/zephyr/program/intelrvp/src/intel_rvp_led.c index 22de04601b..91af0dfb55 100644 --- a/zephyr/program/intelrvp/src/intel_rvp_led.c +++ b/zephyr/program/intelrvp/src/intel_rvp_led.c @@ -80,7 +80,7 @@ static void pulse_leds(enum pwm_led_id id, int period) static void update_charger_led(enum pwm_led_id id) { - enum led_pwr_state chg_st = charge_get_state(); + enum led_pwr_state chg_st = led_pwr_get_state(); /* * The colors listed below are the default, but can be overridden. diff --git a/zephyr/program/nissa/yaviks/src/led.c b/zephyr/program/nissa/yaviks/src/led.c index 7671bd3a92..db93ae4b47 100644 --- a/zephyr/program/nissa/yaviks/src/led.c +++ b/zephyr/program/nissa/yaviks/src/led.c @@ -140,7 +140,7 @@ static void led_set_battery(void) * system suspend with non-charging state. */ if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && - charge_get_state() != PWR_STATE_CHARGE) { + led_pwr_get_state() != PWR_STATE_CHARGE) { suspend_ticks++; led_set_color_battery(RIGHT_PORT, @@ -158,7 +158,7 @@ static void led_set_battery(void) suspend_ticks = 0; - switch (charge_get_state()) { + switch (led_pwr_get_state()) { case PWR_STATE_CHARGE: /* Always indicate when charging, even in suspend. */ set_active_port_color(LED_AMBER); diff --git a/zephyr/program/nissa/yavilla/src/led.c b/zephyr/program/nissa/yavilla/src/led.c index 5bbc9d15b1..d123af8142 100644 --- a/zephyr/program/nissa/yavilla/src/led.c +++ b/zephyr/program/nissa/yavilla/src/led.c @@ -176,7 +176,7 @@ static void led_set_battery(void) * system suspend with non-charging state. */ if (!power_led_support && chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && - charge_get_state() != PWR_STATE_CHARGE) { + led_pwr_get_state() != PWR_STATE_CHARGE) { suspend_ticks++; led_set_color_battery(RIGHT_PORT, @@ -194,7 +194,7 @@ static void led_set_battery(void) suspend_ticks = 0; - switch (charge_get_state()) { + switch (led_pwr_get_state()) { case PWR_STATE_CHARGE: /* Always indicate when charging, even in suspend. */ set_active_port_color(LED_AMBER); -- cgit v1.2.1 From b729eab7c75553c830b54be5da7a348127f0b49c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 8 May 2023 15:33:31 -0600 Subject: charger: Move charger_state_v2.h into charge_state.h We don't have a v1 anymore, so the name makes no sense. Move it into the existing file. Include charge_state.h instead of v2, doing this in the same change to avoid build errors. This makes no functional change. BUG=b:218332694 TEST=make buildall Change-Id: Ic3e3adc45e4d002c2cd5ba8aa65e24686e01d628 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4516191 Reviewed-by: Tim Van Patten Commit-Queue: Simon Glass Tested-by: Simon Glass Reviewed-by: Yuval Peress --- zephyr/program/corsola/src/usbc.c | 2 +- zephyr/program/geralt/src/usbc_config.c | 2 +- zephyr/program/intelrvp/src/chg_usb_pd.c | 2 +- zephyr/program/myst/src/usbc_config.c | 1 - zephyr/program/nissa/craask/src/usbc.c | 2 +- zephyr/program/nissa/joxer/src/usbc.c | 2 +- zephyr/program/nissa/nereid/src/usbc.c | 2 +- zephyr/program/nissa/nivviks/src/usbc.c | 2 +- zephyr/program/nissa/pujjo/src/usbc.c | 2 +- zephyr/program/nissa/src/common.c | 2 +- zephyr/program/nissa/uldren/src/usbc.c | 2 +- zephyr/program/nissa/xivu/src/usbc.c | 2 +- zephyr/program/nissa/xivur/src/usbc.c | 2 +- zephyr/program/nissa/yaviks/src/usbc.c | 2 +- zephyr/program/nissa/yavilla/src/usbc.c | 2 +- zephyr/program/rex/src/usbc_config.c | 1 - zephyr/program/skyrim/src/usbc_config.c | 1 - 17 files changed, 14 insertions(+), 17 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/corsola/src/usbc.c b/zephyr/program/corsola/src/usbc.c index 181b3df141..71c02ff54f 100644 --- a/zephyr/program/corsola/src/usbc.c +++ b/zephyr/program/corsola/src/usbc.c @@ -6,7 +6,7 @@ /* Corsola baseboard-specific USB-C configuration */ #include "baseboard_usbc_config.h" -#include "charge_state_v2.h" +#include "charge_state.h" #include "console.h" #include "ec_commands.h" #include "extpower.h" diff --git a/zephyr/program/geralt/src/usbc_config.c b/zephyr/program/geralt/src/usbc_config.c index 64a55ffb75..f0c56c5a8b 100644 --- a/zephyr/program/geralt/src/usbc_config.c +++ b/zephyr/program/geralt/src/usbc_config.c @@ -6,7 +6,7 @@ /* Geralt baseboard-specific USB-C configuration */ #include "charge_manager.h" -#include "charge_state_v2.h" +#include "charge_state.h" #include "console.h" #include "driver/tcpm/it83xx_pd.h" #include "gpio.h" diff --git a/zephyr/program/intelrvp/src/chg_usb_pd.c b/zephyr/program/intelrvp/src/chg_usb_pd.c index 084617cb98..1b2c1a8736 100644 --- a/zephyr/program/intelrvp/src/chg_usb_pd.c +++ b/zephyr/program/intelrvp/src/chg_usb_pd.c @@ -6,7 +6,7 @@ /* Common USB PD charge configuration */ #include "charge_manager.h" -#include "charge_state_v2.h" +#include "charge_state.h" #include "gpio.h" #include "hooks.h" #include "intelrvp.h" diff --git a/zephyr/program/myst/src/usbc_config.c b/zephyr/program/myst/src/usbc_config.c index 8167dec2f9..5d2401a6af 100644 --- a/zephyr/program/myst/src/usbc_config.c +++ b/zephyr/program/myst/src/usbc_config.c @@ -9,7 +9,6 @@ #include "charge_manager.h" #include "charge_ramp.h" #include "charge_state.h" -#include "charge_state_v2.h" #include "charger.h" #include "cros_board_info.h" #include "cros_cbi.h" diff --git a/zephyr/program/nissa/craask/src/usbc.c b/zephyr/program/nissa/craask/src/usbc.c index 88fc54d3a3..5df3a09bb8 100644 --- a/zephyr/program/nissa/craask/src/usbc.c +++ b/zephyr/program/nissa/craask/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" diff --git a/zephyr/program/nissa/joxer/src/usbc.c b/zephyr/program/nissa/joxer/src/usbc.c index e3e18e0f33..54fea2f663 100644 --- a/zephyr/program/nissa/joxer/src/usbc.c +++ b/zephyr/program/nissa/joxer/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/sm5803.h" #include "driver/tcpm/it83xx_pd.h" diff --git a/zephyr/program/nissa/nereid/src/usbc.c b/zephyr/program/nissa/nereid/src/usbc.c index e3e18e0f33..54fea2f663 100644 --- a/zephyr/program/nissa/nereid/src/usbc.c +++ b/zephyr/program/nissa/nereid/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/sm5803.h" #include "driver/tcpm/it83xx_pd.h" diff --git a/zephyr/program/nissa/nivviks/src/usbc.c b/zephyr/program/nissa/nivviks/src/usbc.c index 88fc54d3a3..5df3a09bb8 100644 --- a/zephyr/program/nissa/nivviks/src/usbc.c +++ b/zephyr/program/nissa/nivviks/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" diff --git a/zephyr/program/nissa/pujjo/src/usbc.c b/zephyr/program/nissa/pujjo/src/usbc.c index 59d876c4db..0b5fe3b809 100644 --- a/zephyr/program/nissa/pujjo/src/usbc.c +++ b/zephyr/program/nissa/pujjo/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c index def29ccd02..aaca2ecc6b 100644 --- a/zephyr/program/nissa/src/common.c +++ b/zephyr/program/nissa/src/common.c @@ -4,7 +4,7 @@ */ #include "battery.h" -#include "charge_state_v2.h" +#include "charge_state.h" #include "charger.h" #include "chipset.h" #include "hooks.h" diff --git a/zephyr/program/nissa/uldren/src/usbc.c b/zephyr/program/nissa/uldren/src/usbc.c index aaba5492dd..33c63472e8 100644 --- a/zephyr/program/nissa/uldren/src/usbc.c +++ b/zephyr/program/nissa/uldren/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" diff --git a/zephyr/program/nissa/xivu/src/usbc.c b/zephyr/program/nissa/xivu/src/usbc.c index 6b95a3b1f4..d77abf37db 100644 --- a/zephyr/program/nissa/xivu/src/usbc.c +++ b/zephyr/program/nissa/xivu/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" diff --git a/zephyr/program/nissa/xivur/src/usbc.c b/zephyr/program/nissa/xivur/src/usbc.c index 639bd3adbb..a0bd74b3a6 100644 --- a/zephyr/program/nissa/xivur/src/usbc.c +++ b/zephyr/program/nissa/xivur/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/isl923x_public.h" #include "driver/retimer/anx7483_public.h" diff --git a/zephyr/program/nissa/yaviks/src/usbc.c b/zephyr/program/nissa/yaviks/src/usbc.c index a4cb140059..307109fa9d 100644 --- a/zephyr/program/nissa/yaviks/src/usbc.c +++ b/zephyr/program/nissa/yaviks/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/sm5803.h" #include "driver/tcpm/it83xx_pd.h" diff --git a/zephyr/program/nissa/yavilla/src/usbc.c b/zephyr/program/nissa/yavilla/src/usbc.c index e3b46d6daa..3cbdd23625 100644 --- a/zephyr/program/nissa/yavilla/src/usbc.c +++ b/zephyr/program/nissa/yavilla/src/usbc.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -#include "charge_state_v2.h" +#include "charge_state.h" #include "chipset.h" #include "driver/charger/sm5803.h" #include "driver/tcpm/it83xx_pd.h" diff --git a/zephyr/program/rex/src/usbc_config.c b/zephyr/program/rex/src/usbc_config.c index d2471c3daf..115d010ff5 100644 --- a/zephyr/program/rex/src/usbc_config.c +++ b/zephyr/program/rex/src/usbc_config.c @@ -7,7 +7,6 @@ #include "charge_manager.h" #include "charge_ramp.h" #include "charge_state.h" -#include "charge_state_v2.h" #include "charger.h" #include "driver/charger/isl9241.h" #include "driver/ppc/nx20p348x.h" diff --git a/zephyr/program/skyrim/src/usbc_config.c b/zephyr/program/skyrim/src/usbc_config.c index ab1d444df8..922e863027 100644 --- a/zephyr/program/skyrim/src/usbc_config.c +++ b/zephyr/program/skyrim/src/usbc_config.c @@ -9,7 +9,6 @@ #include "charge_manager.h" #include "charge_ramp.h" #include "charge_state.h" -#include "charge_state_v2.h" #include "charger.h" #include "cros_board_info.h" #include "cros_cbi.h" -- cgit v1.2.1 From ac6fcbcc0c527115dfa732d9007dd6f87acab74c Mon Sep 17 00:00:00 2001 From: Boris Mittelberg Date: Wed, 10 May 2023 05:38:10 -0700 Subject: myst: add bringup configs Add configs for BRINGUP and SYSTEM_UNLOCKED BUG=b:281691329 TEST=zmake build myst Change-Id: Ib84c1bb98b614cda05848291feb362e6f62fffb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4521338 Reviewed-by: Rob Barnes Reviewed-by: Diana Z Tested-by: Boris Mittelberg Reviewed-by: Robert Zieba Commit-Queue: Boris Mittelberg --- zephyr/program/myst/program.conf | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'zephyr/program') diff --git a/zephyr/program/myst/program.conf b/zephyr/program/myst/program.conf index 0b275b16fa..e96b2580f4 100644 --- a/zephyr/program/myst/program.conf +++ b/zephyr/program/myst/program.conf @@ -95,6 +95,11 @@ CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=y CONFIG_PLATFORM_EC_USB_PD_USB4=n CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y +# Bring up configs +CONFIG_SHELL_HISTORY_BUFFER=256 +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y +CONFIG_PLATFORM_EC_BRINGUP=y + # Disable FRS for bringup CONFIG_PLATFORM_EC_USB_PD_FRS=n CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=n -- cgit v1.2.1 From 454f4b32f8b010b9267d6c47f81502dfdffc6a24 Mon Sep 17 00:00:00 2001 From: mick_hsiao Date: Thu, 11 May 2023 16:43:13 +0800 Subject: Uldren: update fw config Update cbi config to let DB works, Also remove fan code, because uldren doesn't have fan design BUG=b:273159459 TEST=DB can charge and read usb Change-Id: I9da2c3fd7eedc44cfcaad89d32c393cc528feff2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4522690 Commit-Queue: Shou-Chieh Hsu Reviewed-by: Elthan Huang Tested-by: Mick Hsiao Reviewed-by: Shou-Chieh Hsu --- zephyr/program/nissa/CMakeLists.txt | 1 - zephyr/program/nissa/uldren/cbi.dtsi | 46 +++++++++++++++++++---------------- zephyr/program/nissa/uldren/src/fan.c | 41 ------------------------------- 3 files changed, 25 insertions(+), 63 deletions(-) delete mode 100644 zephyr/program/nissa/uldren/src/fan.c (limited to 'zephyr/program') diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index e2f85139bf..cd45f00a3a 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -118,7 +118,6 @@ if(DEFINED CONFIG_BOARD_ULDREN) "uldren/src/kb_backlight.c" "uldren/src/keyboard.c" ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "uldren/src/fan.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "uldren/src/usbc.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "uldren/src/charger.c") endif() diff --git a/zephyr/program/nissa/uldren/cbi.dtsi b/zephyr/program/nissa/uldren/cbi.dtsi index 9d865a38bb..02aa0607f9 100644 --- a/zephyr/program/nissa/uldren/cbi.dtsi +++ b/zephyr/program/nissa/uldren/cbi.dtsi @@ -7,44 +7,47 @@ /* Uldren-specific fw_config fields. */ nissa-fw-config { /* - * FW_CONFIG field to enable KB back light or not. + * FW_CONFIG field to enable USB DB. */ - kb-bl { - enum-name = "FW_KB_BL"; - start = <4>; - size = <1>; + sub-board { + enum-name = "FW_SUB_BOARD"; + start = <1>; + size = <2>; - no-kb-bl { + sub-board-1 { compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_NOT_PRESENT"; + enum-name = "FW_SUB_BOARD_1"; value = <0>; - default; }; - kb-bl-present { + sub-board-2 { compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_PRESENT"; - value = <1>; + enum-name = "FW_SUB_BOARD_2"; + value = <3>; + }; + sub-board-3 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_SUB_BOARD_3"; + value = <2>; }; }; - /* - * FW_CONFIG field to enable USB DB. + * FW_CONFIG field to enable KB back light or not. */ - db-usb { - enum-name = "FW_DB_USB"; - start = <6>; + kb-bl { + enum-name = "FW_KB_BL"; + start = <5>; size = <1>; - no-db-usb { + no-kb-bl { compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_DB_USB_NOT_PRESENT"; + enum-name = "FW_KB_BL_NOT_PRESENT"; value = <0>; + default; }; - db-usb-present { + kb-bl-present { compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_DB_USB_PRESENT"; + enum-name = "FW_KB_BL_PRESENT"; value = <1>; - default; }; }; @@ -67,5 +70,6 @@ value = <1>; }; }; +/delete-node/ fan; }; }; diff --git a/zephyr/program/nissa/uldren/src/fan.c b/zephyr/program/nissa/uldren/src/fan.c deleted file mode 100644 index 32f9d3c65e..0000000000 --- a/zephyr/program/nissa/uldren/src/fan.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2023 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 -#include -#include - -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); -- cgit v1.2.1 From 76d2b9b1e47ba721d83ada33f18a1aab28a80ea7 Mon Sep 17 00:00:00 2001 From: wen zhang Date: Fri, 12 May 2023 01:29:00 +0800 Subject: battery: Deprecate CONFIG_BATTERY_LEVEL_NEAR_FULL Atlas, coral, corori, eve, morphius, primus, and rammus are setting CONFIG_BATTERY_LEVEL_NEAR_FULL to custom values. This causes their LEDs show 'full' while the display battery percentages are still < 100%. We'll make these boards define CONFIG_BATT_HOST_FULL_FACTOR, instead. And fix LED dts for some zephyr projects. BUG=b:280818345 TEST=build pass Change-Id: I98f97798ea99cc812671d5b31d64e92d55a1e05a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4523043 Commit-Queue: wen zhang Tested-by: wen zhang Reviewed-by: Daisuke Nojiri --- zephyr/program/corsola/magikarp/project.overlay | 6 ++---- zephyr/program/corsola/tentacruel/project.overlay | 6 ++---- zephyr/program/corsola/voltorb/project.overlay | 15 ++++++++++++--- zephyr/program/nissa/uldren/led_policy.dtsi | 2 +- zephyr/program/nissa/xivu/led_policy.dtsi | 4 ++-- zephyr/program/skyrim/frostflow/led_policy.dtsi | 4 ++-- 6 files changed, 21 insertions(+), 16 deletions(-) (limited to 'zephyr/program') diff --git a/zephyr/program/corsola/magikarp/project.overlay b/zephyr/program/corsola/magikarp/project.overlay index 3628f6770d..349e066f07 100644 --- a/zephyr/program/corsola/magikarp/project.overlay +++ b/zephyr/program/corsola/magikarp/project.overlay @@ -224,8 +224,7 @@ bat-power-state-charge { charge-state = "PWR_STATE_CHARGE"; /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = ; + batt-lvl = ; color-0 { led-color = <&color_battery_amber>; }; @@ -234,8 +233,7 @@ 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>; + batt-lvl = <95 BATTERY_LEVEL_FULL>; color-0 { led-color = <&color_battery_white>; }; diff --git a/zephyr/program/corsola/tentacruel/project.overlay b/zephyr/program/corsola/tentacruel/project.overlay index 79e8f4a05b..e23d3561e8 100644 --- a/zephyr/program/corsola/tentacruel/project.overlay +++ b/zephyr/program/corsola/tentacruel/project.overlay @@ -270,8 +270,7 @@ bat-power-state-charge { charge-state = "PWR_STATE_CHARGE"; /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = ; + batt-lvl = ; color-0 { led-color = <&color_battery_amber>; }; @@ -280,8 +279,7 @@ 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>; + batt-lvl = <95 BATTERY_LEVEL_FULL>; color-0 { led-color = <&color_battery_white>; }; diff --git a/zephyr/program/corsola/voltorb/project.overlay b/zephyr/program/corsola/voltorb/project.overlay index 7ae230a47e..e5c5df3ab7 100644 --- a/zephyr/program/corsola/voltorb/project.overlay +++ b/zephyr/program/corsola/voltorb/project.overlay @@ -81,17 +81,26 @@ compatible = "cros-ec,led-policy"; /* Voltorb LED bat charge */ - bat-power-state-charge { + bat-power-state-charge-lvl-1 { charge-state = "PWR_STATE_CHARGE"; /* Battery percent range (>= Empty, <= 96%) */ - batt-lvl = ; + batt-lvl = ; color-0 { led-color = <&color_amber>; }; }; + bat-power-state-charge-lvl-2 { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 97, <= 100%) */ + batt-lvl = <97 100>; + + 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"; diff --git a/zephyr/program/nissa/uldren/led_policy.dtsi b/zephyr/program/nissa/uldren/led_policy.dtsi index 95c614cafc..afc4e25f71 100644 --- a/zephyr/program/nissa/uldren/led_policy.dtsi +++ b/zephyr/program/nissa/uldren/led_policy.dtsi @@ -7,7 +7,7 @@ power-state-charge { charge-state = "PWR_STATE_CHARGE"; batt-lvl = ; + BATTERY_LEVEL_FULL>; color-0 { led-color = <&color_white>; diff --git a/zephyr/program/nissa/xivu/led_policy.dtsi b/zephyr/program/nissa/xivu/led_policy.dtsi index 562e361ec5..598480f865 100644 --- a/zephyr/program/nissa/xivu/led_policy.dtsi +++ b/zephyr/program/nissa/xivu/led_policy.dtsi @@ -14,8 +14,8 @@ power-state-charge-lvl-2 { charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Near Full) */ - batt-lvl = <95 97>; + /* Battery percent range (>= 95%, <= 100%) */ + batt-lvl = <95 100>; color-0 { led-color = <&color_white>; diff --git a/zephyr/program/skyrim/frostflow/led_policy.dtsi b/zephyr/program/skyrim/frostflow/led_policy.dtsi index 28e33219a0..178ba9085a 100644 --- a/zephyr/program/skyrim/frostflow/led_policy.dtsi +++ b/zephyr/program/skyrim/frostflow/led_policy.dtsi @@ -14,8 +14,8 @@ power-state-charge-lvl-2 { charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Near Full) */ - batt-lvl = <95 97>; + /* Battery percent range (>= 95%, <= 100%) */ + batt-lvl = <95 100>; color-0 { led-color = <&color_white>; -- cgit v1.2.1