summaryrefslogtreecommitdiff
path: root/driver/led/is31fl3733b.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/led/is31fl3733b.c')
-rw-r--r--driver/led/is31fl3733b.c116
1 files changed, 56 insertions, 60 deletions
diff --git a/driver/led/is31fl3733b.c b/driver/led/is31fl3733b.c
index 5b1df890f1..33004d1cec 100644
--- a/driver/led/is31fl3733b.c
+++ b/driver/led/is31fl3733b.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -14,63 +14,62 @@
#define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "RGBKBD: " fmt, ##args)
#define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "RGBKBD: " fmt, ##args)
-
/* This depends on ADDR1 and ADDR2. (GND, GND) = 0x50. */
-#define IS31FL3733B_ADDR_FLAGS 0x50
+#define IS31FL3733B_ADDR_FLAGS 0x50
-#define IS31FL3733B_ROW_SIZE 16
-#define IS31FL3733B_COL_SIZE 4
-#define IS31FL3733B_GRID_SIZE (IS31FL3733B_COL_SIZE * IS31FL3733B_ROW_SIZE)
-#define IS31FL3733B_BUF_SIZE (SIZE_OF_RGB * IS31FL3733B_GRID_SIZE)
+#define IS31FL3733B_ROW_SIZE 16
+#define IS31FL3733B_COL_SIZE 4
+#define IS31FL3733B_GRID_SIZE (IS31FL3733B_COL_SIZE * IS31FL3733B_ROW_SIZE)
+#define IS31FL3733B_BUF_SIZE (SIZE_OF_RGB * IS31FL3733B_GRID_SIZE)
/* IS31FL3733B registers */
-#define IS31FL3733B_REG_COMMAND 0xFD
-#define IS31FL3733B_REG_COMMAND_WRITE_LOCK 0xFE
-#define IS31FL3733B_REG_INT_MASK 0xF0
-#define IS31FL3733B_REG_INT_STATUS 0xF1
+#define IS31FL3733B_REG_COMMAND 0xFD
+#define IS31FL3733B_REG_COMMAND_WRITE_LOCK 0xFE
+#define IS31FL3733B_REG_INT_MASK 0xF0
+#define IS31FL3733B_REG_INT_STATUS 0xF1
-#define IS31FL3733B_PAGE_CTRL 0x00
-#define IS31FL3733B_PAGE_PWM 0x01
-#define IS31FL3733B_PAGE_AUTO 0x02
-#define IS31FL3733B_PAGE_FUNC 0x03
+#define IS31FL3733B_PAGE_CTRL 0x00
+#define IS31FL3733B_PAGE_PWM 0x01
+#define IS31FL3733B_PAGE_AUTO 0x02
+#define IS31FL3733B_PAGE_FUNC 0x03
/* FEh Command Register Write Lock */
-#define IS31FL3733B_WRITE_DISABLE 0x00
-#define IS31FL3733B_WRITE_ENABLE 0xC5
-
-#define IS31FL3733B_INT_MASK_IAC BIT(3)
-#define IS31FL3733B_INT_MASK_IAB BIT(2)
-#define IS31FL3733B_INT_MASK_IS BIT(1)
-#define IS31FL3733B_INT_MASK_IO BIT(0)
-#define IS31FL3733B_INT_STATUS_ABM3 BIT(4)
-#define IS31FL3733B_INT_STATUS_ABM2 BIT(3)
-#define IS31FL3733B_INT_STATUS_ABM1 BIT(2)
-#define IS31FL3733B_INT_STATUS_SB BIT(1)
-#define IS31FL3733B_INT_STATUS_OB BIT(0)
-
-#define IS31FL3733B_FUNC_CFG 0x00
-#define IS31FL3733B_FUNC_GCC 0x01
-#define IS31FL3733B_FUNC_ABM1_1 0x02
-#define IS31FL3733B_FUNC_ABM1_2 0x03
-#define IS31FL3733B_FUNC_ABM1_3 0x04
-#define IS31FL3733B_FUNC_ABM1_4 0x05
-#define IS31FL3733B_FUNC_ABM2_1 0x06
-#define IS31FL3733B_FUNC_ABM2_2 0x07
-#define IS31FL3733B_FUNC_ABM2_3 0x08
-#define IS31FL3733B_FUNC_ABM2_4 0x09
-#define IS31FL3733B_FUNC_ABM3_1 0x0a
-#define IS31FL3733B_FUNC_ABM3_2 0x0b
-#define IS31FL3733B_FUNC_ABM3_3 0x0c
-#define IS31FL3733B_FUNC_ABM3_4 0x0d
-#define IS31FL3733B_FUNC_TUR 0x0e
-#define IS31FL3733B_FUNC_SW_PU 0x0f
-#define IS31FL3733B_FUNC_CS_PD 0x10
-#define IS31FL3733B_FUNC_RST 0x11
+#define IS31FL3733B_WRITE_DISABLE 0x00
+#define IS31FL3733B_WRITE_ENABLE 0xC5
+
+#define IS31FL3733B_INT_MASK_IAC BIT(3)
+#define IS31FL3733B_INT_MASK_IAB BIT(2)
+#define IS31FL3733B_INT_MASK_IS BIT(1)
+#define IS31FL3733B_INT_MASK_IO BIT(0)
+#define IS31FL3733B_INT_STATUS_ABM3 BIT(4)
+#define IS31FL3733B_INT_STATUS_ABM2 BIT(3)
+#define IS31FL3733B_INT_STATUS_ABM1 BIT(2)
+#define IS31FL3733B_INT_STATUS_SB BIT(1)
+#define IS31FL3733B_INT_STATUS_OB BIT(0)
+
+#define IS31FL3733B_FUNC_CFG 0x00
+#define IS31FL3733B_FUNC_GCC 0x01
+#define IS31FL3733B_FUNC_ABM1_1 0x02
+#define IS31FL3733B_FUNC_ABM1_2 0x03
+#define IS31FL3733B_FUNC_ABM1_3 0x04
+#define IS31FL3733B_FUNC_ABM1_4 0x05
+#define IS31FL3733B_FUNC_ABM2_1 0x06
+#define IS31FL3733B_FUNC_ABM2_2 0x07
+#define IS31FL3733B_FUNC_ABM2_3 0x08
+#define IS31FL3733B_FUNC_ABM2_4 0x09
+#define IS31FL3733B_FUNC_ABM3_1 0x0a
+#define IS31FL3733B_FUNC_ABM3_2 0x0b
+#define IS31FL3733B_FUNC_ABM3_3 0x0c
+#define IS31FL3733B_FUNC_ABM3_4 0x0d
+#define IS31FL3733B_FUNC_TUR 0x0e
+#define IS31FL3733B_FUNC_SW_PU 0x0f
+#define IS31FL3733B_FUNC_CS_PD 0x10
+#define IS31FL3733B_FUNC_RST 0x11
static int is31fl3733b_read(struct rgbkbd *ctx, uint8_t addr, uint8_t *value)
{
- return i2c_xfer(ctx->cfg->i2c, IS31FL3733B_ADDR_FLAGS,
- &addr, sizeof(addr), value, sizeof(*value));
+ return i2c_xfer(ctx->cfg->i2c, IS31FL3733B_ADDR_FLAGS, &addr,
+ sizeof(addr), value, sizeof(*value));
}
static int is31fl3733b_write(struct rgbkbd *ctx, uint8_t addr, uint8_t value)
@@ -80,8 +79,8 @@ static int is31fl3733b_write(struct rgbkbd *ctx, uint8_t addr, uint8_t value)
[1] = value,
};
- return i2c_xfer(ctx->cfg->i2c, IS31FL3733B_ADDR_FLAGS,
- buf, sizeof(buf), NULL, 0);
+ return i2c_xfer(ctx->cfg->i2c, IS31FL3733B_ADDR_FLAGS, buf, sizeof(buf),
+ NULL, 0);
}
static int is31fl3733b_set_page(struct rgbkbd *ctx, uint8_t page)
@@ -90,7 +89,7 @@ static int is31fl3733b_set_page(struct rgbkbd *ctx, uint8_t page)
/* unlock page select once */
rv = is31fl3733b_write(ctx, IS31FL3733B_REG_COMMAND_WRITE_LOCK,
- IS31FL3733B_WRITE_ENABLE);
+ IS31FL3733B_WRITE_ENABLE);
if (rv) {
return rv;
}
@@ -99,7 +98,7 @@ static int is31fl3733b_set_page(struct rgbkbd *ctx, uint8_t page)
}
static int is31fl3733b_get_config(struct rgbkbd *ctx, uint8_t addr,
- uint8_t *value)
+ uint8_t *value)
{
int rv;
@@ -112,7 +111,7 @@ static int is31fl3733b_get_config(struct rgbkbd *ctx, uint8_t addr,
}
static int is31fl3733b_set_config(struct rgbkbd *ctx, uint8_t addr,
- uint8_t value)
+ uint8_t value)
{
int rv;
@@ -150,7 +149,7 @@ static int is31fl3733b_enable(struct rgbkbd *ctx, bool enable)
}
static int is31fl3733b_set_color(struct rgbkbd *ctx, uint8_t offset,
- struct rgb_s *color, uint8_t len)
+ struct rgb_s *color, uint8_t len)
{
int led_addr, led_addr_row, led_addr_col;
int i, rv;
@@ -165,7 +164,7 @@ static int is31fl3733b_set_color(struct rgbkbd *ctx, uint8_t offset,
led_addr_col = (offset + i) / ctx->cfg->row_len;
led_addr = led_addr_row * 0x30 + led_addr_col;
- rv = is31fl3733b_write(ctx, led_addr + 0x00, color[i].r);
+ rv = is31fl3733b_write(ctx, led_addr + 0x00, color[i].r);
rv |= is31fl3733b_write(ctx, led_addr + 0x10, color[i].g);
rv |= is31fl3733b_write(ctx, led_addr + 0x20, color[i].b);
@@ -209,16 +208,13 @@ static int is31fl3733b_init(struct rgbkbd *ctx)
}
if (IS_ENABLED(CONFIG_RGB_KEYBOARD_DEBUG)) {
-
uint8_t val;
int ret;
- ret = is31fl3733b_get_config(ctx,
- IS31FL3733B_FUNC_SW_PU, &val);
+ ret = is31fl3733b_get_config(ctx, IS31FL3733B_FUNC_SW_PU, &val);
CPRINTS("SW_PU: val=0x%02x (rv=%d)", val, ret);
- ret = is31fl3733b_get_config(ctx,
- IS31FL3733B_FUNC_CS_PD, &val);
+ ret = is31fl3733b_get_config(ctx, IS31FL3733B_FUNC_CS_PD, &val);
CPRINTS("CS_PD: val=0x%02x (rv=%d)", val, ret);
}