diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-06-27 14:20:59 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-29 05:37:30 +0000 |
commit | 3b08da5561d84b43b474b971cabb5a8357a39e20 (patch) | |
tree | 0c6de665124d4a896e9577e72afbcff4a2c3ccf7 /chip/mec1322 | |
parent | ebf1ae04fd4ad3231cca2514e67bfaecfbd2a6b3 (diff) | |
download | chrome-ec-3b08da5561d84b43b474b971cabb5a8357a39e20.tar.gz |
chip/mec1322/i2c.c: Format with clang-format
BUG=b:236386294
BRANCH=none
TEST=none
Change-Id: I4cc29c215014f6e151e349d36128c38caf31341d
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729330
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'chip/mec1322')
-rw-r--r-- | chip/mec1322/i2c.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/chip/mec1322/i2c.c b/chip/mec1322/i2c.c index c282714265..58215adae7 100644 --- a/chip/mec1322/i2c.c +++ b/chip/mec1322/i2c.c @@ -16,7 +16,7 @@ #include "util.h" #define CPUTS(outstr) cputs(CC_I2C, outstr) -#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args) +#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args) #define I2C_CLOCK 16000000 /* 16 MHz */ @@ -36,7 +36,7 @@ #define CTRL_PIN BIT(7) /* Pending interrupt not */ /* Completion */ -#define COMP_IDLE BIT(29) /* i2c bus is idle */ +#define COMP_IDLE BIT(29) /* i2c bus is idle */ #define COMP_RW_BITS_MASK 0x3C /* R/W bits mask */ /* Maximum transfer of a SMBUS block transfer */ @@ -68,10 +68,8 @@ static struct { /* Map port number to port name in datasheet, for debug prints. */ static const char *i2c_port_names[MEC1322_I2C_PORT_COUNT] = { - [MEC1322_I2C0_0] = "0_0", - [MEC1322_I2C0_1] = "0_1", - [MEC1322_I2C1] = "1", - [MEC1322_I2C2] = "2", + [MEC1322_I2C0_0] = "0_0", [MEC1322_I2C0_1] = "0_1", + [MEC1322_I2C1] = "1", [MEC1322_I2C2] = "2", [MEC1322_I2C3] = "3", }; @@ -114,8 +112,8 @@ static void configure_controller(int controller, int kbps) MEC1322_I2C_CTRL(controller) = CTRL_PIN; MEC1322_I2C_OWN_ADDR(controller) = 0x0; configure_controller_speed(controller, kbps); - MEC1322_I2C_CTRL(controller) = CTRL_PIN | CTRL_ESO | - CTRL_ACK | CTRL_ENI; + MEC1322_I2C_CTRL(controller) = CTRL_PIN | CTRL_ESO | CTRL_ACK | + CTRL_ENI; MEC1322_I2C_CONFIG(controller) |= BIT(10); /* ENAB */ /* Enable interrupt */ @@ -211,16 +209,15 @@ static void select_port(int port) MEC1322_I2C_CONFIG(controller) &= ~0xf; MEC1322_I2C_CONFIG(controller) |= port_sel; - } static inline int get_line_level(int controller) { int ret, ctrl; /* - * We need to enable BB (Bit Bang) mode in order to read line level - * properly, othervise line levels return always idle (0x60). - */ + * We need to enable BB (Bit Bang) mode in order to read line level + * properly, othervise line levels return always idle (0x60). + */ ctrl = MEC1322_I2C_BB_CTRL(controller); MEC1322_I2C_BB_CTRL(controller) |= 1; ret = (MEC1322_I2C_BB_CTRL(controller) >> 5) & 0x3; @@ -236,10 +233,8 @@ static inline void push_in_buf(uint8_t **in, uint8_t val, int skip) } } -int chip_i2c_xfer(const int port, - const uint16_t addr_flags, - const uint8_t *out, int out_size, - uint8_t *in, int in_size, int flags) +int chip_i2c_xfer(const int port, const uint16_t addr_flags, const uint8_t *out, + int out_size, uint8_t *in, int in_size, int flags) { int i; int controller; @@ -263,8 +258,7 @@ int chip_i2c_xfer(const int port, if (send_start && cdata[controller].transaction_state == I2C_TRANSACTION_STOPPED && (((reg & (STS_BER | STS_LAB)) || !(reg & STS_NBB)) || - (get_line_level(controller) - != I2C_LINE_IDLE))) { + (get_line_level(controller) != I2C_LINE_IDLE))) { CPRINTS("i2c%s bad status 0x%02x, SCL=%d, SDA=%d", i2c_port_names[port], reg, get_line_level(controller) & I2C_LINE_SCL_HIGH, @@ -287,8 +281,7 @@ int chip_i2c_xfer(const int port, if (out_size) { if (send_start) { MEC1322_I2C_DATA(controller) = - (uint8_t)(I2C_STRIP_FLAGS(addr_flags) - << 1); + (uint8_t)(I2C_STRIP_FLAGS(addr_flags) << 1); /* Clock out the slave address, sending START bit */ MEC1322_I2C_CTRL(controller) = CTRL_PIN | CTRL_ESO | @@ -326,24 +319,20 @@ int chip_i2c_xfer(const int port, /* Repeated start case */ if (cdata[controller].transaction_state == I2C_TRANSACTION_OPEN) - MEC1322_I2C_CTRL(controller) = CTRL_ESO | - CTRL_STA | - CTRL_ACK | - CTRL_ENI; + MEC1322_I2C_CTRL(controller) = + CTRL_ESO | CTRL_STA | CTRL_ACK | + CTRL_ENI; MEC1322_I2C_DATA(controller) = - (uint8_t)(I2C_STRIP_FLAGS(addr_flags) - << 1) - | 0x01; + (uint8_t)(I2C_STRIP_FLAGS(addr_flags) << 1) | + 0x01; /* New transaction case, clock out slave address. */ if (cdata[controller].transaction_state == I2C_TRANSACTION_STOPPED) - MEC1322_I2C_CTRL(controller) = CTRL_ESO | - CTRL_STA | - CTRL_ACK | - CTRL_ENI | - CTRL_PIN; + MEC1322_I2C_CTRL(controller) = + CTRL_ESO | CTRL_STA | CTRL_ACK | + CTRL_ENI | CTRL_PIN; cdata[controller].transaction_state = I2C_TRANSACTION_OPEN; @@ -379,8 +368,8 @@ int chip_i2c_xfer(const int port, goto err_chip_i2c_xfer; /* Send STOP */ - MEC1322_I2C_CTRL(controller) = - CTRL_PIN | CTRL_ESO | CTRL_ACK | CTRL_STO; + MEC1322_I2C_CTRL(controller) = CTRL_PIN | CTRL_ESO | + CTRL_ACK | CTRL_STO; cdata[controller].transaction_state = I2C_TRANSACTION_STOPPED; @@ -403,8 +392,8 @@ int chip_i2c_xfer(const int port, return EC_SUCCESS; err_chip_i2c_xfer: /* Send STOP and return error */ - MEC1322_I2C_CTRL(controller) = CTRL_PIN | CTRL_ESO | - CTRL_STO | CTRL_ACK; + MEC1322_I2C_CTRL(controller) = CTRL_PIN | CTRL_ESO | CTRL_STO | + CTRL_ACK; cdata[controller].transaction_state = I2C_TRANSACTION_STOPPED; if (ret_done == STS_LRB) return EC_ERROR_BUSY; @@ -417,8 +406,7 @@ err_chip_i2c_xfer: */ reset_controller(controller); return EC_ERROR_TIMEOUT; - } - else + } else return EC_ERROR_UNKNOWN; } @@ -520,10 +508,22 @@ static void handle_interrupt(int controller) task_set_event(id, TASK_EVENT_I2C_IDLE); } -static void i2c0_interrupt(void) { handle_interrupt(0); } -static void i2c1_interrupt(void) { handle_interrupt(1); } -static void i2c2_interrupt(void) { handle_interrupt(2); } -static void i2c3_interrupt(void) { handle_interrupt(3); } +static void i2c0_interrupt(void) +{ + handle_interrupt(0); +} +static void i2c1_interrupt(void) +{ + handle_interrupt(1); +} +static void i2c2_interrupt(void) +{ + handle_interrupt(2); +} +static void i2c3_interrupt(void) +{ + handle_interrupt(3); +} DECLARE_IRQ(MEC1322_IRQ_I2C_0, i2c0_interrupt, 2); DECLARE_IRQ(MEC1322_IRQ_I2C_1, i2c1_interrupt, 2); |