aboutsummaryrefslogtreecommitdiff
path: root/src/mainboard/lenovo/g505s/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainboard/lenovo/g505s/ec.c')
-rw-r--r--src/mainboard/lenovo/g505s/ec.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mainboard/lenovo/g505s/ec.c b/src/mainboard/lenovo/g505s/ec.c
new file mode 100644
index 0000000000..61f70b7a4e
--- /dev/null
+++ b/src/mainboard/lenovo/g505s/ec.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 Alexandru Gagniuc <mr.nuke.me@gmail.com>
+ * Subject to the GNU GPL v2, or (at your option) any later version.
+ */
+
+#include "ec.h"
+#include <ec/compal/ene932/ec.h>
+
+/* The keyboard matrix tells the EC how the keyboard is wired internally */
+static void set_keyboard_matrix_us(void)
+{
+ ec_kbc_write_cmd(0x59);
+ ec_kbc_write_ib(0xE5);
+}
+
+/* Tell EC to operate in APM mode. Events generate SMIs instead of SCIs */
+static void enter_apm_mode(void)
+{
+ ec_kbc_write_cmd(0x59);
+ ec_kbc_write_ib(0xE9);
+}
+
+void lenovo_g505s_ec_init(void)
+{
+ set_keyboard_matrix_us();
+
+ /*
+ * The EC has a special "blinking Caps Lock LED" mode which it normally
+ * enters when it believes the OS is not responding. It occasionally
+ * disables battery charging when in this mode, although other
+ * functionality is unaffected. Although the EC starts in APM mode by
+ * default, it only leaves the "blinking Caps Lock LED" mode after
+ * receiving the following command.
+ */
+ enter_apm_mode();
+}