summaryrefslogtreecommitdiff
path: root/driver/led
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 /driver/led
parentb73886aff89eebedf27e599385fefb5feaea918f (diff)
downloadchrome-ec-5ec058f42a66d6925063cf73349c7d3340198e6a.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>
Diffstat (limited to 'driver/led')
-rw-r--r--driver/led/aw20198.c25
-rw-r--r--driver/led/aw20198.h30
2 files changed, 34 insertions, 21 deletions
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 */