From 6d39786d6a22fc355cd4d7eea384d254819c6a38 Mon Sep 17 00:00:00 2001 From: Denis Brockus Date: Tue, 16 Jul 2019 15:10:11 -0600 Subject: Remove __7b, __8b and __7bf The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1767528 Reviewed-by: Edward Hill Commit-Queue: Edward Hill Tested-by: Edward Hill --- chip/stm32/i2c-stm32f0.c | 24 ++++++++--------- chip/stm32/i2c-stm32f4.c | 68 ++++++++++++++++++++++++------------------------ chip/stm32/i2c-stm32l.c | 14 +++++----- chip/stm32/i2c-stm32l4.c | 16 ++++++------ chip/stm32/usb_power.c | 58 ++++++++++++++++++++--------------------- chip/stm32/usb_power.h | 4 +-- 6 files changed, 92 insertions(+), 92 deletions(-) (limited to 'chip/stm32') diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c index 657789af50..a3796ec00f 100644 --- a/chip/stm32/i2c-stm32f0.c +++ b/chip/stm32/i2c-stm32f0.c @@ -27,7 +27,7 @@ /* Transmit timeout in microseconds */ #define I2C_TX_TIMEOUT_MASTER (10 * MSEC) -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS #if (I2C_PORT_EC == STM32_I2C1_PORT) #define IRQ_SLAVE STM32_IRQ_I2C1 #else @@ -146,7 +146,7 @@ static void i2c_init_port(const struct i2c_port_t *p) STM32_RCC_APB1ENR |= 1 << (21 + port); if (port == STM32_I2C1_PORT) { -#if defined(CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF) && \ +#if defined(CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS) && \ defined(CONFIG_LOW_POWER_IDLE) && \ (I2C_PORT_EC == STM32_I2C1_PORT) /* @@ -189,7 +189,7 @@ defined(CONFIG_LOW_POWER_IDLE) && \ } /*****************************************************************************/ -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS /* Host command slave */ /* * Buffer for received host command packets (including prefix byte on request, @@ -426,11 +426,11 @@ DECLARE_IRQ(IRQ_SLAVE, i2c2_event_interrupt, 2); /*****************************************************************************/ /* Interface */ -int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, +int chip_i2c_xfer(const int port, const uint16_t slave_addr_flags, const uint8_t *out, int out_bytes, uint8_t *in, int in_bytes, int flags) { - int addr__8b = I2C_GET_ADDR__7b(slave_addr__7bf) << 1; + int addr_8bit = I2C_GET_ADDR(slave_addr_flags) << 1; int rv = EC_SUCCESS; int i; int xfer_start = flags & I2C_XFER_START; @@ -438,7 +438,7 @@ int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, #if defined(CONFIG_I2C_SCL_GATE_ADDR) && defined(CONFIG_I2C_SCL_GATE_PORT) if (port == CONFIG_I2C_SCL_GATE_PORT && - slave_addr__7bf == CONFIG_I2C_SCL_GATE_ADDR__7BF) + slave_addr_flags == CONFIG_I2C_SCL_GATE_ADDR_FLAGS) gpio_set_level(CONFIG_I2C_SCL_GATE_GPIO, 1); #endif @@ -459,7 +459,7 @@ int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, * NBYTES again. if we are starting, then set START bit. */ STM32_I2C_CR2(port) = ((out_bytes & 0xFF) << 16) - | addr__8b + | addr_8bit | ((in_bytes == 0 && xfer_stop) ? STM32_I2C_CR2_AUTOEND : 0) | ((in_bytes == 0 && !xfer_stop) ? @@ -488,7 +488,7 @@ int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, * set START bit to send (re)start and begin read transaction. */ STM32_I2C_CR2(port) = ((in_bytes & 0xFF) << 16) - | STM32_I2C_CR2_RD_WRN | addr__8b + | STM32_I2C_CR2_RD_WRN | addr_8bit | (xfer_stop ? STM32_I2C_CR2_AUTOEND : 0) | (!xfer_stop ? STM32_I2C_CR2_RELOAD : 0) | (out_bytes || xfer_start ? STM32_I2C_CR2_START : 0); @@ -545,7 +545,7 @@ xfer_exit: #ifdef CONFIG_I2C_SCL_GATE_ADDR if (port == CONFIG_I2C_SCL_GATE_PORT && - slave_addr__7bf == CONFIG_I2C_SCL_GATE_ADDR__7BF) + slave_addr_flags == CONFIG_I2C_SCL_GATE_ADDR_FLAGS) gpio_set_level(CONFIG_I2C_SCL_GATE_GPIO, 0); #endif @@ -588,7 +588,7 @@ static void i2c_init(void) for (i = 0; i < i2c_ports_used; i++, p++) i2c_init_port(p); -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_RXIE | STM32_I2C_CR1_ERRIE | STM32_I2C_CR1_ADDRIE | STM32_I2C_CR1_STOPIE | STM32_I2C_CR1_NACKIE; @@ -601,14 +601,14 @@ static void i2c_init(void) STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_WUPEN; #endif STM32_I2C_OAR1(I2C_PORT_EC) = 0x8000 - | (I2C_GET_ADDR__7b(CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF) << 1); + | (I2C_GET_ADDR(CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS) << 1); #ifdef TCPCI_I2C_SLAVE /* * Configure TCPC address with OA2[1] masked so that we respond * to CONFIG_TCPC_I2C_BASE_ADDR and CONFIG_TCPC_I2C_BASE_ADDR + 2. */ STM32_I2C_OAR2(I2C_PORT_EC) = 0x8100 - | (I2C_GET_ADDR__7b(CONFIG_TCPC_I2C_BASE_ADDR__7BF) << 1); + | (I2C_GET_ADDR(CONFIG_TCPC_I2C_BASE_ADDR_FLAGS) << 1); #endif task_enable_irq(IRQ_SLAVE); #endif diff --git a/chip/stm32/i2c-stm32f4.c b/chip/stm32/i2c-stm32f4.c index ea9cb49d79..48f5a73f6a 100644 --- a/chip/stm32/i2c-stm32f4.c +++ b/chip/stm32/i2c-stm32f4.c @@ -25,7 +25,7 @@ /* Transmit timeout in microseconds */ #define I2C_TX_TIMEOUT_MASTER (10 * MSEC) -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS #if (I2C_PORT_EC == STM32_I2C1_PORT) #define IRQ_SLAVE_EV STM32_IRQ_I2C1_EV #define IRQ_SLAVE_ER STM32_IRQ_I2C1_ER @@ -171,7 +171,7 @@ static int wait_sr1(int port, int mask) * * @return Non-zero if error. */ -static int send_start__8b(const int port, const uint16_t slave_addr__8b) +static int send_start(const int port, const uint16_t slave_addr_8bit) { int rv; @@ -182,7 +182,7 @@ static int send_start__8b(const int port, const uint16_t slave_addr__8b) return I2C_ERROR_FAILED_START; /* Write slave address */ - STM32_I2C_DR(port) = slave_addr__8b; + STM32_I2C_DR(port) = slave_addr_8bit; rv = wait_sr1_poll(port, STM32_I2C_SR1_ADDR, SET, 1); if (rv) return rv; @@ -263,7 +263,7 @@ static int wait_fmpi2c_isr(int port, int mask) * * @return Non-zero if error. */ -static int send_fmpi2c_start__8b(const int port, const uint16_t slave_addr__8b, +static int send_fmpi2c_start(const int port, const uint16_t slave_addr_8bit, int size, int is_read) { uint32_t reg; @@ -274,7 +274,7 @@ static int send_fmpi2c_start__8b(const int port, const uint16_t slave_addr__8b, FMPI2C_CR2_RELOAD | FMPI2C_CR2_AUTOEND | FMPI2C_CR2_RD_WRN | FMPI2C_CR2_START | FMPI2C_CR2_STOP); reg |= FMPI2C_CR2_START | FMPI2C_CR2_AUTOEND | - slave_addr__8b | FMPI2C_CR2_SIZE(size) | + slave_addr_8bit | FMPI2C_CR2_SIZE(size) | (is_read ? FMPI2C_CR2_RD_WRN : 0); STM32_FMPI2C_CR2(port) = reg; @@ -401,7 +401,7 @@ static void fmpi2c_clear_regs(int port) * * @return EC_SUCCESS on success. */ -static int chip_fmpi2c_xfer__8b(const int port, const uint16_t slave_addr__8b, +static int chip_fmpi2c_xfer(const int port, const uint16_t slave_addr_8bit, const uint8_t *out, int out_bytes, uint8_t *in, int in_bytes, int flags) { @@ -422,8 +422,8 @@ static int chip_fmpi2c_xfer__8b(const int port, const uint16_t slave_addr__8b, /* No out bytes and no in bytes means just check for active */ if (out_bytes || !in_bytes) { - rv = send_fmpi2c_start__8b( - port, slave_addr__8b, out_bytes, FMPI2C_WRITE); + rv = send_fmpi2c_start( + port, slave_addr_8bit, out_bytes, FMPI2C_WRITE); if (rv) goto xfer_exit; @@ -448,8 +448,8 @@ static int chip_fmpi2c_xfer__8b(const int port, const uint16_t slave_addr__8b, dma_start_rx(dma, in_bytes, in); i2c_dma_enable_tc_interrupt(dma->channel, port); - rv_start = send_fmpi2c_start__8b( - port, slave_addr__8b, in_bytes, FMPI2C_READ); + rv_start = send_fmpi2c_start( + port, slave_addr_8bit, in_bytes, FMPI2C_READ); if (rv_start) goto xfer_exit; @@ -553,11 +553,11 @@ static void i2c_clear_regs(int port) */ /* Perform an i2c transaction. */ -int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, +int chip_i2c_xfer(const int port, const uint16_t slave_addr_flags, const uint8_t *out, int out_bytes, uint8_t *in, int in_bytes, int flags) { - int addr__8b = I2C_GET_ADDR__7b(slave_addr__7bf) << 1; + int addr_8bit = I2C_GET_ADDR(slave_addr_flags) << 1; int started = (flags & I2C_XFER_START) ? 0 : 1; int rv = EC_SUCCESS; int i; @@ -568,7 +568,7 @@ int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, ASSERT(!started); if (p->port == STM32F4_FMPI2C_PORT) { - return chip_fmpi2c_xfer__8b(port, addr__8b, + return chip_fmpi2c_xfer(port, addr_8bit, out, out_bytes, in, in_bytes, flags); } @@ -577,7 +577,7 @@ int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, /* No out bytes and no in bytes means just check for active */ if (out_bytes || !in_bytes) { - rv = send_start__8b(port, addr__8b); + rv = send_start(port, addr_8bit); if (rv) goto xfer_exit; @@ -616,7 +616,7 @@ int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, STM32_I2C_CR2(port) |= STM32_I2C_CR2_LAST; STM32_I2C_CR2(port) |= STM32_I2C_CR2_DMAEN; - rv_start = send_start__8b(port, addr__8b | 0x01); + rv_start = send_start(port, addr_8bit | 0x01); if ((in_bytes == 1) && (flags & I2C_XFER_STOP)) STM32_I2C_CR1(port) |= STM32_I2C_CR1_STOP; @@ -760,7 +760,7 @@ DECLARE_HOOK(HOOK_FREQ_CHANGE, i2c_freq_change_hook, HOOK_PRIO_DEFAULT); /*****************************************************************************/ /* Slave */ -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS /* Host command slave */ /* * Buffer for received host command packets (including prefix byte on request, @@ -839,7 +839,7 @@ static void i2c_process_command(void) host_packet_receive(&i2c_packet); } -#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR_FLAGS static void i2c_send_board_response(int len) { /* host_buffer data range, beyond this length, will return 0xec */ @@ -863,7 +863,7 @@ static void i2c_event_handler(int port) volatile uint32_t i2c_sr2; volatile uint32_t i2c_sr1; static int rx_pending, buf_idx; - static uint16_t addr__8b; + static uint16_t addr_8bit; volatile uint32_t dummy __attribute__((unused)); @@ -888,15 +888,15 @@ static void i2c_event_handler(int port) /* Transfer matched our slave address */ if (i2c_sr1 & STM32_I2C_SR1_ADDR) { - addr__8b = ((i2c_sr2 & STM32_I2C_SR2_DUALF) ? + addr_8bit = ((i2c_sr2 & STM32_I2C_SR2_DUALF) ? STM32_I2C_OAR2(port) : STM32_I2C_OAR1(port)) & 0xfe; if (i2c_sr2 & STM32_I2C_SR2_TRA) { /* Transmitter slave */ i2c_sr1 |= STM32_I2C_SR1_TXE; -#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR_FLAGS if (!rx_pending && !tx_pending) { tx_pending = 1; - i2c_process_board_command(1, addr__8b, 0); + i2c_process_board_command(1, addr_8bit, 0); } #endif } else { @@ -931,11 +931,11 @@ static void i2c_event_handler(int port) host_i2c_resp_port = port; /* Disable buffer interrupt */ STM32_I2C_CR2(port) &= ~STM32_I2C_CR2_ITBUFEN; -#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF - if ((addr__8b >> 1) == - I2C_GET_ADDR__7b( - CONFIG_BOARD_I2C_SLAVE_ADDR__7BF)) - i2c_process_board_command(1, addr__8b, +#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR_FLAGS + if ((addr_8bit >> 1) == + I2C_GET_ADDR( + CONFIG_BOARD_I2C_SLAVE_ADDR_FLAGS)) + i2c_process_board_command(1, addr_8bit, buf_idx); else #endif @@ -957,11 +957,11 @@ static void i2c_event_handler(int port) /* Disable buffer interrupt */ STM32_I2C_CR2(port) &= ~STM32_I2C_CR2_ITBUFEN; -#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR_FLAGS if (rx_pending && - (addr__8b >> 1) == - I2C_GET_ADDR__7b(CONFIG_BOARD_I2C_SLAVE_ADDR__7BF)) - i2c_process_board_command(0, addr__8b, buf_idx); + (addr_8b >> 1) == + I2C_GET_ADDR(CONFIG_BOARD_I2C_SLAVE_ADDR_FLAGS)) + i2c_process_board_command(0, addr_8bit, buf_idx); #endif rx_pending = 0; tx_pending = 0; @@ -996,7 +996,7 @@ static void i2c_init(void) i2c_init_port(p); -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS /* Enable ACK */ STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_ACK; /* Enable interrupts */ @@ -1004,10 +1004,10 @@ static void i2c_init(void) | STM32_I2C_CR2_ITERREN; /* Setup host command slave */ STM32_I2C_OAR1(I2C_PORT_EC) = STM32_I2C_OAR1_B14 - | (I2C_GET_ADDR__7b(CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF) << 1); -#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR__7BF + | (I2C_GET_ADDR(CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS) << 1); +#ifdef CONFIG_BOARD_I2C_SLAVE_ADDR_FLAGS STM32_I2C_OAR2(I2C_PORT_EC) = STM32_I2C_OAR2_ENDUAL - | (I2C_GET_ADDR__7b(CONFIG_BOARD_I2C_SLAVE_ADDR__7BF) << 1); + | (I2C_GET_ADDR(CONFIG_BOARD_I2C_SLAVE_ADDR_FLAGS) << 1); #endif task_enable_irq(IRQ_SLAVE_EV); task_enable_irq(IRQ_SLAVE_ER); diff --git a/chip/stm32/i2c-stm32l.c b/chip/stm32/i2c-stm32l.c index 5801e7eb86..cf65ab6eab 100644 --- a/chip/stm32/i2c-stm32l.c +++ b/chip/stm32/i2c-stm32l.c @@ -98,7 +98,7 @@ static int wait_sr1(int port, int mask) * * @return Non-zero if error. */ -static int send_start__8b(int port, uint16_t slave_addr__8b) +static int send_start(int port, uint16_t slave_addr_8bit) { int rv; @@ -110,7 +110,7 @@ static int send_start__8b(int port, uint16_t slave_addr__8b) return I2C_ERROR_FAILED_START; /* Write slave address */ - STM32_I2C_DR(port) = slave_addr__8b & 0xff; + STM32_I2C_DR(port) = slave_addr_8bit & 0xff; rv = wait_sr1(port, STM32_I2C_SR1_ADDR); if (rv) return rv; @@ -164,12 +164,12 @@ static void i2c_init_port(const struct i2c_port_t *p) /*****************************************************************************/ /* Interface */ -int chip_i2c_xfer__7bf(const int port, - const uint16_t slave_addr__7bf, +int chip_i2c_xfer(const int port, + const uint16_t slave_addr_flags, const uint8_t *out, int out_bytes, uint8_t *in, int in_bytes, int flags) { - int addr__8b == I2C_GET_ADDR__7b(slave_addr__7bf) << 1; + int addr_8bit == I2C_GET_ADDR(slave_addr_flags) << 1; int started = (flags & I2C_XFER_START) ? 0 : 1; int rv = EC_SUCCESS; int i; @@ -196,7 +196,7 @@ int chip_i2c_xfer__7bf(const int port, /* No out bytes and no in bytes means just check for active */ if (out_bytes || !in_bytes) { if (!started) { - rv = send_start__8b(port, addr__8b); + rv = send_start(port, addr_8bit); if (rv) goto xfer_exit; } @@ -228,7 +228,7 @@ int chip_i2c_xfer__7bf(const int port, STM32_I2C_CR1(port) |= STM32_I2C_CR1_ACK; if (!started) { - rv = send_start__8b(port, addr__8b | 0x01); + rv = send_start(port, addr_8bit | 0x01); if (rv) goto xfer_exit; } diff --git a/chip/stm32/i2c-stm32l4.c b/chip/stm32/i2c-stm32l4.c index ff97f6ae02..5810468375 100644 --- a/chip/stm32/i2c-stm32l4.c +++ b/chip/stm32/i2c-stm32l4.c @@ -26,7 +26,7 @@ /* Transmit timeout in microseconds */ #define I2C_TX_TIMEOUT_MASTER (10 * MSEC) -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS #define I2C_SLAVE_ERROR_CODE 0xec #if (I2C_PORT_EC == STM32_I2C1_PORT) #define IRQ_SLAVE STM32_IRQ_I2C1 @@ -177,7 +177,7 @@ static void i2c_init_port(const struct i2c_port_t *p) /*****************************************************************************/ -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS static void i2c_event_handler(int port) { @@ -303,11 +303,11 @@ DECLARE_IRQ(IRQ_SLAVE, i2c_event_interrupt, 2); /*****************************************************************************/ /* Interface */ -int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, +int chip_i2c_xfer(const int port, const uint16_t slave_addr_flags, const uint8_t *out, int out_bytes, uint8_t *in, int in_bytes, int flags) { - int addr__8b = I2C_GET_ADDR__7b(slave_addr__7bf) << 1; + int addr_8bit = I2C_GET_ADDR(slave_addr_flags) << 1; int rv = EC_SUCCESS; int i; int xfer_start = flags & I2C_XFER_START; @@ -330,7 +330,7 @@ int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, * NBYTES again. if we are starting, then set START bit. */ STM32_I2C_CR2(port) = ((out_bytes & 0xFF) << 16) - | addr__8b + | addr_8bit | ((in_bytes == 0 && xfer_stop) ? STM32_I2C_CR2_AUTOEND : 0) | ((in_bytes == 0 && !xfer_stop) ? @@ -359,7 +359,7 @@ int chip_i2c_xfer__7bf(const int port, const uint16_t slave_addr__7bf, * set START bit to send (re)start and begin read transaction. */ STM32_I2C_CR2(port) = ((in_bytes & 0xFF) << 16) - | STM32_I2C_CR2_RD_WRN | addr__8b + | STM32_I2C_CR2_RD_WRN | addr_8bit | (xfer_stop ? STM32_I2C_CR2_AUTOEND : 0) | (!xfer_stop ? STM32_I2C_CR2_RELOAD : 0) | (out_bytes || xfer_start ? STM32_I2C_CR2_START : 0); @@ -453,12 +453,12 @@ static void i2c_init(void) for (i = 0; i < i2c_ports_used; i++, p++) i2c_init_port(p); -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_RXIE | STM32_I2C_CR1_ERRIE | STM32_I2C_CR1_ADDRIE | STM32_I2C_CR1_STOPIE | STM32_I2C_CR1_NACKIE; STM32_I2C_OAR1(I2C_PORT_EC) = 0x8000 - | (I2C_GET_ADDR__7b(CONFIG_HOSTCMD_I2C_SLAVE_ADDR__7BF) << 1); + | (I2C_GET_ADDR(CONFIG_HOSTCMD_I2C_SLAVE_ADDR_FLAGS) << 1); task_enable_irq(IRQ_SLAVE); #endif } diff --git a/chip/stm32/usb_power.c b/chip/stm32/usb_power.c index 4cf8bac99e..90f0039c2c 100644 --- a/chip/stm32/usb_power.c +++ b/chip/stm32/usb_power.c @@ -249,7 +249,7 @@ static int usb_power_state_addina(struct usb_power_config const *config, ina = state->ina_cfg + state->ina_count; ina->port = cmd->addina.port; - ina->addr__7bf = cmd->addina.addr__7bf; + ina->addr_flags = cmd->addina.addr_flags; ina->rs = cmd->addina.rs; ina->type = cmd->addina.type; @@ -270,7 +270,7 @@ static int usb_power_state_addina(struct usb_power_config const *config, struct usb_power_ina_cfg *tmp = state->ina_cfg + i; if ((tmp->port == ina->port) && - (tmp->addr__7bf == ina->addr__7bf)) { + (tmp->addr_flags == ina->addr_flags)) { ina->shared = 1; tmp->shared = 1; } @@ -406,46 +406,46 @@ int reg_type_mapping(enum usb_power_ina_type ina_type) } } -uint16_t ina2xx_readagain__7bf(uint8_t port, uint16_t slave_addr__7bf) +uint16_t ina2xx_readagain(uint8_t port, uint16_t slave_addr_flags) { int res; uint16_t val; - res = i2c_xfer__7bf(port, slave_addr__7bf, + res = i2c_xfer(port, slave_addr_flags, NULL, 0, (uint8_t *)&val, sizeof(uint16_t)); if (res) { CPRINTS("INA2XX I2C readagain failed p:%d a:%02x", - (int)port, (int)I2C_GET_ADDR__7b(slave_addr__7bf)); + (int)port, (int)I2C_GET_ADDR(slave_addr_flags)); return 0x0bad; } return (val >> 8) | ((val & 0xff) << 8); } -uint16_t ina2xx_read__7bf(uint8_t port, uint16_t slave_addr__7bf, +uint16_t ina2xx_read(uint8_t port, uint16_t slave_addr_flags, uint8_t reg) { int res; int val; - res = i2c_read16__7bf(port, slave_addr__7bf, reg, &val); + res = i2c_read16(port, slave_addr_flags, reg, &val); if (res) { CPRINTS("INA2XX I2C read failed p:%d a:%02x, r:%02x", - (int)port, (int)I2C_GET_ADDR__7b(slave_addr__7bf), + (int)port, (int)I2C_GET_ADDR(slave_addr_flags), (int)reg); return 0x0bad; } return (val >> 8) | ((val & 0xff) << 8); } -int ina2xx_write__7bf(uint8_t port, uint16_t slave_addr__7bf, +int ina2xx_write(uint8_t port, uint16_t slave_addr_flags, uint8_t reg, uint16_t val) { int res; uint16_t be_val = (val >> 8) | ((val & 0xff) << 8); - res = i2c_write16__7bf(port, slave_addr__7bf, reg, be_val); + res = i2c_write16(port, slave_addr_flags, reg, be_val); if (res) CPRINTS("INA2XX I2C write failed"); return res; @@ -509,12 +509,12 @@ static int usb_power_init_inas(struct usb_power_config const *config) { int conf, cal; - conf = ina2xx_read__7bf(ina->port, ina->addr__7bf, + conf = ina2xx_read(ina->port, ina->addr_flags, INA231_REG_CONF); - cal = ina2xx_read__7bf(ina->port, ina->addr__7bf, + cal = ina2xx_read(ina->port, ina->addr_flags, INA231_REG_CAL); CPRINTS("[CAP] %d (%d,0x%02x): conf:%x, cal:%x", - i, ina->port, I2C_GET_ADDR__7b(ina->addr__7bf), + i, ina->port, I2C_GET_ADDR(ina->addr_flags), conf, cal); } #endif @@ -536,7 +536,7 @@ static int usb_power_init_inas(struct usb_power_config const *config) if (ina->scale == 0) return -1; value = (5120000 * 100) / (ina->scale * ina->rs); - ret = ina2xx_write__7bf(ina->port, ina->addr__7bf, + ret = ina2xx_write(ina->port, ina->addr_flags, INA231_REG_CAL, value); if (ret != EC_SUCCESS) { CPRINTS("[CAP] usb_power_init_inas CAL FAIL: %d", ret); @@ -546,7 +546,7 @@ static int usb_power_init_inas(struct usb_power_config const *config) { int actual; - actual = ina2xx_read__7bf(ina->port, ina->addr__7bf, + actual = ina2xx_read(ina->port, ina->addr_flags, INA231_REG_CAL); CPRINTS("[CAP] scale: %d uA/div, %d uW/div, cal:%x act:%x", ina->scale / 100, ina->scale*25/100, value, actual); @@ -557,7 +557,7 @@ static int usb_power_init_inas(struct usb_power_config const *config) INA231_CONF_SHUNT_TIME(shunt_time) | INA231_CONF_BUS_TIME(shunt_time) | INA231_CONF_AVG(avg); - ret = ina2xx_write__7bf(ina->port, ina->addr__7bf, + ret = ina2xx_write(ina->port, ina->addr_flags, INA231_REG_CONF, value); if (ret != EC_SUCCESS) { CPRINTS("[CAP] usb_power_init_inas CONF FAIL: %d", ret); @@ -567,22 +567,22 @@ static int usb_power_init_inas(struct usb_power_config const *config) { int actual; - actual = ina2xx_read__7bf(ina->port, ina->addr__7bf, + actual = ina2xx_read(ina->port, ina->addr_flags, INA231_REG_CONF); CPRINTS("[CAP] %d (%d,0x%02x): conf:%x, act:%x", - i, ina->port, I2C_GET_ADDR__7b(ina->addr__7bf), + i, ina->port, I2C_GET_ADDR(ina->addr_flags), value, actual); } #endif #ifdef USB_POWER_VERBOSE { int busv_mv = - (ina2xx_read__7bf(ina->port, ina->addr__7bf, + (ina2xx_read(ina->port, ina->addr_flags, INA231_REG_BUSV) * 125) / 100; CPRINTS("[CAP] %d (%d,0x%02x): busv:%dmv", - i, ina->port, I2C_GET_ADDR__7b(ina->addr__7bf), + i, ina->port, I2C_GET_ADDR(ina->addr_flags), busv_mv); } #endif @@ -590,7 +590,7 @@ static int usb_power_init_inas(struct usb_power_config const *config) * will be cached and all ina2xx_readagain() calls will read * from the same address. */ - ina2xx_read__7bf(ina->port, ina->addr__7bf, + ina2xx_read(ina->port, ina->addr_flags, reg_type_mapping(ina->type)); #ifdef USB_POWER_VERBOSE CPRINTS("[CAP] %d (%d,0x%02x): type:%d", (int)(ina->type)); @@ -649,11 +649,11 @@ static int usb_power_get_samples(struct usb_power_config const *config) * transaction. */ if (ina->shared) - regval = ina2xx_read__7bf(ina->port, ina->addr__7bf, + regval = ina2xx_read(ina->port, ina->addr_flags, reg_type_mapping(ina->type)); else - regval = ina2xx_readagain__7bf(ina->port, - ina->addr__7bf); + regval = ina2xx_readagain(ina->port, + ina->addr_flags); r->power[i] = regval; #ifdef USB_POWER_VERBOSE { @@ -662,13 +662,13 @@ static int usb_power_get_samples(struct usb_power_config const *config) int voltage; int bvoltage; - voltage = ina2xx_read__7bf(ina->port, ina->addr__7bf, + voltage = ina2xx_read(ina->port, ina->addr_flags, INA231_REG_RSHV); - bvoltage = ina2xx_read__7bf(ina->port, ina->addr__7bf, + bvoltage = ina2xx_read(ina->port, ina->addr_flags, INA231_REG_BUSV); - current = ina2xx_read__7bf(ina->port, ina->addr__7bf, + current = ina2xx_read(ina->port, ina->addr_flags, INA231_REG_CURR); - power = ina2xx_read__7bf(ina->port, ina->addr__7bf, + power = ina2xx_read(ina->port, ina->addr_flags, INA231_REG_PWR); { int uV = ((int)voltage * 25) / 10; @@ -678,7 +678,7 @@ static int usb_power_get_samples(struct usb_power_config const *config) int uW = (((int)power * ina->scale*25)/100); CPRINTS("[CAP] %d (%d,0x%02x): %dmV / %dmO = %dmA", - i, ina->port, I2C_GET_ADDR__7b(ina->addr__7bf), + i, ina->port, I2C_GET_ADDR(ina->addr_flags), uV/1000, ina->rs, uA/1000); CPRINTS("[CAP] %duV %dmV %duA %dCuA " "%duW v:%04x, b:%04x, p:%04x", diff --git a/chip/stm32/usb_power.h b/chip/stm32/usb_power.h index f2f1426691..cbea9554a5 100644 --- a/chip/stm32/usb_power.h +++ b/chip/stm32/usb_power.h @@ -138,7 +138,7 @@ struct usb_power_ina_cfg { /* i2c bus. TODO(nsanders): specify what kind of index. */ int port; /* 7-bit i2c addr */ - uint16_t addr__7bf; + uint16_t addr_flags; /* Base voltage. mV */ int mv; @@ -243,7 +243,7 @@ struct __attribute__ ((__packed__)) usb_power_command_addina { uint16_t command; uint8_t port; uint8_t type; - uint16_t addr__7bf; + uint16_t addr_flags; uint8_t extra; uint32_t rs; }; -- cgit v1.2.1