summaryrefslogtreecommitdiff
path: root/driver/ioexpander/it8801.c
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-09-21 14:08:36 -0700
committerTom Hughes <tomhughes@chromium.org>2022-09-22 12:59:38 -0700
commitc453fd704268ef72de871b0c5ac7a989de662334 (patch)
treefcf6ce5810f9ff9e3c8cce434812dd75492269ed /driver/ioexpander/it8801.c
parent6c1587ca70f558b4f96b3f0b18ad8b027d3ba99d (diff)
parent28712dae9d7ed1e694f7622cc083afa71090d4d5 (diff)
downloadchrome-ec-c453fd704268ef72de871b0c5ac7a989de662334.tar.gz
Merge remote-tracking branch cros/main into firmware-fpmcu-dartmonkey-releasefirmware-fpmcu-dartmonkey-release
Generated by: ./util/update_release_branch.py --board dartmonkey --relevant_paths_file ./util/fingerprint-relevant-paths.txt firmware-fpmcu-dartmonkey-release Relevant changes: git log --oneline 6c1587ca70..28712dae9d -- board/nocturne_fp board/dartmonkey common/fpsensor docs/fingerprint driver/fingerprint util/getversion.sh ded9307b79 util/getversion.sh: Fix version when not in a git repo 956055e692 board: change Google USB vendor info 71b2ef709d Update license boilerplate text in source code files 33e11afda0 Revert "fpsensor: Build fpsensor source file with C++" c8d0360723 fpsensor: Build fpsensor source file with C++ bc113abd53 fpsensor: Fix g++ compiler error 150a58a0dc fpsensor: Fix fp_set_sensor_mode return type b33b5ce85b fpsensor: Remove nested designators for C++ compatibility 2e864b2539 tree-wide: const-ify argv for console commands 56d8b360f9 test: Add test for get ikm failure when seed not set 3a3d6c3690 test: Add test for fpsensor trivial key failure 233e6bbd08 fpsensor_crypto: Abstract calls to hmac_SHA256 0a041b285b docs/fingerprint: Typo correction c03fab67e2 docs/fingerprint: Fix the path of fputils.py 0b5d4baf5a util/getversion.sh: Fix empty file list handling 6e128fe760 FPMCU dev board environment with Satlab 3eb29b6aa5 builtin: Move ssize_t to sys/types.h 345d62ebd1 docs/fingerprint: Update power numbers for latest dartmonkey release c25ffdb316 common: Conditionally support printf %l and %i modifiers 9a3c514b45 test: Add a test to check if the debugger is connected 54e603413f Move standard library tests to their own file 43fa6b4bf8 docs/fingerprint: Update power numbers for latest bloonchipper release 25536f9a84 driver/fingerprint/fpc/bep/fpc_sensor_spi.c: Format with clang-format 4face99efd driver/fingerprint/fpc/libfp/fpc_sensor_pal.h: Format with clang-format 738de2b575 trng: Rename rand to trng_rand 14b8270edd docs/fingerprint: Update dragonclaw power numbers 0b268f93d1 driver/fingerprint/fpc/libfp/fpc_private.c: Format with clang-format f80da163f2 driver/fingerprint/fpc/libfp/fpc_private.h: Format with clang-format a0751778f4 board/nocturne_fp/ro_workarounds.c: Format with clang-format 5e9c85c9b1 driver/fingerprint/fpc/libfp/fpc_sensor_pal.c: Format with clang-format c1f9dd3cf8 driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h: Format with clang-format eb1e1bed8d driver/fingerprint/fpc/libfp/fpc1145_private.h: Format with clang-format 6e7b611821 driver/fingerprint/fpc/bep/fpc_bio_algorithm.h: Format with clang-format e0589cd5e2 driver/fingerprint/fpc/bep/fpc1035_private.h: Format with clang-format 58f0246dbe board/nocturne_fp/board_ro.c: Format with clang-format 7905e556a0 common/fpsensor/fpsensor_crypto.c: Format with clang-format 21289d170c driver/fingerprint/fpc/bep/fpc1025_private.h: Format with clang-format 98a20f937e common/fpsensor/fpsensor_state.c: Format with clang-format a2d255d8af common/fpsensor/fpsensor.c: Format with clang-format 84e53a65da board/nocturne_fp/board.h: Format with clang-format 73055eeb3f driver/fingerprint/fpc/bep/fpc_private.c: Format with clang-format 0f7b5cb509 common/fpsensor/fpsensor_private.h: Format with clang-format 1ceade6e65 driver/fingerprint/fpc/bep/fpc_private.h: Format with clang-format dca9d74321 Revert "trng: Rename rand to trng_rand" a6b0b3554f trng: Rename rand to trng_rand 28d0b75b70 third_party/boringssl: Remove unused header BRANCH=None BUG=b:244387210 b:242720240 b:215613183 b:242720910 b:236386294 BUG=b:234181908 b:244781166 b:234781655 b:234143158 b:234181908 BUG=b:237344361 b:236025198 b:234181908 b:180945056 chromium:1098010 BUG=b:246424843 b:234181908 b:131913998 TEST=`make -j buildall` TEST=./util/run_device_tests.py --board dartmonkey Test "aes": PASSED Test "cec": PASSED Test "cortexm_fpu": PASSED Test "crc": PASSED Test "flash_physical": PASSED Test "flash_write_protect": PASSED Test "fpsensor_hw": PASSED Test "fpsensor_spi_ro": PASSED Test "fpsensor_spi_rw": PASSED Test "fpsensor_uart_ro": PASSED Test "fpsensor_uart_rw": PASSED Test "mpu_ro": PASSED Test "mpu_rw": PASSED Test "mutex": PASSED Test "pingpong": PASSED Test "printf": PASSED Test "queue": PASSED Test "rollback_region0": PASSED Test "rollback_region1": PASSED Test "rollback_entropy": PASSED Test "rtc": PASSED Test "sha256": PASSED Test "sha256_unrolled": PASSED Test "static_if": PASSED Test "stdlib": PASSED Test "system_is_locked_wp_on": PASSED Test "system_is_locked_wp_off": PASSED Test "timer_dos": PASSED Test "utils": PASSED Test "utils_str": PASSED Test "panic_data_dartmonkey_v2.0.2887": PASSED Test "panic_data_nocturne_fp_v2.2.64": PASSED Test "panic_data_nami_fp_v2.2.144": PASSED Force-Relevant-Builds: all Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I2c312583a709fedae8fe11d92c22328c3b634bc7
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 */