sensor: bmi160: Convert to new DT_<COMPAT>_<INSTANCE> defines

Convert bmi160 sensor driver to use new defines so we can remove the
dts_fixup.h code for it.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2019-01-18 10:16:33 -06:00 committed by Maureen Helm
parent 31dad5b411
commit affc1ed253
4 changed files with 15 additions and 28 deletions

View file

@ -1,13 +0,0 @@
/*
* Copyright (c) 2018 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_BMI160_SLAVE DT_SNPS_DESIGNWARE_SPI_80010100_BOSCH_BMI160_1_BASE_ADDRESS
#define DT_BMI160_SPI_PORT_NAME DT_SNPS_DESIGNWARE_SPI_80010100_BOSCH_BMI160_1_BUS_NAME
#define DT_BMI160_GPIO_DEV_NAME DT_SNPS_DESIGNWARE_SPI_80010100_BOSCH_BMI160_1_INT_GPIOS_CONTROLLER
#define DT_BMI160_GPIO_PIN_NUM DT_SNPS_DESIGNWARE_SPI_80010100_BOSCH_BMI160_1_INT_GPIOS_PIN
#define DT_BMI160_NAME DT_SNPS_DESIGNWARE_SPI_80010100_BOSCH_BMI160_1_LABEL
#define DT_BMI160_SPI_BUS_FREQ DT_SNPS_DESIGNWARE_SPI_80010100_BOSCH_BMI160_1_SPI_MAX_FREQUENCY

View file

@ -796,16 +796,16 @@ int bmi160_init(struct device *dev)
u8_t val = 0U;
s32_t acc_range, gyr_range;
bmi160->spi = device_get_binding(DT_BMI160_SPI_PORT_NAME);
bmi160->spi = device_get_binding(DT_BOSCH_BMI160_0_BUS_NAME);
if (!bmi160->spi) {
LOG_DBG("SPI master controller not found: %s.",
DT_BMI160_SPI_PORT_NAME);
DT_BOSCH_BMI160_0_BUS_NAME);
return -EINVAL;
}
bmi160->spi_cfg.operation = SPI_WORD_SET(8);
bmi160->spi_cfg.frequency = DT_BMI160_SPI_BUS_FREQ;
bmi160->spi_cfg.slave = DT_BMI160_SLAVE;
bmi160->spi_cfg.frequency = DT_BOSCH_BMI160_0_SPI_MAX_FREQUENCY;
bmi160->spi_cfg.slave = DT_BOSCH_BMI160_0_BASE_ADDRESS;
/* reboot the chip */
if (bmi160_byte_write(dev, BMI160_REG_CMD, BMI160_CMD_SOFT_RESET) < 0) {
@ -900,13 +900,13 @@ int bmi160_init(struct device *dev)
const struct bmi160_device_config bmi160_config = {
#if defined(CONFIG_BMI160_TRIGGER)
.gpio_port = DT_BMI160_GPIO_DEV_NAME,
.int_pin = DT_BMI160_GPIO_PIN_NUM,
.gpio_port = DT_BOSCH_BMI160_0_INT_GPIOS_CONTROLLER,
.int_pin = DT_BOSCH_BMI160_0_INT_GPIOS_PIN,
#endif
};
DEVICE_AND_API_INIT(bmi160, DT_BMI160_NAME, bmi160_init, &bmi160_data,
DEVICE_AND_API_INIT(bmi160, DT_BOSCH_BMI160_0_LABEL, bmi160_init, &bmi160_data,
&bmi160_config, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY,
&bmi160_api);

View file

@ -417,7 +417,7 @@ void main(void)
#endif
printk("IMU: Binding...\n");
bmi160 = device_get_binding(DT_BMI160_NAME);
bmi160 = device_get_binding(DT_BOSCH_BMI160_0_LABEL);
if (!bmi160) {
printk("Gyro: Device not found.\n");
return;

View file

@ -199,13 +199,13 @@
#define DT_ADXL372_SPI_BUS_FREQ 8000000
#endif
#ifndef DT_BMI160_NAME
#define DT_BMI160_NAME ""
#define DT_BMI160_SLAVE 0
#define DT_BMI160_SPI_PORT_NAME ""
#define DT_BMI160_GPIO_DEV_NAME ""
#define DT_BMI160_GPIO_PIN_NUM 0
#define DT_BMI160_SPI_BUS_FREQ 6400000
#ifndef DT_BOSCH_BMI160_0_LABEL
#define DT_BOSCH_BMI160_0_LABEL ""
#define DT_BOSCH_BMI160_0_BASE_ADDRESS 0
#define DT_BOSCH_BMI160_0_BUS_NAME ""
#define DT_BOSCH_BMI160_0_INT_GPIOS_CONTROLLER ""
#define DT_BOSCH_BMI160_0_INT_GPIOS_PIN 0
#define DT_BOSCH_BMI160_0_SPI_MAX_FREQUENCY 6400000
#endif
#ifndef DT_LIS2DH_DEV_NAME