diff options
-rw-r--r-- | zephyr/program/nissa/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/cbi.dtsi | 63 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/generated.dtsi | 6 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/keyboard.dtsi | 15 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/overlay.dtsi | 3 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/power_signals.dtsi | 2 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/project.conf | 5 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/project.overlay | 2 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/src/form_factor.c | 44 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/src/kb_backlight.c | 34 |
10 files changed, 147 insertions, 29 deletions
diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index 97b25e7e06..e2f85139bf 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -114,6 +114,8 @@ endif() if(DEFINED CONFIG_BOARD_ULDREN) project(uldren) zephyr_library_sources( + "uldren/src/form_factor.c" + "uldren/src/kb_backlight.c" "uldren/src/keyboard.c" ) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "uldren/src/fan.c") diff --git a/zephyr/program/nissa/uldren/cbi.dtsi b/zephyr/program/nissa/uldren/cbi.dtsi index 148a7d2e99..9d865a38bb 100644 --- a/zephyr/program/nissa/uldren/cbi.dtsi +++ b/zephyr/program/nissa/uldren/cbi.dtsi @@ -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. */ @@ -6,5 +6,66 @@ / { /* Uldren-specific fw_config fields. */ nissa-fw-config { + /* + * FW_CONFIG field to enable KB back light or not. + */ + kb-bl { + enum-name = "FW_KB_BL"; + start = <4>; + size = <1>; + + no-kb-bl { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_NOT_PRESENT"; + value = <0>; + default; + }; + kb-bl-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_PRESENT"; + value = <1>; + }; + }; + + /* + * FW_CONFIG field to enable USB DB. + */ + db-usb { + enum-name = "FW_DB_USB"; + start = <6>; + size = <1>; + + no-db-usb { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_DB_USB_NOT_PRESENT"; + value = <0>; + }; + db-usb-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_DB_USB_PRESENT"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field for tablet present or not. + */ + tablet { + enum-name = "FW_TABLET"; + start = <7>; + size = <1>; + + no-tablet { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_TABLET_NOT_PRESENT"; + value = <0>; + }; + tablet-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_TABLET_PRESENT"; + value = <1>; + }; + }; }; }; diff --git a/zephyr/program/nissa/uldren/generated.dtsi b/zephyr/program/nissa/uldren/generated.dtsi index f02faec389..ab3b5264ae 100644 --- a/zephyr/program/nissa/uldren/generated.dtsi +++ b/zephyr/program/nissa/uldren/generated.dtsi @@ -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. * @@ -105,6 +105,10 @@ gpio_ec_wp_odl: ec_wp_odl { gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; }; + gpio_en_kb_bl: en_kb_bl { + gpios = <&gpioa 0 GPIO_OUTPUT>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; gpio_en_pp3300_s5: en_pp3300_s5 { gpios = <&gpiob 6 GPIO_OUTPUT>; enum-name = "GPIO_TEMP_SENSOR_POWER"; diff --git a/zephyr/program/nissa/uldren/keyboard.dtsi b/zephyr/program/nissa/uldren/keyboard.dtsi index 5248c4aaff..f958ed9cea 100644 --- a/zephyr/program/nissa/uldren/keyboard.dtsi +++ b/zephyr/program/nissa/uldren/keyboard.dtsi @@ -1,8 +1,21 @@ -/* 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. */ +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm6 6 PWM_KHZ(10) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm6 { + status = "okay"; + pinctrl-0 = <&pwm6_gpc0>; + pinctrl-names = "default"; +}; + &cros_kb_raw { status = "okay"; /* No KSO2 (it's inverted and implemented by GPIO) */ diff --git a/zephyr/program/nissa/uldren/overlay.dtsi b/zephyr/program/nissa/uldren/overlay.dtsi index 50ba4c932e..7e6e823b37 100644 --- a/zephyr/program/nissa/uldren/overlay.dtsi +++ b/zephyr/program/nissa/uldren/overlay.dtsi @@ -1,4 +1,4 @@ -/* Copyright 2021 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. */ @@ -316,7 +316,6 @@ <&gpio8 3 0>, <&gpio8 5 0>, <&gpio8 6 0>, - <&gpioa 0 0>, <&gpiob 1 0>, <&gpiob 7 0>, <&gpioc 0 0>, diff --git a/zephyr/program/nissa/uldren/power_signals.dtsi b/zephyr/program/nissa/uldren/power_signals.dtsi index 1d2b23069d..99e64cc52f 100644 --- a/zephyr/program/nissa/uldren/power_signals.dtsi +++ b/zephyr/program/nissa/uldren/power_signals.dtsi @@ -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. */ diff --git a/zephyr/program/nissa/uldren/project.conf b/zephyr/program/nissa/uldren/project.conf index 0c64e7ad3d..f65c304bd4 100644 --- a/zephyr/program/nissa/uldren/project.conf +++ b/zephyr/program/nissa/uldren/project.conf @@ -9,6 +9,7 @@ CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y # Both ports use a SLGC55545 smart switch with CTL1..3 fixed high, # for SDP2 or CDP only. @@ -17,5 +18,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 -CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=n +# BTN +CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y diff --git a/zephyr/program/nissa/uldren/project.overlay b/zephyr/program/nissa/uldren/project.overlay index 10b76b0080..f56a20e235 100644 --- a/zephyr/program/nissa/uldren/project.overlay +++ b/zephyr/program/nissa/uldren/project.overlay @@ -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. */ diff --git a/zephyr/program/nissa/uldren/src/form_factor.c b/zephyr/program/nissa/uldren/src/form_factor.c index 72c0ba04d3..2dcc61c590 100644 --- a/zephyr/program/nissa/uldren/src/form_factor.c +++ b/zephyr/program/nissa/uldren/src/form_factor.c @@ -4,42 +4,46 @@ */ #include "accelgyro.h" +#include "button.h" +#include "cros_board_info.h" #include "cros_cbi.h" +#include "driver/accel_bma4xx.h" +#include "driver/accelgyro_bmi323.h" +#include "gpio/gpio_int.h" #include "hooks.h" +#include "motion_sense.h" #include "motionsense_sensors.h" +#include "tablet_mode.h" #include <zephyr/devicetree.h> #include <zephyr/logging/log.h> LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); -/* - * Mainboard orientation support. - */ - -#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_inverted)) -#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel)) -#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro)) - static void form_factor_init(void) { int ret; uint32_t val; - /* - * If the firmware config indicates - * an inverted form factor, use the alternative - * rotation matrix. - */ - ret = cros_cbi_get_fw_config(FW_BASE_INVERSION, &val); + + /*check tabletmode*/ + ret = cros_cbi_get_fw_config(FW_TABLET, &val); if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", - FW_BASE_INVERSION); + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_TABLET); return; } - if (val == FW_BASE_INVERTED) { - LOG_INF("Switching to inverted base"); - motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT; - motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT; + if (val == FW_TABLET_NOT_PRESENT) { + LOG_INF("Clamshell: disable motionsense function."); + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu)); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l), + GPIO_DISCONNECTED); + + LOG_INF("Clamshell: disable volume button function."); + button_disable_gpio(BUTTON_VOLUME_UP); + button_disable_gpio(BUTTON_VOLUME_DOWN); + } else { + LOG_INF("Tablet: Enable motionsense function."); } } DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/nissa/uldren/src/kb_backlight.c b/zephyr/program/nissa/uldren/src/kb_backlight.c new file mode 100644 index 0000000000..1f73d3e8be --- /dev/null +++ b/zephyr/program/nissa/uldren/src/kb_backlight.c @@ -0,0 +1,34 @@ +/* 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 "board_config.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" + +#include <zephyr/devicetree.h> +#include <zephyr/logging/log.h> + +LOG_MODULE_DECLARE(uldren, CONFIG_NISSA_LOG_LEVEL); + +__override uint32_t board_override_feature_flags0(uint32_t flags0) +{ + int ret; + uint32_t val; + + /* + * Remove keyboard backlight feature for devices that don't support it. + */ + ret = cros_cbi_get_fw_config(FW_KB_BL, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL); + return flags0; + } + + if (val == FW_KB_BL_NOT_PRESENT) + return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB)); + else + return flags0; +} |