diff --git a/drivers/sensor/bmc150_magn/Kconfig b/drivers/sensor/bmc150_magn/Kconfig index 2a863f329fb..571d6c4fbcb 100644 --- a/drivers/sensor/bmc150_magn/Kconfig +++ b/drivers/sensor/bmc150_magn/Kconfig @@ -11,26 +11,6 @@ menuconfig BMC150_MAGN if BMC150_MAGN -config BMC150_MAGN_DEV_NAME - string "BMC150_MAGN device name" - default "bmc150_magn" - -config BMC150_MAGN_I2C_ADDR - hex "BMC150_MAGN I2C slave address" - default 0x12 - help - Specify the I2C slave address for the BMC150_MAGN. - - 0x12: GND - 0x13: VCC - -config BMC150_MAGN_I2C_MASTER_DEV_NAME - string "I2C master where BMC150_MAGN is connected" - default "I2C_0" - help - Specify the device name of the I2C master device to which BMC150_MAGN - is connected. - menu "Attributes" choice @@ -90,19 +70,4 @@ config BMC150_MAGN_TRIGGER_DRDY help Enable data ready interrupt for BMC150 magnetometer -config BMC150_MAGN_GPIO_DRDY_DEV_NAME - string "GPIO device where BMC150_MAGN data ready interrupt is connected" - depends on BMC150_MAGN_TRIGGER_DRDY - default "GPIO_0" - help - Specify the device name of the GPIO controller the BMC150_MAGN interrupt - is connected to. - -config BMC150_MAGN_GPIO_DRDY_INT_PIN - int "GPIO pin number for the data ready interrupt pin" - default 3 - depends on BMC150_MAGN_TRIGGER_DRDY - help - GPIO pin number for the data ready interrupt pin. - endif # BMC150_MAGN diff --git a/drivers/sensor/bmc150_magn/bmc150_magn.c b/drivers/sensor/bmc150_magn/bmc150_magn.c index ed817a9b4a0..ca999964a51 100644 --- a/drivers/sensor/bmc150_magn/bmc150_magn.c +++ b/drivers/sensor/bmc150_magn/bmc150_magn.c @@ -594,16 +594,16 @@ static int bmc150_magn_init(struct device *dev) } static const struct bmc150_magn_config bmc150_magn_config = { - .i2c_master_dev_name = CONFIG_BMC150_MAGN_I2C_MASTER_DEV_NAME, + .i2c_master_dev_name = DT_INST_0_BOSCH_BMC150_MAGN_BUS_NAME, .i2c_slave_addr = BMC150_MAGN_I2C_ADDR, #if defined(CONFIG_BMC150_MAGN_TRIGGER_DRDY) - .gpio_drdy_dev_name = CONFIG_BMC150_MAGN_GPIO_DRDY_DEV_NAME, - .gpio_drdy_int_pin = CONFIG_BMC150_MAGN_GPIO_DRDY_INT_PIN, + .gpio_drdy_dev_name = DT_INST_0_BOSCH_BMC150_MAGN_DRDY_GPIOS_CONTROLLER, + .gpio_drdy_int_pin = DT_INST_0_BOSCH_BMC150_MAGN_DRDY_GPIOS_PIN, #endif }; static struct bmc150_magn_data bmc150_magn_data; -DEVICE_AND_API_INIT(bmc150_magn, CONFIG_BMC150_MAGN_DEV_NAME, bmc150_magn_init, +DEVICE_AND_API_INIT(bmc150_magn, DT_INST_0_BOSCH_BMC150_MAGN_LABEL, bmc150_magn_init, &bmc150_magn_data, &bmc150_magn_config, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &bmc150_magn_api_funcs); diff --git a/drivers/sensor/bmc150_magn/bmc150_magn.h b/drivers/sensor/bmc150_magn/bmc150_magn.h index d3a40db57ba..b374e1cdbc6 100644 --- a/drivers/sensor/bmc150_magn/bmc150_magn.h +++ b/drivers/sensor/bmc150_magn/bmc150_magn.h @@ -73,7 +73,7 @@ #define BMC150_MAGN_MASK_DRDY_LATCHING BIT(1) #define BMC150_MAGN_MASK_DRDY_INT3_POLARITY BIT(0) -#define BMC150_MAGN_I2C_ADDR CONFIG_BMC150_MAGN_I2C_ADDR +#define BMC150_MAGN_I2C_ADDR DT_INST_0_BOSCH_BMC150_MAGN_BASE_ADDRESS #if defined(CONFIG_BMC150_MAGN_SAMPLING_REP_XY) || \ defined(CONFIG_BMC150_MAGN_SAMPLING_REP_Z) diff --git a/dts/bindings/sensor/bosch,bmc150_magn.yaml b/dts/bindings/sensor/bosch,bmc150_magn.yaml new file mode 100644 index 00000000000..655c5b0cf52 --- /dev/null +++ b/dts/bindings/sensor/bosch,bmc150_magn.yaml @@ -0,0 +1,17 @@ +# Copyright (c) 2019, Linaro Limited +# SPDX-License-Identifier: Apache-2.0 + +title: Bosch BMC150 Magnetometer + +description: | + Bosch BMC150 Magnetometer. See more info at: + https://www.bosch-sensortec.com/bst/products/all_products/bmc150 + +compatible: "bosch,bmc150_magn" + +include: i2c-device.yaml + +properties: + drdy-gpios: + type: phandle-array + required: false diff --git a/samples/sensor/magn_polling/sample.yaml b/samples/sensor/magn_polling/sample.yaml index a2c29f9e7e4..3a7a28207ff 100644 --- a/samples/sensor/magn_polling/sample.yaml +++ b/samples/sensor/magn_polling/sample.yaml @@ -5,3 +5,4 @@ tests: harness: sensor tags: sensors depends_on: i2c gpio + filter: dt_compat_enabled("bosch,bmc150_magn") diff --git a/tests/drivers/build_all/dts_fixup.h b/tests/drivers/build_all/dts_fixup.h index a8b6a1310e2..93f062e4237 100644 --- a/tests/drivers/build_all/dts_fixup.h +++ b/tests/drivers/build_all/dts_fixup.h @@ -390,6 +390,15 @@ #define DT_INST_0_BOSCH_BMG160_INT_GPIOS_PIN 0 #endif +#ifndef DT_INST_0_BOSCH_BMC150_MAGN_LABEL +#define DT_INST_0_BOSCH_BMC150_MAGN_LABEL "" +#define DT_INST_0_BOSCH_BMC150_MAGN_BASE_ADDRESS 0 +#define DT_INST_0_BOSCH_BMC150_MAGN_BUS_NAME "" +#define DT_INST_0_BOSCH_BMC150_MAGN_DRDY_GPIOS_CONTROLLER "" +#define DT_INST_0_BOSCH_BMC150_MAGN_DRDY_GPIOS_FLAGS 0 +#define DT_INST_0_BOSCH_BMC150_MAGN_DRDY_GPIOS_PIN 0 +#endif + #endif /* CONFIG_HAS_DTS_I2C */ #ifndef DT_ADXL372_DEV_NAME