diff options
author | Ben Chen <ben.chen2@quanta.corp-partner.google.com> | 2021-12-08 13:40:22 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-12-10 03:07:37 +0000 |
commit | dbb5497c8fd865e61c53bc17a45b25577db6e6e9 (patch) | |
tree | e0c58ab9643e3cb200666296aa5102f8d0a6582c /board/magolor | |
parent | 4da48bfb0355e52b98e37c1f91b6f707aa480993 (diff) | |
download | chrome-ec-dbb5497c8fd865e61c53bc17a45b25577db6e6e9.tar.gz |
magolor: support Pen detected with fw_config
control pen control by stylus fw_config fiedl to enable/disable.
BUG=b:167983049
BRANCH=dedede
TEST=build BOARD PASS and EE check is PASS.
Change-Id: Ifce1799ef36540b2df4dd6fe60de82869160c4b5
Signed-off-by: Ben Chen <ben.chen2@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3322219
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'board/magolor')
-rw-r--r-- | board/magolor/board.c | 41 | ||||
-rw-r--r-- | board/magolor/board.h | 1 | ||||
-rw-r--r-- | board/magolor/gpio.inc | 3 |
3 files changed, 44 insertions, 1 deletions
diff --git a/board/magolor/board.c b/board/magolor/board.c index 3d3765dbe0..ca656fcf0d 100644 --- a/board/magolor/board.c +++ b/board/magolor/board.c @@ -805,6 +805,37 @@ struct motion_sensor_t motion_sensors[] = { unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); +/** + * Handle debounced pen input changing state. + */ +static void pendetect_deferred(void) +{ + int pen_charge_enable = !gpio_get_level(GPIO_PEN_DET_ODL) && + !chipset_in_state(CHIPSET_STATE_ANY_OFF); + + if (pen_charge_enable) + gpio_set_level(GPIO_EN_PP5000_PEN, 1); + else + gpio_set_level(GPIO_EN_PP5000_PEN, 0); + + CPRINTS("Pen charge %sable", pen_charge_enable ? "en" : "dis"); +} +DECLARE_DEFERRED(pendetect_deferred); + +void pen_detect_interrupt(enum gpio_signal signal) +{ + /* pen input debounce time */ + hook_call_deferred(&pendetect_deferred_data, (100 * MSEC)); +} + +static void pen_charge_check(void) +{ + if (get_cbi_fw_config_stylus() == STYLUS_PRESENT) + hook_call_deferred(&pendetect_deferred_data, (100 * MSEC)); +} +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, pen_charge_check, HOOK_PRIO_LAST); +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, pen_charge_check, HOOK_PRIO_LAST); + void board_init(void) { int on; @@ -874,6 +905,16 @@ void board_init(void) GPIO_INPUT | GPIO_PULL_DOWN); } + if (get_cbi_fw_config_stylus() == STYLUS_PRESENT) { + gpio_enable_interrupt(GPIO_PEN_DET_ODL); + /* Make sure pen detection is triggered or not at sysjump */ + pen_charge_check(); + } else { + gpio_disable_interrupt(GPIO_PEN_DET_ODL); + gpio_set_flags(GPIO_PEN_DET_ODL, + GPIO_INPUT | GPIO_PULL_DOWN); + } + /* Turn on 5V if the system is on, otherwise turn it off. */ on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_SOFT_OFF); diff --git a/board/magolor/board.h b/board/magolor/board.h index c1ef73cc64..9b7117fa0c 100644 --- a/board/magolor/board.h +++ b/board/magolor/board.h @@ -208,5 +208,6 @@ enum battery_type { }; void motion_interrupt(enum gpio_signal signal); +void pen_detect_interrupt(enum gpio_signal s); #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/magolor/gpio.inc b/board/magolor/gpio.inc index b7b692ca56..00a6b4effc 100644 --- a/board/magolor/gpio.inc +++ b/board/magolor/gpio.inc @@ -37,6 +37,7 @@ GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH, lid_interrupt) GPIO_INT(EC_WP_OD, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt) GPIO_INT(BASE_SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING | GPIO_SEL_1P8V, motion_interrupt) GPIO_INT(LID_360_L, PIN(9, 5), GPIO_INT_BOTH, gmr_tablet_switch_isr) +GPIO_INT(PEN_DET_ODL, PIN(5, 0), GPIO_INT_BOTH, pen_detect_interrupt) /* I2C Ports */ GPIO(EC_I2C_EEPROM_SCL, PIN(B, 3), GPIO_INPUT) @@ -57,7 +58,7 @@ GPIO(EC_SUB_IO_2, PIN(3, 4), GPIO_OUT_LOW) GPIO(EN_VCCIO_EXT, PIN(6, 1), GPIO_OUT_LOW) /* TODO(b:149775160) - Modify if needed if we ever use this signal. */ GPIO(EN_VCCST, PIN(A, 7), GPIO_INPUT) -GPIO(EN_PP3300_PEN, PIN(6, 3), GPIO_OUT_LOW) +GPIO(EN_PP5000_PEN, PIN(6, 3), GPIO_OUT_LOW) GPIO(EN_PP3300_A, PIN(0, 3), GPIO_OUT_LOW) GPIO(EN_PP5000_U, PIN(A, 4), GPIO_OUT_LOW) GPIO(EN_SLP_Z, PIN(8, 3), GPIO_OUT_LOW) |