summaryrefslogtreecommitdiff
path: root/zephyr/program
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/program')
-rw-r--r--zephyr/program/corsola/voltorb/CMakeLists.txt1
-rw-r--r--zephyr/program/corsola/voltorb/project.conf3
-rw-r--r--zephyr/program/corsola/voltorb/src/board.c41
-rw-r--r--zephyr/program/geralt/motionsense.dtsi4
-rw-r--r--zephyr/program/geralt/src/base_detect.c2
-rw-r--r--zephyr/program/nissa/CMakeLists.txt1
-rw-r--r--zephyr/program/nissa/uldren/led_pins.dtsi62
-rw-r--r--zephyr/program/nissa/uldren/led_policy.dtsi115
-rw-r--r--zephyr/program/nissa/uldren/overlay.dtsi29
-rw-r--r--zephyr/program/nissa/uldren/project.conf2
-rw-r--r--zephyr/program/nissa/uldren/project.overlay17
-rw-r--r--zephyr/program/nissa/uldren/pwm_leds.dtsi62
-rw-r--r--zephyr/program/nissa/uldren/src/led.c51
-rw-r--r--zephyr/program/nissa/yaviks/src/usbc.c10
14 files changed, 271 insertions, 129 deletions
diff --git a/zephyr/program/corsola/voltorb/CMakeLists.txt b/zephyr/program/corsola/voltorb/CMakeLists.txt
index bcd3e753c1..82fa262bda 100644
--- a/zephyr/program/corsola/voltorb/CMakeLists.txt
+++ b/zephyr/program/corsola/voltorb/CMakeLists.txt
@@ -9,3 +9,4 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
"../src/npcx_usb_pd_policy.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
"../src/npcx_usbc.c" "./src/usbc.c")
+zephyr_library_sources("src/board.c")
diff --git a/zephyr/program/corsola/voltorb/project.conf b/zephyr/program/corsola/voltorb/project.conf
index 5343c7f524..53e619098a 100644
--- a/zephyr/program/corsola/voltorb/project.conf
+++ b/zephyr/program/corsola/voltorb/project.conf
@@ -38,3 +38,6 @@ CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000
# AC_OK debounce time
CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800
+
+# Battery config
+CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=15000
diff --git a/zephyr/program/corsola/voltorb/src/board.c b/zephyr/program/corsola/voltorb/src/board.c
new file mode 100644
index 0000000000..d1d7f0350e
--- /dev/null
+++ b/zephyr/program/corsola/voltorb/src/board.c
@@ -0,0 +1,41 @@
+/* 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 "charge_state.h"
+#include "common.h"
+#include "dps.h"
+#include "math_util.h"
+
+#include <zephyr/logging/log.h>
+
+#include <dt-bindings/battery.h>
+
+LOG_MODULE_REGISTER(board_init, LOG_LEVEL_ERR);
+
+bool voltorb_is_more_efficient(int curr_mv, int prev_mv, int batt_mv,
+ int batt_mw, int input_mw)
+{
+ int batt_state;
+
+ battery_status(&batt_state);
+
+ /* Choose 15V PDO or higher when battery is full. */
+ if ((batt_state & SB_STATUS_FULLY_CHARGED) && (curr_mv >= 15000) &&
+ (prev_mv < 15000 || curr_mv <= prev_mv)) {
+ return true;
+ } else {
+ return ABS(curr_mv - batt_mv) < ABS(prev_mv - batt_mv);
+ }
+}
+
+__override struct dps_config_t dps_config = {
+ .k_less_pwr = 93,
+ .k_more_pwr = 96,
+ .k_sample = 1,
+ .k_window = 3,
+ .t_stable = 10 * SECOND,
+ .t_check = 5 * SECOND,
+ .is_more_efficient = &voltorb_is_more_efficient,
+};
diff --git a/zephyr/program/geralt/motionsense.dtsi b/zephyr/program/geralt/motionsense.dtsi
index 345eb6b278..1446d1cb22 100644
--- a/zephyr/program/geralt/motionsense.dtsi
+++ b/zephyr/program/geralt/motionsense.dtsi
@@ -33,8 +33,8 @@
motionsense-rotation-ref {
compatible = "cros-ec,motionsense-rotation-ref";
lid_rot_ref: lid-rotation-ref {
- mat33 = <0 1 0
- (-1) 0 0
+ mat33 = <1 0 0
+ 0 1 0
0 0 1>;
};
};
diff --git a/zephyr/program/geralt/src/base_detect.c b/zephyr/program/geralt/src/base_detect.c
index 074c2db5f9..feb01337ce 100644
--- a/zephyr/program/geralt/src/base_detect.c
+++ b/zephyr/program/geralt/src/base_detect.c
@@ -91,6 +91,8 @@ static int base_init(const struct device *unused)
{
static struct ap_power_ev_callback cb;
+ base_update(false);
+
ap_power_ev_init_callback(&cb, base_startup_hook,
AP_POWER_STARTUP | AP_POWER_SHUTDOWN);
ap_power_ev_add_callback(&cb);
diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt
index eaaa2ebee1..97b25e7e06 100644
--- a/zephyr/program/nissa/CMakeLists.txt
+++ b/zephyr/program/nissa/CMakeLists.txt
@@ -114,7 +114,6 @@ endif()
if(DEFINED CONFIG_BOARD_ULDREN)
project(uldren)
zephyr_library_sources(
- "uldren/src/led.c"
"uldren/src/keyboard.c"
)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "uldren/src/fan.c")
diff --git a/zephyr/program/nissa/uldren/led_pins.dtsi b/zephyr/program/nissa/uldren/led_pins.dtsi
new file mode 100644
index 0000000000..e9003ffc30
--- /dev/null
+++ b/zephyr/program/nissa/uldren/led_pins.dtsi
@@ -0,0 +1,62 @@
+/* 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.
+ */
+
+/ {
+ pwmleds {
+ compatible = "pwm-leds";
+ pwm_led_y_c0: pwm_led_y_c0 {
+ pwms = <&pwm2 2 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ pwm_led_w_c0: pwm_led_w_c0 {
+ pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ /* reserve to use */
+ pwms = <&pwm1 1 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-pwms = <&pwm_led_y_c0 &pwm_led_w_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-pwms = <&pwm_led_y_c0 &pwm_led_w_c0>;
+ 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_led_y_c0 &pwm_led_w_c0>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* LED2 */
+&pwm0 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
+
+/* LED1 */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
+
diff --git a/zephyr/program/nissa/uldren/led_policy.dtsi b/zephyr/program/nissa/uldren/led_policy.dtsi
new file mode 100644
index 0000000000..95c614cafc
--- /dev/null
+++ b/zephyr/program/nissa/uldren/led_policy.dtsi
@@ -0,0 +1,115 @@
+#include <dt-bindings/battery.h>
+
+/ {
+ led-colors {
+ compatible = "cros-ec,led-policy";
+
+ power-state-charge {
+ charge-state = "PWR_STATE_CHARGE";
+ batt-lvl = <BATTERY_LEVEL_EMPTY
+ BATTERY_LEVEL_NEAR_FULL>;
+
+ color-0 {
+ led-color = <&color_white>;
+ };
+ };
+
+ power-state-near-full {
+ charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-discharge-s0 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ batt-lvl = <BATTERY_LEVEL_LOW BATTERY_LEVEL_FULL>;
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-discharge-s3 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ 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";
+ batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
+
+ color-0 {
+ led-color = <&color_amber>;
+ };
+ };
+
+ power-state-discharge-s3-batt-low {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+ batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
+
+ color-0 {
+ led-color = <&color_amber>;
+ };
+ };
+
+ 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";
+ /* 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-s5 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S5";
+ /* Amber 1 sec, off 3 sec */
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <3000>;
+ };
+ };
+ };
+};
diff --git a/zephyr/program/nissa/uldren/overlay.dtsi b/zephyr/program/nissa/uldren/overlay.dtsi
index 7ea4ac8580..50ba4c932e 100644
--- a/zephyr/program/nissa/uldren/overlay.dtsi
+++ b/zephyr/program/nissa/uldren/overlay.dtsi
@@ -21,11 +21,32 @@
};
batteries {
- default_battery: lgc {
- compatible = "lgc,ap18c8k", "battery-smart";
+ default_battery: byd_yt39x {
+ compatible = "byd,yt39x", "battery-smart";
};
- lgc_ap19b8m {
- compatible = "lgc,ap19b8m", "battery-smart";
+ byd_x0y5m {
+ compatible = "byd,x0y5m", "battery-smart";
+ };
+ lgc_8ghcx {
+ compatible = "lgc,8ghcx", "battery-smart";
+ };
+ sunwoda_ctgkt {
+ compatible = "sunwoda,ctgkt", "battery-smart";
+ };
+ sunwoda_cos3ctgkt {
+ compatible = "sunwoda,cos3ctgkt", "battery-smart";
+ };
+ smp_atl26jgk {
+ compatible = "smp,atl26jgk", "battery-smart";
+ };
+ smp_atlrf9h3 {
+ compatible = "smp,atlrf9h3", "battery-smart";
+ };
+ smp_cos26jgk {
+ compatible = "smp,cos26jgk", "battery-smart";
+ };
+ smp_cosrf9h3 {
+ compatible = "smp,cosrf9h3", "battery-smart";
};
};
diff --git a/zephyr/program/nissa/uldren/project.conf b/zephyr/program/nissa/uldren/project.conf
index 4b735e69ec..0c64e7ad3d 100644
--- a/zephyr/program/nissa/uldren/project.conf
+++ b/zephyr/program/nissa/uldren/project.conf
@@ -17,5 +17,5 @@ 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
-#Disable keyboard backlight
+# Disable keyboard backlight
CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=n
diff --git a/zephyr/program/nissa/uldren/project.overlay b/zephyr/program/nissa/uldren/project.overlay
index 9ca681d979..10b76b0080 100644
--- a/zephyr/program/nissa/uldren/project.overlay
+++ b/zephyr/program/nissa/uldren/project.overlay
@@ -3,12 +3,13 @@
* found in the LICENSE file.
*/
-#include "../cbi.dtsi"
+ #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"
+ #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/uldren/pwm_leds.dtsi b/zephyr/program/nissa/uldren/pwm_leds.dtsi
deleted file mode 100644
index a265a5929e..0000000000
--- a/zephyr/program/nissa/uldren/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>;
-
- /*<red green blue>*/
- 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/uldren/src/led.c b/zephyr/program/nissa/uldren/src/led.c
deleted file mode 100644
index f9e93f47e9..0000000000
--- a/zephyr/program/nissa/uldren/src/led.c
+++ /dev/null
@@ -1,51 +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.
- *
- * 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/yaviks/src/usbc.c b/zephyr/program/nissa/yaviks/src/usbc.c
index fa280615ee..dcaa8221ff 100644
--- a/zephyr/program/nissa/yaviks/src/usbc.c
+++ b/zephyr/program/nissa/yaviks/src/usbc.c
@@ -12,6 +12,7 @@
#include "hooks.h"
#include "system.h"
#include "usb_mux.h"
+#include "watchdog.h"
#include <zephyr/logging/log.h>
@@ -316,6 +317,15 @@ void board_process_pd_alert(int port)
*/
if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_int_odl)))
schedule_deferred_pd_interrupt(port);
+
+ /*
+ * b:273208597: There are some peripheral display docks will
+ * issue HPDs in the short time. TCPM must wake up pd_task
+ * continually to service the events. They may cause the
+ * watchdog to reset. This patch placates watchdog after
+ * receiving dp_attention.
+ */
+ watchdog_reload();
}
int pd_snk_is_vbus_provided(int port)