summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2022-01-16 20:04:10 -0800
committerCommit Bot <commit-bot@chromium.org>2022-03-19 01:56:51 +0000
commit5ec058f42a66d6925063cf73349c7d3340198e6a (patch)
tree91de2c72a04008bad2e9e2b75af012343f2720f0
parentb73886aff89eebedf27e599385fefb5feaea918f (diff)
downloadchrome-ec-factory-guybrush-14600.B-main.tar.gz
Taniks: Enable RGB keyboardfactory-guybrush-14600.B-main
This patch enables the RGB keyboard module for Taniks. BUG=b:199995751 BRANCH=None TEST=make BOARD=taniks Change-Id: I2d95bb2f56a5f8e6505cb902aa67ee05e053acf3 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3394288 Reviewed-by: caveh jalali <caveh@chromium.org> Commit-Queue: caveh jalali <caveh@chromium.org>
-rw-r--r--baseboard/brya/baseboard.h1
-rw-r--r--board/taniks/board.h7
-rw-r--r--board/taniks/ec.tasklist1
-rw-r--r--board/taniks/gpio.inc2
-rw-r--r--board/taniks/keyboard.c20
-rw-r--r--driver/led/aw20198.c25
-rw-r--r--driver/led/aw20198.h30
7 files changed, 64 insertions, 22 deletions
diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h
index 98c8f3dbd6..2bab909d8e 100644
--- a/baseboard/brya/baseboard.h
+++ b/baseboard/brya/baseboard.h
@@ -233,6 +233,7 @@
#define BASEBOARD_PD_INT_TASK_STACK_SIZE 800
#define BASEBOARD_PD_TASK_STACK_SIZE 1216
#define BASEBOARD_POWERBTN_TASK_STACK_SIZE 1088
+#define BASEBOARD_RGBKBD_TASK_STACK_SIZE 2048
#ifndef __ASSEMBLER__
diff --git a/board/taniks/board.h b/board/taniks/board.h
index 4a76b062f9..e6bdc7a637 100644
--- a/board/taniks/board.h
+++ b/board/taniks/board.h
@@ -236,6 +236,13 @@
#define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
#define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV 6100
+/* RGB Keyboard */
+#define GPIO_RGBKBD_SDB_L GPIO_KBMCU_INT_ODL
+#define CONFIG_RGB_KEYBOARD
+#define CONFIG_LED_DRIVER_AW20198 /* Awinic AW20198 on I2C */
+#define RGB_GRID0_COL 11
+#define RGB_GRID0_ROW 6
+
#ifndef __ASSEMBLER__
#include "gpio_signal.h" /* needed by registers.h */
diff --git a/board/taniks/ec.tasklist b/board/taniks/ec.tasklist
index 6d995d6b44..12beb39a23 100644
--- a/board/taniks/ec.tasklist
+++ b/board/taniks/ec.tasklist
@@ -12,6 +12,7 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, HOOKS_TASK_STACK_SIZE) \
+ TASK_ALWAYS(RGBKBD, rgbkbd_task, NULL, BASEBOARD_RGBKBD_TASK_STACK_SIZE) \
TASK_ALWAYS(CHG_RAMP, chg_ramp_task, NULL, BASEBOARD_CHG_RAMP_TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 0, TASK_STACK_SIZE) \
diff --git a/board/taniks/gpio.inc b/board/taniks/gpio.inc
index 17010b5731..7c21123ff1 100644
--- a/board/taniks/gpio.inc
+++ b/board/taniks/gpio.inc
@@ -87,7 +87,7 @@ GPIO(USB_C0_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW)
GPIO(USB_C1_FRS_EN, PIN(9, 4), GPIO_OUT_LOW)
GPIO(USB_C1_RT_RST_R_ODL, PIN(0, 2), GPIO_ODR_HIGH)
GPIO(VCCST_PWRGD_OD, PIN(A, 4), GPIO_ODR_LOW)
-GPIO(KBMCU_INT_ODL, PIN(7, 0), GPIO_INPUT)
+GPIO(KBMCU_INT_ODL, PIN(7, 0), GPIO_ODR_HIGH)
/* KB Outputs */
#define GPIO_KB_OUTPUT (GPIO_OUT_HIGH)
diff --git a/board/taniks/keyboard.c b/board/taniks/keyboard.c
index cbd765b437..b48ffe2590 100644
--- a/board/taniks/keyboard.c
+++ b/board/taniks/keyboard.c
@@ -3,9 +3,11 @@
* found in the LICENSE file.
*/
+#include "aw20198.h"
#include "common.h"
#include "ec_commands.h"
#include "keyboard_scan.h"
+#include "rgb_keyboard.h"
#include "timer.h"
/* Keyboard scan setting */
@@ -46,6 +48,24 @@ static const struct ec_response_keybd_config taniks_kb = {
.capabilities = KEYBD_CAP_SCRNLOCK_KEY | KEYBD_CAP_NUMERIC_KEYPAD,
};
+static struct rgb_s grid0[RGB_GRID0_COL * RGB_GRID0_ROW];
+
+struct rgbkbd rgbkbds[] = {
+ [0] = {
+ .cfg = &(const struct rgbkbd_cfg) {
+ .drv = &aw20198_drv,
+ .i2c = I2C_PORT_KBMCU,
+ .col_len = RGB_GRID0_COL,
+ .row_len = RGB_GRID0_ROW,
+ },
+ .buf = grid0,
+ },
+};
+const uint8_t rgbkbd_count = ARRAY_SIZE(rgbkbds);
+
+const uint8_t rgbkbd_hsize = RGB_GRID0_COL;
+const uint8_t rgbkbd_vsize = RGB_GRID0_ROW;
+
__override const struct ec_response_keybd_config
*board_vivaldi_keybd_config(void)
{
diff --git a/driver/led/aw20198.c b/driver/led/aw20198.c
index 05703710ff..5537556ffa 100644
--- a/driver/led/aw20198.c
+++ b/driver/led/aw20198.c
@@ -4,6 +4,7 @@
*/
#include <string.h>
+#include "aw20198.h"
#include "common.h"
#include "console.h"
#include "gpio.h"
@@ -15,25 +16,7 @@
#define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "AW20198: " fmt, ##args)
#define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "AW20198: " fmt, ##args)
-/* This depends on AD0 and Ad1. (GRD, GRD) = 0x20. */
-#define AW20198_I2C_ADDR_FLAG 0x20
-
-#define AW20198_ROW_SIZE 6
-#define AW20198_COL_SIZE 11
-#define AW20198_GRID_SIZE (AW20198_COL_SIZE * AW20198_ROW_SIZE)
-#define AW20198_BUF_SIZE (SIZE_OF_RGB * AW20198_GRID_SIZE)
-
-#define AW20198_PAGE_FUNC 0xC0
-#define AW20198_PAGE_PWM 0xC1
-#define AW20198_PAGE_SCALE 0xC2
-
-#define AW20198_REG_GCR 0x00
-#define AW20198_REG_GCC 0x01
-#define AW20198_REG_RSTN 0x2F
-#define AW20198_REG_MIXCR 0x46
-#define AW20198_REG_PAGE 0xF0
-
-#define AW20198_RESET_MAGIC 0xAE
+#define BUF_SIZE (SIZE_OF_RGB * AW20198_GRID_SIZE)
static int aw20198_read(struct rgbkbd *ctx, uint8_t addr, uint8_t *value)
{
@@ -99,7 +82,7 @@ static int aw20198_enable(struct rgbkbd *ctx, bool enable)
static int aw20198_set_color(struct rgbkbd *ctx, uint8_t offset,
struct rgb_s *color, uint8_t len)
{
- uint8_t buf[sizeof(offset) + AW20198_BUF_SIZE];
+ uint8_t buf[sizeof(offset) + BUF_SIZE];
const int frame_len = len * SIZE_OF_RGB + sizeof(offset);
const int frame_offset = offset * SIZE_OF_RGB;
int i, rv;
@@ -127,7 +110,7 @@ static int aw20198_set_color(struct rgbkbd *ctx, uint8_t offset,
static int aw20198_set_scale(struct rgbkbd *ctx, uint8_t offset, uint8_t scale,
uint8_t len)
{
- uint8_t buf[sizeof(offset) + AW20198_BUF_SIZE];
+ uint8_t buf[sizeof(offset) + BUF_SIZE];
const int frame_len = len * SIZE_OF_RGB + sizeof(offset);
const int frame_offset = offset * SIZE_OF_RGB;
int rv;
diff --git a/driver/led/aw20198.h b/driver/led/aw20198.h
new file mode 100644
index 0000000000..02b862e27e
--- /dev/null
+++ b/driver/led/aw20198.h
@@ -0,0 +1,30 @@
+/* Copyright 2022 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.
+ */
+
+#ifndef __CROS_EC_DRIVER_LED_AW20198_H
+#define __CROS_EC_DRIVER_LED_AW20198_H
+
+/* This depends on AD0 and AD1. (GRD, GRD) = 0x20. */
+#define AW20198_I2C_ADDR_FLAG 0x20
+
+#define AW20198_ROW_SIZE 6
+#define AW20198_COL_SIZE 11
+#define AW20198_GRID_SIZE (AW20198_COL_SIZE * AW20198_ROW_SIZE)
+
+#define AW20198_PAGE_FUNC 0xC0
+#define AW20198_PAGE_PWM 0xC1
+#define AW20198_PAGE_SCALE 0xC2
+
+#define AW20198_REG_GCR 0x00
+#define AW20198_REG_GCC 0x01
+#define AW20198_REG_RSTN 0x2F
+#define AW20198_REG_MIXCR 0x46
+#define AW20198_REG_PAGE 0xF0
+
+#define AW20198_RESET_MAGIC 0xAE
+
+extern const struct rgbkbd_drv aw20198_drv;
+
+#endif /* __CROS_EC_DRIVER_LED_AW20198_H */