driver: sensors: convert lsm9ds0_mfd to use information coming from dts

Convert lsm9ds0_mfd accel/magn driver to get the device name as well
as i2c slave information from device tree. Updates the build_all
test accordingly.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2018-12-17 15:21:16 +01:00 committed by Maureen Helm
commit 4446b16e24
4 changed files with 34 additions and 24 deletions

View file

@ -9,32 +9,12 @@
menuconfig LSM9DS0_MFD
bool "LSM9DS0 I2C accelerometer, magnetometer and temperature sensor chip"
depends on I2C
depends on (I2C && HAS_DTS_I2C)
help
Enable driver for LSM9DS0 I2C-based MFD sensor.
if LSM9DS0_MFD
config LSM9DS0_MFD_DEV_NAME
string "LSM9DS0_MFD device name"
default "lsm9ds0_mfd"
config LSM9DS0_MFD_I2C_ADDR
hex "LSM9DS0_MFD I2C slave address"
default 0x1E
help
Specify the I2C slave address for the LSM9DS0_MFD.
0x1E: GND
0x1F: VCC
config LSM9DS0_MFD_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_MFD
is connected.
config LSM9DS0_MFD_ACCEL_ENABLE
bool "Enable accelerometer"
default y

View file

@ -788,12 +788,12 @@ int lsm9ds0_mfd_init(struct device *dev)
}
static const struct lsm9ds0_mfd_config lsm9ds0_mfd_config = {
.i2c_master_dev_name = CONFIG_LSM9DS0_MFD_I2C_MASTER_DEV_NAME,
.i2c_slave_addr = LSM9DS0_MFD_I2C_ADDR,
.i2c_master_dev_name = DT_LSM9DS0_MFD_I2C_MASTER_DEV_NAME,
.i2c_slave_addr = DT_LSM9DS0_MFD_I2C_ADDRESS,
};
static struct lsm9ds0_mfd_data lsm9ds0_mfd_data;
DEVICE_AND_API_INIT(lsm9ds0_mfd, CONFIG_LSM9DS0_MFD_DEV_NAME, lsm9ds0_mfd_init,
DEVICE_AND_API_INIT(lsm9ds0_mfd, DT_LSM9DS0_MFD_DEV_NAME, lsm9ds0_mfd_init,
&lsm9ds0_mfd_data, &lsm9ds0_mfd_config, POST_KERNEL,
CONFIG_SENSOR_INIT_PRIORITY, &lsm9ds0_mfd_api_funcs);

View file

@ -0,0 +1,24 @@
#
# Copyright (c) 2018 STMicroelectronics
#
# SPDX-License-Identifier: Apache-2.0
#
---
title: STMicroelectronics MEMS sensors LSM9DS0-MFD
version: 0.1
description: >
This binding gives a base representation of LSM9DS0 3-axis accelerometer + magnetometer
inherits:
!include i2c-device.yaml
properties:
compatible:
constraint: "st,lsm9ds0-mfd"
irq-gpios:
type: compound
category: required
generation: define, use-prop-name
...

View file

@ -162,6 +162,12 @@
#define DT_LIS2MDL_INT_GPIO_PIN_NUM 0
#endif
#ifndef DT_LSM9DS0_MFD_DEV_NAME
#define DT_LSM9DS0_MFD_DEV_NAME ""
#define DT_LSM9DS0_MFD_I2C_ADDRESS 0x1d
#define DT_LSM9DS0_MFD_I2C_MASTER_DEV_NAME ""
#endif
#endif /* CONFIG_HAS_DTS_I2C */
#if defined(CONFIG_HAS_DTS_SPI)