diff options
author | Ivan Chen <yulunchen@google.com> | 2023-05-17 03:32:45 +0000 |
---|---|---|
committer | Ivan Chen <yulunchen@google.com> | 2023-05-17 03:32:45 +0000 |
commit | d7c9c6beb03ee5725232b9ac3bfe4825e1e227cb (patch) | |
tree | 3a0d6776c0e76e325d1b087cd51a850cb871358e /zephyr/program/nissa | |
parent | 8641442366bd7c2c133e302a57f904dfac3c896b (diff) | |
parent | b34dc2ae9022e2fbb57ae6477891ff32954c62fd (diff) | |
download | chrome-ec-firmware-brya-14505.B-main.tar.gz |
Merge remote-tracking branch cros/main into firmware-brya-14505.B-mainfirmware-brya-14505.B-main
Generated by: util/update_release_branch.py --board brya firmware-brya-14505.B-main
Relevant changes:
git log --oneline 8641442366..b34dc2ae90 -- board/brya board/brya
util/getversion.sh
BRANCH=None
TEST=`make -j buildall`
Force-Relevant-Builds: all
Change-Id: I63149b4c1782b3ed57f2556755901c21f5f1e3e9
Signed-off-by: Ivan Chen <yulunchen@google.com>
Diffstat (limited to 'zephyr/program/nissa')
-rw-r--r-- | zephyr/program/nissa/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/program/nissa/craask/src/led.c | 2 | ||||
-rw-r--r-- | zephyr/program/nissa/joxer/cbi.dtsi | 21 | ||||
-rw-r--r-- | zephyr/program/nissa/joxer/motionsense.dtsi | 6 | ||||
-rw-r--r-- | zephyr/program/nissa/joxer/src/form_factor.c | 39 | ||||
-rw-r--r-- | zephyr/program/nissa/uldren/motionsense.dtsi | 8 | ||||
-rw-r--r-- | zephyr/program/nissa/yavilla/gpio.dtsi | 18 | ||||
-rw-r--r-- | zephyr/program/nissa/yavilla/motionsense.dtsi | 148 | ||||
-rw-r--r-- | zephyr/program/nissa/yavilla/overlay.dtsi | 34 | ||||
-rw-r--r-- | zephyr/program/nissa/yavilla/project.conf | 16 | ||||
-rw-r--r-- | zephyr/program/nissa/yavilla/project.overlay | 1 | ||||
-rw-r--r-- | zephyr/program/nissa/yavilla/src/board.c | 36 |
12 files changed, 306 insertions, 24 deletions
diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt index cd45f00a3a..88e2d1c8a4 100644 --- a/zephyr/program/nissa/CMakeLists.txt +++ b/zephyr/program/nissa/CMakeLists.txt @@ -71,6 +71,7 @@ if(DEFINED CONFIG_BOARD_JOXER) zephyr_library_sources( "joxer/src/led.c" "joxer/src/keyboard.c" + "joxer/src/form_factor.c" ) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "joxer/src/usbc.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "joxer/src/charger.c") diff --git a/zephyr/program/nissa/craask/src/led.c b/zephyr/program/nissa/craask/src/led.c index 0af0202cf4..b3aefa3ab2 100644 --- a/zephyr/program/nissa/craask/src/led.c +++ b/zephyr/program/nissa/craask/src/led.c @@ -22,7 +22,7 @@ __override struct led_descriptor LED_INDEFINITE } }, [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE, LED_INDEFINITE } }, - [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_BLUE, LED_INDEFINITE } }, [STATE_DISCHARGE_S3] = { { EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC }, diff --git a/zephyr/program/nissa/joxer/cbi.dtsi b/zephyr/program/nissa/joxer/cbi.dtsi index afbd125b32..71424ed681 100644 --- a/zephyr/program/nissa/joxer/cbi.dtsi +++ b/zephyr/program/nissa/joxer/cbi.dtsi @@ -28,5 +28,26 @@ value = <1>; }; }; + + /* + * FW_CONFIG field to describe lid accelerometer orientation. + */ + lid-inversion { + enum-name = "FW_LID_INVERSION"; + start = <5>; + size = <1>; + + default { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "SENSOR_DEFAULT"; + value = <0>; + default; + }; + inverted { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "SENSOR_INVERTED"; + value = <1>; + }; + }; }; }; diff --git a/zephyr/program/nissa/joxer/motionsense.dtsi b/zephyr/program/nissa/joxer/motionsense.dtsi index e9c46a849a..fbac470660 100644 --- a/zephyr/program/nissa/joxer/motionsense.dtsi +++ b/zephyr/program/nissa/joxer/motionsense.dtsi @@ -40,6 +40,12 @@ 0 0 (-1)>; }; + lid_rot_inverted: lid-rotation-inverted { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + base_rot_ref: base-rotation-ref { mat33 = <1 0 0 0 1 0 diff --git a/zephyr/program/nissa/joxer/src/form_factor.c b/zephyr/program/nissa/joxer/src/form_factor.c new file mode 100644 index 0000000000..1087d7ddca --- /dev/null +++ b/zephyr/program/nissa/joxer/src/form_factor.c @@ -0,0 +1,39 @@ +/* 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 "accelgyro.h" +#include "cros_cbi.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +#include <zephyr/devicetree.h> +#include <zephyr/logging/log.h> + +LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_inverted)) +#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) + +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_LID_INVERSION, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", + FW_LID_INVERSION); + return; + } + if (val == SENSOR_INVERTED) { + LOG_INF("Switching to inverted lid"); + motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/nissa/uldren/motionsense.dtsi b/zephyr/program/nissa/uldren/motionsense.dtsi index 70b381b843..baaec61e5e 100644 --- a/zephyr/program/nissa/uldren/motionsense.dtsi +++ b/zephyr/program/nissa/uldren/motionsense.dtsi @@ -35,14 +35,14 @@ motionsense-rotation-ref { compatible = "cros-ec,motionsense-rotation-ref"; lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 + mat33 = <0 1 0 (-1) 0 0 - 0 0 (-1)>; + 0 0 1>; }; base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 + mat33 = <1 0 0 + 0 1 0 0 0 1>; }; }; diff --git a/zephyr/program/nissa/yavilla/gpio.dtsi b/zephyr/program/nissa/yavilla/gpio.dtsi index a18e674b11..8c76048f25 100644 --- a/zephyr/program/nissa/yavilla/gpio.dtsi +++ b/zephyr/program/nissa/yavilla/gpio.dtsi @@ -34,6 +34,9 @@ named-gpios { compatible = "named-gpios"; + gpio_acc_int_l: acc_int_l { + gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; gpio_all_sys_pwrgd: all_sys_pwrgd { gpios = <&gpiob 7 GPIO_INPUT>; }; @@ -134,6 +137,9 @@ gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>; enum-name = "GPIO_POWER_BUTTON_L"; }; + gpio_imu_int_l: imu_int_l { + gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; gpio_imvp91_vrrdy_od: imvp91_vrrdy_od { gpios = <&gpioj 4 GPIO_INPUT>; no-auto-init; @@ -178,6 +184,10 @@ gpios = <&gpiod 1 GPIO_ODR_HIGH>; no-auto-init; }; + gpio_tablet_mode_l: tablet_mode_l { + gpios = <&gpioa 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp { gpios = <&gpiol 5 GPIO_OUTPUT>; enum-name = "GPIO_USB1_ILIM_SEL"; @@ -216,6 +226,14 @@ gpios = <&gpioksol 2 GPIO_OUTPUT_HIGH>; enum-name = "GPIO_KBD_KSO2"; }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpioi 6 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpioi 7 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; }; named-i2c-ports { diff --git a/zephyr/program/nissa/yavilla/motionsense.dtsi b/zephyr/program/nissa/yavilla/motionsense.dtsi new file mode 100644 index 0000000000..df84c36471 --- /dev/null +++ b/zephyr/program/nissa/yavilla/motionsense.dtsi @@ -0,0 +1,148 @@ +/* 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 <dt-bindings/motionsense/utils.h> + + +/ { + aliases { + /* + * Interrupt bindings for sensor devices. + */ + bmi3xx-int = &base_accel; + bma4xx-int = &lid_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: base-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 (-1) 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + + bma422_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + * TODO(b/238139272): The first entries of the array must be + * accelerometers,then gyroscope. Fix this dependency in the DTS + * processing which makes the devicetree entries independent. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&bma422_data>; + i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY"; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi323_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_ec_i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi323_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_imu &int_acc>; + }; +}; diff --git a/zephyr/program/nissa/yavilla/overlay.dtsi b/zephyr/program/nissa/yavilla/overlay.dtsi index b60ad2f476..c75ae9dd79 100644 --- a/zephyr/program/nissa/yavilla/overlay.dtsi +++ b/zephyr/program/nissa/yavilla/overlay.dtsi @@ -49,6 +49,16 @@ flags = <GPIO_INT_EDGE_BOTH>; handler = "power_button_interrupt"; }; + int_vol_down: vol_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_vol_up: vol_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; int_wp_l: wp_l { irq-pin = <&gpio_ec_wp_odl>; flags = <GPIO_INT_EDGE_BOTH>; @@ -59,6 +69,21 @@ flags = <GPIO_INT_EDGE_BOTH>; handler = "lid_interrupt"; }; + int_tablet_mode: tablet_mode { + irq-pin = <&gpio_tablet_mode_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "gmr_tablet_switch_isr"; + }; + int_acc: lid_imu { + irq-pin = <&gpio_acc_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "bma4xx_interrupt"; + }; + int_imu: ec_imu { + irq-pin = <&gpio_imu_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "bmi3xx_interrupt"; + }; int_usb_c0: usb_c0 { irq-pin = <&gpio_usb_c0_int_odl>; flags = <GPIO_INT_EDGE_FALLING>; @@ -73,14 +98,9 @@ unused-pins { compatible = "unused-gpios"; - unused-gpios = <&gpioa 7 0>, - <&gpioc 0 0>, - <&gpioc 6 0>, + unused-gpios = <&gpioc 6 0>, <&gpiod 7 0>, <&gpioh 2 0>, - <&gpioi 6 0>, - <&gpioi 7 0>, - <&gpioj 0 0>, <&gpioj 3 0>, <&gpiok 7 GPIO_OUTPUT>; }; @@ -292,7 +312,7 @@ &i2c2 { label = "I2C_SENSOR"; - clock-frequency = <I2C_BITRATE_FAST>; + clock-frequency = <I2C_BITRATE_STANDARD>; pinctrl-0 = <&i2c2_clk_gpf6_default &i2c2_data_gpf7_default>; pinctrl-names = "default"; diff --git a/zephyr/program/nissa/yavilla/project.conf b/zephyr/program/nissa/yavilla/project.conf index 30818c4419..8011391adf 100644 --- a/zephyr/program/nissa/yavilla/project.conf +++ b/zephyr/program/nissa/yavilla/project.conf @@ -8,17 +8,11 @@ CONFIG_BOARD_YAVILLA=y CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y -# Sensors: disabled; yavilla is clamshell-only -CONFIG_PLATFORM_EC_LID_ANGLE=n -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n -CONFIG_PLATFORM_EC_ACCEL_FIFO=n -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n -CONFIG_PLATFORM_EC_TABLET_MODE=n -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n +# Sensors +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 # Keyboard diff --git a/zephyr/program/nissa/yavilla/project.overlay b/zephyr/program/nissa/yavilla/project.overlay index 97f431022c..40bbaec4bb 100644 --- a/zephyr/program/nissa/yavilla/project.overlay +++ b/zephyr/program/nissa/yavilla/project.overlay @@ -9,5 +9,6 @@ #include "fan.dtsi" #include "gpio.dtsi" #include "keyboard.dtsi" +#include "motionsense.dtsi" #include "overlay.dtsi" #include "power_signals.dtsi" diff --git a/zephyr/program/nissa/yavilla/src/board.c b/zephyr/program/nissa/yavilla/src/board.c index f89b92ebd8..feee5fa91f 100644 --- a/zephyr/program/nissa/yavilla/src/board.c +++ b/zephyr/program/nissa/yavilla/src/board.c @@ -3,14 +3,19 @@ * found in the LICENSE file. */ /* yavilla hardware configuration */ +#include "cros_cbi.h" #include "gpio/gpio_int.h" #include "hooks.h" +#include "motion_sense.h" +#include "tablet_mode.h" #include "task.h" +#include <zephyr/devicetree.h> #include <zephyr/drivers/gpio.h> #include <zephyr/drivers/pinctrl.h> #include <zephyr/init.h> #include <zephyr/kernel.h> +#include <zephyr/logging/log.h> #include <zephyr/sys/printk.h> LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL); __override uint8_t board_get_usb_pd_port_count(void) @@ -22,10 +27,39 @@ __override uint8_t board_get_usb_pd_port_count(void) */ static void board_init(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; + } + /* * Enable USB-C interrupts. */ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0)); gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1)); + + /* + * Disable tablet related interrupts for tablet absent DUT. + */ + if (val == FW_TABLET_ABSENT) { + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu)); + /* Base accel is not stuffed, don't allow line to float */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l), + GPIO_INPUT | GPIO_PULL_DOWN); + /* Lid accel is not stuffed, don't allow line to float */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_acc_int_l), + GPIO_INPUT | GPIO_PULL_DOWN); + LOG_INF("Clameshell: Disable motion sensors and gmr sensor!"); + } else + LOG_INF("Convertible!!!"); } -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_POST_I2C); |