Skip to content

Commit 3acd0d2

Browse files
committed
azalea: fixed PS2 yellow band
add function can delay EC release irq and clear IBF it will let host not send data too fast, make EC have time to process 8042 data and also not lose data after delay finish read HIKMDI clear IBF data and release 8042 irq verify: run STPM warmboot tools 0/500. (warmboot will let PS2 driver init) Signed-off-by: LeoCX_Tsai <LeoCX_Tsai@compal.com>
1 parent d671dc0 commit 3acd0d2

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

zephyr/program/lotus/azalea/project.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ CONFIG_PLATFORM_EC_PWM_KBLIGHT=y
2424
CONFIG_PLATFORM_EC_KEYBOARD_VIVALDI=n
2525
CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y
2626
CONFIG_PLATFORM_KEYBOARD_SCANCODE_CALLBACK=y
27+
28+
# Thrid party change
29+
CONFIG_THIRD_PARTY_CUSTOMIZED_DESIGN=y

zephyr/shim/src/espi.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,67 @@ void lpc_aux_put_char(uint8_t chr, int send_irq)
644644
LOG_INF("AUX put %02x", kb_char);
645645
}
646646

647+
#ifdef CONFIG_THIRD_PARTY_CUSTOMIZED_DESIGN
648+
649+
/*
650+
* this can delay EC release irq and clear IBF
651+
* it will let host not send data too fast, make EC
652+
* have time to process 8042 data and also not lose data
653+
* after delay finish read HIKMDI clear IBF data and release 8042 irq
654+
*/
655+
static void lpc_kbc_process(void)
656+
{
657+
int rv;
658+
uint32_t status;
659+
660+
rv = espi_read_lpc_request(espi_dev, E8042_CLEAR_IBF, &status);
661+
if (rv) {
662+
LOG_ERR("ESPI read failed: E8042_CLEAR_IBF = %d", rv);
663+
return;
664+
}
665+
666+
rv = espi_write_lpc_request(espi_dev, E8042_RESUME_IRQ, 0);
667+
if (rv) {
668+
LOG_ERR("ESPI write failed: E8042_RESUME_IRQ = %d", rv);
669+
}
670+
}
671+
DECLARE_DEFERRED(lpc_kbc_process);
672+
673+
static void kbc_ibf_obe_handler(uint32_t data)
674+
{
675+
#ifdef HAS_TASK_KEYPROTO
676+
uint8_t is_ibf = is_8042_ibf(data);
677+
uint32_t status = I8042_AUX_DATA;
678+
int rv;
679+
680+
if (is_ibf == HOST_KBC_EVT_IBF) {
681+
682+
/* put data to queue and trigger 8042 task*/
683+
keyboard_host_write(get_8042_data(data), get_8042_type(data));
684+
685+
/* Pause 8042 irq let KB task process data */
686+
rv = espi_write_lpc_request(espi_dev, E8042_PAUSE_IRQ, 0);
687+
if (rv) {
688+
LOG_ERR("ESPI write failed: E8042_PAUSE_IRQ = %d", rv);
689+
}
690+
691+
hook_call_deferred(&lpc_kbc_process_data, 200);
692+
693+
} else if (IS_ENABLED(CONFIG_8042_AUX)) {
694+
rv = espi_write_lpc_request(espi_dev, E8042_CLEAR_FLAG,
695+
&status);
696+
if (rv) {
697+
LOG_ERR("ESPI write failed: E8042_CLEAR_FLAG = %d", rv);
698+
}
699+
}
700+
701+
/* OBE data coming */
702+
if (is_ibf != HOST_KBC_EVT_IBF)
703+
task_wake(TASK_ID_KEYPROTO);
704+
705+
#endif
706+
}
707+
#else
647708
static void kbc_ibf_obe_handler(uint32_t data)
648709
{
649710
#ifdef HAS_TASK_KEYPROTO
@@ -663,6 +724,7 @@ static void kbc_ibf_obe_handler(uint32_t data)
663724
task_wake(TASK_ID_KEYPROTO);
664725
#endif
665726
}
727+
#endif
666728

667729
int lpc_keyboard_input_pending(void)
668730
{

0 commit comments

Comments
 (0)