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

Convert lsm9ds0_gyro driver to get the device name as well as
i2c slave information and gpio info for triggers 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-19 13:27:19 +01:00 committed by Carles Cufí
commit b75a05cae6
4 changed files with 38 additions and 39 deletions

View file

@ -8,32 +8,12 @@
menuconfig LSM9DS0_GYRO menuconfig LSM9DS0_GYRO
bool "LSM9DS0 I2C gyroscope Chip" bool "LSM9DS0 I2C gyroscope Chip"
depends on I2C depends on (I2C && HAS_DTS_I2C)
help help
Enable driver for LSM9DS0 I2C-based gyroscope sensor. Enable driver for LSM9DS0 I2C-based gyroscope sensor.
if LSM9DS0_GYRO 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" menu "Attributes"
choice choice
@ -100,17 +80,4 @@ config LSM9DS0_GYRO_TRIGGER_DRDY
bool "Enable data ready trigger" bool "Enable data ready trigger"
depends on LSM9DS0_GYRO_TRIGGERS 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 endif # LSM9DS0_GYRO

View file

@ -345,17 +345,17 @@ static int lsm9ds0_gyro_init(struct device *dev)
} }
static const struct lsm9ds0_gyro_config lsm9ds0_gyro_config = { static const struct lsm9ds0_gyro_config lsm9ds0_gyro_config = {
.i2c_master_dev_name = CONFIG_LSM9DS0_GYRO_I2C_MASTER_DEV_NAME, .i2c_master_dev_name = DT_LSM9DS0_GYRO_I2C_MASTER_DEV_NAME,
.i2c_slave_addr = LSM9DS0_GYRO_I2C_ADDR, .i2c_slave_addr = DT_LSM9DS0_GYRO_I2C_ADDRESS,
#if defined(CONFIG_LSM9DS0_GYRO_TRIGGER_DRDY) #if defined(CONFIG_LSM9DS0_GYRO_TRIGGER_DRDY)
.gpio_drdy_dev_name = CONFIG_LSM9DS0_GYRO_GPIO_DRDY_DEV_NAME, .gpio_drdy_dev_name = DT_LSM9DS0_GYRO_INT_GPIO_DEV_NAME,
.gpio_drdy_int_pin = CONFIG_LSM9DS0_GYRO_GPIO_DRDY_INT_PIN, .gpio_drdy_int_pin = DT_LSM9DS0_GYRO_INT_GPIO_PIN,
#endif #endif
}; };
static struct lsm9ds0_gyro_data lsm9ds0_gyro_data; 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, lsm9ds0_gyro_init, &lsm9ds0_gyro_data, &lsm9ds0_gyro_config,
POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY,
&lsm9ds0_gyro_api_funcs); &lsm9ds0_gyro_api_funcs);

View file

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

View file

@ -168,6 +168,14 @@
#define DT_LSM9DS0_MFD_I2C_MASTER_DEV_NAME "" #define DT_LSM9DS0_MFD_I2C_MASTER_DEV_NAME ""
#endif #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 */ #endif /* CONFIG_HAS_DTS_I2C */
#if defined(CONFIG_HAS_DTS_SPI) #if defined(CONFIG_HAS_DTS_SPI)