blob: 285a8d5aaab384236aff61161a6dca657d53145c [file] [log] [blame]
Angel Pons89ab2502020-04-03 01:22:28 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Tobias Diedrichcee930a2017-02-12 14:09:06 +01002
3#include "ec.h"
4#include <ec/compal/ene932/ec.h>
5
6/* The keyboard matrix tells the EC how the keyboard is wired internally */
7static void set_keyboard_matrix_us(void)
8{
9 ec_kbc_write_cmd(0x59);
10 ec_kbc_write_ib(0xE5);
11}
12
13/* Tell EC to operate in APM mode. Events generate SMIs instead of SCIs */
14static void enter_apm_mode(void)
15{
16 ec_kbc_write_cmd(0x59);
17 ec_kbc_write_ib(0xE9);
18}
19
20void lenovo_s230u_ec_init(void)
21{
22 set_keyboard_matrix_us();
23
24 /*
25 * The EC has a special "blinking Caps Lock LED" mode which it normally
26 * enters when it believes the OS is not responding. It occasionally
27 * disables battery charging when in this mode, although other
28 * functionality is unaffected. Although the EC starts in APM mode by
29 * default, it only leaves the "blinking Caps Lock LED" mode after
30 * receiving the following command.
31 */
32 enter_apm_mode();
33
34 /* Enable external USB port power. */
35 ec_mm_set_bit(0x3b, 4);
36}