diff options
author | Scott Chao <scott_chao@wistron.corp-partner.google.com> | 2022-03-23 14:44:58 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-03-26 02:30:03 +0000 |
commit | b81c17122e7e4c206d91446bcd7ec039397c3e08 (patch) | |
tree | bbfa36dd09d2159f6824d6b41ba383c42b09e768 /board/primus/ps2.c | |
parent | 81dff9c98a666237f2045b5d5e56cf63f98ff228 (diff) | |
download | chrome-ec-b81c17122e7e4c206d91446bcd7ec039397c3e08.tar.gz |
primus: send suspend mode to trackpointstabilize-voshyr-14637.B-main
BUG=b:226215983
BRANCH=none
TEST=make -j BOARD=primus
TEST=verify by EE
Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com>
Change-Id: I139c8a628f9c01ce299b7ec650839f67ca99a12e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3544753
Reviewed-by: caveh jalali <caveh@chromium.org>
Commit-Queue: caveh jalali <caveh@chromium.org>
Diffstat (limited to 'board/primus/ps2.c')
-rw-r--r-- | board/primus/ps2.c | 81 |
1 files changed, 79 insertions, 2 deletions
diff --git a/board/primus/ps2.c b/board/primus/ps2.c index d91527c508..e5ac1f0aa7 100644 --- a/board/primus/ps2.c +++ b/board/primus/ps2.c @@ -3,20 +3,27 @@ * found in the LICENSE file. */ +#include <stddef.h> + +#include "cbi_ssfc.h" #include "gpio.h" #include "hooks.h" #include "keyboard_8042.h" +#include "ps2.h" #include "ps2_chip.h" #include "time.h" +#include "registers.h" + +#define PS2_TRANSMIT_DELAY_MS 10 void send_aux_data_to_device(uint8_t data) { - ps2_transmit_byte(NPCX_PS2_CH1, data); + ps2_transmit_byte(PRIMUS_PS2_CH, data); } static void board_init(void) { - ps2_enable_channel(NPCX_PS2_CH1, 1, send_aux_data_to_host_interrupt); + ps2_enable_channel(PRIMUS_PS2_CH, 1, send_aux_data_to_host_interrupt); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -43,3 +50,73 @@ static void disable_ps2(void) hook_call_deferred(&enable_ps2_data, 2 * SECOND); } DECLARE_HOOK(HOOK_CHIPSET_RESET, disable_ps2, HOOK_PRIO_DEFAULT); + +static void ps2_transmit(uint8_t cmd) +{ + ps2_transmit_byte(PRIMUS_PS2_CH, cmd); + msleep(PS2_TRANSMIT_DELAY_MS); +} + +static void send_command_to_trackpoint(uint8_t command1, uint8_t command2) +{ + /* + * Send command to trackpoint and wait, + * this will make sure EC get ACK from PS2 device + * and send the next command. + */ + + ps2_transmit(TP_COMMAND); + ps2_transmit(TP_TOGGLE); + ps2_transmit(command1); + ps2_transmit(command2); +} + +int get_trackpoint_id(void) +{ + if (get_cbi_ssfc_trackpoint() == SSFC_SENSOR_TRACKPOINT_ELAN) + return TP_VARIANT_ELAN; + else + return TP_VARIANT_SYNAPTICS; +} + +/* Called on AP S0 -> S3 transition */ +static void ps2_suspend(void) +{ + int trackpoint_id; + /* + * When EC send PS2 command to PS2 device, + * PS2 device will return ACK(0xFA). + * EC will send it to host and cause host wake from suspend. + * So disable EC send data to host to avoid it. + */ + ps2_enable_channel(PRIMUS_PS2_CH, 1, NULL); + trackpoint_id = get_trackpoint_id(); + /* + * Send suspend mode to trackpoint + * Those commands was provide by Elan and Synaptics + */ + if (trackpoint_id == TP_VARIANT_ELAN) + send_command_to_trackpoint(TP_TOGGLE_BURST, + TP_TOGGLE_ELAN_SLEEP); + else if (trackpoint_id == TP_VARIANT_SYNAPTICS) + send_command_to_trackpoint(TP_TOGGLE_SOURCE_TAG, + TP_TOGGLE_SNAPTICS_SLEEP); +} +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, ps2_suspend, HOOK_PRIO_DEFAULT); + +/* Called on AP S3 -> S0 transition */ +static void ps2_resume(void) +{ + int trackpoint_id; + + trackpoint_id = get_trackpoint_id(); + ps2_enable_channel(PRIMUS_PS2_CH, 1, send_aux_data_to_host_interrupt); + /* + * For Synaptics trackpoint, EC need to send command to it again. + * For Elan trackpoint, we just need to touch trackpoint and it wake. + */ + if (trackpoint_id == TP_VARIANT_SYNAPTICS) + send_command_to_trackpoint(TP_TOGGLE_SOURCE_TAG, + TP_TOGGLE_SNAPTICS_SLEEP); +} +DECLARE_HOOK(HOOK_CHIPSET_RESUME, ps2_resume, HOOK_PRIO_DEFAULT); |