diff options
Diffstat (limited to 'board')
-rw-r--r-- | board/boten/board.c | 83 | ||||
-rw-r--r-- | board/boten/board.h | 2 |
2 files changed, 53 insertions, 32 deletions
diff --git a/board/boten/board.c b/board/boten/board.c index b6301834bf..17436a0091 100644 --- a/board/boten/board.c +++ b/board/boten/board.c @@ -7,6 +7,7 @@ #include "adc_chip.h" #include "button.h" +#include "cbi_fw_config.h" #include "charge_manager.h" #include "charge_state_v2.h" #include "charger.h" @@ -216,37 +217,6 @@ const int usb_port_enable[USB_PORT_COUNT] = { GPIO_EN_USB_A0_VBUS, }; -void board_init(void) -{ - gpio_enable_interrupt(GPIO_USB_C0_INT_ODL); - gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL); - /* Enable gpio interrupt for base accelgyro sensor */ - gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); - gpio_enable_interrupt(GPIO_HDMI_HPD_SUB_ODL); - /* Enable gpio interrupt for pen detect */ - gpio_enable_interrupt(GPIO_PEN_DET_ODL); - - /* Make sure pen detection is triggered or not at sysjump */ - if (!gpio_get_level(GPIO_PEN_DET_ODL)) - gpio_set_level(GPIO_EN_PP5000_PEN, 1); - - if (gpio_get_level(GPIO_PEN_DET_ODL)) - gpio_set_level(GPIO_PEN_DET_PCH, 1); - - /* Set LEDs luminance */ - pwm_set_duty(PWM_CH_LED_RED, 70); - pwm_set_duty(PWM_CH_LED_GREEN, 70); - pwm_set_duty(PWM_CH_LED_WHITE, 70); - - /* - * If interrupt lines are already low, schedule them to be processed - * after inits are completed. - */ - if (!gpio_get_level(GPIO_USB_C0_INT_ODL)) - hook_call_deferred(&check_c0_line_data, 0); -} -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); - void board_reset_pd_mcu(void) { /* @@ -467,7 +437,56 @@ struct motion_sensor_t motion_sensors[] = { }, }; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +void board_init(void) +{ + gpio_enable_interrupt(GPIO_USB_C0_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL); + gpio_enable_interrupt(GPIO_HDMI_HPD_SUB_ODL); + if (get_cbi_fw_config_tablet_mode() == TABLET_MODE_PRESENT) { + motion_sensor_count = ARRAY_SIZE(motion_sensors); + /* Enable gpio interrupt for base accelgyro sensor */ + gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); + + /* Enable gpio interrupt for pen detect */ + gpio_enable_interrupt(GPIO_PEN_DET_ODL); + + /* Make sure pen detection is triggered or not at sysjump */ + if (!gpio_get_level(GPIO_PEN_DET_ODL)) + gpio_set_level(GPIO_EN_PP5000_PEN, 1); + + if (gpio_get_level(GPIO_PEN_DET_ODL)) + gpio_set_level(GPIO_PEN_DET_PCH, 1); + } else { + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + /* Base accel is not stuffed, don't allow line to float */ + gpio_set_flags(GPIO_BASE_SIXAXIS_INT_L, + GPIO_INPUT | GPIO_PULL_DOWN); + + /* only clamshell sku todo */ + gpio_set_flags(GPIO_PEN_DET_ODL, GPIO_INPUT | GPIO_PULL_DOWN); + gpio_set_flags(GPIO_PEN_DET_PCH, GPIO_INPUT | GPIO_PULL_DOWN); + gpio_set_flags(GPIO_EN_PP5000_PEN, GPIO_INPUT | GPIO_PULL_DOWN); + gpio_set_flags(GPIO_LID_360_L, GPIO_INPUT | GPIO_PULL_DOWN); + gpio_set_flags(GPIO_VOLUP_BTN_ODL, GPIO_INPUT | GPIO_PULL_DOWN); + gpio_set_flags(GPIO_VOLDN_BTN_ODL, GPIO_INPUT | GPIO_PULL_DOWN); + } + + /* Set LEDs luminance */ + pwm_set_duty(PWM_CH_LED_RED, 70); + pwm_set_duty(PWM_CH_LED_GREEN, 70); + pwm_set_duty(PWM_CH_LED_WHITE, 70); + + /* + * If interrupt lines are already low, schedule them to be processed + * after inits are completed. + */ + if (!gpio_get_level(GPIO_USB_C0_INT_ODL)) + hook_call_deferred(&check_c0_line_data, 0); +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); /* Thermistors */ const struct temp_sensor_t temp_sensors[] = { diff --git a/board/boten/board.h b/board/boten/board.h index 0e2a72015c..8c2b1d4417 100644 --- a/board/boten/board.h +++ b/board/boten/board.h @@ -93,6 +93,8 @@ #define USB_PORT_COUNT 1 #define CONFIG_USB_PORT_POWER_DUMB +#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT + #ifndef __ASSEMBLER__ #include "gpio_signal.h" |