summaryrefslogtreecommitdiff
path: root/driver/led
diff options
context:
space:
mode:
authorElmo_Lan <elmo_lan@compal.corp-partner.google.com>2018-01-23 07:12:46 -0500
committerchrome-bot <chrome-bot@chromium.org>2018-03-02 22:22:34 -0800
commit6790a884a46f18e858a6b308d3b00f86ef915e3f (patch)
tree4bf4cbcfd33118ccba1b66464c5af1d52b5d47df /driver/led
parentf32d92b7f5aa5e6951133bb7b893d264b1bb70e2 (diff)
downloadchrome-ec-6790a884a46f18e858a6b308d3b00f86ef915e3f.tar.gz
Nami: add keyboard backlight function
Base on LM3509 chip. Add file LM3509.C and LM3509.H to control keyboard backlight when S0/LidOpen is turn on, others is turn off. BUG=b:73055990 BRANCH=none TEST=Verify keyboard backlight function in resume and suspend. S0/LidOpen is turn on; S4/S5/G3/LidClose is turn off. Change-Id: Ief9e385f969c9dfc9e8f0d4e47ea7803cee747aa Signed-off-by: Elmo_Lan <elmo_lan@compal.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/881081 Commit-Ready: Raymond Chou <raymond_chou@compal.corp-partner.google.com> Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Diffstat (limited to 'driver/led')
-rw-r--r--driver/led/lm3509.c43
-rw-r--r--driver/led/lm3509.h24
2 files changed, 67 insertions, 0 deletions
diff --git a/driver/led/lm3509.c b/driver/led/lm3509.c
new file mode 100644
index 0000000000..463627a210
--- /dev/null
+++ b/driver/led/lm3509.c
@@ -0,0 +1,43 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * TI LM3509 LED driver.
+ */
+
+#include "i2c.h"
+#include "lm3509.h"
+
+inline int lm3509_write(uint8_t reg, uint8_t val)
+{
+ return i2c_write8(I2C_PORT_KBLIGHT, LM3509_I2C_ADDR, reg, val);
+}
+
+int lm3509_poweron(void)
+{
+ int ret = 0;
+
+ /* BIT= description
+ * [2]= set both main and seconfary current same, both control by BMAIN.
+ * [1]= enable secondary current sink.
+ * [0]= enable main current sink.
+ */
+ ret |= lm3509_write(LM3509_REG_GP, 0x07);
+ /* Brigntness register
+ * 0x00= 0%
+ * 0x1F= 100%
+ */
+ ret |= lm3509_write(LM3509_REG_BMAIN, 0x1F);
+
+ return ret;
+}
+
+int lm3509_poweroff(void)
+{
+ int ret = 0;
+
+ ret |= lm3509_write(LM3509_REG_GP, 0x00);
+ ret |= lm3509_write(LM3509_REG_BMAIN, 0x00);
+
+ return ret;
+}
diff --git a/driver/led/lm3509.h b/driver/led/lm3509.h
new file mode 100644
index 0000000000..ca8c67edbf
--- /dev/null
+++ b/driver/led/lm3509.h
@@ -0,0 +1,24 @@
+/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * TI LM3509 LED driver.
+ */
+
+#ifndef __CROS_EC_LM3509_H
+#define __CROS_EC_LM3509_H
+
+/* 8-bit I2C address */
+#define LM3509_I2C_ADDR 0x6C
+
+#define LM3509_REG_GP 0x10
+#define LM3509_REG_BMAIN 0xA0
+#define LM3509_REG_BSUB 0xB0
+
+/* Power on and initialize LM3509. */
+int lm3509_poweron(void);
+
+/* Power off LM3509. */
+int lm3509_poweroff(void);
+
+#endif /* __CROS_EC_LM3509_H */