diff --git a/drivers/sensor/lsm9ds0_gyro/Kconfig b/drivers/sensor/lsm9ds0_gyro/Kconfig index d939e29b5de..a00680cd108 100644 --- a/drivers/sensor/lsm9ds0_gyro/Kconfig +++ b/drivers/sensor/lsm9ds0_gyro/Kconfig @@ -8,32 +8,12 @@ menuconfig LSM9DS0_GYRO bool "LSM9DS0 I2C gyroscope Chip" - depends on I2C + depends on (I2C && HAS_DTS_I2C) help Enable driver for LSM9DS0 I2C-based gyroscope sensor. if LSM9DS0_GYRO -config LSM9DS0_GYRO_DEV_NAME - string "LSM9DS0_GYRO device name" - default "lsm9ds0_gyro" - -config LSM9DS0_GYRO_I2C_ADDR - hex "LSM9DS0_GYRO I2C slave address" - default 0x6A - help - Specify the I2C slave address for the LSM9DS0_GYRO. - - 0x6A: GND - 0x6B: VCC - -config LSM9DS0_GYRO_I2C_MASTER_DEV_NAME - string "I2C master where LSM9DS0 gyroscope is connected" - default "I2C_0" - help - Specify the device name of the I2C master device to which LSM9DS0_GYRO - is connected. - menu "Attributes" choice @@ -100,17 +80,4 @@ config LSM9DS0_GYRO_TRIGGER_DRDY bool "Enable data ready trigger" depends on LSM9DS0_GYRO_TRIGGERS -config LSM9DS0_GYRO_GPIO_DRDY_DEV_NAME - string "GPIO device where LSM9DS0_GYRO data ready interrupt is connected" - depends on LSM9DS0_GYRO_TRIGGER_DRDY - default "GPIO_0" - help - Specify the device name of the GPIO controller the BMC150_MAGN interrupt - is connected to. - -config LSM9DS0_GYRO_GPIO_DRDY_INT_PIN - int "GPIO pin number for the data ready interrupt pin" - default 3 - depends on LSM9DS0_GYRO_TRIGGER_DRDY - endif # LSM9DS0_GYRO diff --git a/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.c b/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.c index a14e3475fe8..90ab3d1c32f 100644 --- a/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.c +++ b/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.c @@ -345,17 +345,17 @@ static int lsm9ds0_gyro_init(struct device *dev) } static const struct lsm9ds0_gyro_config lsm9ds0_gyro_config = { - .i2c_master_dev_name = CONFIG_LSM9DS0_GYRO_I2C_MASTER_DEV_NAME, - .i2c_slave_addr = LSM9DS0_GYRO_I2C_ADDR, + .i2c_master_dev_name = DT_LSM9DS0_GYRO_I2C_MASTER_DEV_NAME, + .i2c_slave_addr = DT_LSM9DS0_GYRO_I2C_ADDRESS, #if defined(CONFIG_LSM9DS0_GYRO_TRIGGER_DRDY) - .gpio_drdy_dev_name = CONFIG_LSM9DS0_GYRO_GPIO_DRDY_DEV_NAME, - .gpio_drdy_int_pin = CONFIG_LSM9DS0_GYRO_GPIO_DRDY_INT_PIN, + .gpio_drdy_dev_name = DT_LSM9DS0_GYRO_INT_GPIO_DEV_NAME, + .gpio_drdy_int_pin = DT_LSM9DS0_GYRO_INT_GPIO_PIN, #endif }; static struct lsm9ds0_gyro_data lsm9ds0_gyro_data; -DEVICE_AND_API_INIT(lsm9ds0_gyro, CONFIG_LSM9DS0_GYRO_DEV_NAME, +DEVICE_AND_API_INIT(lsm9ds0_gyro, DT_LSM9DS0_GYRO_DEV_NAME, lsm9ds0_gyro_init, &lsm9ds0_gyro_data, &lsm9ds0_gyro_config, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &lsm9ds0_gyro_api_funcs); diff --git a/dts/bindings/sensor/st,lsm9ds0-gyro-i2c.yaml b/dts/bindings/sensor/st,lsm9ds0-gyro-i2c.yaml new file mode 100644 index 00000000000..9d76656264a --- /dev/null +++ b/dts/bindings/sensor/st,lsm9ds0-gyro-i2c.yaml @@ -0,0 +1,24 @@ +# +# Copyright (c) 2018 STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 +# +--- +title: STMicroelectronics MEMS sensors LSM9DS0-GYRO +version: 0.1 + +description: > + This binding gives a base representation of LSM9DS0 3-axis gyro + +inherits: + !include i2c-device.yaml + +properties: + compatible: + constraint: "st,lsm9ds0-gyro" + + irq-gpios: + type: compound + category: required + generation: define, use-prop-name +... diff --git a/tests/drivers/build_all/dts_fixup.h b/tests/drivers/build_all/dts_fixup.h index a2d36c91509..158b939c5e4 100644 --- a/tests/drivers/build_all/dts_fixup.h +++ b/tests/drivers/build_all/dts_fixup.h @@ -168,6 +168,14 @@ #define DT_LSM9DS0_MFD_I2C_MASTER_DEV_NAME "" #endif +#ifndef DT_LSM9DS0_GYRO_DEV_NAME +#define DT_LSM9DS0_GYRO_DEV_NAME "" +#define DT_LSM9DS0_GYRO_I2C_ADDRESS 0x1d +#define DT_LSM9DS0_GYRO_I2C_MASTER_DEV_NAME "" +#define DT_LSM9DS0_GYRO_INT_GPIO_DEV_NAME "" +#define DT_LSM9DS0_GYRO_INT_GPIO_PIN 1 +#endif + #endif /* CONFIG_HAS_DTS_I2C */ #if defined(CONFIG_HAS_DTS_SPI)