diff options
Diffstat (limited to 'driver/ioexpander/pcal6408.c')
-rw-r--r-- | driver/ioexpander/pcal6408.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/driver/ioexpander/pcal6408.c b/driver/ioexpander/pcal6408.c index 46de96b595..1b746bffc3 100644 --- a/driver/ioexpander/pcal6408.c +++ b/driver/ioexpander/pcal6408.c @@ -1,4 +1,4 @@ -/* Copyright 2020 The Chromium OS Authors. All rights reserved. +/* Copyright 2020 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -12,8 +12,8 @@ #include "ioexpander.h" #include "pcal6408.h" -#define CPRINTF(format, args...) cprintf(CC_GPIO, format, ## args) -#define CPRINTS(format, args...) cprints(CC_GPIO, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_GPIO, format, ##args) +#define CPRINTS(format, args...) cprints(CC_GPIO, format, ##args) #ifdef CONFIG_IO_EXPANDER_SUPPORT_GET_PORT #error "This driver doesn't support get_port function" @@ -24,17 +24,16 @@ * we don't have to read it via i2c transaction every time. * Default value of interrupt mask register is 0xff. */ -uint8_t pcal6408_int_mask[] = { - [0 ... (CONFIG_IO_EXPANDER_PORT_COUNT - 1)] = 0xff }; - +uint8_t pcal6408_int_mask[] = { [0 ...(CONFIG_IO_EXPANDER_PORT_COUNT - 1)] = + 0xff }; static int pcal6408_read(int ioex, int reg, int *data) { int rv; struct ioexpander_config_t *ioex_p = &ioex_config[ioex]; - rv = i2c_read8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, - reg, data); + rv = i2c_read8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, reg, + data); return rv; } @@ -44,8 +43,8 @@ static int pcal6408_write(int ioex, int reg, int data) int rv; struct ioexpander_config_t *ioex_p = &ioex_config[ioex]; - rv = i2c_write8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, - reg, data); + rv = i2c_write8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, reg, + data); return rv; } @@ -56,8 +55,7 @@ static int pcal6408_ioex_check_is_valid(int port, int mask) return EC_ERROR_INVAL; if (mask & ~PCAL6408_VALID_GPIO_MASK) { - CPRINTF("GPIO%02d is not support in PCAL6408\n", - __fls(mask)); + CPRINTF("GPIO%02d is not support in PCAL6408\n", __fls(mask)); return EC_ERROR_INVAL; } @@ -110,7 +108,7 @@ static int pcal6408_ioex_set_level(int ioex, int port, int mask, int value) } static int pcal6408_ioex_get_flags_by_mask(int ioex, int port, int mask, - int *flags) + int *flags) { int rv, val; @@ -171,7 +169,7 @@ static int pcal6408_ioex_get_flags_by_mask(int ioex, int port, int mask, } static int pcal6408_ioex_set_flags_by_mask(int ioex, int port, int mask, - int flags) + int flags) { int rv, val; @@ -180,14 +178,13 @@ static int pcal6408_ioex_set_flags_by_mask(int ioex, int port, int mask, return rv; if (((flags & GPIO_INT_BOTH) == GPIO_INT_RISING) || - ((flags & GPIO_INT_BOTH) == GPIO_INT_FALLING)) { + ((flags & GPIO_INT_BOTH) == GPIO_INT_FALLING)) { CPRINTF("PCAL6408 only support GPIO_INT_BOTH.\n"); return EC_ERROR_INVAL; } - if ((flags & (GPIO_INT_F_RISING | GPIO_INT_F_FALLING)) && - !(flags & GPIO_INPUT)) { + !(flags & GPIO_INPUT)) { CPRINTF("Interrupt pin must be GPIO_INPUT.\n"); return EC_ERROR_INVAL; } @@ -269,7 +266,7 @@ static int pcal6408_ioex_set_flags_by_mask(int ioex, int port, int mask, } static int pcal6408_ioex_enable_interrupt(int ioex, int port, int mask, - int enable) + int enable) { int rv, val; @@ -302,7 +299,7 @@ static int pcal6408_ioex_enable_interrupt(int ioex, int port, int mask, pcal6408_int_mask[ioex] |= mask; rv = pcal6408_write(ioex, PCAL6408_REG_INT_MASK, - pcal6408_int_mask[ioex]); + pcal6408_int_mask[ioex]); return rv; } @@ -321,7 +318,7 @@ int pcal6408_ioex_event_handler(int ioex) * read status register will not. */ rv = i2c_read8(ioex_p->i2c_host_port, ioex_p->i2c_addr_flags, - PCAL6408_REG_INT_STATUS, &int_status); + PCAL6408_REG_INT_STATUS, &int_status); if (rv != EC_SUCCESS) return rv; @@ -335,9 +332,7 @@ int pcal6408_ioex_event_handler(int ioex) return EC_SUCCESS; for (i = 0, g = ioex_list; i < ioex_ih_count; i++, g++) { - - if (ioex == g->ioex && 0 == g->port && - (int_status & g->mask)) { + if (ioex == g->ioex && 0 == g->port && (int_status & g->mask)) { ioex_irq_handlers[i](i + IOEX_SIGNAL_START); int_status &= ~g->mask; if (!int_status) @@ -349,10 +344,10 @@ int pcal6408_ioex_event_handler(int ioex) } const struct ioexpander_drv pcal6408_ioexpander_drv = { - .init = &pcal6408_ioex_init, - .get_level = &pcal6408_ioex_get_level, - .set_level = &pcal6408_ioex_set_level, - .get_flags_by_mask = &pcal6408_ioex_get_flags_by_mask, - .set_flags_by_mask = &pcal6408_ioex_set_flags_by_mask, - .enable_interrupt = &pcal6408_ioex_enable_interrupt, + .init = &pcal6408_ioex_init, + .get_level = &pcal6408_ioex_get_level, + .set_level = &pcal6408_ioex_set_level, + .get_flags_by_mask = &pcal6408_ioex_get_flags_by_mask, + .set_flags_by_mask = &pcal6408_ioex_set_flags_by_mask, + .enable_interrupt = &pcal6408_ioex_enable_interrupt, }; |