summaryrefslogtreecommitdiff
path: root/driver/ioexpander/it8801.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/ioexpander/it8801.c')
-rw-r--r--driver/ioexpander/it8801.c101
1 files changed, 50 insertions, 51 deletions
diff --git a/driver/ioexpander/it8801.c b/driver/ioexpander/it8801.c
index dbf13c4da8..256b4c9654 100644
--- a/driver/ioexpander/it8801.c
+++ b/driver/ioexpander/it8801.c
@@ -1,4 +1,4 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -17,7 +17,7 @@
#include "util.h"
#include "keyboard_backlight.h"
-#define CPRINTS(format, args...) cprints(CC_KEYSCAN, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_KEYSCAN, format, ##args)
static int it8801_ioex_set_level(int ioex, int port, int mask, int value);
static void it8801_ioex_event_handler(void);
@@ -25,14 +25,14 @@ DECLARE_DEFERRED(it8801_ioex_event_handler);
static int it8801_read(int reg, int *data)
{
- return i2c_read8(I2C_PORT_KB_DISCRETE,
- KB_DISCRETE_I2C_ADDR_FLAGS, reg, data);
+ return i2c_read8(I2C_PORT_KB_DISCRETE, KB_DISCRETE_I2C_ADDR_FLAGS, reg,
+ data);
}
__maybe_unused static int it8801_write(int reg, int data)
{
- return i2c_write8(I2C_PORT_KB_DISCRETE,
- KB_DISCRETE_I2C_ADDR_FLAGS, reg, data);
+ return i2c_write8(I2C_PORT_KB_DISCRETE, KB_DISCRETE_I2C_ADDR_FLAGS, reg,
+ data);
}
struct it8801_vendor_id_t {
@@ -41,8 +41,8 @@ struct it8801_vendor_id_t {
};
static const struct it8801_vendor_id_t it8801_vendor_id_verify[] = {
- { 0x12, IT8801_REG_HBVIDR},
- { 0x83, IT8801_REG_LBVIDR},
+ { 0x12, IT8801_REG_HBVIDR },
+ { 0x83, IT8801_REG_LBVIDR },
};
static int it8801_check_vendor_id(void)
@@ -133,10 +133,10 @@ void keyboard_raw_task_start(void)
keyboard_raw_enable_interrupt(1);
}
-__overridable const uint8_t it8801_kso_mapping[] = {
- 0, 1, 20, 3, 4, 5, 6, 17, 18, 16, 15, 11, 12,
+__overridable const uint8_t it8801_kso_mapping[] = { 0, 1, 20, 3, 4, 5, 6,
+ 17, 18, 16, 15, 11, 12,
#ifdef CONFIG_KEYBOARD_KEYPAD
- 13, 14
+ 13, 14
#endif
};
BUILD_ASSERT(ARRAY_SIZE(it8801_kso_mapping) == KEYBOARD_COLS_MAX);
@@ -179,11 +179,11 @@ test_mockable void keyboard_raw_drive_column(int col)
if (col == IT8801_REG_MASK_SELKSO2) {
/* Output high(so selected). */
it8801_ioex_set_level(0, 2,
- IT8801_REG_GPIO23SOV, 1);
+ IT8801_REG_GPIO23SOV, 1);
} else {
/* Output low(so not selected). */
it8801_ioex_set_level(0, 2,
- IT8801_REG_GPIO23SOV, 0);
+ IT8801_REG_GPIO23SOV, 0);
}
}
}
@@ -229,25 +229,25 @@ static int it8801_ioex_read(int ioex, int reg, int *data)
{
struct ioexpander_config_t *ioex_p = &ioex_config[ioex];
- return i2c_read8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags,
- reg, data);
+ return i2c_read8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, reg,
+ data);
}
static int it8801_ioex_write(int ioex, int reg, int data)
{
struct ioexpander_config_t *ioex_p = &ioex_config[ioex];
- return i2c_write8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags,
- reg, data);
+ return i2c_write8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, reg,
+ data);
}
static int it8801_ioex_update(int ioex, int reg, int data,
- enum mask_update_action action)
+ enum mask_update_action action)
{
struct ioexpander_config_t *ioex_p = &ioex_config[ioex];
- return i2c_update8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags,
- reg, data, action);
+ return i2c_update8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, reg,
+ data, action);
}
static const int it8801_valid_gpio_group[] = {
@@ -340,15 +340,15 @@ static int it8801_ioex_set_level(int ioex, int port, int mask, int value)
it8801_gpio_sov[port] &= ~mask;
rv = it8801_ioex_write(ioex, IT8801_REG_GPIO_SOVR(port),
- it8801_gpio_sov[port]);
+ it8801_gpio_sov[port]);
}
mutex_unlock(&ioex_mutex);
return rv;
}
-static int it8801_ioex_get_flags_by_mask(int ioex, int port,
- int mask, int *flags)
+static int it8801_ioex_get_flags_by_mask(int ioex, int port, int mask,
+ int *flags)
{
int rv, val;
@@ -378,8 +378,8 @@ static int it8801_ioex_get_flags_by_mask(int ioex, int port,
return EC_SUCCESS;
}
-static int it8801_ioex_set_flags_by_mask(int ioex, int port,
- int mask, int flags)
+static int it8801_ioex_set_flags_by_mask(int ioex, int port, int mask,
+ int flags)
{
int rv, val;
@@ -388,13 +388,13 @@ static int it8801_ioex_set_flags_by_mask(int ioex, int port,
if (flags & ~IT8801_SUPPORT_GPIO_FLAGS) {
CPRINTS("Flag 0x%08x is not supported at port %d, mask %d",
- flags, port, mask);
+ flags, port, mask);
return EC_ERROR_INVAL;
}
/* GPIO alternate function switching(GPIO[00, 12:15, 20:23]). */
rv = it8801_ioex_write(ioex, IT8801_REG_GPIO_CR(port, mask),
- IT8801_REG_MASK_GPIOAFS_FUNC1);
+ IT8801_REG_MASK_GPIOAFS_FUNC1);
if (rv)
return rv;
@@ -418,7 +418,7 @@ static int it8801_ioex_set_flags_by_mask(int ioex, int port,
it8801_gpio_sov[port] &= ~mask;
rv = it8801_ioex_write(ioex, IT8801_REG_GPIO_SOVR(port),
- it8801_gpio_sov[port]);
+ it8801_gpio_sov[port]);
if (rv)
goto unlock_mutex;
@@ -451,13 +451,13 @@ static int it8801_ioex_enable_interrupt(int ioex, int port, int mask,
return EC_ERROR_INVAL;
/* Clear pending interrupt */
- rv = it8801_ioex_update(ioex, IT8801_REG_GPIO_ISR(port),
- mask, MASK_SET);
+ rv = it8801_ioex_update(ioex, IT8801_REG_GPIO_ISR(port), mask,
+ MASK_SET);
if (rv)
return rv;
- return it8801_ioex_update(ioex, IT8801_REG_GPIO_IER(port),
- mask, enable ? MASK_SET : MASK_CLR);
+ return it8801_ioex_update(ioex, IT8801_REG_GPIO_IER(port), mask,
+ enable ? MASK_SET : MASK_CLR);
}
#ifdef CONFIG_ZEPHYR
@@ -483,7 +483,7 @@ static void it8801_ioex_irq(int ioex, int port)
/* Clear pending interrupt */
it8801_ioex_update(ioex, IT8801_REG_GPIO_ISR(port),
- g->mask, MASK_SET);
+ g->mask, MASK_SET);
if (!data)
break;
@@ -502,7 +502,7 @@ static void it8801_ioex_event_handler(void)
/* Wake the keyboard scan task if KSI interrupts are triggered */
if (IS_ENABLED(CONFIG_KEYBOARD_DISCRETE) &&
- data & IT8801_REG_MASK_GISR_GKSIIS)
+ data & IT8801_REG_MASK_GISR_GKSIIS)
task_wake(TASK_ID_KEYSCAN);
/*
@@ -535,14 +535,14 @@ static int it8801_ioex_get_port(int ioex, int port, int *val)
#endif
const struct ioexpander_drv it8801_ioexpander_drv = {
- .init = &it8801_ioex_init,
- .get_level = &it8801_ioex_get_level,
- .set_level = &it8801_ioex_set_level,
+ .init = &it8801_ioex_init,
+ .get_level = &it8801_ioex_get_level,
+ .set_level = &it8801_ioex_set_level,
.get_flags_by_mask = &it8801_ioex_get_flags_by_mask,
.set_flags_by_mask = &it8801_ioex_set_flags_by_mask,
- .enable_interrupt = &it8801_ioex_enable_interrupt,
+ .enable_interrupt = &it8801_ioex_enable_interrupt,
#ifdef CONFIG_IO_EXPANDER_SUPPORT_GET_PORT
- .get_port = &it8801_ioex_get_port,
+ .get_port = &it8801_ioex_get_port,
#endif
};
@@ -561,7 +561,7 @@ static void dump_register(int reg)
ccprintf("ERR (%d)\n", rv);
}
-static int it8801_dump(int argc, char **argv)
+static int it8801_dump(int argc, const char **argv)
{
dump_register(IT8801_REG_KSIIER);
dump_register(IT8801_REG_KSIEER);
@@ -582,13 +582,13 @@ struct it8801_pwm_gpio_map {
};
const static struct it8801_pwm_gpio_map it8801_pwm_gpio_map[] = {
- [1] = {.port = 1, .mask = BIT(2), .pushpull_en = BIT(0)},
- [2] = {.port = 1, .mask = BIT(3), .pushpull_en = BIT(1)},
- [3] = {.port = 1, .mask = BIT(4), .pushpull_en = BIT(2)},
- [4] = {.port = 1, .mask = BIT(5), .pushpull_en = BIT(3)},
- [7] = {.port = 2, .mask = BIT(0), .pushpull_en = BIT(4)},
- [8] = {.port = 2, .mask = BIT(3), .pushpull_en = BIT(5)},
- [9] = {.port = 2, .mask = BIT(2), .pushpull_en = BIT(6)},
+ [1] = { .port = 1, .mask = BIT(2), .pushpull_en = BIT(0) },
+ [2] = { .port = 1, .mask = BIT(3), .pushpull_en = BIT(1) },
+ [3] = { .port = 1, .mask = BIT(4), .pushpull_en = BIT(2) },
+ [4] = { .port = 1, .mask = BIT(5), .pushpull_en = BIT(3) },
+ [7] = { .port = 2, .mask = BIT(0), .pushpull_en = BIT(4) },
+ [8] = { .port = 2, .mask = BIT(3), .pushpull_en = BIT(5) },
+ [9] = { .port = 2, .mask = BIT(2), .pushpull_en = BIT(6) },
};
void it8801_pwm_enable(enum pwm_channel ch, int enabled)
@@ -609,10 +609,10 @@ void it8801_pwm_enable(enum pwm_channel ch, int enabled)
*/
if (it8801_pwm_channels[ch].index <= 7)
it8801_write(IT8801_REG_GPIO_CR(port, mask),
- 0x1 << IT8801_GPIOAFS_SHIFT);
+ 0x1 << IT8801_GPIOAFS_SHIFT);
else
it8801_write(IT8801_REG_GPIO_CR(port, mask),
- 0x2 << IT8801_GPIOAFS_SHIFT);
+ 0x2 << IT8801_GPIOAFS_SHIFT);
it8801_read(IT8801_REG_PWMMCR(it8801_pwm_channels[ch].index), &val);
val &= (~IT8801_PWMMCR_MCR_MASK);
@@ -628,7 +628,6 @@ void it8801_pwm_enable(enum pwm_channel ch, int enabled)
if (enabled)
val |= it8801_pwm_gpio_map[index].pushpull_en;
it8801_write(IT8801_REG_PWMODDSR, val);
-
}
int it8801_pwm_get_enabled(enum pwm_channel ch)
@@ -706,4 +705,4 @@ const struct kblight_drv kblight_it8801 = {
.get_enabled = it8801_kblight_get_enabled,
};
#endif
-#endif /* CONFIG_IO_EXPANDER_IT8801_PWM */
+#endif /* CONFIG_IO_EXPANDER_IT8801_PWM */