summaryrefslogtreecommitdiff
path: root/zephyr/projects/corsola/src/board_chipset.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/projects/corsola/src/board_chipset.c')
-rw-r--r--zephyr/projects/corsola/src/board_chipset.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/zephyr/projects/corsola/src/board_chipset.c b/zephyr/projects/corsola/src/board_chipset.c
new file mode 100644
index 0000000000..54e96bc631
--- /dev/null
+++ b/zephyr/projects/corsola/src/board_chipset.c
@@ -0,0 +1,49 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola baseboard-chipset specific configuration */
+
+#include <zephyr/init.h>
+#include <ap_power/ap_power.h>
+#include <zephyr/drivers/gpio.h>
+#include "gpio.h"
+
+static void board_backlight_handler(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ int value;
+
+ switch (data.event) {
+ default:
+ return;
+
+ case AP_POWER_RESUME:
+ /* Called on AP S3 -> S0 transition */
+ value = 1;
+ break;
+
+ case AP_POWER_SUSPEND:
+ /* Called on AP S0 -> S3 transition */
+ value = 0;
+ break;
+ }
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_bl_en_od), value);
+}
+
+static int install_backlight_handler(const struct device *unused)
+{
+ static struct ap_power_ev_callback cb;
+
+ /*
+ * Add a callback for suspend/resume to
+ * control the keyboard backlight.
+ */
+ ap_power_ev_init_callback(&cb, board_backlight_handler,
+ AP_POWER_RESUME | AP_POWER_SUSPEND);
+ ap_power_ev_add_callback(&cb);
+ return 0;
+}
+
+SYS_INIT(install_backlight_handler, APPLICATION, 1);