Commit 529d53bf authored by Angus Ainslie (Purism)'s avatar Angus Ainslie (Purism)

Merge branch 'f/4.18/gyro' into imx8-4.18-wip

parents 2552192b 8cbbf388
......@@ -59,6 +59,7 @@ Gyroscopes:
- st,l3g4is-gyro
- st,lsm330-gyro
- st,lsm9ds0-gyro
- st,lsm9ds1-gyro
Magnetometers:
- st,lsm303agr-magn
......
......@@ -921,7 +921,7 @@
&i2c3 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3>;
pinctrl-0 = <&pinctrl_i2c3>, <&pinctrl_imu>;
status = "okay";
ov5640_mipi: ov5640_mipi@3c {
......@@ -974,6 +974,13 @@
VDDA-supply = <&ldo3_reg>;
};
lsm9d: lsm9d@6a {
compatible = "st,lsm9ds1-gyro";
reg = <0x6a>;
interrupt-parent = <&gpio3>;
interrupts = <19 IRQ_TYPE_LEVEL_LOW>;
power-supply = <&reg_pwr_en>;
};
};
&uart1 { /* console */
......
......@@ -4470,6 +4470,9 @@ CONFIG_IIO=y
# SSP Sensor Common
#
# CONFIG_IIO_SSP_SENSORHUB is not set
CONFIG_IIO_ST_SENSORS_I2C=m
CONFIG_IIO_ST_SENSORS_SPI=m
CONFIG_IIO_ST_SENSORS_CORE=m
#
# Counters
......@@ -4536,7 +4539,9 @@ CONFIG_IIO=y
# CONFIG_ADXRS450 is not set
# CONFIG_BMG160 is not set
# CONFIG_MPU3050_I2C is not set
# CONFIG_IIO_ST_GYRO_3AXIS is not set
CONFIG_IIO_ST_GYRO_3AXIS=m
CONFIG_IIO_ST_GYRO_I2C_3AXIS=m
CONFIG_IIO_ST_GYRO_SPI_3AXIS=m
# CONFIG_ITG3200 is not set
#
......
......@@ -111,7 +111,8 @@ config IIO_ST_GYRO_3AXIS
select IIO_TRIGGERED_BUFFER if (IIO_BUFFER)
help
Say yes here to build support for STMicroelectronics gyroscopes:
L3G4200D, LSM330DL, L3GD20, LSM330DLC, L3G4IS, LSM330, LSM9DS0.
L3G4200D, LSM330DL, L3GD20, LSM330DLC, L3G4IS, LSM330, LSM9DS0,
LSM9DS1.
This driver can also be built as a module. If so, these modules
will be created:
......
......@@ -23,6 +23,7 @@
#define L3G4IS_GYRO_DEV_NAME "l3g4is_ui"
#define LSM330_GYRO_DEV_NAME "lsm330_gyro"
#define LSM9DS0_GYRO_DEV_NAME "lsm9ds0_gyro"
#define LSM9DS1_GYRO_DEV_NAME "lsm9ds1_gyro"
/**
* struct st_sensors_platform_data - gyro platform data
......
......@@ -56,6 +56,23 @@ static const struct iio_chan_spec st_gyro_16bit_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(3)
};
/* The LSM9DS1 uses different output registers that the other chips. */
static const struct iio_chan_spec st_gyro_lsm9ds1_16bit_channels[] = {
ST_SENSORS_LSM_CHANNELS(IIO_ANGL_VEL,
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 16, 16,
0x18),
ST_SENSORS_LSM_CHANNELS(IIO_ANGL_VEL,
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 16, 16,
0x1a),
ST_SENSORS_LSM_CHANNELS(IIO_ANGL_VEL,
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 16, 16,
0x1c),
IIO_CHAN_SOFT_TIMESTAMP(3)
};
static const struct st_sensor_settings st_gyro_sensors_settings[] = {
{
.wai = 0xd3,
......@@ -285,6 +302,84 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
.multi_read_bit = true,
.bootime = 2,
},
{
.wai = 0x68,
.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LSM9DS1_GYRO_DEV_NAME,
},
.ch = (struct iio_chan_spec *)st_gyro_lsm9ds1_16bit_channels,
.odr = {
.addr = 0x10,
.mask = 0xe0,
.odr_avl = {
{ .hz = 15, .value = 0x01, },
{ .hz = 60, .value = 0x02, },
{ .hz = 119, .value = 0x03, },
{ .hz = 238, .value = 0x04, },
{ .hz = 476, .value = 0x05, },
{ .hz = 952, .value = 0x06, },
},
},
.pw = {
.addr = 0x10,
.mask = 0xe0,
.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
},
.enable_axis = {
.addr = 0x1e,
.mask = 0x38,
},
.fs = {
.addr = 0x10,
.mask = 0x38,
.fs_avl = {
[0] = {
.num = ST_GYRO_FS_AVL_250DPS,
.value = 0x00,
.gain = IIO_DEGREE_TO_RAD(8750),
},
[1] = {
.num = ST_GYRO_FS_AVL_500DPS,
.value = 0x01,
.gain = IIO_DEGREE_TO_RAD(17500),
},
[2] = {
.num = ST_GYRO_FS_AVL_2000DPS,
/* 2 is "Not Available". */
.value = 0x03,
.gain = IIO_DEGREE_TO_RAD(70000),
},
},
},
.bdu = {
.addr = 0x22,
.mask = 0x40,
},
.drdy_irq = {
.int1 = {
.addr = 0x0c,
.mask = 0x02,
},
.int2 = {
.addr = 0x0d,
.mask = 0x02,
},
.addr_ihl = 0x22,
.mask_ihl = 0x20,
.stat_drdy = {
.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
.mask = 0x02,
},
},
.sim = {
.addr = 0x22,
.value = BIT(3),
},
.multi_read_bit = false,
.bootime = 2,
},
};
static int st_gyro_read_raw(struct iio_dev *indio_dev,
......
......@@ -56,6 +56,10 @@ static const struct of_device_id st_gyro_of_match[] = {
.compatible = "st,lsm9ds0-gyro",
.data = LSM9DS0_GYRO_DEV_NAME,
},
{
.compatible = "st,lsm9ds1-gyro",
.data = LSM9DS1_GYRO_DEV_NAME,
},
{},
};
MODULE_DEVICE_TABLE(of, st_gyro_of_match);
......@@ -104,6 +108,7 @@ static const struct i2c_device_id st_gyro_id_table[] = {
{ L3G4IS_GYRO_DEV_NAME },
{ LSM330_GYRO_DEV_NAME },
{ LSM9DS0_GYRO_DEV_NAME },
{ LSM9DS1_GYRO_DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(i2c, st_gyro_id_table);
......
......@@ -61,6 +61,10 @@ static const struct of_device_id st_gyro_of_match[] = {
.compatible = "st,lsm9ds0-gyro",
.data = LSM9DS0_GYRO_DEV_NAME,
},
{
.compatible = "st,lsm9ds1-gyro",
.data = LSM9DS1_GYRO_DEV_NAME,
},
{},
};
MODULE_DEVICE_TABLE(of, st_gyro_of_match);
......@@ -108,6 +112,7 @@ static const struct spi_device_id st_gyro_id_table[] = {
{ L3G4IS_GYRO_DEV_NAME },
{ LSM330_GYRO_DEV_NAME },
{ LSM9DS0_GYRO_DEV_NAME },
{ LSM9DS1_GYRO_DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(spi, st_gyro_id_table);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment