diff options
Diffstat (limited to 'driver/tcpm')
-rw-r--r-- | driver/tcpm/anx7447.c | 39 | ||||
-rw-r--r-- | driver/tcpm/anx7447.h | 20 | ||||
-rw-r--r-- | driver/tcpm/anx74xx.c | 4 | ||||
-rw-r--r-- | driver/tcpm/anx74xx.h | 8 | ||||
-rw-r--r-- | driver/tcpm/anx7688.c | 6 | ||||
-rw-r--r-- | driver/tcpm/fusb302.h | 8 | ||||
-rw-r--r-- | driver/tcpm/mt6370.c | 4 | ||||
-rw-r--r-- | driver/tcpm/mt6370.h | 2 | ||||
-rw-r--r-- | driver/tcpm/nct38xx.h | 18 | ||||
-rw-r--r-- | driver/tcpm/ps8xxx.c | 4 | ||||
-rw-r--r-- | driver/tcpm/ps8xxx.h | 8 | ||||
-rw-r--r-- | driver/tcpm/tcpci.c | 28 | ||||
-rw-r--r-- | driver/tcpm/tcpm.h | 36 | ||||
-rw-r--r-- | driver/tcpm/tusb422.h | 2 |
14 files changed, 93 insertions, 94 deletions
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c index 7883f72717..d8c3cece6f 100644 --- a/driver/tcpm/anx7447.c +++ b/driver/tcpm/anx7447.c @@ -41,7 +41,7 @@ (((anx7447_get_vbus_voltage(port))) > vsafe0v_max) struct anx_state { - uint16_t i2c_slave_addr__7bf; + uint16_t i2c_slave_addr_flags; }; struct anx_usb_mux { @@ -64,17 +64,17 @@ static struct anx_usb_mux mux[CONFIG_USB_PD_PORT_COUNT]; * anx7447_reg_write() and anx7447_reg_read() are implemented here to access * ANX7447 SPI slave address. */ -const struct anx7447_i2c_addr anx7447_i2c_addrs__7bf[] = { - {AN7447_TCPC0_I2C_ADDR__7bf, AN7447_SPI0_I2C_ADDR__7bf}, - {AN7447_TCPC1_I2C_ADDR__7bf, AN7447_SPI1_I2C_ADDR__7bf}, - {AN7447_TCPC2_I2C_ADDR__7bf, AN7447_SPI2_I2C_ADDR__7bf}, - {AN7447_TCPC3_I2C_ADDR__7bf, AN7447_SPI3_I2C_ADDR__7bf} +const struct anx7447_i2c_addr anx7447_i2c_addrs_flags[] = { + {AN7447_TCPC0_I2C_ADDR_FLAGS, AN7447_SPI0_I2C_ADDR_FLAGS}, + {AN7447_TCPC1_I2C_ADDR_FLAGS, AN7447_SPI1_I2C_ADDR_FLAGS}, + {AN7447_TCPC2_I2C_ADDR_FLAGS, AN7447_SPI2_I2C_ADDR_FLAGS}, + {AN7447_TCPC3_I2C_ADDR_FLAGS, AN7447_SPI3_I2C_ADDR_FLAGS} }; static inline int anx7447_reg_write(int port, int reg, int val) { - int rv = i2c_write8__7bf(tcpc_config[port].i2c_info.port, - anx[port].i2c_slave_addr__7bf, + int rv = i2c_write8(tcpc_config[port].i2c_info.port, + anx[port].i2c_slave_addr_flags, reg, val); #ifdef CONFIG_USB_PD_TCPC_LOW_POWER pd_device_accessed(port); @@ -84,8 +84,8 @@ static inline int anx7447_reg_write(int port, int reg, int val) static inline int anx7447_reg_read(int port, int reg, int *val) { - int rv = i2c_read8__7bf(tcpc_config[port].i2c_info.port, - anx[port].i2c_slave_addr__7bf, + int rv = i2c_read8(tcpc_config[port].i2c_info.port, + anx[port].i2c_slave_addr_flags, reg, val); #ifdef CONFIG_USB_PD_TCPC_LOW_POWER pd_device_accessed(port); @@ -291,20 +291,19 @@ static int anx7447_init(int port) * find corresponding anx7447 SPI slave address according to * specified TCPC slave address */ - for (i = 0; i < ARRAY_SIZE(anx7447_i2c_addrs__7bf); i++) { - if (I2C_GET_ADDR__7b( - tcpc_config[port].i2c_info.addr__7bf) == - I2C_GET_ADDR__7b( - anx7447_i2c_addrs__7bf[i].tcpc_slave_addr__7bf)) { - anx[port].i2c_slave_addr__7bf = - anx7447_i2c_addrs__7bf[i].spi_slave_addr__7bf; + for (i = 0; i < ARRAY_SIZE(anx7447_i2c_addrs_flags); i++) { + if (I2C_GET_ADDR(tcpc_config[port].i2c_info.addr_flags) == + I2C_GET_ADDR( + anx7447_i2c_addrs_flags[i].tcpc_slave_addr_flags)) { + anx[port].i2c_slave_addr_flags = + anx7447_i2c_addrs_flags[i].spi_slave_addr_flags; break; } } - if (!I2C_GET_ADDR__7b(anx[port].i2c_slave_addr__7bf)) { + if (!I2C_GET_ADDR(anx[port].i2c_slave_addr_flags)) { ccprintf("TCPC I2C slave addr 0x%x is invalid for ANX7447\n", - I2C_GET_ADDR__7b(tcpc_config[port] - .i2c_info.addr__7bf)); + I2C_GET_ADDR(tcpc_config[port] + .i2c_info.addr_flags)); return EC_ERROR_UNKNOWN; } diff --git a/driver/tcpm/anx7447.h b/driver/tcpm/anx7447.h index 32958f0007..f4827180da 100644 --- a/driver/tcpm/anx7447.h +++ b/driver/tcpm/anx7447.h @@ -91,19 +91,19 @@ /* End of defines used for CONFIG_USB_PD_TCPM_ANX7447_OCM_ERASE_COMMAND */ struct anx7447_i2c_addr { - uint16_t tcpc_slave_addr__7bf; - uint16_t spi_slave_addr__7bf; + uint16_t tcpc_slave_addr_flags; + uint16_t spi_slave_addr_flags; }; -#define AN7447_TCPC0_I2C_ADDR__7bf (0x2C) -#define AN7447_TCPC1_I2C_ADDR__7bf (0x2B) -#define AN7447_TCPC2_I2C_ADDR__7bf (0x2A) -#define AN7447_TCPC3_I2C_ADDR__7bf (0x29) +#define AN7447_TCPC0_I2C_ADDR_FLAGS 0x2C +#define AN7447_TCPC1_I2C_ADDR_FLAGS 0x2B +#define AN7447_TCPC2_I2C_ADDR_FLAGS 0x2A +#define AN7447_TCPC3_I2C_ADDR_FLAGS 0x29 -#define AN7447_SPI0_I2C_ADDR__7bf (0x3F) -#define AN7447_SPI1_I2C_ADDR__7bf (0x37) -#define AN7447_SPI2_I2C_ADDR__7bf (0x32) -#define AN7447_SPI3_I2C_ADDR__7bf (0x31) +#define AN7447_SPI0_I2C_ADDR_FLAGS 0x3F +#define AN7447_SPI1_I2C_ADDR_FLAGS 0x37 +#define AN7447_SPI2_I2C_ADDR_FLAGS 0x32 +#define AN7447_SPI3_I2C_ADDR_FLAGS 0x31 /* * Time TEST_R must be held high for a reset diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index bf75e21e07..47a7349f6a 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -1173,7 +1173,7 @@ struct i2c_stress_test_dev anx74xx_i2c_stress_test_dev = { .read_val = ANX74XX_VENDOR_ID & 0xFF, .write_reg = ANX74XX_REG_CC_SOFTWARE_CTRL, }, - .i2c_read__7bf = &tcpc_i2c_read__7bf, - .i2c_write__7bf = &tcpc_i2c_write__7bf, + .i2c_read = &tcpc_i2c_read, + .i2c_write = &tcpc_i2c_write, }; #endif /* CONFIG_CMD_I2C_STRESS_TEST_TCPC */ diff --git a/driver/tcpm/anx74xx.h b/driver/tcpm/anx74xx.h index 39762129a7..2648013abf 100644 --- a/driver/tcpm/anx74xx.h +++ b/driver/tcpm/anx74xx.h @@ -11,10 +11,10 @@ #define __CROS_EC_USB_PD_TCPM_ANX74XX_H /* I2C interface */ -#define ANX74XX_I2C_ADDR1__7bf 0x28 -#define ANX74XX_I2C_ADDR2__7bf 0x39 -#define ANX74XX_I2C_ADDR3__7bf 0x3E -#define ANX74XX_I2C_ADDR4__7bf 0x40 +#define ANX74XX_I2C_ADDR1_FLAGS 0x28 +#define ANX74XX_I2C_ADDR2_FLAGS 0x39 +#define ANX74XX_I2C_ADDR3_FLAGS 0x3E +#define ANX74XX_I2C_ADDR4_FLAGS 0x40 #define ANX74XX_REG_IRQ_POL_LOW 0x00 #define ANX74XX_REG_IRQ_POL_HIGH 0x02 diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c index 4ea0602483..b450245a76 100644 --- a/driver/tcpm/anx7688.c +++ b/driver/tcpm/anx7688.c @@ -21,7 +21,7 @@ #define ANX7688_REG_HPD_IRQ BIT(1) #define ANX7688_REG_HPD_ENABLE BIT(2) -#define ANX7688_USBC_ADDR__7bf 0x28 +#define ANX7688_USBC_ADDR_FLAGS 0x28 #define ANX7688_REG_RAMCTRL 0xe7 #define ANX7688_REG_RAMCTRL_BOOT_DONE BIT(6) @@ -39,7 +39,7 @@ static int anx7688_init(int port) * 100ms to follow cts. */ while (1) { - rv = i2c_read8__7bf(I2C_PORT_TCPC, ANX7688_USBC_ADDR__7bf, + rv = i2c_read8(I2C_PORT_TCPC, ANX7688_USBC_ADDR_FLAGS, ANX7688_REG_RAMCTRL, &mask); if (rv == EC_SUCCESS && (mask & ANX7688_REG_RAMCTRL_BOOT_DONE)) @@ -174,7 +174,7 @@ static int anx7688_tcpm_get_vbus_level(int port) * Therefore, we use a proprietary register to read the unfiltered VBus * value. See crosbug.com/p/55221 . */ - i2c_read8__7bf(I2C_PORT_TCPC, 0x28, 0x40, ®); + i2c_read8(I2C_PORT_TCPC, 0x28, 0x40, ®); return ((reg & 0x10) ? 1 : 0); } #endif diff --git a/driver/tcpm/fusb302.h b/driver/tcpm/fusb302.h index edf1feb8dd..ec418407f7 100644 --- a/driver/tcpm/fusb302.h +++ b/driver/tcpm/fusb302.h @@ -16,13 +16,13 @@ /* I2C slave address varies by part number */ /* FUSB302BUCX / FUSB302BMPX */ -#define FUSB302_I2C_SLAVE_ADDR__7bf 0x22 +#define FUSB302_I2C_SLAVE_ADDR_FLAGS 0x22 /* FUSB302B01MPX */ -#define FUSB302_I2C_SLAVE_ADDR_B01__7bf 0x23 +#define FUSB302_I2C_SLAVE_ADDR_B01_FLAGS 0x23 /* FUSB302B10MPX */ -#define FUSB302_I2C_SLAVE_ADDR_B10__7bf 0x24 +#define FUSB302_I2C_SLAVE_ADDR_B10_FLAGS 0x24 /* FUSB302B11MPX */ -#define FUSB302_I2C_SLAVE_ADDR_B11__7bf 0x25 +#define FUSB302_I2C_SLAVE_ADDR_B11_FLAGS 0x25 /* Default retry count for transmitting */ #define PD_RETRY_COUNT 3 diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c index 473e2a1881..1d729f28e1 100644 --- a/driver/tcpm/mt6370.c +++ b/driver/tcpm/mt6370.c @@ -22,8 +22,8 @@ /* i2c_write function which won't wake TCPC from low power mode. */ static int mt6370_i2c_write8(int port, int reg, int val) { - return i2c_write8__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, reg, val); + return i2c_write8(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); } static int mt6370_init(int port) diff --git a/driver/tcpm/mt6370.h b/driver/tcpm/mt6370.h index 166009d9a4..64ebd51a3d 100644 --- a/driver/tcpm/mt6370.h +++ b/driver/tcpm/mt6370.h @@ -48,7 +48,7 @@ #define MT6370_REG_UNLOCK_PW2 0xF0 #define MT6370_REG_UNLOCK_PW1 0xF1 -#define MT6370_TCPC_I2C_ADDR__7bf 0x4E +#define MT6370_TCPC_I2C_ADDR_FLAGS 0x4E /* * MT6370_REG_PHY_CTRL1 0x80 diff --git a/driver/tcpm/nct38xx.h b/driver/tcpm/nct38xx.h index 1357d47bab..e85860f2db 100644 --- a/driver/tcpm/nct38xx.h +++ b/driver/tcpm/nct38xx.h @@ -10,15 +10,15 @@ #define __CROS_EC_USB_PD_TCPM_NCT38XX_H /* I2C interface */ -#define NCT38xx_I2C_ADDR1_1__7bf 0x70 -#define NCT38xx_I2C_ADDR1_2__7bf 0x71 -#define NCT38xx_I2C_ADDR1_3__7bf 0x72 -#define NCT38xx_I2C_ADDR1_4__7bf 0x73 - -#define NCT38xx_I2C_ADDR2_1__7bf 0x74 -#define NCT38xx_I2C_ADDR2_2__7bf 0x75 -#define NCT38xx_I2C_ADDR2_3__7bf 0x76 -#define NCT38xx_I2C_ADDR2_4__7bf 0x77 +#define NCT38xx_I2C_ADDR1_1_FLAGS 0x70 +#define NCT38xx_I2C_ADDR1_2_FLAGS 0x71 +#define NCT38xx_I2C_ADDR1_3_FLAGS 0x72 +#define NCT38xx_I2C_ADDR1_4_FLAGS 0x73 + +#define NCT38xx_I2C_ADDR2_1_FLAGS 0x74 +#define NCT38xx_I2C_ADDR2_2_FLAGS 0x75 +#define NCT38xx_I2C_ADDR2_3_FLAGS 0x76 +#define NCT38xx_I2C_ADDR2_4_FLAGS 0x77 #define NCT38XX_REG_VENDOR_ID_L 0x00 #define NCT38XX_REG_VENDOR_ID_H 0x01 diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index db243621b8..e95a70191a 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -207,8 +207,8 @@ struct i2c_stress_test_dev ps8xxx_i2c_stress_test_dev = { .read_val = PS8XXX_VENDOR_ID & 0xFF, .write_reg = MUX_IN_HPD_ASSERTION_REG, }, - .i2c_read__7bf = &tcpc_i2c_read__7bf, - .i2c_write__7bf = &tcpc_i2c_write__7bf, + .i2c_read = &tcpc_i2c_read, + .i2c_write = &tcpc_i2c_write, }; #endif /* CONFIG_CMD_I2C_STRESS_TEST_TCPC */ diff --git a/driver/tcpm/ps8xxx.h b/driver/tcpm/ps8xxx.h index 143ab67649..b94156652d 100644 --- a/driver/tcpm/ps8xxx.h +++ b/driver/tcpm/ps8xxx.h @@ -9,10 +9,10 @@ #define __CROS_EC_USB_PD_TCPM_PS8XXX_H /* I2C interface */ -#define PS8751_I2C_ADDR1__7bf (0x0B) -#define PS8751_I2C_ADDR2__7bf (0x1B) -#define PS8751_I2C_ADDR3__7bf (0x2B) -#define PS8751_I2C_ADDR4__7bf (0x4B) +#define PS8751_I2C_ADDR1_FLAGS 0x0B +#define PS8751_I2C_ADDR2_FLAGS 0x1B +#define PS8751_I2C_ADDR3_FLAGS 0x2B +#define PS8751_I2C_ADDR4_FLAGS 0x4B /* Minimum Delay for reset assertion */ #define PS8XXX_RESET_DELAY_MS 1 diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 129adf3da9..ab0b4f777c 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -40,8 +40,8 @@ int tcpc_write(int port, int reg, int val) pd_wait_exit_low_power(port); - rv = i2c_write8__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + rv = i2c_write8(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); pd_device_accessed(port); @@ -54,8 +54,8 @@ int tcpc_write16(int port, int reg, int val) pd_wait_exit_low_power(port); - rv = i2c_write16__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + rv = i2c_write16(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); pd_device_accessed(port); @@ -68,8 +68,8 @@ int tcpc_read(int port, int reg, int *val) pd_wait_exit_low_power(port); - rv = i2c_read8__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + rv = i2c_read8(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); pd_device_accessed(port); @@ -82,8 +82,8 @@ int tcpc_read16(int port, int reg, int *val) pd_wait_exit_low_power(port); - rv = i2c_read16__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + rv = i2c_read16(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); pd_device_accessed(port); @@ -96,8 +96,8 @@ int tcpc_read_block(int port, int reg, uint8_t *in, int size) pd_wait_exit_low_power(port); - rv = i2c_read_block__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + rv = i2c_read_block(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, in, size); pd_device_accessed(port); @@ -110,8 +110,8 @@ int tcpc_write_block(int port, int reg, const uint8_t *out, int size) pd_wait_exit_low_power(port); - rv = i2c_write_block__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + rv = i2c_write_block(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, out, size); pd_device_accessed(port); @@ -137,8 +137,8 @@ int tcpc_xfer_unlocked(int port, const uint8_t *out, int out_size, pd_wait_exit_low_power(port); - rv = i2c_xfer_unlocked__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + rv = i2c_xfer_unlocked(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, out, out_size, in, in_size, flags); pd_device_accessed(port); diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h index 9d03f52500..ca7d3cf7bd 100644 --- a/driver/tcpm/tcpm.h +++ b/driver/tcpm/tcpm.h @@ -27,60 +27,60 @@ #ifndef CONFIG_USB_PD_TCPC_LOW_POWER static inline int tcpc_write(int port, int reg, int val) { - return i2c_write8__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + return i2c_write8(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); } static inline int tcpc_write16(int port, int reg, int val) { - return i2c_write16__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + return i2c_write16(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); } static inline int tcpc_read(int port, int reg, int *val) { - return i2c_read8__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + return i2c_read8(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); } static inline int tcpc_read16(int port, int reg, int *val) { - return i2c_read16__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + return i2c_read16(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, val); } static inline int tcpc_xfer(int port, const uint8_t *out, int out_size, uint8_t *in, int in_size) { - return i2c_xfer__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + return i2c_xfer(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, out, out_size, in, in_size); } static inline int tcpc_xfer_unlocked(int port, const uint8_t *out, int out_size, uint8_t *in, int in_size, int flags) { - return i2c_xfer_unlocked__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + return i2c_xfer_unlocked(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, out, out_size, in, in_size, flags); } static inline int tcpc_read_block(int port, int reg, uint8_t *in, int size) { - return i2c_read_block__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + return i2c_read_block(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, in, size); } static inline int tcpc_write_block(int port, int reg, const uint8_t *out, int size) { - return i2c_write_block__7bf(tcpc_config[port].i2c_info.port, - tcpc_config[port].i2c_info.addr__7bf, + return i2c_write_block(tcpc_config[port].i2c_info.port, + tcpc_config[port].i2c_info.addr_flags, reg, out, size); } @@ -225,13 +225,13 @@ static inline int tcpm_enter_low_power_mode(int port) #endif #ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC -static inline int tcpc_i2c_read__7bf(const int port, const uint16_t addr__7bf, +static inline int tcpc_i2c_read(const int port, const uint16_t addr_flags, const int reg, int *data) { return tcpc_read(port, reg, data); } -static inline int tcpc_i2c_write__7bf(const int port, const uint16_t addr__7bf, +static inline int tcpc_i2c_write(const int port, const uint16_t addr_flags, const int reg, int data) { return tcpc_write(port, reg, data); diff --git a/driver/tcpm/tusb422.h b/driver/tcpm/tusb422.h index 524886801c..52d0a079d6 100644 --- a/driver/tcpm/tusb422.h +++ b/driver/tcpm/tusb422.h @@ -9,7 +9,7 @@ #define __CROS_EC_USB_PD_TCPM_TUSB422_H /* I2C interface */ -#define TUSB422_I2C_ADDR__7bf 0x20 +#define TUSB422_I2C_ADDR_FLAGS 0x20 extern const struct tcpm_drv tusb422_tcpm_drv; |