sensor: bmc150_magn: Convert to DTS

Convert bmc150_magn sensor driver to utilize device tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2019-11-07 11:23:01 -06:00 committed by Maureen Helm
commit 36c94ddd36
6 changed files with 32 additions and 40 deletions

View file

@ -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

View file

@ -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);

View file

@ -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)

View file

@ -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

View file

@ -5,3 +5,4 @@ tests:
harness: sensor
tags: sensors
depends_on: i2c gpio
filter: dt_compat_enabled("bosch,bmc150_magn")

View file

@ -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