diff options
-rw-r--r-- | baseboard/volteer/baseboard.c | 17 | ||||
-rw-r--r-- | baseboard/volteer/baseboard.h | 17 | ||||
-rw-r--r-- | board/malefor/board.c | 34 | ||||
-rw-r--r-- | board/malefor/board.h | 7 |
4 files changed, 66 insertions, 9 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c index ee8cf8fc72..0964f53122 100644 --- a/baseboard/volteer/baseboard.c +++ b/baseboard/volteer/baseboard.c @@ -581,12 +581,27 @@ static void config_db_usb3(void) } static uint8_t board_id; +static uint32_t fw_config; uint8_t get_board_id(void) { return board_id; } +uint32_t get_fw_config(void) +{ + return fw_config; +} + +/* + * ec_config_has_tablet_mode() will return 1 is present or 0 + */ +enum ec_cfg_tablet_mode_type ec_config_has_tablet_mode(void) +{ + return ((get_fw_config() & EC_CFG_TABLET_MODE_MASK) + >> EC_CFG_TABLET_MODE_L); +} + __overridable void config_volteer_gpios(void) { } @@ -614,11 +629,11 @@ static void cbi_init(void) config_volteer_gpios(); /* FW config */ - if (cbi_get_fw_config(&cbi_val) != EC_SUCCESS) { CPRINTS("CBI: Read FW config failed, assuming USB4"); usb_db_val = USB_DB_USB4; } else { + fw_config = cbi_val; usb_db_val = CBI_FW_CONFIG_USB_DB_TYPE(cbi_val); } diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h index 7ce7acd673..f68fc431f6 100644 --- a/baseboard/volteer/baseboard.h +++ b/baseboard/volteer/baseboard.h @@ -279,6 +279,21 @@ enum usb_db_id { #define CBI_FW_CONFIG_USB_DB_TYPE(bits) \ (((bits) & CBI_FW_CONFIG_USB_DB_MASK) >> CBI_FW_CONFIG_USB_DB_SHIFT) +/* + * Tablet Mode (1 bit) + * + * ec_config_has_tablet_mode() will return 1 is present or 0 + */ +enum ec_cfg_tablet_mode_type { + TABLET_MODE_NO = 0, + TABLET_MODE_YES = 1, +}; +#define EC_CFG_TABLET_MODE_L 11 +#define EC_CFG_TABLET_MODE_H 11 +#define EC_CFG_TABLET_MODE_MASK \ + GENMASK(EC_CFG_TABLET_MODE_H,\ + EC_CFG_TABLET_MODE_L) + extern enum gpio_signal ps8xxx_rst_odl; void board_reset_pd_mcu(void); @@ -297,6 +312,8 @@ unsigned char get_board_id(void); */ __override_proto void config_volteer_gpios(void); +enum ec_cfg_tablet_mode_type ec_config_has_tablet_mode(void); + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BASEBOARD_H */ diff --git a/board/malefor/board.c b/board/malefor/board.c index 4953182917..4211bdfabc 100644 --- a/board/malefor/board.c +++ b/board/malefor/board.c @@ -15,6 +15,7 @@ #include "fan_chip.h" #include "gpio.h" #include "hooks.h" +#include "keyboard_scan.h" #include "lid_switch.h" #include "power.h" #include "power_button.h" @@ -29,10 +30,21 @@ #include "gpio_list.h" /* Must come after other header files. */ +#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args) + static void board_init(void) { - /* Enable gpio interrupt for base accelgyro sensor */ - gpio_enable_interrupt(GPIO_EC_IMU_INT_L); + if (ec_config_has_tablet_mode()) { + /* Enable gpio interrupt for base accelgyro sensor */ + gpio_enable_interrupt(GPIO_EC_IMU_INT_L); + } else { + motion_sensor_count = 0; + /* Device is clamshell only */ + tablet_set_mode(0); + /* Gyro is not present, don't allow line to float */ + gpio_set_flags(GPIO_EC_IMU_INT_L, GPIO_INPUT | GPIO_PULL_DOWN); + } /* Enable gpio interrupt for camera vsync */ gpio_enable_interrupt(GPIO_EC_CAM_VSYN_SLP_S0IX); @@ -47,6 +59,24 @@ static void board_init(void) } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); +int board_is_lid_angle_tablet_mode(void) +{ + return ec_config_has_tablet_mode(); +} + +/* Enable or disable input devices, based on tablet mode or chipset state */ +#ifndef TEST_BUILD +void lid_angle_peripheral_enable(int enable) +{ + if (ec_config_has_tablet_mode()) { + if (chipset_in_state(CHIPSET_STATE_ANY_OFF) || + tablet_get_mode()) + enable = 0; + keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE); + } +} +#endif + /******************************************************************************/ /* Sensors */ /* Lid and base Sensor mutex */ diff --git a/board/malefor/board.h b/board/malefor/board.h index 4b30fdc1d5..1ec6632a3d 100644 --- a/board/malefor/board.h +++ b/board/malefor/board.h @@ -26,6 +26,7 @@ /* Keyboard features */ /* Sensors */ +#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT #define CONFIG_ACCEL_LIS2DE /* Lid accel */ #define CONFIG_ACCELGYRO_LSM6DSM /* Base accel */ @@ -33,16 +34,10 @@ #define CONFIG_ACCEL_FORCE_MODE_MASK \ BIT(LID_ACCEL) -/* - * TODO: b/152434719 - Malefor will support 360-degree rotation of the - * lid on some SKUs, these macros will be enabled once covers are ready. - */ -#if 0 #define CONFIG_LID_ANGLE #define CONFIG_LID_ANGLE_UPDATE #define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL #define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL -#endif #define CONFIG_ACCEL_LSM6DSM_INT_EVENT \ TASK_EVENT_MOTION_SENSOR_INTERRUPT(BASE_ACCEL) |