diff options
Diffstat (limited to 'driver/accel_kionix.c')
-rw-r--r-- | driver/accel_kionix.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/driver/accel_kionix.c b/driver/accel_kionix.c index 4e1f5bb4fc..ec7953551f 100644 --- a/driver/accel_kionix.c +++ b/driver/accel_kionix.c @@ -133,26 +133,26 @@ static int find_param_index(const int eng_val, const int round_up, /** * Read register from accelerometer. */ -static int raw_read8__7bf(const int port, - const uint16_t i2c_spi_addr__7bf, +static int raw_read8(const int port, + const uint16_t i2c_spi_addr_flags, const int reg, int *data_ptr) { int rv = EC_ERROR_INVAL; - if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) { + if (SLAVE_IS_SPI(i2c_spi_addr_flags)) { #ifdef CONFIG_SPI_ACCEL_PORT uint8_t val; uint8_t cmd = 0x80 | reg; rv = spi_transaction( - &spi_devices[SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf)], + &spi_devices[SLAVE_GET_SPI_ADDR(i2c_spi_addr_flags)], &cmd, 1, &val, 1); if (rv == EC_SUCCESS) *data_ptr = val; #endif } else { - rv = i2c_read8__7bf(port, i2c_spi_addr__7bf, + rv = i2c_read8(port, i2c_spi_addr_flags, reg, data_ptr); } return rv; @@ -161,42 +161,42 @@ static int raw_read8__7bf(const int port, /** * Write register from accelerometer. */ -static int raw_write8__7bf(const int port, - const uint16_t i2c_spi_addr__7bf, +static int raw_write8(const int port, + const uint16_t i2c_spi_addr_flags, const int reg, int data) { int rv = EC_ERROR_INVAL; - if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) { + if (SLAVE_IS_SPI(i2c_spi_addr_flags)) { #ifdef CONFIG_SPI_ACCEL_PORT uint8_t cmd[2] = { reg, data }; rv = spi_transaction( - &spi_devices[SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf)], + &spi_devices[SLAVE_GET_SPI_ADDR(i2c_spi_addr_flags)], cmd, 2, NULL, 0); #endif } else { - rv = i2c_write8__7bf(port, i2c_spi_addr__7bf, + rv = i2c_write8(port, i2c_spi_addr_flags, reg, data); } return rv; } -static int raw_read_multi__7bf(const int port, - const uint16_t i2c_spi_addr__7bf, +static int raw_read_multi(const int port, + const uint16_t i2c_spi_addr_flags, uint8_t reg, uint8_t *rxdata, int rxlen) { int rv = EC_ERROR_INVAL; - if (SLAVE_IS_SPI(i2c_spi_addr__7bf)) { + if (SLAVE_IS_SPI(i2c_spi_addr_flags)) { #ifdef CONFIG_SPI_ACCEL_PORT reg |= 0x80; rv = spi_transaction( - &spi_devices[SLAVE_GET_SPI_ADDR__7b(i2c_spi_addr__7bf)], + &spi_devices[SLAVE_GET_SPI_ADDR(i2c_spi_addr_flags)], ®, 1, rxdata, rxlen); #endif } else { - rv = i2c_read_block__7bf(port, i2c_spi_addr__7bf, + rv = i2c_read_block(port, i2c_spi_addr_flags, reg, rxdata, rxlen); } return rv; @@ -225,14 +225,14 @@ static int disable_sensor(const struct motion_sensor_t *s, int *reg_val) * so that we can restore it later. */ for (i = 0; i < SENSOR_ENABLE_ATTEMPTS; i++) { - ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_read8(s->port, s->i2c_spi_addr_flags, reg, reg_val); if (ret != EC_SUCCESS) continue; *reg_val &= ~pc1_field; - ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_write8(s->port, s->i2c_spi_addr_flags, reg, *reg_val); if (ret == EC_SUCCESS) return EC_SUCCESS; @@ -258,7 +258,7 @@ static int enable_sensor(const struct motion_sensor_t *s, int reg_val) pc1_field = KIONIX_PC1_FIELD(V(s)); for (i = 0; i < SENSOR_ENABLE_ATTEMPTS; i++) { - ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_read8(s->port, s->i2c_spi_addr_flags, reg, ®_val); if (ret != EC_SUCCESS) continue; @@ -270,7 +270,7 @@ static int enable_sensor(const struct motion_sensor_t *s, int reg_val) #endif /* Enable accelerometer based on reg_val value. */ - ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_write8(s->port, s->i2c_spi_addr_flags, reg, reg_val | pc1_field); /* On first success, we are done. */ @@ -305,7 +305,7 @@ static int set_value(const struct motion_sensor_t *s, int reg, int val, /* Determine new value of control reg and attempt to write it. */ reg_val_new = (reg_val & ~field) | val; - ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_write8(s->port, s->i2c_spi_addr_flags, reg, reg_val_new); /* If successfully written, then save the range. */ @@ -447,7 +447,7 @@ static int check_orientation_locked(const struct motion_sensor_t *s) int orientation, raw_orientation; int ret; - ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_read8(s->port, s->i2c_spi_addr_flags, KX022_TSCP, &raw_orientation); if (ret != EC_SUCCESS) return ret; @@ -473,7 +473,7 @@ static int read(const struct motion_sensor_t *s, intv3_t v) /* Read 6 bytes starting at XOUT_L. */ reg = KIONIX_XOUT_L(V(s)); mutex_lock(s->mutex); - ret = raw_read_multi__7bf(s->port, s->i2c_spi_addr__7bf, reg, acc, 6); + ret = raw_read_multi(s->port, s->i2c_spi_addr_flags, reg, acc, 6); #ifdef CONFIG_KX022_ORIENTATION_SENSOR if ((s->location == MOTIONSENSE_LOC_LID) && (V(s) == 0) && (ret == EC_SUCCESS)) @@ -532,7 +532,7 @@ static int init(const struct motion_sensor_t *s) do { msleep(1); /* Read WHO_AM_I to be sure the device has booted */ - ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_read8(s->port, s->i2c_spi_addr_flags, reg, &val); if (ret == EC_SUCCESS) break; @@ -546,7 +546,7 @@ static int init(const struct motion_sensor_t *s) } else { /* Write 0x00 to the internal register for KX022 */ reg = KX022_INTERNAL; - ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_write8(s->port, s->i2c_spi_addr_flags, reg, 0x0); if (ret != EC_SUCCESS) { /* @@ -554,13 +554,13 @@ static int init(const struct motion_sensor_t *s) * from the first address, resend the command using * the second address. */ - if (!SLAVE_IS_SPI(s->i2c_spi_addr__7bf)) { - const uint16_t i2c_alt_addr__7bf = - I2C_GET_ADDR__7b( - s->i2c_spi_addr__7bf) + if (!SLAVE_IS_SPI(s->i2c_spi_addr_flags)) { + const uint16_t i2c_alt_addr_flags = + I2C_GET_ADDR( + s->i2c_spi_addr_flags) & ~2; - ret = raw_write8__7bf(s->port, - i2c_alt_addr__7bf, + ret = raw_write8(s->port, + i2c_alt_addr_flags, reg, 0x0); } } @@ -578,21 +578,21 @@ static int init(const struct motion_sensor_t *s) ret = disable_sensor(s, &val); if (ret != EC_SUCCESS) goto reset_failed; - ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &val); + ret = raw_read8(s->port, s->i2c_spi_addr_flags, reg, &val); if (ret != EC_SUCCESS) goto reset_failed; val |= reset_field; } else { /* Write 0 to CTRL2 for KX022 */ - ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, reg, 0x0); + ret = raw_write8(s->port, s->i2c_spi_addr_flags, reg, 0x0); if (ret != EC_SUCCESS) goto reset_failed; val = reset_field; } - ret = raw_write8__7bf(s->port, s->i2c_spi_addr__7bf, reg, val); + ret = raw_write8(s->port, s->i2c_spi_addr_flags, reg, val); if (ret != EC_SUCCESS) goto reset_failed; @@ -602,7 +602,7 @@ static int init(const struct motion_sensor_t *s) do { msleep(1); - ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, + ret = raw_read8(s->port, s->i2c_spi_addr_flags, reg, &val); /* Reset complete. */ if ((ret == EC_SUCCESS) && !(val & reset_field)) @@ -618,7 +618,7 @@ static int init(const struct motion_sensor_t *s) msleep(2); reg = KX022_COTR; - ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &val); + ret = raw_read8(s->port, s->i2c_spi_addr_flags, reg, &val); if (val != KX022_COTR_VAL_DEFAULT) { CPRINTF("[%s: the software reset failed]\n", s->name); ret = EC_ERROR_HW_INTERNAL; @@ -627,7 +627,7 @@ static int init(const struct motion_sensor_t *s) } reg = KIONIX_WHO_AM_I(V(s)); - ret = raw_read8__7bf(s->port, s->i2c_spi_addr__7bf, reg, &val); + ret = raw_read8(s->port, s->i2c_spi_addr_flags, reg, &val); if (ret != EC_SUCCESS || val != KIONIX_WHO_AM_I_VAL(V(s))) { ret = EC_ERROR_HW_INTERNAL; goto reset_failed; @@ -670,7 +670,7 @@ struct i2c_stress_test_dev kionix_i2c_stress_test_dev = { .read_val = KIONIX_WHO_AM_I_VAL(V(s)), .write_reg = KIONIX_ODR_REG(V(s)), }, - .i2c_read__7bf = &raw_read8__7bf, - .i2c_write__7bf = &raw_write8__7bf, + .i2c_read = &raw_read8, + .i2c_write = &raw_write8, }; #endif /* CONFIG_CMD_I2C_STRESS_TEST_ACCEL */ |