sensor: bmm150: Convert to DTS

Convert bmm150 sensor driver and sample app to utilize device tree.

Introduce a dts board overlay on the frdm_k64f board to ensure we at
least have a single platform in which the sample gets built.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2019-11-07 11:00:38 -06:00 committed by Maureen Helm
commit 7b8b5524be
7 changed files with 35 additions and 21 deletions

View file

@ -10,24 +10,6 @@ menuconfig BMM150
Enable driver for BMM150 I2C-based Geomagnetic sensor.
if BMM150
config BMM150_DEV_NAME
string "BMM150 device name"
default "bmm150"
config BMM150_I2C_ADDR
hex "BMM150 I2C slave address"
default 0x10
help
Specify the I2C slave address for the BMM150.
Possible addresses are 0x10,0x11,0x12,0x13.
config BMM150_I2C_MASTER_DEV_NAME
string "I2C master where BMM150 is connected"
default "I2C_0"
help
Specify the device name of the I2C master device to which BMM150
is connected.
choice
prompt "Default preset"
default BMM150_PRESET_REGULAR

View file

@ -598,12 +598,12 @@ static int bmm150_init(struct device *dev)
}
static const struct bmm150_config bmm150_config = {
.i2c_master_dev_name = CONFIG_BMM150_I2C_MASTER_DEV_NAME,
.i2c_master_dev_name = DT_INST_0_BOSCH_BMM150_BUS_NAME,
.i2c_slave_addr = BMM150_I2C_ADDR,
};
static struct bmm150_data bmm150_data;
DEVICE_AND_API_INIT(bmm150, CONFIG_BMM150_DEV_NAME, bmm150_init,
DEVICE_AND_API_INIT(bmm150, DT_INST_0_BOSCH_BMM150_LABEL, bmm150_init,
&bmm150_data, &bmm150_config, POST_KERNEL,
CONFIG_SENSOR_INIT_PRIORITY, &bmm150_api_funcs);

View file

@ -82,7 +82,7 @@
#define BMM150_MASK_DRDY_LATCHING BIT(1)
#define BMM150_MASK_DRDY_INT3_POLARITY BIT(0)
#define BMM150_I2C_ADDR CONFIG_BMM150_I2C_ADDR
#define BMM150_I2C_ADDR DT_INST_0_BOSCH_BMM150_BASE_ADDRESS
#if defined(CONFIG_BMM150_SAMPLING_REP_XY) || \
defined(CONFIG_BMM150_SAMPLING_REP_Z)

View file

@ -0,0 +1,12 @@
# Copyright (c) 2019, Linaro Limited
# SPDX-License-Identifier: Apache-2.0
title: Bosch BMM150 Geomagnetic sensor
description: |
Bosch BMM150 Geomagnetic sensor. See more info at:
https://www.bosch-sensortec.com/bst/products/all_products/bmm150
compatible: "bosch,bmm150"
include: i2c-device.yaml

View file

@ -0,0 +1,13 @@
/*
* Copyright (c) 2019, Linaro Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
&i2c0 {
bmm150@10 {
compatible = "bosch,bmm150";
reg = <0x10>;
label = "BMM150";
};
};

View file

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

View file

@ -375,6 +375,12 @@
#define DT_INST_0_HOPERF_HP206C_BUS_NAME ""
#endif
#ifndef DT_INST_0_BOSCH_BMM150_LABEL
#define DT_INST_0_BOSCH_BMM150_LABEL ""
#define DT_INST_0_BOSCH_BMM150_BASE_ADDRESS 0
#define DT_INST_0_BOSCH_BMM150_BUS_NAME ""
#endif
#endif /* CONFIG_HAS_DTS_I2C */
#ifndef DT_ADXL372_DEV_NAME